Commit 8526f66c authored by zhangfeng's avatar zhangfeng

feature-reward:补充功能

parent 042ebb13
......@@ -26,12 +26,8 @@ public interface RewardMapper extends AbstractMapper<RewardDO> {
.eqIfPresent(RewardDO::getTitleFr, vo.getTitle())
.eqIfPresent(RewardDO::getPointsRequire, vo.getPointsRequire())
.eqIfPresent(RewardDO::getNodeId, vo.getNodeId())
.eqIfPresent(RewardDO::getExchangeCount, vo.getExchangeCount())
.eqIfPresent(RewardDO::getQuantityRemain, vo.getQuantityRemain())
.betweenIfPresent(RewardDO::getStartTime, vo.getBeginStartTime(), vo.getEndStartTime())
.betweenIfPresent(RewardDO::getEndTime, vo.getBeginEndTime(), vo.getEndEndTime())
.eqIfPresent(RewardDO::getPickMethod, vo.getPickMethod())
.eqIfPresent(RewardDO::getAllowCount, vo.getAllowCount())
.eqIfPresent(RewardDO::getStatus, vo.getStatus())
.betweenIfPresent(RewardDO::getCreateTime, vo.getBeginCreateTime(), vo.getEndCreateTime())
.orderByDesc(RewardDO::getId));
......@@ -51,12 +47,8 @@ public interface RewardMapper extends AbstractMapper<RewardDO> {
.eqIfPresent(RewardDO::getTitleFr, vo.getTitle())
.eqIfPresent(RewardDO::getPointsRequire, vo.getPointsRequire())
.eqIfPresent(RewardDO::getNodeId, vo.getNodeId())
.eqIfPresent(RewardDO::getExchangeCount, vo.getExchangeCount())
.eqIfPresent(RewardDO::getQuantityRemain, vo.getQuantityRemain())
.betweenIfPresent(RewardDO::getStartTime, vo.getBeginStartTime(), vo.getEndStartTime())
.betweenIfPresent(RewardDO::getEndTime, vo.getBeginEndTime(), vo.getEndEndTime())
.eqIfPresent(RewardDO::getPickMethod, vo.getPickMethod())
.eqIfPresent(RewardDO::getAllowCount, vo.getAllowCount())
.eqIfPresent(RewardDO::getStatus, vo.getStatus())
.betweenIfPresent(RewardDO::getCreateTime, vo.getBeginCreateTime(), vo.getEndCreateTime())
.orderByDesc(RewardDO::getId));
......
......@@ -2,6 +2,8 @@ package cn.iocoder.yudao.module.reward.service.reward;
import java.util.*;
import javax.annotation.Resource;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQuery;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
......@@ -11,6 +13,7 @@ import cn.iocoder.yudao.module.reward.dal.dataobject.reward.RewardDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.reward.convert.reward.RewardConvert;
import cn.iocoder.yudao.module.reward.dal.mysql.reward.RewardMapper;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.reward.enums.ErrorCodeConstants.*;
import static com.baomidou.mybatisplus.core.toolkit.IdWorker.getId;
......@@ -31,10 +34,10 @@ public class RewardServiceImpl extends AbstractService<RewardMapper, RewardDO> i
public Long create(RewardCreateReqVO createReqVO) {
// 插入
RewardDO rewardDO = RewardConvert.INSTANCE.convert(createReqVO);
rewardDO.setCode("111");
int id = rewardMapper.insert(rewardDO);
rewardDO.setCode(generateRewardCode());
rewardMapper.insert(rewardDO);
// 返回
return (long)id;
return rewardDO.getId();
}
@Override
......@@ -72,7 +75,20 @@ public class RewardServiceImpl extends AbstractService<RewardMapper, RewardDO> i
@Override
public PageResult<RewardDO> getPage(RewardQueryVO query, PageVO page) {
return rewardMapper.selectPage(page, query);
PageResult<RewardDO> rewardDOPageResult = rewardMapper.selectPage(page, new LambdaQuery<RewardDO>()
.eqIfPresent(RewardDO::getCode, query.getCode())
.eqIfPresent(RewardDO::getTitleZh, query.getTitle())
.eqIfPresent(RewardDO::getTitleEn, query.getTitle())
.eqIfPresent(RewardDO::getTitleFr, query.getTitle())
.eqIfPresent(RewardDO::getPointsRequire, query.getPointsRequire())
.eqIfPresent(RewardDO::getNodeId, query.getNodeId())
.eqIfPresent(RewardDO::getQuantityRemain, query.getQuantityRemain())
.eqIfPresent(RewardDO::getPickMethod, query.getPickMethod())
.eqIfPresent(RewardDO::getStatus, query.getStatus())
.betweenIfPresent(RewardDO::getCreateTime, query.getBeginCreateTime(), query.getEndCreateTime())
.orderByDesc(RewardDO::getId));
return rewardDOPageResult;
}
@Override
......@@ -81,7 +97,8 @@ public class RewardServiceImpl extends AbstractService<RewardMapper, RewardDO> i
}
//生成礼品ID
private String generateRewardCode(){
return String.valueOf(getId());
private String generateRewardCode() {
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
return uuid.substring(0, 12).toUpperCase();
}
}
......@@ -15,8 +15,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@Data
public class RewardBaseVO {
@ApiModelProperty(value = "礼品ID", required = true)
@NotNull(message = "礼品ID不能为空")
@ApiModelProperty(value = "礼品ID")
private String code;
@ApiModelProperty(value = "中文名称")
......@@ -37,19 +36,16 @@ public class RewardBaseVO {
@ApiModelProperty(value = "法文礼品图片")
private String imgFr;
@ApiModelProperty(value = "兑换所需积分", required = true)
@NotNull(message = "兑换所需积分不能为空")
@ApiModelProperty(value = "兑换所需积分")
private Integer pointsRequire;
@ApiModelProperty(value = "兑换网点", required = true)
@NotNull(message = "兑换网点不能为空")
@ApiModelProperty(value = "兑换网点")
private Integer nodeId;
@ApiModelProperty(value = "已兑换次数")
private Integer exchangeCount;
@ApiModelProperty(value = "剩余数量", required = true)
@NotNull(message = "剩余数量不能为空")
@ApiModelProperty(value = "剩余数量")
private Integer quantityRemain;
@ApiModelProperty(value = "活动开始时间")
......@@ -60,12 +56,10 @@ public class RewardBaseVO {
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private Date endTime;
@ApiModelProperty(value = "领取方式(1上门领取,2包邮到家,3邮寄到付)", required = true)
@NotNull(message = "领取方式(1上门领取,2包邮到家,3邮寄到付)不能为空")
@ApiModelProperty(value = "领取方式(1上门领取,2包邮到家,3邮寄到付)")
private Integer pickMethod;
@ApiModelProperty(value = "允许兑换次数", required = true)
@NotNull(message = "允许兑换次数不能为空")
@ApiModelProperty(value = "允许兑换次数")
private Integer allowCount;
@ApiModelProperty(value = "中文备注")
......@@ -77,8 +71,7 @@ public class RewardBaseVO {
@ApiModelProperty(value = "法文备注")
private String remarkFr;
@ApiModelProperty(value = "礼品状态(1已启用,2未启用,3已关闭,4已过期)", required = true)
@NotNull(message = "礼品状态(1已启用,2未启用,3已关闭,4已过期)不能为空")
@ApiModelProperty(value = "礼品状态(1已启用,2未启用,3已关闭,4已过期)")
private Integer status;
}
......@@ -21,37 +21,21 @@ public class RewardQueryVO {
@ApiModelProperty(value = "兑换所需积分")
private Integer pointsRequire;
@ApiModelProperty(value = "兑换所需积分查询条件(1大于,2等于,3小于)")
private Integer pointsRequireSymbol;
@ApiModelProperty(value = "兑换网点")
private Integer nodeId;
@ApiModelProperty(value = "已兑换次数")
private Integer exchangeCount;
@ApiModelProperty(value = "剩余数量")
private Integer quantityRemain;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始活动开始时间")
private Date beginStartTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束活动开始时间")
private Date endStartTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始活动结束时间")
private Date beginEndTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束活动结束时间")
private Date endEndTime;
@ApiModelProperty(value = "剩余数量查询条件(1大于,2等于,3小于)")
private Integer quantityRemainSymbol;
@ApiModelProperty(value = "领取方式(1上门领取,2包邮到家,3邮寄到付)")
private Integer pickMethod;
@ApiModelProperty(value = "允许兑换次数")
private Integer allowCount;
@ApiModelProperty(value = "礼品状态(1已启用,2未启用,3已关闭,4已过期)")
private Integer status;
......
import cn.hutool.core.lang.UUID;
public class GenRewardCodeTest {
public static void main(String[] args) {
String format = String.format("%012d", 2);
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
System.out.println(format);
System.out.println(uuid);
}
}
......@@ -25,7 +25,7 @@ import cn.iocoder.yudao.module.reward.service.reward.RewardService;
@Validated
@RestController
@Api(tags = "管理后台 - 礼品")
@RequestMapping("/reward/")
@RequestMapping("/ecw/reward/")
public class RewardController {
@Resource
......@@ -56,7 +56,7 @@ public class RewardController {
}
@GetMapping("/get")
@ApiOperation("获得礼品")
@ApiOperation("获得礼品详情")
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
@PreAuthorize("@ss.hasPermission('reward::query')")
public CommonResult<RewardBackVO> get(@RequestParam("id") Long id) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment