mitao
2024-04-19 b21c37b7899b17dede7773db3c799aab1063ae1c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
package com.finance.web.controller.api;
 
 
import com.finance.common.core.domain.R;
import com.finance.common.exception.ServiceException;
import com.finance.system.dto.update.DataIndicatorsUpdDTO;
import com.finance.system.dto.update.FormalIndicatorsUpdDTO;
import com.finance.system.dto.update.RiskLevelUpdDTO;
import com.finance.system.query.DataScreenConfigQuery;
import com.finance.system.service.TbDataScreenConfigService;
import com.finance.system.vo.DataScreenConfigVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
/**
 * <p>
 * 大屏数据配置表 前端控制器
 * </p>
 *
 * @author mitao
 * @since 2024-03-13
 */
@Slf4j
@RestController
@RequestMapping("/data-screen-config")
@RequiredArgsConstructor
@Api(tags = {"大屏数据配置相关接口"})
public class TbDataScreenConfigController {
 
    private final TbDataScreenConfigService tbDataScreenConfigService;
 
    @PostMapping("/get-risk-level")
    @ApiOperation("获取风险等级设置")
    public R<DataScreenConfigVO> getRiskLevel() {
        try {
            return R.ok(tbDataScreenConfigService.getRiskLevel());
        } catch (Exception e) {
            if (e instanceof ServiceException) {
                return R.fail(e.getMessage());
            }
            throw new RuntimeException(e);
        }
    }
 
    @PostMapping("/edit-risk-level")
    @ApiOperation("编辑风险等级设置")
    public R<DataScreenConfigVO> editRiskLevel(
            @Validated @RequestBody RiskLevelUpdDTO dto) {
        try {
            return R.ok(tbDataScreenConfigService.editRiskLevel(dto));
        } catch (Exception e) {
            if (e instanceof ServiceException) {
                return R.fail(e.getMessage());
            }
            throw new RuntimeException(e);
        }
    }
 
    @PostMapping("/get-indicators")
    @ApiOperation("获取数据指标/形式指标级配置")
    public R<List<DataScreenConfigVO>> getIndicatorsConfig(
            @Validated @RequestBody DataScreenConfigQuery query) {
        try {
            return R.ok(tbDataScreenConfigService.getIndicatorsConfig(query.getType()));
        } catch (Exception e) {
            if (e instanceof ServiceException) {
                return R.fail(e.getMessage());
            }
            throw new RuntimeException(e);
        }
    }
 
    @PostMapping("/edit-data-indicators")
    @ApiOperation("编辑数据指标标级配置")
    public R<List<DataScreenConfigVO>> editDataIndicatorsConfig(
            @Validated @RequestBody List<DataIndicatorsUpdDTO> dtoList) {
        try {
            return R.ok(tbDataScreenConfigService.editDataIndicatorsConfig(dtoList));
        } catch (Exception e) {
            if (e instanceof ServiceException) {
                return R.fail(e.getMessage());
            }
            throw new RuntimeException(e);
        }
    }
 
    @PostMapping("/edit-formal-indicators")
    @ApiOperation("编辑形式指标标级配置")
    public R<List<DataScreenConfigVO>> editFormalIndicatorsConfig(
            @Validated @RequestBody List<FormalIndicatorsUpdDTO> dtoList) {
        try {
            return R.ok(tbDataScreenConfigService.editFormalIndicatorsConfig(dtoList));
        } catch (Exception e) {
            if (e instanceof ServiceException) {
                return R.fail(e.getMessage());
            }
            throw new RuntimeException(e);
        }
    }
}