前端:商品推荐。忘记提交了
This commit is contained in:
@@ -17,13 +17,14 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("users/banner")
|
||||
@RequestMapping("users/product_recommend")
|
||||
@Api("商品推荐模块")
|
||||
public class UsersProductRecommendController {
|
||||
|
||||
@@ -34,7 +35,7 @@ public class UsersProductRecommendController {
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("获得所有 Banner 列表")
|
||||
public CommonResult<Multimap<Integer, UsersProductRecommendVO>> list() {
|
||||
public CommonResult<Map<Integer, Collection<UsersProductRecommendVO>>> list() {
|
||||
// 查询商品推荐列表
|
||||
List<ProductRecommendBO> productRecommends = productRecommendService.getProductRecommendList(
|
||||
null, CommonStatusEnum.ENABLE.getValue()).getData();
|
||||
@@ -43,11 +44,11 @@ public class UsersProductRecommendController {
|
||||
productRecommends.stream().map(ProductRecommendBO::getProductSpuId).collect(Collectors.toSet())).getData();
|
||||
Map<Integer, ProductSpuBO> spuMap = spus.stream().collect(Collectors.toMap(ProductSpuBO::getId, account -> account));
|
||||
// 组合结果,返回
|
||||
Multimap<Integer, UsersProductRecommendVO> result = new HashMultimap<>();
|
||||
Multimap<Integer, UsersProductRecommendVO> result = HashMultimap.create();
|
||||
productRecommends.sort(Comparator.comparing(ProductRecommendBO::getSort)); // 排序,按照 sort 升序
|
||||
productRecommends.forEach(productRecommendBO -> result.put(productRecommendBO.getType(),
|
||||
ProductRecommendConvert.INSTANCE.convert(spuMap.get(productRecommendBO.getProductSpuId())))); // 将 ProductSpuBO 添加到 results 中
|
||||
return CommonResult.success(result);
|
||||
return CommonResult.success(result.asMap());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package cn.iocoder.mall.promotion.biz.config;
|
||||
|
||||
import cn.iocoder.common.framework.util.ServiceExceptionUtil;
|
||||
import cn.iocoder.mall.user.service.api.constant.UserErrorCodeEnum;
|
||||
import cn.iocoder.mall.promotion.api.constant.PromotionErrorCodeEnum;
|
||||
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.event.EventListener;
|
||||
@@ -18,7 +18,7 @@ public class ServiceExceptionConfiguration {
|
||||
// } catch (IOException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
for (UserErrorCodeEnum item : UserErrorCodeEnum.values()) {
|
||||
for (PromotionErrorCodeEnum item : PromotionErrorCodeEnum.values()) {
|
||||
ServiceExceptionUtil.put(item.getCode(), item.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
status, memo, create_time
|
||||
</sql>
|
||||
|
||||
<!-- <select id="selectListByPidAndStatusOrderBySort" resultType="BannerDO">-->
|
||||
<!-- <select id="selectListByPidAndStatusOrderBySort" resultType="ProductRecommendDO">-->
|
||||
<!-- SELECT-->
|
||||
<!-- <include refid="FIELDS" />-->
|
||||
<!-- FROM product_recommend-->
|
||||
@@ -17,14 +17,14 @@
|
||||
<!-- ORDER BY sort ASC-->
|
||||
<!-- </select>-->
|
||||
|
||||
<!-- <select id="selectList" resultType="BannerDO">-->
|
||||
<!-- <select id="selectList" resultType="ProductRecommendDO">-->
|
||||
<!-- SELECT-->
|
||||
<!-- <include refid="FIELDS" />-->
|
||||
<!-- FROM product_recommend-->
|
||||
<!-- WHERE deleted = 0-->
|
||||
<!-- </select>-->
|
||||
|
||||
<select id="selectById" parameterType="Integer" resultType="BannerDO">
|
||||
<select id="selectById" parameterType="Integer" resultType="ProductRecommendDO">
|
||||
SELECT
|
||||
<include refid="FIELDS" />
|
||||
FROM product_recommend
|
||||
@@ -32,7 +32,7 @@
|
||||
AND deleted = 0
|
||||
</select>
|
||||
|
||||
<select id="selectByProductSpuIdAndType" resultType="BannerDO">
|
||||
<select id="selectByProductSpuIdAndType" resultType="ProductRecommendDO">
|
||||
SELECT
|
||||
<include refid="FIELDS" />
|
||||
FROM product_recommend
|
||||
@@ -41,13 +41,13 @@
|
||||
product_spu_id = #{productSpuId}
|
||||
</if>
|
||||
<if test="type != null">
|
||||
type = #{type}
|
||||
AND type = #{type}
|
||||
</if>
|
||||
AND deleted = 0
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectListByTypeAndStatus" parameterType="Integer" resultType="BannerDO">
|
||||
<select id="selectListByTypeAndStatus" parameterType="Integer" resultType="ProductRecommendDO">
|
||||
SELECT
|
||||
<include refid="FIELDS" />
|
||||
FROM product_recommend
|
||||
@@ -56,13 +56,13 @@
|
||||
type = #{type}
|
||||
</if>
|
||||
<if test="status != null">
|
||||
status = #{status}
|
||||
AND status = #{status}
|
||||
</if>
|
||||
AND deleted = 0
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectPageByType" resultType="BannerDO">
|
||||
<select id="selectPageByType" resultType="ProductRecommendDO">
|
||||
SELECT
|
||||
<include refid="FIELDS" />
|
||||
FROM product_recommend
|
||||
@@ -87,7 +87,7 @@
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<insert id="insert" parameterType="BannerDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
|
||||
<insert id="insert" parameterType="ProductRecommendDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
|
||||
INSERT INTO product_recommend (
|
||||
type, product_spu_id, sort, status, memo,
|
||||
create_time, deleted
|
||||
@@ -97,7 +97,7 @@
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="update" parameterType="BannerDO">
|
||||
<update id="update" parameterType="ProductRecommendDO">
|
||||
UPDATE product_recommend
|
||||
<set>
|
||||
<if test="type != null">
|
||||
|
||||
Reference in New Issue
Block a user