Bladeren bron

Merge branch 'wip/customer/common-inform' into 84-integrate

linwenhua 2 jaren geleden
bovenliggende
commit
9636ed8620
37 gewijzigde bestanden met toevoegingen van 246 en 1486 verwijderingen
  1. 0 34
      smsb-customer-manager-adapter/src/main/java/com/inspur/customer/web/controller/InformTestController.java
  2. 6 5
      smsb-customer-manager-adapter/src/main/java/com/inspur/customer/web/controller/authcode/AuthCodeController.java
  3. 44 47
      smsb-customer-manager-app/src/main/java/com/inspur/customer/service/authcode/AuthCodeServiceImpl.java
  4. 0 300
      smsb-customer-manager-app/src/main/java/com/inspur/customer/service/inform/CommonInformServiceImpl.java
  5. 0 37
      smsb-customer-manager-app/src/main/java/com/inspur/customer/service/inform/InformMessageContentRecordServiceImpl.java
  6. 0 114
      smsb-customer-manager-app/src/main/java/com/inspur/customer/service/inform/InformMessageRecordServiceImpl.java
  7. 0 21
      smsb-customer-manager-app/src/main/java/com/inspur/customer/service/inform/handler/AbstractMessageHandler.java
  8. 0 45
      smsb-customer-manager-app/src/main/java/com/inspur/customer/service/inform/handler/EmailMessageHandler.java
  9. 0 25
      smsb-customer-manager-app/src/main/java/com/inspur/customer/service/inform/handler/NoteMessageHandler.java
  10. 0 45
      smsb-customer-manager-app/src/main/java/com/inspur/customer/service/inform/handler/WeChatAppletMessageHandler.java
  11. 0 49
      smsb-customer-manager-app/src/main/java/com/inspur/customer/service/inform/handler/WeChatMessageHandler.java
  12. 0 64
      smsb-customer-manager-app/src/main/java/com/inspur/customer/service/inform/object/InformResult.java
  13. 0 3
      smsb-customer-manager-app/src/main/java/com/inspur/customer/service/tenant/TenantExceptionInformStrategyServiceImpl.java
  14. 84 0
      smsb-customer-manager-app/src/main/java/com/inspur/customer/service/tenant/UserInformServiceImpl.java
  15. 0 47
      smsb-customer-manager-client/src/main/java/com/inspur/customer/client/inform/CommonInformService.java
  16. 0 20
      smsb-customer-manager-client/src/main/java/com/inspur/customer/client/inform/InformMessageContentRecordService.java
  17. 0 33
      smsb-customer-manager-client/src/main/java/com/inspur/customer/client/inform/InformMessageRecordService.java
  18. 22 0
      smsb-customer-manager-client/src/main/java/com/inspur/customer/client/tenant/UserInformService.java
  19. 4 0
      smsb-customer-manager-client/src/main/java/com/inspur/customer/context/inform/InformLevelEnum.java
  20. 0 60
      smsb-customer-manager-client/src/main/java/com/inspur/customer/object/inform/CommonInformCO.java
  21. 0 21
      smsb-customer-manager-client/src/main/java/com/inspur/customer/object/inform/CommonMessageCO.java
  22. 0 40
      smsb-customer-manager-client/src/main/java/com/inspur/customer/object/inform/CustomerBaseException.java
  23. 0 71
      smsb-customer-manager-client/src/main/java/com/inspur/customer/object/inform/InformAddressees.java
  24. 0 44
      smsb-customer-manager-client/src/main/java/com/inspur/customer/object/inform/InformMessageContentRecordDto.java
  25. 0 56
      smsb-customer-manager-client/src/main/java/com/inspur/customer/object/inform/InformMessageRecordDto.java
  26. 0 59
      smsb-customer-manager-client/src/main/java/com/inspur/customer/object/inform/InformStrategy.java
  27. 5 1
      smsb-customer-manager-client/src/main/java/com/inspur/customer/object/tenant/ExceptionInformStrategyCmd.java
  28. 64 0
      smsb-customer-manager-client/src/main/java/com/inspur/customer/object/tenant/InformAddresseeCO.java
  29. 12 0
      smsb-customer-manager-client/src/main/java/com/inspur/customer/object/tenant/TenantExceptionInformStrategyCO.java
  30. 5 0
      smsb-customer-manager-client/src/main/java/com/inspur/customer/object/user/authcode/AuthCodeDTO.java
  31. 0 14
      smsb-customer-manager-infrastructure/src/main/java/com/inspur/customer/infrastructure/mapper/inform/InformMessageContentRecordMapper.java
  32. 0 13
      smsb-customer-manager-infrastructure/src/main/java/com/inspur/customer/infrastructure/mapper/inform/InformMessageRecordMapper.java
  33. 0 48
      smsb-customer-manager-infrastructure/src/main/java/com/inspur/customer/infrastructure/object/inform/InformMessageContentRecordDO.java
  34. 0 81
      smsb-customer-manager-infrastructure/src/main/java/com/inspur/customer/infrastructure/object/inform/InformMessageRecordDO.java
  35. 0 5
      smsb-customer-manager-infrastructure/src/main/resources/mapper/inform/InformMessageContentRecordMapper.xml
  36. 0 5
      smsb-customer-manager-infrastructure/src/main/resources/mapper/inform/InformMessageRecordMapper.xml
  37. 0 79
      smsb-customer-manager-start-web/src/test/java/com/inspur/customer/MessageHandlerTest.java

+ 0 - 34
smsb-customer-manager-adapter/src/main/java/com/inspur/customer/web/controller/InformTestController.java

@@ -1,34 +0,0 @@
-package com.inspur.customer.web.controller;
-
-import com.inspur.customer.client.inform.CommonInformService;
-import com.inspur.customer.context.inform.InformTypeEnum;
-import com.inspur.customer.object.inform.CommonInformCO;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.dubbo.config.annotation.DubboReference;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * @author linwenhua
- * @date 2022-07-04 14:37
- **/
-@Slf4j
-@RestController
-public class InformTestController {
-
-    @DubboReference
-    private CommonInformService commonInformService;
-
-    @PostMapping("inform/test")
-    public void testInform(@RequestBody CommonInformCO commonInformCO) {
-        commonInformCO.setTypeEnum(InformTypeEnum.AI_MEDIA_WARN);
-        commonInformService.commonInform(commonInformCO);
-    }
-
-    @PostMapping("inform/tenant")
-    public void testTenant(@RequestBody CommonInformCO commonInformCO) {
-        commonInformCO.setTypeEnum(InformTypeEnum.AI_AUDIT_CREDIT_INSUFFICIENT_WARN);
-        commonInformService.tenantLevelInform(commonInformCO);
-    }
-}

+ 6 - 5
smsb-customer-manager-adapter/src/main/java/com/inspur/customer/web/controller/authcode/AuthCodeController.java

@@ -16,7 +16,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 
-/**@Description: 验证码相关接口
+/**
+ * 验证码相关接口
  * @version v1.0
  * @author joe wan
  * @date 2022/6/29 14:14
@@ -29,10 +30,10 @@ public class AuthCodeController {
     @DubboReference
     private AuthCodeService authCodeService;
 
-    /**@Description: 电话、邮件发送验证码
+    /**
+     * 电话、邮件发送验证码
      * @param[com.inspur.customer.service.dto.AuthCodeDTO]
      * @return com.alibaba.cola.dto.Response
-     * @version v1.0
      * @author joe wan
      * @date 2022/6/29 17:19
      */
@@ -44,8 +45,8 @@ public class AuthCodeController {
         return authCodeService.sendAuthCode(authCodeDTO);
     }
 
-    /**@Description: 电话、邮件验证码check
-     * @param[com.inspur.customer.service.dto.AuthCodeDTO]
+    /**
+     * 电话、邮件验证码check
      * @return com.alibaba.cola.dto.SingleResponse<com.inspur.customer.service.dto.AuthCodeResponseDTO>
      * @version v1.0
      * @author joe wan

+ 44 - 47
smsb-customer-manager-app/src/main/java/com/inspur/customer/service/authcode/AuthCodeServiceImpl.java

@@ -1,17 +1,14 @@
 package com.inspur.customer.service.authcode;
 
 import com.alibaba.cola.dto.Response;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
 import com.inspur.customer.client.authcode.AuthCodeService;
 import com.inspur.customer.object.user.authcode.AuthCodeCheckDTO;
 import com.inspur.customer.object.user.authcode.AuthCodeCheckResponse;
 import com.inspur.customer.object.user.authcode.AuthCodeDTO;
-import com.inspur.inform.client.email.SmsbEmailService;
-import com.inspur.inform.client.sms.SmsbSmsService;
-import com.inspur.inform.object.message.EmailMessage;
-import com.inspur.inform.object.message.SmsMessage;
-import com.inspur.inform.constants.SmsbSmsTemplateType;
+import com.inspur.inform.client.CommonInformService;
+import com.inspur.inform.object.message.AbstractBaseInformMessage;
+import com.inspur.inform.object.message.EmailInformMessage;
+import com.inspur.inform.object.message.SmsInformMessage;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.dubbo.config.annotation.DubboReference;
@@ -19,6 +16,8 @@ import org.apache.dubbo.config.annotation.DubboService;
 import org.springframework.data.redis.core.RedisTemplate;
 
 import javax.annotation.Resource;
+import java.util.Collections;
+import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
@@ -33,19 +32,18 @@ import java.util.concurrent.TimeUnit;
 @DubboService(interfaceClass = AuthCodeService.class)
 public class AuthCodeServiceImpl implements AuthCodeService {
 
-    @DubboReference
-    SmsbSmsService smsbSmsService;
+    private static final String AUTH_CODE_MESSAGE_TEMPLATE = "auth_code";
 
-    @DubboReference
-    SmsbEmailService smsbEmailService;
+    private static final String AUTH_CODE_CACHE_KEY = "msr:authCode:";
 
+    @DubboReference
+    private CommonInformService commonInformService;
     @Resource
     private RedisTemplate<String, String> redisTemplate;
 
-    /**@Description: 电话、邮件发送验证码
-     * @param[com.inspur.customer.service.dto.AuthCodeDTO]
+    /**
+     * 电话、邮件发送验证码
      * @return com.alibaba.cola.dto.Response
-     * @version v1.0
      * @author joe wan
      * @date 2022/6/29 17:20
      */
