|
@@ -7,6 +7,7 @@ import com.slodon.b2b2c.core.constant.RedisConst;
|
|
|
import com.slodon.b2b2c.core.constant.StoreConst;
|
|
|
import com.slodon.b2b2c.core.response.JsonResult;
|
|
|
import com.slodon.b2b2c.core.response.SldResponse;
|
|
|
+import com.slodon.b2b2c.core.util.FileUrlUtil;
|
|
|
import com.slodon.b2b2c.core.util.StringUtil;
|
|
|
import com.slodon.b2b2c.core.util.UserUtil;
|
|
|
import com.slodon.b2b2c.goods.example.GoodsCategoryExample;
|
|
@@ -265,14 +266,14 @@ public class GoodsCategorySellerController {
|
|
|
@ApiImplicitParam(name = "categoryId1", value = "一级分类Id", required = true)
|
|
|
})
|
|
|
@GetMapping("bottomCategory")
|
|
|
- public JsonResult<List<FrontGoodsCategoryVO>> bottomCategory(HttpServletRequest request, Integer categoryId1) {
|
|
|
+ public JsonResult<List<FrontGoodsCategoryVO>> bottomCategory(HttpServletRequest request, Integer categoryId1,String webSite) {
|
|
|
Vendor vendor = UserUtil.getUser(request, Vendor.class);
|
|
|
|
|
|
List<FrontGoodsCategoryVO> vos = new ArrayList<>();
|
|
|
//根据店铺类型获取分类
|
|
|
if (vendor.getStore().getIsOwnStore().equals(StoreConst.IS_OWN_STORE)) {
|
|
|
//查询redis缓存
|
|
|
- String dataJson = stringRedisTemplate.opsForValue().get(RedisConst.FRONT_GOODS_CATEGORY);
|
|
|
+ String dataJson = stringRedisTemplate.opsForValue().get(RedisConst.FRONT_GOODS_CATEGORY + "_" + webSite);
|
|
|
if (!StringUtils.isEmpty(dataJson)) {
|
|
|
JSONArray jsonArray = JSONArray.parseArray(dataJson);
|
|
|
for (int i = 0; i < jsonArray.size(); i++) {
|
|
@@ -284,6 +285,7 @@ public class GoodsCategorySellerController {
|
|
|
for (int j = 0; j < array2.size(); j++) {
|
|
|
JSONObject object = array2.getJSONObject(j);
|
|
|
FrontGoodsCategoryVO categoryVO = new FrontGoodsCategoryVO();
|
|
|
+ categoryVO.setWebSite(object.getString("webSite"));
|
|
|
categoryVO.setCategoryId(object.getInteger("categoryId"));
|
|
|
categoryVO.setCategoryName(object.getString("categoryName"));
|
|
|
categoryVO.setPid(object.getInteger("pid"));
|
|
@@ -294,6 +296,7 @@ public class GoodsCategorySellerController {
|
|
|
for (int k = 0; k < array3.size(); k++) {
|
|
|
JSONObject jsonObject2 = array3.getJSONObject(k);
|
|
|
FrontGoodsCategoryVO goodsCategoryVO = new FrontGoodsCategoryVO();
|
|
|
+ goodsCategoryVO.setWebSite(jsonObject2.getString("webSite"));
|
|
|
goodsCategoryVO.setCategoryId(jsonObject2.getInteger("categoryId"));
|
|
|
goodsCategoryVO.setCategoryName(jsonObject2.getString("categoryName"));
|
|
|
goodsCategoryVO.setPid(jsonObject2.getInteger("pid"));
|
|
@@ -314,6 +317,7 @@ public class GoodsCategorySellerController {
|
|
|
StoreBindCategoryExample example = new StoreBindCategoryExample();
|
|
|
example.setStoreId(vendor.getStoreId());
|
|
|
example.setGoodsCategoryId1(categoryId1);
|
|
|
+ example.setWebSite(webSite);
|
|
|
example.setState(StoreConst.STORE_CATEGORY_STATE_PASS);
|
|
|
List<StoreBindCategory> list = storeBindCategoryModel.getStoreBindCategoryList(example, null);
|
|
|
//key-二级分类id, value-二级分类名称
|
|
@@ -339,6 +343,7 @@ public class GoodsCategorySellerController {
|
|
|
thirdList.forEach(goodsCategory -> {
|
|
|
if (secondMap.containsKey(goodsCategory.getPid())) {
|
|
|
FrontGoodsCategoryVO categoryVO = new FrontGoodsCategoryVO();
|
|
|
+ categoryVO.setWebSite(webSite);
|
|
|
categoryVO.setCategoryId(goodsCategory.getCategoryId());
|
|
|
categoryVO.setCategoryName(goodsCategory.getCategoryName());
|
|
|
categoryVO.setPid(goodsCategory.getCategoryId());
|
|
@@ -347,6 +352,7 @@ public class GoodsCategorySellerController {
|
|
|
} else {
|
|
|
List<FrontGoodsCategoryVO> thirdVos = new ArrayList<>();
|
|
|
FrontGoodsCategoryVO categoryVO = new FrontGoodsCategoryVO();
|
|
|
+ categoryVO.setWebSite(webSite);
|
|
|
categoryVO.setCategoryId(goodsCategory.getCategoryId());
|
|
|
categoryVO.setCategoryName(goodsCategory.getCategoryName());
|
|
|
categoryVO.setPid(goodsCategory.getCategoryId());
|
|
@@ -368,4 +374,76 @@ public class GoodsCategorySellerController {
|
|
|
}
|
|
|
return SldResponse.success(vos);
|
|
|
}
|
|
|
+
|
|
|
+ @ApiOperation("获取品牌分类列表接口")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "webSite", value = "站点", paramType = "query")
|
|
|
+ })
|
|
|
+ @GetMapping("getStoreCateList")
|
|
|
+ public JsonResult<List<FrontGoodsCategoryVO>> getStoreCateList(HttpServletRequest request, @RequestParam(value = "webSite", required = false, defaultValue = "1") String webSite) {
|
|
|
+ Vendor vendor = UserUtil.getUser(request, Vendor.class);
|
|
|
+
|
|
|
+ List<FrontGoodsCategoryVO> vos = new ArrayList<>();
|
|
|
+ if (vendor.getStore().getIsOwnStore().equals(StoreConst.IS_OWN_STORE)) {
|
|
|
+ //一级分类信息
|
|
|
+ GoodsCategoryExample example = new GoodsCategoryExample();
|
|
|
+ example.setPid(0);
|
|
|
+ example.setWebSite(webSite);
|
|
|
+ example.setState(GoodsCategoryConst.CATEGORY_STATE_1);
|
|
|
+ example.setOrderBy("sort asc, create_time desc");
|
|
|
+ List<GoodsCategory> list = goodsCategoryModel.getGoodsCategoryList(example, null);
|
|
|
+
|
|
|
+ //只获取一级分类,children设置为空集合
|
|
|
+ if (!CollectionUtils.isEmpty(list)) {
|
|
|
+ for (GoodsCategory goodsCategory : list) {
|
|
|
+ FrontGoodsCategoryVO vo = new FrontGoodsCategoryVO(goodsCategory);
|
|
|
+ // 设置children为空集合而不是null
|
|
|
+ vo.setChildren(new ArrayList<>());
|
|
|
+ vos.add(vo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //入驻店铺,获取审核通过的分类
|
|
|
+ StoreBindCategoryExample example = new StoreBindCategoryExample();
|
|
|
+ example.setStoreId(vendor.getStoreId());
|
|
|
+ example.setWebSite(webSite);
|
|
|
+ example.setState(StoreConst.STORE_CATEGORY_STATE_PASS);
|
|
|
+ List<StoreBindCategory> list = storeBindCategoryModel.getStoreBindCategoryList(example, null);
|
|
|
+
|
|
|
+ //只获取一级分类,children设置为空集合
|
|
|
+ if (!CollectionUtils.isEmpty(list)) {
|
|
|
+ // 提取所有一级分类ID并去重
|
|
|
+ Set<Integer> firstLevelIdSet = new HashSet<>();
|
|
|
+ for (StoreBindCategory bindCategory : list) {
|
|
|
+ firstLevelIdSet.add(bindCategory.getGoodsCategoryId1());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 批量查询一级分类
|
|
|
+ StringBuilder firstLevelIdsBuilder = new StringBuilder();
|
|
|
+ for (Integer id : firstLevelIdSet) {
|
|
|
+ if (firstLevelIdsBuilder.length() > 0) {
|
|
|
+ firstLevelIdsBuilder.append(",");
|
|
|
+ }
|
|
|
+ firstLevelIdsBuilder.append(id);
|
|
|
+ }
|
|
|
+ String firstLevelIds = firstLevelIdsBuilder.toString();
|
|
|
+
|
|
|
+ GoodsCategoryExample firstExample = new GoodsCategoryExample();
|
|
|
+ firstExample.setCategoryIdIn(firstLevelIds);
|
|
|
+ List<GoodsCategory> firstLevelCategories = goodsCategoryModel.getGoodsCategoryList(firstExample, null);
|
|
|
+
|
|
|
+ // 构建返回结果,children设置为空集合
|
|
|
+ for (GoodsCategory firstCategory : firstLevelCategories) {
|
|
|
+ FrontGoodsCategoryVO vo = new FrontGoodsCategoryVO(firstCategory);
|
|
|
+ // 设置children为空集合而不是null
|
|
|
+ vo.setChildren(new ArrayList<>());
|
|
|
+ vos.add(vo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return SldResponse.success(vos);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|