|
|
@@ -1,5 +1,6 @@
|
|
|
package com.uas.platform.b2c.prod.product.kind.service.impl;
|
|
|
|
|
|
+import com.uas.platform.b2c.core.support.SystemSession;
|
|
|
import com.uas.platform.b2c.prod.product.kind.dao.KindConcernDao;
|
|
|
import com.uas.platform.b2c.prod.product.kind.dao.KindDao;
|
|
|
import com.uas.platform.b2c.prod.product.kind.model.Kind;
|
|
|
@@ -190,4 +191,99 @@ public class KindConcernServiceImpl implements KindConcernService {
|
|
|
}, pageInfo);
|
|
|
return new Page<KindConcern>(kindConcernPage.getNumber(), kindConcernPage.getSize(), kindConcernPage.getContent(), (int) kindConcernPage.getTotalElements());
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * PC批量关注接口
|
|
|
+ *
|
|
|
+ * @param kinds 类目名称List
|
|
|
+ * @return 处理结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ModelMap addKindConcernByBatch(List<String> kinds) {
|
|
|
+ ModelMap map = new ModelMap();
|
|
|
+ try {
|
|
|
+ if (CollectionUtils.isEmpty(kinds)) {
|
|
|
+ map.put("success", false);
|
|
|
+ map.put("message", "传入参数为空");
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ List<KindConcern> kindConcerns = new ArrayList<>();
|
|
|
+ Date now = new Date();
|
|
|
+ Long enUU = SystemSession.getUser().getEnterprise().getUu();
|
|
|
+ // 成功
|
|
|
+ int count = 0;
|
|
|
+ // 已存在
|
|
|
+ int existed = 0;
|
|
|
+ // 已存在列表
|
|
|
+ List<String> existedList = new ArrayList<>();
|
|
|
+ map.put("all", kinds.size());
|
|
|
+ for (String name : kinds) {
|
|
|
+ KindConcern concern = kindConcernDao.findByNameCnAndEnUU(name, enUU);
|
|
|
+ if (null == concern) {
|
|
|
+ KindConcern kindConcern = new KindConcern();
|
|
|
+ kindConcern.setDate(now);
|
|
|
+ kindConcern.setEnUU(enUU);
|
|
|
+ kindConcern.setNameCn(name);
|
|
|
+ kindConcern.setStatus(Constant.YES);
|
|
|
+ kindConcerns.add(kindConcern);
|
|
|
+ count += 1;
|
|
|
+ } else {
|
|
|
+ existed += 1;
|
|
|
+ existedList.add(name);
|
|
|
+ concern.setStatus(Constant.YES);
|
|
|
+ kindConcerns.add(concern);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ map.put("existed", existed);
|
|
|
+ map.put("count", count);
|
|
|
+ map.put("existedList", existedList);
|
|
|
+ kindConcernDao.save(kindConcerns);
|
|
|
+ return map;
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ map.put("success", false);
|
|
|
+ map.put("message", e.getMessage());
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * PC批量取消关注接口
|
|
|
+ *
|
|
|
+ * @param ids 需要批量取消的类目id
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ModelMap deleteKindConcernByBatch(List<Long> ids) {
|
|
|
+ ModelMap map = new ModelMap();
|
|
|
+ try {
|
|
|
+ if (CollectionUtils.isEmpty(ids)) {
|
|
|
+ map.put("success", false);
|
|
|
+ map.put("message", "传入参数为空");
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ Long enUU = SystemSession.getUser().getEnterprise().getUu();
|
|
|
+ List<KindConcern> kindConcerns = kindConcernDao.findAll(ids);
|
|
|
+ if (CollectionUtils.isEmpty(kindConcerns)) {
|
|
|
+ map.put("success", false);
|
|
|
+ map.put("message", "未找到符合对应的类目关注记录");
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ for (KindConcern kindConcern : kindConcerns) {
|
|
|
+ if (!enUU.equals(kindConcern.getEnUU())) {
|
|
|
+ map.put("success", false);
|
|
|
+ map.put("message", "存在不属于当前企业的类目关注记录,无法删除");
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ map.put("count", kindConcerns.size());
|
|
|
+ kindConcernDao.delete(kindConcerns);
|
|
|
+ return map;
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ map.put("success", false);
|
|
|
+ map.put("message", e.getMessage());
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|