|
@@ -1,9 +1,23 @@
|
|
|
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;
|
|
|
+import cn.com.xwy.boot.web.dto.RestResponse;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+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 javax.servlet.http.HttpServletRequest;
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* <p>
|
|
|
* 保养项目 前端控制器
|
|
@@ -13,7 +27,80 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
* @since 2019-12-18
|
|
|
*/
|
|
|
@RestController
|
|
|
+@AllArgsConstructor
|
|
|
@RequestMapping("/maintenance-option")
|
|
|
public class MaintenanceOptionController {
|
|
|
|
|
|
-}
|
|
|
+ private final MaintenanceOptionServiceImpl optionService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ * @description 分页获取维保项列表
|
|
|
+ * @date 2019/12/19 9:21
|
|
|
+ */
|
|
|
+ @PostMapping("/list")
|
|
|
+ public RestResponse list(@RequestBody OptionReq req, HttpServletRequest request) {
|
|
|
+ IPage page = optionService.page(
|
|
|
+ new Page<>(req.getPageNum(), req.getPageSize()),
|
|
|
+ new QueryWrapper<MaintenanceOption>()
|
|
|
+ .eq(req.getLiftType() != null, "lift_type", req.getLiftType())
|
|
|
+ .eq(req.getType() != null, "type", req.getType()));
|
|
|
+ if (page.getRecords().isEmpty()) {
|
|
|
+ return RestResponse.ok(null, ApiConstants.RESULT_NO_DATA, "无数据");
|
|
|
+ }
|
|
|
+ return RestResponse.ok(page, ApiConstants.RESULT_SUCCESS, "成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ * @description 新增维保项
|
|
|
+ * @date 2019/12/19 9:20
|
|
|
+ */
|
|
|
+ @PostMapping("/add")
|
|
|
+ public RestResponse add(@RequestBody MaintenanceOption option) {
|
|
|
+ if (optionService.save(option)) {
|
|
|
+ return RestResponse.ok(null, ApiConstants.RESULT_SUCCESS, "成功");
|
|
|
+ }
|
|
|
+ return RestResponse.ok(null, ApiConstants.RESULT_ERROR, "失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ * @description 更新维保项
|
|
|
+ * @date 2019/12/19 10:03
|
|
|
+ */
|
|
|
+ @PostMapping("/modify")
|
|
|
+ public RestResponse modify(@RequestBody MaintenanceOption option) {
|
|
|
+ MaintenanceOption byId = optionService.getById(option.getId());
|
|
|
+ if (byId == null) {
|
|
|
+ return RestResponse.ok(null, ApiConstants.RESULT_NO_DATA, "无数据");
|
|
|
+ }
|
|
|
+ if (byId.getEdit() == 1) {
|
|
|
+ if (optionService.updateById(option)) {
|
|
|
+ return RestResponse.ok(null, ApiConstants.RESULT_SUCCESS, "成功");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return RestResponse.ok(null, ApiConstants.RESULT_ERROR, "失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ * @description 判断是否可以编辑,可以编辑的维保项才可以删除
|
|
|
+ * @date 2019/12/19 9:20
|
|
|
+ */
|
|
|
+ @PostMapping("/delete")
|
|
|
+ public RestResponse delete(@RequestBody MaintenanceOption option) {
|
|
|
+ MaintenanceOption byId = optionService.getById(option.getId());
|
|
|
+ if (byId == null) {
|
|
|
+ return RestResponse.ok(null, ApiConstants.RESULT_NO_DATA, "无数据");
|
|
|
+ }
|
|
|
+ if (byId.getEdit() == 1 && optionService.removeById(option.getId())) {
|
|
|
+ return RestResponse.ok(null, ApiConstants.RESULT_SUCCESS, "成功");
|
|
|
+ }
|
|
|
+ return RestResponse.ok(null, ApiConstants.RESULT_ERROR, "失败");
|
|
|
+ }
|
|
|
+}
|