浏览代码

代码优化

Zhaops 6 年之前
父节点
当前提交
e387b7c0b2
共有 1 个文件被更改,包括 14 次插入17 次删除
  1. 14 17
      icssman-service/src/main/java/com/diagbot/facade/IntroduceInfoFacade.java

+ 14 - 17
icssman-service/src/main/java/com/diagbot/facade/IntroduceInfoFacade.java

@@ -64,22 +64,20 @@ public class IntroduceInfoFacade extends IntroduceInfoServiceImpl {
      */
     public Boolean saveIntroduce(IntroduceVO introduceVO) {
         IntroduceInfo introduceInfo = new IntroduceInfo();
-        if (!(introduceVO.getId() == null || introduceInfo.getId().equals(0))) {
+        Date now = DateUtil.now();
+        String userId = UserUtils.getCurrentPrincipleID();
+        if (!(introduceVO.getId() == null || introduceVO.getId().equals(0))) {
             introduceInfo = this.getById(introduceVO.getId());
             if (introduceInfo == null) {
                 throw new CommonException(CommonErrorCode.NOT_EXISTS, "提示信息不存在");
             } else if (introduceInfo.getIsDeleted().equals(IsDeleteEnum.Y.getKey())) {
                 throw new CommonException(CommonErrorCode.NOT_EXISTS, "提示信息已删除");
-            } else {
-                introduceInfo.setModifier(UserUtils.getCurrentPrincipleID());
-                introduceInfo.setGmtModified(DateUtil.now());
             }
+        } else {
+            introduceInfo.setCreator(userId);
+            introduceInfo.setGmtCreate(now);
         }
 
-        Date now = DateUtil.now();
-        String userId = UserUtils.getCurrentPrincipleID();
-        introduceInfo.setCreator(userId);
-        introduceInfo.setGmtCreate(now);
         introduceInfo.setModifier(userId);
         introduceInfo.setGmtModified(now);
         introduceInfo.setName(introduceVO.getName());
@@ -90,15 +88,14 @@ public class IntroduceInfoFacade extends IntroduceInfoServiceImpl {
 
         //明细信息不更新,每次都删除重新插入
         //删除已有明细,逻辑删除
-        if (!(introduceInfo.getId() == null)) {
-            UpdateWrapper<IntroduceDetail> detailUpdateWrapper = new UpdateWrapper<>();
-            detailUpdateWrapper.eq("introduce_id", introduceInfo.getId()).
-                    eq("is_deleted", IsDeleteEnum.N.getKey()).
-                    set("is_deleted", IsDeleteEnum.Y.getKey()).
-                    set("modifier", UserUtils.getCurrentPrincipleID()).
-                    set("gmt_modified", DateUtil.now());
-            introduceDetailFacade.update(new IntroduceDetail(), detailUpdateWrapper);
-        }
+        UpdateWrapper<IntroduceDetail> detailUpdateWrapper = new UpdateWrapper<>();
+        detailUpdateWrapper.eq("introduce_id", introduceInfo.getId()).
+                eq("is_deleted", IsDeleteEnum.N.getKey()).
+                set("is_deleted", IsDeleteEnum.Y.getKey()).
+                set("modifier", userId).
+                set("gmt_modified", now);
+        introduceDetailFacade.update(new IntroduceDetail(), detailUpdateWrapper);
+
         List<IntroduceDetail> introduceDetailList = Lists.newArrayList();
         for (IntroduceDetailVO detailVO : introduceVO.getDetailVOList()) {
             IntroduceDetail detail = new IntroduceDetail();