Browse Source

商机关注新增合并接口

liusw 7 years ago
parent
commit
6665e4d0f2

+ 13 - 8
src/main/java/com/uas/platform/b2c/prod/product/kind/controller/KindConcernController.java

@@ -1,7 +1,11 @@
 package com.uas.platform.b2c.prod.product.kind.controller;
 
+import com.uas.platform.b2c.common.account.model.User;
+import com.uas.platform.b2c.core.support.SystemSession;
+import com.uas.platform.b2c.fa.payment.utils.StringUtils;
 import com.uas.platform.b2c.prod.product.kind.model.KindConcern;
 import com.uas.platform.b2c.prod.product.kind.service.KindConcernService;
+import com.uas.platform.core.exception.IllegalOperatorException;
 import com.uas.platform.core.model.Constant;
 import com.uas.platform.core.model.PageParams;
 import com.uas.sso.support.Page;
@@ -57,6 +61,7 @@ public class KindConcernController {
     @RequestMapping(value = "/list", method = RequestMethod.GET)
     public Page<KindConcern> getConcernKindByPage(PageParams pageParams, String keyword, Long enUU, String type) {
         if (HAS_CONCERN.equals(type)) {
+            return kindConcernService.getConcernKindByPage(pageParams, keyword, enUU);
         } else if (NOT_CONCERN.equals(type)) {
             return kindConcernService.getNotConcernKindByPage(pageParams, keyword, enUU);
         }
@@ -82,16 +87,16 @@ public class KindConcernController {
      */
     @RequestMapping(value = "/modify", method = RequestMethod.POST)
     public ModelMap addKindConcern(@RequestBody KindConcern kindConcern) {
-        // status 为0,说明是未关注类目
-        if (Constant.NO == kindConcern.getStatus()) {
-            return kindConcernService.addKindConcern(kindConcern);
-        } else if (Constant.YES == kindConcern.getStatus()) {
+        if (kindConcern != null && kindConcern.getId() != null) {
             return kindConcernService.deleteKindConcern(kindConcern);
         }
-        ModelMap map = new ModelMap();
-        map.put("success", false);
-        map.put("message", "参数错误");
-        return map;
+        User user = SystemSession.getUser();
+        if (user != null && user.getEnterprise() != null) {
+            kindConcern.setEnUU(user.getEnterprise().getUu());
+        } else {
+            throw new IllegalOperatorException("用户信息错误");
+        }
+        return kindConcernService.addKindConcern(kindConcern);
     }
 
     /**

+ 1 - 1
src/main/java/com/uas/platform/b2c/prod/product/kind/model/KindConcern.java

@@ -59,7 +59,7 @@ public class KindConcern {
      * 关注状态 (1已关注 0 未关注)
      */
     @Column(name = "kc_status")
-    private Short status = 1;
+    private Short status;
 
     /**
      * 最近更新时间

+ 15 - 15
src/main/java/com/uas/platform/b2c/prod/product/kind/service/impl/KindConcernServiceImpl.java

@@ -94,26 +94,26 @@ public class KindConcernServiceImpl implements KindConcernService {
     public ModelMap deleteKindConcern(KindConcern kindConcern) {
         ModelMap map = new ModelMap();
         try {
-            if (null == kindConcern) {
-                map.put("success", false);
-                map.put("message", "传入参数为空");
-                return map;
-            }
+//            if (null == kindConcern) {
+//                map.put("success", false);
+//                map.put("message", "传入参数为空");
+//                return map;
+//            }
             if (null == kindConcern.getId()) {
                 map.put("success", false);
                 map.put("message", "传入id为空");
                 return map;
             }
-            if (null == kindConcern.getEnUU()) {
-                map.put("success", false);
-                map.put("message", "传入企业为空");
-                return map;
-            }
-            if (StringUtils.isEmpty(kindConcern.getNameCn())) {
-                map.put("success", false);
-                map.put("message", "传入物料名称(类目)为空");
-                return map;
-            }
+//            if (null == kindConcern.getEnUU()) {
+//                map.put("success", false);
+//                map.put("message", "传入企业为空");
+//                return map;
+//            }
+//            if (StringUtils.isEmpty(kindConcern.getNameCn())) {
+//                map.put("success", false);
+//                map.put("message", "传入物料名称(类目)为空");
+//                return map;
+//            }
             KindConcern concern = kindConcernDao.findOne(kindConcern.getId());
             if (null != concern) {
                 kindConcernDao.delete(concern);