|
@@ -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();
|
|
|
}
|
|
|
|
|
|
/**
|