|
@@ -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;
|
|
@@ -16,6 +17,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -38,11 +40,11 @@ public class MaintenanceOptionController {
|
|
|
* @return cn.com.xwy.boot.web.dto.RestResponse
|
|
|
*/
|
|
|
@PostMapping("/list")
|
|
|
- public RestResponse list(@RequestBody OptionReq req) {
|
|
|
+ public RestResponse<?> list(@RequestBody OptionReq req) {
|
|
|
IPage<MaintenanceOption> page = optionService.page(
|
|
|
new Page<>(req.getPageNum(), req.getPageSize()), new QueryWrapper<MaintenanceOption>()
|
|
|
//10086L是固定数据的公司id
|
|
|
- .in("mt_company_id", 10086L, req.getMtCompanyId())
|
|
|
+ .in("mt_company_id", ApiConstants.Platform.COMPANY_ID, req.getMtCompanyId())
|
|
|
.in(req.getType() != null, "type", type(req))
|
|
|
.eq(req.getLiftCategory() != null, "lift_category", req.getLiftCategory())
|
|
|
.eq("status", 2)
|
|
@@ -60,28 +62,28 @@ public class MaintenanceOptionController {
|
|
|
* @return RestResponse
|
|
|
*/
|
|
|
@PostMapping("/options")
|
|
|
- public RestResponse options(@RequestBody OptionReq req) {
|
|
|
+ public RestResponse<?> options(@RequestBody OptionReq req) {
|
|
|
Integer category = req.getLiftCategory();
|
|
|
String sort = null;
|
|
|
- if (category == 4 || category == 5) {
|
|
|
- req.setLiftCategory(3);
|
|
|
- sort = "-1";
|
|
|
+ if (Objects.nonNull(category) && (category == 4 || category == 5)) {
|
|
|
+ req.setLiftCategory(ApiConstants.Option.ESCALATOR_CATEGORY);
|
|
|
+ sort = ApiConstants.Option.ESCALATOR_SORT;
|
|
|
}
|
|
|
- if (category == 3) {
|
|
|
- req.setLiftCategory(4);
|
|
|
+ if (Objects.nonNull(category) && category == 3) {
|
|
|
+ req.setLiftCategory(ApiConstants.Option.SUNDRIES_CATEGORY);
|
|
|
}
|
|
|
List<MaintenanceOption> options = optionService.list(
|
|
|
new QueryWrapper<MaintenanceOption>()
|
|
|
//10086L是固定数据的公司id
|
|
|
- .in("mt_company_id", 10086L, req.getMtCompanyId())
|
|
|
- .in(req.getType() != null, "type", type(req))
|
|
|
- .eq(req.getLiftCategory() != null, "lift_category", req.getLiftCategory())
|
|
|
- .eq("status", 2)
|
|
|
- .in(sort != null, "sort", sort));
|
|
|
+ .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", 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);
|
|
|
}
|
|
|
|
|
@@ -92,7 +94,7 @@ public class MaintenanceOptionController {
|
|
|
* @return RestResponse
|
|
|
*/
|
|
|
@PostMapping("/add")
|
|
|
- public RestResponse add(@RequestBody MaintenanceOption option) {
|
|
|
+ public RestResponse<?> add(@RequestBody MaintenanceOption option) {
|
|
|
if (option.getLiftCategory() == 3) {
|
|
|
option.setSort(-1);
|
|
|
}
|
|
@@ -108,10 +110,10 @@ public class MaintenanceOptionController {
|
|
|
* @return RestResponse
|
|
|
*/
|
|
|
@PostMapping("/modify")
|
|
|
- public RestResponse modify(@RequestBody MaintenanceOption option) {
|
|
|
+ public RestResponse<?> modify(@RequestBody MaintenanceOption option) {
|
|
|
Long mtCompanyId = optionService.getById(option.getId()).getMtCompanyId();
|
|
|
//10086L是固定数据的公司id
|
|
|
- if (option.getMtCompanyId().equals(mtCompanyId) || option.getMtCompanyId().equals(10086L)) {
|
|
|
+ if (option.getMtCompanyId().equals(mtCompanyId) || option.getMtCompanyId().equals(ApiConstants.Platform.COMPANY_ID)) {
|
|
|
return RestResponse.success(optionService.updateById(option));
|
|
|
}
|
|
|
return RestResponse.fail("默认维保项无法编辑");
|
|
@@ -124,10 +126,10 @@ public class MaintenanceOptionController {
|
|
|
* @return RestResponse
|
|
|
*/
|
|
|
@PostMapping("/delete")
|
|
|
- public RestResponse delete(@RequestBody MaintenanceOption option) {
|
|
|
+ public RestResponse<?> delete(@RequestBody MaintenanceOption option) {
|
|
|
Long mtCompanyId = optionService.getById(option.getId()).getMtCompanyId();
|
|
|
//10086L是固定数据的公司id
|
|
|
- if (option.getMtCompanyId().equals(mtCompanyId) || option.getMtCompanyId().equals(10086L)) {
|
|
|
+ if (option.getMtCompanyId().equals(mtCompanyId) || option.getMtCompanyId().equals(ApiConstants.Platform.COMPANY_ID)) {
|
|
|
return RestResponse.success(optionService.removeById(option.getId()));
|
|
|
}
|
|
|
return RestResponse.fail("默认维保项无法删除");
|