Browse Source

[chg]1.增加统一处理审计字段配置 2.修改公共RestResponse

别傲 5 years ago
parent
commit
74e740cf15

+ 14 - 14
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/controller/MaintenanceController.java

@@ -1,7 +1,6 @@
 package cn.com.ty.lift.business.maintenance.controller;
 
 import cn.com.ty.lift.business.framework.util.MessageUtils;
-import cn.com.ty.lift.business.maintenance.dao.entity.model.BatchMaintenancePlanRequest;
 import cn.com.ty.lift.business.maintenance.dao.entity.model.MaintenancePlanRequest;
 import cn.com.ty.lift.business.maintenance.dao.entity.model.UpdateMaintenancePlanReq;
 import cn.com.ty.lift.business.maintenance.service.MaintenancePlanService;
@@ -15,7 +14,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
-import java.util.List;
 
 /**
  * @author bieao
@@ -39,9 +37,9 @@ public class MaintenanceController {
     public RestResponse generatePlan(@RequestBody MaintenancePlanRequest request) {
         boolean result = maintenancePlanService.insertBatch(request);
         if (result) {
-            return RestResponse.ok(null, ApiConstants.RESULT_SUCCESS, MessageUtils.get("msg.add.success"));
+            return RestResponse.success(null, ApiConstants.RESULT_SUCCESS, MessageUtils.get("msg.add.success"));
         } else {
-            return RestResponse.error(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.add.fail"));
+            return RestResponse.fail(MessageUtils.get("msg.add.fail"));
         }
     }
 
@@ -55,29 +53,31 @@ public class MaintenanceController {
     public RestResponse modifyPlan(@RequestBody UpdateMaintenancePlanReq request) {
         boolean result = maintenancePlanService.modifyPlan(request);
         if (result) {
-            return RestResponse.ok(null, ApiConstants.RESULT_SUCCESS, MessageUtils.get("msg.modify.success"));
+            return RestResponse.success(null, ApiConstants.RESULT_SUCCESS, MessageUtils.get("msg.modify.success"));
         } else {
-            return RestResponse.error(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.modify.fail"));
+            return RestResponse.fail(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.modify.fail"));
         }
     }
 
     /**
-     * @param request ids 维保计划id列表
+     * @param request mtCompanyId 公司id
+     * @param request liftId 电梯id
      * @return 是否成功
      * @description 清空维保计划
      * @date 2019/12/17 3:14 PM
      */
     @PostMapping("batch/clean")
-    public RestResponse deleteByIds(@RequestBody BatchMaintenancePlanRequest request) {
-        List<Long> ids = request.getIds();
-        if (ObjectUtil.isEmpty(ids)) {
-            return RestResponse.ok(null, ApiConstants.RESULT_NO_PARAM, MessageUtils.get("msg.param.empty"));
+    public RestResponse cleanPlan(@RequestBody MaintenancePlanRequest request) {
+        String mtCompanyId = request.getMtCompanyId();
+        String liftId = request.getLiftId();
+        if (ObjectUtil.isEmpty(mtCompanyId) || ObjectUtil.isEmpty(liftId)) {
+            return RestResponse.failParam();
         }
-        boolean result = maintenancePlanService.deleteByIds(request);
+        boolean result = maintenancePlanService.cleanPlan(mtCompanyId, liftId);
         if (result) {
-            return RestResponse.ok(null, ApiConstants.RESULT_SUCCESS, MessageUtils.get("msg.modify.success"));
+            return RestResponse.success(null, ApiConstants.RESULT_SUCCESS, MessageUtils.get("msg.modify.success"));
         } else {
-            return RestResponse.error(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.modify.fail"));
+            return RestResponse.fail(MessageUtils.get("msg.modify.fail"));
         }
     }