Commit e99a6e4ec8b2f0dfb8e0f322c040aae7b17eefaa
1 parent
3ccf8c7a
【代码评审】商城:积分商城的 review
Showing
3 changed files
with
5 additions
and
70 deletions
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/point/vo/product/PointProductPageReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.promotion.controller.admin.point.vo.product; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 4 | -import io.swagger.v3.oas.annotations.media.Schema; | |
| 5 | -import lombok.Data; | |
| 6 | -import lombok.EqualsAndHashCode; | |
| 7 | -import lombok.ToString; | |
| 8 | -import org.springframework.format.annotation.DateTimeFormat; | |
| 9 | - | |
| 10 | -import java.time.LocalDateTime; | |
| 11 | - | |
| 12 | -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 13 | - | |
| 14 | -@Schema(description = "管理后台 - 积分商城商品分页 Request VO") | |
| 15 | -@Data | |
| 16 | -@EqualsAndHashCode(callSuper = true) | |
| 17 | -@ToString(callSuper = true) | |
| 18 | -public class PointProductPageReqVO extends PageParam { | |
| 19 | - | |
| 20 | - @Schema(description = "积分商城活动 id", example = "29388") | |
| 21 | - private Long activityId; | |
| 22 | - | |
| 23 | - @Schema(description = "商品 SPU 编号", example = "8112") | |
| 24 | - private Long spuId; | |
| 25 | - | |
| 26 | - @Schema(description = "商品 SKU 编号", example = "2736") | |
| 27 | - private Long skuId; | |
| 28 | - | |
| 29 | - @Schema(description = "可兑换数量", example = "3926") | |
| 30 | - private Integer maxCount; | |
| 31 | - | |
| 32 | - @Schema(description = "兑换积分") | |
| 33 | - private Integer point; | |
| 34 | - | |
| 35 | - @Schema(description = "兑换金额,单位:分", example = "15860") | |
| 36 | - private Integer price; | |
| 37 | - | |
| 38 | - @Schema(description = "兑换类型", example = "2") | |
| 39 | - private Integer type; | |
| 40 | - | |
| 41 | - @Schema(description = "积分商城商品状态", example = "2") | |
| 42 | - private Integer activityStatus; | |
| 43 | - | |
| 44 | - @Schema(description = "创建时间") | |
| 45 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 46 | - private LocalDateTime[] createTime; | |
| 47 | - | |
| 48 | -} | |
| 49 | 0 | \ No newline at end of file |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/point/PointProductMapper.java
| 1 | 1 | package cn.iocoder.yudao.module.promotion.dal.mysql.point; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | 3 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 6 | -import cn.iocoder.yudao.module.promotion.controller.admin.point.vo.product.PointProductPageReqVO; | |
| 7 | 4 | import cn.iocoder.yudao.module.promotion.dal.dataobject.point.PointProductDO; |
| 8 | 5 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| 9 | 6 | import org.apache.ibatis.annotations.Mapper; |
| ... | ... | @@ -19,18 +16,6 @@ import java.util.List; |
| 19 | 16 | @Mapper |
| 20 | 17 | public interface PointProductMapper extends BaseMapperX<PointProductDO> { |
| 21 | 18 | |
| 22 | - default PageResult<PointProductDO> selectPage(PointProductPageReqVO reqVO) { | |
| 23 | - return selectPage(reqVO, new LambdaQueryWrapperX<PointProductDO>() | |
| 24 | - .eqIfPresent(PointProductDO::getActivityId, reqVO.getActivityId()) | |
| 25 | - .eqIfPresent(PointProductDO::getSpuId, reqVO.getSpuId()) | |
| 26 | - .eqIfPresent(PointProductDO::getSkuId, reqVO.getSkuId()) | |
| 27 | - .eqIfPresent(PointProductDO::getPoint, reqVO.getPoint()) | |
| 28 | - .eqIfPresent(PointProductDO::getPrice, reqVO.getPrice()) | |
| 29 | - .eqIfPresent(PointProductDO::getActivityStatus, reqVO.getActivityStatus()) | |
| 30 | - .betweenIfPresent(PointProductDO::getCreateTime, reqVO.getCreateTime()) | |
| 31 | - .orderByDesc(PointProductDO::getId)); | |
| 32 | - } | |
| 33 | - | |
| 34 | 19 | default List<PointProductDO> selectListByActivityId(Collection<Long> activityIds) { |
| 35 | 20 | return selectList(PointProductDO::getActivityId, activityIds); |
| 36 | 21 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/point/PointActivityServiceImpl.java
| ... | ... | @@ -51,12 +51,6 @@ public class PointActivityServiceImpl implements PointActivityService { |
| 51 | 51 | @Resource |
| 52 | 52 | private ProductSkuApi productSkuApi; |
| 53 | 53 | |
| 54 | - private static List<PointProductDO> buildPointProductDO(PointActivityDO pointActivity, List<PointProductSaveReqVO> products) { | |
| 55 | - return BeanUtils.toBean(products, PointProductDO.class, product -> { | |
| 56 | - product.setActivityId(pointActivity.getId()).setActivityStatus(pointActivity.getStatus()); | |
| 57 | - }); | |
| 58 | - } | |
| 59 | - | |
| 60 | 54 | @Override |
| 61 | 55 | public Long createPointActivity(PointActivitySaveReqVO createReqVO) { |
| 62 | 56 | // 1.1 校验商品是否存在 |
| ... | ... | @@ -72,10 +66,14 @@ public class PointActivityServiceImpl implements PointActivityService { |
| 72 | 66 | pointActivityMapper.insert(pointActivity); |
| 73 | 67 | // 2.2 插入积分商城活动商品 |
| 74 | 68 | pointProductMapper.insertBatch(buildPointProductDO(pointActivity, createReqVO.getProducts())); |
| 75 | - // 返回 | |
| 76 | 69 | return pointActivity.getId(); |
| 77 | 70 | } |
| 78 | 71 | |
| 72 | + private static List<PointProductDO> buildPointProductDO(PointActivityDO pointActivity, List<PointProductSaveReqVO> products) { | |
| 73 | + return BeanUtils.toBean(products, PointProductDO.class, product -> | |
| 74 | + product.setActivityId(pointActivity.getId()).setActivityStatus(pointActivity.getStatus())); | |
| 75 | + } | |
| 76 | + | |
| 79 | 77 | @Override |
| 80 | 78 | public void updatePointActivity(PointActivitySaveReqVO updateReqVO) { |
| 81 | 79 | // 1.1 校验存在 | ... | ... |