提交 95aa2b49 作者: xiaowang

新增:小程序接口新增

上级 592adcfd
...@@ -103,5 +103,10 @@ public class CategoryController { ...@@ -103,5 +103,10 @@ public class CategoryController {
return categoryService.exchange(list); return categoryService.exchange(list);
} }
@ApiOperation(value = "小程序分类信息--含一二级分类")
@GetMapping("/appCategoryInfo")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = CategoryPrimaryDTO.class)})
public ResultBody<CategoryPrimaryDTO> appCategoryInfo() {
return categoryService.appCategoryInfo();
}
} }
...@@ -3,6 +3,7 @@ package com.mmc.pms.controller.mall; ...@@ -3,6 +3,7 @@ package com.mmc.pms.controller.mall;
import com.mmc.pms.common.ResultBody; import com.mmc.pms.common.ResultBody;
import com.mmc.pms.controller.BaseController; import com.mmc.pms.controller.BaseController;
import com.mmc.pms.model.mall.MallGoodsVO; import com.mmc.pms.model.mall.MallGoodsVO;
import com.mmc.pms.service.mall.AppMallGoodsService;
import com.mmc.pms.service.mall.MallGoodsService; import com.mmc.pms.service.mall.MallGoodsService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -26,6 +27,8 @@ import javax.annotation.Resource; ...@@ -26,6 +27,8 @@ import javax.annotation.Resource;
public class AppMallGoodsController extends BaseController { public class AppMallGoodsController extends BaseController {
@Resource @Resource
private MallGoodsService mallGoodsService; private MallGoodsService mallGoodsService;
@Resource
private AppMallGoodsService appMallGoodsService;
@ApiOperation(value = "小程序商品详情") @ApiOperation(value = "小程序商品详情")
@GetMapping("appMallGoodsDetails") @GetMapping("appMallGoodsDetails")
...@@ -33,4 +36,18 @@ public class AppMallGoodsController extends BaseController { ...@@ -33,4 +36,18 @@ public class AppMallGoodsController extends BaseController {
public ResultBody<MallGoodsVO> appMallGoodsDetails(@RequestParam Long id) { public ResultBody<MallGoodsVO> appMallGoodsDetails(@RequestParam Long id) {
return mallGoodsService.mallGoodsDetails(id); return mallGoodsService.mallGoodsDetails(id);
} }
@ApiOperation(value = "查询品牌方的商品")
@GetMapping("queryBrandGoods")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = MallGoodsVO.class)})
public ResultBody<MallGoodsVO> queryBrandGoods(@RequestParam Integer userAccountId) {
return appMallGoodsService.queryBrandGoods(userAccountId);
}
@ApiOperation(value = "根据子分类查询商品信息")
@GetMapping("queryGoodsInfoByCategorySub")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = MallGoodsVO.class)})
public ResultBody<MallGoodsVO> queryGoodsInfoByCategorySub(@RequestParam Integer categorySubId) {
return appMallGoodsService.queryGoodsInfoByCategorySub(categorySubId);
}
} }
...@@ -49,4 +49,8 @@ public interface CategoryDao { ...@@ -49,4 +49,8 @@ public interface CategoryDao {
int categoryListCount(CategoryQO param); int categoryListCount(CategoryQO param);
void exchange(ServiceDO serviceDO); void exchange(ServiceDO serviceDO);
List<CategoryPrimaryDO> selectPrimaryList();
List<CategorySubDO> selectCategorySubList(List<Integer> ids);
} }
package com.mmc.pms.dao.mall;
import com.mmc.pms.entity.mall.MallGoodsDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @Author LW
* @date 2023/7/26 14:57
* 概要:
*/
@Mapper
public interface AppMallGoodsDao {
List<MallGoodsDO> queryGoodsInfo(@Param("userAccountId") Integer userAccountId, @Param("categorySubId") Integer categorySubId);
}
...@@ -104,9 +104,9 @@ public class MallGoodsDO implements Serializable { ...@@ -104,9 +104,9 @@ public class MallGoodsDO implements Serializable {
goodsResourcesVO.setUrl(url); goodsResourcesVO.setUrl(url);
goodsResourcesVO.setType(type); goodsResourcesVO.setType(type);
resourcesList.add(goodsResourcesVO); resourcesList.add(goodsResourcesVO);
return MallGoodsVO.builder().id(id).tradeName(tradeName).resourcesList(resourcesList) return MallGoodsVO.builder().id(id).userAccountId(userAccountId).tradeName(tradeName).resourcesList(resourcesList)
.categoryPrimaryId(categoryPrimaryId).categorySubId(categorySubId) .categoryPrimaryId(categoryPrimaryId).labelShow(labelShow).goodsLabel(goodsLabel).categorySubId(categorySubId)
.shelfStatus(shelfStatus).createTime(createTime).build(); .shelfStatus(shelfStatus).createTime(createTime).description(description).build();
} }
} }
...@@ -34,4 +34,6 @@ public interface CategoryService { ...@@ -34,4 +34,6 @@ public interface CategoryService {
ResultBody exchange(List<CategoryPrimaryVO> list); ResultBody exchange(List<CategoryPrimaryVO> list);
ResultBody<CategoryPrimaryDTO> appCategoryInfo();
} }
...@@ -13,11 +13,13 @@ import com.mmc.pms.model.category.vo.CategoryPrimaryVO; ...@@ -13,11 +13,13 @@ import com.mmc.pms.model.category.vo.CategoryPrimaryVO;
import com.mmc.pms.model.category.vo.CategorySubVO; import com.mmc.pms.model.category.vo.CategorySubVO;
import com.mmc.pms.page.PageResult; import com.mmc.pms.page.PageResult;
import com.mmc.pms.service.category.CategoryService; import com.mmc.pms.service.category.CategoryService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -132,4 +134,26 @@ public class CategoryServiceImpl implements CategoryService { ...@@ -132,4 +134,26 @@ public class CategoryServiceImpl implements CategoryService {
return ResultBody.success(); return ResultBody.success();
} }
@Override
public ResultBody<CategoryPrimaryDTO> appCategoryInfo() {
// 获取所有以及分类
List<CategoryPrimaryDO> categoryPrimaryList = categoryDao.selectPrimaryList();
if (CollectionUtils.isEmpty(categoryPrimaryList)) {
return ResultBody.success();
}
List<CategoryPrimaryDTO> primaryList = categoryPrimaryList.stream()
.map(CategoryPrimaryDO::buildCategoryPrimaryDTO).collect(Collectors.toList());
List<Integer> ids = primaryList.stream().map(CategoryPrimaryDTO::getId).collect(Collectors.toList());
// 批量查找二级分类
List<CategorySubDO> categorySubList = categoryDao.selectCategorySubList(ids);
if (CollectionUtils.isNotEmpty(categorySubList)) {
Map<Integer, List<CategorySubDO>> subMap = categorySubList.stream().collect(Collectors.groupingBy(CategorySubDO::getCategoryPrimaryId));
for (CategoryPrimaryDTO categoryPrimaryDTO : primaryList) {
List<CategorySubDO> categorySubDOList = subMap.get(categoryPrimaryDTO.getId());
categoryPrimaryDTO.setSubDTOList(categorySubDOList);
}
}
return ResultBody.success(primaryList);
}
} }
package com.mmc.pms.service.mall;
import com.mmc.pms.common.ResultBody;
import com.mmc.pms.model.mall.MallGoodsVO;
/**
* @Author LW
* @date 2023/7/26 14:55
* 概要:
*/
public interface AppMallGoodsService {
ResultBody<MallGoodsVO> queryBrandGoods(Integer userAccountId);
ResultBody<MallGoodsVO> queryGoodsInfoByCategorySub(Integer categorySubId);
}
package com.mmc.pms.service.mall.impl;
import com.mmc.pms.common.ResultBody;
import com.mmc.pms.dao.mall.AppMallGoodsDao;
import com.mmc.pms.entity.mall.MallGoodsDO;
import com.mmc.pms.model.mall.MallGoodsVO;
import com.mmc.pms.service.mall.AppMallGoodsService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;
/**
* @Author LW
* @date 2023/7/26 14:55
* 概要:
*/
@Service
public class AppMallGoodsServiceImpl implements AppMallGoodsService {
@Resource
private AppMallGoodsDao appMallGoodsDao;
@Override
public ResultBody<MallGoodsVO> queryBrandGoods(Integer userAccountId) {
List<MallGoodsDO> mallGoodsList = appMallGoodsDao.queryGoodsInfo(userAccountId, null);
return checkGoodsInfo(mallGoodsList);
}
@Override
public ResultBody<MallGoodsVO> queryGoodsInfoByCategorySub(Integer categorySubId) {
List<MallGoodsDO> mallGoodsList = appMallGoodsDao.queryGoodsInfo(null, categorySubId);
return checkGoodsInfo(mallGoodsList);
}
private ResultBody<MallGoodsVO> checkGoodsInfo(List<MallGoodsDO> mallGoodsList) {
if (CollectionUtils.isNotEmpty(mallGoodsList)) {
return ResultBody.success(mallGoodsList.stream().map(MallGoodsDO::buildListMallGoodsVO).collect(Collectors.toList()));
}
return ResultBody.success();
}
}
...@@ -188,5 +188,28 @@ ...@@ -188,5 +188,28 @@
order by sort desc, update_time desc, create_time desc order by sort desc, update_time desc, create_time desc
limit #{pageNo},#{pageSize} limit #{pageNo},#{pageSize}
</select> </select>
<select id="selectPrimaryList" resultType="com.mmc.pms.entity.category.CategoryPrimaryDO">
select id,
`name`,
description,
create_time,
icon,
sort
from category_primary
</select>
<select id="selectCategorySubList" resultType="com.mmc.pms.entity.category.CategorySubDO">
select id,
`name`,
description,
create_time,
update_time,
category_primary_id
from category_sub
<where>
<foreach collection="list" separator="," item="item" open="category_primary_id in (" close=")">
#{item}
</foreach>
</where>
</select>
</mapper> </mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.mmc.pms.dao.mall.AppMallGoodsDao">
<select id="queryGoodsInfo" resultType="com.mmc.pms.entity.mall.MallGoodsDO">
SELECT mg.id,
mg.trade_name,
mg.shelf_status,
mg.create_time,
mg.description,
mg.category_primary_id,
mg.user_account_id,
mg.goods_label,
mg.label_show,
mg.category_sub_id,
mg.goods_label,
img.id as imgId, img.url,
img.type
FROM mall_goods mg
INNER JOIN mall_goods_resources img ON mg.id = img.mall_goods_id
AND img.type = 0
<where>
mg.is_deleted = 0
<if test="userAccountId != null">
and mg.user_account_id = #{userAccountId}
</if>
<if test="categorySubId != null">
and mg.category_sub_id =#{categorySubId}
</if>
</where>
</select>
</mapper>
\ No newline at end of file
...@@ -19,3 +19,6 @@ data-filter: ...@@ -19,3 +19,6 @@ data-filter:
- /pms/webDevice/ad - /pms/webDevice/ad
- /pms/actuator/health/readiness - /pms/actuator/health/readiness
- /pms/app/goods/appMallGoodsDetails - /pms/app/goods/appMallGoodsDetails
- /pms/category/appCategoryInfo
- /pms/app/goods/queryBrandGoods
- /pms/app/goods/queryGoodsInfoByCategorySub
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论