Forráskód Böngészése

refactor: add some special strategies like tenant/department strategy

linwenhua 3 éve
szülő
commit
6815178a8b

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

@@ -7,6 +7,7 @@ import com.inspur.customer.infrastructure.mapper.tenant.TenantExceptionInformStr
 import com.inspur.customer.infrastructure.object.tenant.TenantExceptionInformStrategyDO;
 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.DubboService;
 import org.springframework.cache.annotation.CacheEvict;
 import org.springframework.cache.annotation.Cacheable;
@@ -19,6 +20,7 @@ import java.util.Map;
  * @author linwenhua
  * @date 2022-06-08 11:49
  **/
+@Slf4j
 @DubboService(interfaceClass = TenantExceptionInformStrategyService.class)
 public class TenantExceptionInformStrategyServiceImpl extends ServiceImpl<TenantExceptionInformStrategyMapper, TenantExceptionInformStrategyDO> implements TenantExceptionInformStrategyService {
 
@@ -42,6 +44,7 @@ public class TenantExceptionInformStrategyServiceImpl extends ServiceImpl<Tenant
     @Override
     @Cacheable(value = "msr:tenant:informStrategy", key = "#tenant")
     public TenantExceptionInformStrategyCO getTenantInformStrategyCache(String tenant) {
+        log.info("get inform strategy: {}", tenant);
         TenantExceptionInformStrategyDO informStrategyDo = this.getById(tenant);
         // if user didn't not set strategy, return default
         if (informStrategyDo == null) {
@@ -70,13 +73,16 @@ public class TenantExceptionInformStrategyServiceImpl extends ServiceImpl<Tenant
      * @return co
      */
     private TenantExceptionInformStrategyCO changeToInformStrategyCo(TenantExceptionInformStrategyDO informStrategyDo) {
-        TenantExceptionInformStrategyCO informStrategyCo = new TenantExceptionInformStrategyCO(informStrategyDo.getTenant());
+        TenantExceptionInformStrategyCO informStrategyCo = new TenantExceptionInformStrategyCO(informStrategyDo.getTenant(), 10);
         informStrategyCo.updateStrategy(TenantExceptionInformStrategyCO.HINT_LEVEL_KEY, new ExceptionInformStrategyCmd(informStrategyDo.getHintLevelFlag()));
         informStrategyCo.updateStrategy(TenantExceptionInformStrategyCO.MIDDLE_LEVEL_KEY, new ExceptionInformStrategyCmd(informStrategyDo.getMiddleLevelFlag()));
         informStrategyCo.updateStrategy(TenantExceptionInformStrategyCO.URGENT_LEVEL_KEY, new ExceptionInformStrategyCmd(informStrategyDo.getUrgencyLevelFlag()));
-        // TODO special inform
+        // special strategy
         informStrategyCo.updateStrategy(TenantExceptionInformStrategyCO.TENANT_LEVEL_KEY, new ExceptionInformStrategyCmd(15));
         informStrategyCo.updateStrategy(TenantExceptionInformStrategyCO.DEPARTMENT_LEVEL, new ExceptionInformStrategyCmd(15));
+        // single method
+        informStrategyCo.updateStrategy(TenantExceptionInformStrategyCO.SINGLE_NOTE, new ExceptionInformStrategyCmd(1));
+        informStrategyCo.updateStrategy(TenantExceptionInformStrategyCO.SINGLE_EMAIL, new ExceptionInformStrategyCmd(2));
         return informStrategyCo;
     }
 
@@ -86,12 +92,17 @@ public class TenantExceptionInformStrategyServiceImpl extends ServiceImpl<Tenant
      * @return strategy
      */
     private TenantExceptionInformStrategyCO getDefaultStrategy(String tenant) {
-        TenantExceptionInformStrategyCO informStrategyCo = new TenantExceptionInformStrategyCO(tenant);
-        Map<String, ExceptionInformStrategyCmd> strategyMap = new HashMap<>(3);
-        strategyMap.put(TenantExceptionInformStrategyCO.HINT_LEVEL_KEY, new ExceptionInformStrategyCmd(14));
-        strategyMap.put(TenantExceptionInformStrategyCO.MIDDLE_LEVEL_KEY, new ExceptionInformStrategyCmd(15));
-        strategyMap.put(TenantExceptionInformStrategyCO.URGENT_LEVEL_KEY, new ExceptionInformStrategyCmd(15));
-        informStrategyCo.setStrategy(strategyMap);
+        log.info("get default strategy");
+        TenantExceptionInformStrategyCO informStrategyCo = new TenantExceptionInformStrategyCO(tenant, 10);
+        informStrategyCo.updateStrategy(TenantExceptionInformStrategyCO.HINT_LEVEL_KEY, new ExceptionInformStrategyCmd(14));
+        informStrategyCo.updateStrategy(TenantExceptionInformStrategyCO.MIDDLE_LEVEL_KEY, new ExceptionInformStrategyCmd(15));
+        informStrategyCo.updateStrategy(TenantExceptionInformStrategyCO.URGENT_LEVEL_KEY, new ExceptionInformStrategyCmd(15));
+        // special strategy
+        informStrategyCo.updateStrategy(TenantExceptionInformStrategyCO.TENANT_LEVEL_KEY, new ExceptionInformStrategyCmd(15));
+        informStrategyCo.updateStrategy(TenantExceptionInformStrategyCO.DEPARTMENT_LEVEL, new ExceptionInformStrategyCmd(15));
+        // single method
+        informStrategyCo.updateStrategy(TenantExceptionInformStrategyCO.SINGLE_NOTE, new ExceptionInformStrategyCmd(1));
+        informStrategyCo.updateStrategy(TenantExceptionInformStrategyCO.SINGLE_EMAIL, new ExceptionInformStrategyCmd(2));
         return informStrategyCo;
     }