|
@@ -0,0 +1,139 @@
|
|
|
+package com.platform.rest.controller.repair;
|
|
|
+
|
|
|
+import com.platform.common.util.R;
|
|
|
+import com.platform.dao.dto.repair.RepairReasonDTO;
|
|
|
+import com.platform.dao.entity.repair.RepairReason;
|
|
|
+import com.platform.service.repair.RepairReasonService;
|
|
|
+import com.platform.dao.util.ExcelUtil;
|
|
|
+import com.platform.dao.vo.export.repair.ExportRepairReasonVO;
|
|
|
+import com.platform.dao.vo.query.repair.RepairReasonVO;
|
|
|
+import com.platform.common.util.BeanConverterUtil;
|
|
|
+import com.platform.common.validation.group.AddGroup;
|
|
|
+import com.platform.common.validation.group.UpdateGroup;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import com.platform.common.bean.AbstractPageResultBean;
|
|
|
+import com.platform.rest.log.annotation.SysLog;
|
|
|
+import java.util.List;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Description 维修原因 控制器
|
|
|
+ * @Author chenyuehu
|
|
|
+ * @Date 2021-05-03 12:36:26
|
|
|
+ * @Version Copyright (c) 2020,北京乾元坤和科技有限公司 All rights reserved.
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@AllArgsConstructor
|
|
|
+@RequestMapping("/repair/repair-reasons")
|
|
|
+public class RepairReasonController {
|
|
|
+
|
|
|
+ private final RepairReasonService repairReasonService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过id查询单条记录
|
|
|
+ *
|
|
|
+ * @param id 主键
|
|
|
+ * @return R
|
|
|
+ */
|
|
|
+ @GetMapping("/{id}")
|
|
|
+ public R<RepairReason> getById(@PathVariable("id") String id){
|
|
|
+ return new R<>(repairReasonService.getModelById(id));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增记录
|
|
|
+ *
|
|
|
+ * @param repairReasonDTO 维修原因DTO
|
|
|
+ * @return R
|
|
|
+ */
|
|
|
+ @SysLog("新增维修原因")
|
|
|
+ @PostMapping
|
|
|
+ @PreAuthorize("@pms.hasPermission('repair-repair-reasons-add')")
|
|
|
+ public R save(@Validated({AddGroup.class}) @RequestBody RepairReasonDTO repairReasonDTO) {
|
|
|
+ return new R<>(repairReasonService.saveModelByDTO(repairReasonDTO));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改记录
|
|
|
+ *
|
|
|
+ * @param repairReasonDTO 维修原因DTO
|
|
|
+ * @return R
|
|
|
+ */
|
|
|
+ @SysLog("修改维修原因")
|
|
|
+ @PutMapping("/{id}")
|
|
|
+ @PreAuthorize("@pms.hasPermission('repair-repair-reasons-edit')")
|
|
|
+ public R update(@PathVariable("id") String id, @Validated({UpdateGroup.class}) @RequestBody RepairReasonDTO repairReasonDTO) {
|
|
|
+ repairReasonService.modModelByDTO(repairReasonDTO);
|
|
|
+ return new R<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过id删除一条记录
|
|
|
+ *
|
|
|
+ * @param id 主键
|
|
|
+ * @return R
|
|
|
+ */
|
|
|
+ @SysLog("删除维修原因")
|
|
|
+ @DeleteMapping("/{id}")
|
|
|
+ @PreAuthorize("@pms.hasPermission('repair-repair-reasons-del')")
|
|
|
+ public R removeById(@PathVariable String id){
|
|
|
+ repairReasonService.deleteByPrimaryKey(id);
|
|
|
+ return new R<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量记录
|
|
|
+ *
|
|
|
+ * @param ids 主键
|
|
|
+ * @return R
|
|
|
+ */
|
|
|
+ @SysLog("批量删除维修原因")
|
|
|
+ @DeleteMapping("")
|
|
|
+ @PreAuthorize("@pms.hasPermission('repair-repair-reasons-del')")
|
|
|
+ public R removeIds(@RequestBody List<String> ids){
|
|
|
+ repairReasonService.batchDelete(ids);
|
|
|
+ return new R<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取分页
|
|
|
+ *
|
|
|
+ * @param pageNum 当前页码
|
|
|
+ * @param pageSize 每页条数
|
|
|
+ * @param repairReasonDTO 维修原因DTO
|
|
|
+ * @return R
|
|
|
+ */
|
|
|
+ @GetMapping("/page")
|
|
|
+ public R<AbstractPageResultBean<RepairReasonVO>> query(RepairReasonDTO repairReasonDTO, @RequestParam(defaultValue = "1") int pageNum, @RequestParam(defaultValue = "20") int pageSize) {
|
|
|
+ return new R<>(repairReasonService.selectPageList(repairReasonDTO, pageNum, pageSize));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取列表
|
|
|
+ *
|
|
|
+ * @param repairReasonDTO 维修原因DTO
|
|
|
+ * @return R
|
|
|
+ */
|
|
|
+ @GetMapping("")
|
|
|
+ public R query(RepairReasonDTO repairReasonDTO) {
|
|
|
+ return new R<>(repairReasonService.getModelListByDTO(repairReasonDTO));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 维修原因导出
|
|
|
+ *
|
|
|
+ * @param repairReasonDTO 维修原因DTO
|
|
|
+ * @return R
|
|
|
+ */
|
|
|
+ @GetMapping("/export")
|
|
|
+ @SysLog("维修原因导出")
|
|
|
+ @PreAuthorize("@pms.hasPermission('repair-repair-reasons-export')")
|
|
|
+ public void export(HttpServletResponse response, RepairReasonDTO repairReasonDTO) {
|
|
|
+ List<RepairReason> list = repairReasonService.getModelListByDTO(repairReasonDTO);
|
|
|
+ ExcelUtil.exportResponseDict(response, ExportRepairReasonVO.class, BeanConverterUtil.copyListProperties(list, ExportRepairReasonVO.class), "维修原因");
|
|
|
+ }
|
|
|
+
|
|
|
+}
|