From 33323c1483604330b17b1767e774fd39d1c005fc Mon Sep 17 00:00:00 2001 From: xiaqing Date: Wed, 9 Aug 2023 16:13:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=9A=E5=91=98=E7=AD=BE=E5=88=B0=E9=92=88?= =?UTF-8?q?=E5=AF=B9=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F=E3=80=81=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E4=BC=98=E5=8C=96=201.=E4=BC=98=E5=8C=96todo=E5=BB=BA?= =?UTF-8?q?=E8=AE=AE=202.=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../signin/MemberSignInConfigController.java | 11 ++-- .../signin/MemberSignInRecordController.java | 39 ++++++------ .../signin/vo/MemberSignInConfigBaseVO.java | 4 ++ .../vo/MemberSignInConfigPageReqVO.java | 16 ----- .../signin/vo/MemberSignInRecordBaseVO.java | 2 +- .../vo/MemberSignInRecordPageReqVO.java | 2 +- .../signin/vo/MemberSignInRecordRespVO.java | 3 + .../signin/MemberSignInRecordConvert.java | 63 +++++++++++++++++-- .../signin/MemberSignInConfigDO.java | 5 +- .../signin/MemberSignInRecordDO.java | 2 +- .../signin/MemberSignInConfigMapper.java | 40 ++++++++---- .../signin/MemberSignInConfigService.java | 6 +- .../signin/MemberSignInConfigServiceImpl.java | 33 +++++----- .../signin/MemberSignInRecordService.java | 14 +---- .../signin/MemberSignInRecordServiceImpl.java | 20 +----- .../src/main/resources/application-local.yaml | 14 ++--- 16 files changed, 152 insertions(+), 122 deletions(-) delete mode 100644 yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/MemberSignInConfigPageReqVO.java diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/MemberSignInConfigController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/MemberSignInConfigController.java index ea208b6c6..361e69506 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/MemberSignInConfigController.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/MemberSignInConfigController.java @@ -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.PageResult; 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.MemberSignInConfigUpdateReqVO; 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.validation.Valid; +import java.util.List; + import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; @Tag(name = "管理后台 - 积分签到规则") @@ -63,12 +64,12 @@ public class MemberSignInConfigController { return success(MemberSignInConfigConvert.INSTANCE.convert(signInConfig)); } - @GetMapping("/page") + @GetMapping("/list") @Operation(summary = "获得积分签到规则分页") @PreAuthorize("@ss.hasPermission('point:sign-in-config:query')") - public CommonResult> getSignInConfigPage(@Valid MemberSignInConfigPageReqVO pageVO) { - PageResult pageResult = memberSignInConfigService.getSignInConfigPage(pageVO); - return success(MemberSignInConfigConvert.INSTANCE.convertPage(pageResult)); + public CommonResult> getSignInConfigPage() { + List pageResult = memberSignInConfigService.getSignInConfigList(); + return success(MemberSignInConfigConvert.INSTANCE.convertList(pageResult)); } } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/MemberSignInRecordController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/MemberSignInRecordController.java index fae6ebdab..d8abba748 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/MemberSignInRecordController.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/MemberSignInRecordController.java @@ -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.dal.dataobject.signin.MemberSignInRecordDO; 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.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.util.CollectionUtils; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.validation.Valid; +import java.util.List; +import java.util.stream.Collectors; + import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; @Tag(name = "管理后台 - 用户签到积分") @@ -27,31 +33,22 @@ public class MemberSignInRecordController { @Resource 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 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 getSignInRecord(@RequestParam("id") Long id) { - MemberSignInRecordDO signInRecord = memberSignInRecordService.getSignInRecord(id); - return success(MemberSignInRecordConvert.INSTANCE.convert(signInRecord)); - } @GetMapping("/page") @Operation(summary = "获得用户签到积分分页") @PreAuthorize("@ss.hasPermission('point:sign-in-record:query')") - public CommonResult> getSignInRecordPage(@Valid MemberSignInRecordPageReqVO pageVO) { - PageResult pageResult = memberSignInRecordService.getSignInRecordPage(pageVO); - return success(MemberSignInRecordConvert.INSTANCE.convertPage(pageResult)); + public CommonResult > getSignInRecordPage(@Valid MemberSignInRecordPageReqVO pageVO) { + PageResult pageResult = memberSignInRecordService.getSignInRecordPage(pageVO); + List result = pageResult.getList(); + //设置获取的用户信息 + List users = null; + if (!CollectionUtils.isEmpty(result)) { + List ids = result.stream().map(user -> user.getUserId()).collect(Collectors.toList()); + users = adminUserApi.getUserList(ids); + } + return success(MemberSignInRecordConvert.INSTANCE.convertPage(pageResult, users)); } } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/MemberSignInConfigBaseVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/MemberSignInConfigBaseVO.java index 334d98ad2..7aa098eed 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/MemberSignInConfigBaseVO.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/MemberSignInConfigBaseVO.java @@ -16,4 +16,8 @@ public class MemberSignInConfigBaseVO { @Schema(description = "签到天数对应分数", example = "10") private Integer point; + @Schema(description = "是否启用", example = "1") + private Boolean isEnable; + + } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/MemberSignInConfigPageReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/MemberSignInConfigPageReqVO.java deleted file mode 100644 index 7ffd3827a..000000000 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/MemberSignInConfigPageReqVO.java +++ /dev/null @@ -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; - -} diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/MemberSignInRecordBaseVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/MemberSignInRecordBaseVO.java index f593d0d35..c3c51f5ba 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/MemberSignInRecordBaseVO.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/MemberSignInRecordBaseVO.java @@ -11,7 +11,7 @@ import lombok.Data; public class MemberSignInRecordBaseVO { @Schema(description = "签到用户", example = "6507") - private Integer userId; + private Long userId; @Schema(description = "第几天签到") private Integer day; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/MemberSignInRecordPageReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/MemberSignInRecordPageReqVO.java index d3808a831..eace459f9 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/MemberSignInRecordPageReqVO.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/MemberSignInRecordPageReqVO.java @@ -18,7 +18,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ public class MemberSignInRecordPageReqVO extends PageParam { @Schema(description = "签到用户", example = "6507") - private Integer userId; + private Long userId; @Schema(description = "第几天签到") private Integer day; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/MemberSignInRecordRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/MemberSignInRecordRespVO.java index a5b784412..a01fa5a22 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/MemberSignInRecordRespVO.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/signin/vo/MemberSignInRecordRespVO.java @@ -19,4 +19,7 @@ public class MemberSignInRecordRespVO extends MemberSignInRecordBaseVO { @Schema(description = "签到时间") private LocalDateTime createTime; + //昵称,用于前台展示 + private String nickName; + } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/signin/MemberSignInRecordConvert.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/signin/MemberSignInRecordConvert.java index 0af4e6178..c8b0cba98 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/signin/MemberSignInRecordConvert.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/signin/MemberSignInRecordConvert.java @@ -1,12 +1,18 @@ package cn.iocoder.yudao.module.member.convert.signin; 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.MemberSignInRecordUpdateReqVO; 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.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 @@ -18,12 +24,57 @@ public interface MemberSignInRecordConvert { 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 convertPage(PageResult page, List userRespDTOS) { + if (page == null) { + return null; + } + + PageResult pageResult = new PageResult (); + + pageResult.setList(memberSignInRecordDOListToMemberSignInRecordRespVOList(page.getList(),userRespDTOS)); + pageResult.setTotal(page.getTotal()); + + return pageResult; + } + + default List memberSignInRecordDOListToMemberSignInRecordRespVOList(List list,List userRespDTOS) { + if (list == null) { + return null; + } + Map maps=null; + //是否需要转换用户标志 + boolean userNickFlag = !CollectionUtils.isEmpty(userRespDTOS); + if(userNickFlag){ + maps = userRespDTOS.stream() + .collect(Collectors.toMap(AdminUserRespDTO::getId, AdminUserRespDTO::getNickname, (key1, key2) -> key2)); + } + List list1 = new ArrayList (list.size()); + for (MemberSignInRecordDO memberSignInRecordDO : list) { + MemberSignInRecordRespVO recordRespVO = convert(memberSignInRecordDO); + if(userNickFlag){ + recordRespVO.setNickName(maps.get(recordRespVO.getUserId())); + } + list1.add(recordRespVO); + } + + return list1; + } - PageResult convertPage(PageResult page); } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/signin/MemberSignInConfigDO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/signin/MemberSignInConfigDO.java index 1c7bcd853..42142e3f3 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/signin/MemberSignInConfigDO.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/signin/MemberSignInConfigDO.java @@ -34,5 +34,8 @@ public class MemberSignInConfigDO extends BaseDO { * 签到天数对应分数 */ private Integer point; - + /** + * 是否启用 + */ + private Boolean isEnable; } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/signin/MemberSignInRecordDO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/signin/MemberSignInRecordDO.java index 8cf89cc43..a95940327 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/signin/MemberSignInRecordDO.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/signin/MemberSignInRecordDO.java @@ -29,7 +29,7 @@ public class MemberSignInRecordDO extends BaseDO { /** * 签到用户 */ - private Integer userId; + private Long userId; /** * 第几天签到 */ diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/signin/MemberSignInConfigMapper.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/signin/MemberSignInConfigMapper.java index 6f14d0d5d..7c8f5974f 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/signin/MemberSignInConfigMapper.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/signin/MemberSignInConfigMapper.java @@ -1,13 +1,13 @@ 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.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 com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + /** * 积分签到规则 Mapper * @@ -16,18 +16,32 @@ import org.apache.ibatis.annotations.Mapper; @Mapper public interface MemberSignInConfigMapper extends BaseMapperX { - default PageResult selectPage(MemberSignInConfigPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(MemberSignInConfigDO::getDay, reqVO.getDay()) - .orderByAsc(MemberSignInConfigDO::getDay)); + /** + * 描述 :选择性更新对象属性,如果不为空则更新。 + * Author :xiaqing + * Date :2023-08-08 23:38:48 + */ + default int updateIfPresent(MemberSignInConfigDO updateObj){ + LambdaUpdateWrapper 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 long selectSameDayNotSelf(MemberSignInConfigUpdateReqVO reqVO){ - return selectCount(new LambdaQueryWrapperX () - .ne(MemberSignInConfigDO::getId, reqVO.getId()) - .eq(MemberSignInConfigDO::getDay,reqVO.getDay()) - ); + default List getList(){ + return selectList(new LambdaQueryWrapperX ().orderByAsc(MemberSignInConfigDO::getDay)); + } + + /** + * 描述 :根据天数查询对应记录 + * Date :2023-08-09 00:07:11 + */ + default MemberSignInConfigDO selectByDay(Integer day){ + return selectOne(new LambdaQueryWrapperX () + .eq(MemberSignInConfigDO::getDay,day)); + } } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/signin/MemberSignInConfigService.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/signin/MemberSignInConfigService.java index f58870507..f873e52c7 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/signin/MemberSignInConfigService.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/signin/MemberSignInConfigService.java @@ -1,12 +1,11 @@ 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.MemberSignInConfigPageReqVO; import cn.iocoder.yudao.module.member.controller.admin.signin.vo.MemberSignInConfigUpdateReqVO; import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInConfigDO; import javax.validation.Valid; +import java.util.List; /** * 积分签到规则 Service 接口 @@ -48,9 +47,8 @@ public interface MemberSignInConfigService { /** * 获得积分签到规则分页 * - * @param pageReqVO 分页查询 * @return 积分签到规则分页 */ - PageResult getSignInConfigPage(MemberSignInConfigPageReqVO pageReqVO); + List getSignInConfigList(); } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/signin/MemberSignInConfigServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/signin/MemberSignInConfigServiceImpl.java index a1cc2e321..68085ff16 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/signin/MemberSignInConfigServiceImpl.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/signin/MemberSignInConfigServiceImpl.java @@ -1,17 +1,20 @@ 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.MemberSignInConfigPageReqVO; 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.dal.dataobject.signin.MemberSignInConfigDO; 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.validation.annotation.Validated; import javax.annotation.Resource; +import java.util.List; + 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_NOT_EXISTS; @@ -28,30 +31,28 @@ public class MemberSignInConfigServiceImpl implements MemberSignInConfigService @Resource private MemberSignInConfigMapper memberSignInConfigMapper; - // TODO @xiaqing:这种写的逻辑,最好按照 校验 - 更新这样的顺序写;类似这里,37 要放到 34 前面;updateSignInConfig 也是一样的思路 @Override public Integer createSignInConfig(MemberSignInConfigCreateReqVO createReqVO) { + // 判断是否重复插入签到天数 + validateSignInConfigExistsDay(createReqVO.getDay()); + // 插入 MemberSignInConfigDO signInConfig = MemberSignInConfigConvert.INSTANCE.convert(createReqVO); - // 判断是否重复插入签到天数 - validateSignInConfigExistsDay(signInConfig.getDay()); memberSignInConfigMapper.insert(signInConfig); // 返回 return signInConfig.getId(); } - // TODO @xiaqing:这个逻辑的空行要注意;52 到 53 是没必要的空行;而 49 和 50 之间有个空行会好点,可以区分出是 校验 - 更新这样的逻辑间隔 @Override public void updateSignInConfig(MemberSignInConfigUpdateReqVO updateReqVO) { // 校验存在 validateSignInConfigExists(updateReqVO.getId()); //判断是否重复插入签到天数 validateSignInConfigSameDayNotSelf(updateReqVO); - // 判断更新的 + + // 判断更新 MemberSignInConfigDO updateObj = MemberSignInConfigConvert.INSTANCE.convert(updateReqVO); - - - memberSignInConfigMapper.updateById(updateObj); + memberSignInConfigMapper.updateIfPresent(updateObj); } @Override @@ -68,18 +69,18 @@ public class MemberSignInConfigServiceImpl implements MemberSignInConfigService } } - // TODO @xiaqing:这个唯一判断,也可以参考下别的模块哈; //根据签到天数判断是否存在一个相同的天数 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); } } - // TODO @xiaqing:参考下别的模块,判断唯一,排除自己怎么写的哈; // 更新天数时判断是否有重复的天数,需要去除自己 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); } } @@ -90,8 +91,8 @@ public class MemberSignInConfigServiceImpl implements MemberSignInConfigService } @Override - public PageResult getSignInConfigPage(MemberSignInConfigPageReqVO pageReqVO) { - return memberSignInConfigMapper.selectPage(pageReqVO); + public List getSignInConfigList() { + return memberSignInConfigMapper.getList(); } } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/signin/MemberSignInRecordService.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/signin/MemberSignInRecordService.java index 0faf2c1a9..8f7d2a064 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/signin/MemberSignInRecordService.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/signin/MemberSignInRecordService.java @@ -11,20 +11,7 @@ import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO */ public interface MemberSignInRecordService { - /** - * 删除用户签到积分 - * - * @param id 编号 - */ - void deleteSignInRecord(Long id); - /** - * 获得用户签到积分 - * - * @param id 编号 - * @return 用户签到积分 - */ - MemberSignInRecordDO getSignInRecord(Long id); /** * 获得用户签到积分分页 @@ -34,4 +21,5 @@ public interface MemberSignInRecordService { */ PageResult getSignInRecordPage(MemberSignInRecordPageReqVO pageReqVO); + } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/signin/MemberSignInRecordServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/signin/MemberSignInRecordServiceImpl.java index 23698b5e8..4bc9bf8ea 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/signin/MemberSignInRecordServiceImpl.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/signin/MemberSignInRecordServiceImpl.java @@ -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.dal.dataobject.signin.MemberSignInRecordDO; 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.validation.annotation.Validated; @@ -23,25 +24,10 @@ public class MemberSignInRecordServiceImpl implements MemberSignInRecordService @Resource 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 public PageResult getSignInRecordPage(MemberSignInRecordPageReqVO pageReqVO) { diff --git a/yudao-server/src/main/resources/application-local.yaml b/yudao-server/src/main/resources/application-local.yaml index 4cddf8065..cd0111992 100644 --- a/yudao-server/src/main/resources/application-local.yaml +++ b/yudao-server/src/main/resources/application-local.yaml @@ -44,31 +44,31 @@ spring: primary: master datasource: master: - name: ruoyi-vue-pro - 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 连接的示例 + name: mall + 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: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:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.master.name} # SQLServer 连接的示例 username: root - password: 123456 + password: 1qaz!QAZ # username: sa # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W slave: # 模拟从库,可根据自己需要修改 - name: ruoyi-vue-pro - 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 连接的示例 + name: mall + 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: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:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.slave.name} # SQLServer 连接的示例 username: root - password: 123456 + password: 1qaz!QAZ # username: sa # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 redis: - host: 127.0.0.1 # 地址 + host: 10.211.55.5 # 地址 port: 6379 # 端口 database: 0 # 数据库索引 # password: dev # 密码,建议生产环境开启