@@ -54,43 +52,42 @@ public class AuthCodeServiceImpl implements AuthCodeService {
         try{
 
             //生成一个6位验证码
-            int authcode = (int)((Math.random() * 9 + 1) * 100000);
-            //发送邮件
-            if(StringUtils.isNotBlank(authCodeDTO.getEmail())){
-                EmailMessage emailMessage = new EmailMessage();
-                emailMessage.setSubject("浪潮安播云");
-                emailMessage.setEmailContent("【浪潮安播云】您的验证码"+ authcode +",该验证码5分钟内有效,请勿泄漏于他人!");
-                emailMessage.setAddressees(Lists.newArrayList(authCodeDTO.getEmail()));
-                Boolean aBoolean = smsbEmailService.sendEmail(emailMessage);
-                if(aBoolean) {
-                    redisTemplate.opsForValue().set("smsb:authcode:email:" + authCodeDTO.getEmail(), authcode + "", 5, TimeUnit.MINUTES);
-                }
-            }
-            //发送手机短信
-            if(StringUtils.isNotBlank(authCodeDTO.getPhoneNum())){
-                SmsMessage smsMessage = new SmsMessage();
-                Map<String, String> maps = Maps.newHashMap();
-                maps.put("MSRcode",""+authcode);
-                smsMessage.setTemplateParam(maps);
-                smsMessage.setPhones(Lists.newArrayList(authCodeDTO.getPhoneNum()));
-                smsMessage.setSignName("浪潮安播云");
-                smsMessage.setTemplateType(SmsbSmsTemplateType.AUTH_CODE);
-                Response sendResponse = smsbSmsService.sendWarningMessage(smsMessage);
-                if (sendResponse.isSuccess()) {
-                    redisTemplate.opsForValue().set("smsb:authcode:phoneNum:" + authCodeDTO.getPhoneNum(), authcode + "", 5, TimeUnit.MINUTES);
-                }
+            String authCode = String.valueOf(((Math.random() * 9 + 1) * 100000));
+            Boolean sendResult = commonInformService.sendMessage(AUTH_CODE_MESSAGE_TEMPLATE, getMessage(authCode, authCodeDTO));
+            if (Boolean.TRUE.equals(sendResult)) {
+                redisTemplate.opsForValue().set(AUTH_CODE_CACHE_KEY + authCodeDTO.getEmail(), authCode, 5, TimeUnit.MINUTES);
+                return Response.buildSuccess();
+            } else {
+                return Response.buildFailure("500", "send auth code fail");
             }
         } catch (Exception e){
-            log.error("发送验证码报错 --》 {}", authCodeDTO, e);
-            return Response.buildFailure("999","发送失败!");
+            log.error("auth code message: {}", authCodeDTO);
+            log.error("fail message: {}", e.getMessage(), e);
+            return Response.buildFailure("500","send auth code fail");
+        }
+    }
+
+    private AbstractBaseInformMessage getMessage(String authCode, AuthCodeDTO authCodeDTO) {
+        if (StringUtils.isNotBlank(authCodeDTO.getEmail())) {
+            EmailInformMessage emailInformMessage = new EmailInformMessage();
+            Map<String, String> params = new HashMap<>(1);
+            params.put("\\{MSR_AUTH_CODE}", String.valueOf(authCode));
+            emailInformMessage.setContentParams(params);
+            emailInformMessage.setAddressees(Collections.singletonList(authCodeDTO.getEmail()));
+            return emailInformMessage;
+        } else {
+            SmsInformMessage smsInformMessage = new SmsInformMessage();
+            Map<String, String> params = new HashMap<>(1);
+            params.put("MSRcode", String.valueOf(authCode));
+            smsInformMessage.setContentParams(params);
+            smsInformMessage.setAddressees(Collections.singletonList(authCodeDTO.getPhoneNum()));
+            return smsInformMessage;
         }
-        return Response.buildSuccess();
     }
 
-    /**@Description: 电话、邮件验证码check
-     * @param[com.inspur.customer.service.dto.AuthCodeCheckDTO]
+    /**
+     * 电话、邮件验证码check
      * @return com.inspur.customer.object.user.authcode.AuthCodeCheckResponse
-     * @version v1.0
      * @author joe wan
      * @date 2022/6/30 17:56
      */
@@ -99,13 +96,13 @@ public class AuthCodeServiceImpl implements AuthCodeService {
 
         AuthCodeCheckResponse result = new AuthCodeCheckResponse();
         if (StringUtils.isNotBlank(authCodeCheckDTO.getPhoneNumAuthCode())) {
-            String authcodePhone = redisTemplate.opsForValue().get("smsb:authcode:phoneNum:" + authCodeCheckDTO.getPhoneNum());
+            String authcodePhone = redisTemplate.opsForValue().get(AUTH_CODE_CACHE_KEY + authCodeCheckDTO.getPhoneNum());
             if (authCodeCheckDTO.getPhoneNumAuthCode().equals(authcodePhone)) {
                 result.setCheckPhoneNum(true);
             }
         }
         if (StringUtils.isNotBlank(authCodeCheckDTO.getEmailAuthCode())) {
-            String authcodeEmail = redisTemplate.opsForValue().get("smsb:authcode:email:" + authCodeCheckDTO.getEmail());
+            String authcodeEmail = redisTemplate.opsForValue().get(AUTH_CODE_CACHE_KEY + authCodeCheckDTO.getEmail());
             if (authCodeCheckDTO.getEmailAuthCode().equals(authcodeEmail)) {
                 result.setCheckEmail(true);
             }

+ 0 - 300
smsb-customer-manager-app/src/main/java/com/inspur/customer/service/inform/CommonInformServiceImpl.java

@@ -1,300 +0,0 @@
-package com.inspur.customer.service.inform;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.inspur.customer.client.inform.CommonInformService;
-import com.inspur.customer.client.inform.InformMessageRecordService;
-import com.inspur.customer.client.keycloak.KeycloakService;
-import com.inspur.customer.client.tenant.TenantExceptionInformStrategyService;
-import com.inspur.customer.context.inform.MessageTemplateEnum;
-import com.inspur.customer.object.inform.*;
-import com.inspur.customer.object.keycloak.KeycloakUserCO;
-import com.inspur.customer.object.tenant.ExceptionInformStrategyCmd;
-import com.inspur.customer.object.tenant.TenantExceptionInformStrategyCO;
-import com.inspur.customer.service.inform.handler.EmailMessageHandler;
-import com.inspur.customer.service.inform.handler.NoteMessageHandler;
-import com.inspur.customer.service.inform.handler.WeChatAppletMessageHandler;
-import com.inspur.customer.service.inform.handler.WeChatMessageHandler;
-import com.inspur.customer.service.inform.object.InformResult;
-import com.inspur.inform.client.email.SmsbEmailService;
-import com.inspur.inform.client.sms.SmsbSmsService;
-import com.inspur.inform.client.wechat.IWeChatService;
-import com.inspur.inform.client.wechat.applet.IWxAppletUserMessageService;
-import com.inspur.inform.object.applet.message.WxAppletUserMessageDto;
-import com.inspur.inform.object.message.EmailMessage;
-import com.inspur.inform.object.message.SmsMessage;
-import com.inspur.inform.object.message.WechatMessage;
-import com.inspur.logging.object.EventBaseException;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.dubbo.config.annotation.DubboReference;
-import org.apache.dubbo.config.annotation.DubboService;
-
-import javax.annotation.Resource;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CompletableFuture;
-
-/**
- * common inform service impl
- *
- * @author linwenhua
- * @date 2022-06-29 15:30
- **/
-@Slf4j
-@DubboService(interfaceClass = CommonInformService.class)
-public class CommonInformServiceImpl implements CommonInformService {
-
-    @Resource
-    private ObjectMapper objectMapper;
-
-    @Resource
-    private EmailMessageHandler emailMessageHandler;
-    @Resource
-    private NoteMessageHandler noteMessageHandler;
-    @Resource
-    private WeChatMessageHandler weChatMessageHandler;
-    @Resource
-    private WeChatAppletMessageHandler weChatAppletMessageHandler;
-
-    @DubboReference
-    private KeycloakService keycloakService;
-    @DubboReference
-    private TenantExceptionInformStrategyService tenantExceptionInformStrategyService;
-    @DubboReference
-    private InformMessageRecordService informMessageRecordService;
-
-    @DubboReference(timeout = 3000, async = true)
-    private SmsbEmailService smsbEmailService;
-    @DubboReference(timeout = 3000, async = true)
-    private SmsbSmsService smsbSmsService;
-    @DubboReference(timeout = 3000, async = true)
-    private IWeChatService weChatService;
-    @DubboReference(timeout = 3000, async = true)
-    private IWxAppletUserMessageService wxAppletUserMessageService;
-
-    @Override
-    public void commonInform(CommonInformCO informCo) {
-        // get base user
-        List<KeycloakUserCO> users = keycloakService.getUsersByIds(Collections.singletonList(informCo.getUserId()));
-        // get strategy
-        TenantExceptionInformStrategyCO informStrategyCo = tenantExceptionInformStrategyService.getTenantInformStrategyCache(informCo.getTenant());
-        ExceptionInformStrategyCmd informStrategyCmd = informStrategyCo.getStrategy().get(String.valueOf(informCo.getTypeEnum().getLevel().getId()));
-        switch (informCo.getTypeEnum().getLevel()) {
-            case HINT: {
-                log.info("hint");
-                break;
-            }
-            case INTERMEDIATE: {
-                log.info("intermediate");
-                //todo replace get user method
-                users.addAll(keycloakService.getUsersInRole("ROLE_SUPER_ADMIN"));
-                break;
-            }
-            case URGENT: {
-                log.info("urgent");
-                //todo replace get user method
-                users.addAll(keycloakService.getUsersInRole("ROLE_SUPER_ADMIN"));
-                break;
-            }
-            default: {
-                log.info("not support");
-                throw new EventBaseException("类型错误", 500);
-            }
-        }
-        // execute inform
-        executeInformUserCmd(informCo, informStrategyCmd, users);
-    }
-
-    @Override
-    public void tenantLevelInform(CommonInformCO informCo) {
-        log.info("tenant level: {}", informCo.getTenant());
-        // get user
-        List<KeycloakUserCO> users = keycloakService.getGroupSupervisor(informCo.getTenant());
-        // get strategy
-        TenantExceptionInformStrategyCO informStrategyCo = tenantExceptionInformStrategyService.getTenantInformStrategyCache(informCo.getTenant());
-        log.info("strategy: {}", informStrategyCo);
-        ExceptionInformStrategyCmd informStrategyCmd = informStrategyCo.getStrategy().get(String.valueOf(informCo.getTypeEnum().getLevel().getId()));
-        // execute inform
-        executeInformUserCmd(informCo, informStrategyCmd, users);
-    }
-
-    @Override
-    public void superAdminLevelInform(CommonInformCO informCo) {
-        List<KeycloakUserCO> users = keycloakService.getSuperAdmin();
-        ExceptionInformStrategyCmd informStrategyCmd = new ExceptionInformStrategyCmd();
-        informStrategyCmd.setEmail(true);
-        informStrategyCmd.setNote(true);
-        informStrategyCmd.setWechat(true);
-        informStrategyCmd.setWechatApplet(true);
-        executeInformUserCmd(informCo, informStrategyCmd, users);
-    }
-
-    @Override
-    public void departmentLevelInform(CommonInformCO informCo) {
-        log.info("department level: {}", informCo.getOrg());
-        // get user
-        List<KeycloakUserCO> users = keycloakService.getGroupAdmin(informCo.getOrg());
-        // get strategy
-        TenantExceptionInformStrategyCO informStrategyCo = tenantExceptionInformStrategyService.getTenantInformStrategyCache(informCo.getTenant());
-        ExceptionInformStrategyCmd informStrategyCmd = informStrategyCo.getStrategy().get(String.valueOf(informCo.getTypeEnum().getLevel().getId()));
-        // execute inform
-        executeInformUserCmd(informCo, informStrategyCmd, users);
-    }
-
-    @Override
-    public void singleInformMethod(CommonInformCO informCo) {
-        log.info("single inform level: {}", informCo.getUserId());
-        List<KeycloakUserCO> users = keycloakService.getUsersByIds(Collections.singletonList(informCo.getUserId()));
-        // get strategy
-        TenantExceptionInformStrategyCO informStrategyCo = tenantExceptionInformStrategyService.getTenantInformStrategyCache(informCo.getTenant());
-        ExceptionInformStrategyCmd informStrategyCmd = informStrategyCo.getStrategy().get(String.valueOf(informCo.getTypeEnum().getLevel().getId()));
-        // execute inform
-        executeInformUserCmd(informCo, informStrategyCmd, users);
-    }
-
-    /**
-     * execute inform action
-     * @param informCo inform object
-     * @param informStrategyCmd strategy
-     * @param users users
-     */
-    private void executeInformUserCmd(CommonInformCO informCo, ExceptionInformStrategyCmd informStrategyCmd, List<KeycloakUserCO> users) {
-        // set addressees
-        InformAddressees addressees = new InformAddressees(users.size());
-        users.forEach(user -> {
-            log.info("user: {}", user);
-            addressees.addPhone(user.getPhone());
-            addressees.addEmailAddressee(user.getEmail());
-            addressees.addOpenId(user.getWechat());
-            addressees.addUserId(user.getId());
-        });
-        try {
-            // save record
-            Long contentId = this.saveSendRecord(informCo, informStrategyCmd, users);
-            // send message
-            InformResult informResult = sendMessage(informCo, informStrategyCmd, addressees);
-            // update record
-            updateSendRecord(informResult, contentId, informStrategyCmd);
-        } catch (IOException e) {
-            if (e instanceof JsonProcessingException) {
-                log.error("序列化出错: {}", e.getMessage(), e);
-                throw new CustomerBaseException("参数序列化出错", 500);
-            }
-            log.error("模板转换出错: {}", e.getMessage(), e);
-            throw new CustomerBaseException("模板转换出错", 500);
-        }
-    }
-
-    /**
-     * send message
-     * @param informCo inform co
-     * @param informStrategyCmd strategy
-     * @param addressees address
-     * @return inform result(CompletableFuture)
-     */
-    private InformResult sendMessage(CommonInformCO informCo, ExceptionInformStrategyCmd informStrategyCmd, InformAddressees addressees) throws IOException {
-        MessageTemplateEnum templateEnum = informCo.getTypeEnum().getTemplateEnum();
-        // inform result
-        InformResult informResult = new InformResult();
-        if (Boolean.TRUE.equals(informStrategyCmd.getEmail())) {
-            EmailMessage emailMessage = emailMessageHandler.makeEmailMessage(informCo.getEmailMessage(), templateEnum.getEmail(), addressees.getEmailAddressees());
-            log.info("email");
-            informResult.setEmailResult(smsbEmailService.asyncSendEmail(emailMessage));
-        }
-        if (Boolean.TRUE.equals(informStrategyCmd.getNote())) {
-            SmsMessage smsMessage = noteMessageHandler.makeSmsMessage(informCo.getNoteMessage(), addressees.getPhones(), templateEnum.getNote());
-            log.info("note");
-            informResult.setNoteResult(smsbSmsService.asyncSend(smsMessage));
-        }
-        if (Boolean.TRUE.equals(informStrategyCmd.getWechat())) {
-            WechatMessage wechatMessage = weChatMessageHandler.makeWeChatMessage(informCo.getWeChatMessage(), addressees.getOpenIds(), templateEnum.getWechat());
-            log.info("wechat");
-            informResult.setWeChatResult(weChatService.asyncSend(wechatMessage));
-        }
-        if (Boolean.TRUE.equals(informStrategyCmd.getWechatApplet())) {
-            WxAppletUserMessageDto wxAppletUserMessageDto = weChatAppletMessageHandler.makeWeChatAppletMessage(informCo.getWeChatAppletMessage(), templateEnum.getApplet());
-            log.info("applet");
-            informResult.setWeChatAppletResult(wxAppletUserMessageService.asyncInsertBatch(wxAppletUserMessageDto, addressees.getUserIds()));
-        }
-        return informResult;
-    }
-
-    /**
-     * save record
-     * @param informCo inform co
-     * @param informStrategyCmd strategy
-     * @param users users
-     * @return content id
-     * @throws JsonProcessingException json
-     */
-    private Long saveSendRecord(CommonInformCO informCo, ExceptionInformStrategyCmd informStrategyCmd, List<KeycloakUserCO> users) throws JsonProcessingException {
-        InformMessageRecordDto messageRecordDto = new InformMessageRecordDto();
-        messageRecordDto.setTenant(informCo.getTenant());
-        messageRecordDto.setOrg(informCo.getOrg());
-        Map<String, String> messageMap = new HashMap<>(4);
-        log.info("strategy: {}", informStrategyCmd);
-        if (Boolean.TRUE.equals(informStrategyCmd.getEmail())) {
-            messageMap.put(InformMessageRecordDto.EMAIL_KEY, objectMapper.writeValueAsString(informCo.getEmailMessage()));
-        }
-        if (Boolean.TRUE.equals(informStrategyCmd.getNote())) {
-            messageMap.put(InformMessageRecordDto.NOTE_KEY, objectMapper.writeValueAsString(informCo.getNoteMessage()));
-        }
-        if (Boolean.TRUE.equals(informStrategyCmd.getWechat())) {
-            messageMap.put(InformMessageRecordDto.WECHAT_KEY, objectMapper.writeValueAsString(informCo.getWeChatMessage()));
-        }
-        if (Boolean.TRUE.equals(informStrategyCmd.getWechatApplet())) {
-            messageMap.put(InformMessageRecordDto.WECHAT_APPLET_KEY, objectMapper.writeValueAsString(informCo.getWeChatAppletMessage()));
-        }
-        messageRecordDto.setMessageMap(messageMap);
-        return informMessageRecordService.saveRecord(users, informStrategyCmd, messageRecordDto);
-    }
-
-    /**
-     * update record after future done
-     * @param informResult result
-     * @param contentId contentId
-     * @param informStrategyCmd strategy
-     */
-    private void updateSendRecord(InformResult informResult, Long contentId, ExceptionInformStrategyCmd informStrategyCmd) {
-        CompletableFuture<Void> totalFuture = setFutureCombine(informResult, informStrategyCmd.getCount());
-        totalFuture.whenComplete((result, error) -> {
-            log.error("future error: {}", error.getMessage(), error);
-            log.info("update result flag");
-        });
-        totalFuture.join();
-        informResult.updateResultFlag();
-        // update record
-        informMessageRecordService.updateRecord(contentId, informResult.getResultFlag());
-    }
-
-    /**
-     * set future combine
-     * @param informResult result
-     * @param size future count
-     * @return combined future
-     */
-    public CompletableFuture<Void> setFutureCombine(InformResult informResult, Integer size) {
-        int index = 0;
-        CompletableFuture[] completableFutures = new CompletableFuture[size];
-        if (informResult.getNoteResult() != null) {
-            completableFutures[index] = informResult.getNoteResult();
-            index++;
-        }
-        if (informResult.getEmailResult() != null) {
-            completableFutures[index] = informResult.getEmailResult();
-            index++;
-        }
-        if (informResult.getWeChatResult() != null) {
-            completableFutures[index] = informResult.getWeChatResult();
-            index++;
-        }
-        if (informResult.getWeChatAppletResult() != null) {
-            completableFutures[index] = informResult.getWeChatAppletResult();
-        }
-        log.info("combine future");
-        return CompletableFuture.allOf(completableFutures);
-    }
-}

+ 0 - 37
smsb-customer-manager-app/src/main/java/com/inspur/customer/service/inform/InformMessageContentRecordServiceImpl.java

@@ -1,37 +0,0 @@
-package com.inspur.customer.service.inform;
-
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.inspur.customer.client.inform.InformMessageContentRecordService;
-import com.inspur.customer.infrastructure.mapper.inform.InformMessageContentRecordMapper;
-import com.inspur.customer.infrastructure.object.inform.InformMessageContentRecordDO;
-import com.inspur.customer.object.inform.InformMessageContentRecordDto;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.dubbo.config.annotation.DubboService;
-import org.springframework.beans.BeanUtils;
-
-import javax.annotation.Resource;
-
-/**
- * message content record service
- * @author linwenhua
- * @date 2022-07-01 10:08
- **/
-@Slf4j
-@DubboService(interfaceClass = InformMessageContentRecordService.class)
-public class InformMessageContentRecordServiceImpl extends ServiceImpl<InformMessageContentRecordMapper, InformMessageContentRecordDO> implements InformMessageContentRecordService {
-
-    @Resource
-    private ObjectMapper objectMapper;
-
-    @Override
-    public Long saveContentRecord(InformMessageContentRecordDto informMessageContentRecordDto) throws JsonProcessingException {
-        InformMessageContentRecordDO informMessageContentRecordDo = new InformMessageContentRecordDO();
-        BeanUtils.copyProperties(informMessageContentRecordDto, informMessageContentRecordDo);
-        // transform to json
-        informMessageContentRecordDo.setMessageMapJson(objectMapper.writeValueAsString(informMessageContentRecordDto.getMessageMap()));
-        this.save(informMessageContentRecordDo);
-        return informMessageContentRecordDo.getId();
-    }
-}

+ 0 - 114
smsb-customer-manager-app/src/main/java/com/inspur/customer/service/inform/InformMessageRecordServiceImpl.java

@@ -1,114 +0,0 @@
-package com.inspur.customer.service.inform;
-
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.inspur.customer.client.inform.InformMessageContentRecordService;
-import com.inspur.customer.client.inform.InformMessageRecordService;
-import com.inspur.customer.infrastructure.mapper.inform.InformMessageRecordMapper;
-import com.inspur.customer.infrastructure.object.inform.InformMessageRecordDO;
-import com.inspur.customer.object.inform.InformMessageContentRecordDto;
-import com.inspur.customer.object.inform.InformMessageRecordDto;
-import com.inspur.customer.object.keycloak.KeycloakUserCO;
-import com.inspur.customer.object.tenant.ExceptionInformStrategyCmd;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.dubbo.config.annotation.DubboReference;
-import org.apache.dubbo.config.annotation.DubboService;
-import org.springframework.beans.BeanUtils;
-
-import java.util.ArrayList;
-import java.util.BitSet;
-import java.util.List;
-
-/**
- * message send record service
- * @author linwenhua
- * @date 2022-06-30 17:40
- **/
-@Slf4j
-@DubboService(interfaceClass = InformMessageRecordService.class)
-public class InformMessageRecordServiceImpl extends ServiceImpl<InformMessageRecordMapper, InformMessageRecordDO> implements InformMessageRecordService {
-
-    @DubboReference
-    private InformMessageContentRecordService informMessageContentRecordService;
-
-    @Override
-    public Long saveRecord(List<KeycloakUserCO> users, ExceptionInformStrategyCmd informStrategyCmd, InformMessageRecordDto informMessageRecordDto) throws JsonProcessingException {
-        List<InformMessageRecordDO> informMessageRecordDos = new ArrayList<>(users.size());
-        // save content
-        Long contentId = this.saveMessageContent(informMessageRecordDto, informStrategyCmd, users.size());
-        users.forEach(user -> {
-            InformMessageRecordDO informMessageRecordDo = new InformMessageRecordDO();
-            BeanUtils.copyProperties(informMessageRecordDto, informMessageRecordDo);
-            // set inform flag
-            informMessageRecordDo.setInformFlag(getInformFlag(user, informStrategyCmd));
-            // status default 0
-            informMessageRecordDo.setInformStatus(0);
-            informMessageRecordDo.setContentId(contentId);
-            informMessageRecordDo.setUserId(user.getId());
-            informMessageRecordDos.add(informMessageRecordDo);
-        });
-        this.saveBatch(informMessageRecordDos, informMessageRecordDos.size());
-        return contentId;
-    }
-
-    @Override
-    public void updateRecord(Long contentId, Integer informStatus) {
-        log.info("update send record: {}", contentId);
-        BitSet informBitMap = BitSet.valueOf(new byte[]{informStatus.byteValue()});
-        List<InformMessageRecordDO> messageRecordDos = this.list(Wrappers
-            .<InformMessageRecordDO>lambdaQuery()
-            .eq(InformMessageRecordDO::getContentId, contentId));
-        messageRecordDos.forEach(messageRecordDo -> {
-            BitSet userBitMap = messageRecordDo.getBitMap();
-            userBitMap.and(informBitMap);
-            if (userBitMap.isEmpty()) {
-                messageRecordDo.setInformStatus(0);
-            } else {
-                messageRecordDo.setInformStatus((int) userBitMap.toByteArray()[0]);
-            }
-        });
-        this.updateBatchById(messageRecordDos);
-    }
-
-    /**
-     * save message content
-     * @param informMessageRecordDto record
-     * @param informStrategyCmd strategy
-     * @param size record count
-     * @return contentId
-     * @throws JsonProcessingException json parse exception
-     */
-    private Long saveMessageContent(InformMessageRecordDto informMessageRecordDto, ExceptionInformStrategyCmd informStrategyCmd, Integer size) throws JsonProcessingException {
-        InformMessageContentRecordDto informMessageContentRecordDto = new InformMessageContentRecordDto();
-        informMessageContentRecordDto.setTenant(informMessageRecordDto.getTenant());
-        informMessageContentRecordDto.setUsers(size);
-        informMessageContentRecordDto.setMessageMap(informMessageRecordDto.getMessageMap());
-        informMessageContentRecordDto.setInformFlag(informStrategyCmd.getStrategyFlag());
-        return informMessageContentRecordService.saveContentRecord(informMessageContentRecordDto);
-    }
-
-    /**
-     * get inform flag by bitMap
-     * 从低位开始
-     * 0 位: note 1
-     * 1 位: email 2
-     * 2 位: weChat 4
-     * 3 位: weChatApplet 8
-     * @param keycloakUserCo user
-     * @param informStrategyCmd strategy
-     * @return flag
-     */
-    private Integer getInformFlag(KeycloakUserCO keycloakUserCo, ExceptionInformStrategyCmd informStrategyCmd) {
-        log.info("user: {}", keycloakUserCo);
-        BitSet userBitSet = keycloakUserCo.getInformFlag();
-        BitSet strategyBitSet = informStrategyCmd.getStrategySet();
-        userBitSet.and(strategyBitSet);
-        log.info("userBitSet: {}", userBitSet);
-        log.info("strategy: {}", strategyBitSet);
-        if (userBitSet.isEmpty()) {
-            return 0;
-        }
-        return (int) userBitSet.toByteArray()[0];
-    }
-}

+ 0 - 21
smsb-customer-manager-app/src/main/java/com/inspur/customer/service/inform/handler/AbstractMessageHandler.java

@@ -1,21 +0,0 @@
-package com.inspur.customer.service.inform.handler;
-
-import org.apache.commons.io.IOUtils;
-import org.springframework.core.io.ClassPathResource;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.charset.StandardCharsets;
-
-/**
- * @author linwenhua
- * @date 2022-07-01 15:44
- **/
-public class AbstractMessageHandler {
-
-    protected String getTemplate(String filePath) throws IOException {
-        ClassPathResource classPathResource = new ClassPathResource(filePath);
-        InputStream inputStream = classPathResource.getInputStream();
-        return IOUtils.toString(inputStream, StandardCharsets.UTF_8);
-    }
-}

+ 0 - 45
smsb-customer-manager-app/src/main/java/com/inspur/customer/service/inform/handler/EmailMessageHandler.java

@@ -1,45 +0,0 @@
-package com.inspur.customer.service.inform.handler;
-
-import com.inspur.customer.object.inform.CommonMessageCO;
-import com.inspur.inform.object.message.EmailMessage;
-import org.apache.commons.io.IOUtils;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.stereotype.Component;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.charset.StandardCharsets;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * email message content handler
- * @author linwenhua
- * @date 2022-07-01 10:58
- **/
-@Component
-public class EmailMessageHandler extends AbstractMessageHandler {
-
-    private static final String FILE_PATH_PRE = "email/";
-
-    private static final String FILE_PATH_SUF = ".html";
-
-    public EmailMessage makeEmailMessage(CommonMessageCO commonMessageCo, String fileName, List<String> addressees) throws IOException {
-        // get content
-        String filePath = FILE_PATH_PRE + fileName + FILE_PATH_SUF;
-        String content = getTemplate(filePath);
-        Iterator<String> integer = commonMessageCo.getMessageMap().keySet().iterator();
-        String key;
-        while (integer.hasNext()) {
-            key = integer.next();
-            content = content.replaceFirst(key, commonMessageCo.getMessageMap().get(key));
-        }
-        // set email message
-        // todo attach file and subject
-        EmailMessage emailMessage = new EmailMessage();
-        emailMessage.setAddressees(addressees);
-        emailMessage.setEmailContent(content);
-        emailMessage.setSubject(commonMessageCo.getSubject());
-        return emailMessage;
-    }
-}

+ 0 - 25
smsb-customer-manager-app/src/main/java/com/inspur/customer/service/inform/handler/NoteMessageHandler.java

@@ -1,25 +0,0 @@
-package com.inspur.customer.service.inform.handler;
-
-import com.inspur.customer.object.inform.CommonMessageCO;
-import com.inspur.inform.object.message.SmsMessage;
-import com.inspur.inform.constants.SmsbSmsTemplateType;
-import org.springframework.stereotype.Component;
-
-import java.util.List;
-
-/**
- * note message content handler
- * @author linwenhua
- * @date 2022-07-01 10:57
- **/
-@Component
-public class NoteMessageHandler extends AbstractMessageHandler {
-
-    public SmsMessage makeSmsMessage(CommonMessageCO commonMessageCo, List<String> phones, Integer smsType) {
-        SmsMessage message = new SmsMessage();
-        message.setPhones(phones);
-        message.setTemplateParam(commonMessageCo.getMessageMap());
-        message.setTemplateType(SmsbSmsTemplateType.getTypeById(smsType));
-        return message;
-    }
-}

+ 0 - 45
smsb-customer-manager-app/src/main/java/com/inspur/customer/service/inform/handler/WeChatAppletMessageHandler.java

@@ -1,45 +0,0 @@
-package com.inspur.customer.service.inform.handler;
-
-import com.inspur.customer.object.inform.CommonMessageCO;
-import com.inspur.inform.client.wechat.applet.IWxAppletUserMessageService;
-import com.inspur.inform.constants.UserMsgType;
-import com.inspur.inform.constants.applet.WxAppletMessageTemplate;
-import com.inspur.inform.object.applet.message.WxAppletUserMessageDto;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.dubbo.config.annotation.DubboReference;
-import org.springframework.stereotype.Component;
-
-import java.util.Iterator;
-
-/**
- * weChat applet message content handler
- * @author linwenhua
- * @date 2022-07-01 10:58
- **/
-@Slf4j
-@Component
-public class WeChatAppletMessageHandler extends AbstractMessageHandler {
-
-    @DubboReference(timeout = 10000, retries = 0)
-    private IWxAppletUserMessageService wxAppletUserMessageService;
-
-    public WxAppletUserMessageDto makeWeChatAppletMessage(CommonMessageCO commonMessageCo, String fileName) {
-        // get content
-        WxAppletMessageTemplate messageTemplateEnum = WxAppletMessageTemplate.getTemplateByFilePath(fileName);
-        log.info("template: {}", messageTemplateEnum);
-        String content = wxAppletUserMessageService.getTemplate(messageTemplateEnum);
-        Iterator<String> integer = commonMessageCo.getMessageMap().keySet().iterator();
-        String key;
-        while (integer.hasNext()) {
-            key = integer.next();
-            content = content.replaceFirst(key, commonMessageCo.getMessageMap().get(key));
-        }
-        WxAppletUserMessageDto wxAppletUserMessageDto = new WxAppletUserMessageDto();
-        wxAppletUserMessageDto.setSubject(commonMessageCo.getSubject());
-        //todo type level pic
-        wxAppletUserMessageDto.setType(UserMsgType.SYSTEM.getType());
-        wxAppletUserMessageDto.setPic(0);
-        wxAppletUserMessageDto.setMessage(content);
-        return wxAppletUserMessageDto;
-    }
-}

+ 0 - 49
smsb-customer-manager-app/src/main/java/com/inspur/customer/service/inform/handler/WeChatMessageHandler.java

@@ -1,49 +0,0 @@
-package com.inspur.customer.service.inform.handler;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.inspur.customer.object.inform.CommonMessageCO;
-import com.inspur.inform.object.message.WechatKeyword;
-import com.inspur.inform.object.message.WechatMessage;
-import com.inspur.inform.object.message.WechatRealMessage;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.Resource;
-import java.io.IOException;
-import java.text.MessageFormat;
-import java.util.List;
-
-/**
- * weChat message content handler
- * @author linwenhua
- * @date 2022-07-01 10:57
- **/
-@Component
-public class WeChatMessageHandler extends AbstractMessageHandler {
-
-    @Resource
-    private ObjectMapper objectMapper;
-
-    private static final String FILE_PATH_PRE = "weChat/";
-
-    private static final String FILE_PATH_SUF = ".json";
-
-    public WechatMessage makeWeChatMessage(CommonMessageCO commonMessageCo, List<String> openIds, String fileName) throws IOException {
-        WechatRealMessage wechatRealMessage = getRealMessage(fileName);
-        commonMessageCo.getMessageMap().forEach((key, word) -> {
-            WechatKeyword wechatKeyword = wechatRealMessage.getData().get(key);
-            String keywordValue = wechatKeyword.getValue();
-            String[] words = word.split("/");
-            wechatKeyword.setValue(MessageFormat.format(keywordValue, words));
-        });
-        WechatMessage wechatMessage = new WechatMessage(wechatRealMessage);
-        wechatMessage.setInformAddresses(openIds);
-        return wechatMessage;
-    }
-
-    private WechatRealMessage getRealMessage(String fileName) throws IOException {
-        // get content
-        String filePath = FILE_PATH_PRE + fileName + FILE_PATH_SUF;
-        String content = getTemplate(filePath);
-        return objectMapper.readValue(content, WechatRealMessage.class);
-    }
-}

+ 0 - 64
smsb-customer-manager-app/src/main/java/com/inspur/customer/service/inform/object/InformResult.java

@@ -1,64 +0,0 @@
-package com.inspur.customer.service.inform.object;
-
-import com.inspur.inform.object.message.MessageSendResponse;
-import lombok.Data;
-import lombok.extern.slf4j.Slf4j;
-
-import java.util.BitSet;
-import java.util.concurrent.CompletableFuture;
-
-/**
- * @author linwenhua
- * @date 2022-07-01 19:01
- **/
-@Data
-@Slf4j
-public class InformResult {
-
-    private BitSet resultFlag = new BitSet(4);
-
-    private CompletableFuture<MessageSendResponse> emailResult;
-    private CompletableFuture<MessageSendResponse> noteResult;
-    private CompletableFuture<MessageSendResponse> weChatResult;
-    private CompletableFuture<MessageSendResponse> weChatAppletResult;
-
-    public void updateResultFlag(Integer index) {
-        resultFlag.set(index);
-    }
-
-    public void updateResultFlag() {
-        if (noteResult != null) {
-            log.info("update note flag");
-            getFlagFromFuture(noteResult, 0);
-        }
-        if (emailResult != null) {
-            log.info("update email flag");
-            getFlagFromFuture(emailResult, 1);
-        }
-        if (weChatResult != null) {
-            log.info("update weChat flag");
-            getFlagFromFuture(weChatResult, 2);
-        }
-        if (weChatAppletResult != null) {
-            log.info("update applet flag");
-            getFlagFromFuture(weChatAppletResult, 3);
-        }
-    }
-
-    public Integer getResultFlag() {
-        if (resultFlag.isEmpty()) {
-            return 0;
-        }
-        return (int) resultFlag.toByteArray()[0];
-    }
-
-    private void getFlagFromFuture(CompletableFuture<MessageSendResponse> future, Integer index) {
-        future.whenComplete((result, error) -> {
-            if (error == null) {
-                resultFlag.set(index);
-            }
-        });
-    }
-
-
-}

+ 0 - 3
smsb-customer-manager-app/src/main/java/com/inspur/customer/service/tenant/TenantExceptionInformStrategyServiceImpl.java

@@ -12,9 +12,6 @@ import org.apache.dubbo.config.annotation.DubboService;
 import org.springframework.cache.annotation.CacheEvict;
 import org.springframework.cache.annotation.Cacheable;
 
-import java.util.HashMap;
-import java.util.Map;
-
 /**
  * tenant exception inform strategy service implement
  * @author linwenhua

+ 84 - 0
smsb-customer-manager-app/src/main/java/com/inspur/customer/service/tenant/UserInformServiceImpl.java

@@ -0,0 +1,84 @@
+package com.inspur.customer.service.tenant;
+
+import com.alibaba.cola.exception.BizException;
+import com.inspur.customer.client.keycloak.KeycloakService;
+import com.inspur.customer.client.tenant.TenantExceptionInformStrategyService;
+import com.inspur.customer.client.tenant.UserInformService;
+import com.inspur.customer.context.inform.InformLevelEnum;
+import com.inspur.customer.context.inform.InformTypeEnum;
+import com.inspur.customer.object.tenant.InformAddresseeCO;
+import com.inspur.customer.object.keycloak.KeycloakUserCO;
+import com.inspur.customer.object.tenant.ExceptionInformStrategyCmd;
+import com.inspur.customer.object.tenant.TenantExceptionInformStrategyCO;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.dubbo.config.annotation.DubboReference;
+import org.apache.dubbo.config.annotation.DubboService;
+
+import javax.annotation.Nullable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author linwenhua
+ * @date 2022-12-02 16:19
+ **/
+@Slf4j
+@DubboService(interfaceClass = UserInformService.class)
+public class UserInformServiceImpl implements UserInformService {
+
+    @DubboReference
+    private KeycloakService keycloakService;
+    @DubboReference
+    private TenantExceptionInformStrategyService tenantExceptionInformStrategyService;
+
+    @Override
+    public InformAddresseeCO getInformAddresseesByInformLevel(@Nullable String userId, String tenant, @Nullable List<String> org, InformLevelEnum informLevel) {
+        // get base user
+        List<KeycloakUserCO> users = new ArrayList<>();
+        InformAddresseeCO informAddressee = new InformAddresseeCO();
+        if (userId != null) {
+            users.addAll(keycloakService.getUsersByIds(Collections.singletonList(userId)));
+        }
+        // get and set inform strategy
+        log.info("tenant: {}", tenant);
+        TenantExceptionInformStrategyCO informStrategy = tenantExceptionInformStrategyService.getTenantInformStrategyCache(tenant);
+        informAddressee.setInformStrategy(informStrategy.getInformStrategy(String.valueOf(informLevel.getId())));
+        // get additional user
+        switch (informLevel) {
+            case HINT: {
+                log.info("hint");
+                break;
+            }
+            case INTERMEDIATE: {
+                log.info("intermediate");
+                //todo replace get user method
+                users.addAll(keycloakService.getUsersInRole("ROLE_SUPER_ADMIN"));
+                break;
+            }
+            case URGENT: {
+                log.info("urgent");
+                //todo replace get user method
+                users.addAll(keycloakService.getUsersInRole("ROLE_SUPER_ADMIN"));
+                break;
+            }
+            default: {
+                log.info("not support");
+                throw new BizException("500", "类型错误");
+            }
+        }
+        informAddressee.setUsers(users);
+        return informAddressee;
+    }
+
+    @Override
+    public InformAddresseeCO getInformAddresseesByInformType(@Nullable String userId, String tenant, @Nullable List<String> orgs, InformTypeEnum informType) {
+        return getInformAddresseesByInformLevel(userId, tenant, orgs, informType.getLevel());
+    }
+
+    @Override
+    public ExceptionInformStrategyCmd getInformStrategyByInformLevel(String tenant, InformLevelEnum informLevel) {
+        TenantExceptionInformStrategyCO tenantExceptionInformStrategy = tenantExceptionInformStrategyService.getTenantInformStrategyCache(tenant);
+        return tenantExceptionInformStrategy.getInformStrategy(String.valueOf(informLevel.getId()));
+    }
+}

+ 0 - 47
smsb-customer-manager-client/src/main/java/com/inspur/customer/client/inform/CommonInformService.java

@@ -1,47 +0,0 @@
-package com.inspur.customer.client.inform;
-
-import com.inspur.customer.object.inform.CommonInformCO;
-
-/**
- * common inform service
- * @author linwenhua
- * @date 2022-06-29 14:59
- **/
-public interface CommonInformService {
-
-    /**
-     * common inform for some level like that:
-     * @see com.inspur.customer.context.inform.InformLevelEnum#HINT
-     * @see com.inspur.customer.context.inform.InformLevelEnum#INTERMEDIATE
-     * @see com.inspur.customer.context.inform.InformLevelEnum#URGENT
-     * @param informCo informCo
-     */
-    void commonInform(CommonInformCO informCo);
-
-    /**
-     * tenant level inform for tenant manager
-     *
-     * @param informCo informCO
-     * @see com.inspur.customer.context.inform.InformLevelEnum#TENANT
-     */
-    void tenantLevelInform(CommonInformCO informCo);
-
-    void superAdminLevelInform(CommonInformCO informCo);
-
-    /**
-     * department level inform for department leader
-     *
-     * @param informCo informCO
-     * @see com.inspur.customer.context.inform.InformLevelEnum#HINT
-     */
-    void departmentLevelInform(CommonInformCO informCo);
-
-    /**
-     * single inform method for some level like that:
-     * @see com.inspur.customer.context.inform.InformLevelEnum#SINGLE_EMAIL
-     * @see com.inspur.customer.context.inform.InformLevelEnum#SINGLE_NOTE
-     * @param informCo informCo
-     */
-    void singleInformMethod(CommonInformCO informCo);
-
-}

+ 0 - 20
smsb-customer-manager-client/src/main/java/com/inspur/customer/client/inform/InformMessageContentRecordService.java

@@ -1,20 +0,0 @@
-package com.inspur.customer.client.inform;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.inspur.customer.object.inform.InformMessageContentRecordDto;
-
-/**
- * message content record service
- * @author linwenhua
- * @date 2022-06-29 16:31
- **/
-public interface InformMessageContentRecordService {
-
-    /**
-     * save content
-     * @param informMessageContentRecordDto content record
-     * @throws JsonProcessingException json parse exception
-     * @return content id
-     */
-    Long saveContentRecord(InformMessageContentRecordDto informMessageContentRecordDto) throws JsonProcessingException;
-}

+ 0 - 33
smsb-customer-manager-client/src/main/java/com/inspur/customer/client/inform/InformMessageRecordService.java

@@ -1,33 +0,0 @@
-package com.inspur.customer.client.inform;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.inspur.customer.object.inform.InformMessageRecordDto;
-import com.inspur.customer.object.keycloak.KeycloakUserCO;
-import com.inspur.customer.object.tenant.ExceptionInformStrategyCmd;
-
-import java.util.List;
-
-/**
- * message send record service
- * @author linwenhua
- * @date 2022-06-29 16:31
- **/
-public interface InformMessageRecordService {
-
-    /**
-     * save send record
-     * @param users users
-     * @param informStrategyCmd inform strategy
-     * @param informMessageRecordDto message record
-     * @throws JsonProcessingException json parse exception
-     * @return content id
-     */
-    Long saveRecord(List<KeycloakUserCO> users, ExceptionInformStrategyCmd informStrategyCmd, InformMessageRecordDto informMessageRecordDto) throws JsonProcessingException;
-
-    /**
-     * update record
-     * @param contentId contentId
-     * @param informStatus status
-     */
-    void updateRecord(Long contentId, Integer informStatus);
-}

+ 22 - 0
smsb-customer-manager-client/src/main/java/com/inspur/customer/client/tenant/UserInformService.java

@@ -0,0 +1,22 @@
+package com.inspur.customer.client.tenant;
+
+import com.inspur.customer.context.inform.InformLevelEnum;
+import com.inspur.customer.context.inform.InformTypeEnum;
+import com.inspur.customer.object.tenant.InformAddresseeCO;
+import com.inspur.customer.object.tenant.ExceptionInformStrategyCmd;
+import org.springframework.lang.Nullable;
+
+import java.util.List;
+
+/**
+ * @author linwenhua
+ * @date 2022-12-02 16:17
+ **/
+public interface UserInformService {
+
+    InformAddresseeCO getInformAddresseesByInformLevel(@Nullable String userId, String tenant, List<String> departments, InformLevelEnum informLevel);
+
+    InformAddresseeCO getInformAddresseesByInformType(@Nullable String userId, String tenant, @Nullable List<String> departments, InformTypeEnum informType);
+
+    ExceptionInformStrategyCmd getInformStrategyByInformLevel(String tenant, InformLevelEnum informLevel);
+}

+ 4 - 0
smsb-customer-manager-client/src/main/java/com/inspur/customer/context/inform/InformLevelEnum.java

@@ -52,6 +52,10 @@ public enum InformLevelEnum {
     @Getter
     private final String name;
 
+    public static InformLevelEnum getLevelById(int id) {
+        return Arrays.stream(InformLevelEnum.values()).filter(informLevel -> id == informLevel.getId()).findFirst().orElse(null);
+    }
+
     public static String getLevelName(int id) {
         return Arrays.stream(InformLevelEnum.values()).filter(informLevel -> id == informLevel.getId()).findFirst().map(InformLevelEnum::getName).orElse(null);
     }

+ 0 - 60
smsb-customer-manager-client/src/main/java/com/inspur/customer/object/inform/CommonInformCO.java

@@ -1,60 +0,0 @@
-package com.inspur.customer.object.inform;
-
-import com.inspur.customer.context.inform.InformTypeEnum;
-import lombok.Data;
-
-import java.io.Serializable;
-
-/**
- * @author linwenhua
- * @date 2022-06-29 16:40
- **/
-@Data
-public class CommonInformCO implements Serializable {
-
-    private static final long serialVersionUID = 4485440990149055018L;
-
-    private InformTypeEnum typeEnum;
-
-    /*---------------- batch inform ----------------*/
-
-    /**
-     * tenant identifier
-     */
-    private String tenant;
-
-    /**
-     * department
-     */
-    private String org;
-
-    /*---------------- single inform ----------------*/
-
-    /**
-     * user id
-     */
-    private String userId;
-
-    /*-------------------------------- message consider to make a list  --------------------------------*/
-
-    /**
-     * email message
-     */
-    private CommonMessageCO emailMessage;
-
-    /**
-     * note message
-     */
-    private CommonMessageCO noteMessage;
-
-    /**
-     * weChat message
-     */
-    private CommonMessageCO weChatMessage;
-
-    /**
-     * weChat applet
-     */
-    private CommonMessageCO weChatAppletMessage;
-
-}

+ 0 - 21
smsb-customer-manager-client/src/main/java/com/inspur/customer/object/inform/CommonMessageCO.java

@@ -1,21 +0,0 @@
-package com.inspur.customer.object.inform;
-
-import lombok.Data;
-
-import java.io.Serializable;
-import java.util.Map;
-
-/**
- * @author linwenhua
- * @date 2022-06-29 16:43
- **/
-@Data
-public class CommonMessageCO implements Serializable {
-
-    private String subject;
-
-    private static final long serialVersionUID = -4561191896624275223L;
-
-    private Map<String, String> messageMap;
-
-}

+ 0 - 40
smsb-customer-manager-client/src/main/java/com/inspur/customer/object/inform/CustomerBaseException.java

@@ -1,40 +0,0 @@
-package com.inspur.customer.object.inform;
-
-import lombok.Getter;
-
-/**
- * @author linwenhua
- * @date 2022-07-01 16:31
- **/
-public class CustomerBaseException extends RuntimeException{
-
-    private static final long serialVersionUID = 6432409098208302604L;
-
-    @Getter
-    private String msg;
-
-    @Getter
-    private int code = 500;
-
-    public CustomerBaseException(String msg) {
-        super(msg);
-        this.msg = msg;
-    }
-
-    public CustomerBaseException(String msg, Throwable e) {
-        super(msg, e);
-        this.msg = msg;
-    }
-
-    public CustomerBaseException(String msg, int code) {
-        super(msg);
-        this.msg = msg;
-        this.code = code;
-    }
-
-    public CustomerBaseException(String msg, int code, Throwable e) {
-        super(msg, e);
-        this.msg = msg;
-        this.code = code;
-    }
-}

+ 0 - 71
smsb-customer-manager-client/src/main/java/com/inspur/customer/object/inform/InformAddressees.java

@@ -1,71 +0,0 @@
-package com.inspur.customer.object.inform;
-
-import lombok.Getter;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.lang.Nullable;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * @author linwenhua
- * @date 2022-06-14 09:45
- **/
-public class InformAddressees implements Serializable {
-
-    private static final long serialVersionUID = 5978949873926901132L;
-
-    @Getter
-    private final List<String> phones;
-
-    @Getter
-    private final List<String> emailAddressees;
-
-    @Getter
-    private final List<String> openIds;
-    /**
-     * user id for applet
-     */
-    @Getter
-    List<String> userIds;
-    
-    public InformAddressees(List<String> openIds) {
-        this.phones = Collections.emptyList();
-        this.emailAddressees = Collections.emptyList();
-        this.openIds = Collections.emptyList();
-        this.userIds = Collections.emptyList();
-    }
-    
-    public InformAddressees(Integer size) {
-        phones = new ArrayList<>(size);
-        emailAddressees = new ArrayList<>(size);
-        openIds = new ArrayList<>(size);
-        userIds = new ArrayList<>(size);
-    }
-
-    public void addPhone(@Nullable String phone) {
-        if (StringUtils.isNotBlank(phone)) {
-            phones.add(phone);
-        }
-    }
-
-    public void addEmailAddressee(@Nullable String emailAddressee) {
-        if (StringUtils.isNotBlank(emailAddressee)) {
-            emailAddressees.add(emailAddressee);
-        }
-    }
-
-    public void addOpenId(@Nullable String openId) {
-        if (StringUtils.isNotBlank(openId)) {
-            openIds.add(openId);
-        }
-    }
-
-    public void addUserId(@Nullable String userId) {
-        if (StringUtils.isNotBlank(userId)) {
-            userIds.add(userId);
-        }
-    }
-}

+ 0 - 44
smsb-customer-manager-client/src/main/java/com/inspur/customer/object/inform/InformMessageContentRecordDto.java

@@ -1,44 +0,0 @@
-package com.inspur.customer.object.inform;
-
-import lombok.Data;
-
-import java.io.Serializable;
-import java.util.Map;
-
-/**
- * @author linwenhua
- * @date 2022-06-29 16:36
- **/
-@Data
-public class InformMessageContentRecordDto implements Serializable {
-
-    private static final long serialVersionUID = -1708529192978236713L;
-
-    private Long id;
-
-    /**
-     * tenant identifier
-     */
-    private String tenant;
-
-    /**
-     * the number of user
-     */
-    private Integer users;
-
-    /**
-     * inform flag
-     * bit 0: note
-     * bit 1: email
-     * bit 2: weChat
-     * bit 3: weChat applet
-     */
-    private Integer informFlag;
-
-    /**
-     * message map
-     */
-    private Map<String, String> messageMap;
-
-    private String contentMapJson;
-}

+ 0 - 56
smsb-customer-manager-client/src/main/java/com/inspur/customer/object/inform/InformMessageRecordDto.java

@@ -1,56 +0,0 @@
-package com.inspur.customer.object.inform;
-
-import lombok.Data;
-
-import java.io.Serializable;
-import java.util.Map;
-
-/**
- * message send record
- * @author linwenhua
- * @date 2022-06-29 16:35
- **/
-@Data
-public class InformMessageRecordDto implements Serializable {
-
-    private static final long serialVersionUID = -1729327083071852247L;
-
-    public static final String EMAIL_KEY = "email";
-
-    public static final String NOTE_KEY = "note";
-
-    public static final String WECHAT_KEY = "weChat";
-
-    public static final String WECHAT_APPLET_KEY = "weChatApplet";
-
-    private Long id;
-
-    /**
-     * content record id
-     * @see InformMessageContentRecordDto#getId()
-     */
-    private Long contentId;
-
-    private Integer type;
-
-    /**
-     * tenant identifier
-     */
-    private String tenant;
-
-    /**
-     * department
-     */
-    private String org;
-
-    /**
-     * user id
-     */
-    private String userId;
-
-    /**
-     * message map
-     */
-    private Map<String, String> messageMap;
-
-}

+ 0 - 59
smsb-customer-manager-client/src/main/java/com/inspur/customer/object/inform/InformStrategy.java

@@ -1,59 +0,0 @@
-package com.inspur.customer.object.inform;
-
-import com.inspur.customer.context.inform.InformLevelEnum;
-import lombok.Getter;
-
-import java.io.Serializable;
-
-/**
- * @author linwenhua
- * @date 2022-06-30 09:50
- **/
-public class InformStrategy implements Serializable {
-
-    private static final long serialVersionUID = -7952204074632539933L;
-
-    @Getter
-    private Boolean email;
-
-    @Getter
-    private Boolean note;
-
-    @Getter
-    private Boolean weChat;
-
-    @Getter
-    private Boolean weChatApplet;
-
-    public InformStrategy(InformLevelEnum informLevelEnum) {
-        switch (informLevelEnum) {
-            case SINGLE_EMAIL: {
-                this.email = true;
-                break;
-            }
-            case SINGLE_NOTE : {
-                this.note = true;
-                break;
-            }
-            case TEST:
-            case  HINT : {
-                this.email = true;
-                this.note = false;
-                this.weChat = true;
-                this.weChatApplet = true;
-                break;
-            }
-            case INTERMEDIATE :
-            case URGENT : {
-                this.email = true;
-                this.note = true;
-                this.weChat = true;
-                this.weChatApplet = true;
-                break;
-            }
-            default : {
-                break;
-            }
-        }
-    }
-}

+ 5 - 1
smsb-customer-manager-client/src/main/java/com/inspur/customer/object/tenant/ExceptionInformStrategyCmd.java

@@ -28,7 +28,7 @@ public class ExceptionInformStrategyCmd extends Command {
     private Boolean email;
 
     /**
-     * inform user by wechat
+     * inform user by weChat
      */
     private Boolean wechat;
 
@@ -46,6 +46,10 @@ public class ExceptionInformStrategyCmd extends Command {
         setFlag(byteFlag);
     }
 
+    public Boolean needInform() {
+        return note || email || wechat || wechatApplet;
+    }
+
     /**
      * get inform strategy flag with bit identifier
      * 从低位开始

+ 64 - 0
smsb-customer-manager-client/src/main/java/com/inspur/customer/object/tenant/InformAddresseeCO.java

@@ -0,0 +1,64 @@
+package com.inspur.customer.object.tenant;
+
+import com.inspur.customer.object.keycloak.KeycloakUserCO;
+import com.inspur.customer.object.tenant.ExceptionInformStrategyCmd;
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * @author linwenhua
+ * @date 2022-12-06 09:41
+ **/
+public class InformAddresseeCO implements Serializable {
+
+    private static final long serialVersionUID = -2056897808671772295L;
+
+    @Setter
+    @Getter
+    private ExceptionInformStrategyCmd informStrategy;
+
+    @Setter
+    private List<KeycloakUserCO> users;
+
+    public List<String> getEmailAddressees() {
+        if (Boolean.TRUE.equals(informStrategy.getEmail())) {
+            return users.stream().map(KeycloakUserCO::getEmail).filter(StringUtils::isNotBlank).collect(Collectors.toList());
+        }
+        return Collections.emptyList();
+    }
+
+    public List<String> getWeChatAddressees() {
+        if (Boolean.TRUE.equals(informStrategy.getWechat())) {
+            return users.stream().map(KeycloakUserCO::getWechat).filter(StringUtils::isNotBlank).collect(Collectors.toList());
+        }
+        return Collections.emptyList();
+    }
+
+    public List<String> getUserIds() {
+        if (Boolean.TRUE.equals(informStrategy.getWechatApplet())) {
+            return users.stream().map(KeycloakUserCO::getId).filter(StringUtils::isNotBlank).collect(Collectors.toList());
+        }
+        return Collections.emptyList();
+    }
+
+    public List<String> getWeChatAppletAddressees() {
+        if (Boolean.TRUE.equals(informStrategy.getWechatApplet())) {
+            return users.stream().map(KeycloakUserCO::getWechatAppletOpenId).filter(StringUtils::isNotBlank).collect(Collectors.toList());
+        }
+        return Collections.emptyList();
+    }
+
+    public List<String> getPhoneAddressees() {
+        if (Boolean.TRUE.equals(informStrategy.getNote())) {
+            return users.stream().map(KeycloakUserCO::getPhone).filter(StringUtils::isNotBlank).collect(Collectors.toList());
+        }
+        return Collections.emptyList();
+    }
+
+}

+ 12 - 0
smsb-customer-manager-client/src/main/java/com/inspur/customer/object/tenant/TenantExceptionInformStrategyCO.java

@@ -1,6 +1,7 @@
 package com.inspur.customer.object.tenant;
 
 import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
 
 import java.io.Serializable;
 import java.util.HashMap;
@@ -12,6 +13,7 @@ import java.util.Map;
  * @date 2022-06-07 18:37
  **/
 @Data
+@Slf4j
 public class TenantExceptionInformStrategyCO implements Serializable {
 
     private static final long serialVersionUID = -2981913767151035603L;
@@ -54,6 +56,16 @@ public class TenantExceptionInformStrategyCO implements Serializable {
         return strategy.get(level).getStrategyFlag();
     }
 
+    public ExceptionInformStrategyCmd getInformStrategy(String level) {
+        ExceptionInformStrategyCmd informStrategyCmd = strategy.get(level);
+        if (informStrategyCmd == null) {
+            log.error("strategy is null: {}", level);
+            // email and weChat
+            informStrategyCmd =  new ExceptionInformStrategyCmd(6);
+        }
+        return informStrategyCmd;
+    }
+
     public void updateStrategy(String strategyKey, ExceptionInformStrategyCmd informStrategyCmd) {
         this.strategy.put(strategyKey, informStrategyCmd);
     }

+ 5 - 0
smsb-customer-manager-client/src/main/java/com/inspur/customer/object/user/authcode/AuthCodeDTO.java

@@ -1,6 +1,7 @@
 package com.inspur.customer.object.user.authcode;
 
 import lombok.Data;
+import org.apache.commons.lang3.StringUtils;
 
 import javax.validation.constraints.Email;
 import javax.validation.constraints.Pattern;
@@ -14,4 +15,8 @@ public class AuthCodeDTO implements Serializable {
 
     @Pattern(regexp = "^$|^[1][3-9][0-9]{9}$", message = "手机号码格式错误")
     private String phoneNum;
+
+    public boolean addresseeIsNotBlank() {
+        return !(StringUtils.isBlank(email) && StringUtils.isBlank(phoneNum));
+    }
 }

+ 0 - 14
smsb-customer-manager-infrastructure/src/main/java/com/inspur/customer/infrastructure/mapper/inform/InformMessageContentRecordMapper.java

@@ -1,14 +0,0 @@
-package com.inspur.customer.infrastructure.mapper.inform;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.inspur.customer.infrastructure.object.inform.InformMessageContentRecordDO;
-import com.inspur.customer.infrastructure.object.inform.InformMessageRecordDO;
-import org.apache.ibatis.annotations.Mapper;
-
-/**
- * @author linwenhua
- * @date 2022-06-29 16:08
- **/
-@Mapper
-public interface InformMessageContentRecordMapper extends BaseMapper<InformMessageContentRecordDO> {
-}

+ 0 - 13
smsb-customer-manager-infrastructure/src/main/java/com/inspur/customer/infrastructure/mapper/inform/InformMessageRecordMapper.java

@@ -1,13 +0,0 @@
-package com.inspur.customer.infrastructure.mapper.inform;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.inspur.customer.infrastructure.object.inform.InformMessageRecordDO;
-import org.apache.ibatis.annotations.Mapper;
-
-/**
- * @author linwenhua
- * @date 2022-06-29 16:08
- **/
-@Mapper
-public interface InformMessageRecordMapper extends BaseMapper<InformMessageRecordDO> {
-}

+ 0 - 48
smsb-customer-manager-infrastructure/src/main/java/com/inspur/customer/infrastructure/object/inform/InformMessageContentRecordDO.java

@@ -1,48 +0,0 @@
-package com.inspur.customer.infrastructure.object.inform;
-
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.Data;
-
-import java.io.Serializable;
-
-/**
- * message content record
- * @author linwenhua
- * @date 2022-06-29 15:46
- **/
-@Data
-@TableName("inform_message_content_record")
-public class InformMessageContentRecordDO implements Serializable {
-
-    private static final long serialVersionUID = 4564437666438735274L;
-
-    /**
-     * record id
-     */
-    @TableId
-    private Long id;
-
-    /**
-     * tenant identifier
-     */
-    @TableField("tenant")
-    private String tenant;
-
-    /**
-     * inform flag
-     * bit 0: note
-     * bit 1: email
-     * bit 2: weChat
-     * bit 3: weChat applet
-     */
-    @TableField("inform_flag")
-    private Integer informFlag;
-
-    /**
-     * message map json
-     */
-    @TableField("message_map_json")
-    private String messageMapJson;
-}

+ 0 - 81
smsb-customer-manager-infrastructure/src/main/java/com/inspur/customer/infrastructure/object/inform/InformMessageRecordDO.java

@@ -1,81 +0,0 @@
-package com.inspur.customer.infrastructure.object.inform;
-
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.Data;
-
-import java.io.Serializable;
-import java.util.BitSet;
-
-/**
- * record of message sending
- * @author linwenhua
- * @date 2022-06-29 15:46
- **/
-@Data
-@TableName("inform_message_record")
-public class InformMessageRecordDO implements Serializable {
-
-    private static final long serialVersionUID = 493815370400441472L;
-
-    @TableId
-    private Long id;
-
-    /**
-     * content record id
-     * @see InformMessageContentRecordDO#getId()
-     */
-    @TableField("content_id")
-    private Long contentId;
-
-    /**
-     * tenant identifier
-     */
-    @TableField("tenant")
-    private String tenant;
-
-    /**
-     * department
-     */
-    @TableField("org")
-    private String org;
-
-    /**
-     * user id
-     */
-    @TableField("user_id")
-    private String userId;
-
-    /**
-     * message type
-     */
-    @TableField("type")
-    private Integer type;
-
-    /**
-     * inform flag
-     * bit 0: note
-     * bit 1: email
-     * bit 2: weChat
-     * bit 3: weChat applet
-     */
-    @TableField("inform_flag")
-    private Integer informFlag;
-
-    /**
-     * inform flag
-     * bit 0: note
-     * bit 1: email
-     * bit 2: weChat
-     * bit 3: weChat applet
-     */
-    @TableField("inform_status")
-    private Integer informStatus;
-
-    public BitSet getBitMap() {
-        byte[] byteFlag = new byte[]{informFlag.byteValue()};
-        return BitSet.valueOf(byteFlag);
-    }
-
-}

+ 0 - 5
smsb-customer-manager-infrastructure/src/main/resources/mapper/inform/InformMessageContentRecordMapper.xml

@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.inspur.customer.infrastructure.mapper.inform.InformMessageContentRecordMapper">
-
-</mapper>

+ 0 - 5
smsb-customer-manager-infrastructure/src/main/resources/mapper/inform/InformMessageRecordMapper.xml

@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.inspur.customer.infrastructure.mapper.inform.InformMessageRecordMapper">
-
-</mapper>

+ 0 - 79
smsb-customer-manager-start-web/src/test/java/com/inspur/customer/MessageHandlerTest.java

@@ -1,79 +0,0 @@
-package com.inspur.customer;
-
-import com.inspur.customer.object.inform.CommonMessageCO;
-import com.inspur.customer.service.inform.handler.EmailMessageHandler;
-import com.inspur.customer.service.inform.handler.WeChatAppletMessageHandler;
-import com.inspur.customer.service.inform.handler.WeChatMessageHandler;
-import com.inspur.inform.object.applet.WeChatAppletUserDataDto;
-import com.inspur.inform.object.applet.message.WxAppletUserMessageDto;
-import com.inspur.inform.object.message.EmailMessage;
-import com.inspur.inform.object.message.WechatMessage;
-import lombok.extern.slf4j.Slf4j;
-import org.junit.jupiter.api.Test;
-
-import java.io.IOException;
-import java.util.BitSet;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author linwenhua
- * @date 2022-07-01 13:56
- **/
-@Slf4j
-class MessageHandlerTest {
-
-    private final EmailMessageHandler emailMessageHandler = new EmailMessageHandler();
-
-    private final WeChatAppletMessageHandler weChatAppletMessageHandler = new WeChatAppletMessageHandler();
-
-    private final WeChatMessageHandler weChatMessageHandler = new WeChatMessageHandler();
-
-    @Test
-    void testEmail() throws IOException {
-        CommonMessageCO commonMessageCo = new CommonMessageCO();
-        commonMessageCo.setSubject("测试");
-        Map<String, String> attributes = new HashMap<>(10);
-        attributes.put("MSRlevel", "紧急");
-        attributes.put("MSRdevice", "紧急");
-        attributes.put("MSRarea", "紧急");
-        attributes.put("MSRtime", "紧急");
-        commonMessageCo.setMessageMap(attributes);
-        EmailMessage emailMessage = emailMessageHandler.makeEmailMessage(commonMessageCo, "BatchDeviceEmptyOrchestration", Collections.emptyList());
-        log.info("message: {}", emailMessage);
-    }
-
-    @Test
-    void testApplet() throws IOException {
-        CommonMessageCO commonMessageCo = new CommonMessageCO();
-        commonMessageCo.setSubject("测试");
-        Map<String, String> attributes = new HashMap<>(10);
-        attributes.put("MSRlevel", "紧急");
-        attributes.put("MSRdevice", "紧急");
-        attributes.put("MSRarea", "紧急");
-        attributes.put("MSRtime", "紧急");
-        commonMessageCo.setMessageMap(attributes);
-        WxAppletUserMessageDto wxAppletUserMessageDto = weChatAppletMessageHandler.makeWeChatAppletMessage(commonMessageCo, "MultiWarn");
-        log.info("message: {}", wxAppletUserMessageDto);
-    }
-
-    @Test
-    void testWeChat() throws IOException {
-        CommonMessageCO commonMessageCo = new CommonMessageCO();
-        commonMessageCo.setSubject("测试");
-        Map<String, String> attributes = new HashMap<>(10);
-        attributes.put("keyword1", "紧急");
-        attributes.put("keyword3", "紧急");
-        commonMessageCo.setMessageMap(attributes);
-        WechatMessage wechatMessage = weChatMessageHandler.makeWeChatMessage(commonMessageCo, Collections.emptyList(), "device");
-        log.info("message: {}", wechatMessage);
-    }
-
-    @Test
-    void testBitset() {
-        BitSet bitSet = new BitSet(4);
-        bitSet.set(2);
-        log.info("size: {}", bitSet.length());
-    }
-}