Commit 8482e3c8 by 何文超

代码调整

parent feb98d54
package com.gic.plug.web.controller.goods;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.goods.api.dto.SpecCordDTO;
import com.gic.goods.api.service.CordApiService;
import com.gic.goods.api.util.Constant;
import com.gic.mall.base.api.enums.ErrorCodeEnums;
import com.gic.mall.share.api.dto.shop.ShopDTO;
import com.gic.mall.share.api.service.ShopApiService;
import com.gic.plug.web.vo.goods.MallGoodsCordVO;
import com.gic.search.business.api.constant.enums.OperateEnum;
import com.gic.search.business.api.dto.DynamicSearchDTO;
import com.gic.search.business.api.dto.ESResponseQueryBatchDTO;
import com.gic.search.business.api.service.EsBusinessOperaApiService;
import com.gic.search.business.api.utils.QueryConditionAssemblyUtil;
import com.gic.widget.screening.api.service.EsScreeningSearchService;
/**
* 商城装修选择器
......@@ -28,16 +39,88 @@ public class AppletConfigGoodsController {
@Autowired
private ShopApiService shopApiService;
@Autowired
private EsScreeningSearchService esScreeningSearchService;
@Autowired
private EsBusinessOperaApiService esBusinessOperaApiService;
@RequestMapping("get-mall-cord-list")
public RestResponse getMallCordList(Long appConfigId) {
ServiceResponse<ShopDTO> shopDTOServiceResponse = shopApiService.getShopByAppletId(appConfigId, 1129, 1);
ServiceResponse<ShopDTO> shopDTOServiceResponse = shopApiService.getShopByAppletId(appConfigId, 1129, 1);
if (shopDTOServiceResponse.getResult() == null) {
return RestResponse.failure(ErrorCodeEnums.MAll_ERR.getCode(), "不存在店铺");
}
Long areaId = shopDTOServiceResponse.getResult().getAreaId();
ServiceResponse<List<SpecCordDTO>> listServiceResponse = cordApiService.listSpecCordDTO(areaId);
return RestResponse.success(EntityUtil.changeEntityListByOrika(MallGoodsCordVO.class, listServiceResponse.getResult()));
return RestResponse
.success(EntityUtil.changeEntityListByOrika(MallGoodsCordVO.class, listServiceResponse.getResult()));
}
/**
* 商城组对外提供的组件
* @param currentPage
* @param pageSize
* @param appConfigId
* @param search
* @param cordId
* @return
*/
@RequestMapping("list-mall-goods-selector")
public RestResponse listGoodsByChannel(@RequestParam(value = "currentPage", defaultValue = "1") Integer currentPage,
@RequestParam(value = "pageSize", defaultValue = "20") Integer pageSize, Long appConfigId, String search, Long cordId) {
Integer shopType = 1;
ServiceResponse<ShopDTO> shopDTOServiceResponse = shopApiService.getShopByAppletId(appConfigId, 1129, shopType);
if (shopDTOServiceResponse.getResult() == null) {
return RestResponse.failure(ErrorCodeEnums.MAll_ERR.getCode(), "不存在店铺");
}
Long areaId = shopDTOServiceResponse.getResult().getAreaId();
ServiceResponse<ESResponseQueryBatchDTO> serviceResponse = searchGoods(currentPage, pageSize, areaId, search,
Constant.CHANNEL_CODE_MALL, cordId);
if (serviceResponse.isSuccess()) {
return RestResponse.success(serviceResponse.getResult());
}
return RestResponse.failure(serviceResponse.getCode(), serviceResponse.getMessage());
}
private ServiceResponse<ESResponseQueryBatchDTO> searchGoods(Integer currentPage, Integer pageSize,
Long goodsDomainId, String search, String channelCode, Long cordId) {
DynamicSearchDTO searchDTO = new DynamicSearchDTO();
String searchCode = "";
if (Constant.CHANNEL_CODE_MALL.equals(channelCode)) {
searchCode = "gic_mall_goods";
}
String esName = esScreeningSearchService.getCurrentEsName("1129", searchCode);
searchDTO.setIndexName(esName);
searchDTO.setColumnCategoryCode(searchCode);
searchDTO.setEnterpriseId("1129");
searchDTO.setType("mapper_type");
searchDTO.setBegin((currentPage - 1) * pageSize);
searchDTO.setRecordNumber(pageSize);
JSONObject jsonObject = QueryConditionAssemblyUtil.createSimpleQueryNode("goodsDomainId",
OperateEnum.OPERATE_EQ, goodsDomainId);
JSONObject status = QueryConditionAssemblyUtil.createSimpleQueryNode("status", OperateEnum.OPERATE_EQ, 2);
jsonObject = QueryConditionAssemblyUtil.addQueryNodeForSiblin(status, jsonObject, OperateEnum.OPERATE_EQ);
if (StringUtils.isNotBlank(search)) {
JSONObject goodsCodeJson = QueryConditionAssemblyUtil.createSimpleQueryNode("goodsCode",
OperateEnum.OPERATE_LIKE, search);
JSONObject goodsNameJson = QueryConditionAssemblyUtil.createSimpleQueryNode("goodsName",
OperateEnum.OPERATE_LIKE, search);
List<JSONObject> jsonArray = new ArrayList<>();
jsonArray.add(goodsCodeJson);
jsonArray.add(goodsNameJson);
JSONObject object = QueryConditionAssemblyUtil.createListQueryNode(jsonArray, OperateEnum.OPERATE_OR);
QueryConditionAssemblyUtil.addQueryNodeForSiblin(object, jsonObject, OperateEnum.OPERATE_AND);
}
if (cordId != null) {
JSONObject cordJSON = QueryConditionAssemblyUtil.createSimpleQueryNode("cordId",
OperateEnum.OPERATE_CONTAIN, search);
QueryConditionAssemblyUtil.addQueryNodeForSiblin(cordJSON, jsonObject, OperateEnum.OPERATE_AND);
}
searchDTO.setSearchJson(jsonObject);
ServiceResponse<ESResponseQueryBatchDTO> serviceResponse = esBusinessOperaApiService.queryDataBatch(searchDTO,
false, null);
return serviceResponse;
}
}
package com.gic.plug.web.controller.goods;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.curator.shaded.com.google.common.collect.Lists;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
......@@ -22,9 +18,6 @@ import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.goods.api.dto.GoodsSkuDTO;
import com.gic.goods.api.service.GoodsApiService;
import com.gic.goods.api.util.Constant;
import com.gic.mall.base.api.enums.ErrorCodeEnums;
import com.gic.mall.share.api.dto.shop.ShopDTO;
import com.gic.mall.share.api.service.ShopApiService;
import com.gic.plug.web.vo.goods.GoodsVO;
import com.gic.search.business.api.constant.enums.OperateEnum;
import com.gic.search.business.api.dto.DynamicSearchDTO;
......@@ -51,9 +44,6 @@ public class GoodsController {
@Autowired
private GoodsApiService goodsApiService;
@Autowired
private ShopApiService shopApiService;
/**
* @Description: 查询所有(不分页)
......@@ -70,34 +60,7 @@ public class GoodsController {
}
/**
* 商城组对外提供的组件
* @param currentPage
* @param pageSize
* @param appConfigId
* @param search
* @param channelCode
* @param cordId
* @return
*/
@RequestMapping("list-goods-selector")
public RestResponse listGoodsByChannel(@RequestParam(value = "currentPage", defaultValue = "1") Integer currentPage,
@RequestParam(value = "pageSize", defaultValue = "20") Integer pageSize, Long appConfigId, String search, String channelCode, Long cordId) {
Integer shopType = null;
if (Objects.equals(channelCode, Constant.CHANNEL_CODE_MALL)) {
shopType = 1;
}
ServiceResponse<ShopDTO> shopDTOServiceResponse = shopApiService.getShopByAppletId(appConfigId, 1129, shopType);
if (shopDTOServiceResponse.getResult() == null) {
return RestResponse.failure(ErrorCodeEnums.MAll_ERR.getCode(), "不存在店铺");
}
Long areaId = shopDTOServiceResponse.getResult().getAreaId();
ServiceResponse<ESResponseQueryBatchDTO> serviceResponse = searchGoods(currentPage, pageSize, areaId, search, channelCode, cordId);
if (serviceResponse.isSuccess()) {
return RestResponse.success(serviceResponse.getResult());
}
return RestResponse.failure(serviceResponse.getCode(), serviceResponse.getMessage());
}
/**
......@@ -145,39 +108,7 @@ public class GoodsController {
return RestResponse.success(goodsVOS);
}
private ServiceResponse<ESResponseQueryBatchDTO> searchGoods( Integer currentPage,Integer pageSize, Long goodsDomainId,String search,String channelCode, Long cordId) {
DynamicSearchDTO searchDTO = new DynamicSearchDTO();
String searchCode = "";
if (Constant.CHANNEL_CODE_MALL.equals(channelCode)) {
searchCode = "gic_mall_goods";
}
String esName = esScreeningSearchService.getCurrentEsName("1129", searchCode);
searchDTO.setIndexName(esName);
searchDTO.setColumnCategoryCode(searchCode);
searchDTO.setEnterpriseId("1129");
searchDTO.setType("mapper_type");
searchDTO.setBegin((currentPage - 1) * pageSize);
searchDTO.setRecordNumber(pageSize);
JSONObject jsonObject = QueryConditionAssemblyUtil.createSimpleQueryNode("goodsDomainId", OperateEnum.OPERATE_EQ, goodsDomainId);
JSONObject status = QueryConditionAssemblyUtil.createSimpleQueryNode("status", OperateEnum.OPERATE_EQ, 2);
jsonObject = QueryConditionAssemblyUtil.addQueryNodeForSiblin(status, jsonObject, OperateEnum.OPERATE_EQ);
if (StringUtils.isNotBlank(search)) {
JSONObject goodsCodeJson = QueryConditionAssemblyUtil.createSimpleQueryNode("goodsCode", OperateEnum.OPERATE_LIKE, search);
JSONObject goodsNameJson = QueryConditionAssemblyUtil.createSimpleQueryNode("goodsName", OperateEnum.OPERATE_LIKE, search);
List<JSONObject> jsonArray = new ArrayList<>();
jsonArray.add(goodsCodeJson);
jsonArray.add(goodsNameJson);
JSONObject object = QueryConditionAssemblyUtil.createListQueryNode(jsonArray,OperateEnum.OPERATE_OR);
QueryConditionAssemblyUtil.addQueryNodeForSiblin(object, jsonObject, OperateEnum.OPERATE_AND);
}
if (cordId != null) {
JSONObject cordJSON = QueryConditionAssemblyUtil.createSimpleQueryNode("cordId", OperateEnum.OPERATE_CONTAIN, search);
QueryConditionAssemblyUtil.addQueryNodeForSiblin(cordJSON, jsonObject, OperateEnum.OPERATE_AND);
}
searchDTO.setSearchJson(jsonObject);
ServiceResponse<ESResponseQueryBatchDTO> serviceResponse = esBusinessOperaApiService.queryDataBatch(searchDTO, false, null);
return serviceResponse;
}
private ServiceResponse<ESResponseQueryBatchDTO> searchES( Integer currentPage,Integer pageSize, Long goodsDomainId,String search,String channelCode) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment