Przeglądaj źródła

修改用户数据,没有时新增判定新增

anderx 1 rok temu
rodzic
commit
9a4312dbf8

+ 24 - 11
src/main/java/com/goafanti/customer/service/impl/UserArchivesServiceImpl.java

@@ -120,26 +120,39 @@ public class UserArchivesServiceImpl extends BaseMybatisDao< UserArchivesMapper>
      */
      */
     @Override
     @Override
     public UserArchives update(UserArchives userArchives) {
     public UserArchives update(UserArchives userArchives) {
+        if (userArchives.getAppearancePatentCount()!=null||
+            userArchives.getInventionPatentCount()!=null||
+                userArchives.getUtilityModelCount() !=null||
+                userArchives.getSoftwareWorksCount()!=null||
+                userArchives.getOtherCount()!=null
+        ){
+            int count = getCount(userArchives);
+            userArchives.setPatentCount(count);
+        }
+
+        if(userArchives.getId()==null){
+            return insert(userArchives);
+        }else {
+            this.userArchivesMapper.update(userArchives);
+            return this.queryById(userArchives.getId());
+        }
+    }
+
+    private int getCount(UserArchives userArchives) {
         int count = 0;
         int count = 0;
         if (userArchives.getAppearancePatentCount()!=null){
         if (userArchives.getAppearancePatentCount()!=null){
-            count+=userArchives.getAppearancePatentCount();
+            count+= userArchives.getAppearancePatentCount();
         }
         }
         if (userArchives.getInventionPatentCount()!=null){
         if (userArchives.getInventionPatentCount()!=null){
-            count+=userArchives.getInventionPatentCount();
+            count+= userArchives.getInventionPatentCount();
         }
         }
         if (userArchives.getUtilityModelCount() !=null){
         if (userArchives.getUtilityModelCount() !=null){
-            count+=userArchives.getUtilityModelCount();
+            count+= userArchives.getUtilityModelCount();
         }
         }
         if (userArchives.getOtherCount()!=null){
         if (userArchives.getOtherCount()!=null){
-            count+=userArchives.getOtherCount();
-        }
-        userArchives.setPatentCount(count);
-        if(userArchives.getId()==null){
-            return insert(userArchives);
-        }else {
-            this.userArchivesMapper.update(userArchives);
-            return this.queryById(userArchives.getId());
+            count+= userArchives.getOtherCount();
         }
         }
+        return count;
     }
     }
 
 
     /**
     /**