会员签到针对代码格式、功能优化

1.优化todo建议
2.删除无用代码
This commit is contained in:
xiaqing 2023-08-09 16:13:35 +08:00
parent ba59ec85e0
commit 33323c1483
16 changed files with 152 additions and 122 deletions

View File

@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.member.controller.admin.signin;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInConfigCreateReqVO; import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInConfigCreateReqVO;
import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInConfigPageReqVO;
import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInConfigRespVO; import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInConfigRespVO;
import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInConfigUpdateReqVO; import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInConfigUpdateReqVO;
import cn.iocoder.yudao.module.member.convert.signin.MemberSignInConfigConvert; import cn.iocoder.yudao.module.member.convert.signin.MemberSignInConfigConvert;
@ -19,6 +18,8 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Tag(name = "管理后台 - 积分签到规则") @Tag(name = "管理后台 - 积分签到规则")
@ -63,12 +64,12 @@ public class MemberSignInConfigController {
return success(MemberSignInConfigConvert.INSTANCE.convert(signInConfig)); return success(MemberSignInConfigConvert.INSTANCE.convert(signInConfig));
} }
@GetMapping("/page") @GetMapping("/list")
@Operation(summary = "获得积分签到规则分页") @Operation(summary = "获得积分签到规则分页")
@PreAuthorize("@ss.hasPermission('point:sign-in-config:query')") @PreAuthorize("@ss.hasPermission('point:sign-in-config:query')")
public CommonResult<PageResult<MemberSignInConfigRespVO>> getSignInConfigPage(@Valid MemberSignInConfigPageReqVO pageVO) { public CommonResult<List<MemberSignInConfigRespVO>> getSignInConfigPage() {
PageResult<MemberSignInConfigDO> pageResult = memberSignInConfigService.getSignInConfigPage(pageVO); List<MemberSignInConfigDO> pageResult = memberSignInConfigService.getSignInConfigList();
return success(MemberSignInConfigConvert.INSTANCE.convertPage(pageResult)); return success(MemberSignInConfigConvert.INSTANCE.convertList(pageResult));
} }
} }

View File

@ -7,16 +7,22 @@ import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInRec
import cn.iocoder.yudao.module.member.convert.signin.MemberSignInRecordConvert; import cn.iocoder.yudao.module.member.convert.signin.MemberSignInRecordConvert;
import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO; import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO;
import cn.iocoder.yudao.module.member.service.signin.MemberSignInRecordService; import cn.iocoder.yudao.module.member.service.signin.MemberSignInRecordService;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.List;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Tag(name = "管理后台 - 用户签到积分") @Tag(name = "管理后台 - 用户签到积分")
@ -27,31 +33,22 @@ public class MemberSignInRecordController {
@Resource @Resource
private MemberSignInRecordService memberSignInRecordService; private MemberSignInRecordService memberSignInRecordService;
@Resource
AdminUserApi adminUserApi;
// TODO @xiaqing签到是不是不用删除
@DeleteMapping("/delete")
@Operation(summary = "删除用户签到积分")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('point:sign-in-record:delete')")
public CommonResult<Boolean> deleteSignInRecord(@RequestParam("id") Long id) {
memberSignInRecordService.deleteSignInRecord(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得用户签到积分")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('point:sign-in-record:query')")
public CommonResult<MemberSignInRecordRespVO> getSignInRecord(@RequestParam("id") Long id) {
MemberSignInRecordDO signInRecord = memberSignInRecordService.getSignInRecord(id);
return success(MemberSignInRecordConvert.INSTANCE.convert(signInRecord));
}
@GetMapping("/page") @GetMapping("/page")
@Operation(summary = "获得用户签到积分分页") @Operation(summary = "获得用户签到积分分页")
@PreAuthorize("@ss.hasPermission('point:sign-in-record:query')") @PreAuthorize("@ss.hasPermission('point:sign-in-record:query')")
public CommonResult<PageResult<MemberSignInRecordRespVO>> getSignInRecordPage(@Valid MemberSignInRecordPageReqVO pageVO) { public CommonResult <PageResult <MemberSignInRecordRespVO>> getSignInRecordPage(@Valid MemberSignInRecordPageReqVO pageVO) {
PageResult<MemberSignInRecordDO> pageResult = memberSignInRecordService.getSignInRecordPage(pageVO); PageResult <MemberSignInRecordDO> pageResult = memberSignInRecordService.getSignInRecordPage(pageVO);
return success(MemberSignInRecordConvert.INSTANCE.convertPage(pageResult)); List <MemberSignInRecordDO> result = pageResult.getList();
//设置获取的用户信息
List <AdminUserRespDTO> users = null;
if (!CollectionUtils.isEmpty(result)) {
List <Long> ids = result.stream().map(user -> user.getUserId()).collect(Collectors.toList());
users = adminUserApi.getUserList(ids);
}
return success(MemberSignInRecordConvert.INSTANCE.convertPage(pageResult, users));
} }
} }

