Sfoglia il codice sorgente

商机关注新增合并接口

liusw 7 anni fa
parent
commit
5b918e4a6d

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

@@ -57,13 +57,24 @@ public class KindConcernController {
     @RequestMapping(value = "/list", method = RequestMethod.GET)
     @RequestMapping(value = "/list", method = RequestMethod.GET)
     public Page<KindConcern> getConcernKindByPage(PageParams pageParams, String keyword, Long enUU, String type) {
     public Page<KindConcern> getConcernKindByPage(PageParams pageParams, String keyword, Long enUU, String type) {
         if (HAS_CONCERN.equals(type)) {
         if (HAS_CONCERN.equals(type)) {
-            return kindConcernService.getConcernKindByPage(pageParams, keyword, enUU);
         } else if (NOT_CONCERN.equals(type)) {
         } else if (NOT_CONCERN.equals(type)) {
             return kindConcernService.getNotConcernKindByPage(pageParams, keyword, enUU);
             return kindConcernService.getNotConcernKindByPage(pageParams, keyword, enUU);
         }
         }
         return null;
         return null;
     }
     }
 
 
+    /**
+     * 获取所有的类目信息包括已关注和未关注
+     * @param pageParams
+     * @param keyword
+     * @param enUU
+     * @return
+     */
+    @RequestMapping(value = "/kindList", method = RequestMethod.GET)
+    public Page<KindConcern> getKindByPage(PageParams pageParams, String keyword, Long enUU) {
+        return kindConcernService.getKindByPage(pageParams, keyword, enUU);
+    }
+
     /**
     /**
      * 设置关注、取消关注接口
      * 设置关注、取消关注接口
      * @param kindConcern  类目关注实体
      * @param kindConcern  类目关注实体

+ 8 - 0
src/main/java/com/uas/platform/b2c/prod/product/kind/service/KindConcernService.java

@@ -59,4 +59,12 @@ public interface KindConcernService {
      * @return 结果
      * @return 结果
      */
      */
     ModelMap deleteKindConcernByBatch(List<Long> ids);
     ModelMap deleteKindConcernByBatch(List<Long> ids);
+
+    /**
+     * 获取所有的类目信息包括已关注和未关注
+     * @param pageParams
+     * @param keyword
+     * @return
+     */
+    Page<KindConcern> getKindByPage(PageParams pageParams, String keyword, Long enUU);
 }
 }

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

@@ -14,6 +14,8 @@ import com.uas.sso.support.Page;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Sort;
 import org.springframework.data.domain.Sort;
 import org.springframework.data.jpa.domain.Specification;
 import org.springframework.data.jpa.domain.Specification;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
+import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import org.springframework.ui.ModelMap;
 import org.springframework.ui.ModelMap;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.CollectionUtils;
@@ -23,9 +25,7 @@ import javax.persistence.criteria.CriteriaBuilder;
 import javax.persistence.criteria.CriteriaQuery;
 import javax.persistence.criteria.CriteriaQuery;
 import javax.persistence.criteria.Predicate;
 import javax.persistence.criteria.Predicate;
 import javax.persistence.criteria.Root;
 import javax.persistence.criteria.Root;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 
 
 /**
 /**
  * 类目接口实现
  * 类目接口实现
@@ -42,6 +42,9 @@ public class KindConcernServiceImpl implements KindConcernService {
     @Autowired
     @Autowired
     private KindDao kindDao;
     private KindDao kindDao;
 
 
+    @Autowired
+    private NamedParameterJdbcTemplate jdbcTemplate;
+
 
 
     /**
     /**
      * 添加关注
      * 添加关注
@@ -288,4 +291,22 @@ public class KindConcernServiceImpl implements KindConcernService {
             return map;
             return map;
         }
         }
     }
     }
+
+    @Override
+    public Page<KindConcern> getKindByPage(PageParams pageParams, String keyword, Long enUU) {
+        Map<String, Object> params = new HashMap<>();
+        String sql = "select ki_name as nameCn, kc_id as id, kc_date as date,kc_enuu as enUU, kc_name_en as nameEn, kc_status as status " +
+                "from (select ki_name from product$kind) a left join (select * from product$kind_concern where kc_enuu = :enUU) b on a.ki_name = b.kc_name ";
+        params.put("enUU", enUU);
+        if (!StringUtils.isEmpty(keyword)) {
+            sql += " where ki_name LIKE '%' :keyword '%' ";
+            params.put("keyword", keyword);
+        }
+        sql += " order by status desc limit :start,:pageSize;";
+        PageInfo pageInfo = new PageInfo(pageParams);
+        params.put("start", pageInfo.getOffset());
+        params.put("pageSize", pageInfo.getPageSize());
+        List<KindConcern> kindConcerns = jdbcTemplate.query(sql, params, new BeanPropertyRowMapper<>(KindConcern.class));
+        return new Page<KindConcern>(pageInfo.getPageNumber(), pageInfo.getPageSize(), kindConcerns, 0);
+    }
 }
 }