فهرست منبع

添加人员,日志

zhaoxian 4 سال پیش
والد
کامیت
d0bee04887

+ 25 - 4
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/CollectionSlogansServiceImpl.java

@@ -30,14 +30,16 @@ public class CollectionSlogansServiceImpl extends ServiceImpl<CollectionSlogansM
         CollectionSlogans co = new CollectionSlogans();
         String userId = requestJson.getString("userId");
         Long accountId = requestJson.getLong("accountId");
-        if (!Check.isNull(requestJson.getJSONArray("coverSlogansList"))) {
+        JSONArray coverSlogansList = requestJson.getJSONArray("coverSlogansList");
+        JSONArray captionsList = requestJson.getJSONArray("captionsList");
+        if (!Check.isNull(coverSlogansList)) {
             //封面广告语
             co.setType(NoEn.NO1.valueStr());
-            co.setValue(requestJson.getJSONArray("coverSlogansList").toString());
+            co.setValue(coverSlogansList.toString());
         }
-        if (!Check.isNull(requestJson.getJSONArray("captionsList"))) {
+        if (!Check.isNull(captionsList)) {
             co.setType(NoEn.NO2.valueStr());
-            co.setValue(requestJson.getJSONArray("captionsList").toString());
+            co.setValue(captionsList.toString());
         }
         co.setAccountId(accountId);
         co.setUserId(userId);
@@ -45,6 +47,25 @@ public class CollectionSlogansServiceImpl extends ServiceImpl<CollectionSlogansM
         if (!Check.isNull(slogansJson)) {
             QueryWrapper<CollectionSlogans> queryWrapper = new QueryWrapper<>();
             queryWrapper.eq("id", slogansJson.getInteger("id"));
+            //如果入参中type为delete,则只做修改操作,否则需要判断已有数据和入参数据不能重复
+            if (!"delete".equals(requestJson.getString("type"))) {
+                JSONArray value = slogansJson.getJSONArray("value");
+                if (NoEn.NO1.valueStr().equals(co.getType())) {
+                    for (int i = 0; i < coverSlogansList.size(); i++) {
+                        if (!value.contains(coverSlogansList.get(i))) {
+                            value.add(coverSlogansList.get(i));
+                        }
+                    }
+                    co.setValue(value.toString());
+                } else {
+                    for (int i = 0; i < captionsList.size(); i++) {
+                        if (!value.contains(captionsList.get(i))) {
+                            value.add(captionsList.get(i));
+                        }
+                    }
+                    co.setValue(value.toString());
+                }
+            }
             collectionSlogansMapper.update(co, queryWrapper);
         } else {
             collectionSlogansMapper.insert(co);