|
|
|
|
@ -3,23 +3,26 @@ package com.biutag.supervision.controller.system;
|
|
|
|
|
import cn.hutool.core.date.DatePattern; |
|
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
|
import cn.hutool.core.util.IdUtil; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
|
import com.biutag.supervision.pojo.Result; |
|
|
|
|
import com.biutag.supervision.pojo.domain.PoliceAuth; |
|
|
|
|
import com.biutag.supervision.pojo.entity.NegDepartAuthority; |
|
|
|
|
import com.biutag.supervision.pojo.entity.NegSourceAuthority; |
|
|
|
|
import com.biutag.supervision.pojo.entity.SupDepart; |
|
|
|
|
import com.biutag.supervision.pojo.entity.SupPolice; |
|
|
|
|
import com.biutag.supervision.pojo.model.PoliceModel; |
|
|
|
|
import com.biutag.supervision.pojo.param.PoliceQueryParam; |
|
|
|
|
import com.biutag.supervision.service.NegDepartAuthorityService; |
|
|
|
|
import com.biutag.supervision.service.NegSourceAuthorityService; |
|
|
|
|
import com.biutag.supervision.service.SupDepartService; |
|
|
|
|
import com.biutag.supervision.service.SupPoliceService; |
|
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
|
import java.util.Date; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Objects; |
|
|
|
|
|
|
|
|
|
@RequestMapping("police") |
|
|
|
|
@RequiredArgsConstructor |
|
|
|
|
@ -28,6 +31,8 @@ public class PoliceController {
|
|
|
|
|
|
|
|
|
|
private final SupPoliceService policeService; |
|
|
|
|
|
|
|
|
|
private final SupDepartService departService; |
|
|
|
|
|
|
|
|
|
private final NegDepartAuthorityService negDepartAuthorityService; |
|
|
|
|
|
|
|
|
|
private final NegSourceAuthorityService negSourceAuthorityService; |
|
|
|
|
@ -39,6 +44,16 @@ public class PoliceController {
|
|
|
|
|
|
|
|
|
|
@PostMapping |
|
|
|
|
public Result<Boolean> add(@RequestBody SupPolice police) { |
|
|
|
|
SupPolice policeByEmpNo = policeService.getOne(new LambdaQueryWrapper<SupPolice>().eq(SupPolice::getEmpNo, police.getEmpNo())); |
|
|
|
|
if (Objects.nonNull(policeByEmpNo)) { |
|
|
|
|
SupDepart depart = departService.getById(policeByEmpNo.getOrgId()); |
|
|
|
|
throw new RuntimeException(String.format("该人员[%s]已存在于“%s”单位中,请联系二级机构或市局管理员以进行人员调整。", police.getEmpNo(), depart.getName())); |
|
|
|
|
} |
|
|
|
|
SupPolice one = policeService.getOne(new LambdaQueryWrapper<SupPolice>().eq(SupPolice::getIdCode, police.getIdCode())); |
|
|
|
|
if (Objects.nonNull(one)) { |
|
|
|
|
SupDepart depart = departService.getById(one.getOrgId()); |
|
|
|
|
throw new RuntimeException(String.format("该人员[%s]已存在于“%s”单位中,请联系二级机构或市局管理员以进行人员调整。", police.getIdCode(), depart.getName())); |
|
|
|
|
} |
|
|
|
|
police.setId(IdUtil.getSnowflakeNextIdStr()); |
|
|
|
|
police.setUpdatedAt(DateUtil.format(new Date(), DatePattern.NORM_DATETIME_FORMAT)); |
|
|
|
|
police.setCreatedAt(DateUtil.format(new Date(), DatePattern.NORM_DATETIME_FORMAT)); |
|
|
|
|
@ -47,6 +62,16 @@ public class PoliceController {
|
|
|
|
|
|
|
|
|
|
@PutMapping |
|
|
|
|
public Result<Boolean> update(@RequestBody SupPolice police) { |
|
|
|
|
SupPolice policeByEmpNo = policeService.getOne(new LambdaQueryWrapper<SupPolice>().eq(SupPolice::getEmpNo, police.getEmpNo()).ne(SupPolice::getId, police.getId())); |
|
|
|
|
if (Objects.nonNull(policeByEmpNo)) { |
|
|
|
|
SupDepart depart = departService.getById(policeByEmpNo.getOrgId()); |
|
|
|
|
throw new RuntimeException(String.format("该人员[%s]已存在于“%s”单位中,请联系二级机构或市局管理员以进行人员调整。", police.getEmpNo(), depart.getName())); |
|
|
|
|
} |
|
|
|
|
SupPolice one = policeService.getOne(new LambdaQueryWrapper<SupPolice>().eq(SupPolice::getIdCode, police.getIdCode()).ne(SupPolice::getId, police.getId())); |
|
|
|
|
if (Objects.nonNull(one)) { |
|
|
|
|
SupDepart depart = departService.getById(one.getOrgId()); |
|
|
|
|
throw new RuntimeException(String.format("该人员[%s]已存在于“%s”单位中,请联系二级机构或市局管理员以进行人员调整。", police.getIdCode(), depart.getName())); |
|
|
|
|
} |
|
|
|
|
police.setUpdatedAt(DateUtil.format(new Date(), DatePattern.NORM_DATETIME_FORMAT)); |
|
|
|
|
return Result.success(policeService.updateById(police)); |
|
|
|
|
} |
|
|
|
|
|