From 0db4581030328bfc34d1464e67a31153438d9686 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 21 Oct 2023 19:56:53 +0800 Subject: [PATCH] =?UTF-8?q?code=20review=EF=BC=9A=E7=AD=BE=E5=88=B0?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/admin/spu/ProductSpuController.java | 1 + .../controller/admin/banner/vo/BannerPageReqVO.java | 4 +--- .../controller/app/banner/AppBannerController.java | 6 ++++-- .../module/promotion/dal/dataobject/banner/BannerDO.java | 3 +-- .../member/convert/signin/MemberSignInRecordConvert.java | 9 +++++---- .../dal/mysql/signin/MemberSignInRecordMapper.java | 6 ++++-- .../service/signin/MemberSignInRecordServiceImpl.java | 4 +++- 7 files changed, 19 insertions(+), 14 deletions(-) diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java index f41138179..f9c60a62b 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java @@ -93,6 +93,7 @@ public class ProductSpuController { // 查询商品 SKU List skus = productSkuService.getSkuListBySpuId(spu.getId()); // 查询优惠卷 + // TODO @puhui999:优惠劵的信息,要不交给前端读取?主要是为了避免商品依赖 promotion 模块哈; List couponTemplateList = couponTemplateApi.getCouponTemplateListByIds( spu.getGiveCouponTemplateIds()); return success(ProductSpuConvert.INSTANCE.convertForSpuDetailRespVO(spu, skus, couponTemplateList)); diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerPageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerPageReqVO.java index 4aafb9f46..d4efa0df1 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerPageReqVO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/vo/BannerPageReqVO.java @@ -13,15 +13,13 @@ import java.time.LocalDateTime; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; -/** - * @author xia - */ @Schema(description = "管理后台 - Banner 分页 Request VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) public class BannerPageReqVO extends PageParam { + // TODO @puhui999:example @Schema(description = "标题") private String title; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/banner/AppBannerController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/banner/AppBannerController.java index 4947e113c..bf6396f31 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/banner/AppBannerController.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/banner/AppBannerController.java @@ -26,8 +26,7 @@ import static cn.iocoder.yudao.framework.common.util.cache.CacheUtils.buildAsync @Validated public class AppBannerController { - @Resource - private BannerService bannerService; + // TODO @puhui999:这个目前不缓存,也没问题,因为首页没用到。 /** * {@link AppBannerRespVO} 缓存,通过它异步刷新 {@link #getBannerList0(Integer)} 所要的首页数据 */ @@ -41,6 +40,9 @@ public class AppBannerController { }); + @Resource + private BannerService bannerService; + @GetMapping("/list") @Operation(summary = "获得 banner 列表") @Parameter(name = "position", description = "Banner position", example = "1") diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/banner/BannerDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/banner/BannerDO.java index 0a2065e77..6906e81d1 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/banner/BannerDO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/banner/BannerDO.java @@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.promotion.enums.banner.BannerPositionEnum; import com.baomidou.mybatisplus.annotation.TableName; import lombok.*; +// TODO @puhui999:表名改成 promotion_banner,然后有序加下;另外,sql 给我下哈;还有那个 position 字典,嘿嘿。 /** * banner DO * @@ -61,6 +62,4 @@ public class BannerDO extends BaseDO { */ private Integer browseCount; - // TODO 芋艿 其他数据相关 - } 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 6ad9794d8..0526ed64a 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 @@ -48,19 +48,20 @@ public interface MemberSignInRecordConvert { // 1. 计算今天是第几天签到 long day = ChronoUnit.DAYS.between(firstRecord.getCreateTime(), LocalDateTime.now()); // 2. 初始化签到信息 + // TODO @puhui999:signInRecord=》record MemberSignInRecordDO signInRecord = new MemberSignInRecordDO().setUserId(userId) - .setDay(Integer.parseInt(Long.toString(day))) // 设置签到天数 - .setPoint(0) // 设置签到积分默认为 0 + .setDay(Integer.parseInt(Long.toString(day))) // 设置签到天数 TODO @puhui999:day 应该跟着第几天签到走;不是累加哈;另外 long 转 int,应该 (int) day 就可以了。。。 + .setPoint(0) // 设置签到积分默认为 .setExperience(0); // 设置签到经验默认为 0 - - // 3. 获取签到对应的积分数 MemberSignInConfigDO lastConfig = signInConfigs.get(signInConfigs.size() - 1); // 最大签到天数 if (day > lastConfig.getDay()) { // 超出范围按第一天的经验计算 + // TODO @puhui999:不能直接取 0,万一它 day 不匹配哈。就是第一天没奖励。。。 signInRecord.setPoint(signInConfigs.get(0).getPoint()); signInRecord.setExperience(signInConfigs.get(0).getExperience()); return signInRecord; } + // TODO @puhui999:signInConfig 可以改成 config; MemberSignInConfigDO signInConfig = CollUtil.findOne(signInConfigs, config -> ObjUtil.equal(config.getDay(), day)); if (signInConfig == null) { return signInRecord; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/signin/MemberSignInRecordMapper.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/signin/MemberSignInRecordMapper.java index fcd4ae408..01fe75c14 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/signin/MemberSignInRecordMapper.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/signin/MemberSignInRecordMapper.java @@ -35,9 +35,9 @@ public interface MemberSignInRecordMapper extends BaseMapperX() .eq(MemberSignInRecordDO::getUserId, userId)); } @@ -73,6 +74,7 @@ public interface MemberSignInRecordMapper extends BaseMapperX selectListByUserId(Long userId) { return selectList(new LambdaQueryWrapperX() .eq(MemberSignInRecordDO::getUserId, userId) 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 586e60ac4..be9b420e9 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 @@ -58,6 +58,7 @@ public class MemberSignInRecordServiceImpl implements MemberSignInRecordService @Override public AppMemberSignInRecordSummaryRespVO getSignInRecordSummary(Long userId) { // 1. 初始化默认返回信息 + // TODO @puhui999:这里 vo 改成 summary 会更好理解; AppMemberSignInRecordSummaryRespVO vo = new AppMemberSignInRecordSummaryRespVO(); vo.setTotalDay(0); vo.setContinuousDay(0); @@ -71,6 +72,7 @@ public class MemberSignInRecordServiceImpl implements MemberSignInRecordService vo.setTotalDay(signCount.intValue()); // 设置总签到天数 // 3. 校验当天是否有签到 + // TODO @puhui999:是不是 signInRecord 可以精简成 record 哈;另外,Desc 貌似可以去掉哈;最后一条了; MemberSignInRecordDO signInRecord = signInRecordMapper.selectLastRecordByUserIdDesc(userId); if (signInRecord == null) { return vo; @@ -82,6 +84,7 @@ public class MemberSignInRecordServiceImpl implements MemberSignInRecordService return vo; } // 4.1. 判断连续签到天数 + // TODO @puhui999:连续签到,可以基于 signInRecord 的 day 和当前时间判断呀? List signInRecords = signInRecordMapper.selectListByUserId(userId); vo.setContinuousDay(calculateConsecutiveDays(signInRecords)); return vo; @@ -164,7 +167,6 @@ public class MemberSignInRecordServiceImpl implements MemberSignInRecordService if (!ObjectUtils.equalsAny(record.getExperience(), null, 0)) { memberLevelService.addExperience(userId, record.getExperience(), MemberExperienceBizTypeEnum.SIGN_IN, String.valueOf(record.getId())); } - return record; }