mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2025-01-31 17:40:05 +08:00
code review:会员签到配置
This commit is contained in:
parent
bfc72a9802
commit
c7285da9a7
@ -12,18 +12,20 @@ import javax.validation.constraints.NotNull;
|
|||||||
@Data
|
@Data
|
||||||
public class MemberPointConfigBaseVO {
|
public class MemberPointConfigBaseVO {
|
||||||
|
|
||||||
@NotNull(message = "积分抵扣开发不能为空")
|
|
||||||
@Schema(description = "积分抵扣开关", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
@Schema(description = "积分抵扣开关", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
||||||
|
@NotNull(message = "积分抵扣开发不能为空")
|
||||||
private Boolean tradeDeductEnable;
|
private Boolean tradeDeductEnable;
|
||||||
|
|
||||||
@NotNull(message = "积分抵扣不能为空")
|
|
||||||
@Schema(description = "积分抵扣,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "13506")
|
@Schema(description = "积分抵扣,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "13506")
|
||||||
|
@NotNull(message = "积分抵扣不能为空")
|
||||||
private Integer tradeDeductUnitPrice;
|
private Integer tradeDeductUnitPrice;
|
||||||
@NotNull(message = "积分抵扣最大值不能为空")
|
|
||||||
@Schema(description = "积分抵扣最大值", requiredMode = Schema.RequiredMode.REQUIRED, example = "32428")
|
@Schema(description = "积分抵扣最大值", requiredMode = Schema.RequiredMode.REQUIRED, example = "32428")
|
||||||
|
@NotNull(message = "积分抵扣最大值不能为空")
|
||||||
private Integer tradeDeductMaxPrice;
|
private Integer tradeDeductMaxPrice;
|
||||||
@NotNull(message = "1元赠送积分不能为空")
|
|
||||||
@Schema(description = "1 元赠送多少分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
@Schema(description = "1 元赠送多少分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||||
|
@NotNull(message = "1 元赠送积分不能为空")
|
||||||
private Integer tradeGivePoint;
|
private Integer tradeGivePoint;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
package cn.iocoder.yudao.module.member.controller.admin.signin.vo.config;
|
package cn.iocoder.yudao.module.member.controller.admin.signin.vo.config;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.*;
|
import lombok.Data;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
|
||||||
import javax.validation.constraints.NotEmpty;
|
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import javax.validation.constraints.Pattern;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 积分签到规则 Base VO,提供给添加、修改、详细的子 VO 使用
|
* 积分签到规则 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||||
@ -15,13 +12,12 @@ import javax.validation.constraints.Pattern;
|
|||||||
@Data
|
@Data
|
||||||
public class MemberSignInConfigBaseVO {
|
public class MemberSignInConfigBaseVO {
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "签到第 x 天", requiredMode = Schema.RequiredMode.REQUIRED, example = "7")
|
@Schema(description = "签到第 x 天", requiredMode = Schema.RequiredMode.REQUIRED, example = "7")
|
||||||
@NotNull(message = "签到天数不能为空")
|
@NotNull(message = "签到天数不能为空")
|
||||||
private Integer day;
|
private Integer day;
|
||||||
|
|
||||||
@Schema(description = "签到天数对应分数", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
|
@Schema(description = "奖励积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
|
||||||
@NotNull(message = "签到天数对应分数不能为空")
|
@NotNull(message = "奖励积分不能为空")
|
||||||
private Integer point;
|
private Integer point;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
@ -31,7 +31,7 @@ public class MemberSignInConfigDO extends BaseDO {
|
|||||||
*/
|
*/
|
||||||
private Integer day;
|
private Integer day;
|
||||||
/**
|
/**
|
||||||
* 签到天数对应分数
|
* 奖励积分
|
||||||
*/
|
*/
|
||||||
private Integer point;
|
private Integer point;
|
||||||
|
|
||||||
|
@ -1,13 +1,9 @@
|
|||||||
package cn.iocoder.yudao.module.member.dal.mysql.signin;
|
package cn.iocoder.yudao.module.member.dal.mysql.signin;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInConfigDO;
|
import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInConfigDO;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 积分签到规则 Mapper
|
* 积分签到规则 Mapper
|
||||||
*
|
*
|
||||||
@ -16,7 +12,6 @@ import java.util.List;
|
|||||||
@Mapper
|
@Mapper
|
||||||
public interface MemberSignInConfigMapper extends BaseMapperX<MemberSignInConfigDO> {
|
public interface MemberSignInConfigMapper extends BaseMapperX<MemberSignInConfigDO> {
|
||||||
|
|
||||||
|
|
||||||
default MemberSignInConfigDO selectByDay(Integer day) {
|
default MemberSignInConfigDO selectByDay(Integer day) {
|
||||||
return selectOne(MemberSignInConfigDO::getDay, day);
|
return selectOne(MemberSignInConfigDO::getDay, day);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package cn.iocoder.yudao.module.member.service.point;
|
package cn.iocoder.yudao.module.member.service.point;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
|
|
||||||
import cn.iocoder.yudao.module.member.controller.admin.point.vo.config.MemberPointConfigSaveReqVO;
|
import cn.iocoder.yudao.module.member.controller.admin.point.vo.config.MemberPointConfigSaveReqVO;
|
||||||
import cn.iocoder.yudao.module.member.convert.point.MemberPointConfigConvert;
|
import cn.iocoder.yudao.module.member.convert.point.MemberPointConfigConvert;
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.point.MemberPointConfigDO;
|
import cn.iocoder.yudao.module.member.dal.dataobject.point.MemberPointConfigDO;
|
||||||
@ -26,17 +25,14 @@ public class MemberPointConfigServiceImpl implements MemberPointConfigService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveConfig(MemberPointConfigSaveReqVO saveReqVO) {
|
public void saveConfig(MemberPointConfigSaveReqVO saveReqVO) {
|
||||||
//获取当前记录
|
// 存在,则进行更新
|
||||||
MemberPointConfigDO configDO = getConfig();
|
MemberPointConfigDO dbConfig = getConfig();
|
||||||
MemberPointConfigDO pointConfigDO = MemberPointConfigConvert.INSTANCE.convert(saveReqVO);
|
if (dbConfig != null) {
|
||||||
//当前存在记录,则更新,否则插入
|
pointConfigMapper.updateById(MemberPointConfigConvert.INSTANCE.convert(saveReqVO).setId(dbConfig.getId()));
|
||||||
if (configDO != null) {
|
return;
|
||||||
pointConfigDO.setId(configDO.getId());
|
|
||||||
pointConfigMapper.updateById(pointConfigDO);
|
|
||||||
} else {
|
|
||||||
pointConfigDO.setId(null);
|
|
||||||
pointConfigMapper.insert(pointConfigDO);
|
|
||||||
}
|
}
|
||||||
|
// 不存在,则进行插入
|
||||||
|
pointConfigMapper.insert(MemberPointConfigConvert.INSTANCE.convert(saveReqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -29,6 +29,7 @@ public class MemberPointRecordServiceImpl implements MemberPointRecordService {
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private MemberPointRecordMapper recordMapper;
|
private MemberPointRecordMapper recordMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private MemberUserApi memberUserApi;
|
private MemberUserApi memberUserApi;
|
||||||
|
|
||||||
@ -44,6 +45,7 @@ public class MemberPointRecordServiceImpl implements MemberPointRecordService {
|
|||||||
}
|
}
|
||||||
userIds = convertSet(users, MemberUserRespDTO::getId);
|
userIds = convertSet(users, MemberUserRespDTO::getId);
|
||||||
}
|
}
|
||||||
|
// 执行查询
|
||||||
return recordMapper.selectPage(pageReqVO, userIds);
|
return recordMapper.selectPage(pageReqVO, userIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,10 +11,10 @@ import org.springframework.validation.annotation.Validated;
|
|||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*;
|
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.SIGN_IN_CONFIG_EXISTS;
|
||||||
|
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.SIGN_IN_CONFIG_NOT_EXISTS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 积分签到规则 Service 实现类
|
* 积分签到规则 Service 实现类
|
||||||
@ -91,10 +91,9 @@ public class MemberSignInConfigServiceImpl implements MemberSignInConfigService
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List <MemberSignInConfigDO> getSignInConfigList() {
|
public List <MemberSignInConfigDO> getSignInConfigList() {
|
||||||
//查询出所有的配置记录
|
List<MemberSignInConfigDO> list = signInConfigMapper.selectList();
|
||||||
List<MemberSignInConfigDO> result = signInConfigMapper.selectList();
|
list.sort(Comparator.comparing(MemberSignInConfigDO::getDay));
|
||||||
//业务侧排序后返回结果
|
return list;
|
||||||
return result.stream().sorted(Comparator.comparing(MemberSignInConfigDO::getDay)).collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user