diff --git a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/mapper/BaseMapperX.java b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/mapper/BaseMapperX.java index fb4af6d69..e220d011d 100644 --- a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/mapper/BaseMapperX.java +++ b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/mapper/BaseMapperX.java @@ -2,6 +2,7 @@ package cn.iocoder.yudao.framework.mybatis.core.mapper; import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -75,9 +76,13 @@ public interface BaseMapperX extends BaseMapper { return selectList(new LambdaQueryWrapper().in(field, values)); } + default List selectList(SFunction leField, SFunction geField, Object value) { + return selectList(new LambdaQueryWrapper().le(leField, value).ge(geField, value)); + } + /** * 逐条插入,适合少量数据插入,或者对性能要求不高的场景 - * + *

* 如果大量,请使用 {@link com.baomidou.mybatisplus.extension.service.impl.ServiceImpl#saveBatch(Collection)} 方法 * 使用示例,可见 RoleMenuBatchInsertMapper、UserRoleBatchInsertMapper 类 * diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/seckillactivity/SeckillActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/SeckillActivityController.java similarity index 99% rename from yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/seckillactivity/SeckillActivityController.java rename to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/SeckillActivityController.java index 1efeb387e..5acaf7cf0 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/seckillactivity/SeckillActivityController.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/SeckillActivityController.java @@ -1,8 +1,8 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckillactivity; +package cn.iocoder.yudao.module.promotion.controller.admin.seckill; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckillactivity.vo.*; +import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.*; import cn.iocoder.yudao.module.promotion.convert.seckill.seckillactivity.SeckillActivityConvert; import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillActivityDO; import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillProductDO; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/seckilltime/SeckillTimeController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/SeckillTimeController.java similarity index 78% rename from yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/seckilltime/SeckillTimeController.java rename to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/SeckillTimeController.java index 37fbfcbea..3cb6d4ca6 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/seckilltime/SeckillTimeController.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/SeckillTimeController.java @@ -1,9 +1,9 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckilltime; +package cn.iocoder.yudao.module.promotion.controller.admin.seckill; import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckilltime.vo.SeckillTimeCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckilltime.vo.SeckillTimeRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckilltime.vo.SeckillTimeUpdateReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time.SeckillTimeCreateReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time.SeckillTimeRespVO; +import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time.SeckillTimeUpdateReqVO; import cn.iocoder.yudao.module.promotion.convert.seckill.seckilltime.SeckillTimeConvert; import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckilltime.SeckillTimeDO; import cn.iocoder.yudao.module.promotion.service.seckill.seckilltime.SeckillTimeService; @@ -20,7 +20,6 @@ import java.util.List; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -// TODO @halfninety:controller 可以都放在 seckill 包下;vo 下分成 actvity 和 time @Api(tags = "管理后台 - 秒杀时段") @RestController @RequestMapping("/promotion/seckill-time") @@ -65,20 +64,9 @@ public class SeckillTimeController { @GetMapping("/list") @ApiOperation("获得所有秒杀时段列表") -// @PreAuthorize("@ss.hasPermission('promotion:seckill-time:query')") - // TODO @halfninety:权限为啥注释掉呀? + @PreAuthorize("@ss.hasPermission('promotion:seckill-time:query')") public CommonResult> getSeckillTimeList() { List list = seckillTimeService.getSeckillTimeList(); return success(SeckillTimeConvert.INSTANCE.convertList(list)); } - - // TODO @halfninety:不用的,可以删除掉 -// @GetMapping("/page") -// @ApiOperation("获得秒杀时段分页") -// @PreAuthorize("@ss.hasPermission('promotion:seckill-time:query')") -// public CommonResult> getSeckillTimePage(@Valid SeckillTimePageReqVO pageVO) { -// PageResult pageResult = seckillTimeService.getSeckillTimePage(pageVO); -// return success(SeckillTimeConvert.INSTANCE.convertPage(pageResult)); -// } - } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/seckilltime/vo/SeckillTimeSimpleRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/seckilltime/vo/SeckillTimeSimpleRespVO.java deleted file mode 100644 index 25714595f..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/seckilltime/vo/SeckillTimeSimpleRespVO.java +++ /dev/null @@ -1,4 +0,0 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckilltime.vo; - -public class SeckillTimeSimpleRespVO { -} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/seckillactivity/vo/SeckillActivityBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityBaseVO.java similarity index 92% rename from yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/seckillactivity/vo/SeckillActivityBaseVO.java rename to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityBaseVO.java index 66128212a..877e7553a 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/seckillactivity/vo/SeckillActivityBaseVO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityBaseVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckillactivity.vo; +package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; @@ -14,9 +14,9 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT; /** -* 秒杀活动 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ + * 秒杀活动 Base VO,提供给添加、修改、详细的子 VO 使用 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 + */ @Data public class SeckillActivityBaseVO { diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/seckillactivity/vo/SeckillActivityCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityCreateReqVO.java similarity index 68% rename from yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/seckillactivity/vo/SeckillActivityCreateReqVO.java rename to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityCreateReqVO.java index 939102ac0..58dbd0dd9 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/seckillactivity/vo/SeckillActivityCreateReqVO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityCreateReqVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckillactivity.vo; +package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -7,12 +7,10 @@ import lombok.EqualsAndHashCode; import lombok.ToString; import javax.validation.Valid; -import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; import java.util.List; -// TODO halfninety:检查下所有的 VO,需要保证 example 都写了哈。 @ApiModel("管理后台 - 秒杀活动创建 Request VO") @Data @EqualsAndHashCode(callSuper = true) @@ -22,14 +20,13 @@ public class SeckillActivityCreateReqVO extends SeckillActivityBaseVO { @ApiModelProperty(value = "备注", example = "限时秒杀活动") private String remark; - @ApiModelProperty(value = "排序", required = true) + @ApiModelProperty(value = "排序", required = true, example = "1") @NotNull(message = "排序不能为空") private Integer sort; - // TODO halfninety:直接使用数组接口。timeIds, - @ApiModelProperty(value = "秒杀时段id", required = true) - @NotBlank(message = "参与场次不能为空") - private String timeId; + @ApiModelProperty(value = "秒杀时段id", required = true, example = "1,3") + @NotEmpty(message = "参与场次不能为空") + private List timeIds; /** * 商品列表 diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/seckillactivity/vo/SeckillActivityDetailRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityDetailRespVO.java similarity index 93% rename from yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/seckillactivity/vo/SeckillActivityDetailRespVO.java rename to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityDetailRespVO.java index aa6343137..a8a079abf 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/seckillactivity/vo/SeckillActivityDetailRespVO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityDetailRespVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckillactivity.vo; +package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity; import io.swagger.annotations.ApiModel; import lombok.Data; @@ -11,7 +11,7 @@ import java.util.List; @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class SeckillActivityDetailRespVO extends SeckillActivityRespVO{ +public class SeckillActivityDetailRespVO extends SeckillActivityRespVO { /** * 商品列表 diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/seckillactivity/vo/SeckillActivityPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityPageReqVO.java similarity index 92% rename from yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/seckillactivity/vo/SeckillActivityPageReqVO.java rename to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityPageReqVO.java index 5aa32fac8..34808d523 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/seckillactivity/vo/SeckillActivityPageReqVO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityPageReqVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckillactivity.vo; +package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity; import cn.iocoder.yudao.framework.common.pojo.PageParam; import com.fasterxml.jackson.annotation.JsonFormat; @@ -26,8 +26,8 @@ public class SeckillActivityPageReqVO extends PageParam { @ApiModelProperty(value = "活动状态", example = "进行中") private Integer status; - @ApiModelProperty(value = "秒杀时段id") - private String timeId; + @ApiModelProperty(value = "秒杀时段id", example = "1") + private Long timeId; @ApiModelProperty(value = "创建时间") @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/seckillactivity/vo/SeckillActivityRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityRespVO.java similarity index 71% rename from yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/seckillactivity/vo/SeckillActivityRespVO.java rename to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityRespVO.java index 220f4df6f..50055f8b0 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/seckillactivity/vo/SeckillActivityRespVO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityRespVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckillactivity.vo; +package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -7,6 +7,7 @@ import lombok.EqualsAndHashCode; import lombok.ToString; import java.time.LocalDateTime; +import java.util.List; @ApiModel("管理后台 - 秒杀活动 Response VO") @Data @@ -14,22 +15,22 @@ import java.time.LocalDateTime; @ToString(callSuper = true) public class SeckillActivityRespVO extends SeckillActivityBaseVO { - @ApiModelProperty(value = "秒杀活动id", required = true, example = "1") + @ApiModelProperty(value = "秒杀活动id", required = true, example = "1") private Long id; - @ApiModelProperty(value = "付款订单数", required = true) + @ApiModelProperty(value = "付款订单数", required = true, example = "1") private Integer orderCount; - @ApiModelProperty(value = "付款人数", required = true) + @ApiModelProperty(value = "付款人数", required = true, example = "1") private Integer userCount; @ApiModelProperty(value = "创建时间", required = true) private LocalDateTime createTime; - @ApiModelProperty(value = "秒杀时段id", required = true) - private String timeId; + @ApiModelProperty(value = "秒杀时段id", required = true, example = "1,3") + private List timeIds; - @ApiModelProperty(value = "排序", required = true) + @ApiModelProperty(value = "排序", required = true, example = "1") private Integer sort; @ApiModelProperty(value = "备注", example = "限时秒杀活动") diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/seckillactivity/vo/SeckillActivityUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityUpdateReqVO.java similarity index 80% rename from yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/seckillactivity/vo/SeckillActivityUpdateReqVO.java rename to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityUpdateReqVO.java index f53bb50d8..e55739a4b 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/seckillactivity/vo/SeckillActivityUpdateReqVO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityUpdateReqVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckillactivity.vo; +package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -24,13 +24,13 @@ public class SeckillActivityUpdateReqVO extends SeckillActivityBaseVO { @ApiModelProperty(value = "备注", example = "限时秒杀活动") private String remark; - @ApiModelProperty(value = "排序", required = true) + @ApiModelProperty(value = "排序", required = true, example = "1") @NotNull(message = "排序不能为空") private Integer sort; - @ApiModelProperty(value = "秒杀时段id", required = true) - @NotNull(message = "秒杀时段id不能为空") - private String timeId; + @ApiModelProperty(value = "秒杀时段id", required = true, example = "1,3") + @NotEmpty(message = "秒杀时段id不能为空") + private List timeIds; /** * 商品列表 diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/seckilltime/vo/SeckillTimeBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/time/SeckillTimeBaseVO.java similarity index 55% rename from yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/seckilltime/vo/SeckillTimeBaseVO.java rename to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/time/SeckillTimeBaseVO.java index fd2ea5480..4fc8c8f3c 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/seckilltime/vo/SeckillTimeBaseVO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/time/SeckillTimeBaseVO.java @@ -1,31 +1,27 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckilltime.vo; +package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time; -import lombok.*; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import javax.validation.constraints.NotNull; import java.time.LocalTime; -import java.util.*; -import io.swagger.annotations.*; -import javax.validation.constraints.*; -import org.springframework.format.annotation.DateTimeFormat; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; /** -* 秒杀时段 Base VO,提供给添加、修改、详细的子 VO 使用 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 -*/ + * 秒杀时段 Base VO,提供给添加、修改、详细的子 VO 使用 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 + */ @Data public class SeckillTimeBaseVO { - @ApiModelProperty(value = "秒杀时段名称", required = true) + @ApiModelProperty(value = "秒杀时段名称", required = true, example = "上午场") @NotNull(message = "秒杀时段名称不能为空") private String name; - @ApiModelProperty(value = "开始时间点", required = true) + @ApiModelProperty(value = "开始时间点", required = true, example = "16:30:40") @NotNull(message = "开始时间点不能为空") private LocalTime startTime; - @ApiModelProperty(value = "结束时间点", required = true) + @ApiModelProperty(value = "结束时间点", required = true, example = "16:30:40") @NotNull(message = "结束时间点不能为空") private LocalTime endTime; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/seckilltime/vo/SeckillTimeCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/time/SeckillTimeCreateReqVO.java similarity index 94% rename from yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/seckilltime/vo/SeckillTimeCreateReqVO.java rename to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/time/SeckillTimeCreateReqVO.java index e00ad7a63..197fb8a68 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/seckilltime/vo/SeckillTimeCreateReqVO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/time/SeckillTimeCreateReqVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckilltime.vo; +package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time; import lombok.*; import io.swagger.annotations.*; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/seckilltime/vo/SeckillTimePageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/time/SeckillTimePageReqVO.java similarity index 69% rename from yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/seckilltime/vo/SeckillTimePageReqVO.java rename to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/time/SeckillTimePageReqVO.java index 7fe5b07d5..b482ca34e 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/seckilltime/vo/SeckillTimePageReqVO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/time/SeckillTimePageReqVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckilltime.vo; +package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time; import cn.iocoder.yudao.framework.common.pojo.PageParam; import io.swagger.annotations.ApiModel; @@ -16,25 +16,15 @@ import java.time.LocalTime; @ToString(callSuper = true) public class SeckillTimePageReqVO extends PageParam { - @ApiModelProperty(value = "秒杀时段名称") + @ApiModelProperty(value = "秒杀时段名称", example = "上午场") private String name; - @ApiModelProperty(value = "开始时间点") + @ApiModelProperty(value = "开始时间点", example = "16:30:40") @DateTimeFormat(pattern = "HH:mm:ss") private LocalTime startTime; - @ApiModelProperty(value = "结束时间点") + @ApiModelProperty(value = "结束时间点", example = "16:30:40") @DateTimeFormat(pattern = "HH:mm:ss") private LocalTime endTime; - - - - - - -// @ApiModelProperty(value = "创建时间") -// @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) -// private Date[] createTime; - } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/seckilltime/vo/SeckillTimeRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/time/SeckillTimeRespVO.java similarity index 56% rename from yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/seckilltime/vo/SeckillTimeRespVO.java rename to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/time/SeckillTimeRespVO.java index c40f189d9..632020191 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/seckilltime/vo/SeckillTimeRespVO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/time/SeckillTimeRespVO.java @@ -1,8 +1,12 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckilltime.vo; +package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time; -import lombok.*; -import java.util.*; -import io.swagger.annotations.*; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import java.time.LocalDateTime; @ApiModel("管理后台 - 秒杀时段 Response VO") @Data @@ -10,13 +14,13 @@ import io.swagger.annotations.*; @ToString(callSuper = true) public class SeckillTimeRespVO extends SeckillTimeBaseVO { - @ApiModelProperty(value = "编号", required = true) + @ApiModelProperty(value = "编号", required = true, example = "1") private Long id; - @ApiModelProperty(value = "秒杀活动数量", required = true) + @ApiModelProperty(value = "秒杀活动数量", required = true, example = "1") private Integer seckillActivityCount; @ApiModelProperty(value = "创建时间", required = true) - private Date createTime; + private LocalDateTime createTime; } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/seckilltime/vo/SeckillTimeUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/time/SeckillTimeUpdateReqVO.java similarity index 86% rename from yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/seckilltime/vo/SeckillTimeUpdateReqVO.java rename to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/time/SeckillTimeUpdateReqVO.java index 16b786c7d..72931938d 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/seckilltime/vo/SeckillTimeUpdateReqVO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/time/SeckillTimeUpdateReqVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckilltime.vo; +package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -14,7 +14,7 @@ import javax.validation.constraints.NotNull; @ToString(callSuper = true) public class SeckillTimeUpdateReqVO extends SeckillTimeBaseVO { - @ApiModelProperty(value = "编号", required = true) + @ApiModelProperty(value = "编号", required = true, example = "1") @NotNull(message = "编号不能为空") private Long id; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillactivity/SeckillActivityConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillactivity/SeckillActivityConvert.java index fda7b6e1d..1a00fdeb6 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillactivity/SeckillActivityConvert.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillactivity/SeckillActivityConvert.java @@ -2,7 +2,8 @@ package cn.iocoder.yudao.module.promotion.convert.seckill.seckillactivity; import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckillactivity.vo.*; +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; +import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.*; import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillActivityDO; import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillProductDO; import org.mapstruct.Mapper; @@ -27,7 +28,7 @@ public interface SeckillActivityConvert { SeckillActivityDO convert(SeckillActivityCreateReqVO bean); - default String map(Long[] value){ + default String map(Long[] value) { return value.toString(); } @@ -39,7 +40,7 @@ public interface SeckillActivityConvert { PageResult convertPage(PageResult page); - @Mappings({@Mapping(target = "products",source = "seckillProducts")}) + @Mappings({@Mapping(target = "products", source = "seckillProducts")}) SeckillActivityDetailRespVO convert(SeckillActivityDO seckillActivity, List seckillProducts); @@ -56,7 +57,6 @@ public interface SeckillActivityConvert { && ObjectUtil.equals(productDO.getSeckillPrice(), productVO.getSeckillPrice()) && ObjectUtil.equals(productDO.getStock(), productVO.getStock()) && ObjectUtil.equals(productDO.getLimitBuyCount(), productVO.getLimitBuyCount()); - } /** @@ -74,4 +74,10 @@ public interface SeckillActivityConvert { && ObjectUtil.equals(productDO.getLimitBuyCount(), productVO.getLimitBuyCount()); } + + default List convertList(List products, SeckillActivityDO seckillActivity) { + return CollectionUtils.convertList(products, product -> convert(product) + .setActivityId(seckillActivity.getId()).setTimeIds(seckillActivity.getTimeIds())); + } + } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckilltime/SeckillTimeConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckilltime/SeckillTimeConvert.java index dda7d2c9d..4cea7a91c 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckilltime/SeckillTimeConvert.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckilltime/SeckillTimeConvert.java @@ -4,9 +4,9 @@ import java.util.*; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckilltime.vo.SeckillTimeCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckilltime.vo.SeckillTimeRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckilltime.vo.SeckillTimeUpdateReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time.SeckillTimeCreateReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time.SeckillTimeRespVO; +import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time.SeckillTimeUpdateReqVO; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckilltime.SeckillTimeDO; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/seckillactivity/SeckillActivityDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/seckillactivity/SeckillActivityDO.java index 0cc8e680c..1d3b6da27 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/seckillactivity/SeckillActivityDO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/seckillactivity/SeckillActivityDO.java @@ -1,28 +1,29 @@ package cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; +import cn.iocoder.yudao.module.promotion.enums.common.PromotionActivityStatusEnum; import com.baomidou.mybatisplus.annotation.KeySequence; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionActivityStatusEnum; -import lombok.*; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; -import java.math.BigDecimal; import java.time.LocalDateTime; +import java.util.List; /** * 秒杀活动 DO * - * @author 芋道源码 + * @author halfninety */ -@TableName("promotion_seckill_activity") +@TableName(value = "promotion_seckill_activity", autoResultMap = true) @KeySequence("promotion_seckill_activity_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor public class SeckillActivityDO extends BaseDO { /** @@ -36,7 +37,7 @@ public class SeckillActivityDO extends BaseDO { private String name; /** * 活动状态 - * + *

* 枚举 {@link PromotionActivityStatusEnum 对应的类} */ private Integer status; @@ -59,8 +60,8 @@ public class SeckillActivityDO extends BaseDO { /** * 秒杀时段 id */ - // TODO @halfninety 可以使用 List 存储;看下别的模块怎么做的哈 - private String timeId; + @TableField(typeHandler = LongListTypeHandler.class) + private List timeIds; /** * 付款订单数 */ @@ -69,10 +70,9 @@ public class SeckillActivityDO extends BaseDO { * 付款人数 */ private Integer userCount; - // TODO @halfninety 使用 Long 哈。单位是分 /** * 订单实付金额,单位:分 */ - private BigDecimal totalPrice; + private Long totalPrice; } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/seckillactivity/SeckillProductDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/seckillactivity/SeckillProductDO.java index 3ed54efa4..3783d6dda 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/seckillactivity/SeckillProductDO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/seckillactivity/SeckillProductDO.java @@ -1,21 +1,25 @@ package cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import java.io.Serializable; -import java.math.BigDecimal; -import java.util.Date; +import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; +import com.baomidou.mybatisplus.annotation.*; import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import java.util.List; /** * 秒杀参与商品 + * + * @author halfninety * @TableName promotion_seckill_product */ -@TableName(value ="promotion_seckill_product") +@TableName(value = "promotion_seckill_product", autoResultMap = true) +@KeySequence("promotion_seckill_product_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 @Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) public class SeckillProductDO extends BaseDO { /** * 秒杀参与商品编号 @@ -31,7 +35,8 @@ public class SeckillProductDO extends BaseDO { /** * 秒杀时段id */ - private Long timeId; + @TableField(typeHandler = LongListTypeHandler.class) + private List timeIds; /** * 商品id diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/seckilltime/SeckillTimeDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/seckilltime/SeckillTimeDO.java index 56dc0eb93..df338c0e6 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/seckilltime/SeckillTimeDO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/seckilltime/SeckillTimeDO.java @@ -4,7 +4,9 @@ import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; import java.time.LocalTime; @@ -18,9 +20,6 @@ import java.time.LocalTime; @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor public class SeckillTimeDO extends BaseDO { /** diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillActivityMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillActivityMapper.java index 41b7cafdc..c01676c2a 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillActivityMapper.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillActivityMapper.java @@ -1,28 +1,26 @@ package cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillactivity; +import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckillactivity.vo.SeckillActivityPageReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityPageReqVO; import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillActivityDO; import org.apache.ibatis.annotations.Mapper; /** * 秒杀活动 Mapper * - * @author 芋道源码 + * @author halfninety */ @Mapper public interface SeckillActivityMapper extends BaseMapperX { -// TODO: 2022/11/28 halfninety 秒杀活动通过场次查询使用like会出现问题,查询活动场次编号为1,则活动场次编号为 1,11,......的都会被查出来 default PageResult selectPage(SeckillActivityPageReqVO reqVO) { return selectPage(reqVO, new LambdaQueryWrapperX() .likeIfPresent(SeckillActivityDO::getName, reqVO.getName()) .eqIfPresent(SeckillActivityDO::getStatus, reqVO.getStatus()) - .likeIfPresent(SeckillActivityDO::getTimeId, reqVO.getTimeId()) -// .like(StringUtils.hasText(reqVO.getTimeId()),SeckillActivityDO::getTimeId, reqVO.getTimeId() + ",") .betweenIfPresent(SeckillActivityDO::getCreateTime, reqVO.getCreateTime()) + .apply(ObjectUtil.isNotNull(reqVO.getTimeId()),"FIND_IN_SET(" + reqVO.getTimeId() + ",time_ids) > 0") .orderByDesc(SeckillActivityDO::getId)); } - } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillProductMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillProductMapper.java index 3c76b45df..a590de1a5 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillProductMapper.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillProductMapper.java @@ -1,21 +1,35 @@ package cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillactivity; +import cn.hutool.core.collection.CollUtil; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillProductDO; +import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper; import org.apache.ibatis.annotations.Mapper; import java.util.Collection; import java.util.List; +/** + * 秒杀活动商品 Mapper + * + * @author halfninety + */ @Mapper public interface SeckillProductMapper extends BaseMapperX { - default List selectListByActivityId(Long id){ - return selectList(SeckillProductDO::getActivityId,id); + default List selectListByActivityId(Long id) { + return selectList(SeckillProductDO::getActivityId, id); } - default List selectListBySkuIds(Collection skuIds){ - return selectList(SeckillProductDO::getSkuId,skuIds); + default List selectListBySkuIds(Collection skuIds) { + return selectList(SeckillProductDO::getSkuId, skuIds); + } + + default void updateTimeIdsByActivityId(Long id, List timeIds) { + new LambdaUpdateChainWrapper<>(this) + .set(SeckillProductDO::getTimeIds, CollUtil.join(timeIds, ",")) + .eq(SeckillProductDO::getActivityId, id) + .update(); } } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckilltime/SeckillTimeMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckilltime/SeckillTimeMapper.java index f9d903a51..c34484e8c 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckilltime/SeckillTimeMapper.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckilltime/SeckillTimeMapper.java @@ -1,6 +1,5 @@ package cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckilltime; -import cn.hutool.core.collection.CollUtil; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckilltime.SeckillTimeDO; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -8,59 +7,31 @@ import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWra import org.apache.ibatis.annotations.Mapper; import java.time.LocalTime; -import java.util.Collections; +import java.util.Collection; import java.util.List; /** * 秒杀时段 Mapper * - * @author 芋道源码 + * @author halfninety */ @Mapper public interface SeckillTimeMapper extends BaseMapperX { - // @TODO halfninety:){ 之间要有空格哈 - default List selectListWithTime(LocalTime time){ - // TODO @halfninety:mapper 层,不做空判断,业务上面自己的保证 - if (time == null) { - return Collections.emptyList(); - } - // TODO @halfninety:在 BaseMapperX 上,可以封装一个 2 个字段的检索哈 - return selectList(new LambdaQueryWrapper() - .le(SeckillTimeDO::getStartTime,time) - .ge(SeckillTimeDO::getEndTime,time)); + default List selectListByTime(LocalTime time) { + return selectList(SeckillTimeDO::getStartTime, SeckillTimeDO::getEndTime, time); } - // TODO @halfninety:selectListByXXX,使用 By 作为查询条件。 - default List selectListWithTime(LocalTime startTime, LocalTime endTime){ - // TODO @halfninety:mapper 层,不做空判断,业务上面自己的保证 - if (startTime == null && endTime == null) { - return Collections.emptyList(); - } + default List selectListByTime(LocalTime startTime, LocalTime endTime) { return selectList(new LambdaQueryWrapper() - .ge(SeckillTimeDO::getStartTime,startTime) - .le(SeckillTimeDO::getEndTime,endTime)); + .ge(SeckillTimeDO::getStartTime, startTime) + .le(SeckillTimeDO::getEndTime, endTime)); } - // TODO @halfninety:updateActivityCount + 和 -,可以执使用一个方法实现哈。多传递一个参数 - default void sekillActivityCountAdd(List ids){ - if (CollUtil.isEmpty(ids)){ - return; - } - new LambdaUpdateChainWrapper(this) - .in(SeckillTimeDO::getId,ids) - .setSql("`seckill_activity_count` = `seckill_activity_count` + 1 ") + default void updateActivityCount(Collection ids, String type, Integer count) { + new LambdaUpdateChainWrapper<>(this) + .in(SeckillTimeDO::getId, ids) + .setSql("`seckill_activity_count` = `seckill_activity_count` " + type + count) .update(); } - - default void sekillActivityCountReduce(List ids){ - if (CollUtil.isEmpty(ids)){ - return; - } - new LambdaUpdateChainWrapper(this) - .in(SeckillTimeDO::getId,ids) - .setSql("`seckill_activity_count` = `seckill_activity_count` - 1 ") - .update(); - } - } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckillactivity/SeckillActivityService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckillactivity/SeckillActivityService.java index 6b45330ba..a0ff74dc8 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckillactivity/SeckillActivityService.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckillactivity/SeckillActivityService.java @@ -3,9 +3,9 @@ package cn.iocoder.yudao.module.promotion.service.seckill.seckillactivity; import java.util.*; import javax.validation.*; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckillactivity.vo.SeckillActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckillactivity.vo.SeckillActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckillactivity.vo.SeckillActivityUpdateReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityCreateReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityPageReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityUpdateReqVO; import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillActivityDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillProductDO; @@ -13,7 +13,7 @@ import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity. /** * 秒杀活动 Service 接口 * - * @author 芋道源码 + * @author halfninety */ public interface SeckillActivityService { @@ -34,6 +34,7 @@ public interface SeckillActivityService { /** * 关闭秒杀活动 + * * @param id 编号 */ void closeSeckillActivity(Long id); @@ -71,6 +72,7 @@ public interface SeckillActivityService { /** * 通过活动编号获取活动商品 + * * @param id 活动编号 * @return 活动商品列表 */ diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckillactivity/SeckillActivityServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckillactivity/SeckillActivityServiceImpl.java index 390521a07..45581d825 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckillactivity/SeckillActivityServiceImpl.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckillactivity/SeckillActivityServiceImpl.java @@ -3,11 +3,10 @@ package cn.iocoder.yudao.module.promotion.service.seckill.seckillactivity; import cn.hutool.core.collection.CollUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.string.StrUtils; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckillactivity.vo.SeckillActivityBaseVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckillactivity.vo.SeckillActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckillactivity.vo.SeckillActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckillactivity.vo.SeckillActivityUpdateReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityBaseVO; +import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityCreateReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityPageReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityUpdateReqVO; import cn.iocoder.yudao.module.promotion.convert.seckill.seckillactivity.SeckillActivityConvert; import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillActivityDO; import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillProductDO; @@ -22,7 +21,6 @@ import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; import java.util.Collection; import java.util.List; -import java.util.stream.Collectors; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; @@ -31,41 +29,34 @@ import static java.util.Arrays.asList; /** * 秒杀活动 Service 实现类 * - * @author 芋道源码 // TODO @halfninety:作者改成你自己哈 + * @author halfninety */ @Service @Validated public class SeckillActivityServiceImpl implements SeckillActivityService { - @Resource private SeckillActivityMapper seckillActivityMapper; @Resource private SeckillProductMapper seckillProductMapper; - @Resource private SeckillTimeService seckillTimeService; @Override public Long createSeckillActivity(SeckillActivityCreateReqVO createReqVO) { - // TODO @halfninety:多余的变量,需要删除 - List statuses = asList(PromotionActivityStatusEnum.WAIT.getStatus(), PromotionActivityStatusEnum.RUN.getStatus()); // 校验商品是否冲突 validateSeckillActivityProductConflicts(null, createReqVO.getProducts()); + // 校验秒杀时段是否存在 + seckillTimeService.validateSeckillTimeExists(createReqVO.getTimeIds()); - // TODO halfninety:要校验下,秒杀时间段存在 // 插入秒杀活动 SeckillActivityDO seckillActivity = SeckillActivityConvert.INSTANCE.convert(createReqVO) .setStatus(PromotionUtils.calculateActivityStatus(createReqVO.getStartTime(), createReqVO.getEndTime())); seckillActivityMapper.insert(seckillActivity); // 插入商品 - // TODO @halfninety:是不是写成一个 convertList,通过 default 来处理下;这样可读性更好哈 - List productDOS = CollectionUtils.convertList(createReqVO.getProducts(), - product -> SeckillActivityConvert.INSTANCE.convert(product).setActivityId(seckillActivity.getId())); + List productDOS = SeckillActivityConvert.INSTANCE.convertList(createReqVO.getProducts(), seckillActivity); seckillProductMapper.insertBatch(productDOS); - - // TODO halfninety:最后在更新秒杀时间段的商品数量哈。【我已经改了】一般先做核心的逻辑,在做附件的逻辑。 // 更新秒杀时段的秒杀活动数量 - seckillTimeService.sekillActivityCountAdd(StrUtils.splitToLong(createReqVO.getTimeId(),",")); + seckillTimeService.sekillActivityCountIncr(createReqVO.getTimeIds()); return seckillActivity.getId(); } @@ -79,53 +70,51 @@ public class SeckillActivityServiceImpl implements SeckillActivityService { // 校验商品是否冲突 validateSeckillActivityProductConflicts(updateReqVO.getId(), updateReqVO.getProducts()); - // 更新秒杀时段的秒杀活动数量 - // TODO @halfninety:可以直接传递 seckillActivity 进去,不用重复查询; - updateSeckillTimeActivityCount(updateReqVO.getId(), updateReqVO.getTimeId()); // 更新活动 SeckillActivityDO updateObj = SeckillActivityConvert.INSTANCE.convert(updateReqVO) .setStatus(PromotionUtils.calculateActivityStatus(updateReqVO.getStartTime(), updateReqVO.getEndTime())); seckillActivityMapper.updateById(updateObj); // 更新商品 updateSeckillProduct(updateReqVO); + // 更新秒杀时段的秒杀活动数量 + updateSeckillTimeActivityCount(seckillActivity, updateReqVO.getTimeIds()); } - // TODO @halfninety:注释写全哈; + /** * 更新秒杀时段的秒杀活动数量 * - * @param id - * @param timeId + * @param seckillActivity 查询出的秒杀活动 + * @param updateTimeIds 更新后的秒杀时段id列表 */ - private void updateSeckillTimeActivityCount(Long id, String timeId) { - List updateTimeIds = StrUtils.splitToLong(timeId, ","); - // 查出自己的 timeIds - SeckillActivityDO seckillActivityDO = seckillActivityMapper.selectById(id); - List existsTimeIds = StrUtils.splitToLong(seckillActivityDO.getTimeId(), ","); + private void updateSeckillTimeActivityCount(SeckillActivityDO seckillActivity, List updateTimeIds) { + // 查询出 timeIds + List existsTimeIds = seckillActivity.getTimeIds(); // 需要减少的时间段 - // TODO @halfninety:可以使用 CollUtil.filterNew() - List reduceIds = existsTimeIds.stream() - .filter(existsTimeId -> !updateTimeIds.contains(existsTimeId)) - .collect(Collectors.toList()); + Collection reduceIds = CollUtil.filterNew(existsTimeIds, existsTimeId -> !updateTimeIds.contains(existsTimeId)); // 需要添加的时间段 - // TODO @halfninety:IDEA 一般会有告警提示,下面可以 lambada 表达式优化下;通过 command + 回车 - updateTimeIds.removeIf(updateTimeId -> existsTimeIds.contains(updateTimeId)); + updateTimeIds.removeIf(existsTimeIds::contains); // 更新减少时间段和增加时间段 - // TODO @halfninety:判断非空才操作 - seckillTimeService.sekillActivityCountAdd(updateTimeIds); - seckillTimeService.sekillActivityCountReduce(reduceIds); + if (CollUtil.isNotEmpty(updateTimeIds)) { + seckillTimeService.sekillActivityCountIncr(updateTimeIds); + } + if (CollUtil.isNotEmpty(reduceIds)) { + seckillTimeService.sekillActivityCountDecr(reduceIds); + } } /** * 更新秒杀商品 + * 后台查出的数据和前台查出的数据进行遍历, + * 1. 对前台数据进行遍历:如果不存在于后台的 sku 中需要新增 + * 2. 对后台数据进行遍历:如果不存在于前台的 sku 中需要删除 + * 3. 最后对当前活动商品全部更新,更新秒杀时段id列表 + * + * @param updateReqVO 更新的请求VO */ private void updateSeckillProduct(SeckillActivityUpdateReqVO updateReqVO) { List seckillProductDOS = seckillProductMapper.selectListByActivityId(updateReqVO.getId()); List products = updateReqVO.getProducts(); - // TODO halfninety:下面这段,其实可以放到注释哈 - // 对后台查出的数据和前台查出的数据进行遍历, - // 1. 对前台数据进行遍历:如果不存在于后台的 sku 中需要新增 - // 2. 对后台数据进行遍历:如果不存在于前台的 sku 中需要删除 // 计算需要删除的数据 List deleteIds = CollectionUtils.convertList(seckillProductDOS, SeckillProductDO::getId, @@ -143,6 +132,9 @@ public class SeckillActivityServiceImpl implements SeckillActivityService { if (CollUtil.isNotEmpty(newSeckillProductDOs)) { seckillProductMapper.insertBatch(newSeckillProductDOs); } + + //全量更新当前活动商品的秒杀时段id列表(timeIds) + seckillProductMapper.updateTimeIdsByActivityId(updateReqVO.getId(), updateReqVO.getTimeIds()); } /** @@ -198,7 +190,7 @@ public class SeckillActivityServiceImpl implements SeckillActivityService { throw exception(SECKILL_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END); } // 更新秒杀时段的秒杀活动数量 - seckillTimeService.sekillActivityCountReduce(StrUtils.splitToLong(seckillActivity.getTimeId(),",")); + seckillTimeService.sekillActivityCountDecr(seckillActivity.getTimeIds()); // 删除 seckillActivityMapper.deleteById(id); } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckilltime/SeckillTimeService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckilltime/SeckillTimeService.java index 0256c873a..2e9c21249 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckilltime/SeckillTimeService.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckilltime/SeckillTimeService.java @@ -1,16 +1,17 @@ package cn.iocoder.yudao.module.promotion.service.seckill.seckilltime; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckilltime.vo.SeckillTimeCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckilltime.vo.SeckillTimeUpdateReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time.SeckillTimeCreateReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time.SeckillTimeUpdateReqVO; import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckilltime.SeckillTimeDO; import javax.validation.Valid; +import java.util.Collection; import java.util.List; /** * 秒杀时段 Service 接口 * - * @author 芋道源码 + * @author halfninety */ public interface SeckillTimeService { @@ -51,12 +52,19 @@ public interface SeckillTimeService { */ List getSeckillTimeList(); + /** + * 校验秒杀时段是否存在 + * + * @param timeIds 秒杀时段id集合 + */ + void validateSeckillTimeExists(Collection timeIds); + /** * 秒杀时段列表的秒杀活动数量加 1 * * @param ids 秒杀时段id列表 */ - void sekillActivityCountAdd(List ids); + void sekillActivityCountIncr(Collection ids); /** @@ -64,5 +72,5 @@ public interface SeckillTimeService { * * @param ids 秒杀时段id列表 */ - void sekillActivityCountReduce(List ids); + void sekillActivityCountDecr(Collection ids); } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckilltime/SeckillTimeServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckilltime/SeckillTimeServiceImpl.java index 234f40e5b..d38183860 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckilltime/SeckillTimeServiceImpl.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckilltime/SeckillTimeServiceImpl.java @@ -1,8 +1,8 @@ package cn.iocoder.yudao.module.promotion.service.seckill.seckilltime; import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckilltime.vo.SeckillTimeCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckilltime.vo.SeckillTimeUpdateReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time.SeckillTimeCreateReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time.SeckillTimeUpdateReqVO; import cn.iocoder.yudao.module.promotion.convert.seckill.seckilltime.SeckillTimeConvert; import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckilltime.SeckillTimeDO; import cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckilltime.SeckillTimeMapper; @@ -11,6 +11,7 @@ import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; import java.time.LocalTime; +import java.util.Collection; import java.util.List; import java.util.Objects; @@ -21,7 +22,7 @@ import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.SECKILL /** * 秒杀时段 Service 实现类 * - * @author 芋道源码 // TODO @halfninety:作者改成你自己哈 + * @author halfninety */ @Service @Validated @@ -33,7 +34,7 @@ public class SeckillTimeServiceImpl implements SeckillTimeService { @Override public Long createSeckillTime(SeckillTimeCreateReqVO createReqVO) { // 校验时间段是否冲突 - validateSeckillTimeConflict(null,createReqVO.getStartTime(), createReqVO.getEndTime()); + validateSeckillTimeConflict(null, createReqVO.getStartTime(), createReqVO.getEndTime()); // 插入 SeckillTimeDO seckillTime = SeckillTimeConvert.INSTANCE.convert(createReqVO); seckillTimeMapper.insert(seckillTime); @@ -74,10 +75,10 @@ public class SeckillTimeServiceImpl implements SeckillTimeService { */ private void validateSeckillTimeConflict(Long id, LocalTime startTime, LocalTime endTime) { //查询开始时间,结束时间,是否在别人的时间段内 - List startTimeList = seckillTimeMapper.selectListWithTime(startTime); - List endTimeList = seckillTimeMapper.selectListWithTime(endTime); + List startTimeList = seckillTimeMapper.selectListByTime(startTime); + List endTimeList = seckillTimeMapper.selectListByTime(endTime); //查询自己时间段内是否有时间段 - List startEndTimeList = seckillTimeMapper.selectListWithTime(startTime, endTime); + List startEndTimeList = seckillTimeMapper.selectListByTime(startTime, endTime); if (id != null) { //移除自己 startTimeList.removeIf(seckillTime -> Objects.equals(seckillTime.getId(), id)); @@ -100,15 +101,24 @@ public class SeckillTimeServiceImpl implements SeckillTimeService { return seckillTimeMapper.selectList(); } - // TODO @halfninety:updateActivityCount + 和 -,可以执使用一个方法实现哈。多传递一个参数 @Override - public void sekillActivityCountAdd(List ids) { - seckillTimeMapper.sekillActivityCountAdd(ids); + public void validateSeckillTimeExists(Collection timeIds) { + if (CollUtil.isEmpty(timeIds)) { + throw exception(SECKILL_TIME_NOT_EXISTS); + } + if (seckillTimeMapper.selectBatchIds(timeIds).size() != timeIds.size()) { + throw exception(SECKILL_TIME_NOT_EXISTS); + } } @Override - public void sekillActivityCountReduce(List ids) { - seckillTimeMapper.sekillActivityCountReduce(ids); + public void sekillActivityCountIncr(Collection ids) { + seckillTimeMapper.updateActivityCount(ids, "+", 1); + } + + @Override + public void sekillActivityCountDecr(Collection ids) { + seckillTimeMapper.updateActivityCount(ids, "-", 1); } } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/mapper/seckillactivity/SeckillActivityMapper.xml b/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/mapper/seckillactivity/SeckillActivityMapper.xml deleted file mode 100644 index 335ea77da..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/mapper/seckillactivity/SeckillActivityMapper.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/mapper/seckilltime/SeckillTimeMapper.xml b/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/mapper/seckilltime/SeckillTimeMapper.xml deleted file mode 100644 index 351eca7fb..000000000 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/resources/mapper/seckilltime/SeckillTimeMapper.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/seckillactivity/SeckillActivityServiceImplTest.java b/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/seckillactivity/SeckillActivityServiceImplTest.java index 2ea767e97..853568077 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/seckillactivity/SeckillActivityServiceImplTest.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/seckillactivity/SeckillActivityServiceImplTest.java @@ -2,9 +2,9 @@ package cn.iocoder.yudao.module.promotion.service.seckillactivity; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckillactivity.vo.SeckillActivityCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckillactivity.vo.SeckillActivityPageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckillactivity.vo.SeckillActivityUpdateReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityCreateReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityPageReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityUpdateReqVO; import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillActivityDO; import cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillactivity.SeckillActivityMapper; import cn.iocoder.yudao.module.promotion.service.seckill.seckillactivity.SeckillActivityServiceImpl; @@ -107,7 +107,7 @@ public class SeckillActivityServiceImplTest extends BaseDbUnitTest { SeckillActivityDO dbSeckillActivity = randomPojo(SeckillActivityDO.class, o -> { // 等会查询到 o.setName(null); o.setStatus(null); - o.setTimeId(null); + o.setTimeIds(null); o.setCreateTime(null); }); seckillActivityMapper.insert(dbSeckillActivity); @@ -116,7 +116,7 @@ public class SeckillActivityServiceImplTest extends BaseDbUnitTest { // 测试 status 不匹配 seckillActivityMapper.insert(cloneIgnoreId(dbSeckillActivity, o -> o.setStatus(null))); // 测试 timeId 不匹配 - seckillActivityMapper.insert(cloneIgnoreId(dbSeckillActivity, o -> o.setTimeId(null))); + seckillActivityMapper.insert(cloneIgnoreId(dbSeckillActivity, o -> o.setTimeIds(null))); // 测试 createTime 不匹配 seckillActivityMapper.insert(cloneIgnoreId(dbSeckillActivity, o -> o.setCreateTime(null))); // 准备参数 @@ -141,7 +141,7 @@ public class SeckillActivityServiceImplTest extends BaseDbUnitTest { SeckillActivityDO dbSeckillActivity = randomPojo(SeckillActivityDO.class, o -> { // 等会查询到 o.setName(null); o.setStatus(null); - o.setTimeId(null); + o.setTimeIds(null); o.setCreateTime(null); }); seckillActivityMapper.insert(dbSeckillActivity); @@ -150,7 +150,7 @@ public class SeckillActivityServiceImplTest extends BaseDbUnitTest { // 测试 status 不匹配 seckillActivityMapper.insert(cloneIgnoreId(dbSeckillActivity, o -> o.setStatus(null))); // 测试 timeId 不匹配 - seckillActivityMapper.insert(cloneIgnoreId(dbSeckillActivity, o -> o.setTimeId(null))); + seckillActivityMapper.insert(cloneIgnoreId(dbSeckillActivity, o -> o.setTimeIds(null))); // 测试 createTime 不匹配 seckillActivityMapper.insert(cloneIgnoreId(dbSeckillActivity, o -> o.setCreateTime(null))); // 准备参数 diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/seckilltime/SeckillTimeServiceImplTest.java b/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/seckilltime/SeckillTimeServiceImplTest.java index 439bcf03e..e61023c66 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/seckilltime/SeckillTimeServiceImplTest.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/seckilltime/SeckillTimeServiceImplTest.java @@ -1,7 +1,7 @@ package cn.iocoder.yudao.module.promotion.service.seckilltime; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckilltime.vo.SeckillTimeCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckilltime.vo.SeckillTimeUpdateReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time.SeckillTimeCreateReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time.SeckillTimeUpdateReqVO; import cn.iocoder.yudao.module.promotion.service.seckill.seckilltime.SeckillTimeServiceImpl; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/yudao-ui-admin/src/views/mall/promotion/seckill/seckillActivity/index.vue b/yudao-ui-admin/src/views/mall/promotion/seckill/seckillActivity/index.vue index 3805def34..265c54749 100644 --- a/yudao-ui-admin/src/views/mall/promotion/seckill/seckillActivity/index.vue +++ b/yudao-ui-admin/src/views/mall/promotion/seckill/seckillActivity/index.vue @@ -51,10 +51,10 @@ - + @@ -107,7 +107,7 @@ - {{ item.name + ': { ' }} {{ item.startTime }} -- {{ item.endTime + @@ -186,7 +186,7 @@