|
@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -40,8 +41,9 @@ public class MaintenanceOptionController {
|
|
|
public RestResponse list(@RequestBody OptionReq req) {
|
|
|
IPage<MaintenanceOption> page = optionService.page(
|
|
|
new Page<>(req.getPageNum(), req.getPageSize()), new QueryWrapper<MaintenanceOption>()
|
|
|
- .in("mt_company_id", 0L, req.getMtCompanyId())
|
|
|
- .eq(req.getType() != null, "type", req.getType())
|
|
|
+ //10086是平台的团队id
|
|
|
+ .in("mt_company_id", 10086L, req.getMtCompanyId())
|
|
|
+ .in(req.getType() != null, "type", type(req))
|
|
|
.eq(req.getLiftType() != null, "lift_type", req.getLiftType())
|
|
|
.orderByDesc("mt_company_id")
|
|
|
);
|
|
@@ -51,14 +53,27 @@ public class MaintenanceOptionController {
|
|
|
return RestResponse.success(page);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * app端维保项列表
|
|
|
+ *
|
|
|
+ * @param req
|
|
|
+ * @return RestResponse
|
|
|
+ */
|
|
|
@PostMapping("/options")
|
|
|
- public RestResponse options(@RequestBody MaintenanceOption req) {
|
|
|
+ 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>()
|
|
|
- .in("mt_company_id", 0L, req.getMtCompanyId())
|
|
|
- .eq(req.getType() != null, "type", req.getType())
|
|
|
+ //10086是平台的团队id
|
|
|
+ .in("mt_company_id", 10086L, req.getMtCompanyId())
|
|
|
+ .in(req.getType() != null, "type", type(req))
|
|
|
.eq(req.getLiftType() != null, "lift_type", req.getLiftType())
|
|
|
- .eq(req.getSort() != null, "sort", req.getSort()));
|
|
|
+ .in(sort != null, "sort", sort)
|
|
|
+ );
|
|
|
if (options.isEmpty()) {
|
|
|
return RestResponse.success();
|
|
|
}
|
|
@@ -73,9 +88,6 @@ public class MaintenanceOptionController {
|
|
|
*/
|
|
|
@PostMapping("/add")
|
|
|
public RestResponse add(@RequestBody MaintenanceOption option) {
|
|
|
- if (option.getMtCompanyId().equals(0L)) {
|
|
|
- option.setEdit(0);
|
|
|
- }
|
|
|
if (optionService.save(option)) {
|
|
|
return RestResponse.success(option.getId(), "成功");
|
|
|
}
|
|
@@ -90,8 +102,8 @@ public class MaintenanceOptionController {
|
|
|
*/
|
|
|
@PostMapping("/modify")
|
|
|
public RestResponse modify(@RequestBody MaintenanceOption option) {
|
|
|
- MaintenanceOption byId = optionService.getById(option.getId());
|
|
|
- if (byId.getEdit() == 0) {
|
|
|
+ //10086是平台的团队id
|
|
|
+ if (option.getMtCompanyId().equals(10086L)) {
|
|
|
return RestResponse.fail("默认维保项无法编辑");
|
|
|
}
|
|
|
if (optionService.updateById(option)) {
|
|
@@ -108,8 +120,8 @@ public class MaintenanceOptionController {
|
|
|
*/
|
|
|
@PostMapping("/delete")
|
|
|
public RestResponse delete(@RequestBody MaintenanceOption option) {
|
|
|
- MaintenanceOption byId = optionService.getById(option.getId());
|
|
|
- if (byId.getEdit() == 0) {
|
|
|
+ //10086是平台的团队id
|
|
|
+ if (option.getMtCompanyId().equals(10086L)) {
|
|
|
return RestResponse.fail("默认维保项无法删除");
|
|
|
}
|
|
|
if (optionService.removeById(option.getId())) {
|
|
@@ -117,4 +129,25 @@ public class MaintenanceOptionController {
|
|
|
}
|
|
|
return RestResponse.fail();
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 维保项type 1半月 2季度保 3半年保 4全年保(仅仅只有自己的,
|
|
|
+ * 比如type=2时,并没有1的维保项,所以要处理一下,把1包含进去
|
|
|
+ *
|
|
|
+ * @param req
|
|
|
+ * @return type列表
|
|
|
+ */
|
|
|
+ private ArrayList<Integer> type(OptionReq req) {
|
|
|
+ ArrayList<Integer> types = new ArrayList<>();
|
|
|
+ Integer type = req.getType();
|
|
|
+ if (type > 0)
|
|
|
+ types.add(1);
|
|
|
+ if (type > 1)
|
|
|
+ types.add(2);
|
|
|
+ if (type > 2)
|
|
|
+ types.add(3);
|
|
|
+ if (type > 3)
|
|
|
+ types.add(4);
|
|
|
+ return types;
|
|
|
+ }
|
|
|
}
|