From 2aeccffe1bc9b04964ee8dcc82b2c1af7993ce1f Mon Sep 17 00:00:00 2001 From: mash Date: Thu, 9 Feb 2023 11:14:50 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=BA=BA=E5=91=98=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../staff/controller/PersonnelController.java | 10 ++++- .../staff/request/PersonnelDeleteRequest.java | 2 +- .../staff/service/IPersonnelService.java | 1 + .../service/impl/ExchangeServiceImpl.java | 19 ++++----- .../service/impl/PersonnelServiceImpl.java | 41 ++++++++++--------- 5 files changed, 41 insertions(+), 32 deletions(-) diff --git a/src/main/java/com/ydool/staff/controller/PersonnelController.java b/src/main/java/com/ydool/staff/controller/PersonnelController.java index 0f7954a..fdd8d07 100644 --- a/src/main/java/com/ydool/staff/controller/PersonnelController.java +++ b/src/main/java/com/ydool/staff/controller/PersonnelController.java @@ -7,6 +7,7 @@ import com.ydool.common.constant.UrlConstant; import com.ydool.common.data.dto.AjaxResult; import com.ydool.common.utils.UploadUtils; import com.ydool.staff.dto.PersonnelDto; +import com.ydool.staff.dto.PersonnelUpdateDto; import com.ydool.staff.entity.Attachment; import com.ydool.staff.entity.SelectRequest; import com.ydool.staff.request.ChangeRequest; @@ -43,7 +44,7 @@ public class PersonnelController extends BaseController { IAttachmentService attachmentService; @PostMapping( "personnelList") - @ApiOperation(value = "人员列表,传id查一条",response = PersonnelDto.class) + @ApiOperation(value = "人员列表",response = PersonnelDto.class) @ApiImplicitParams({ @ApiImplicitParam(name = "orderBy", value = "排序顺序 降序:desc,升序:asc"), @ApiImplicitParam(name = "column", value = "排序字段 字段名"), @@ -53,6 +54,13 @@ public class PersonnelController extends BaseController { return personnelService.personnelList(getPage(),request,orderBy,column); } + @GetMapping("getById") + @ApiOperation(value = "查询一条",response = PersonnelUpdateDto.class) + @ApiImplicitParam(name = "id",value = "id" ) + public AjaxResult getById(String id){ + return personnelService.getById(id); + } + @PostMapping(value = "savePersonnel") @ApiOperation(value = "新增人员申报",response = PersonnelRequest.class) public AjaxResult savePersonnel(@Validated @RequestBody PersonnelRequest personnelRequest){ diff --git a/src/main/java/com/ydool/staff/request/PersonnelDeleteRequest.java b/src/main/java/com/ydool/staff/request/PersonnelDeleteRequest.java index 364089f..16adc4e 100644 --- a/src/main/java/com/ydool/staff/request/PersonnelDeleteRequest.java +++ b/src/main/java/com/ydool/staff/request/PersonnelDeleteRequest.java @@ -13,5 +13,5 @@ import java.util.List; @Data public class PersonnelDeleteRequest { @ApiModelProperty(value = "id") - private List ids; + private String[] ids; } diff --git a/src/main/java/com/ydool/staff/service/IPersonnelService.java b/src/main/java/com/ydool/staff/service/IPersonnelService.java index 69883f6..4a5f3c9 100644 --- a/src/main/java/com/ydool/staff/service/IPersonnelService.java +++ b/src/main/java/com/ydool/staff/service/IPersonnelService.java @@ -25,6 +25,7 @@ public interface IPersonnelService { */ AjaxResult personnelList(Page page , SelectRequest request, String orderBy,String column); + AjaxResult getById(String id); AjaxResult personnelByExchangeList(); /** diff --git a/src/main/java/com/ydool/staff/service/impl/ExchangeServiceImpl.java b/src/main/java/com/ydool/staff/service/impl/ExchangeServiceImpl.java index 43c723c..49db24c 100644 --- a/src/main/java/com/ydool/staff/service/impl/ExchangeServiceImpl.java +++ b/src/main/java/com/ydool/staff/service/impl/ExchangeServiceImpl.java @@ -2,6 +2,7 @@ package com.ydool.staff.service.impl; import cn.dev33.satoken.stp.StpUtil; import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -29,6 +30,7 @@ import org.thymeleaf.util.StringUtils; import javax.annotation.Resource; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; @@ -96,17 +98,14 @@ public class ExchangeServiceImpl extends BaseService i @Override @Transactional(rollbackFor = Exception.class) - public AjaxResult deleteExchangeById(PersonnelDeleteRequest request) { - List ids = request.getIds(); - boolean flag = false; - if (1 asList = Arrays.asList(ids.getIds()); + if (CollectionUtil.isEmpty(asList)) { + return AjaxResult.fail().msg("Id不能为空!"); + } else { + int i = personnelMapper.deleteBatchIds(asList); + return i > 0 ? AjaxResult.ok().msg("删除成功!") : AjaxResult.fail().msg("删除失败!"); } - flag = removeById(ids.get(0)); - return flag?AjaxResult.ok().msg("删除成功!"):AjaxResult.fail().msg("删除失败!"); } } diff --git a/src/main/java/com/ydool/staff/service/impl/PersonnelServiceImpl.java b/src/main/java/com/ydool/staff/service/impl/PersonnelServiceImpl.java index ef6e3b6..da5792a 100644 --- a/src/main/java/com/ydool/staff/service/impl/PersonnelServiceImpl.java +++ b/src/main/java/com/ydool/staff/service/impl/PersonnelServiceImpl.java @@ -77,16 +77,6 @@ public class PersonnelServiceImpl extends BaseService ids = personnelDeleteRequest.getIds(); - boolean flag = false; - if (1 asList = Arrays.asList(ids.getIds()); + if (CollectionUtil.isEmpty(asList)) { + return AjaxResult.fail().msg("Id不能为空!"); + } else { + int i = personnelMapper.deleteBatchIds(asList); + return i > 0 ? AjaxResult.ok().msg("删除成功!") : AjaxResult.fail().msg("删除失败!"); } - flag = removeById(ids.get(0)); - return flag?AjaxResult.ok().msg("删除成功!"):AjaxResult.fail().msg("删除失败!"); } @Override