Просмотр исходного кода

Merge branch 'wanghaicheng' of lift-manager/lift-server into develop

wanghaicheng 5 лет назад
Родитель
Сommit
392092464e

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

@@ -32,21 +32,21 @@ public class MaintenanceOptionController {
     private final MaintenanceOptionServiceImpl optionService;
 
     /**
-     * 分页获取维保项列表
-     *
      * @param req 页码 页大小
      * @return cn.com.xwy.boot.web.dto.RestResponse
-     * @since 2019/12/19 9:21
+     * @description 分页获取维保项列表
+     * @date 2019/12/19 9:21
      */
     @PostMapping("/list")
     public RestResponse list(@RequestBody OptionReq req) {
         IPage<MaintenanceOption> page = optionService.page(
                 new Page<>(req.getPageNum(), req.getPageSize()), new QueryWrapper<MaintenanceOption>()
-                        //0是系统默认维保项
-                        .in("mt_company_id", 0L, req.getMtCompanyId())
+                        //10086是平台的团队id
+                        .in("mt_company_id", 10086L, req.getMtCompanyId())
+                        //留1是为了兼容以前数据,2.0使用的status版本1 ,    3.0使用的status版本2
+                        .eq("status", 2)
                         .in(req.getType() != null, "type", type(req))
                         .eq(req.getLiftType() != null, "lift_type", req.getLiftType())
-                        .eq("status",2)
                         .orderByDesc("mt_company_id")
         );
         if (page.getRecords().isEmpty()) {
@@ -58,37 +58,42 @@ public class MaintenanceOptionController {
     /**
      * app端维保项列表
      *
-     * @param request
+     * @param req
      * @return RestResponse
      */
     @PostMapping("/options")
-    public RestResponse options(@RequestBody OptionReq request) {
-        Integer liftType = request.getLiftType();
+    public RestResponse options(@RequestBody OptionReq req) {
+        Integer liftType = req.getLiftType();
         String sort = null;
         if (liftType.equals(3)) {
             sort = "-1,1";
         }
         List<MaintenanceOption> options = optionService.list(
                 new QueryWrapper<MaintenanceOption>()
-                        //0是系统默认维保项
-                        .in("mt_company_id", 0L, request.getMtCompanyId())
-                        .in(request.getType() != null, "type", type(request))
-                        .eq(request.getLiftType() != null, "lift_type", request.getLiftType())
-                        .eq("status",2)
+                        //10086是平台的团队id
+                        .in("mt_company_id", 10086L, req.getMtCompanyId())
+                        //留1是为了兼容以前数据,2.0使用的status版本1 ,    3.0使用的status版本2
+                        .eq("status", 2)
+                        .in(req.getType() != null, "type", type(req))
+                        .eq(req.getLiftType() != null, "lift_type", req.getLiftType())
                         .in(sort != null, "sort", sort)
         );
+        if (options.isEmpty()) {
+            return RestResponse.success();
+        }
         return RestResponse.success(options);
     }
 
     /**
-     * 新增维保项
-     *
      * @param option 维保项信息
      * @return RestResponse
-     * @since 2019/12/19 9:20
+     * @description 新增维保项
+     * @date 2019/12/19 9:20
      */
     @PostMapping("/add")
     public RestResponse add(@RequestBody MaintenanceOption option) {
+        //留1是为了兼容以前数据,2.0使用的status版本1 ,    3.0使用的status版本2
+        option.setStatus(2);
         if (optionService.save(option)) {
             return RestResponse.success(option.getId(), "成功");
         }
@@ -96,16 +101,15 @@ public class MaintenanceOptionController {
     }
 
     /**
-     * 判断是否默认维保项,不是默认维保项才可以更新
-     *
      * @param option 维保项信息
      * @return RestResponse
-     * @since 2019/12/19 10:03
+     * @description 判断是否默认维保项,不是默认维保项才可以更新
+     * @date 2019/12/19 10:03
      */
     @PostMapping("/modify")
     public RestResponse modify(@RequestBody MaintenanceOption option) {
-        //0是系统默认维保项
-        if (option.getMtCompanyId().equals(0L)) {
+        //10086是平台的团队id
+        if (option.getMtCompanyId().equals(10086L)) {
             return RestResponse.fail("默认维保项无法编辑");
         }
         if (optionService.updateById(option)) {
@@ -115,15 +119,21 @@ public class MaintenanceOptionController {
     }
 
     /**
-     * 判断是否是默认维保项,不是默认的维保项才可以删除
-     *
      * @param option 维保项id
      * @return RestResponse
-     * @since 2019/12/19 9:20
+     * @description 判断是否是默认维保项,不是默认的维保项才可以删除
+     * @date 2019/12/19 9:20
      */
     @PostMapping("/delete")
     public RestResponse delete(@RequestBody MaintenanceOption option) {
-        return optionService.delete(option);
+        //10086是平台的团队id
+        if (option.getMtCompanyId().equals(10086L)) {
+            return RestResponse.fail("默认维保项无法删除");
+        }
+        if (optionService.removeById(option.getId())) {
+            return RestResponse.success(null, "成功");
+        }
+        return RestResponse.fail();
     }
 
     /**

+ 3 - 0
lift-enterprise-service/src/main/java/cn/com/ty/lift/enterprise/region/service/impl/RegionServiceImpl.java

@@ -94,6 +94,9 @@ public class RegionServiceImpl extends ServiceImpl<RegionMapper, Region> impleme
             }
             region.put("projectNum", projectNum);
             region.put("num", num);
+
+            projectNum = 0;
+            num = 0;
         }
         return RestResponse.success(regions, "成功");
     }