diff --git a/mall-sms/sms-api/src/main/java/com/youlai/mall/sms/pojo/constant/AppConstants.java b/mall-sms/sms-api/src/main/java/com/youlai/mall/sms/pojo/constant/AppConstants.java new file mode 100644 index 000000000..362a7acc7 --- /dev/null +++ b/mall-sms/sms-api/src/main/java/com/youlai/mall/sms/pojo/constant/AppConstants.java @@ -0,0 +1,12 @@ +package com.youlai.mall.sms.pojo.constant; + +/** + * @author huawei + * @desc + * @email huawei_code@163.com + * @date 2021/3/10 + */ +public class AppConstants { + + public static final String COUPON_LOCK = "lock:coupon:"; +} diff --git a/mall-sms/sms-api/src/main/java/com/youlai/mall/sms/pojo/domain/SmsCoupon.java b/mall-sms/sms-api/src/main/java/com/youlai/mall/sms/pojo/domain/SmsCoupon.java new file mode 100644 index 000000000..54311091f --- /dev/null +++ b/mall-sms/sms-api/src/main/java/com/youlai/mall/sms/pojo/domain/SmsCoupon.java @@ -0,0 +1,100 @@ +package com.youlai.mall.sms.pojo.domain; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * sms_coupon + * @author + */ +@Data +public class SmsCoupon implements Serializable { + /** + * ID + */ + private Long id; + + /** + * 优惠券标题(有图片则显示图片):无门槛50元优惠券 | 单品最高减2000元 + */ + private String title; + + /** + * 图片 + */ + private String img; + + /** + * 1满减券 2叠加满减券 3无门槛券(需要限制大小) + */ + private Integer type; + + /** + * 发布状态, PUBLISH发布,DRAFT草稿,OFFLINE下线 + */ + private String publish; + + /** + * 满多少才可以使用(为0则不限制金额) + */ + private Long conditionPrice; + + /** + * 抵扣价格 + */ + private Long price; + + /** + * 优惠券总量 + */ + private Integer publishCount; + + /** + * 每张优惠券限领张数(默认为1,为0不限制) + */ + private Integer limitCount; + + /** + * 已领取的优惠券数量 + */ + private Integer takeCount; + + /** + * 已使用的优惠券数量 + */ + private Integer usedCount; + + /** + * 发放开始时间 + */ + private Date startTime; + + /** + * 发放结束时间 + */ + private Date endTime; + + /** + * 自领取之日起有效天数 + */ + private Integer validDays; + + /** + * 逻辑删除使用 + */ + private Integer status; + + /** + * 创建时间 + */ + private Date gmtCreate; + + /** + * 修改时间 + */ + private Date gmtModified; + + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/mall-sms/sms-api/src/main/java/com/youlai/mall/sms/pojo/domain/SmsCouponRecord.java b/mall-sms/sms-api/src/main/java/com/youlai/mall/sms/pojo/domain/SmsCouponRecord.java new file mode 100644 index 000000000..48240aa08 --- /dev/null +++ b/mall-sms/sms-api/src/main/java/com/youlai/mall/sms/pojo/domain/SmsCouponRecord.java @@ -0,0 +1,87 @@ +package com.youlai.mall.sms.pojo.domain; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * sms_coupon_record + * @author + */ +@Data +public class SmsCouponRecord implements Serializable { + private Long id; + + /** + * 优惠券id + */ + private Long couponId; + + /** + * 使用状态 可用 NEW,已使用USED,过期 EXPIRED; + */ + private String useState; + + /** + * 用户id + */ + private Long userId; + + /** + * 用户昵称(冗余字段) + */ + private String userName; + + /** + * 1满减券 2叠加满减券 3无门槛券 + */ + private Integer couponType; + + /** + * 优惠券标题 + */ + private String couponTitle; + + /** + * 满多少才可以使用(为0则不限制金额) + */ + private Long conditionPrice; + + /** + * 抵扣价格 + */ + private Long price; + + /** + * 开始时间 + */ + private Date startTime; + + /** + * 结束时间 + */ + private Date endTime; + + /** + * 订单id + */ + private Long orderId; + + /** + * 逻辑删除使用 + */ + private Integer status; + + /** + * 创建时间 + */ + private Date gmtCreate; + + /** + * 修改时间 + */ + private Date gmtModified; + + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/mall-sms/sms-api/src/main/java/com/youlai/mall/sms/pojo/enums/CouponStateEnum.java b/mall-sms/sms-api/src/main/java/com/youlai/mall/sms/pojo/enums/CouponStateEnum.java new file mode 100644 index 000000000..f7837e5d2 --- /dev/null +++ b/mall-sms/sms-api/src/main/java/com/youlai/mall/sms/pojo/enums/CouponStateEnum.java @@ -0,0 +1,14 @@ +package com.youlai.mall.sms.pojo.enums; + +/** + * @author huawei + * @desc + * @email huawei_code@163.com + * @date 2021/2/28 + */ +public enum CouponStateEnum { + + NEW, + USED, + EXPIRED; +} diff --git a/mall-sms/sms-api/src/main/java/com/youlai/mall/sms/pojo/form/CouponForm.java b/mall-sms/sms-api/src/main/java/com/youlai/mall/sms/pojo/form/CouponForm.java new file mode 100644 index 000000000..093ca1e7d --- /dev/null +++ b/mall-sms/sms-api/src/main/java/com/youlai/mall/sms/pojo/form/CouponForm.java @@ -0,0 +1,97 @@ +package com.youlai.mall.sms.pojo.form; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.util.Date; + +/** + * @author huawei + * @desc 优惠券提交表单 + * @email huawei_code@163.com + * @date 2021/3/14 + */ +@ApiModel("优惠券提交表单") +@Data +public class CouponForm { + + /** + * ID + */ + private Long id; + + /** + * 优惠券标题(有图片则显示图片):无门槛50元优惠券 | 单品最高减2000元 + */ + @ApiModelProperty("优惠券标题") + @NotBlank(message = "请填写优惠券标题") + private String title; + + /** + * 图片 + */ + @ApiModelProperty("优惠券图片") + private String img; + + /** + * 1满减券 2叠加满减券 3无门槛券(需要限制大小) + */ + @ApiModelProperty("优惠券类型") + private Integer type; + + /** + * 满多少才可以使用(为0则不限制金额) + */ + @ApiModelProperty("优惠券满减金额(为0则不限制金额)") + private Long conditionPrice; + + /** + * 抵扣价格 + */ + @ApiModelProperty("优惠券抵扣价格") + @NotNull(message = "请填写优惠券抵扣金额") + @Min(value = 1,message = "抵扣价格不能小于1") + private Long price; + + /** + * 优惠券总量 + */ + @ApiModelProperty("优惠券总量") + @NotNull(message = "请填写优惠券总量") + @Min(value = 1,message = "优惠券总量不能小于1") + private Integer publishCount; + + /** + * 每张优惠券限领张数(默认为1,为0不限制) + */ + @ApiModelProperty("优惠券限领张数") + @Min(value = 0,message = "优惠券限领张数不能为负数") + private Integer limitCount; + + /** + * 发放开始时间 + */ + @ApiModelProperty("优惠券发放开始时间") + @NotNull(message = "请填写优惠券发放开始时间") + private Date startTime; + + /** + * 发放结束时间 + */ + @ApiModelProperty("优惠券发放结束时间") + @NotNull(message = "请填写优惠券发放结束时间") + private Date endTime; + + /** + * 自领取之日起有效天数 + */ + @ApiModelProperty("自领取之日起有效天数") + @NotNull(message = "请填写正确的有效天数") + @Min(value = 1,message = "有效天数总量不能小于1") + private Integer validDays; + +} diff --git a/mall-sms/sms-api/src/main/java/com/youlai/mall/sms/pojo/vo/SmsCouponVO.java b/mall-sms/sms-api/src/main/java/com/youlai/mall/sms/pojo/vo/SmsCouponVO.java new file mode 100644 index 000000000..6291e3b4e --- /dev/null +++ b/mall-sms/sms-api/src/main/java/com/youlai/mall/sms/pojo/vo/SmsCouponVO.java @@ -0,0 +1,100 @@ +package com.youlai.mall.sms.pojo.vo; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * sms_coupon + * @author + */ +@Data +public class SmsCouponVO implements Serializable { + /** + * ID + */ + private Long id; + + /** + * 优惠券标题(有图片则显示图片):无门槛50元优惠券 | 单品最高减2000元 + */ + private String title; + + /** + * 图片 + */ + private String img; + + /** + * 1满减券 2叠加满减券 3无门槛券(需要限制大小) + */ + private Integer type; + + /** + * 发布状态, PUBLISH发布,DRAFT草稿,OFFLINE下线 + */ + private String publish; + + /** + * 满多少才可以使用(为0则不限制金额) + */ + private Long conditionPrice; + + /** + * 抵扣价格 + */ + private Long price; + + /** + * 优惠券总量 + */ + private Integer publishCount; + + /** + * 每张优惠券限领张数(默认为1,为0不限制) + */ + private Integer limitCount; + + /** + * 已领取的优惠券数量 + */ + private Integer takeCount; + + /** + * 已使用的优惠券数量 + */ + private Integer usedCount; + + /** + * 发放开始时间 + */ + private Date startTime; + + /** + * 发放结束时间 + */ + private Date endTime; + + /** + * 自领取之日起有效天数 + */ + private Integer validDays; + + /** + * 逻辑删除使用 + */ + private Integer status; + + /** + * 创建时间 + */ + private Date gmtCreate; + + /** + * 修改时间 + */ + private Date gmtModified; + + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/controller/admin/CouponController.java b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/controller/admin/CouponController.java new file mode 100644 index 000000000..9dfd02952 --- /dev/null +++ b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/controller/admin/CouponController.java @@ -0,0 +1,81 @@ +package com.youlai.mall.sms.controller.admin; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.youlai.common.base.BasePageQuery; +import com.youlai.common.result.Result; +import com.youlai.mall.sms.pojo.domain.SmsCoupon; +import com.youlai.mall.sms.pojo.form.CouponForm; +import com.youlai.mall.sms.service.ISmsCouponService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +/** + * @author huawei + * @desc 优惠券管理服务 + * @email huawei_code@163.com + * @date 2021/3/14 + */ +@Api(tags = "优惠券管理服务") +@RestController +@RequestMapping("/api.admin/v1/coupon") +public class CouponController { + + @Autowired + private ISmsCouponService couponService; + + @ApiOperation("优惠券分页列表查询") + @GetMapping("/page") + public Result page(@ApiParam("条件分页请求入参") BasePageQuery query) { + Page page = new Page<>(query.getPageNum(), query.getPageSize()); + return Result.success(couponService.pageQuery(page, query)); + } + + @ApiOperation("查询优惠券详情") + @RequestMapping("/${couponId}/detail") + public Result detail(@ApiParam("删除商品分页列表查询") @PathVariable("couponId") String couponId) { + return Result.success(couponService.detail(couponId)); + } + + /** + * 新增优惠券 + * + * @return + */ + @ApiOperation("新增优惠券") + @PostMapping() + public Result add(@ApiParam("新增优惠券提交表单") @Validated @RequestBody CouponForm form) { + couponService.add(form); + return Result.success(); + } + + /** + * 修改优惠券 + * + * @return + */ + @ApiOperation("修改优惠券") + @PutMapping() + public Result modify(@ApiParam("修改优惠券提交表单") @Validated @RequestBody CouponForm form) { + if (form.getId() == null) { + return Result.failed("优惠券ID不能为空"); + } + couponService.modify(form); + return Result.success(); + } + + /** + * 删除优惠券 + * + * @return + */ + @ApiOperation("删除优惠券") + @DeleteMapping() + public Result del(@ApiParam("优惠券ID") @RequestParam("couponId") String couponId) { + couponService.removeById(couponId); + return Result.success(); + } +} diff --git a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/controller/admin/CouponRecordController.java b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/controller/admin/CouponRecordController.java new file mode 100644 index 000000000..cc5396416 --- /dev/null +++ b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/controller/admin/CouponRecordController.java @@ -0,0 +1,73 @@ +package com.youlai.mall.sms.controller.admin; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.youlai.common.base.BasePageQuery; +import com.youlai.common.result.Result; +import com.youlai.common.web.util.RequestUtils; +import com.youlai.mall.sms.pojo.domain.SmsCouponRecord; +import com.youlai.mall.sms.service.ICouponRecordService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +/** + * @author huawei + * @desc 优惠券领券记录服务 + * @email huawei_code@163.com + * @date 2021/3/15 + */ +@Api(tags = "优惠券领券记录服务") +@RestController +@RequestMapping("/api.admin/v1/coupon_record") +public class CouponRecordController { + + @Autowired + private ICouponRecordService couponRecordService; + + @ApiOperation(value = "分页获取会员领券记录") + @GetMapping("/page") + public Result page(BasePageQuery pageQuery) { + Long userId = RequestUtils.getUserId(); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("user_id", userId).orderByDesc("create_time"); + Page page = new Page<>(pageQuery.getPageNum(), pageQuery.getPageSize()); + IPage result = couponRecordService.page(page, queryWrapper); + return Result.success(result); + } + + @ApiOperation(value = "获取优惠券记录详情") + @GetMapping("/{id}/detail") + public Result detail(@ApiParam(value = "优惠券记录ID") @PathVariable("id") String id) { + Long userId = RequestUtils.getUserId(); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("user_id", userId ).eq("id", id); + SmsCouponRecord result = couponRecordService.getOne(queryWrapper); + if (result == null) { + return Result.failed("优惠券记录不存在"); + } + return Result.success(result); + } + + + /** + * 用户领券功能 + * 1、查询优惠券是否真实存在 + * 2、校验优惠券信息(是否有效、是否超额领取、是否过期) + * 3、 + * + * @param couponId + * @return + */ + @ApiOperation(value = "用户领券功能") + @PostMapping() + public Result add(@ApiParam(name = "couponId", value = "优惠券ID", required = true) + @RequestParam("couponId") String couponId) { + couponRecordService.add(couponId); + return Result.success(); + + } +} diff --git a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/controller/app/SeckillController.java b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/controller/app/SeckillController.java index 4b6a8f2a8..bec4280fb 100644 --- a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/controller/app/SeckillController.java +++ b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/controller/app/SeckillController.java @@ -2,7 +2,7 @@ package com.youlai.mall.sms.controller.app; import com.youlai.common.result.Result; import com.youlai.mall.sms.pojo.vo.SmsSeckillSkuVO; -import com.youlai.mall.sms.service.SeckillService; +import com.youlai.mall.sms.service.ISeckillService; import io.swagger.annotations.Api; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -25,11 +25,11 @@ import java.util.List; public class SeckillController { @Autowired - private SeckillService seckillService; + private ISeckillService ISeckillService; @GetMapping public Result getCurrentSeckillSession() { - List currentSeckills = seckillService.getCurrentSeckillSession(); + List currentSeckills = ISeckillService.getCurrentSeckillSession(); return Result.success(); } } diff --git a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/mapper/SmsCouponDao.java b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/mapper/SmsCouponDao.java new file mode 100644 index 000000000..67c218242 --- /dev/null +++ b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/mapper/SmsCouponDao.java @@ -0,0 +1,21 @@ +package com.youlai.mall.sms.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.youlai.mall.sms.pojo.domain.SmsCoupon; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +@Mapper +public interface SmsCouponDao extends BaseMapper { + int deleteByPrimaryKey(Long id); + + int insertSelective(SmsCoupon record); + + SmsCoupon selectByPrimaryKey(Long id); + + int updateByPrimaryKeySelective(SmsCoupon record); + + int updateByPrimaryKey(SmsCoupon record); + + int updateTakeStock(@Param("id") String couponId); +} \ No newline at end of file diff --git a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/mapper/SmsCouponRecordDao.java b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/mapper/SmsCouponRecordDao.java new file mode 100644 index 000000000..30e87f377 --- /dev/null +++ b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/mapper/SmsCouponRecordDao.java @@ -0,0 +1,18 @@ +package com.youlai.mall.sms.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.youlai.mall.sms.pojo.domain.SmsCouponRecord; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface SmsCouponRecordDao extends BaseMapper { + int deleteByPrimaryKey(Long id); + + int insertSelective(SmsCouponRecord record); + + SmsCouponRecord selectByPrimaryKey(Long id); + + int updateByPrimaryKeySelective(SmsCouponRecord record); + + int updateByPrimaryKey(SmsCouponRecord record); +} \ No newline at end of file diff --git a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/scheduled/SeckillSkuScheduled.java b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/scheduled/SeckillSkuScheduled.java index f7cdb50c3..28c4066f7 100644 --- a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/scheduled/SeckillSkuScheduled.java +++ b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/scheduled/SeckillSkuScheduled.java @@ -1,6 +1,6 @@ package com.youlai.mall.sms.scheduled; -import com.youlai.mall.sms.service.SeckillService; +import com.youlai.mall.sms.service.ISeckillService; import lombok.extern.slf4j.Slf4j; import org.redisson.api.RLock; import org.redisson.api.RedissonClient; @@ -23,7 +23,7 @@ public class SeckillSkuScheduled { private static final String SECKILL_SKU_LATEST_3_DAY= "seckillSkuLatest3Days"; @Autowired - private SeckillService seckillService; + private ISeckillService ISeckillService; @Autowired @@ -38,7 +38,7 @@ public class SeckillSkuScheduled { lock.lock(10, TimeUnit.SECONDS); try { - seckillService.updateSeckillSkuLatest3Days(); + ISeckillService.updateSeckillSkuLatest3Days(); } finally { lock.unlock(); } diff --git a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/ICouponRecordService.java b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/ICouponRecordService.java new file mode 100644 index 000000000..fc0c37630 --- /dev/null +++ b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/ICouponRecordService.java @@ -0,0 +1,19 @@ +package com.youlai.mall.sms.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.youlai.mall.sms.pojo.domain.SmsCouponRecord; + +/** + * @author huawei + * @desc 优惠券领券记录业务接口 + * @email huawei_code@163.com + * @date 2021/3/15 + */ +public interface ICouponRecordService extends IService { + + /** + * 用户领券 + * @param couponId + */ + void add(String couponId); +} diff --git a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/SeckillService.java b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/ISeckillService.java similarity index 92% rename from mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/SeckillService.java rename to mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/ISeckillService.java index 4e7dc55c6..5dab15231 100644 --- a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/SeckillService.java +++ b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/ISeckillService.java @@ -10,7 +10,7 @@ import java.util.List; * @email huawei_code@163.com * @date 2021/3/5 */ -public interface SeckillService { +public interface ISeckillService { void updateSeckillSkuLatest3Days(); diff --git a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/ISmsCouponRecordService.java b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/ISmsCouponRecordService.java new file mode 100644 index 000000000..3f02c4aa4 --- /dev/null +++ b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/ISmsCouponRecordService.java @@ -0,0 +1,13 @@ +package com.youlai.mall.sms.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.youlai.mall.sms.pojo.domain.SmsCouponRecord; + +/** + * @author huawei + * @desc + * @email huawei_code@163.com + * @date 2021/3/14 + */ +public interface ISmsCouponRecordService extends IService { +} diff --git a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/ISmsCouponService.java b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/ISmsCouponService.java new file mode 100644 index 000000000..21c47d38e --- /dev/null +++ b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/ISmsCouponService.java @@ -0,0 +1,48 @@ +package com.youlai.mall.sms.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.youlai.common.base.BasePageQuery; +import com.youlai.mall.sms.pojo.domain.SmsCoupon; +import com.youlai.mall.sms.pojo.form.CouponForm; +import com.youlai.mall.sms.pojo.vo.SmsCouponVO; + +/** + * @author huawei + * @desc + * @email huawei_code@163.com + * @date 2021/3/14 + */ +public interface ISmsCouponService extends IService { + + /** + * 获取优惠券详情 + * + * @param couponId 优惠券ID + */ + SmsCouponVO detail(String couponId); + + /** + * 新增优惠券 + * + * @param form 新增提交表单 + */ + void add(CouponForm form); + + /** + * 修改优惠券 + * + * @param form 修改优惠券提交表单 + */ + void modify(CouponForm form); + + IPage pageQuery(Page page, BasePageQuery query); + + /** + * 根据已领券数量 + * @param couponId + * @return + */ + int updateTakeStock(String couponId); +} diff --git a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/SmsSeckillSessionService.java b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/ISmsSeckillSessionService.java similarity index 88% rename from mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/SmsSeckillSessionService.java rename to mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/ISmsSeckillSessionService.java index 57633ae83..f131262af 100644 --- a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/SmsSeckillSessionService.java +++ b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/ISmsSeckillSessionService.java @@ -12,7 +12,7 @@ import java.util.List; * @email huawei_code@163.com * @date 2021/3/5 */ -public interface SmsSeckillSessionService extends IService { +public interface ISmsSeckillSessionService extends IService { /** * 根据起始时间和结束时间查询秒杀活动列表 diff --git a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/SmsSeckillSkuRelationService.java b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/ISmsSeckillSkuRelationService.java similarity index 85% rename from mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/SmsSeckillSkuRelationService.java rename to mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/ISmsSeckillSkuRelationService.java index 7be4507a6..4122b21c9 100644 --- a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/SmsSeckillSkuRelationService.java +++ b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/ISmsSeckillSkuRelationService.java @@ -11,7 +11,7 @@ import java.util.List; * @email huawei_code@163.com * @date 2021/3/5 */ -public interface SmsSeckillSkuRelationService extends IService { +public interface ISmsSeckillSkuRelationService extends IService { /** * 根据秒杀活动ID获取关联商品 diff --git a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/impl/CouponRecordServiceImpl.java b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/impl/CouponRecordServiceImpl.java new file mode 100644 index 000000000..ffa5c8a1e --- /dev/null +++ b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/impl/CouponRecordServiceImpl.java @@ -0,0 +1,108 @@ +package com.youlai.mall.sms.service.impl; + +import cn.hutool.core.date.DateUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.youlai.common.web.exception.BizException; +import com.youlai.common.web.util.RequestUtils; +import com.youlai.mall.sms.mapper.SmsCouponRecordDao; +import com.youlai.mall.sms.pojo.domain.SmsCoupon; +import com.youlai.mall.sms.pojo.domain.SmsCouponRecord; +import com.youlai.mall.sms.pojo.enums.CouponStateEnum; +import com.youlai.mall.sms.service.ICouponRecordService; +import com.youlai.mall.sms.service.ISmsCouponService; +import lombok.extern.slf4j.Slf4j; +import org.redisson.api.RLock; +import org.redisson.api.RedissonClient; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Date; + +import static com.youlai.mall.sms.pojo.constant.AppConstants.COUPON_LOCK; + +/** + * @author huawei + * @desc 优惠券领券记录业务实现类 + * @email huawei_code@163.com + * @date 2021/3/15 + */ +@Service +@Slf4j +public class CouponRecordServiceImpl extends ServiceImpl implements ICouponRecordService { + + @Autowired + private ISmsCouponService couponService; + + @Autowired + private RedissonClient redissonClient; + + @Override + public void add(String couponId) { + Long userId = RequestUtils.getUserId(); + RLock lock = redissonClient.getLock(COUPON_LOCK + couponId); + lock.lock(); + + try { + SmsCoupon coupon = couponService.getById(couponId); + this.couponCheck(coupon, userId); + // 封装优惠券领取记录对象 + SmsCouponRecord couponRecord = new SmsCouponRecord(); + BeanUtils.copyProperties(coupon, couponRecord); + couponRecord.setStartTime(new Date()); + couponRecord.setEndTime(DateUtil.offsetDay(new Date(), coupon.getValidDays())); + couponRecord.setUseState(CouponStateEnum.NEW.name()); + couponRecord.setUserId(RequestUtils.getUserId()); + couponRecord.setUserName(RequestUtils.getUsername()); + couponRecord.setCouponId(coupon.getId()); + couponRecord.setId(null); + + // 高并发下扣减库存 + //高并发下扣减劵库存,采用乐观锁,当前stock做版本号,延伸多种防止超卖的问题,一次只能领取1张,TODO + int rows = couponService.updateTakeStock(couponId); + if (rows == 1) { + //库存扣减成功才保存 + this.save(couponRecord); + } else { + log.warn("发放优惠券失败,coupon={},loginUser={}", coupon, userId); + throw new BizException("发放优惠券失败"); + } + } finally { + lock.unlock(); + } + } + + /** + * 优惠券检查 + * + * @param couponEntity + * @param userId + */ + private void couponCheck(SmsCoupon couponEntity, long userId) { + + //优惠券不存在 + if (couponEntity == null) { + throw new BizException("优惠券不存在"); + } + //库存不足 + if ((couponEntity.getPublishCount() - couponEntity.getTakeCount()) <= 0) { + throw new BizException("优惠券已经被领光了"); + } + //是否在领取时间范围 + long time = System.currentTimeMillis(); + long start = couponEntity.getStartTime().getTime(); + long end = couponEntity.getEndTime().getTime(); + if (time < start || time > end) { + throw new BizException("优惠券不在领券时间范围内"); + } + //用户是否超过限制 + int recordNum = this.count(new QueryWrapper() + .eq("coupon_id", couponEntity.getId()) + .eq("user_id", userId)); + + if (recordNum >= couponEntity.getLimitCount()) { + throw new BizException("优惠券已经达到领券次数限制"); + } + } +} diff --git a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/impl/SeckillServiceImpl.java b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/impl/SeckillServiceImpl.java index 002f30bdb..3b29bf170 100644 --- a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/impl/SeckillServiceImpl.java +++ b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/impl/SeckillServiceImpl.java @@ -10,16 +10,15 @@ import com.youlai.mall.sms.pojo.domain.SmsSeckillSession; import com.youlai.mall.sms.pojo.domain.SmsSeckillSkuRelation; import com.youlai.mall.sms.pojo.to.SeckillSkuRedisTO; import com.youlai.mall.sms.pojo.vo.SmsSeckillSkuVO; -import com.youlai.mall.sms.service.SeckillService; -import com.youlai.mall.sms.service.SmsSeckillSessionService; -import com.youlai.mall.sms.service.SmsSeckillSkuRelationService; +import com.youlai.mall.sms.service.ISeckillService; +import com.youlai.mall.sms.service.ISmsSeckillSessionService; +import com.youlai.mall.sms.service.ISmsSeckillSkuRelationService; import lombok.extern.slf4j.Slf4j; import org.redisson.api.RSemaphore; import org.redisson.api.RedissonClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import javax.annotation.Resource; import java.util.Date; import java.util.List; import java.util.stream.Collectors; @@ -32,17 +31,17 @@ import java.util.stream.Collectors; */ @Service @Slf4j -public class SeckillServiceImpl implements SeckillService { +public class SeckillServiceImpl implements ISeckillService { private static final String SECKILL_SESSION_CACHE_PREFIX = "seckill:sessions:"; private static final String SECKILL_SKU_CACHE_PREFIX = "seckill:skus"; private static final String SECKILL_SKU_SEMAPHORE = "seckill:stock:"; @Autowired - private SmsSeckillSessionService seckillSessionService; + private ISmsSeckillSessionService seckillSessionService; @Autowired - private SmsSeckillSkuRelationService seckillSkuRelationService; + private ISmsSeckillSkuRelationService seckillSkuRelationService; @Autowired private RedisUtils redisUtils; diff --git a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/impl/SmsCouponRecordServiceImpl.java b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/impl/SmsCouponRecordServiceImpl.java new file mode 100644 index 000000000..4ce406b63 --- /dev/null +++ b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/impl/SmsCouponRecordServiceImpl.java @@ -0,0 +1,19 @@ +package com.youlai.mall.sms.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.youlai.mall.sms.mapper.SmsCouponRecordDao; +import com.youlai.mall.sms.pojo.domain.SmsCouponRecord; +import com.youlai.mall.sms.service.ISmsCouponRecordService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +/** + * @author huawei + * @desc 优惠券领取记录业务实现类 + * @email huawei_code@163.com + * @date 2021/3/14 + */ +@Slf4j +@Service +public class SmsCouponRecordServiceImpl extends ServiceImpl implements ISmsCouponRecordService { +} diff --git a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/impl/SmsCouponServiceImpl.java b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/impl/SmsCouponServiceImpl.java new file mode 100644 index 000000000..0fe734366 --- /dev/null +++ b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/impl/SmsCouponServiceImpl.java @@ -0,0 +1,61 @@ +package com.youlai.mall.sms.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.youlai.common.base.BasePageQuery; +import com.youlai.common.web.util.BeanMapperUtils; +import com.youlai.mall.sms.mapper.SmsCouponDao; +import com.youlai.mall.sms.pojo.domain.SmsCoupon; +import com.youlai.mall.sms.pojo.form.CouponForm; +import com.youlai.mall.sms.pojo.vo.SmsCouponVO; +import com.youlai.mall.sms.service.ISmsCouponService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +/** + * @author huawei + * @desc 优惠券服务业务实现类 + * @email huawei_code@163.com + * @date 2021/3/14 + */ +@Service +@Slf4j +public class SmsCouponServiceImpl extends ServiceImpl implements ISmsCouponService { + @Override + public SmsCouponVO detail(String couponId) { + log.info("根据优惠券ID获取优惠券详情,couponId={}", couponId); + SmsCoupon coupon = this.getById(couponId); + return BeanMapperUtils.map(coupon, SmsCouponVO.class); + } + + @Override + public void add(CouponForm form) { + log.info("新增优惠券,form={}", form); + SmsCoupon coupon = BeanMapperUtils.map(form, SmsCoupon.class); + coupon.setId(null); + this.save(coupon); + } + + @Override + public void modify(CouponForm form) { + log.info("新增优惠券,form={}", form); + SmsCoupon coupon = BeanMapperUtils.map(form, SmsCoupon.class); + // TODO 如果该优惠券已经有领取记录,则优惠券价格、限领账户、过期时间等相关参数不能修改 + // 这里没有考虑太复杂,如有需要自行处理 + this.updateById(coupon); + } + + @Override + public IPage pageQuery(Page page, BasePageQuery query) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + IPage iPage = this.page(page,queryWrapper); + return iPage; + } + + @Override + public int updateTakeStock(String couponId) { + return this.updateTakeStock(couponId); + } +} diff --git a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/impl/SmsSeckillSessionServiceImpl.java b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/impl/SmsSeckillSessionServiceImpl.java index 0e060f074..cb09a1c73 100644 --- a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/impl/SmsSeckillSessionServiceImpl.java +++ b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/impl/SmsSeckillSessionServiceImpl.java @@ -5,7 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.youlai.mall.sms.mapper.SmsSeckillSessionMapper; import com.youlai.mall.sms.pojo.domain.SmsSeckillSession; -import com.youlai.mall.sms.service.SmsSeckillSessionService; +import com.youlai.mall.sms.service.ISmsSeckillSessionService; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -19,7 +19,7 @@ import java.util.List; */ @Service @Slf4j -public class SmsSeckillSessionServiceImpl extends ServiceImpl implements SmsSeckillSessionService { +public class SmsSeckillSessionServiceImpl extends ServiceImpl implements ISmsSeckillSessionService { @Override public List selectByTime(DateTime startTime, DateTime endTime) { log.info("根据起始时间和结束时间查询秒杀活动列表, startTime={}, endTime={}", startTime, endTime); diff --git a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/impl/SmsSeckillSkuRelationServiceImpl.java b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/impl/SmsSeckillSkuRelationServiceImpl.java index 64a1961d2..4eeabd6dc 100644 --- a/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/impl/SmsSeckillSkuRelationServiceImpl.java +++ b/mall-sms/sms-boot/src/main/java/com/youlai/mall/sms/service/impl/SmsSeckillSkuRelationServiceImpl.java @@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.youlai.mall.sms.mapper.SmsSeckillSkuRelationMapper; import com.youlai.mall.sms.pojo.domain.SmsSeckillSkuRelation; -import com.youlai.mall.sms.service.SmsSeckillSkuRelationService; +import com.youlai.mall.sms.service.ISmsSeckillSkuRelationService; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -18,7 +18,7 @@ import java.util.List; */ @Service @Slf4j -public class SmsSeckillSkuRelationServiceImpl extends ServiceImpl implements SmsSeckillSkuRelationService { +public class SmsSeckillSkuRelationServiceImpl extends ServiceImpl implements ISmsSeckillSkuRelationService { @Override public List selectBySessionId(Long sessionId) { log.info("根据秒杀活动场次ID查询关联商品列表,sessionId={}",sessionId); diff --git a/mall-sms/sms-boot/src/main/resources/mapper/SmsCouponDao.xml b/mall-sms/sms-boot/src/main/resources/mapper/SmsCouponDao.xml new file mode 100644 index 000000000..1ae033b36 --- /dev/null +++ b/mall-sms/sms-boot/src/main/resources/mapper/SmsCouponDao.xml @@ -0,0 +1,224 @@ + + + + + + + + + + + + + + + + + + + + + + + + id, title, img, `type`, publish, condition_price, price, publish_count,limit_count, take_count, + used_count, start_time, end_time, valid_days, `status`, gmt_create, gmt_modified + + + + delete + from sms_coupon + where id = #{id,jdbcType=BIGINT} + + + + insert into sms_coupon + + + title, + + + img, + + + `type`, + + + publish, + + + condition_price, + + + price, + + + publish_count, + + + limit_count, + + + take_count, + + + used_count, + + + start_time, + + + end_time, + + + valid_days, + + + `status`, + + + gmt_create, + + + gmt_modified, + + + + + #{title,jdbcType=VARCHAR}, + + + #{img,jdbcType=VARCHAR}, + + + #{type,jdbcType=INTEGER}, + + + #{publish,jdbcType=VARCHAR}, + + + #{conditionPrice,jdbcType=BIGINT}, + + + #{price,jdbcType=BIGINT}, + + + #{publishCount,jdbcType=INTEGER}, + + + #{limitCount,jdbcType=INTEGER}, + + + #{takeCount,jdbcType=INTEGER}, + + + #{usedCount,jdbcType=INTEGER}, + + + #{startTime,jdbcType=TIMESTAMP}, + + + #{endTime,jdbcType=TIMESTAMP}, + + + #{validDays,jdbcType=INTEGER}, + + + #{status,jdbcType=INTEGER}, + + + #{gmtCreate,jdbcType=TIMESTAMP}, + + + #{gmtModified,jdbcType=TIMESTAMP}, + + + + + update sms_coupon + + + title = #{title,jdbcType=VARCHAR}, + + + img = #{img,jdbcType=VARCHAR}, + + + `type` = #{type,jdbcType=INTEGER}, + + + publish = #{publish,jdbcType=VARCHAR}, + + + condition_price = #{conditionPrice,jdbcType=BIGINT}, + + + price = #{price,jdbcType=BIGINT}, + + + publish_count = #{publishCount,jdbcType=INTEGER}, + + + limit_count = #{limitCount,jdbcType=INTEGER}, + + + take_count = #{takeCount,jdbcType=INTEGER}, + + + used_count = #{usedCount,jdbcType=INTEGER}, + + + start_time = #{startTime,jdbcType=TIMESTAMP}, + + + end_time = #{endTime,jdbcType=TIMESTAMP}, + + + valid_days = #{validDays,jdbcType=INTEGER}, + + + `status` = #{status,jdbcType=INTEGER}, + + + gmt_create = #{gmtCreate,jdbcType=TIMESTAMP}, + + + gmt_modified = #{gmtModified,jdbcType=TIMESTAMP}, + + + where id = #{id,jdbcType=BIGINT} + + + update sms_coupon + set title = #{title,jdbcType=VARCHAR}, + img = #{img,jdbcType=VARCHAR}, + `type` = #{type,jdbcType=INTEGER}, + publish = #{publish,jdbcType=VARCHAR}, + condition_price = #{conditionPrice,jdbcType=BIGINT}, + price = #{price,jdbcType=BIGINT}, + publish_count = #{publishCount,jdbcType=INTEGER}, + limit_count = #{limitCount,jdbcType=INTEGER}, + take_count = #{takeCount,jdbcType=INTEGER}, + used_count = #{usedCount,jdbcType=INTEGER}, + start_time = #{startTime,jdbcType=TIMESTAMP}, + end_time = #{endTime,jdbcType=TIMESTAMP}, + valid_days = #{validDays,jdbcType=INTEGER}, + `status` = #{status,jdbcType=INTEGER}, + gmt_create = #{gmtCreate,jdbcType=TIMESTAMP}, + gmt_modified = #{gmtModified,jdbcType=TIMESTAMP} + where id = #{id,jdbcType=BIGINT} + + + + + update sms_coupon + set take_count = take_count + 1 + where id = #{id} + + \ No newline at end of file diff --git a/mall-sms/sms-boot/src/main/resources/mapper/SmsCouponRecordDao.xml b/mall-sms/sms-boot/src/main/resources/mapper/SmsCouponRecordDao.xml new file mode 100644 index 000000000..c552bf775 --- /dev/null +++ b/mall-sms/sms-boot/src/main/resources/mapper/SmsCouponRecordDao.xml @@ -0,0 +1,194 @@ + + + + + + + + + + + + + + + + + + + + + + id, coupon_id, use_state, user_id, user_name, coupon_type, coupon_title, + condition_price, price, start_time, end_time, order_id, `status`, gmt_create, gmt_modified + + + + delete from sms_coupon_record + where id = #{id,jdbcType=BIGINT} + + + + insert into sms_coupon_record + + + coupon_id, + + + use_state, + + + user_id, + + + user_name, + + + coupon_type, + + + coupon_title, + + + condition_price, + + + price, + + + start_time, + + + end_time, + + + order_id, + + + `status`, + + + gmt_create, + + + gmt_modified, + + + + + #{couponId,jdbcType=BIGINT}, + + + #{useState,jdbcType=VARCHAR}, + + + #{userId,jdbcType=BIGINT}, + + + #{userName,jdbcType=VARCHAR}, + + + #{couponType,jdbcType=INTEGER}, + + + #{couponTitle,jdbcType=VARCHAR}, + + + #{conditionPrice,jdbcType=BIGINT}, + + + #{price,jdbcType=BIGINT}, + + + #{startTime,jdbcType=TIMESTAMP}, + + + #{endTime,jdbcType=TIMESTAMP}, + + + #{orderId,jdbcType=BIGINT}, + + + #{status,jdbcType=INTEGER}, + + + #{gmtCreate,jdbcType=TIMESTAMP}, + + + #{gmtModified,jdbcType=TIMESTAMP}, + + + + + update sms_coupon_record + + + coupon_id = #{couponId,jdbcType=BIGINT}, + + + + use_state = #{useState,jdbcType=VARCHAR}, + + + user_id = #{userId,jdbcType=BIGINT}, + + + user_name = #{userName,jdbcType=VARCHAR}, + + + coupon_type = #{couponType,jdbcType=INTEGER}, + + + coupon_title = #{couponTitle,jdbcType=VARCHAR}, + + + condition_price = #{conditionPrice,jdbcType=BIGINT}, + + + price = #{price,jdbcType=BIGINT}, + + + start_time = #{startTime,jdbcType=TIMESTAMP}, + + + end_time = #{endTime,jdbcType=TIMESTAMP}, + + + order_id = #{orderId,jdbcType=BIGINT}, + + + `status` = #{status,jdbcType=INTEGER}, + + + gmt_create = #{gmtCreate,jdbcType=TIMESTAMP}, + + + gmt_modified = #{gmtModified,jdbcType=TIMESTAMP}, + + + where id = #{id,jdbcType=BIGINT} + + + update sms_coupon_record + set coupon_id = #{couponId,jdbcType=BIGINT}, + use_state = #{useState,jdbcType=VARCHAR}, + user_id = #{userId,jdbcType=BIGINT}, + user_name = #{userName,jdbcType=VARCHAR}, + coupon_type = #{couponType,jdbcType=INTEGER}, + coupon_title = #{couponTitle,jdbcType=VARCHAR}, + condition_price = #{conditionPrice,jdbcType=BIGINT}, + price = #{price,jdbcType=BIGINT}, + start_time = #{startTime,jdbcType=TIMESTAMP}, + end_time = #{endTime,jdbcType=TIMESTAMP}, + order_id = #{orderId,jdbcType=BIGINT}, + `status` = #{status,jdbcType=INTEGER}, + gmt_create = #{gmtCreate,jdbcType=TIMESTAMP}, + gmt_modified = #{gmtModified,jdbcType=TIMESTAMP} + where id = #{id,jdbcType=BIGINT} + + \ No newline at end of file diff --git a/youlai-common/common-core/pom.xml b/youlai-common/common-core/pom.xml index 5367d8606..ec4327038 100644 --- a/youlai-common/common-core/pom.xml +++ b/youlai-common/common-core/pom.xml @@ -37,6 +37,11 @@ ${dozer.version} + + io.swagger + swagger-annotations + + diff --git a/youlai-common/common-core/src/main/java/com/youlai/common/base/BasePageQuery.java b/youlai-common/common-core/src/main/java/com/youlai/common/base/BasePageQuery.java new file mode 100644 index 000000000..21a88dbd5 --- /dev/null +++ b/youlai-common/common-core/src/main/java/com/youlai/common/base/BasePageQuery.java @@ -0,0 +1,20 @@ +package com.youlai.common.base; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author huawei + * @desc 基础分页请求对象 + * @email huawei_code@163.com + * @date 2021/2/28 + */ +@Data +public class BasePageQuery { + + @ApiModelProperty(value = "当前页", example = "1") + private int pageNum = 1; + + @ApiModelProperty(value = "每页记录数", example = "10") + private int pageSize = 10; +}