From 0ce924a6f41a53060f88267f54a8824d11c5153b Mon Sep 17 00:00:00 2001 From: buaixuexideshitongxue <2936013465@qq.com> Date: Fri, 12 Dec 2025 17:32:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=BA=E5=91=98=E6=81=A2=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/system/PoliceController.java | 43 +++++++++++----- .../supervision/mapper/SupPoliceMapper.java | 4 +- src/main/resources/mapper/SupPoliceMapper.xml | 51 +++++++++++++++++++ 3 files changed, 83 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/biutag/supervision/controller/system/PoliceController.java b/src/main/java/com/biutag/supervision/controller/system/PoliceController.java index 29fc147..391dd6a 100644 --- a/src/main/java/com/biutag/supervision/controller/system/PoliceController.java +++ b/src/main/java/com/biutag/supervision/controller/system/PoliceController.java @@ -15,6 +15,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.biutag.supervision.constants.AppConstants; +import com.biutag.supervision.mapper.SupPoliceMapper; import com.biutag.supervision.pojo.Result; import com.biutag.supervision.pojo.domain.PoliceAuth; import com.biutag.supervision.pojo.dto.PoliceDto; @@ -24,12 +25,14 @@ import com.biutag.supervision.pojo.entity.*; import com.biutag.supervision.pojo.model.PoliceModel; import com.biutag.supervision.pojo.param.PoliceQueryParam; import com.biutag.supervision.service.*; +import jakarta.annotation.Resource; import jakarta.validation.ConstraintViolation; import jakarta.validation.Valid; import jakarta.validation.Validator; import lombok.RequiredArgsConstructor; import org.apache.xmlbeans.UserType; import org.springframework.beans.BeanUtils; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -55,6 +58,9 @@ public class PoliceController { private final Validator validator; + @Resource + private SupPoliceMapper supPoliceMapper; + @GetMapping public Result> list(PoliceQueryParam param) { return Result.success(policeService.page(param)); @@ -73,6 +79,7 @@ public class PoliceController { } @PostMapping + @Transactional public Result add(@Valid @RequestBody PoliceDto policeDto) { SupPolice policeByEmpNo = policeService.getOne(new LambdaQueryWrapper().eq(SupPolice::getEmpNo, policeDto.getEmpNo())); if (Objects.nonNull(policeByEmpNo)) { @@ -84,20 +91,28 @@ public class PoliceController { SupDepart depart = departService.getById(one.getOrgId()); throw new RuntimeException(String.format("该人员[%s]已存在于“%s”单位中,请联系二级机构或市局管理员以进行人员调整。", policeDto.getIdCode(), depart.getName())); } - SupPolice police = new SupPolice(); - BeanUtils.copyProperties(policeDto, police); - police.setId(IdUtil.getSnowflakeNextIdStr()); - police.setUpdatedAt(DateUtil.format(new Date(), DatePattern.NORM_DATETIME_FORMAT)); - police.setCreatedAt(DateUtil.format(new Date(), DatePattern.NORM_DATETIME_FORMAT)); - policeService.save(police); - if (policeDto.getCreateUserFlag() && !userService.exists(new LambdaQueryWrapper().eq(BaseUser::getUserName, police.getIdCode()))) { - UserDto userDto = new UserDto(); - userDto.setUserName(police.getIdCode()); - userDto.setNickName(police.getName()); - userDto.setPassword(policeDto.getPassword()); - userDto.setUserType("normal"); - userDto.setRoleIds(new ArrayList<>()); - baseUserService.save(userDto); + SupPolice delPolice= supPoliceMapper.selectByIdCodeAndDel(policeDto.getIdCode(), AppConstants.DEL); + if (Objects.nonNull(delPolice)){ + delPolice.setOrgId(policeDto.getOrgId()); + delPolice.setDel(AppConstants.UN_DEL); + delPolice.setDelReason(""); + supPoliceMapper.updateIgnoreLogicDeleteById(delPolice); + }else { + SupPolice police = new SupPolice(); + BeanUtils.copyProperties(policeDto, police); + police.setId(IdUtil.getSnowflakeNextIdStr()); + police.setUpdatedAt(DateUtil.format(new Date(), DatePattern.NORM_DATETIME_FORMAT)); + police.setCreatedAt(DateUtil.format(new Date(), DatePattern.NORM_DATETIME_FORMAT)); + policeService.save(police); + if (policeDto.getCreateUserFlag() && !userService.exists(new LambdaQueryWrapper().eq(BaseUser::getUserName, police.getIdCode()))) { + UserDto userDto = new UserDto(); + userDto.setUserName(police.getIdCode()); + userDto.setNickName(police.getName()); + userDto.setPassword(policeDto.getPassword()); + userDto.setUserType("normal"); + userDto.setRoleIds(new ArrayList<>()); + baseUserService.save(userDto); + } } return Result.success(); } diff --git a/src/main/java/com/biutag/supervision/mapper/SupPoliceMapper.java b/src/main/java/com/biutag/supervision/mapper/SupPoliceMapper.java index bbd98fb..f9b96f3 100644 --- a/src/main/java/com/biutag/supervision/mapper/SupPoliceMapper.java +++ b/src/main/java/com/biutag/supervision/mapper/SupPoliceMapper.java @@ -23,4 +23,6 @@ public interface SupPoliceMapper extends BaseMapper { List getPeopleList(@Param("ids") List ids); -} + SupPolice selectByIdCodeAndDel(String idCode, String del); + + int updateIgnoreLogicDeleteById(@Param("p") SupPolice p);} diff --git a/src/main/resources/mapper/SupPoliceMapper.xml b/src/main/resources/mapper/SupPoliceMapper.xml index a663c28..408ffaa 100644 --- a/src/main/resources/mapper/SupPoliceMapper.xml +++ b/src/main/resources/mapper/SupPoliceMapper.xml @@ -67,4 +67,55 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + + UPDATE sup_police + + account_id = #{p.accountId}, + district_id = #{p.districtId}, + org_id = #{p.orgId}, + emp_no = #{p.empNo}, + job = #{p.job}, + job_type = #{p.jobType}, + manager_id = #{p.managerId}, + phone = #{p.phone}, + fax_no = #{p.faxNo}, + post_title = #{p.postTitle}, + work_address = #{p.workAddress}, + account = #{p.account}, + mobile = #{p.mobile}, + email = #{p.email}, + id_code = #{p.idCode}, + display_name = #{p.displayName}, + name = #{p.name}, + gender = #{p.gender}, + birthday = #{p.birthday}, + avatar_url = #{p.avatarUrl}, + status = #{p.status}, + hired_at = #{p.hiredAt}, + created_at = #{p.createdAt}, + type = #{p.type}, + person_status = #{p.personStatus}, + position = #{p.position}, + person_type = #{p.personType}, + marital_status = #{p.maritalStatus}, + have_children = #{p.haveChildren}, + education = #{p.education}, + employment_date = #{p.employmentDate}, + police_role = #{p.policeRole}, + sort_id = #{p.sortId}, + del = #{p.del}, + del_reason = #{p.delReason}, + updated_at = NOW() + + WHERE id = #{p.id} + +