Browse Source

人员恢复

master
buaixuexideshitongxue 2 months ago
parent
commit
0ce924a6f4
  1. 15
      src/main/java/com/biutag/supervision/controller/system/PoliceController.java
  2. 4
      src/main/java/com/biutag/supervision/mapper/SupPoliceMapper.java
  3. 51
      src/main/resources/mapper/SupPoliceMapper.xml

15
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<Page<PoliceModel>> list(PoliceQueryParam param) {
return Result.success(policeService.page(param));
@ -73,6 +79,7 @@ public class PoliceController {
}
@PostMapping
@Transactional
public Result<Boolean> add(@Valid @RequestBody PoliceDto policeDto) {
SupPolice policeByEmpNo = policeService.getOne(new LambdaQueryWrapper<SupPolice>().eq(SupPolice::getEmpNo, policeDto.getEmpNo()));
if (Objects.nonNull(policeByEmpNo)) {
@ -84,6 +91,13 @@ public class PoliceController {
SupDepart depart = departService.getById(one.getOrgId());
throw new RuntimeException(String.format("该人员[%s]已存在于“%s”单位中,请联系二级机构或市局管理员以进行人员调整。", policeDto.getIdCode(), depart.getName()));
}
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());
@ -99,6 +113,7 @@ public class PoliceController {
userDto.setRoleIds(new ArrayList<>());
baseUserService.save(userDto);
}
}
return Result.success();
}

4
src/main/java/com/biutag/supervision/mapper/SupPoliceMapper.java

@ -23,4 +23,6 @@ public interface SupPoliceMapper extends BaseMapper<SupPolice> {
List<People> getPeopleList(@Param("ids") List<String> ids);
}
SupPolice selectByIdCodeAndDel(String idCode, String del);
int updateIgnoreLogicDeleteById(@Param("p") SupPolice p);}

51
src/main/resources/mapper/SupPoliceMapper.xml

@ -67,4 +67,55 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
</where>
</select>
<select id="selectByIdCodeAndDel" resultType="com.biutag.supervision.pojo.entity.SupPolice">
SELECT *
FROM sup_police
WHERE id_code = #{idCode}
AND del = #{del}
</select>
<update id="updateIgnoreLogicDeleteById">
UPDATE sup_police
<set>
<if test="p.accountId != null">account_id = #{p.accountId},</if>
<if test="p.districtId != null">district_id = #{p.districtId},</if>
<if test="p.orgId != null">org_id = #{p.orgId},</if>
<if test="p.empNo != null">emp_no = #{p.empNo},</if>
<if test="p.job != null">job = #{p.job},</if>
<if test="p.jobType != null">job_type = #{p.jobType},</if>
<if test="p.managerId != null">manager_id = #{p.managerId},</if>
<if test="p.phone != null">phone = #{p.phone},</if>
<if test="p.faxNo != null">fax_no = #{p.faxNo},</if>
<if test="p.postTitle != null">post_title = #{p.postTitle},</if>
<if test="p.workAddress != null">work_address = #{p.workAddress},</if>
<if test="p.account != null">account = #{p.account},</if>
<if test="p.mobile != null">mobile = #{p.mobile},</if>
<if test="p.email != null">email = #{p.email},</if>
<if test="p.idCode != null">id_code = #{p.idCode},</if>
<if test="p.displayName != null">display_name = #{p.displayName},</if>
<if test="p.name != null">name = #{p.name},</if>
<if test="p.gender != null">gender = #{p.gender},</if>
<if test="p.birthday != null">birthday = #{p.birthday},</if>
<if test="p.avatarUrl != null">avatar_url = #{p.avatarUrl},</if>
<if test="p.status != null">status = #{p.status},</if>
<if test="p.hiredAt != null">hired_at = #{p.hiredAt},</if>
<if test="p.createdAt != null">created_at = #{p.createdAt},</if>
<if test="p.type != null">type = #{p.type},</if>
<if test="p.personStatus != null">person_status = #{p.personStatus},</if>
<if test="p.position != null">position = #{p.position},</if>
<if test="p.personType != null">person_type = #{p.personType},</if>
<if test="p.maritalStatus != null">marital_status = #{p.maritalStatus},</if>
<if test="p.haveChildren != null">have_children = #{p.haveChildren},</if>
<if test="p.education != null">education = #{p.education},</if>
<if test="p.employmentDate != null">employment_date = #{p.employmentDate},</if>
<if test="p.policeRole != null">police_role = #{p.policeRole},</if>
<if test="p.sortId != null">sort_id = #{p.sortId},</if>
<if test="p.del != null">del = #{p.del},</if>
<if test="p.delReason != null">del_reason = #{p.delReason},</if>
updated_at = NOW()
</set>
WHERE id = #{p.id}
</update>
</mapper>

Loading…
Cancel
Save