Explorar o código

update->优化 魔法值改常量

wang-hai-cheng %!s(int64=5) %!d(string=hai) anos
pai
achega
9ed02da0a6

+ 12 - 0
lift-common/src/main/java/cn/com/ty/lift/common/constants/ApiConstants.java

@@ -358,4 +358,16 @@ public class ApiConstants {
         Integer NULL = 0;
         Integer AUDIT = 1;
     }
+
+    public interface Option {
+        Integer CURRENT_VERSION = 2;
+        Integer DEFAULT_STATUS = 0;//web端补录要求默认0
+        String ESCALATOR_SORT = "-1";//扶梯检查部位的sort值
+        Integer ESCALATOR_CATEGORY = 3;//扶梯种类
+        Integer SUNDRIES_CATEGORY = 4;//杂物梯种类
+    }
+
+    public interface Platform {
+        Long COMPANY_ID = 10086L;
+    }
 }

+ 7 - 6
lift-enterprise-service/src/main/java/cn/com/ty/lift/enterprise/option/controller/MaintenanceOptionController.java

@@ -1,6 +1,7 @@
 package cn.com.ty.lift.enterprise.option.controller;
 
 
+import cn.com.ty.lift.common.constants.ApiConstants;
 import cn.com.ty.lift.enterprise.option.dao.entity.MaintenanceOption;
 import cn.com.ty.lift.enterprise.option.dao.entity.model.OptionReq;
 import cn.com.ty.lift.enterprise.option.service.impl.MaintenanceOptionServiceImpl;
@@ -65,24 +66,24 @@ public class MaintenanceOptionController {
         Integer category = req.getLiftCategory();
         String sort = null;
         if (Objects.nonNull(category) && (category == 4 || category == 5)) {
-            req.setLiftCategory(3);
-            sort = "-1";
+            req.setLiftCategory(ApiConstants.Option.ESCALATOR_CATEGORY);
+            sort = ApiConstants.Option.ESCALATOR_SORT;
         }
         if (Objects.nonNull(category) && category == 3) {
-            req.setLiftCategory(4);
+            req.setLiftCategory(ApiConstants.Option.SUNDRIES_CATEGORY);
         }
         List<MaintenanceOption> options = optionService.list(
                 new QueryWrapper<MaintenanceOption>()
                         //10086L是固定数据的公司id
-                        .in("mt_company_id", 10086L, req.getMtCompanyId())
+                        .in("mt_company_id", ApiConstants.Platform.COMPANY_ID, req.getMtCompanyId())
                         .in(Objects.nonNull(req.getType()), "type", type(req))
                         .eq(Objects.nonNull(req.getLiftCategory()), "lift_category", req.getLiftCategory())
-                        .eq("status", 2)
+                        .eq("status", ApiConstants.Option.CURRENT_VERSION)
                         .in(Objects.nonNull(sort), "sort", sort));
         if (options.isEmpty()) {
             return RestResponse.success();
         }
-        options.forEach(o -> o.setStatus(0));
+        options.forEach(o -> o.setStatus(ApiConstants.Option.DEFAULT_STATUS));
         return RestResponse.success(options);
     }