zhijiezhao 3 lat temu
rodzic
commit
66ab91a7ba

+ 5 - 4
src/main/java/com/caimei365/commodity/controller/SearchProductApi.java

@@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.RestController;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 /**
  * 搜索商品(阿里云搜索)
@@ -43,10 +44,10 @@ public class SearchProductApi {
             @ApiImplicitParam(required = false, name = "identity", value = "用户身份: 0个人,1协销,2会员机构,3供应商,4普通机构")
     })
     @GetMapping("/brand")
-    public ResponseJson<List<HashMap<String, Object>>> queryBrand(String keyword, Integer id, Integer idType,
-                                                                  @RequestParam(value = "newFlag", defaultValue = "0") Integer newFlag,
-                                                                  @RequestParam(value = "promotionFlag", defaultValue = "0") Integer promotionFlag,
-                                                                  @RequestParam(value = "identity", defaultValue = "0") Integer identity) {
+    public ResponseJson<Set<HashMap<String, Object>>> queryBrand(String keyword, Integer id, Integer idType,
+                                                                 @RequestParam(value = "newFlag", defaultValue = "0") Integer newFlag,
+                                                                 @RequestParam(value = "promotionFlag", defaultValue = "0") Integer promotionFlag,
+                                                                 @RequestParam(value = "identity", defaultValue = "0") Integer identity) {
         return searchProductService.queryBrand(keyword, id, idType, newFlag, promotionFlag, identity);
     }
 

+ 2 - 1
src/main/java/com/caimei365/commodity/service/SearchProductService.java

@@ -6,6 +6,7 @@ import com.caimei365.commodity.model.po.SearchHistoryPo;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 /**
  * Description
@@ -89,5 +90,5 @@ public interface SearchProductService {
      */
     ResponseJson<Map<String, Object>> getHotSearchTerms();
 
-    ResponseJson<List<HashMap<String, Object>>> queryBrand(String keyword, Integer id, Integer idType,Integer newFlag ,Integer promotionFlag, Integer identity);
+    ResponseJson<Set<HashMap<String, Object>>> queryBrand(String keyword, Integer id, Integer idType, Integer newFlag , Integer promotionFlag, Integer identity);
 }

+ 5 - 5
src/main/java/com/caimei365/commodity/service/impl/SearchProductServiceImpl.java

@@ -105,7 +105,7 @@ public class SearchProductServiceImpl implements SearchProductService {
 
 
     @Override
-    public ResponseJson<List<HashMap<String, Object>>> queryBrand(String keyword, Integer id, Integer idType, Integer newFlag, Integer promotionFlag, Integer identity) {
+    public ResponseJson<Set<HashMap<String, Object>>> queryBrand(String keyword, Integer id, Integer idType, Integer newFlag, Integer promotionFlag, Integer identity) {
         String queryStr = "";
         String filter = "";
         if (!StringUtils.isEmpty(keyword) && idType == null && id == null) {
@@ -144,15 +144,15 @@ public class SearchProductServiceImpl implements SearchProductService {
             filter += "AND p_promotions_id > 0";
         }
         SearchParams searchParams = searchOpenService.getParams(queryStr, identity, filter);
-        ResponseJson<List<HashMap<String, Object>>> result = getBrandResult(searchParams, queryStr);
+        ResponseJson<Set<HashMap<String, Object>>> result = getBrandResult(searchParams, queryStr);
         return result;
     }
 
-    private ResponseJson<List<HashMap<String, Object>>> getBrandResult(SearchParams searchParams, String queryStr) {
-        ResponseJson<List<HashMap<String, Object>>> result;
+    private ResponseJson<Set<HashMap<String, Object>>> getBrandResult(SearchParams searchParams, String queryStr) {
+        ResponseJson<Set<HashMap<String, Object>>> result;
         try {
             JSONObject resultJson = searchOpenService.getResultJsonObject(queryStr, searchParams);
-            List<HashMap<String, Object>> maps = new ArrayList<>();
+            Set<HashMap<String, Object>> maps = new HashSet<>();
             if (1 == resultJson.getInt("status")) {
                 JSONArray pageData = resultJson.getJSONArray("items");
                 for (int i = 0; i < pageData.length(); i++) {

+ 2 - 2
src/main/resources/mapper/SearchMapper.xml

@@ -14,7 +14,7 @@
         p.unit as p_unit,
         p.sellNumber as p_sales,
         p.favoriteTimes as p_favorite,
-        p.brandID as p_brand_id,
+        br.id as p_brand_id,
         br.name as p_brand_name,
         p.shopID as p_supplier_id,
         sh.name as p_supplier_name,
@@ -38,7 +38,7 @@
         left join smalltype as s on p.smallTypeID = s.smallTypeID
         left join bigtype as b on p.bigTypeID = b.bigTypeID
         left join cm_products_classify as c on p.classifyId = c.id
-        left join cm_brand as br on p.brandID = br.id
+        right join cm_brand as br on p.brandID = br.id
         left join shop as sh on p.shopID = sh.shopID
     </sql>
     <select id="searchProductById" resultType="com.caimei365.commodity.model.search.ProductDO">