New file |
| | |
| | | package cn.lili.modules; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | public class Demo_1 { |
| | | |
| | | // 奖品类 |
| | | static class Prize { |
| | | private String name; // 奖品名称 |
| | | private double probability; // 中奖概率(0-1之间) |
| | | |
| | | public Prize(String name, double probability) { |
| | | this.name = name; |
| | | this.probability = probability; |
| | | } |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public double getProbability() { |
| | | return probability; |
| | | } |
| | | } |
| | | |
| | | // 抽奖系统类 |
| | | public static class LotterySystem { |
| | | private List<Prize> prizes; |
| | | private List<Double> probabilityIntervals; |
| | | private Random random; |
| | | |
| | | public LotterySystem(List<Prize> prizes) { |
| | | // 验证概率总和是否为1 |
| | | double totalProbability = 0; |
| | | for (Prize prize : prizes) { |
| | | totalProbability += prize.getProbability(); |
| | | } |
| | | |
| | | // 如果总和不是1,进行归一化处理 |
| | | if (Math.abs(totalProbability - 1.0) > 0.0001) { |
| | | List<Prize> normalizedPrizes = new ArrayList<>(); |
| | | for (Prize prize : prizes) { |
| | | normalizedPrizes.add(new Prize( |
| | | prize.getName(), |
| | | prize.getProbability() / totalProbability |
| | | )); |
| | | } |
| | | this.prizes = normalizedPrizes; |
| | | } else { |
| | | this.prizes = prizes; |
| | | } |
| | | |
| | | // 初始化概率区间 |
| | | initProbabilityIntervals(); |
| | | this.random = new Random(); |
| | | } |
| | | |
| | | // 初始化概率区间 |
| | | private void initProbabilityIntervals() { |
| | | probabilityIntervals = new ArrayList<>(); |
| | | double current = 0; |
| | | |
| | | for (Prize prize : prizes) { |
| | | current += prize.getProbability(); |
| | | probabilityIntervals.add(current); |
| | | } |
| | | } |
| | | |
| | | // 执行抽奖 |
| | | public String draw() { |
| | | // 生成0-1之间的随机数 |
| | | double randomValue = random.nextDouble(); |
| | | |
| | | // 查找随机数落在哪个区间 |
| | | for (int i = 0; i < probabilityIntervals.size(); i++) { |
| | | if (randomValue < probabilityIntervals.get(i)) { |
| | | return prizes.get(i).getName(); |
| | | } |
| | | } |
| | | |
| | | // 理论上不会走到这里 |
| | | return "未中奖"; |
| | | } |
| | | |
| | | // 测试抽奖系统 |
| | | public static void main(String[] args) { |
| | | // 创建5个奖品,设置不同的中奖概率 |
| | | List<Prize> prizes = new ArrayList<>(); |
| | | prizes.add(new Prize("一等奖", 0.01)); // 1%概率 |
| | | prizes.add(new Prize("二等奖", 0.05)); // 5%概率 |
| | | prizes.add(new Prize("三等奖", 0.1)); // 10%概率 |
| | | prizes.add(new Prize("四等奖", 0.2)); // 20%概率 |
| | | prizes.add(new Prize("五等奖", 0.64)); // 64%概率 |
| | | |
| | | // 创建抽奖系统 |
| | | LotterySystem lottery = new LotterySystem(prizes); |
| | | |
| | | // 测试10000次抽奖,查看概率分布 |
| | | Map<String, Integer> result = new HashMap<>(); |
| | | int totalDraws = 100000; |
| | | |
| | | for (int i = 0; i < totalDraws; i++) { |
| | | String prizeName = lottery.draw(); |
| | | result.put(prizeName, result.getOrDefault(prizeName, 0) + 1); |
| | | } |
| | | |
| | | // 输出结果 |
| | | System.out.println("抽奖" + totalDraws + "次的结果:"); |
| | | for (Map.Entry<String, Integer> entry : result.entrySet()) { |
| | | double percentage = (entry.getValue() * 100.0) / totalDraws; |
| | | System.out.printf("%s: %d次 (%.2f%%)\n", |
| | | entry.getKey(), entry.getValue(), percentage); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.domain.entity; |
| | | |
| | | import cn.lili.mybatis.BaseEntity; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 活动奖品关联表 |
| | | * |
| | | * @author peng |
| | | * @since 2025-08-14 |
| | | */ |
| | | @Data |
| | | @TableName("lmk_activity_ref_prize") |
| | | public class ActivityRefPrize extends BaseEntity { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @TableField("prize_activity_id") |
| | | /** 抽奖活动id */ |
| | | private Long prizeActivityId; |
| | | |
| | | @TableField("prize_id") |
| | | /** 奖品id */ |
| | | private Long prizeId; |
| | | |
| | | @TableField("prize_content") |
| | | /** 奖品内容 */ |
| | | private String prizeContent; |
| | | |
| | | @TableField("prize_num") |
| | | /** 奖品数量 */ |
| | | private Integer prizeNum; |
| | | |
| | | @TableField("prize_probability") |
| | | /** 中将概率 */ |
| | | private BigDecimal prizeProbability; |
| | | |
| | | @TableField("version") |
| | | /** 乐观锁 */ |
| | | private Integer version; |
| | | |
| | | @TableField("remain_num") |
| | | /** 剩余数量 */ |
| | | private Integer remainNum; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.domain.entity; |
| | | |
| | | import cn.lili.mybatis.BaseEntity; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import java.io.Serializable; |
| | | import java.time.LocalDateTime; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 抽奖活动 |
| | | * |
| | | * @author peng |
| | | * @since 2025-08-14 |
| | | */ |
| | | @Data |
| | | @TableName("lmk_prize_activity") |
| | | public class PrizeActivity extends BaseEntity { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @TableField("activity_name") |
| | | /** 活动名称 */ |
| | | private String activityName; |
| | | |
| | | @TableField("activity_des") |
| | | /** 活动描述 */ |
| | | private String activityDes; |
| | | |
| | | @TableField("begin_time") |
| | | /** 活动开始时间 */ |
| | | private LocalDateTime beginTime; |
| | | |
| | | @TableField("end_time") |
| | | /** 活动结束时间 */ |
| | | private LocalDateTime endTime; |
| | | |
| | | @TableField("max_prize") |
| | | /** 每日最大抽奖上限 */ |
| | | private Integer maxPrize; |
| | | |
| | | @TableField("prize_num") |
| | | /** 初始化抽奖次数 */ |
| | | private Integer prizeNum; |
| | | |
| | | @TableField("activity_img") |
| | | /** 活动图片 */ |
| | | private String activityImg; |
| | | |
| | | @TableField("activity_cover") |
| | | /** 活动封面 */ |
| | | private String activityCover; |
| | | |
| | | @TableField("enable_status") |
| | | /** 是否开启活动 */ |
| | | private String enableStatus; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.domain.entity; |
| | | |
| | | import cn.lili.mybatis.BaseEntity; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import java.io.Serializable; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 抽奖活动奖品 |
| | | * |
| | | * @author peng |
| | | * @since 2025-08-14 |
| | | */ |
| | | @Data |
| | | @TableName("lmk_prize_draw") |
| | | public class PrizeDraw extends BaseEntity { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @TableField("prize_name") |
| | | /** 奖品名称 */ |
| | | private String prizeName; |
| | | |
| | | @TableField("prize_type") |
| | | /** 奖品类型 */ |
| | | private String prizeType; |
| | | |
| | | @TableField("coupon_id") |
| | | /** 优惠卷id */ |
| | | private Long couponId; |
| | | |
| | | @TableField("prize_content") |
| | | /** 奖品内容 */ |
| | | private String prizeContent; |
| | | |
| | | @TableField("prize_cover") |
| | | /** 奖品封面 */ |
| | | private String prizeCover; |
| | | |
| | | @TableField("prize_des") |
| | | /** 奖品描述 */ |
| | | private String prizeDes; |
| | | |
| | | @TableField("prize_img") |
| | | /** 奖品图片 */ |
| | | private String prizeImg; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.domain.entity; |
| | | |
| | | import cn.lili.mybatis.BaseEntity; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import java.io.Serializable; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 获取抽奖次数记录表 |
| | | * |
| | | * @author peng |
| | | * @since 2025-08-14 |
| | | */ |
| | | @Data |
| | | @TableName("lmk_prize_number") |
| | | public class PrizeNumber extends BaseEntity { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @TableField("user_id") |
| | | /** 用户id */ |
| | | private Long userId; |
| | | |
| | | @TableField("activity_prize_id") |
| | | /** 抽奖活动id */ |
| | | private Long activityPrizeId; |
| | | |
| | | @TableField("user_action") |
| | | /** 用户行为 */ |
| | | private String userAction; |
| | | |
| | | @TableField("use_status") |
| | | /** 使用状态 */ |
| | | private String useStatus; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.domain.entity; |
| | | |
| | | import cn.lili.mybatis.BaseEntity; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import java.io.Serializable; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 用户抽奖记录表 |
| | | * |
| | | * @author peng |
| | | * @since 2025-08-14 |
| | | */ |
| | | @Data |
| | | @TableName("lmk_prize_record") |
| | | public class PrizeRecord extends BaseEntity { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @TableField("user_id") |
| | | /** 用户id */ |
| | | private Long userId; |
| | | |
| | | @TableField("nick_name") |
| | | /** 用户昵称 */ |
| | | private String nickName; |
| | | |
| | | @TableField("prize_activity_id") |
| | | /** 活动id */ |
| | | private Long prizeActivityId; |
| | | |
| | | @TableField("prize_activity_name") |
| | | /** 活动名称 */ |
| | | private String prizeActivityName; |
| | | |
| | | @TableField("prize_activity_cover") |
| | | /** 活动封面 */ |
| | | private String prizeActivityCover; |
| | | |
| | | @TableField("prize_status") |
| | | /** 中奖状态 */ |
| | | private String prizeStatus; |
| | | |
| | | @TableField("prize_content") |
| | | /** 中奖内容 */ |
| | | private String prizeContent; |
| | | |
| | | @TableField("prize_id") |
| | | /** 奖品id */ |
| | | private Long prizeId; |
| | | |
| | | @TableField("prize_img") |
| | | /** 奖品封面 */ |
| | | private String prizeImg; |
| | | |
| | | @TableField("prize_num_id") |
| | | /** 抽奖次数表id */ |
| | | private Long prizeNumId; |
| | | |
| | | @TableField("activity_prize_ref_id") |
| | | /** 活动奖品关联表id */ |
| | | private Long activityPrizeRefId; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.domain.form; |
| | | |
| | | import cn.lili.group.Update; |
| | | import cn.lili.group.Add; |
| | | import cn.lili.base.AbsForm; |
| | | import cn.lili.modules.lmk.domain.entity.ActivityRefPrize; |
| | | import org.springframework.beans.BeanUtils; |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | import org.springframework.lang.NonNull; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 活动奖品关联表表单 |
| | | * |
| | | * @author peng |
| | | * @since 2025-08-14 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "ActivityRefPrize表单", description = "活动奖品关联表表单") |
| | | public class ActivityRefPrizeForm extends AbsForm { |
| | | |
| | | @NotNull(message = "抽奖活动id不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("抽奖活动id") |
| | | private Long prizeActivityId; |
| | | |
| | | @NotNull(message = "奖品id不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("奖品id") |
| | | private Long prizeId; |
| | | |
| | | @NotBlank(message = "奖品内容不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("奖品内容") |
| | | private String prizeContent; |
| | | |
| | | @NotNull(message = "奖品数量不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("奖品数量") |
| | | private Integer prizeNum; |
| | | |
| | | @NotNull(message = "中将概率不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("中将概率") |
| | | private BigDecimal prizeProbability; |
| | | |
| | | @NotNull(message = "乐观锁不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("乐观锁") |
| | | private Integer version; |
| | | |
| | | @NotNull(message = "剩余数量不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("剩余数量") |
| | | private Integer remainNum; |
| | | |
| | | public static ActivityRefPrize getEntityByForm(@NonNull ActivityRefPrizeForm form, ActivityRefPrize entity) { |
| | | if(entity == null) { |
| | | entity = new ActivityRefPrize(); |
| | | } |
| | | BeanUtils.copyProperties(form, entity); |
| | | return entity; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.domain.form; |
| | | |
| | | import cn.lili.group.Update; |
| | | import cn.lili.group.Add; |
| | | import cn.lili.base.AbsForm; |
| | | import cn.lili.modules.lmk.domain.entity.PrizeActivity; |
| | | import org.springframework.beans.BeanUtils; |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | import org.springframework.lang.NonNull; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 抽奖活动表单 |
| | | * |
| | | * @author peng |
| | | * @since 2025-08-14 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "PrizeActivity表单", description = "抽奖活动表单") |
| | | public class PrizeActivityForm extends AbsForm { |
| | | |
| | | @NotBlank(message = "活动名称不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("活动名称") |
| | | private String activityName; |
| | | |
| | | @NotBlank(message = "活动描述不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("活动描述") |
| | | private String activityDes; |
| | | |
| | | @NotNull(message = "活动开始时间不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("活动开始时间") |
| | | private Date beginTime; |
| | | |
| | | @NotNull(message = "活动结束时间不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("活动结束时间") |
| | | private Date endTime; |
| | | |
| | | @NotNull(message = "每日最大抽奖上限不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("每日最大抽奖上限") |
| | | private Integer maxPrize; |
| | | |
| | | @NotNull(message = "初始化抽奖次数不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("初始化抽奖次数") |
| | | private Integer prizeNum; |
| | | |
| | | @NotBlank(message = "活动图片不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("活动图片") |
| | | private String activityImg; |
| | | |
| | | @NotBlank(message = "活动封面不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("活动封面") |
| | | private String activityCover; |
| | | |
| | | @NotBlank(message = "是否开启活动不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("是否开启活动") |
| | | private String enableStatus; |
| | | |
| | | public static PrizeActivity getEntityByForm(@NonNull PrizeActivityForm form, PrizeActivity entity) { |
| | | if(entity == null) { |
| | | entity = new PrizeActivity(); |
| | | } |
| | | BeanUtils.copyProperties(form, entity); |
| | | return entity; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.domain.form; |
| | | |
| | | import cn.lili.group.Update; |
| | | import cn.lili.group.Add; |
| | | import cn.lili.base.AbsForm; |
| | | import cn.lili.modules.lmk.domain.entity.PrizeDraw; |
| | | import org.springframework.beans.BeanUtils; |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | import org.springframework.lang.NonNull; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 抽奖活动奖品表单 |
| | | * |
| | | * @author peng |
| | | * @since 2025-08-14 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "PrizeDraw表单", description = "抽奖活动奖品表单") |
| | | public class PrizeDrawForm extends AbsForm { |
| | | |
| | | @NotBlank(message = "奖品名称不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("奖品名称") |
| | | private String prizeName; |
| | | |
| | | @NotBlank(message = "奖品类型不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("奖品类型") |
| | | private String prizeType; |
| | | |
| | | @NotNull(message = "优惠卷id不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("优惠卷id") |
| | | private Long couponId; |
| | | |
| | | @NotBlank(message = "奖品内容不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("奖品内容") |
| | | private String prizeContent; |
| | | |
| | | @NotBlank(message = "奖品封面不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("奖品封面") |
| | | private String prizeCover; |
| | | |
| | | @NotBlank(message = "奖品描述不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("奖品描述") |
| | | private String prizeDes; |
| | | |
| | | @NotBlank(message = "奖品图片不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("奖品图片") |
| | | private String prizeImg; |
| | | |
| | | public static PrizeDraw getEntityByForm(@NonNull PrizeDrawForm form, PrizeDraw entity) { |
| | | if(entity == null) { |
| | | entity = new PrizeDraw(); |
| | | } |
| | | BeanUtils.copyProperties(form, entity); |
| | | return entity; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.domain.form; |
| | | |
| | | import cn.lili.group.Update; |
| | | import cn.lili.group.Add; |
| | | import cn.lili.base.AbsForm; |
| | | import cn.lili.modules.lmk.domain.entity.PrizeNumber; |
| | | import org.springframework.beans.BeanUtils; |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | import org.springframework.lang.NonNull; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 获取抽奖次数记录表表单 |
| | | * |
| | | * @author peng |
| | | * @since 2025-08-14 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "PrizeNumber表单", description = "获取抽奖次数记录表表单") |
| | | public class PrizeNumberForm extends AbsForm { |
| | | |
| | | @NotNull(message = "用户id不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("用户id") |
| | | private Long userId; |
| | | |
| | | @NotNull(message = "抽奖活动id不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("抽奖活动id") |
| | | private Long activityPrizeId; |
| | | |
| | | @NotBlank(message = "用户行为不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("用户行为") |
| | | private String userAction; |
| | | |
| | | @NotBlank(message = "使用状态不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("使用状态") |
| | | private String useStatus; |
| | | |
| | | public static PrizeNumber getEntityByForm(@NonNull PrizeNumberForm form, PrizeNumber entity) { |
| | | if(entity == null) { |
| | | entity = new PrizeNumber(); |
| | | } |
| | | BeanUtils.copyProperties(form, entity); |
| | | return entity; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.domain.form; |
| | | |
| | | import cn.lili.group.Update; |
| | | import cn.lili.group.Add; |
| | | import cn.lili.base.AbsForm; |
| | | import cn.lili.modules.lmk.domain.entity.PrizeRecord; |
| | | import org.springframework.beans.BeanUtils; |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | import org.springframework.lang.NonNull; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 用户抽奖记录表表单 |
| | | * |
| | | * @author peng |
| | | * @since 2025-08-14 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "PrizeRecord表单", description = "用户抽奖记录表表单") |
| | | public class PrizeRecordForm extends AbsForm { |
| | | |
| | | @NotNull(message = "用户id不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("用户id") |
| | | private Long userId; |
| | | |
| | | @NotBlank(message = "用户昵称不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("用户昵称") |
| | | private String nickName; |
| | | |
| | | @NotNull(message = "活动id不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("活动id") |
| | | private Long prizeActivityId; |
| | | |
| | | @NotBlank(message = "活动名称不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("活动名称") |
| | | private String prizeActivityName; |
| | | |
| | | @NotBlank(message = "活动封面不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("活动封面") |
| | | private String prizeActivityCover; |
| | | |
| | | @NotBlank(message = "中奖状态不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("中奖状态") |
| | | private String prizeStatus; |
| | | |
| | | @NotBlank(message = "中奖内容不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("中奖内容") |
| | | private String prizeContent; |
| | | |
| | | @NotNull(message = "奖品id不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("奖品id") |
| | | private Long prizeId; |
| | | |
| | | @NotBlank(message = "奖品封面不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("奖品封面") |
| | | private String prizeImg; |
| | | |
| | | @NotNull(message = "抽奖次数表id不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("抽奖次数表id") |
| | | private Long prizeNumId; |
| | | |
| | | @NotNull(message = "活动奖品关联表id不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("活动奖品关联表id") |
| | | private Long activityPrizeRefId; |
| | | |
| | | public static PrizeRecord getEntityByForm(@NonNull PrizeRecordForm form, PrizeRecord entity) { |
| | | if(entity == null) { |
| | | entity = new PrizeRecord(); |
| | | } |
| | | BeanUtils.copyProperties(form, entity); |
| | | return entity; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.domain.query; |
| | | |
| | | import cn.lili.base.AbsQuery; |
| | | import java.util.List; |
| | | import org.springframework.lang.NonNull; |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 活动奖品关联表查询 |
| | | * |
| | | * @author peng |
| | | * @since 2025-08-14 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "ActivityRefPrize查询参数", description = "活动奖品关联表查询参数") |
| | | public class ActivityRefPrizeQuery extends AbsQuery { |
| | | } |
| | | |
New file |
| | |
| | | package cn.lili.modules.lmk.domain.query; |
| | | |
| | | import cn.lili.base.AbsQuery; |
| | | import java.util.List; |
| | | import org.springframework.lang.NonNull; |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 抽奖活动查询 |
| | | * |
| | | * @author peng |
| | | * @since 2025-08-14 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "PrizeActivity查询参数", description = "抽奖活动查询参数") |
| | | public class PrizeActivityQuery extends AbsQuery { |
| | | } |
| | | |
New file |
| | |
| | | package cn.lili.modules.lmk.domain.query; |
| | | |
| | | import cn.lili.base.AbsQuery; |
| | | import java.util.List; |
| | | import org.springframework.lang.NonNull; |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 抽奖活动奖品查询 |
| | | * |
| | | * @author peng |
| | | * @since 2025-08-14 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "PrizeDraw查询参数", description = "抽奖活动奖品查询参数") |
| | | public class PrizeDrawQuery extends AbsQuery { |
| | | } |
| | | |
New file |
| | |
| | | package cn.lili.modules.lmk.domain.query; |
| | | |
| | | import cn.lili.base.AbsQuery; |
| | | import java.util.List; |
| | | import org.springframework.lang.NonNull; |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 获取抽奖次数记录表查询 |
| | | * |
| | | * @author peng |
| | | * @since 2025-08-14 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "PrizeNumber查询参数", description = "获取抽奖次数记录表查询参数") |
| | | public class PrizeNumberQuery extends AbsQuery { |
| | | } |
| | | |
New file |
| | |
| | | package cn.lili.modules.lmk.domain.query; |
| | | |
| | | import cn.lili.base.AbsQuery; |
| | | import java.util.List; |
| | | import org.springframework.lang.NonNull; |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 用户抽奖记录表查询 |
| | | * |
| | | * @author peng |
| | | * @since 2025-08-14 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "PrizeRecord查询参数", description = "用户抽奖记录表查询参数") |
| | | public class PrizeRecordQuery extends AbsQuery { |
| | | } |
| | | |
New file |
| | |
| | | package cn.lili.modules.lmk.domain.vo; |
| | | |
| | | import cn.lili.base.AbsVo; |
| | | import cn.lili.modules.lmk.domain.entity.ActivityRefPrize; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | import org.springframework.lang.NonNull; |
| | | import org.springframework.beans.BeanUtils; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 活动奖品关联表展示 |
| | | * |
| | | * @author peng |
| | | * @since 2025-08-14 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "活动奖品关联表响应数据", description = "活动奖品关联表响应数据") |
| | | public class ActivityRefPrizeVO extends AbsVo { |
| | | |
| | | /** 抽奖活动id */ |
| | | @ApiModelProperty("抽奖活动id") |
| | | private Long prizeActivityId; |
| | | |
| | | /** 奖品id */ |
| | | @ApiModelProperty("奖品id") |
| | | private Long prizeId; |
| | | |
| | | /** 奖品内容 */ |
| | | @ApiModelProperty("奖品内容") |
| | | private String prizeContent; |
| | | |
| | | /** 奖品数量 */ |
| | | @ApiModelProperty("奖品数量") |
| | | private Integer prizeNum; |
| | | |
| | | /** 中将概率 */ |
| | | @ApiModelProperty("中将概率") |
| | | private BigDecimal prizeProbability; |
| | | |
| | | /** 乐观锁 */ |
| | | @ApiModelProperty("乐观锁") |
| | | private Integer version; |
| | | |
| | | /** 剩余数量 */ |
| | | @ApiModelProperty("剩余数量") |
| | | private Integer remainNum; |
| | | |
| | | public static ActivityRefPrizeVO getVoByEntity(@NonNull ActivityRefPrize entity, ActivityRefPrizeVO vo) { |
| | | if(vo == null) { |
| | | vo = new ActivityRefPrizeVO(); |
| | | } |
| | | BeanUtils.copyProperties(entity, vo); |
| | | return vo; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.domain.vo; |
| | | |
| | | import cn.lili.base.AbsVo; |
| | | import cn.lili.modules.lmk.domain.entity.PrizeActivity; |
| | | import java.util.List; |
| | | import org.springframework.lang.NonNull; |
| | | import org.springframework.beans.BeanUtils; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 抽奖活动展示 |
| | | * |
| | | * @author peng |
| | | * @since 2025-08-14 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "抽奖活动响应数据", description = "抽奖活动响应数据") |
| | | public class PrizeActivityVO extends AbsVo { |
| | | |
| | | /** 活动名称 */ |
| | | @ApiModelProperty("活动名称") |
| | | private String activityName; |
| | | |
| | | /** 活动描述 */ |
| | | @ApiModelProperty("活动描述") |
| | | private String activityDes; |
| | | |
| | | /** 活动开始时间 */ |
| | | @ApiModelProperty("活动开始时间") |
| | | private Date beginTime; |
| | | |
| | | /** 活动结束时间 */ |
| | | @ApiModelProperty("活动结束时间") |
| | | private Date endTime; |
| | | |
| | | /** 每日最大抽奖上限 */ |
| | | @ApiModelProperty("每日最大抽奖上限") |
| | | private Integer maxPrize; |
| | | |
| | | /** 初始化抽奖次数 */ |
| | | @ApiModelProperty("初始化抽奖次数") |
| | | private Integer prizeNum; |
| | | |
| | | /** 活动图片 */ |
| | | @ApiModelProperty("活动图片") |
| | | private String activityImg; |
| | | |
| | | /** 活动封面 */ |
| | | @ApiModelProperty("活动封面") |
| | | private String activityCover; |
| | | |
| | | /** 是否开启活动 */ |
| | | @ApiModelProperty("是否开启活动") |
| | | private String enableStatus; |
| | | |
| | | public static PrizeActivityVO getVoByEntity(@NonNull PrizeActivity entity, PrizeActivityVO vo) { |
| | | if(vo == null) { |
| | | vo = new PrizeActivityVO(); |
| | | } |
| | | BeanUtils.copyProperties(entity, vo); |
| | | return vo; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.domain.vo; |
| | | |
| | | import cn.lili.base.AbsVo; |
| | | import cn.lili.modules.lmk.domain.entity.PrizeDraw; |
| | | import java.util.List; |
| | | import org.springframework.lang.NonNull; |
| | | import org.springframework.beans.BeanUtils; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 抽奖活动奖品展示 |
| | | * |
| | | * @author peng |
| | | * @since 2025-08-14 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "抽奖活动奖品响应数据", description = "抽奖活动奖品响应数据") |
| | | public class PrizeDrawVO extends AbsVo { |
| | | |
| | | /** 奖品名称 */ |
| | | @ApiModelProperty("奖品名称") |
| | | private String prizeName; |
| | | |
| | | /** 奖品类型 */ |
| | | @ApiModelProperty("奖品类型") |
| | | private String prizeType; |
| | | |
| | | /** 优惠卷id */ |
| | | @ApiModelProperty("优惠卷id") |
| | | private Long couponId; |
| | | |
| | | /** 奖品内容 */ |
| | | @ApiModelProperty("奖品内容") |
| | | private String prizeContent; |
| | | |
| | | /** 奖品封面 */ |
| | | @ApiModelProperty("奖品封面") |
| | | private String prizeCover; |
| | | |
| | | /** 奖品描述 */ |
| | | @ApiModelProperty("奖品描述") |
| | | private String prizeDes; |
| | | |
| | | /** 奖品图片 */ |
| | | @ApiModelProperty("奖品图片") |
| | | private String prizeImg; |
| | | |
| | | public static PrizeDrawVO getVoByEntity(@NonNull PrizeDraw entity, PrizeDrawVO vo) { |
| | | if(vo == null) { |
| | | vo = new PrizeDrawVO(); |
| | | } |
| | | BeanUtils.copyProperties(entity, vo); |
| | | return vo; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.domain.vo; |
| | | |
| | | import cn.lili.base.AbsVo; |
| | | import cn.lili.modules.lmk.domain.entity.PrizeNumber; |
| | | import java.util.List; |
| | | import org.springframework.lang.NonNull; |
| | | import org.springframework.beans.BeanUtils; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 获取抽奖次数记录表展示 |
| | | * |
| | | * @author peng |
| | | * @since 2025-08-14 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "获取抽奖次数记录表响应数据", description = "获取抽奖次数记录表响应数据") |
| | | public class PrizeNumberVO extends AbsVo { |
| | | |
| | | /** 用户id */ |
| | | @ApiModelProperty("用户id") |
| | | private Long userId; |
| | | |
| | | /** 抽奖活动id */ |
| | | @ApiModelProperty("抽奖活动id") |
| | | private Long activityPrizeId; |
| | | |
| | | /** 用户行为 */ |
| | | @ApiModelProperty("用户行为") |
| | | private String userAction; |
| | | |
| | | /** 使用状态 */ |
| | | @ApiModelProperty("使用状态") |
| | | private String useStatus; |
| | | |
| | | public static PrizeNumberVO getVoByEntity(@NonNull PrizeNumber entity, PrizeNumberVO vo) { |
| | | if(vo == null) { |
| | | vo = new PrizeNumberVO(); |
| | | } |
| | | BeanUtils.copyProperties(entity, vo); |
| | | return vo; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.domain.vo; |
| | | |
| | | import cn.lili.base.AbsVo; |
| | | import cn.lili.modules.lmk.domain.entity.PrizeRecord; |
| | | import java.util.List; |
| | | import org.springframework.lang.NonNull; |
| | | import org.springframework.beans.BeanUtils; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 用户抽奖记录表展示 |
| | | * |
| | | * @author peng |
| | | * @since 2025-08-14 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "用户抽奖记录表响应数据", description = "用户抽奖记录表响应数据") |
| | | public class PrizeRecordVO extends AbsVo { |
| | | |
| | | /** 用户id */ |
| | | @ApiModelProperty("用户id") |
| | | private Long userId; |
| | | |
| | | /** 用户昵称 */ |
| | | @ApiModelProperty("用户昵称") |
| | | private String nickName; |
| | | |
| | | /** 活动id */ |
| | | @ApiModelProperty("活动id") |
| | | private Long prizeActivityId; |
| | | |
| | | /** 活动名称 */ |
| | | @ApiModelProperty("活动名称") |
| | | private String prizeActivityName; |
| | | |
| | | /** 活动封面 */ |
| | | @ApiModelProperty("活动封面") |
| | | private String prizeActivityCover; |
| | | |
| | | /** 中奖状态 */ |
| | | @ApiModelProperty("中奖状态") |
| | | private String prizeStatus; |
| | | |
| | | /** 中奖内容 */ |
| | | @ApiModelProperty("中奖内容") |
| | | private String prizeContent; |
| | | |
| | | /** 奖品id */ |
| | | @ApiModelProperty("奖品id") |
| | | private Long prizeId; |
| | | |
| | | /** 奖品封面 */ |
| | | @ApiModelProperty("奖品封面") |
| | | private String prizeImg; |
| | | |
| | | /** 抽奖次数表id */ |
| | | @ApiModelProperty("抽奖次数表id") |
| | | private Long prizeNumId; |
| | | |
| | | /** 活动奖品关联表id */ |
| | | @ApiModelProperty("活动奖品关联表id") |
| | | private Long activityPrizeRefId; |
| | | |
| | | public static PrizeRecordVO getVoByEntity(@NonNull PrizeRecord entity, PrizeRecordVO vo) { |
| | | if(vo == null) { |
| | | vo = new PrizeRecordVO(); |
| | | } |
| | | BeanUtils.copyProperties(entity, vo); |
| | | return vo; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.mapper; |
| | | |
| | | import cn.lili.modules.lmk.domain.entity.ActivityRefPrize; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import cn.lili.modules.lmk.domain.vo.ActivityRefPrizeVO; |
| | | import cn.lili.modules.lmk.domain.form.ActivityRefPrizeForm; |
| | | import cn.lili.modules.lmk.domain.query.ActivityRefPrizeQuery; |
| | | import java.util.List; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | /** |
| | | * 活动奖品关联表 Mapper 接口 |
| | | * |
| | | * @author peng |
| | | * @since 2025-08-14 |
| | | */ |
| | | @Mapper |
| | | public interface ActivityRefPrizeMapper extends BaseMapper<ActivityRefPrize> { |
| | | |
| | | /** |
| | | * id查找活动奖品关联表 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | ActivityRefPrizeVO getById(String id); |
| | | |
| | | /** |
| | | * 分页 |
| | | */ |
| | | IPage getPage(IPage page, @Param("query") ActivityRefPrizeQuery query); |
| | | |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.mapper; |
| | | |
| | | import cn.lili.modules.lmk.domain.entity.PrizeActivity; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import cn.lili.modules.lmk.domain.vo.PrizeActivityVO; |
| | | import cn.lili.modules.lmk.domain.form.PrizeActivityForm; |
| | | import cn.lili.modules.lmk.domain.query.PrizeActivityQuery; |
| | | import java.util.List; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | /** |
| | | * 抽奖活动 Mapper 接口 |
| | | * |
| | | * @author peng |
| | | * @since 2025-08-14 |
| | | */ |
| | | @Mapper |
| | | public interface PrizeActivityMapper extends BaseMapper<PrizeActivity> { |
| | | |
| | | /** |
| | | * id查找抽奖活动 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | PrizeActivityVO getById(String id); |
| | | |
| | | /** |
| | | * 分页 |
| | | */ |
| | | IPage getPage(IPage page, @Param("query") PrizeActivityQuery query); |
| | | |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.mapper; |
| | | |
| | | import cn.lili.modules.lmk.domain.entity.PrizeDraw; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import cn.lili.modules.lmk.domain.vo.PrizeDrawVO; |
| | | import cn.lili.modules.lmk.domain.form.PrizeDrawForm; |
| | | import cn.lili.modules.lmk.domain.query.PrizeDrawQuery; |
| | | import java.util.List; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | /** |
| | | * 抽奖活动奖品 Mapper 接口 |
| | | * |
| | | * @author peng |
| | | * @since 2025-08-14 |
| | | */ |
| | | @Mapper |
| | | public interface PrizeDrawMapper extends BaseMapper<PrizeDraw> { |
| | | |
| | | /** |
| | | * id查找抽奖活动奖品 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | PrizeDrawVO getById(String id); |
| | | |
| | | /** |
| | | * 分页 |
| | | */ |
| | | IPage getPage(IPage page, @Param("query") PrizeDrawQuery query); |
| | | |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.mapper; |
| | | |
| | | import cn.lili.modules.lmk.domain.entity.PrizeNumber; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import cn.lili.modules.lmk.domain.vo.PrizeNumberVO; |
| | | import cn.lili.modules.lmk.domain.form.PrizeNumberForm; |
| | | import cn.lili.modules.lmk.domain.query.PrizeNumberQuery; |
| | | import java.util.List; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | /** |
| | | * 获取抽奖次数记录表 Mapper 接口 |
| | | * |
| | | * @author peng |
| | | * @since 2025-08-14 |
| | | */ |
| | | @Mapper |
| | | public interface PrizeNumberMapper extends BaseMapper<PrizeNumber> { |
| | | |
| | | /** |
| | | * id查找获取抽奖次数记录表 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | PrizeNumberVO getById(String id); |
| | | |
| | | /** |
| | | * 分页 |
| | | */ |
| | | IPage getPage(IPage page, @Param("query") PrizeNumberQuery query); |
| | | |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.mapper; |
| | | |
| | | import cn.lili.modules.lmk.domain.entity.PrizeRecord; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import cn.lili.modules.lmk.domain.vo.PrizeRecordVO; |
| | | import cn.lili.modules.lmk.domain.form.PrizeRecordForm; |
| | | import cn.lili.modules.lmk.domain.query.PrizeRecordQuery; |
| | | import java.util.List; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | /** |
| | | * 用户抽奖记录表 Mapper 接口 |
| | | * |
| | | * @author peng |
| | | * @since 2025-08-14 |
| | | */ |
| | | @Mapper |
| | | public interface PrizeRecordMapper extends BaseMapper<PrizeRecord> { |
| | | |
| | | /** |
| | | * id查找用户抽奖记录表 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | PrizeRecordVO getById(String id); |
| | | |
| | | /** |
| | | * 分页 |
| | | */ |
| | | IPage getPage(IPage page, @Param("query") PrizeRecordQuery query); |
| | | |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.service; |
| | | |
| | | import cn.lili.modules.lmk.domain.entity.ActivityRefPrize; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import cn.lili.base.Result; |
| | | import cn.lili.modules.lmk.domain.form.ActivityRefPrizeForm; |
| | | import cn.lili.modules.lmk.domain.query.ActivityRefPrizeQuery; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 活动奖品关联表 服务类 |
| | | * |
| | | * @author peng |
| | | * @since 2025-08-14 |
| | | */ |
| | | public interface ActivityRefPrizeService extends IService<ActivityRefPrize> { |
| | | |
| | | /** |
| | | * 添加 |
| | | * @param form |
| | | * @return |
| | | */ |
| | | Result add(ActivityRefPrizeForm form); |
| | | |
| | | /** |
| | | * 修改 |
| | | * @param form |
| | | * @return |
| | | */ |
| | | Result update(ActivityRefPrizeForm form); |
| | | |
| | | /** |
| | | * 批量删除 |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | Result remove(List<String> ids); |
| | | |
| | | /** |
| | | * id删除 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | Result removeById(String id); |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * @param query |
| | | * @return |
| | | */ |
| | | Result page(ActivityRefPrizeQuery query); |
| | | |
| | | /** |
| | | * 根据id查找 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | Result detail(String id); |
| | | |
| | | /** |
| | | * 列表 |
| | | * @return |
| | | */ |
| | | Result all(); |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.service; |
| | | |
| | | import cn.lili.modules.lmk.domain.entity.PrizeActivity; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import cn.lili.base.Result; |
| | | import cn.lili.modules.lmk.domain.form.PrizeActivityForm; |
| | | import cn.lili.modules.lmk.domain.query.PrizeActivityQuery; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 抽奖活动 服务类 |
| | | * |
| | | * @author peng |
| | | * @since 2025-08-14 |
| | | */ |
| | | public interface PrizeActivityService extends IService<PrizeActivity> { |
| | | |
| | | /** |
| | | * 添加 |
| | | * @param form |
| | | * @return |
| | | */ |
| | | Result add(PrizeActivityForm form); |
| | | |
| | | /** |
| | | * 修改 |
| | | * @param form |
| | | * @return |
| | | */ |
| | | Result update(PrizeActivityForm form); |
| | | |
| | | /** |
| | | * 批量删除 |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | Result remove(List<String> ids); |
| | | |
| | | /** |
| | | * id删除 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | Result removeById(String id); |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * @param query |
| | | * @return |
| | | */ |
| | | Result page(PrizeActivityQuery query); |
| | | |
| | | /** |
| | | * 根据id查找 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | Result detail(String id); |
| | | |
| | | /** |
| | | * 列表 |
| | | * @return |
| | | */ |
| | | Result all(); |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.service; |
| | | |
| | | import cn.lili.modules.lmk.domain.entity.PrizeDraw; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import cn.lili.base.Result; |
| | | import cn.lili.modules.lmk.domain.form.PrizeDrawForm; |
| | | import cn.lili.modules.lmk.domain.query.PrizeDrawQuery; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 抽奖活动奖品 服务类 |
| | | * |
| | | * @author peng |
| | | * @since 2025-08-14 |
| | | */ |
| | | public interface PrizeDrawService extends IService<PrizeDraw> { |
| | | |
| | | /** |
| | | * 添加 |
| | | * @param form |
| | | * @return |
| | | */ |
| | | Result add(PrizeDrawForm form); |
| | | |
| | | /** |
| | | * 修改 |
| | | * @param form |
| | | * @return |
| | | */ |
| | | Result update(PrizeDrawForm form); |
| | | |
| | | /** |
| | | * 批量删除 |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | Result remove(List<String> ids); |
| | | |
| | | /** |
| | | * id删除 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | Result removeById(String id); |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * @param query |
| | | * @return |
| | | */ |
| | | Result page(PrizeDrawQuery query); |
| | | |
| | | /** |
| | | * 根据id查找 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | Result detail(String id); |
| | | |
| | | /** |
| | | * 列表 |
| | | * @return |
| | | */ |
| | | Result all(); |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.service; |
| | | |
| | | import cn.lili.modules.lmk.domain.entity.PrizeNumber; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import cn.lili.base.Result; |
| | | import cn.lili.modules.lmk.domain.form.PrizeNumberForm; |
| | | import cn.lili.modules.lmk.domain.query.PrizeNumberQuery; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 获取抽奖次数记录表 服务类 |
| | | * |
| | | * @author peng |
| | | * @since 2025-08-14 |
| | | */ |
| | | public interface PrizeNumberService extends IService<PrizeNumber> { |
| | | |
| | | /** |
| | | * 添加 |
| | | * @param form |
| | | * @return |
| | | */ |
| | | Result add(PrizeNumberForm form); |
| | | |
| | | /** |
| | | * 修改 |
| | | * @param form |
| | | * @return |
| | | */ |
| | | Result update(PrizeNumberForm form); |
| | | |
| | | /** |
| | | * 批量删除 |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | Result remove(List<String> ids); |
| | | |
| | | /** |
| | | * id删除 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | Result removeById(String id); |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * @param query |
| | | * @return |
| | | */ |
| | | Result page(PrizeNumberQuery query); |
| | | |
| | | /** |
| | | * 根据id查找 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | Result detail(String id); |
| | | |
| | | /** |
| | | * 列表 |
| | | * @return |
| | | */ |
| | | Result all(); |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.service; |
| | | |
| | | import cn.lili.modules.lmk.domain.entity.PrizeRecord; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import cn.lili.base.Result; |
| | | import cn.lili.modules.lmk.domain.form.PrizeRecordForm; |
| | | import cn.lili.modules.lmk.domain.query.PrizeRecordQuery; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 用户抽奖记录表 服务类 |
| | | * |
| | | * @author peng |
| | | * @since 2025-08-14 |
| | | */ |
| | | public interface PrizeRecordService extends IService<PrizeRecord> { |
| | | |
| | | /** |
| | | * 添加 |
| | | * @param form |
| | | * @return |
| | | */ |
| | | Result add(PrizeRecordForm form); |
| | | |
| | | /** |
| | | * 修改 |
| | | * @param form |
| | | * @return |
| | | */ |
| | | Result update(PrizeRecordForm form); |
| | | |
| | | /** |
| | | * 批量删除 |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | Result remove(List<String> ids); |
| | | |
| | | /** |
| | | * id删除 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | Result removeById(String id); |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * @param query |
| | | * @return |
| | | */ |
| | | Result page(PrizeRecordQuery query); |
| | | |
| | | /** |
| | | * 根据id查找 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | Result detail(String id); |
| | | |
| | | /** |
| | | * 列表 |
| | | * @return |
| | | */ |
| | | Result all(); |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import cn.lili.modules.lmk.domain.entity.ActivityRefPrize; |
| | | import cn.lili.modules.lmk.mapper.ActivityRefPrizeMapper; |
| | | import cn.lili.modules.lmk.service.ActivityRefPrizeService; |
| | | import cn.lili.base.Result; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import cn.lili.modules.lmk.domain.form.ActivityRefPrizeForm; |
| | | import cn.lili.modules.lmk.domain.vo.ActivityRefPrizeVO; |
| | | import cn.lili.modules.lmk.domain.query.ActivityRefPrizeQuery; |
| | | import org.springframework.stereotype.Service; |
| | | import lombok.RequiredArgsConstructor; |
| | | import cn.lili.utils.PageUtil; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.util.Assert; |
| | | |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 活动奖品关联表 服务实现类 |
| | | * |
| | | * @author peng |
| | | * @since 2025-08-14 |
| | | */ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class ActivityRefPrizeServiceImpl extends ServiceImpl<ActivityRefPrizeMapper, ActivityRefPrize> implements ActivityRefPrizeService { |
| | | |
| | | private final ActivityRefPrizeMapper activityRefPrizeMapper; |
| | | |
| | | /** |
| | | * 添加 |
| | | * @param form |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result add(ActivityRefPrizeForm form) { |
| | | ActivityRefPrize entity = ActivityRefPrizeForm.getEntityByForm(form, null); |
| | | baseMapper.insert(entity); |
| | | return Result.ok("添加成功"); |
| | | } |
| | | |
| | | /** |
| | | * 修改 |
| | | * @param form |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result update(ActivityRefPrizeForm form) { |
| | | ActivityRefPrize entity = baseMapper.selectById(form.getId()); |
| | | |
| | | // 为空抛IllegalArgumentException,做全局异常处理 |
| | | Assert.notNull(entity, "记录不存在"); |
| | | BeanUtils.copyProperties(form, entity); |
| | | baseMapper.updateById(entity); |
| | | return Result.ok("修改成功"); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除 |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result remove(List<String> ids) { |
| | | baseMapper.deleteBatchIds(ids); |
| | | return Result.ok("删除成功"); |
| | | } |
| | | |
| | | /** |
| | | * id删除 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result removeById(String id) { |
| | | baseMapper.deleteById(id); |
| | | return Result.ok("删除成功"); |
| | | } |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * @param query |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result page(ActivityRefPrizeQuery query) { |
| | | IPage<ActivityRefPrizeVO> page = PageUtil.getPage(query, ActivityRefPrizeVO.class); |
| | | baseMapper.getPage(page, query); |
| | | return Result.ok().data(page.getRecords()).total(page.getTotal()); |
| | | } |
| | | |
| | | /** |
| | | * 根据id查找 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result detail(String id) { |
| | | ActivityRefPrizeVO vo = baseMapper.getById(id); |
| | | Assert.notNull(vo, "记录不存在"); |
| | | return Result.ok().data(vo); |
| | | } |
| | | |
| | | /** |
| | | * 列表 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result all() { |
| | | List<ActivityRefPrize> entities = baseMapper.selectList(null); |
| | | List<ActivityRefPrizeVO> vos = entities.stream() |
| | | .map(entity -> ActivityRefPrizeVO.getVoByEntity(entity, null)) |
| | | .collect(Collectors.toList()); |
| | | return Result.ok().data(vos); |
| | | } |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import cn.lili.modules.lmk.domain.entity.PrizeActivity; |
| | | import cn.lili.modules.lmk.mapper.PrizeActivityMapper; |
| | | import cn.lili.modules.lmk.service.PrizeActivityService; |
| | | import cn.lili.base.Result; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import cn.lili.modules.lmk.domain.form.PrizeActivityForm; |
| | | import cn.lili.modules.lmk.domain.vo.PrizeActivityVO; |
| | | import cn.lili.modules.lmk.domain.query.PrizeActivityQuery; |
| | | import org.springframework.stereotype.Service; |
| | | import lombok.RequiredArgsConstructor; |
| | | import cn.lili.utils.PageUtil; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.util.Assert; |
| | | |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 抽奖活动 服务实现类 |
| | | * |
| | | * @author peng |
| | | * @since 2025-08-14 |
| | | */ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class PrizeActivityServiceImpl extends ServiceImpl<PrizeActivityMapper, PrizeActivity> implements PrizeActivityService { |
| | | |
| | | private final PrizeActivityMapper prizeActivityMapper; |
| | | |
| | | /** |
| | | * 添加 |
| | | * @param form |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result add(PrizeActivityForm form) { |
| | | PrizeActivity entity = PrizeActivityForm.getEntityByForm(form, null); |
| | | baseMapper.insert(entity); |
| | | return Result.ok("添加成功"); |
| | | } |
| | | |
| | | /** |
| | | * 修改 |
| | | * @param form |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result update(PrizeActivityForm form) { |
| | | PrizeActivity entity = baseMapper.selectById(form.getId()); |
| | | |
| | | // 为空抛IllegalArgumentException,做全局异常处理 |
| | | Assert.notNull(entity, "记录不存在"); |
| | | BeanUtils.copyProperties(form, entity); |
| | | baseMapper.updateById(entity); |
| | | return Result.ok("修改成功"); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除 |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result remove(List<String> ids) { |
| | | baseMapper.deleteBatchIds(ids); |
| | | return Result.ok("删除成功"); |
| | | } |
| | | |
| | | /** |
| | | * id删除 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result removeById(String id) { |
| | | baseMapper.deleteById(id); |
| | | return Result.ok("删除成功"); |
| | | } |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * @param query |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result page(PrizeActivityQuery query) { |
| | | IPage<PrizeActivityVO> page = PageUtil.getPage(query, PrizeActivityVO.class); |
| | | baseMapper.getPage(page, query); |
| | | return Result.ok().data(page.getRecords()).total(page.getTotal()); |
| | | } |
| | | |
| | | /** |
| | | * 根据id查找 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result detail(String id) { |
| | | PrizeActivityVO vo = baseMapper.getById(id); |
| | | Assert.notNull(vo, "记录不存在"); |
| | | return Result.ok().data(vo); |
| | | } |
| | | |
| | | /** |
| | | * 列表 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result all() { |
| | | List<PrizeActivity> entities = baseMapper.selectList(null); |
| | | List<PrizeActivityVO> vos = entities.stream() |
| | | .map(entity -> PrizeActivityVO.getVoByEntity(entity, null)) |
| | | .collect(Collectors.toList()); |
| | | return Result.ok().data(vos); |
| | | } |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import cn.lili.modules.lmk.domain.entity.PrizeDraw; |
| | | import cn.lili.modules.lmk.mapper.PrizeDrawMapper; |
| | | import cn.lili.modules.lmk.service.PrizeDrawService; |
| | | import cn.lili.base.Result; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import cn.lili.modules.lmk.domain.form.PrizeDrawForm; |
| | | import cn.lili.modules.lmk.domain.vo.PrizeDrawVO; |
| | | import cn.lili.modules.lmk.domain.query.PrizeDrawQuery; |
| | | import org.springframework.stereotype.Service; |
| | | import lombok.RequiredArgsConstructor; |
| | | import cn.lili.utils.PageUtil; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.util.Assert; |
| | | |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 抽奖活动奖品 服务实现类 |
| | | * |
| | | * @author peng |
| | | * @since 2025-08-14 |
| | | */ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class PrizeDrawServiceImpl extends ServiceImpl<PrizeDrawMapper, PrizeDraw> implements PrizeDrawService { |
| | | |
| | | private final PrizeDrawMapper prizeDrawMapper; |
| | | |
| | | /** |
| | | * 添加 |
| | | * @param form |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result add(PrizeDrawForm form) { |
| | | PrizeDraw entity = PrizeDrawForm.getEntityByForm(form, null); |
| | | baseMapper.insert(entity); |
| | | return Result.ok("添加成功"); |
| | | } |
| | | |
| | | /** |
| | | * 修改 |
| | | * @param form |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result update(PrizeDrawForm form) { |
| | | PrizeDraw entity = baseMapper.selectById(form.getId()); |
| | | |
| | | // 为空抛IllegalArgumentException,做全局异常处理 |
| | | Assert.notNull(entity, "记录不存在"); |
| | | BeanUtils.copyProperties(form, entity); |
| | | baseMapper.updateById(entity); |
| | | return Result.ok("修改成功"); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除 |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result remove(List<String> ids) { |
| | | baseMapper.deleteBatchIds(ids); |
| | | return Result.ok("删除成功"); |
| | | } |
| | | |
| | | /** |
| | | * id删除 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result removeById(String id) { |
| | | baseMapper.deleteById(id); |
| | | return Result.ok("删除成功"); |
| | | } |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * @param query |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result page(PrizeDrawQuery query) { |
| | | IPage<PrizeDrawVO> page = PageUtil.getPage(query, PrizeDrawVO.class); |
| | | baseMapper.getPage(page, query); |
| | | return Result.ok().data(page.getRecords()).total(page.getTotal()); |
| | | } |
| | | |
| | | /** |
| | | * 根据id查找 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result detail(String id) { |
| | | PrizeDrawVO vo = baseMapper.getById(id); |
| | | Assert.notNull(vo, "记录不存在"); |
| | | return Result.ok().data(vo); |
| | | } |
| | | |
| | | /** |
| | | * 列表 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result all() { |
| | | List<PrizeDraw> entities = baseMapper.selectList(null); |
| | | List<PrizeDrawVO> vos = entities.stream() |
| | | .map(entity -> PrizeDrawVO.getVoByEntity(entity, null)) |
| | | .collect(Collectors.toList()); |
| | | return Result.ok().data(vos); |
| | | } |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import cn.lili.modules.lmk.domain.entity.PrizeNumber; |
| | | import cn.lili.modules.lmk.mapper.PrizeNumberMapper; |
| | | import cn.lili.modules.lmk.service.PrizeNumberService; |
| | | import cn.lili.base.Result; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import cn.lili.modules.lmk.domain.form.PrizeNumberForm; |
| | | import cn.lili.modules.lmk.domain.vo.PrizeNumberVO; |
| | | import cn.lili.modules.lmk.domain.query.PrizeNumberQuery; |
| | | import org.springframework.stereotype.Service; |
| | | import lombok.RequiredArgsConstructor; |
| | | import cn.lili.utils.PageUtil; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.util.Assert; |
| | | |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 获取抽奖次数记录表 服务实现类 |
| | | * |
| | | * @author peng |
| | | * @since 2025-08-14 |
| | | */ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class PrizeNumberServiceImpl extends ServiceImpl<PrizeNumberMapper, PrizeNumber> implements PrizeNumberService { |
| | | |
| | | private final PrizeNumberMapper prizeNumberMapper; |
| | | |
| | | /** |
| | | * 添加 |
| | | * @param form |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result add(PrizeNumberForm form) { |
| | | PrizeNumber entity = PrizeNumberForm.getEntityByForm(form, null); |
| | | baseMapper.insert(entity); |
| | | return Result.ok("添加成功"); |
| | | } |
| | | |
| | | /** |
| | | * 修改 |
| | | * @param form |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result update(PrizeNumberForm form) { |
| | | PrizeNumber entity = baseMapper.selectById(form.getId()); |
| | | |
| | | // 为空抛IllegalArgumentException,做全局异常处理 |
| | | Assert.notNull(entity, "记录不存在"); |
| | | BeanUtils.copyProperties(form, entity); |
| | | baseMapper.updateById(entity); |
| | | return Result.ok("修改成功"); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除 |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result remove(List<String> ids) { |
| | | baseMapper.deleteBatchIds(ids); |
| | | return Result.ok("删除成功"); |
| | | } |
| | | |
| | | /** |
| | | * id删除 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result removeById(String id) { |
| | | baseMapper.deleteById(id); |
| | | return Result.ok("删除成功"); |
| | | } |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * @param query |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result page(PrizeNumberQuery query) { |
| | | IPage<PrizeNumberVO> page = PageUtil.getPage(query, PrizeNumberVO.class); |
| | | baseMapper.getPage(page, query); |
| | | return Result.ok().data(page.getRecords()).total(page.getTotal()); |
| | | } |
| | | |
| | | /** |
| | | * 根据id查找 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result detail(String id) { |
| | | PrizeNumberVO vo = baseMapper.getById(id); |
| | | Assert.notNull(vo, "记录不存在"); |
| | | return Result.ok().data(vo); |
| | | } |
| | | |
| | | /** |
| | | * 列表 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result all() { |
| | | List<PrizeNumber> entities = baseMapper.selectList(null); |
| | | List<PrizeNumberVO> vos = entities.stream() |
| | | .map(entity -> PrizeNumberVO.getVoByEntity(entity, null)) |
| | | .collect(Collectors.toList()); |
| | | return Result.ok().data(vos); |
| | | } |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import cn.lili.modules.lmk.domain.entity.PrizeRecord; |
| | | import cn.lili.modules.lmk.mapper.PrizeRecordMapper; |
| | | import cn.lili.modules.lmk.service.PrizeRecordService; |
| | | import cn.lili.base.Result; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import cn.lili.modules.lmk.domain.form.PrizeRecordForm; |
| | | import cn.lili.modules.lmk.domain.vo.PrizeRecordVO; |
| | | import cn.lili.modules.lmk.domain.query.PrizeRecordQuery; |
| | | import org.springframework.stereotype.Service; |
| | | import lombok.RequiredArgsConstructor; |
| | | import cn.lili.utils.PageUtil; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.util.Assert; |
| | | |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 用户抽奖记录表 服务实现类 |
| | | * |
| | | * @author peng |
| | | * @since 2025-08-14 |
| | | */ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class PrizeRecordServiceImpl extends ServiceImpl<PrizeRecordMapper, PrizeRecord> implements PrizeRecordService { |
| | | |
| | | private final PrizeRecordMapper prizeRecordMapper; |
| | | |
| | | /** |
| | | * 添加 |
| | | * @param form |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result add(PrizeRecordForm form) { |
| | | PrizeRecord entity = PrizeRecordForm.getEntityByForm(form, null); |
| | | baseMapper.insert(entity); |
| | | return Result.ok("添加成功"); |
| | | } |
| | | |
| | | /** |
| | | * 修改 |
| | | * @param form |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result update(PrizeRecordForm form) { |
| | | PrizeRecord entity = baseMapper.selectById(form.getId()); |
| | | |
| | | // 为空抛IllegalArgumentException,做全局异常处理 |
| | | Assert.notNull(entity, "记录不存在"); |
| | | BeanUtils.copyProperties(form, entity); |
| | | baseMapper.updateById(entity); |
| | | return Result.ok("修改成功"); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除 |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result remove(List<String> ids) { |
| | | baseMapper.deleteBatchIds(ids); |
| | | return Result.ok("删除成功"); |
| | | } |
| | | |
| | | /** |
| | | * id删除 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result removeById(String id) { |
| | | baseMapper.deleteById(id); |
| | | return Result.ok("删除成功"); |
| | | } |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * @param query |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result page(PrizeRecordQuery query) { |
| | | IPage<PrizeRecordVO> page = PageUtil.getPage(query, PrizeRecordVO.class); |
| | | baseMapper.getPage(page, query); |
| | | return Result.ok().data(page.getRecords()).total(page.getTotal()); |
| | | } |
| | | |
| | | /** |
| | | * 根据id查找 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result detail(String id) { |
| | | PrizeRecordVO vo = baseMapper.getById(id); |
| | | Assert.notNull(vo, "记录不存在"); |
| | | return Result.ok().data(vo); |
| | | } |
| | | |
| | | /** |
| | | * 列表 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result all() { |
| | | List<PrizeRecord> entities = baseMapper.selectList(null); |
| | | List<PrizeRecordVO> vos = entities.stream() |
| | | .map(entity -> PrizeRecordVO.getVoByEntity(entity, null)) |
| | | .collect(Collectors.toList()); |
| | | return Result.ok().data(vos); |
| | | } |
| | | } |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="cn.lili.modules.lmk.mapper.ActivityRefPrizeMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="cn.lili.modules.lmk.domain.vo.ActivityRefPrizeVO"> |
| | | <id column="id" property="id"/> |
| | | <result column="prize_activity_id" property="prizeActivityId" /> |
| | | <result column="prize_id" property="prizeId" /> |
| | | <result column="prize_content" property="prizeContent" /> |
| | | <result column="prize_num" property="prizeNum" /> |
| | | <result column="prize_probability" property="prizeProbability" /> |
| | | <result column="version" property="version" /> |
| | | <result column="remain_num" property="remainNum" /> |
| | | </resultMap> |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | <select id="getById" resultMap="BaseResultMap"> |
| | | SELECT |
| | | LARP.prize_activity_id, |
| | | LARP.prize_id, |
| | | LARP.prize_content, |
| | | LARP.prize_num, |
| | | LARP.prize_probability, |
| | | LARP.version, |
| | | LARP.remain_num, |
| | | LARP.id |
| | | FROM |
| | | lmk_activity_ref_prize LARP |
| | | WHERE |
| | | LARP.id = #{id} AND LARP.delete_flag = 0 |
| | | </select> |
| | | |
| | | |
| | | <select id="getPage" resultMap="BaseResultMap"> |
| | | SELECT |
| | | LARP.prize_activity_id, |
| | | LARP.prize_id, |
| | | LARP.prize_content, |
| | | LARP.prize_num, |
| | | LARP.prize_probability, |
| | | LARP.version, |
| | | LARP.remain_num, |
| | | LARP.id |
| | | FROM |
| | | lmk_activity_ref_prize LARP |
| | | WHERE |
| | | LARP.delete_flag = 0 |
| | | </select> |
| | | |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="cn.lili.modules.lmk.mapper.PrizeActivityMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="cn.lili.modules.lmk.domain.vo.PrizeActivityVO"> |
| | | <id column="id" property="id"/> |
| | | <result column="activity_name" property="activityName" /> |
| | | <result column="activity_des" property="activityDes" /> |
| | | <result column="begin_time" property="beginTime" /> |
| | | <result column="end_time" property="endTime" /> |
| | | <result column="max_prize" property="maxPrize" /> |
| | | <result column="prize_num" property="prizeNum" /> |
| | | <result column="activity_img" property="activityImg" /> |
| | | <result column="activity_cover" property="activityCover" /> |
| | | <result column="enable_status" property="enableStatus" /> |
| | | </resultMap> |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | <select id="getById" resultMap="BaseResultMap"> |
| | | SELECT |
| | | LPA.activity_name, |
| | | LPA.activity_des, |
| | | LPA.begin_time, |
| | | LPA.end_time, |
| | | LPA.max_prize, |
| | | LPA.prize_num, |
| | | LPA.activity_img, |
| | | LPA.activity_cover, |
| | | LPA.enable_status, |
| | | LPA.id |
| | | FROM |
| | | lmk_prize_activity LPA |
| | | WHERE |
| | | LPA.id = #{id} AND LPA.delete_flag = 0 |
| | | </select> |
| | | |
| | | |
| | | <select id="getPage" resultMap="BaseResultMap"> |
| | | SELECT |
| | | LPA.activity_name, |
| | | LPA.activity_des, |
| | | LPA.begin_time, |
| | | LPA.end_time, |
| | | LPA.max_prize, |
| | | LPA.prize_num, |
| | | LPA.activity_img, |
| | | LPA.activity_cover, |
| | | LPA.enable_status, |
| | | LPA.id |
| | | FROM |
| | | lmk_prize_activity LPA |
| | | WHERE |
| | | LPA.delete_flag = 0 |
| | | </select> |
| | | |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="cn.lili.modules.lmk.mapper.PrizeDrawMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="cn.lili.modules.lmk.domain.vo.PrizeDrawVO"> |
| | | <id column="id" property="id"/> |
| | | <result column="prize_name" property="prizeName" /> |
| | | <result column="prize_type" property="prizeType" /> |
| | | <result column="coupon_id" property="couponId" /> |
| | | <result column="prize_content" property="prizeContent" /> |
| | | <result column="prize_cover" property="prizeCover" /> |
| | | <result column="prize_des" property="prizeDes" /> |
| | | <result column="prize_img" property="prizeImg" /> |
| | | </resultMap> |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | <select id="getById" resultMap="BaseResultMap"> |
| | | SELECT |
| | | LPD.prize_name, |
| | | LPD.prize_type, |
| | | LPD.coupon_id, |
| | | LPD.prize_content, |
| | | LPD.prize_cover, |
| | | LPD.prize_des, |
| | | LPD.prize_img, |
| | | LPD.id |
| | | FROM |
| | | lmk_prize_draw LPD |
| | | WHERE |
| | | LPD.id = #{id} AND LPD.delete_flag = 0 |
| | | </select> |
| | | |
| | | |
| | | <select id="getPage" resultMap="BaseResultMap"> |
| | | SELECT |
| | | LPD.prize_name, |
| | | LPD.prize_type, |
| | | LPD.coupon_id, |
| | | LPD.prize_content, |
| | | LPD.prize_cover, |
| | | LPD.prize_des, |
| | | LPD.prize_img, |
| | | LPD.id |
| | | FROM |
| | | lmk_prize_draw LPD |
| | | WHERE |
| | | LPD.delete_flag = 0 |
| | | </select> |
| | | |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="cn.lili.modules.lmk.mapper.PrizeNumberMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="cn.lili.modules.lmk.domain.vo.PrizeNumberVO"> |
| | | <id column="id" property="id"/> |
| | | <result column="user_id" property="userId" /> |
| | | <result column="activity_prize_id" property="activityPrizeId" /> |
| | | <result column="user_action" property="userAction" /> |
| | | <result column="use_status" property="useStatus" /> |
| | | </resultMap> |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | <select id="getById" resultMap="BaseResultMap"> |
| | | SELECT |
| | | LPN.user_id, |
| | | LPN.activity_prize_id, |
| | | LPN.user_action, |
| | | LPN.use_status, |
| | | LPN.id |
| | | FROM |
| | | lmk_prize_number LPN |
| | | WHERE |
| | | LPN.id = #{id} AND LPN.delete_flag = 0 |
| | | </select> |
| | | |
| | | |
| | | <select id="getPage" resultMap="BaseResultMap"> |
| | | SELECT |
| | | LPN.user_id, |
| | | LPN.activity_prize_id, |
| | | LPN.user_action, |
| | | LPN.use_status, |
| | | LPN.id |
| | | FROM |
| | | lmk_prize_number LPN |
| | | WHERE |
| | | LPN.delete_flag = 0 |
| | | </select> |
| | | |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="cn.lili.modules.lmk.mapper.PrizeRecordMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="cn.lili.modules.lmk.domain.vo.PrizeRecordVO"> |
| | | <id column="id" property="id"/> |
| | | <result column="user_id" property="userId" /> |
| | | <result column="nick_name" property="nickName" /> |
| | | <result column="prize_activity_id" property="prizeActivityId" /> |
| | | <result column="prize_activity_name" property="prizeActivityName" /> |
| | | <result column="prize_activity_cover" property="prizeActivityCover" /> |
| | | <result column="prize_status" property="prizeStatus" /> |
| | | <result column="prize_content" property="prizeContent" /> |
| | | <result column="prize_id" property="prizeId" /> |
| | | <result column="prize_img" property="prizeImg" /> |
| | | <result column="prize_num_id" property="prizeNumId" /> |
| | | <result column="activity_prize_ref_id" property="activityPrizeRefId" /> |
| | | </resultMap> |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | <select id="getById" resultMap="BaseResultMap"> |
| | | SELECT |
| | | LPR.user_id, |
| | | LPR.nick_name, |
| | | LPR.prize_activity_id, |
| | | LPR.prize_activity_name, |
| | | LPR.prize_activity_cover, |
| | | LPR.prize_status, |
| | | LPR.prize_content, |
| | | LPR.prize_id, |
| | | LPR.prize_img, |
| | | LPR.prize_num_id, |
| | | LPR.activity_prize_ref_id, |
| | | LPR.id |
| | | FROM |
| | | lmk_prize_record LPR |
| | | WHERE |
| | | LPR.id = #{id} AND LPR.delete_flag = 0 |
| | | </select> |
| | | |
| | | |
| | | <select id="getPage" resultMap="BaseResultMap"> |
| | | SELECT |
| | | LPR.user_id, |
| | | LPR.nick_name, |
| | | LPR.prize_activity_id, |
| | | LPR.prize_activity_name, |
| | | LPR.prize_activity_cover, |
| | | LPR.prize_status, |
| | | LPR.prize_content, |
| | | LPR.prize_id, |
| | | LPR.prize_img, |
| | | LPR.prize_num_id, |
| | | LPR.activity_prize_ref_id, |
| | | LPR.id |
| | | FROM |
| | | lmk_prize_record LPR |
| | | WHERE |
| | | LPR.delete_flag = 0 |
| | | </select> |
| | | |
| | | </mapper> |