|
@@ -1,13 +1,15 @@
|
|
|
package cn.com.ty.lift.system.settings.controller;
|
|
|
|
|
|
|
|
|
-import cn.com.ty.lift.common.constants.ApiConstants;
|
|
|
import cn.com.ty.lift.system.settings.dao.entity.GlobalSet;
|
|
|
import cn.com.ty.lift.system.settings.service.impl.GlobalSetServiceImpl;
|
|
|
import cn.com.xwy.boot.web.dto.RestResponse;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import java.time.Clock;
|
|
|
import java.time.LocalDateTime;
|
|
@@ -23,7 +25,7 @@ import java.util.List;
|
|
|
* @since 2019-12-13
|
|
|
*/
|
|
|
@RestController
|
|
|
-@RequestMapping("/global-set")
|
|
|
+@RequestMapping("/set")
|
|
|
@AllArgsConstructor
|
|
|
public class GlobalSetController {
|
|
|
private final GlobalSetServiceImpl globalSetService;
|
|
@@ -34,15 +36,15 @@ public class GlobalSetController {
|
|
|
* @description 获取维保公司的全局设置列表
|
|
|
* @date 2019/12/13 16:23
|
|
|
*/
|
|
|
- @PostMapping
|
|
|
+ @PostMapping("list")
|
|
|
public RestResponse sets(@RequestBody GlobalSet globalSet) {
|
|
|
List<GlobalSet> globalSets = globalSetService
|
|
|
.list(new QueryWrapper<GlobalSet>()
|
|
|
.eq("company_id", globalSet.getCompanyId()));
|
|
|
if (globalSets.isEmpty()) {
|
|
|
- return RestResponse.success(null, ApiConstants.RESULT_NO_DATA, "无数据");
|
|
|
+ return RestResponse.success();
|
|
|
}
|
|
|
- return RestResponse.success(globalSets, ApiConstants.RESULT_SUCCESS, "查询成功");
|
|
|
+ return RestResponse.success(globalSets, "成功");
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -51,14 +53,12 @@ public class GlobalSetController {
|
|
|
* @description 根据id更新维保公司的全局设置
|
|
|
* @date 2019/12/13 16:24
|
|
|
*/
|
|
|
- @PostMapping("/update")
|
|
|
- public RestResponse update(@RequestBody List<GlobalSet> globalSets) {
|
|
|
- globalSets.forEach(globalSet -> {
|
|
|
- globalSet.setUpdateTime(LocalDateTime.now(Clock.system(ZoneId.of("Asia/Shanghai"))));
|
|
|
- });
|
|
|
- if (globalSetService.updateBatchById(globalSets)) {
|
|
|
- return RestResponse.success(null, ApiConstants.RESULT_SUCCESS, "更新成功");
|
|
|
+ @PostMapping("/modify")
|
|
|
+ public RestResponse modify(@RequestBody List<GlobalSet> globalSets) {
|
|
|
+ globalSets.forEach(globalSet -> globalSet.setUpdateTime(LocalDateTime.now()));
|
|
|
+ if (globalSetService.saveOrUpdateBatch(globalSets)) {
|
|
|
+ return RestResponse.success(null, "成功");
|
|
|
}
|
|
|
- return RestResponse.success(null, ApiConstants.RESULT_NO_DATA, "无数据");
|
|
|
+ return RestResponse.success();
|
|
|
}
|
|
|
}
|