浏览代码

refactor: remove unnecessary inform strategy and change inform strategy controller path(request mapping and package)

linwenhua 3 年之前
父节点
当前提交
694989525d

+ 3 - 3
smsb-customer-manager-adapter/src/main/java/com/inspur/customer/web/controller/TenantExceptionInformStrategyController.java → smsb-customer-manager-adapter/src/main/java/com/inspur/customer/web/controller/tenant/TenantExceptionInformStrategyController.java

@@ -1,4 +1,4 @@
-package com.inspur.customer.web.controller;
+package com.inspur.customer.web.controller.tenant;
 
 import com.alibaba.cola.dto.SingleResponse;
 import com.inspur.customer.client.tenant.TenantExceptionInformStrategyService;
@@ -16,12 +16,12 @@ public class TenantExceptionInformStrategyController {
     @DubboReference
     private TenantExceptionInformStrategyService tenantExceptionInformStrategyService;
 
-    @PostMapping("/device/informStrategy")
+    @PostMapping("/tenant/informStrategy")
     public SingleResponse<TenantExceptionInformStrategyCO> setTenantInformStrategy(@RequestBody TenantExceptionInformStrategyCO informStrategyCo) {
         return tenantExceptionInformStrategyService.setInformStrategy(informStrategyCo);
     }
 
-    @GetMapping("/device/informStrategy")
+    @GetMapping("/tenant/informStrategy")
     public SingleResponse<TenantExceptionInformStrategyCO> setTenantInformStrategy(@RequestParam String tenant) {
         return tenantExceptionInformStrategyService.getTenantInformStrategy(tenant);
     }

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

@@ -36,9 +36,10 @@ public class TenantExceptionInformStrategyServiceImpl extends ServiceImpl<Tenant
     public SingleResponse<TenantExceptionInformStrategyCO> getTenantInformStrategy(String tenant) {
         TenantExceptionInformStrategyDO informStrategyDO = this.getById(tenant);
         if (informStrategyDO == null) {
-            return SingleResponse.of(getDefaultStrategy(tenant));
+            TenantExceptionInformStrategyCO defaultStrategy = getDefaultStrategy(tenant);
+            return SingleResponse.of(removeUnUseStrategy(defaultStrategy));
         }
-        return SingleResponse.of(changeToInformStrategyCo(informStrategyDO));
+        return SingleResponse.of(removeUnUseStrategy(changeToInformStrategyCo(informStrategyDO)));
     }
 
     @Override
@@ -106,4 +107,13 @@ public class TenantExceptionInformStrategyServiceImpl extends ServiceImpl<Tenant
         return informStrategyCo;
     }
 
+    private TenantExceptionInformStrategyCO removeUnUseStrategy(TenantExceptionInformStrategyCO strategyCO) {
+        strategyCO.getStrategy().remove(TenantExceptionInformStrategyCO.TENANT_LEVEL_KEY);
+        strategyCO.getStrategy().remove(TenantExceptionInformStrategyCO.DEPARTMENT_LEVEL);
+        // single method
+        strategyCO.getStrategy().remove(TenantExceptionInformStrategyCO.SINGLE_NOTE);
+        strategyCO.getStrategy().remove(TenantExceptionInformStrategyCO.SINGLE_EMAIL);
+        return strategyCO;
+    }
+
 }