Переглянути джерело

派出所列表增加返回字段:管理员账号

renruixin 3 роки тому
батько
коміт
589b1407bc

+ 2 - 0
src/main/java/com/metro/entity/ro/Police/DetailPoliceResp.java

@@ -4,6 +4,7 @@ import com.metro.enums.UserEnums;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.Data;
+import lombok.experimental.Accessors;
 
 
 import java.time.LocalDateTime;
 import java.time.LocalDateTime;
 
 
@@ -17,6 +18,7 @@ import java.time.LocalDateTime;
  */
  */
 @Data
 @Data
 @ApiModel
 @ApiModel
+@Accessors(chain = true)
 public class DetailPoliceResp {
 public class DetailPoliceResp {
     @ApiModelProperty(value = "id")
     @ApiModelProperty(value = "id")
     private Integer id;
     private Integer id;

+ 3 - 0
src/main/java/com/metro/entity/ro/Police/SelectPolicePageResp.java

@@ -31,6 +31,9 @@ public class SelectPolicePageResp implements Serializable {
     @ApiModelProperty(value = "管理员姓名")
     @ApiModelProperty(value = "管理员姓名")
     private String userName;
     private String userName;
 
 
+    @ApiModelProperty(value = "账号")
+    private String account;
+
     @ApiModelProperty(value = "管理员手机号")
     @ApiModelProperty(value = "管理员手机号")
     private String phone;
     private String phone;
 
 

+ 8 - 5
src/main/java/com/metro/service/impl/PoliceServiceImpl.java

@@ -76,7 +76,7 @@ public class PoliceServiceImpl extends BaseService implements PoliceService {
             if (!CollectionUtils.isEmpty(collect)) {
             if (!CollectionUtils.isEmpty(collect)) {
                 Account account = collect.get(p.getId() + "");
                 Account account = collect.get(p.getId() + "");
                 if (ObjectUtil.isNotEmpty(account)) {
                 if (ObjectUtil.isNotEmpty(account)) {
-                    q.setCreateTime(account.getCreateTime()).setAddress(account.getAddress()).setPhone(account.getPhone()).setUserName(account.getUserName());
+                    q.setCreateTime(account.getCreateTime()).setAccount(account.getAccount()).setAddress(account.getAddress()).setPhone(account.getPhone()).setUserName(account.getUserName());
                 }
                 }
             }
             }
         }));
         }));
@@ -121,7 +121,7 @@ public class PoliceServiceImpl extends BaseService implements PoliceService {
         Company selectOne = companysMapper.selectOne(new LambdaQueryWrapper<Company>().eq(Company::getId, req.getId()));
         Company selectOne = companysMapper.selectOne(new LambdaQueryWrapper<Company>().eq(Company::getId, req.getId()));
         if (ObjectUtils.isEmpty(selectOne)) throw new BusinessException("未获取到派出所信息");
         if (ObjectUtils.isEmpty(selectOne)) throw new BusinessException("未获取到派出所信息");
         Police police = mapper.selectList(new LambdaQueryWrapper<Police>().eq(Police::getCompanyId, selectOne.getId()).eq(Police::getIsDelete, UserConstant.NOT_DELETE)).stream().findFirst().orElse(null);
         Police police = mapper.selectList(new LambdaQueryWrapper<Police>().eq(Police::getCompanyId, selectOne.getId()).eq(Police::getIsDelete, UserConstant.NOT_DELETE)).stream().findFirst().orElse(null);
-        return MapperManager.mapper(police, DetailPoliceResp.class, p -> p.setBranchName(ObjectUtil.isEmpty(selectOne.getBranchName()) ? null : selectOne.getBranchName()));
+        return MapperManager.mapper(police, DetailPoliceResp.class, p -> p.setId(selectOne.getId()).setBranchName(ObjectUtil.isEmpty(selectOne.getBranchName()) ? null : selectOne.getBranchName()));
     }
     }
 
 
     /*
     /*
@@ -132,12 +132,15 @@ public class PoliceServiceImpl extends BaseService implements PoliceService {
     public UpdatePoliceResp update(UpdatePoliceReq req) {
     public UpdatePoliceResp update(UpdatePoliceReq req) {
         if (getAccountInfo().getType() != 2) throw new BusinessException("非分局管理员不能修改!");
         if (getAccountInfo().getType() != 2) throw new BusinessException("非分局管理员不能修改!");
         Police account = mapper.selectOne(new LambdaQueryWrapper<Police>().eq(Police::getAccount, req.getAccount()).eq(Police::getIsDelete, UserConstant.NOT_DELETE));
         Police account = mapper.selectOne(new LambdaQueryWrapper<Police>().eq(Police::getAccount, req.getAccount()).eq(Police::getIsDelete, UserConstant.NOT_DELETE));
-        if (ObjectUtil.isEmpty(account)) throw new BusinessException(account.getAccount() + "不存在!不能修改");
+        if (ObjectUtil.isEmpty(account)) throw new BusinessException(req.getAccount() + "已经停用或者不存在!不能修改");
         int insert = mapper.update(MapperManager.mapper(req, Police.class, p -> p.setPassword(MD5UtilNew.string2MD5(req.getPassword())).setUpdateTime(LocalDateTime.now())), new LambdaQueryWrapper<Police>().eq(Police::getAccount, account.getAccount())
         int insert = mapper.update(MapperManager.mapper(req, Police.class, p -> p.setPassword(MD5UtilNew.string2MD5(req.getPassword())).setUpdateTime(LocalDateTime.now())), new LambdaQueryWrapper<Police>().eq(Police::getAccount, account.getAccount())
                 .eq(Police::getIsDelete, UserConstant.NOT_DELETE));
                 .eq(Police::getIsDelete, UserConstant.NOT_DELETE));
         if (insert == BigDecimal.ZERO.intValue()) throw new BusinessException("修改派出所管理员账号异常!");
         if (insert == BigDecimal.ZERO.intValue()) throw new BusinessException("修改派出所管理员账号异常!");
-        Company selectOne = companysMapper.selectOne(new LambdaQueryWrapper<Company>().eq(Company::getId, req.getId()).ne(Company::getBranchName, req.getBranchName()));
-        if (ObjectUtils.isEmpty(selectOne)) throw new BusinessException("派出所已经存在,请重新填写派所名");
+        Company selectOne = companysMapper.selectOne(new LambdaQueryWrapper<Company>().eq(Company::getId, req.getId()));
+        if (ObjectUtils.isEmpty(selectOne)) throw new BusinessException("没有该派出所");
+        List<Company> companies = companysMapper.selectList(new LambdaQueryWrapper<Company>().eq(Company::getCompanyId, selectOne.getCompanyId()));
+        long count = companies.stream().filter(p -> !p.getBranchName().equals(selectOne.getBranchName())).filter(p -> p.getBranchName().equals(req.getBranchName())).count();
+        if(count != BigDecimal.ZERO.longValue()) throw new BusinessException("派出所名称已经存在!请更改");
         int insert1 = companysMapper.updateById(new Company().setBranchName(req.getBranchName()).setId(req.getId()));
         int insert1 = companysMapper.updateById(new Company().setBranchName(req.getBranchName()).setId(req.getId()));
         if (insert1 == BigDecimal.ZERO.intValue()) throw new BusinessException("修改派出所失败!");
         if (insert1 == BigDecimal.ZERO.intValue()) throw new BusinessException("修改派出所失败!");
         return new UpdatePoliceResp().setCount(insert + insert1);
         return new UpdatePoliceResp().setCount(insert + insert1);