فهرست منبع

【代码评审】SYSTEM:订阅消息

YunaiV 7 ماه پیش
والد
کامیت
345f41b153

+ 1 - 0
yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/MessageTemplateConstants.java

@@ -11,6 +11,7 @@ public interface MessageTemplateConstants {
 
     String PAY_WALLET_CHANGE = "充值成功通知";
 
+    // TODO @puhui999:这种建议不枚举,直接写~嘿嘿。
     /**
      * 充值成功通知模版参数
      *

+ 1 - 0
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/message/subscribe/SubscribeMessageClient.java

@@ -11,6 +11,7 @@ import java.util.Map;
 
 import static cn.iocoder.yudao.module.pay.enums.MessageTemplateConstants.PAY_WALLET_CHANGE;
 
+// TODO @puhui999:建议可以先直接调用,不要新建一个 client。
 /**
  * 订阅消息
  *

+ 2 - 0
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeServiceImpl.java

@@ -139,8 +139,10 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService {
         sendPayWalletChangeMessage(payOrderId, walletRecharge);
     }
 
+    // TODO @puhui999:发送,使用异步发送;@Async
     private void sendPayWalletChangeMessage(Long payOrderId, PayWalletRechargeDO walletRecharge) {
         PayWalletDO wallet = payWalletService.getWallet(walletRecharge.getWalletId());
+        // TODO @puhui999:可以使用 MapUtil.builder();另外,不应该是并发 hashmap 哈
         Map<String, String> messages = MapUtil.newConcurrentHashMap(4);
         messages.put(MessageTemplateConstants.PayWalletChangeTemplateParams.NO, String.valueOf(payOrderId));
         messages.put(MessageTemplateConstants.PayWalletChangeTemplateParams.PRICE,

+ 1 - 0
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApi.java

@@ -57,6 +57,7 @@ public interface SocialClientApi {
      */
     List<SocialWxSubscribeTemplateRespDTO> getSubscribeTemplateList(Integer userType);
 
+    // TODO @puhui999:sendSubscribeMessage 两个方法,可以融合成一个么?
     /**
      * 发送微信小程序订阅消息
      *

+ 3 - 0
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialClientApiImpl.java

@@ -75,6 +75,7 @@ public class SocialClientApiImpl implements SocialClientApi {
 
     public void sendSubscribeMessage(String templateTitle, Map<String, String> messages, Integer userType, Long userId,
                             Integer socialType, String path) {
+        // TODO @puhui999:建议是,先不拆小方法。因为逻辑的复杂度其实不高哈。合在一个方法里,因为咱写了 1.1 1.2 2. 这样的逻辑,也能一下子看懂。
         // 1.1 获得订阅模版
         SocialWxSubscribeTemplateRespDTO template = getTemplate(templateTitle, userType);
         if (template == null) {
@@ -104,6 +105,7 @@ public class SocialClientApiImpl implements SocialClientApi {
                 .setTemplateId(template.getId()).setToUser(openId).setPage(path);
     }
 
+    // TODO @puhui999:建议下沉到 service 实现。
     /**
      * 获得小程序订阅消息模版
      *
@@ -120,6 +122,7 @@ public class SocialClientApiImpl implements SocialClientApi {
         return CollectionUtil.findOne(templateList, item -> ObjUtil.equal(item.getTitle(), templateTitle));
     }
 
+    // TODO @puhui999:建议下沉到 service 实现。
     /**
      * 获得用户 openId
      *