MetricsDefController.java 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. package com.jjt.biz.controller;
  2. import com.jjt.biz.domain.MetricsDef;
  3. import com.jjt.biz.service.IMetricsDefService;
  4. import com.jjt.common.annotation.Log;
  5. import com.jjt.common.core.controller.BaseController;
  6. import com.jjt.common.core.domain.AjaxResult;
  7. import com.jjt.common.core.page.TableDataInfo;
  8. import com.jjt.common.enums.BusinessType;
  9. import com.jjt.common.utils.poi.ExcelUtil;
  10. import io.swagger.annotations.Api;
  11. import io.swagger.annotations.ApiOperation;
  12. import org.springframework.security.access.prepost.PreAuthorize;
  13. import org.springframework.web.bind.annotation.*;
  14. import javax.annotation.Resource;
  15. import javax.servlet.http.HttpServletResponse;
  16. import java.util.List;
  17. /**
  18. * 指标定义Controller
  19. *
  20. * @author jjt
  21. * @date 2024-08-08
  22. */
  23. @Api(tags = "指标定义")
  24. @RestController
  25. @RequestMapping("/metrics/def")
  26. public class MetricsDefController extends BaseController {
  27. @Resource
  28. private IMetricsDefService metricsDefService;
  29. /**
  30. * 查询指标定义列表
  31. */
  32. @ApiOperation("查询指标定义列表")
  33. @PreAuthorize("@ss.hasPermi('metrics:def:list')")
  34. @GetMapping("/list")
  35. public TableDataInfo list(MetricsDef metricsDef) {
  36. startPage();
  37. List<MetricsDef> list = metricsDefService.selectMetricsDefList(metricsDef);
  38. return getDataTable(list);
  39. }
  40. /**
  41. * 导出指标定义列表
  42. */
  43. @ApiOperation("导出指标定义列表")
  44. @PreAuthorize("@ss.hasPermi('metrics:def:export')")
  45. @Log(title = "指标定义", businessType = BusinessType.EXPORT)
  46. @PostMapping("/export")
  47. public void export(HttpServletResponse response, MetricsDef metricsDef) {
  48. List<MetricsDef> list = metricsDefService.selectMetricsDefList(metricsDef);
  49. ExcelUtil<MetricsDef> util = new ExcelUtil<MetricsDef>(MetricsDef.class);
  50. util.exportExcel(response, list, "指标定义数据");
  51. }
  52. /**
  53. * 获取指标定义详细信息
  54. */
  55. @ApiOperation("获取指标定义详细信息")
  56. @PreAuthorize("@ss.hasPermi('metrics:def:query')")
  57. @GetMapping(value = "/{metricsId}")
  58. public AjaxResult getInfo(@PathVariable("metricsId") Long metricsId) {
  59. MetricsDef def = metricsDefService.selectMetricsDefByMetricsId(metricsId);
  60. return success(def);
  61. }
  62. /**
  63. * 新增指标定义
  64. */
  65. @ApiOperation("新增指标定义")
  66. @PreAuthorize("@ss.hasPermi('metrics:def:add')")
  67. @Log(title = "指标定义", businessType = BusinessType.INSERT)
  68. @PostMapping
  69. public AjaxResult add(@RequestBody MetricsDef metricsDef) {
  70. int r = metricsDefService.insertMetricsDef(metricsDef);
  71. metricsDef.setMetricsCode("D_" + (10000 + metricsDef.getMetricsId()));
  72. metricsDefService.updateMetricsDef(metricsDef);
  73. return toAjax(r);
  74. }
  75. /**
  76. * 修改指标定义
  77. */
  78. @ApiOperation("修改指标定义")
  79. @PreAuthorize("@ss.hasPermi('metrics:def:edit')")
  80. @Log(title = "指标定义", businessType = BusinessType.UPDATE)
  81. @PostMapping("/edit")
  82. public AjaxResult edit(@RequestBody MetricsDef metricsDef) {
  83. return toAjax(metricsDefService.updateMetricsDef(metricsDef));
  84. }
  85. /**
  86. * 删除指标定义
  87. */
  88. @ApiOperation("删除指标定义")
  89. @PreAuthorize("@ss.hasPermi('metrics:def:remove')")
  90. @Log(title = "指标定义", businessType = BusinessType.DELETE)
  91. @GetMapping("/del/{metricsIds}")
  92. public AjaxResult remove(@PathVariable Long[] metricsIds) {
  93. return toAjax(metricsDefService.deleteMetricsDefByMetricsIds(metricsIds));
  94. }
  95. }