View File

@ -16,4 +16,8 @@ public class MemberSignInConfigBaseVO {
@Schema(description = "签到天数对应分数", example = "10") @Schema(description = "签到天数对应分数", example = "10")
private Integer point; private Integer point;
@Schema(description = "是否启用", example = "1")
private Boolean isEnable;
} }

View File

@ -1,16 +0,0 @@
package cn.iocoder.yudao.module.member.controller.admin.signin.vo;
import lombok.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
@Schema(description = "管理后台 - 积分签到规则分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class MemberSignInConfigPageReqVO extends PageParam {
@Schema(description = "签到第x天", example = "7")
private Integer day;
}

View File

@ -11,7 +11,7 @@ import lombok.Data;
public class MemberSignInRecordBaseVO { public class MemberSignInRecordBaseVO {
@Schema(description = "签到用户", example = "6507") @Schema(description = "签到用户", example = "6507")
private Integer userId; private Long userId;
@Schema(description = "第几天签到") @Schema(description = "第几天签到")
private Integer day; private Integer day;

View File

@ -18,7 +18,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
public class MemberSignInRecordPageReqVO extends PageParam { public class MemberSignInRecordPageReqVO extends PageParam {
@Schema(description = "签到用户", example = "6507") @Schema(description = "签到用户", example = "6507")
private Integer userId; private Long userId;
@Schema(description = "第几天签到") @Schema(description = "第几天签到")
private Integer day; private Integer day;

View File

@ -19,4 +19,7 @@ public class MemberSignInRecordRespVO extends MemberSignInRecordBaseVO {
@Schema(description = "签到时间") @Schema(description = "签到时间")
private LocalDateTime createTime; private LocalDateTime createTime;
//昵称用于前台展示
private String nickName;
} }

View File

@ -1,12 +1,18 @@
package cn.iocoder.yudao.module.member.convert.signin; package cn.iocoder.yudao.module.member.convert.signin;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInRecordCreateReqVO;
import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInRecordRespVO; import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInRecordRespVO;
import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInRecordUpdateReqVO;
import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO; import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/** /**
* 用户签到积分 Convert * 用户签到积分 Convert
@ -18,12 +24,57 @@ public interface MemberSignInRecordConvert {
MemberSignInRecordConvert INSTANCE = Mappers.getMapper(MemberSignInRecordConvert.class); MemberSignInRecordConvert INSTANCE = Mappers.getMapper(MemberSignInRecordConvert.class);
MemberSignInRecordDO convert(MemberSignInRecordCreateReqVO bean); default public MemberSignInRecordRespVO convert(MemberSignInRecordDO bean) {
if (bean == null) {
return null;
}
MemberSignInRecordDO convert(MemberSignInRecordUpdateReqVO bean); MemberSignInRecordRespVO memberSignInRecordRespVO = new MemberSignInRecordRespVO();
MemberSignInRecordRespVO convert(MemberSignInRecordDO bean); memberSignInRecordRespVO.setUserId(bean.getUserId());
memberSignInRecordRespVO.setDay(bean.getDay());
memberSignInRecordRespVO.setPoint(bean.getPoint());
memberSignInRecordRespVO.setId(bean.getId());
memberSignInRecordRespVO.setCreateTime(bean.getCreateTime());
return memberSignInRecordRespVO;
}
default PageResult <MemberSignInRecordRespVO> convertPage(PageResult <MemberSignInRecordDO> page, List<AdminUserRespDTO> userRespDTOS) {
if (page == null) {
return null;
}
PageResult <MemberSignInRecordRespVO> pageResult = new PageResult <MemberSignInRecordRespVO>();
pageResult.setList(memberSignInRecordDOListToMemberSignInRecordRespVOList(page.getList(),userRespDTOS));
pageResult.setTotal(page.getTotal());
return pageResult;
}
default List <MemberSignInRecordRespVO> memberSignInRecordDOListToMemberSignInRecordRespVOList(List <MemberSignInRecordDO> list,List<AdminUserRespDTO> userRespDTOS) {
if (list == null) {
return null;
}
Map <Long, String> maps=null;
//是否需要转换用户标志
boolean userNickFlag = !CollectionUtils.isEmpty(userRespDTOS);
if(userNickFlag){
maps = userRespDTOS.stream()
.collect(Collectors.toMap(AdminUserRespDTO::getId, AdminUserRespDTO::getNickname, (key1, key2) -> key2));
}
List <MemberSignInRecordRespVO> list1 = new ArrayList <MemberSignInRecordRespVO>(list.size());
for (MemberSignInRecordDO memberSignInRecordDO : list) {
MemberSignInRecordRespVO recordRespVO = convert(memberSignInRecordDO);
if(userNickFlag){
recordRespVO.setNickName(maps.get(recordRespVO.getUserId()));
}
list1.add(recordRespVO);
}
return list1;
}
PageResult<MemberSignInRecordRespVO> convertPage(PageResult<MemberSignInRecordDO> page);
} }

View File

@ -34,5 +34,8 @@ public class MemberSignInConfigDO extends BaseDO {
* 签到天数对应分数 * 签到天数对应分数
*/ */
private Integer point; private Integer point;
/**
* 是否启用
*/
private Boolean isEnable;
} }

View File

@ -29,7 +29,7 @@ public class MemberSignInRecordDO extends BaseDO {
/** /**
* 签到用户 * 签到用户
*/ */
private Integer userId; private Long userId;
/** /**
* 第几天签到 * 第几天签到
*/ */

View File

@ -1,13 +1,13 @@
package cn.iocoder.yudao.module.member.dal.mysql.signin; package cn.iocoder.yudao.module.member.dal.mysql.signin;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
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.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInConfigPageReqVO;
import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInConfigUpdateReqVO;
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,18 +16,32 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper @Mapper
public interface MemberSignInConfigMapper extends BaseMapperX<MemberSignInConfigDO> { public interface MemberSignInConfigMapper extends BaseMapperX<MemberSignInConfigDO> {
default PageResult<MemberSignInConfigDO> selectPage(MemberSignInConfigPageReqVO reqVO) { /**
return selectPage(reqVO, new LambdaQueryWrapperX<MemberSignInConfigDO>() * 描述 :选择性更新对象属性如果不为空则更新
.eqIfPresent(MemberSignInConfigDO::getDay, reqVO.getDay()) * Author :xiaqing
.orderByAsc(MemberSignInConfigDO::getDay)); * Date :2023-08-08 23:38:48
*/
default int updateIfPresent(MemberSignInConfigDO updateObj){
LambdaUpdateWrapper <MemberSignInConfigDO> wrapper = new LambdaUpdateWrapper <>();
wrapper.eq(MemberSignInConfigDO::getId, updateObj.getId())
.set(updateObj.getDay() != null, MemberSignInConfigDO::getDay, updateObj.getDay())
.set(updateObj.getPoint() != null, MemberSignInConfigDO::getPoint, updateObj.getPoint())
.set(updateObj.getIsEnable() != null, MemberSignInConfigDO::getIsEnable, updateObj.getIsEnable());
return update(null,wrapper);
} }
// default List <MemberSignInConfigDO> getList(){
default long selectSameDayNotSelf(MemberSignInConfigUpdateReqVO reqVO){ return selectList(new LambdaQueryWrapperX <MemberSignInConfigDO>().orderByAsc(MemberSignInConfigDO::getDay));
return selectCount(new LambdaQueryWrapperX <MemberSignInConfigDO>() }
.ne(MemberSignInConfigDO::getId, reqVO.getId())
.eq(MemberSignInConfigDO::getDay,reqVO.getDay()) /**
); * 描述 :根据天数查询对应记录
* Date :2023-08-09 00:07:11
*/
default MemberSignInConfigDO selectByDay(Integer day){
return selectOne(new LambdaQueryWrapperX <MemberSignInConfigDO>()
.eq(MemberSignInConfigDO::getDay,day));
} }
} }

View File

@ -1,12 +1,11 @@
package cn.iocoder.yudao.module.member.service.signin; package cn.iocoder.yudao.module.member.service.signin;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInConfigCreateReqVO; import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInConfigCreateReqVO;
import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInConfigPageReqVO;
import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInConfigUpdateReqVO; import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInConfigUpdateReqVO;
import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInConfigDO; import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInConfigDO;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.List;
/** /**
* 积分签到规则 Service 接口 * 积分签到规则 Service 接口
@ -48,9 +47,8 @@ public interface MemberSignInConfigService {
/** /**
* 获得积分签到规则分页 * 获得积分签到规则分页
* *
* @param pageReqVO 分页查询
* @return 积分签到规则分页 * @return 积分签到规则分页
*/ */
PageResult<MemberSignInConfigDO> getSignInConfigPage(MemberSignInConfigPageReqVO pageReqVO); List<MemberSignInConfigDO> getSignInConfigList();
} }

