mall:新增 discount 限时折扣、reward 满减送
parent
96fc252348
commit
405bf497ef
|
@ -1,51 +0,0 @@
|
|||
package cn.iocoder.yudao.module.market.enums.activity;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 促销活动状态枚举
|
||||
*/
|
||||
public enum MarketActivityStatusEnum implements IntArrayValuable {
|
||||
|
||||
WAIT(10, "未开始"),
|
||||
RUN(20, "进行中"),
|
||||
END(30, "已结束"),
|
||||
/**
|
||||
* 1. WAIT、RUN、END 可以转换成 INVALID 状态。
|
||||
* 2. INVALID 只可以转换成 DELETED 状态。
|
||||
*/
|
||||
INVALID(40, "已撤销"),
|
||||
DELETED(50, "已删除"),
|
||||
;
|
||||
|
||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(MarketActivityStatusEnum::getValue).toArray();
|
||||
|
||||
/**
|
||||
* 状态值
|
||||
*/
|
||||
private final Integer value;
|
||||
/**
|
||||
* 状态名
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
MarketActivityStatusEnum(Integer value, String name) {
|
||||
this.value = value;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] array() {
|
||||
return ARRAYS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package cn.iocoder.yudao.module.market.enums.common;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 促销活动的状态枚举
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum PromotionActivityStatusEnum implements IntArrayValuable {
|
||||
|
||||
WAIT(10, "未开始"),
|
||||
RUN(20, "进行中"),
|
||||
END(30, "已结束"),
|
||||
CLOSE(40, "已关闭");
|
||||
|
||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionActivityStatusEnum::getStatus).toArray();
|
||||
|
||||
/**
|
||||
* 状态值
|
||||
*/
|
||||
private final Integer status;
|
||||
/**
|
||||
* 状态名
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
@Override
|
||||
public int[] array() {
|
||||
return ARRAYS;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package cn.iocoder.yudao.module.market.enums.common;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 营销的条件类型枚举
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum PromotionConditionTypeEnum implements IntArrayValuable {
|
||||
|
||||
PRICE(10, "满 N 元"),
|
||||
COUNT(20, "满 N 件");
|
||||
|
||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionConditionTypeEnum::getType).toArray();
|
||||
|
||||
/**
|
||||
* 类型值
|
||||
*/
|
||||
private final Integer type;
|
||||
/**
|
||||
* 类型名
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
@Override
|
||||
public int[] array() {
|
||||
return ARRAYS;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package cn.iocoder.yudao.module.market.enums.common;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 营销的商品范围枚举
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum PromotionProductScopeEnum implements IntArrayValuable {
|
||||
|
||||
ALL(1, "全部商品参与"),
|
||||
SPU(2, "指定商品参与"),
|
||||
;
|
||||
|
||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionProductScopeEnum::getScope).toArray();
|
||||
|
||||
/**
|
||||
* 范围值
|
||||
*/
|
||||
private final Integer scope;
|
||||
/**
|
||||
* 范围名
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
@Override
|
||||
public int[] array() {
|
||||
return ARRAYS;
|
||||
}
|
||||
|
||||
}
|
|
@ -15,8 +15,8 @@ import java.util.Arrays;
|
|||
@AllArgsConstructor
|
||||
public enum PromotionTypeEnum implements IntArrayValuable {
|
||||
|
||||
TIME_LIMITED_DISCOUNT(1, "限时折扣"),
|
||||
FULL_PRIVILEGE(2, "满减送"),
|
||||
DISCOUNT(1, "限时折扣"),
|
||||
REWARD(2, "满减送"),
|
||||
;
|
||||
|
||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionTypeEnum::getType).toArray();
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
package cn.iocoder.yudao.module.market.controller.admin;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Api(tags = "管理后台 - 营销")
|
||||
@RestController
|
||||
@RequestMapping("/market/test")
|
||||
@Validated
|
||||
public class MarketTestController {
|
||||
|
||||
@GetMapping("/get")
|
||||
@ApiOperation("获取 market 信息")
|
||||
public CommonResult<String> get() {
|
||||
return success("true");
|
||||
}
|
||||
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
package cn.iocoder.yudao.module.market.controller.admin.activity;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.annotations.*;
|
||||
import javax.validation.*;
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import cn.iocoder.yudao.module.market.controller.admin.activity.vo.*;
|
||||
import cn.iocoder.yudao.module.market.dal.dataobject.activity.ActivityDO;
|
||||
import cn.iocoder.yudao.module.market.convert.activity.ActivityConvert;
|
||||
import cn.iocoder.yudao.module.market.service.activity.ActivityService;
|
||||
|
||||
@Api(tags = "管理后台 - 促销活动")
|
||||
@RestController
|
||||
@RequestMapping("/market/activity")
|
||||
@Validated
|
||||
public class ActivityController {
|
||||
|
||||
@Resource
|
||||
private ActivityService activityService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@ApiOperation("创建促销活动")
|
||||
@PreAuthorize("@ss.hasPermission('market:activity:create')")
|
||||
public CommonResult<Long> createActivity(@Valid @RequestBody ActivityCreateReqVO createReqVO) {
|
||||
return success(activityService.createActivity(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@ApiOperation("更新促销活动")
|
||||
@PreAuthorize("@ss.hasPermission('market:activity:update')")
|
||||
public CommonResult<Boolean> updateActivity(@Valid @RequestBody ActivityUpdateReqVO updateReqVO) {
|
||||
activityService.updateActivity(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@ApiOperation("删除促销活动")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)
|
||||
@PreAuthorize("@ss.hasPermission('market:activity:delete')")
|
||||
public CommonResult<Boolean> deleteActivity(@RequestParam("id") Long id) {
|
||||
activityService.deleteActivity(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@ApiOperation("获得促销活动")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
|
||||
@PreAuthorize("@ss.hasPermission('market:activity:query')")
|
||||
public CommonResult<ActivityRespVO> getActivity(@RequestParam("id") Long id) {
|
||||
ActivityDO activity = activityService.getActivity(id);
|
||||
return success(ActivityConvert.INSTANCE.convert(activity));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("获得促销活动列表")
|
||||
@ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
|
||||
@PreAuthorize("@ss.hasPermission('market:activity:query')")
|
||||
public CommonResult<List<ActivityRespVO>> getActivityList(@RequestParam("ids") Collection<Long> ids) {
|
||||
List<ActivityDO> list = activityService.getActivityList(ids);
|
||||
return success(ActivityConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("获得促销活动分页")
|
||||
@PreAuthorize("@ss.hasPermission('market:activity:query')")
|
||||
public CommonResult<PageResult<ActivityRespVO>> getActivityPage(@Valid ActivityPageReqVO pageVO) {
|
||||
PageResult<ActivityDO> pageResult = activityService.getActivityPage(pageVO);
|
||||
return success(ActivityConvert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
package cn.iocoder.yudao.module.market.controller.admin.activity.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import cn.iocoder.yudao.module.market.enums.activity.MarketActivityStatusEnum;
|
||||
import cn.iocoder.yudao.module.market.enums.common.PromotionTypeEnum;
|
||||
import lombok.*;
|
||||
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 文档生成
|
||||
*/
|
||||
@Data
|
||||
public class ActivityBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "活动标题", required = true)
|
||||
@NotNull(message = "活动标题不能为空")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty(value = "活动类型", required = true)
|
||||
@NotNull(message = "活动类型不能为空")
|
||||
@InEnum(PromotionTypeEnum.class)
|
||||
private Integer activityType;
|
||||
|
||||
@ApiModelProperty(value = "活动状态", required = true)
|
||||
@NotNull(message = "活动状态不能为空")
|
||||
@InEnum(MarketActivityStatusEnum.class)
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "开始时间", required = true)
|
||||
@NotNull(message = "开始时间不能为空")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private Date startTime;
|
||||
|
||||
@ApiModelProperty(value = "结束时间", required = true)
|
||||
@NotNull(message = "结束时间不能为空")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private Date endTime;
|
||||
|
||||
@ApiModelProperty(value = "失效时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private Date invalidTime;
|
||||
|
||||
@ApiModelProperty(value = "删除时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private Date deleteTime;
|
||||
|
||||
@ApiModelProperty(value = "限制折扣字符串,使用 JSON 序列化成字符串存储")
|
||||
private String timeLimitedDiscount;
|
||||
|
||||
@ApiModelProperty(value = "限制折扣字符串,使用 JSON 序列化成字符串存储")
|
||||
private String fullPrivilege;
|
||||
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package cn.iocoder.yudao.module.market.controller.admin.activity.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* @author xia
|
||||
*/
|
||||
@ApiModel("管理后台 - 促销活动创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ActivityCreateReqVO extends ActivityBaseVO {
|
||||
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
package cn.iocoder.yudao.module.market.controller.admin.activity.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import cn.iocoder.yudao.module.market.enums.activity.MarketActivityStatusEnum;
|
||||
import cn.iocoder.yudao.module.market.enums.common.PromotionTypeEnum;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@ApiModel("管理后台 - 促销活动分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ActivityPageReqVO extends PageParam {
|
||||
|
||||
@ApiModelProperty(value = "活动标题")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty(value = "活动类型")
|
||||
@InEnum(PromotionTypeEnum.class)
|
||||
private Integer activityType;
|
||||
|
||||
@ApiModelProperty(value = "活动状态")
|
||||
@InEnum(MarketActivityStatusEnum.class)
|
||||
private Integer status;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始时间")
|
||||
private Date[] startTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束时间")
|
||||
private Date[] endTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "失效时间")
|
||||
private Date[] invalidTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "删除时间")
|
||||
private Date[] deleteTime;
|
||||
|
||||
@ApiModelProperty(value = "限制折扣字符串,使用 JSON 序列化成字符串存储")
|
||||
private String timeLimitedDiscount;
|
||||
|
||||
@ApiModelProperty(value = "限制折扣字符串,使用 JSON 序列化成字符串存储")
|
||||
private String fullPrivilege;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date[] createTime;
|
||||
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
package cn.iocoder.yudao.module.market.controller.admin.activity.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
@ApiModel("管理后台 - 促销活动 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ActivityRespVO extends ActivityBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "活动编号", required = true)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "创建时间", required = true)
|
||||
private Date createTime;
|
||||
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
package cn.iocoder.yudao.module.market.controller.admin.activity.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@ApiModel("管理后台 - 促销活动更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ActivityUpdateReqVO extends ActivityBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "活动编号", required = true)
|
||||
@NotNull(message = "活动编号不能为空")
|
||||
private Long id;
|
||||
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
/**
|
||||
* TODO 占位
|
||||
*/
|
||||
package cn.iocoder.yudao.module.market.controller.admin.discount;
|
|
@ -1,32 +0,0 @@
|
|||
package cn.iocoder.yudao.module.market.convert.activity;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
import cn.iocoder.yudao.module.market.controller.admin.activity.vo.*;
|
||||
import cn.iocoder.yudao.module.market.dal.dataobject.activity.ActivityDO;
|
||||
|
||||
/**
|
||||
* 促销活动 Convert
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface ActivityConvert {
|
||||
|
||||
ActivityConvert INSTANCE = Mappers.getMapper(ActivityConvert.class);
|
||||
|
||||
ActivityDO convert(ActivityCreateReqVO bean);
|
||||
|
||||
ActivityDO convert(ActivityUpdateReqVO bean);
|
||||
|
||||
ActivityRespVO convert(ActivityDO bean);
|
||||
|
||||
List<ActivityRespVO> convertList(List<ActivityDO> list);
|
||||
|
||||
PageResult<ActivityRespVO> convertPage(PageResult<ActivityDO> page);
|
||||
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
/**
|
||||
* TODO 占位
|
||||
*/
|
||||
package cn.iocoder.yudao.module.market.convert.discount;
|
|
@ -1,64 +0,0 @@
|
|||
package cn.iocoder.yudao.module.market.dal.dataobject.activity;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 促销活动 DO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@TableName("market_activity")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ActivityDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 活动编号
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 活动标题
|
||||
*/
|
||||
private String title;
|
||||
/**
|
||||
* 活动类型MarketActivityTypeEnum
|
||||
*/
|
||||
private Integer activityType;
|
||||
/**
|
||||
* 活动状态MarketActivityStatusEnum
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
private Date startTime;
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
private Date endTime;
|
||||
/**
|
||||
* 失效时间
|
||||
*/
|
||||
private Date invalidTime;
|
||||
/**
|
||||
* 删除时间
|
||||
*/
|
||||
private Date deleteTime;
|
||||
/**
|
||||
* 限制折扣字符串,使用 JSON 序列化成字符串存储
|
||||
*/
|
||||
private String timeLimitedDiscount;
|
||||
/**
|
||||
* 限制折扣字符串,使用 JSON 序列化成字符串存储
|
||||
*/
|
||||
private String fullPrivilege;
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package cn.iocoder.yudao.module.market.dal.dataobject.discount;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import cn.iocoder.yudao.module.market.enums.common.PromotionActivityStatusEnum;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 限时折扣活动 DO
|
||||
*
|
||||
* 一个活动下,可以有 {@link DiscountProductDO} 商品;
|
||||
* 一个商品,在指定时间段内,只能属于一个活动;
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@TableName(value = "promotion_discount_activity", autoResultMap = true)
|
||||
@KeySequence("promotion_discount_activity_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class DiscountActivityDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 活动编号,主键自增
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 活动标题
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 状态
|
||||
*
|
||||
* 枚举 {@link PromotionActivityStatusEnum}
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
private Date startTime;
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
private Date endTime;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package cn.iocoder.yudao.module.market.dal.dataobject.discount;
|
||||
|
||||
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.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 限时折扣商品 DO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@TableName(value = "promotion_discount_product", autoResultMap = true)
|
||||
@KeySequence("promotion_discount_product_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class DiscountProductDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 编号,主键自增
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 限时折扣活动的编号
|
||||
*
|
||||
* 关联 {@link DiscountActivityDO#getId()}
|
||||
*/
|
||||
private Long activityId;
|
||||
/**
|
||||
* 商品 SPU 编号
|
||||
*
|
||||
* 关联 ProductSpuDO 的 id 编号
|
||||
*/
|
||||
private Long spuId;
|
||||
/**
|
||||
* 商品 SKU 编号
|
||||
*
|
||||
* 关联 ProductSkuDO 的 id 编号
|
||||
*/
|
||||
private Long skuId;
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
private Date startTime;
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
private Date endTime;
|
||||
/**
|
||||
* 销售价格,单位:分
|
||||
*
|
||||
* 冗余 ProductSkuDO 的 price 字段
|
||||
*/
|
||||
private Integer originalPrice;
|
||||
/**
|
||||
* 优惠价格,单位:分
|
||||
*/
|
||||
private Integer promotionPrice;
|
||||
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
package cn.iocoder.yudao.module.market.dal.dataobject.reward;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import cn.iocoder.yudao.module.market.enums.common.PromotionActivityStatusEnum;
|
||||
import cn.iocoder.yudao.module.market.enums.common.PromotionConditionTypeEnum;
|
||||
import cn.iocoder.yudao.module.market.enums.common.PromotionProductScopeEnum;
|
||||
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 com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 满减送活动 DO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@TableName(value = "promotion_reward_activity", autoResultMap = true)
|
||||
@KeySequence("promotion_reward_activity_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class RewardActivityDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 活动编号,主键自增
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 活动标题
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 状态
|
||||
*
|
||||
* 枚举 {@link PromotionActivityStatusEnum}
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
private Date startTime;
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
private Date endTime;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
/**
|
||||
* 条件类型
|
||||
*
|
||||
* 枚举 {@link PromotionConditionTypeEnum}
|
||||
*/
|
||||
private Integer conditionType;
|
||||
/**
|
||||
* 商品范围
|
||||
*
|
||||
* 枚举 {@link PromotionProductScopeEnum}
|
||||
*/
|
||||
private Integer productScope;
|
||||
/**
|
||||
* 商品 SPU 编号的数组
|
||||
*/
|
||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||
private List<Long> spuIds;
|
||||
/**
|
||||
* 优惠规则的数组
|
||||
*/
|
||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||
private List<Rule> rules;
|
||||
|
||||
/**
|
||||
* 优惠规则
|
||||
*/
|
||||
@Data
|
||||
public static class Rule {
|
||||
|
||||
/**
|
||||
* 优惠门槛
|
||||
*
|
||||
* 1. 满 N 元,单位:分
|
||||
* 2. 满 N 件
|
||||
*/
|
||||
private Integer limit;
|
||||
/**
|
||||
* 优惠价格,单位:分
|
||||
*/
|
||||
private Integer promotionPrice;
|
||||
/**
|
||||
* 是否包邮
|
||||
*/
|
||||
private Boolean freeDelivery;
|
||||
/**
|
||||
* 赠送的积分
|
||||
*/
|
||||
private Integer integral;
|
||||
/**
|
||||
* 赠送的优惠劵编号的数组
|
||||
*/
|
||||
private List<Long> couponIds;
|
||||
/**
|
||||
* 赠送的优惠卷数量的数组
|
||||
*/
|
||||
private List<Integer> couponCounts;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
package cn.iocoder.yudao.module.market.dal.mysql.activity;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.market.dal.dataobject.activity.ActivityDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.market.controller.admin.activity.vo.*;
|
||||
|
||||
/**
|
||||
* 促销活动 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface ActivityMapper extends BaseMapperX<ActivityDO> {
|
||||
|
||||
default PageResult<ActivityDO> selectPage(ActivityPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<ActivityDO>()
|
||||
.eqIfPresent(ActivityDO::getTitle, reqVO.getTitle())
|
||||
.eqIfPresent(ActivityDO::getActivityType, reqVO.getActivityType())
|
||||
.eqIfPresent(ActivityDO::getStatus, reqVO.getStatus())
|
||||
.betweenIfPresent(ActivityDO::getStartTime, reqVO.getStartTime())
|
||||
.betweenIfPresent(ActivityDO::getEndTime, reqVO.getEndTime())
|
||||
.betweenIfPresent(ActivityDO::getInvalidTime, reqVO.getInvalidTime())
|
||||
.betweenIfPresent(ActivityDO::getDeleteTime, reqVO.getDeleteTime())
|
||||
.eqIfPresent(ActivityDO::getTimeLimitedDiscount, reqVO.getTimeLimitedDiscount())
|
||||
.eqIfPresent(ActivityDO::getFullPrivilege, reqVO.getFullPrivilege())
|
||||
.betweenIfPresent(ActivityDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(ActivityDO::getId));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
/**
|
||||
* TODO 占位
|
||||
*/
|
||||
package cn.iocoder.yudao.module.market.dal.mysql.discount;
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
* market 模块,我们放营销业务。
|
||||
* promotion 模块,我们放营销业务。
|
||||
* 例如说:营销活动、banner、优惠券等等
|
||||
*
|
||||
* 1. Controller URL:以 /market/ 开头,避免和其它 Module 冲突
|
||||
* 2. DataObject 表名:以 market_ 开头,方便在数据库中区分
|
||||
* 1. Controller URL:以 /promotion/ 开头,避免和其它 Module 冲突
|
||||
* 2. DataObject 表名:以 promotion_ 开头,方便在数据库中区分
|
||||
*/
|
||||
package cn.iocoder.yudao.module.market;
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
package cn.iocoder.yudao.module.market.service.activity;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
import cn.iocoder.yudao.module.market.controller.admin.activity.vo.*;
|
||||
import cn.iocoder.yudao.module.market.dal.dataobject.activity.ActivityDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
/**
|
||||
* 促销活动 Service 接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface ActivityService {
|
||||
|
||||
/**
|
||||
* 创建促销活动
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createActivity(@Valid ActivityCreateReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新促销活动
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateActivity(@Valid ActivityUpdateReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除促销活动
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteActivity(Long id);
|
||||
|
||||
/**
|
||||
* 获得促销活动
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 促销活动
|
||||
*/
|
||||
ActivityDO getActivity(Long id);
|
||||
|
||||
/**
|
||||
* 获得促销活动列表
|
||||
*
|
||||
* @param ids 编号
|
||||
* @return 促销活动列表
|
||||
*/
|
||||
List<ActivityDO> getActivityList(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得促销活动分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 促销活动分页
|
||||
*/
|
||||
PageResult<ActivityDO> getActivityPage(ActivityPageReqVO pageReqVO);
|
||||
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
package cn.iocoder.yudao.module.market.service.activity;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.market.controller.admin.activity.vo.*;
|
||||
import cn.iocoder.yudao.module.market.dal.dataobject.activity.ActivityDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import cn.iocoder.yudao.module.market.convert.activity.ActivityConvert;
|
||||
import cn.iocoder.yudao.module.market.dal.mysql.activity.ActivityMapper;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.market.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 促销活动 Service 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class ActivityServiceImpl implements ActivityService {
|
||||
|
||||
@Resource
|
||||
private ActivityMapper activityMapper;
|
||||
|
||||
@Override
|
||||
public Long createActivity(ActivityCreateReqVO createReqVO) {
|
||||
// 插入
|
||||
ActivityDO activity = ActivityConvert.INSTANCE.convert(createReqVO);
|
||||
activityMapper.insert(activity);
|
||||
// 返回
|
||||
return activity.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateActivity(ActivityUpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
this.validateActivityExists(updateReqVO.getId());
|
||||
// 更新
|
||||
ActivityDO updateObj = ActivityConvert.INSTANCE.convert(updateReqVO);
|
||||
activityMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteActivity(Long id) {
|
||||
// 校验存在
|
||||
this.validateActivityExists(id);
|
||||
// 删除
|
||||
activityMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateActivityExists(Long id) {
|
||||
if (activityMapper.selectById(id) == null) {
|
||||
throw exception(ACTIVITY_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActivityDO getActivity(Long id) {
|
||||
return activityMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ActivityDO> getActivityList(Collection<Long> ids) {
|
||||
return activityMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ActivityDO> getActivityPage(ActivityPageReqVO pageReqVO) {
|
||||
return activityMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
/**
|
||||
* TODO 占位
|
||||
*/
|
||||
package cn.iocoder.yudao.module.market.service.discount;
|
|
@ -1,197 +0,0 @@
|
|||
package cn.iocoder.yudao.module.market.service.activity;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||
|
||||
import cn.iocoder.yudao.module.market.controller.admin.activity.vo.*;
|
||||
import cn.iocoder.yudao.module.market.dal.dataobject.activity.ActivityDO;
|
||||
import cn.iocoder.yudao.module.market.dal.mysql.activity.ActivityMapper;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import static cn.iocoder.yudao.module.market.enums.ErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* {@link ActivityServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Import(ActivityServiceImpl.class)
|
||||
public class ActivityServiceImplTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private ActivityServiceImpl activityService;
|
||||
|
||||
@Resource
|
||||
private ActivityMapper activityMapper;
|
||||
|
||||
@Test
|
||||
public void testCreateActivity_success() {
|
||||
// 准备参数
|
||||
ActivityCreateReqVO reqVO = randomPojo(ActivityCreateReqVO.class);
|
||||
|
||||
// 调用
|
||||
Long activityId = activityService.createActivity(reqVO);
|
||||
// 断言
|
||||
assertNotNull(activityId);
|
||||
// 校验记录的属性是否正确
|
||||
ActivityDO activity = activityMapper.selectById(activityId);
|
||||
assertPojoEquals(reqVO, activity);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateActivity_success() {
|
||||
// mock 数据
|
||||
ActivityDO dbActivity = randomPojo(ActivityDO.class);
|
||||
activityMapper.insert(dbActivity);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
ActivityUpdateReqVO reqVO = randomPojo(ActivityUpdateReqVO.class, o -> {
|
||||
o.setId(dbActivity.getId()); // 设置更新的 ID
|
||||
});
|
||||
|
||||
// 调用
|
||||
activityService.updateActivity(reqVO);
|
||||
// 校验是否更新正确
|
||||
ActivityDO activity = activityMapper.selectById(reqVO.getId()); // 获取最新的
|
||||
assertPojoEquals(reqVO, activity);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateActivity_notExists() {
|
||||
// 准备参数
|
||||
ActivityUpdateReqVO reqVO = randomPojo(ActivityUpdateReqVO.class);
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> activityService.updateActivity(reqVO), ACTIVITY_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteActivity_success() {
|
||||
// mock 数据
|
||||
ActivityDO dbActivity = randomPojo(ActivityDO.class);
|
||||
activityMapper.insert(dbActivity);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
Long id = dbActivity.getId();
|
||||
|
||||
// 调用
|
||||
activityService.deleteActivity(id);
|
||||
// 校验数据不存在了
|
||||
assertNull(activityMapper.selectById(id));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteActivity_notExists() {
|
||||
// 准备参数
|
||||
Long id = randomLongId();
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> activityService.deleteActivity(id), ACTIVITY_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void testGetActivityPage() {
|
||||
// mock 数据
|
||||
ActivityDO dbActivity = randomPojo(ActivityDO.class, o -> { // 等会查询到
|
||||
o.setTitle(null);
|
||||
o.setActivityType(null);
|
||||
o.setStatus(null);
|
||||
o.setStartTime(null);
|
||||
o.setEndTime(null);
|
||||
o.setInvalidTime(null);
|
||||
o.setDeleteTime(null);
|
||||
o.setTimeLimitedDiscount(null);
|
||||
o.setFullPrivilege(null);
|
||||
o.setCreateTime(null);
|
||||
});
|
||||
activityMapper.insert(dbActivity);
|
||||
// 测试 title 不匹配
|
||||
activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setTitle(null)));
|
||||
// 测试 activityType 不匹配
|
||||
activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setActivityType(null)));
|
||||
// 测试 status 不匹配
|
||||
activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setStatus(null)));
|
||||
// 测试 startTime 不匹配
|
||||
activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setStartTime(null)));
|
||||
// 测试 endTime 不匹配
|
||||
activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setEndTime(null)));
|
||||
// 测试 invalidTime 不匹配
|
||||
activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setInvalidTime(null)));
|
||||
// 测试 deleteTime 不匹配
|
||||
activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setDeleteTime(null)));
|
||||
// 测试 timeLimitedDiscount 不匹配
|
||||
activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setTimeLimitedDiscount(null)));
|
||||
// 测试 fullPrivilege 不匹配
|
||||
activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setFullPrivilege(null)));
|
||||
// 测试 createTime 不匹配
|
||||
activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setCreateTime(null)));
|
||||
// 准备参数
|
||||
ActivityPageReqVO reqVO = new ActivityPageReqVO();
|
||||
reqVO.setTitle(null);
|
||||
reqVO.setActivityType(null);
|
||||
reqVO.setStatus(null);
|
||||
reqVO.setStartTime(null);
|
||||
reqVO.setEndTime(null);
|
||||
reqVO.setInvalidTime(null);
|
||||
reqVO.setDeleteTime(null);
|
||||
reqVO.setTimeLimitedDiscount(null);
|
||||
reqVO.setFullPrivilege(null);
|
||||
reqVO.setCreateTime(null);
|
||||
|
||||
// 调用
|
||||
PageResult<ActivityDO> pageResult = activityService.getActivityPage(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbActivity, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void testGetActivityList() {
|
||||
// mock 数据
|
||||
ActivityDO dbActivity = randomPojo(ActivityDO.class, o -> { // 等会查询到
|
||||
o.setTitle(null);
|
||||
o.setActivityType(null);
|
||||
o.setStatus(null);
|
||||
o.setStartTime(null);
|
||||
o.setEndTime(null);
|
||||
o.setInvalidTime(null);
|
||||
o.setDeleteTime(null);
|
||||
o.setTimeLimitedDiscount(null);
|
||||
o.setFullPrivilege(null);
|
||||
o.setCreateTime(null);
|
||||
});
|
||||
activityMapper.insert(dbActivity);
|
||||
// 测试 title 不匹配
|
||||
activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setTitle(null)));
|
||||
// 测试 activityType 不匹配
|
||||
activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setActivityType(null)));
|
||||
// 测试 status 不匹配
|
||||
activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setStatus(null)));
|
||||
// 测试 startTime 不匹配
|
||||
activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setStartTime(null)));
|
||||
// 测试 endTime 不匹配
|
||||
activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setEndTime(null)));
|
||||
// 测试 invalidTime 不匹配
|
||||
activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setInvalidTime(null)));
|
||||
// 测试 deleteTime 不匹配
|
||||
activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setDeleteTime(null)));
|
||||
// 测试 timeLimitedDiscount 不匹配
|
||||
activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setTimeLimitedDiscount(null)));
|
||||
// 测试 fullPrivilege 不匹配
|
||||
activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setFullPrivilege(null)));
|
||||
// 测试 createTime 不匹配
|
||||
activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setCreateTime(null)));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue