Commit 39db271e authored by zhangfeng's avatar zhangfeng

feature-reward:调整目录结构

parent 41244ed8
package cn.iocoder.yudao.module.reward.convert.reward;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import cn.iocoder.yudao.module.reward.vo.reward.*;
import cn.iocoder.yudao.module.reward.dal.dataobject.reward.RewardDO;
/**
* 礼品 Convert
* @author 系统管理员
*/
@Mapper
public interface RewardConvert {
/*****转换MapStruct*****/
RewardConvert INSTANCE = Mappers.getMapper(RewardConvert.class);
/***
* 创建VO转实体
* @param bean
* @return
*/
RewardDO convert(RewardCreateReqVO bean);
/***
* 修改VO转实体
* @param bean
* @return
*/
RewardDO convert(RewardUpdateReqVO bean);
/***
* 实体转返回VO
* @param bean
* @return
*/
RewardBackVO convert(RewardDO bean);
/***
* 实体列表转返回VO列表
* @param list
* @return
*/
List<RewardBackVO> convertList(List<RewardDO> list);
/***
* 实体分页转返回分页
* @param page
* @return
*/
PageResult<RewardBackVO> convertPage(PageResult<RewardDO> page);
/***
* 更新礼品状态VO转实体
* @param bean
* @return
*/
RewardDO convertStatusReqVO(RewardStatusReqVO bean);
}
package cn.iocoder.yudao.module.reward.dal.dataobject.reward;
import lombok.*;
import java.util.*;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
/**
* 礼品 DO
*
* @author 系统管理员
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName("ecw_reward")
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class RewardDO extends BaseDO {
/**
* 主键
*/
@TableId
private Long id;
/**
* 礼品ID
*/
private String code;
/**
* 中文名称
*/
private String titleZh;
/**
* 英文名称
*/
private String titleEn;
/**
* 法文名称
*/
private String titleFr;
/**
* 中文礼品图片
*/
private String imgZh;
/**
* 英文礼品图片
*/
private String imgEn;
/**
* 法文礼品图片
*/
private String imgFr;
/**
* 兑换所需积分
*/
private Integer pointsRequire;
/**
* 兑换网点
*/
private Integer nodeId;
/**
* 已兑换次数
*/
private Integer exchangeCount;
/**
* 剩余数量
*/
private Integer quantityRemain;
/**
* 活动开始时间
*/
private Date startTime;
/**
* 活动结束时间
*/
private Date endTime;
/**
* 领取方式(1上门领取,2包邮到家,3邮寄到付)
*/
private Integer pickMethod;
/**
* 允许兑换次数
*/
private Integer allowCount;
/**
* 中文备注
*/
private String remarkZh;
/**
* 英文备注
*/
private String remarkEn;
/**
* 法文备注
*/
private String remarkFr;
/**
* 礼品状态(1已启用,2未启用,3已关闭,4已过期)
*/
private Integer status;
}
package cn.iocoder.yudao.module.reward.dal.mysql.reward;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQuery;
import cn.iocoder.yudao.framework.mybatis.core.mapper.AbstractMapper;
import cn.iocoder.yudao.module.reward.dal.dataobject.reward.RewardDO;
import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.reward.vo.reward.*;
/**
* 礼品 Mapper
* @author 系统管理员
*/
@Mapper
public interface RewardMapper extends AbstractMapper<RewardDO> {
@Override
default PageResult<RewardDO> selectPage(PageVO page, Object object) {
if (object instanceof RewardQueryVO) {
RewardQueryVO vo = (RewardQueryVO)object;
return selectPage(page, new LambdaQuery<RewardDO>()
.eqIfPresent(RewardDO::getCode, vo.getCode())
.eqIfPresent(RewardDO::getTitleZh, vo.getTitle())
.eqIfPresent(RewardDO::getTitleEn, vo.getTitle())
.eqIfPresent(RewardDO::getTitleFr, vo.getTitle())
.eqIfPresent(RewardDO::getPointsRequire, vo.getPointsRequire())
.eqIfPresent(RewardDO::getNodeId, vo.getNodeId())
.eqIfPresent(RewardDO::getQuantityRemain, vo.getQuantityRemain())
.eqIfPresent(RewardDO::getPickMethod, vo.getPickMethod())
.eqIfPresent(RewardDO::getStatus, vo.getStatus())
.betweenIfPresent(RewardDO::getCreateTime, vo.getBeginCreateTime(), vo.getEndCreateTime())
.orderByDesc(RewardDO::getId));
}
return null;
}
@Override
default List<RewardDO> selectList(Object object) {
if (object instanceof RewardQueryVO) {
RewardQueryVO vo = (RewardQueryVO)object;
return selectList(new LambdaQuery<RewardDO>()
.eqIfPresent(RewardDO::getCode, vo.getCode())
.eqIfPresent(RewardDO::getTitleZh, vo.getTitle())
.eqIfPresent(RewardDO::getTitleEn, vo.getTitle())
.eqIfPresent(RewardDO::getTitleFr, vo.getTitle())
.eqIfPresent(RewardDO::getPointsRequire, vo.getPointsRequire())
.eqIfPresent(RewardDO::getNodeId, vo.getNodeId())
.eqIfPresent(RewardDO::getQuantityRemain, vo.getQuantityRemain())
.eqIfPresent(RewardDO::getPickMethod, vo.getPickMethod())
.eqIfPresent(RewardDO::getStatus, vo.getStatus())
.betweenIfPresent(RewardDO::getCreateTime, vo.getBeginCreateTime(), vo.getEndCreateTime())
.orderByDesc(RewardDO::getId));
}
return null;
}
}
package cn.iocoder.yudao.module.reward.service.reward;
import java.util.*;
import javax.validation.*;
import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import cn.iocoder.yudao.framework.mybatis.core.service.IService;
import cn.iocoder.yudao.module.reward.vo.reward.*;
import cn.iocoder.yudao.module.reward.dal.dataobject.reward.RewardDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
/**
* 礼品 Service 接口
*
* @author 系统管理员
*/
public interface RewardService extends IService<RewardDO> {
/**
* 创建礼品
* @param createReqVO 创建信息
* @return 编号
*/
Long create(@Valid RewardCreateReqVO createReqVO);
/**
* 更新礼品
* @param updateReqVO 更新信息
*/
void update(@Valid RewardUpdateReqVO updateReqVO);
/**
* 删除礼品
* @param id 编号
*/
void delete(Long id);
/**
* 获得礼品
* @param id 编号
* @return 礼品
*/
RewardDO get(Long id);
/**
* 获得礼品列表
* @param ids 编号
* @return 礼品列表
*/
List<RewardDO> getList(Collection<Long> ids);
/**
* 获得礼品分页
* @param page 分页查询
* @param query 查询
* @return 礼品分页
*/
PageResult<RewardDO> getPage(RewardQueryVO query, PageVO page);
/**
* 获得礼品列表, 用于 Excel 导出
* @param query 查询
* @return 礼品列表
*/
List<RewardDO> getList(RewardQueryVO query);
}
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;
import cn.iocoder.yudao.framework.mybatis.core.service.AbstractService;
import cn.iocoder.yudao.module.reward.vo.reward.*;
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;
/**
* 礼品 Service 实现类
*
* @author 系统管理员
*/
@Service
@Validated
public class RewardServiceImpl extends AbstractService<RewardMapper, RewardDO> implements RewardService {
@Resource
private RewardMapper rewardMapper;
@Override
public Long create(RewardCreateReqVO createReqVO) {
// 插入
RewardDO rewardDO = RewardConvert.INSTANCE.convert(createReqVO);
rewardDO.setCode(generateRewardCode());
rewardMapper.insert(rewardDO);
// 返回
return rewardDO.getId();
}
@Override
public void update(RewardUpdateReqVO updateReqVO) {
// 校验存在
this.validateExists(updateReqVO.getId());
// 更新
RewardDO updateObj = RewardConvert.INSTANCE.convert(updateReqVO);
rewardMapper.updateById(updateObj);
}
@Override
public void delete(Long id) {
// 校验存在
this.validateExists(id);
// 删除
rewardMapper.deleteById(id);
}
private void validateExists(Long id) {
if (rewardMapper.selectById(id) == null) {
throw exception(_NOT_EXISTS);
}
}
@Override
public RewardDO get(Long id) {
return rewardMapper.selectById(id);
}
@Override
public List<RewardDO> getList(Collection<Long> ids) {
return rewardMapper.selectBatchIds(ids);
}
@Override
public PageResult<RewardDO> getPage(RewardQueryVO query, PageVO page) {
LambdaQuery<RewardDO> lambdaQuery = new LambdaQuery<>();
//礼品ID
lambdaQuery.eqIfPresent(RewardDO::getCode, query.getCode());
//礼品名称,模糊匹配三种语言
if (query.getTitle() != null) {
lambdaQuery.and(wrapper ->
wrapper.like(RewardDO::getTitleZh, query.getTitle())
.or()
.like(RewardDO::getTitleEn, query.getTitle())
.or()
.like(RewardDO::getTitleFr, query.getTitle())
);
}
//兑换积分
if (query.getPointsRequireSymbol() != null && query.getPointsRequire() != null) {
lambdaQuery.gt(query.getPointsRequireSymbol() == 1, RewardDO::getPointsRequire, query.getPointsRequire())
.eq(query.getPointsRequireSymbol() == 2, RewardDO::getPointsRequire, query.getPointsRequire())
.lt(query.getPointsRequireSymbol() == 3, RewardDO::getPointsRequire, query.getPointsRequire());
}
//兑换网点id,领取方式,状态
lambdaQuery.eqIfPresent(RewardDO::getNodeId, query.getNodeId())
.eqIfPresent(RewardDO::getPickMethod, query.getPickMethod())
.eqIfPresent(RewardDO::getStatus, query.getStatus());
//备注,模糊匹配三种语言
if (query.getRemark() != null) {
lambdaQuery.and(wrapper ->
wrapper.like(RewardDO::getRemarkZh, query.getRemark())
.or()
.like(RewardDO::getRemarkEn, query.getRemark())
.or()
.like(RewardDO::getRemarkFr, query.getRemark())
);
}
//剩余数量
if (query.getQuantityRemainSymbol() != null && query.getQuantityRemain() != null) {
lambdaQuery.gt(query.getQuantityRemainSymbol() == 1, RewardDO::getQuantityRemain, query.getQuantityRemain())
.eq(query.getQuantityRemainSymbol() == 2, RewardDO::getQuantityRemain, query.getQuantityRemain())
.lt(query.getQuantityRemainSymbol() == 3, RewardDO::getQuantityRemain, query.getQuantityRemain());
}
//创建时间
lambdaQuery.betweenIfPresent(RewardDO::getCreateTime, query.getBeginCreateTime(), query.getEndCreateTime())
.orderByDesc(RewardDO::getId);
return rewardMapper.selectPage(page, lambdaQuery);
}
@Override
public List<RewardDO> getList(RewardQueryVO query) {
return rewardMapper.selectList(query);
}
//生成礼品ID
private String generateRewardCode() {
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
return uuid.substring(0, 12).toUpperCase();
}
}
package cn.iocoder.yudao.module.reward.vo.reward;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import com.alibaba.excel.annotation.ExcelProperty;
import org.springframework.format.annotation.DateTimeFormat;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
/**
* 礼品 Response VO
* @author 系统管理员
*/
@Data
@ApiModel("管理后台 - 礼品 Response VO")
public class RewardBackVO {
@ExcelProperty("")
@ApiModelProperty(value = "", required = true)
private Long id;
@ExcelProperty("礼品ID")
@ApiModelProperty(value = "礼品ID", required = true)
private String code;
@ExcelProperty("中文名称")
@ApiModelProperty(value = "中文名称")
private String titleZh;
@ExcelProperty("英文名称")
@ApiModelProperty(value = "英文名称")
private String titleEn;
@ExcelProperty("法文名称")
@ApiModelProperty(value = "法文名称")
private String titleFr;
@ExcelProperty("中文礼品图片")
@ApiModelProperty(value = "中文礼品图片")
private String imgZh;
@ExcelProperty("英文礼品图片")
@ApiModelProperty(value = "英文礼品图片")
private String imgEn;
@ExcelProperty("法文礼品图片")
@ApiModelProperty(value = "法文礼品图片")
private String imgFr;
@ExcelProperty("兑换所需积分")
@ApiModelProperty(value = "兑换所需积分", required = true)
private Integer pointsRequire;
@ExcelProperty("兑换网点")
@ApiModelProperty(value = "兑换网点", required = true)
private Integer nodeId;
@ExcelProperty("已兑换次数")
@ApiModelProperty(value = "已兑换次数")
private Integer exchangeCount;
@ExcelProperty("剩余数量")
@ApiModelProperty(value = "剩余数量", required = true)
private Integer quantityRemain;
@ExcelProperty("活动开始时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "活动开始时间")
private Date startTime;
@ExcelProperty("活动结束时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "活动结束时间")
private Date endTime;
@ExcelProperty("领取方式(1上门领取,2包邮到家,3邮寄到付)")
@ApiModelProperty(value = "领取方式(1上门领取,2包邮到家,3邮寄到付)", required = true)
private Integer pickMethod;
@ExcelProperty("允许兑换次数")
@ApiModelProperty(value = "允许兑换次数", required = true)
private Integer allowCount;
@ExcelProperty("中文备注")
@ApiModelProperty(value = "中文备注")
private String remarkZh;
@ExcelProperty("英文备注")
@ApiModelProperty(value = "英文备注")
private String remarkEn;
@ExcelProperty("法文备注")
@ApiModelProperty(value = "法文备注")
private String remarkFr;
@ExcelProperty("礼品状态(1已启用,2未启用,3已关闭,4已过期)")
@ApiModelProperty(value = "礼品状态(1已启用,2未启用,3已关闭,4已过期)", required = true)
private Integer status;
@ExcelProperty("创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "创建时间", required = true)
private Date createTime;
}
package cn.iocoder.yudao.module.reward.vo.reward;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import javax.validation.constraints.*;
import org.springframework.format.annotation.DateTimeFormat;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
/**
* 礼品 Base VO,提供给添加、修改、详细的子 VO 使用
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
*/
@Data
public class RewardBaseVO {
@ApiModelProperty(value = "礼品ID")
private String code;
@ApiModelProperty(value = "中文名称")
private String titleZh;
@ApiModelProperty(value = "英文名称")
private String titleEn;
@ApiModelProperty(value = "法文名称")
private String titleFr;
@ApiModelProperty(value = "中文礼品图片")
private String imgZh;
@ApiModelProperty(value = "英文礼品图片")
private String imgEn;
@ApiModelProperty(value = "法文礼品图片")
private String imgFr;
@ApiModelProperty(value = "兑换所需积分")
private Integer pointsRequire;
@ApiModelProperty(value = "兑换网点")
private Integer nodeId;
@ApiModelProperty(value = "已兑换次数")
private Integer exchangeCount;
@ApiModelProperty(value = "剩余数量")
private Integer quantityRemain;
@ApiModelProperty(value = "活动开始时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private Date startTime;
@ApiModelProperty(value = "活动结束时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private Date endTime;
@ApiModelProperty(value = "领取方式(1上门领取,2包邮到家,3邮寄到付)")
private Integer pickMethod;
@ApiModelProperty(value = "允许兑换次数")
private Integer allowCount;
@ApiModelProperty(value = "中文备注")
private String remarkZh;
@ApiModelProperty(value = "英文备注")
private String remarkEn;
@ApiModelProperty(value = "法文备注")
private String remarkFr;
@ApiModelProperty(value = "礼品状态(1已启用,2未启用,3已关闭,4已过期)")
private Integer status;
}
package cn.iocoder.yudao.module.reward.vo.reward;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.*;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Data
@ToString(callSuper = true)
@ApiModel("管理后台 - 礼品创建 Request VO")
public class RewardCreateReqVO {
@ApiModelProperty(value = "中文名称")
private String titleZh;
@ApiModelProperty(value = "英文名称")
private String titleEn;
@ApiModelProperty(value = "法文名称")
private String titleFr;
@ApiModelProperty(value = "中文礼品图片")
private String imgZh;
@ApiModelProperty(value = "英文礼品图片")
private String imgEn;
@ApiModelProperty(value = "法文礼品图片")
private String imgFr;
@ApiModelProperty(value = "兑换所需积分", required = true)
@NotNull(message = "兑换所需积分不能为空")
private Integer pointsRequire;
@ApiModelProperty(value = "兑换网点", required = true)
@NotNull(message = "兑换网点不能为空")
private Integer nodeId;
@ApiModelProperty(value = "剩余数量", required = true)
@NotNull(message = "剩余数量不能为空")
private Integer quantityRemain;
@ApiModelProperty(value = "活动开始时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private Date startTime;
@ApiModelProperty(value = "活动结束时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private Date endTime;
@ApiModelProperty(value = "领取方式(1上门领取,2包邮到家,3邮寄到付)", required = true)
@NotNull(message = "领取方式不能为空")
private Integer pickMethod;
@ApiModelProperty(value = "允许兑换次数", required = true)
@NotNull(message = "允许兑换次数不能为空")
private Integer allowCount;
@ApiModelProperty(value = "中文备注")
@Size(max = 500, message = "中文备注长度不能超过500")
private String remarkZh;
@ApiModelProperty(value = "英文备注")
@Size(max = 500, message = "英文备注长度不能超过500")
private String remarkEn;
@ApiModelProperty(value = "法文备注")
@Size(max = 500, message = "法文备注长度不能超过500")
private String remarkFr;
@ApiModelProperty(value = "礼品状态(1已启用,2未启用,3已关闭,4已过期)", required = true)
@NotNull(message = "礼品状态不能为空")
private Integer status;
}
package cn.iocoder.yudao.module.reward.vo.reward;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Data
@ApiModel("管理后台 - 礼品查询 VO")
public class RewardQueryVO {
@ApiModelProperty(value = "礼品ID")
private String code;
@ApiModelProperty(value = "名称(不区分语言)")
private String title;
@ApiModelProperty(value = "兑换所需积分")
private Integer pointsRequire;
@ApiModelProperty(value = "兑换所需积分查询条件(1大于,2等于,3小于)")
private Integer pointsRequireSymbol;
@ApiModelProperty(value = "兑换网点")
private Integer nodeId;
@ApiModelProperty(value = "剩余数量")
private Integer quantityRemain;
@ApiModelProperty(value = "剩余数量查询条件(1大于,2等于,3小于)")
private Integer quantityRemainSymbol;
@ApiModelProperty(value = "领取方式(1上门领取,2包邮到家,3邮寄到付)")
private Integer pickMethod;
@ApiModelProperty(value = "礼品状态(1已启用,2未启用,3已关闭,4已过期)")
private Integer status;
@ApiModelProperty(value = "备注(不区分语言)")
private Integer remark;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始创建时间")
private Date beginCreateTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束创建时间")
private Date endCreateTime;
}
package cn.iocoder.yudao.module.reward.vo.reward;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
@Data
@ApiModel("管理后台 - 礼品状态更新 VO")
public class RewardStatusReqVO {
@ApiModelProperty(value = "", required = true)
@NotNull(message = "不能为空")
private Long id;
@ApiModelProperty(value = "礼品状态(1已启用,2未启用,3已关闭,4已过期)")
@NotNull(message = "礼品状态不能为空")
private Integer status;
}
package cn.iocoder.yudao.module.reward.vo.reward;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import javax.validation.constraints.*;
@ApiModel("管理后台 - 礼品更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class RewardUpdateReqVO extends RewardBaseVO {
@ApiModelProperty(value = "", required = true)
@NotNull(message = "不能为空")
private 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