View File

@ -1,17 +1,20 @@
package cn.iocoder.yudao.module.member.service.signin; package cn.iocoder.yudao.module.member.service.signin;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInConfigCreateReqVO; import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInConfigCreateReqVO;
import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInConfigPageReqVO;
import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInConfigUpdateReqVO; import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInConfigUpdateReqVO;
import cn.iocoder.yudao.module.member.convert.signin.MemberSignInConfigConvert; import cn.iocoder.yudao.module.member.convert.signin.MemberSignInConfigConvert;
import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInConfigDO; import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInConfigDO;
import cn.iocoder.yudao.module.member.dal.mysql.signin.MemberSignInConfigMapper; import cn.iocoder.yudao.module.member.dal.mysql.signin.MemberSignInConfigMapper;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List;
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.SIGN_IN_CONFIG_EXISTS; 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; import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.SIGN_IN_CONFIG_NOT_EXISTS;
@ -28,30 +31,28 @@ public class MemberSignInConfigServiceImpl implements MemberSignInConfigService
@Resource @Resource
private MemberSignInConfigMapper memberSignInConfigMapper; private MemberSignInConfigMapper memberSignInConfigMapper;
// TODO @xiaqing这种写的逻辑最好按照 校验 - 更新这样的顺序写类似这里37 要放到 34 前面updateSignInConfig 也是一样的思路
@Override @Override
public Integer createSignInConfig(MemberSignInConfigCreateReqVO createReqVO) { public Integer createSignInConfig(MemberSignInConfigCreateReqVO createReqVO) {
// 判断是否重复插入签到天数
validateSignInConfigExistsDay(createReqVO.getDay());
// 插入 // 插入
MemberSignInConfigDO signInConfig = MemberSignInConfigConvert.INSTANCE.convert(createReqVO); MemberSignInConfigDO signInConfig = MemberSignInConfigConvert.INSTANCE.convert(createReqVO);
// 判断是否重复插入签到天数
validateSignInConfigExistsDay(signInConfig.getDay());
memberSignInConfigMapper.insert(signInConfig); memberSignInConfigMapper.insert(signInConfig);
// 返回 // 返回
return signInConfig.getId(); return signInConfig.getId();
} }
// TODO @xiaqing这个逻辑的空行要注意52 53 是没必要的空行 49 50 之间有个空行会好点可以区分出是 校验 - 更新这样的逻辑间隔
@Override @Override
public void updateSignInConfig(MemberSignInConfigUpdateReqVO updateReqVO) { public void updateSignInConfig(MemberSignInConfigUpdateReqVO updateReqVO) {
// 校验存在 // 校验存在
validateSignInConfigExists(updateReqVO.getId()); validateSignInConfigExists(updateReqVO.getId());
//判断是否重复插入签到天数 //判断是否重复插入签到天数
validateSignInConfigSameDayNotSelf(updateReqVO); validateSignInConfigSameDayNotSelf(updateReqVO);
// 判断更新的
// 判断更新
MemberSignInConfigDO updateObj = MemberSignInConfigConvert.INSTANCE.convert(updateReqVO); MemberSignInConfigDO updateObj = MemberSignInConfigConvert.INSTANCE.convert(updateReqVO);
memberSignInConfigMapper.updateIfPresent(updateObj);
memberSignInConfigMapper.updateById(updateObj);
} }
@Override @Override
@ -68,18 +69,18 @@ public class MemberSignInConfigServiceImpl implements MemberSignInConfigService
} }
} }
// TODO @xiaqing这个唯一判断也可以参考下别的模块哈
//根据签到天数判断是否存在一个相同的天数 //根据签到天数判断是否存在一个相同的天数
private void validateSignInConfigExistsDay(Integer day) { private void validateSignInConfigExistsDay(Integer day) {
if (memberSignInConfigMapper.selectCount(MemberSignInConfigDO::getDay,day)>0) { MemberSignInConfigDO configDO = memberSignInConfigMapper.selectByDay(day);
if (configDO != null) {
throw exception(SIGN_IN_CONFIG_EXISTS); throw exception(SIGN_IN_CONFIG_EXISTS);
} }
} }
// TODO @xiaqing参考下别的模块判断唯一排除自己怎么写的哈
// 更新天数时判断是否有重复的天数需要去除自己 // 更新天数时判断是否有重复的天数需要去除自己
private void validateSignInConfigSameDayNotSelf(MemberSignInConfigUpdateReqVO reqVO) { private void validateSignInConfigSameDayNotSelf(MemberSignInConfigUpdateReqVO reqVO) {
if (memberSignInConfigMapper.selectSameDayNotSelf(reqVO)>0) { MemberSignInConfigDO configDO = memberSignInConfigMapper.selectByDay(reqVO.getDay());
if (configDO != null && configDO.getId() != reqVO.getId()) {
throw exception(SIGN_IN_CONFIG_EXISTS); throw exception(SIGN_IN_CONFIG_EXISTS);
} }
} }
@ -90,8 +91,8 @@ public class MemberSignInConfigServiceImpl implements MemberSignInConfigService
} }
@Override @Override
public PageResult<MemberSignInConfigDO> getSignInConfigPage(MemberSignInConfigPageReqVO pageReqVO) { public List <MemberSignInConfigDO> getSignInConfigList() {
return memberSignInConfigMapper.selectPage(pageReqVO); return memberSignInConfigMapper.getList();
} }
} }

