lyhzzz 9 月之前
父节点
当前提交
46d7f2c23d

+ 1 - 1
src/main/java/com/fdkankan/manage/common/ResultCode.java

@@ -84,7 +84,7 @@ public enum ResultCode  {
 
     TEMPLATE_EMPTY(60016, "模板数据为空"),
 
-
+    ID_CARD_EXIT(60017, "身份证号码已存在"),
     ;
 
     private Integer code;

+ 1 - 2
src/main/java/com/fdkankan/manage/controller/JyPlatformController.java

@@ -38,8 +38,7 @@ public class JyPlatformController {
 
     @PostMapping("/addOrUpdate")
     public ResultData addOrUpdate(@RequestBody JyPlatformVo param){
-        jyPlatformService.addOrUpdate(param);
-        return ResultData.ok();
+        return ResultData.ok(jyPlatformService.addOrUpdate(param));
     }
 
     @PostMapping("/del")

+ 1 - 1
src/main/java/com/fdkankan/manage/service/IJyPlatformService.java

@@ -17,7 +17,7 @@ public interface IJyPlatformService extends IService<JyPlatform> {
 
     Object pageList(JyPlatformParam param);
 
-    void addOrUpdate(JyPlatformVo param);
+    JyPlatform addOrUpdate(JyPlatformVo param);
 
     void del(JyPlatform param);
 

+ 16 - 1
src/main/java/com/fdkankan/manage/service/impl/JyPlatformServiceImpl.java

@@ -59,7 +59,7 @@ public class JyPlatformServiceImpl extends ServiceImpl<IJyPlatformMapper, JyPlat
     }
 
     @Override
-    public void addOrUpdate(JyPlatformVo param) {
+    public JyPlatform addOrUpdate(JyPlatformVo param) {
         if(StringUtils.isBlank(param.getPlatformName()) || StringUtils.isBlank(param.getName())
                 ||  StringUtils.isBlank(param.getIdCard())){
 
@@ -70,13 +70,22 @@ public class JyPlatformServiceImpl extends ServiceImpl<IJyPlatformMapper, JyPlat
         if(param.getId() == null){  //创建平台自动生成平台访问地址
             String uuid = UUID.randomUUID().toString().substring(0, 18).replace("-", "");
             param.setPlatformAddress(uuid);
+            jyPlatform = this.getByIdCard(param.getIdCard());
+            if(jyPlatform != null){
+                throw new BusinessException(ResultCode.ID_CARD_EXIT);
+            }
             jyPlatform = new JyPlatform();
             jyUserPlatform = new JyUserPlatform();
+
         }else {
             jyPlatform = this.getById(param.getId());
             if(jyPlatform == null){
                 throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
             }
+            JyPlatform jyPlatform2 = this.getByIdCard(param.getIdCard());
+            if(jyPlatform2 != null && !jyPlatform2.getId().equals(jyPlatform.getId())){
+                throw new BusinessException(ResultCode.ID_CARD_EXIT);
+            }
             jyUserPlatform = jyUserPlatformService.getByIdCard(jyPlatform.getIdCard());
         }
         BeanUtils.copyProperties(param,jyPlatform);
@@ -85,7 +94,13 @@ public class JyPlatformServiceImpl extends ServiceImpl<IJyPlatformMapper, JyPlat
         jyUserPlatform.setPlatformId(jyPlatform.getId());
         jyUserPlatformService.saveOrUpdate(jyUserPlatform);
 
+        return jyPlatform;
+    }
 
+    private JyPlatform getByIdCard(String idCard) {
+        LambdaQueryWrapper<JyPlatform> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(JyPlatform::getIdCard,idCard);
+        return this.getOne(wrapper);
     }
 
     @Override