|
@@ -0,0 +1,141 @@
|
|
|
+package com.platform.rest.controller.hidden;
|
|
|
+
|
|
|
+import com.platform.common.util.R;
|
|
|
+import com.platform.dao.dto.hidden.HiddenDangerDTO;
|
|
|
+import com.platform.dao.entity.hidden.HiddenDanger;
|
|
|
+import com.platform.service.hidden.HiddenDangerService;
|
|
|
+import com.platform.dao.util.ExcelUtil;
|
|
|
+import com.platform.dao.vo.export.hidden.ExportHiddenDangerVO;
|
|
|
+import com.platform.dao.vo.query.hidden.HiddenDangerVO;
|
|
|
+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 lsq
|
|
|
+ * @Date 2022-12-14 16:19:10
|
|
|
+ * @Version Copyright (c) 2020,北京乾元坤和科技有限公司 All rights reserved.
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@AllArgsConstructor
|
|
|
+@RequestMapping("/hidden/dangers")
|
|
|
+public class HiddenDangerController {
|
|
|
+
|
|
|
+ private final HiddenDangerService hiddenDangerService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过id查询单条记录
|
|
|
+ *
|
|
|
+ * @param id 主键
|
|
|
+ * @return R
|
|
|
+ */
|
|
|
+ @GetMapping("/{id}")
|
|
|
+ public R<HiddenDanger> getById(@PathVariable("id") String id){
|
|
|
+ return new R<>(hiddenDangerService.getModelById(id));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增记录
|
|
|
+ *
|
|
|
+ * @param hiddenDangerDTO 隐患管理表DTO
|
|
|
+ * @return R
|
|
|
+ */
|
|
|
+ @SysLog("新增隐患管理表")
|
|
|
+ @PostMapping
|
|
|
+ @PreAuthorize("@pms.hasPermission('hidden-dangers-add')")
|
|
|
+ public R save(@Validated({AddGroup.class}) @RequestBody HiddenDangerDTO hiddenDangerDTO) {
|
|
|
+ return new R<>(hiddenDangerService.saveModelByDTO(hiddenDangerDTO));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改记录
|
|
|
+ *
|
|
|
+ * @param hiddenDangerDTO 隐患管理表DTO
|
|
|
+ * @return R
|
|
|
+ */
|
|
|
+ @SysLog("修改隐患管理表")
|
|
|
+ @PutMapping("/{id}")
|
|
|
+ @PreAuthorize("@pms.hasPermission('hidden-dangers-edit')")
|
|
|
+ public R update(@PathVariable("id") String id, @Validated({UpdateGroup.class}) @RequestBody HiddenDangerDTO hiddenDangerDTO) {
|
|
|
+ hiddenDangerService.modModelByDTO(hiddenDangerDTO);
|
|
|
+ return new R<>();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过id删除一条记录
|
|
|
+ *
|
|
|
+ * @param id 主键
|
|
|
+ * @return R
|
|
|
+ */
|
|
|
+ @SysLog("删除隐患管理表")
|
|
|
+ @DeleteMapping("/{id}")
|
|
|
+ @PreAuthorize("@pms.hasPermission('hidden-dangers-del')")
|
|
|
+ public R removeById(@PathVariable String id){
|
|
|
+ hiddenDangerService.deleteByPrimaryKey(id);
|
|
|
+ return new R<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量记录
|
|
|
+ *
|
|
|
+ * @param ids 主键
|
|
|
+ * @return R
|
|
|
+ */
|
|
|
+ @SysLog("批量删除隐患管理表")
|
|
|
+ @DeleteMapping("")
|
|
|
+ @PreAuthorize("@pms.hasPermission('hidden-dangers-del')")
|
|
|
+ public R removeIds(@RequestBody List<String> ids){
|
|
|
+ hiddenDangerService.batchDelete(ids);
|
|
|
+ return new R<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取分页
|
|
|
+ *
|
|
|
+ * @param pageNum 当前页码
|
|
|
+ * @param pageSize 每页条数
|
|
|
+ * @param hiddenDangerDTO 隐患管理表DTO
|
|
|
+ * @return R
|
|
|
+ */
|
|
|
+ @GetMapping("/page")
|
|
|
+ public R<AbstractPageResultBean<HiddenDangerVO>> query(HiddenDangerDTO hiddenDangerDTO, @RequestParam(defaultValue = "1") int pageNum, @RequestParam(defaultValue = "20") int pageSize) {
|
|
|
+ return new R<>(hiddenDangerService.selectPageList(hiddenDangerDTO, pageNum, pageSize));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取列表
|
|
|
+ *
|
|
|
+ * @param hiddenDangerDTO 隐患管理表DTO
|
|
|
+ * @return R
|
|
|
+ */
|
|
|
+ @GetMapping("")
|
|
|
+ public R query(HiddenDangerDTO hiddenDangerDTO) {
|
|
|
+ return new R<>(hiddenDangerService.getModelListByDTO(hiddenDangerDTO));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 隐患管理表导出
|
|
|
+ *
|
|
|
+ * @param hiddenDangerDTO 隐患管理表DTO
|
|
|
+ * @return R
|
|
|
+ */
|
|
|
+ @GetMapping("/export")
|
|
|
+ @SysLog("隐患管理表导出")
|
|
|
+ @PreAuthorize("@pms.hasPermission('hidden-dangers-export')")
|
|
|
+ public void export(HttpServletResponse response, HiddenDangerDTO hiddenDangerDTO) {
|
|
|
+ List<HiddenDanger> list = hiddenDangerService.getModelListByDTO(hiddenDangerDTO);
|
|
|
+ ExcelUtil.exportResponseDict(response, ExportHiddenDangerVO.class, BeanConverterUtil.copyListProperties(list, ExportHiddenDangerVO.class), "隐患管理表");
|
|
|
+ }
|
|
|
+
|
|
|
+}
|