123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- package com.jjt.biz.controller;
- import com.jjt.biz.domain.MetricsDef;
- import com.jjt.biz.service.IMetricsDefService;
- import com.jjt.common.annotation.Log;
- import com.jjt.common.core.controller.BaseController;
- import com.jjt.common.core.domain.AjaxResult;
- import com.jjt.common.core.page.TableDataInfo;
- import com.jjt.common.enums.BusinessType;
- import com.jjt.common.utils.poi.ExcelUtil;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import org.springframework.security.access.prepost.PreAuthorize;
- import org.springframework.web.bind.annotation.*;
- import javax.annotation.Resource;
- import javax.servlet.http.HttpServletResponse;
- import java.util.List;
- /**
- * 指标定义Controller
- *
- * @author jjt
- * @date 2024-08-08
- */
- @Api(tags = "指标定义")
- @RestController
- @RequestMapping("/metrics/def")
- public class MetricsDefController extends BaseController {
- @Resource
- private IMetricsDefService metricsDefService;
- /**
- * 查询指标定义列表
- */
- @ApiOperation("查询指标定义列表")
- @PreAuthorize("@ss.hasPermi('metrics:def:list')")
- @GetMapping("/list")
- public TableDataInfo list(MetricsDef metricsDef) {
- startPage();
- List<MetricsDef> list = metricsDefService.selectMetricsDefList(metricsDef);
- return getDataTable(list);
- }
- /**
- * 导出指标定义列表
- */
- @ApiOperation("导出指标定义列表")
- @PreAuthorize("@ss.hasPermi('metrics:def:export')")
- @Log(title = "指标定义", businessType = BusinessType.EXPORT)
- @PostMapping("/export")
- public void export(HttpServletResponse response, MetricsDef metricsDef) {
- List<MetricsDef> list = metricsDefService.selectMetricsDefList(metricsDef);
- ExcelUtil<MetricsDef> util = new ExcelUtil<MetricsDef>(MetricsDef.class);
- util.exportExcel(response, list, "指标定义数据");
- }
- /**
- * 获取指标定义详细信息
- */
- @ApiOperation("获取指标定义详细信息")
- @PreAuthorize("@ss.hasPermi('metrics:def:query')")
- @GetMapping(value = "/{metricsId}")
- public AjaxResult getInfo(@PathVariable("metricsId") Long metricsId) {
- MetricsDef def = metricsDefService.selectMetricsDefByMetricsId(metricsId);
- return success(def);
- }
- /**
- * 新增指标定义
- */
- @ApiOperation("新增指标定义")
- @PreAuthorize("@ss.hasPermi('metrics:def:add')")
- @Log(title = "指标定义", businessType = BusinessType.INSERT)
- @PostMapping
- public AjaxResult add(@RequestBody MetricsDef metricsDef) {
- int r = metricsDefService.insertMetricsDef(metricsDef);
- metricsDef.setMetricsCode("D_" + (10000 + metricsDef.getMetricsId()));
- metricsDefService.updateMetricsDef(metricsDef);
- return toAjax(r);
- }
- /**
- * 修改指标定义
- */
- @ApiOperation("修改指标定义")
- @PreAuthorize("@ss.hasPermi('metrics:def:edit')")
- @Log(title = "指标定义", businessType = BusinessType.UPDATE)
- @PostMapping("/edit")
- public AjaxResult edit(@RequestBody MetricsDef metricsDef) {
- return toAjax(metricsDefService.updateMetricsDef(metricsDef));
- }
- /**
- * 删除指标定义
- */
- @ApiOperation("删除指标定义")
- @PreAuthorize("@ss.hasPermi('metrics:def:remove')")
- @Log(title = "指标定义", businessType = BusinessType.DELETE)
- @GetMapping("/del/{metricsIds}")
- public AjaxResult remove(@PathVariable Long[] metricsIds) {
- return toAjax(metricsDefService.deleteMetricsDefByMetricsIds(metricsIds));
- }
- }
|