View File

@ -11,20 +11,7 @@ import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO
*/ */
public interface MemberSignInRecordService { public interface MemberSignInRecordService {
/**
* 删除用户签到积分
*
* @param id 编号
*/
void deleteSignInRecord(Long id);
/**
* 获得用户签到积分
*
* @param id 编号
* @return 用户签到积分
*/
MemberSignInRecordDO getSignInRecord(Long id);
/** /**
* 获得用户签到积分分页 * 获得用户签到积分分页
@ -34,4 +21,5 @@ public interface MemberSignInRecordService {
*/ */
PageResult<MemberSignInRecordDO> getSignInRecordPage(MemberSignInRecordPageReqVO pageReqVO); PageResult<MemberSignInRecordDO> getSignInRecordPage(MemberSignInRecordPageReqVO pageReqVO);
} }

View File

@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInRecordPageReqVO; import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInRecordPageReqVO;
import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO; import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO;
import cn.iocoder.yudao.module.member.dal.mysql.signin.MemberSignInRecordMapper; import cn.iocoder.yudao.module.member.dal.mysql.signin.MemberSignInRecordMapper;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -23,25 +24,10 @@ public class MemberSignInRecordServiceImpl implements MemberSignInRecordService
@Resource @Resource
private MemberSignInRecordMapper memberSignInRecordMapper; private MemberSignInRecordMapper memberSignInRecordMapper;
@Resource
AdminUserApi adminUserApi;
@Override
public void deleteSignInRecord(Long id) {
// 校验存在
validateSignInRecordExists(id);
// 删除
memberSignInRecordMapper.deleteById(id);
}
private void validateSignInRecordExists(Long id) {
if (memberSignInRecordMapper.selectById(id) == null) {
throw exception(SIGN_IN_RECORD_NOT_EXISTS);
}
}
@Override
public MemberSignInRecordDO getSignInRecord(Long id) {
return memberSignInRecordMapper.selectById(id);
}
@Override @Override
public PageResult<MemberSignInRecordDO> getSignInRecordPage(MemberSignInRecordPageReqVO pageReqVO) { public PageResult<MemberSignInRecordDO> getSignInRecordPage(MemberSignInRecordPageReqVO pageReqVO) {

View File

@ -44,31 +44,31 @@ spring:
primary: master primary: master
datasource: datasource:
master: master:
name: ruoyi-vue-pro name: mall
url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 url: jdbc:mysql://10.211.55.5:3308/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
# url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT # MySQL Connector/J 5.X 连接的示例 # url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT # MySQL Connector/J 5.X 连接的示例
# url: jdbc:postgresql://127.0.0.1:5432/${spring.datasource.dynamic.datasource.master.name} # PostgreSQL 连接的示例 # url: jdbc:postgresql://127.0.0.1:5432/${spring.datasource.dynamic.datasource.master.name} # PostgreSQL 连接的示例
# url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
# url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.master.name} # SQLServer 连接的示例 # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.master.name} # SQLServer 连接的示例
username: root username: root
password: 123456 password: 1qaz!QAZ
# username: sa # username: sa
# password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W
slave: # 模拟从库,可根据自己需要修改 slave: # 模拟从库,可根据自己需要修改
name: ruoyi-vue-pro name: mall
url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 url: jdbc:mysql://10.211.55.5:3308/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
# url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT # MySQL Connector/J 5.X 连接的示例 # url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT # MySQL Connector/J 5.X 连接的示例
# url: jdbc:postgresql://127.0.0.1:5432/${spring.datasource.dynamic.datasource.slave.name} # PostgreSQL 连接的示例 # url: jdbc:postgresql://127.0.0.1:5432/${spring.datasource.dynamic.datasource.slave.name} # PostgreSQL 连接的示例
# url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
# url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.slave.name} # SQLServer 连接的示例 # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.slave.name} # SQLServer 连接的示例
username: root username: root
password: 123456 password: 1qaz!QAZ
# username: sa # username: sa
# password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W
# Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优
redis: redis:
host: 127.0.0.1 # 地址 host: 10.211.55.5 # 地址
port: 6379 # 端口 port: 6379 # 端口
database: 0 # 数据库索引 database: 0 # 数据库索引
# password: dev # 密码,建议生产环境开启 # password: dev # 密码,建议生产环境开启