|
@@ -0,0 +1,139 @@
|
|
|
|
+package com.platform.rest.controller.customize;
|
|
|
|
+
|
|
|
|
+import com.platform.common.util.R;
|
|
|
|
+import com.platform.dao.dto.customize.CustomizeReportDTO;
|
|
|
|
+import com.platform.dao.entity.customize.CustomizeReport;
|
|
|
|
+import com.platform.service.customize.CustomizeReportService;
|
|
|
|
+import com.platform.dao.util.ExcelUtil;
|
|
|
|
+import com.platform.dao.vo.export.customize.ExportCustomizeReportVO;
|
|
|
|
+import com.platform.dao.vo.query.customize.CustomizeReportVO;
|
|
|
|
+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 xc
|
|
|
|
+ * @Date 2022-04-15 10:26:43
|
|
|
|
+ * @Version Copyright (c) 2020,北京乾元坤和科技有限公司 All rights reserved.
|
|
|
|
+ */
|
|
|
|
+@RestController
|
|
|
|
+@AllArgsConstructor
|
|
|
|
+@RequestMapping("/customize/reports")
|
|
|
|
+public class CustomizeReportController {
|
|
|
|
+
|
|
|
|
+ private final CustomizeReportService customizeReportService;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 通过id查询单条记录
|
|
|
|
+ *
|
|
|
|
+ * @param id 主键
|
|
|
|
+ * @return R
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/{id}")
|
|
|
|
+ public R<CustomizeReport> getById(@PathVariable("id") String id){
|
|
|
|
+ return new R<>(customizeReportService.getModelById(id));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 新增记录
|
|
|
|
+ *
|
|
|
|
+ * @param customizeReportDTO 自定义报表DTO
|
|
|
|
+ * @return R
|
|
|
|
+ */
|
|
|
|
+ @SysLog("新增自定义报表")
|
|
|
|
+ @PostMapping
|
|
|
|
+ @PreAuthorize("@pms.hasPermission('customize-reports-add')")
|
|
|
|
+ public R save(@Validated({AddGroup.class}) @RequestBody CustomizeReportDTO customizeReportDTO) {
|
|
|
|
+ return new R<>(customizeReportService.saveModelByDTO(customizeReportDTO));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 修改记录
|
|
|
|
+ *
|
|
|
|
+ * @param customizeReportDTO 自定义报表DTO
|
|
|
|
+ * @return R
|
|
|
|
+ */
|
|
|
|
+ @SysLog("修改自定义报表")
|
|
|
|
+ @PutMapping("/{id}")
|
|
|
|
+ @PreAuthorize("@pms.hasPermission('customize-reports-edit')")
|
|
|
|
+ public R update(@PathVariable("id") String id, @Validated({UpdateGroup.class}) @RequestBody CustomizeReportDTO customizeReportDTO) {
|
|
|
|
+ customizeReportService.modModelByDTO(customizeReportDTO);
|
|
|
|
+ return new R<>();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 通过id删除一条记录
|
|
|
|
+ *
|
|
|
|
+ * @param id 主键
|
|
|
|
+ * @return R
|
|
|
|
+ */
|
|
|
|
+ @SysLog("删除自定义报表")
|
|
|
|
+ @DeleteMapping("/{id}")
|
|
|
|
+ @PreAuthorize("@pms.hasPermission('customize-reports-del')")
|
|
|
|
+ public R removeById(@PathVariable String id){
|
|
|
|
+ customizeReportService.deleteByPrimaryKey(id);
|
|
|
|
+ return new R<>();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 批量记录
|
|
|
|
+ *
|
|
|
|
+ * @param ids 主键
|
|
|
|
+ * @return R
|
|
|
|
+ */
|
|
|
|
+ @SysLog("批量删除自定义报表")
|
|
|
|
+ @DeleteMapping("")
|
|
|
|
+ @PreAuthorize("@pms.hasPermission('customize-reports-del')")
|
|
|
|
+ public R removeIds(@RequestBody List<String> ids){
|
|
|
|
+ customizeReportService.batchDelete(ids);
|
|
|
|
+ return new R<>();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取分页
|
|
|
|
+ *
|
|
|
|
+ * @param pageNum 当前页码
|
|
|
|
+ * @param pageSize 每页条数
|
|
|
|
+ * @param customizeReportDTO 自定义报表DTO
|
|
|
|
+ * @return R
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/page")
|
|
|
|
+ public R<AbstractPageResultBean<CustomizeReportVO>> query(CustomizeReportDTO customizeReportDTO, @RequestParam(defaultValue = "1") int pageNum, @RequestParam(defaultValue = "20") int pageSize) {
|
|
|
|
+ return new R<>(customizeReportService.selectPageList(customizeReportDTO, pageNum, pageSize));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取列表
|
|
|
|
+ *
|
|
|
|
+ * @param customizeReportDTO 自定义报表DTO
|
|
|
|
+ * @return R
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("")
|
|
|
|
+ public R query(CustomizeReportDTO customizeReportDTO) {
|
|
|
|
+ return new R<>(customizeReportService.getModelListByDTO(customizeReportDTO));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 自定义报表导出
|
|
|
|
+ *
|
|
|
|
+ * @param customizeReportDTO 自定义报表DTO
|
|
|
|
+ * @return R
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/export")
|
|
|
|
+ @SysLog("自定义报表导出")
|
|
|
|
+ @PreAuthorize("@pms.hasPermission('customize-reports-export')")
|
|
|
|
+ public void export(HttpServletResponse response, CustomizeReportDTO customizeReportDTO) {
|
|
|
|
+ List<CustomizeReport> list = customizeReportService.getModelListByDTO(customizeReportDTO);
|
|
|
|
+ ExcelUtil.exportResponseDict(response, ExportCustomizeReportVO.class, BeanConverterUtil.copyListProperties(list, ExportCustomizeReportVO.class), "自定义报表");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|