Authored by LUOXC

Merge branch 'test6.9.13' of http://git.yoho.cn/ufo/yohoufo-fore into test6.9.13

package com.yohoufo.common.constant;
import lombok.Getter;
import lombok.Setter;
/**
* Created by li.ma on 2019/9/30.
*/
public enum BusinessClientEnum {
BUSINESS_CLIENT_XIANYU("h5/xianyu", "闲鱼标识");
@Getter@Setter
String name;
@Getter@Setter
String desc;
BusinessClientEnum(String name, String desc){
this.name = name;
this.desc = desc;
}
public static boolean isXianYu(String name) {
return BUSINESS_CLIENT_XIANYU.getName().equals(name);
}
}
... ...
... ... @@ -141,14 +141,13 @@ public class ProductSearchController {
return new ApiResponse.ApiResponseBuilder().code(200).message("product.search.list.filter").data(resp).build();
}
@IgnoreSignature
@ApiOperation(name = "ufo.product.search.brandList", desc="品牌列表")
@RequestMapping(params = "method=ufo.product.search.brandList")
@IgnoreSession
@Cachable(expire = 180)
public ApiResponse searchBrandList() {
public ApiResponse searchBrandList(@RequestParam(value = "business_client", required = false) String businessClient) {
SearchBrandListResp resp = productSearchService.searchBrandList();
SearchBrandListResp resp = productSearchService.searchBrandList(businessClient);
return new ApiResponse.ApiResponseBuilder().code(200).message("product.search.brandList").data(resp).build();
}
... ...
package com.yohoufo.product.helper;
import com.yoho.core.config.ConfigReader;
import com.yohoufo.common.constant.BusinessClientEnum;
import com.yohoufo.common.utils.UfoStringUtils;
import com.yohoufo.product.request.ProductSearchReq;
import org.apache.commons.lang3.StringUtils;
... ... @@ -293,6 +295,18 @@ public class SearchParam {
return this;
}
/**
* 如果是闲鱼请求,则设置产品大分类ID
*
* @return
*/
public SearchParam setXianYuSort(String businessClient, ConfigReader configReader) {
if (BusinessClientEnum.isXianYu(businessClient)) {
setMaxSort(configReader.getString("ufo.product.xianYuSorts", ""));
}
return this;
}
public Map<String, Object> getParam() {
return param;
}
... ...
... ... @@ -21,7 +21,7 @@ public interface ProductSearchService {
SearchProductListFilterResp searchProductListFilter(ProductSearchReq req);
SearchBrandListResp searchBrandList();
SearchBrandListResp searchBrandList(String businessClient);
SearchProductRecommendResp searchProductRecommendById(Integer productId);
... ...
... ... @@ -11,8 +11,10 @@ import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import com.yoho.core.config.ConfigReader;
import com.yohobuy.ufo.model.promotion.response.CouponInfo;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.common.constant.BusinessClientEnum;
import com.yohoufo.dal.product.BrandMapper;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
... ... @@ -81,6 +83,9 @@ public class ProductSearchServiceImpl implements ProductSearchService {
@Autowired
private ProductMapper productMapper;
@Autowired
private ConfigReader configReader;
public static final String PRODUCT_LIST_URL = "/yohosearch/ufo/productList.json";
... ... @@ -437,9 +442,11 @@ public class ProductSearchServiceImpl implements ProductSearchService {
}
@Override
public SearchBrandListResp searchBrandList() {
public SearchBrandListResp searchBrandList(String businessClient) {
SearchBrandListResp resp = new SearchBrandListResp();
SearchParam searchParam = new SearchParam();
searchParam.setXianYuSort(businessClient, configReader); // 如果是闲鱼请求,则设置大品类
JSONObject data = search(searchParam.getParam(), BRAND_LIST_URL);
if(data != null && !CollectionUtils.isEmpty(data.getJSONArray("brand_list"))) {
resp = JSON.toJavaObject(data, SearchBrandListResp.class);
... ...
... ... @@ -54,4 +54,7 @@ ufo.order.pay.transferWithWalletSwitch=false
ufo.deposit2Instock.close = true
#验签开关
gateway.signature.isVerifyAllMethod = true
\ No newline at end of file
gateway.signature.isVerifyAllMethod = true
#闲鱼品类
ufo.product.xianYuSorts = 40
\ No newline at end of file
... ...