Commit 0612f246 authored by zhangfeng's avatar zhangfeng

积分规则接口

parent d5fc0620
......@@ -65,9 +65,9 @@ public class ScoreRuleController {
@ApiOperation("获得积分规则详情")
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
@PreAuthorize("@ss.hasPermission('member:score-rule:query')")
public CommonResult<ScoreRuleBackVO> getScoreRule(@NotNull @RequestBody Long id) {
ScoreRuleBackVO scoreRuleBackVO = scoreRuleService.getScoreRule(id);
return success(scoreRuleBackVO);
public CommonResult<ScoreRuleBackDetailVO> getScoreRule(@NotNull @RequestBody Long id) {
ScoreRuleBackDetailVO scoreRuleBackDetailVO = scoreRuleService.getScoreRule(id);
return success(scoreRuleBackDetailVO);
}
@PostMapping("/list")
......
package cn.iocoder.yudao.module.member.convert.scoreRule;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.member.dal.dataobject.scoreRule.ScoreRuleDO;
import cn.iocoder.yudao.module.member.vo.scoreRule.ScoreRuleBackVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.ScoreRuleCreateReqVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.ScoreRuleUpdateReqVO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import cn.iocoder.yudao.module.member.dal.dataobject.scoreRule.ScoreRuleDO;
import java.util.List;
/**
* 积分规则 DO Convert
......
......@@ -41,7 +41,7 @@ public interface ScoreRuleService extends IService<ScoreRuleDO> {
* @param id 编号
* @return 积分规则
*/
ScoreRuleBackVO getScoreRule(Long id);
ScoreRuleBackDetailVO getScoreRule(Long id);
/**
* 获得积分规则列表
......
......@@ -17,6 +17,7 @@ import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleOrderVExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleRegisterExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleShareExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRulerRecommendExtraVO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
......@@ -99,14 +100,15 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
}
@Override
public ScoreRuleBackVO getScoreRule(Long id) {
public ScoreRuleBackDetailVO getScoreRule(Long id) {
ScoreRuleDO scoreRuleDO = scoreRuleMapper.selectById(id);
if (scoreRuleDO == null) {
throw exception(SCORE_RULE_NOT_EXISTS);
}
ScoreRuleBackVO scoreRuleBackVO = ScoreRuleConvert.INSTANCE.convert(scoreRuleDO);
setExtraVO(scoreRuleBackVO);
return scoreRuleBackVO;
ScoreRuleBackDetailVO scoreRuleBackDetailVO = new ScoreRuleBackDetailVO();
BeanUtils.copyProperties(scoreRuleDO, scoreRuleBackDetailVO);
setExtraVO(scoreRuleBackDetailVO);
return scoreRuleBackDetailVO;
}
......@@ -114,7 +116,6 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
public List<ScoreRuleBackVO> getScoreRuleList(Collection<Long> ids) {
List<ScoreRuleDO> scoreRuleDOS = scoreRuleMapper.selectBatchIds(ids);
List<ScoreRuleBackVO> scoreRuleBackVOS = ScoreRuleConvert.INSTANCE.convertList(scoreRuleDOS);
scoreRuleBackVOS.forEach(this::setExtraVO);
return scoreRuleBackVOS;
}
......@@ -122,24 +123,23 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
public PageResult<ScoreRuleBackVO> getScoreRulePage(ScoreRuleQueryVO query, PageVO page) {
PageResult<ScoreRuleDO> pageResult = scoreRuleMapper.selectPage(page, query);
PageResult<ScoreRuleBackVO> scoreRuleBackVOPageResult = ScoreRuleConvert.INSTANCE.convertPage(pageResult);
scoreRuleBackVOPageResult.getList().forEach(this::setExtraVO);
return scoreRuleBackVOPageResult;
}
/**
* 设置返回VO额外信息
*
* @param scoreRuleBackVO VO
* @param scoreRuleBackDetailVO VO
*/
private void setExtraVO(ScoreRuleBackVO scoreRuleBackVO) {
if (scoreRuleBackVO.getType() == ScoreRuleTypeEnum.ORDER_V.getValue()) {
scoreRuleBackVO.setExtraOrderV(JSONUtil.toBean(scoreRuleBackVO.getExtra(), ScoreRuleOrderVExtraVO.class));
} else if (scoreRuleBackVO.getType() == ScoreRuleTypeEnum.REGISTER.getValue()) {
scoreRuleBackVO.setExtraRegister(JSONUtil.toBean(scoreRuleBackVO.getExtra(), ScoreRuleRegisterExtraVO.class));
} else if (scoreRuleBackVO.getType() == ScoreRuleTypeEnum.RECOMMEND.getValue()) {
scoreRuleBackVO.setExtraRecommend(JSONUtil.toBean(scoreRuleBackVO.getExtra(), ScoreRulerRecommendExtraVO.class));
} else if (scoreRuleBackVO.getType() == ScoreRuleTypeEnum.SHARE.getValue()) {
scoreRuleBackVO.setExtraShare(JSONUtil.toBean(scoreRuleBackVO.getExtra(), ScoreRuleShareExtraVO.class));
private void setExtraVO(ScoreRuleBackDetailVO scoreRuleBackDetailVO) {
if (scoreRuleBackDetailVO.getType() == ScoreRuleTypeEnum.ORDER_V.getValue()) {
scoreRuleBackDetailVO.setExtraOrderV(JSONUtil.toBean(scoreRuleBackDetailVO.getExtra(), ScoreRuleOrderVExtraVO.class));
} else if (scoreRuleBackDetailVO.getType() == ScoreRuleTypeEnum.REGISTER.getValue()) {
scoreRuleBackDetailVO.setExtraRegister(JSONUtil.toBean(scoreRuleBackDetailVO.getExtra(), ScoreRuleRegisterExtraVO.class));
} else if (scoreRuleBackDetailVO.getType() == ScoreRuleTypeEnum.RECOMMEND.getValue()) {
scoreRuleBackDetailVO.setExtraRecommend(JSONUtil.toBean(scoreRuleBackDetailVO.getExtra(), ScoreRulerRecommendExtraVO.class));
} else if (scoreRuleBackDetailVO.getType() == ScoreRuleTypeEnum.SHARE.getValue()) {
scoreRuleBackDetailVO.setExtraShare(JSONUtil.toBean(scoreRuleBackDetailVO.getExtra(), ScoreRuleShareExtraVO.class));
} else {
throw exception(SCORE_RULE_NOT_EXISTS);
}
......
package cn.iocoder.yudao.module.member.vo.scoreRule;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleOrderVExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleRegisterExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleShareExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRulerRecommendExtraVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel("管理后台 - 积分规则详细信息 Response VO")
public class ScoreRuleBackDetailVO extends ScoreRuleBackVO{
@ApiModelProperty(value = "扩展字段原始")
private String extra;
@ApiModelProperty(value = "订单V值扩展字段")
private ScoreRuleOrderVExtraVO extraOrderV;
@ApiModelProperty(value = "注册扩展字段")
private ScoreRuleRegisterExtraVO extraRegister;
@ApiModelProperty(value = "推荐扩展字段")
private ScoreRulerRecommendExtraVO extraRecommend;
@ApiModelProperty(value = "分享扩展字段")
private ScoreRuleShareExtraVO extraShare;
}
package cn.iocoder.yudao.module.member.vo.scoreRule;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleOrderVExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleRegisterExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleShareExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRulerRecommendExtraVO;
import com.baomidou.dynamic.datasource.annotation.DS;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
/**
......@@ -17,7 +15,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
* @author 系统管理员
*/
@Data
@ApiModel("管理后台 - 积分规则 Response VO")
@ApiModel("管理后台 - 积分规则基本信息 Response VO")
public class ScoreRuleBackVO {
@ExcelProperty("主键")
......@@ -72,7 +70,7 @@ public class ScoreRuleBackVO {
@ExcelProperty("积分有效期")
@ApiModelProperty(value = "积分有效期", required = true)
private Integer socrePeriod;
private Integer scorePeriod;
@ExcelProperty("排序值")
@ApiModelProperty(value = "排序值", required = true)
......@@ -95,15 +93,17 @@ public class ScoreRuleBackVO {
@ApiModelProperty(value = "创建时间", required = true)
private Date createTime;
@ApiModelProperty(value = "扩展字段原始")
private String extra;
@ApiModelProperty(value = "订单V值扩展字段")
private ScoreRuleOrderVExtraVO extraOrderV;
@ApiModelProperty(value = "注册扩展字段")
private ScoreRuleRegisterExtraVO extraRegister;
@ApiModelProperty(value = "推荐扩展字段")
private ScoreRulerRecommendExtraVO extraRecommend;
@ApiModelProperty(value = "分享扩展字段")
private ScoreRuleShareExtraVO extraShare;
@ExcelProperty("更新时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "更新时间", required = true)
private Date updateTime;
@ExcelProperty("创建人")
@ApiModelProperty(value = "创建人", required = true)
private String creator;
@ExcelProperty("更新人")
@ApiModelProperty(value = "更新人", required = true)
private String updater;
}
......@@ -70,7 +70,7 @@ public class ScoreRuleBaseVO {
@NotNull(message = "排序值不能为空")
private Integer orderNum;
@ApiModelProperty(value = "是否推送(0是,1否)", required = true)
@ApiModelProperty(value = "是否推送(0是,1否)默认是", required = true)
@NotNull(message = "是否推送不能为空")
private Integer pushActivity = 0;
......
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