xuhy
2025-04-30 fd345592daef5f203af84eeb4fa33fd989a2ba66
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
package com.ruoyi.admin.controller.large;
 
 
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.admin.large.model.AnalysisServiceIndexChildData;
import com.ruoyi.admin.large.model.AnalysisServiceIndexData;
import com.ruoyi.admin.large.service.AnalysisServiceIndexChildDataService;
import com.ruoyi.admin.large.service.AnalysisServiceIndexDataService;
import com.ruoyi.admin.service.SysUserService;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.security.service.TokenService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
import java.util.stream.Collectors;
 
/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xiaochen
 * @since 2025-04-21
 */
@Api(tags = {"大屏-服务指标分析渠道商"})
@RestController
@RequestMapping("/analysis-service-index-data")
public class AnalysisServiceIndexDataController {
 
    private final AnalysisServiceIndexDataService analysisServiceIndexDataService;
    private final AnalysisServiceIndexChildDataService analysisServiceIndexChildDataService;
    private final TokenService tokenService;
    private final SysUserService sysUserService;
 
    @Autowired
    public AnalysisServiceIndexDataController(AnalysisServiceIndexDataService analysisServiceIndexDataService, AnalysisServiceIndexChildDataService analysisServiceIndexChildDataService, TokenService tokenService, SysUserService sysUserService) {
        this.analysisServiceIndexDataService = analysisServiceIndexDataService;
        this.analysisServiceIndexChildDataService = analysisServiceIndexChildDataService;
        this.tokenService = tokenService;
        this.sysUserService = sysUserService;
    }
 
    /**
     * 查询服务指标分析渠道商列表
     */
    @ApiOperation( value = "查询服务指标分析渠道商列表")
    @PostMapping(value = "/list")
    public R<List<AnalysisServiceIndexData>> list() {
        List<AnalysisServiceIndexData> list = analysisServiceIndexDataService.list();
        List<AnalysisServiceIndexChildData> analysisServiceIndexChildDataList = analysisServiceIndexChildDataService.list();
        for (AnalysisServiceIndexData analysisServiceIndexData : list) {
            List<AnalysisServiceIndexChildData> indexChildDataList = analysisServiceIndexChildDataList.stream().filter(e -> e.getServiceIndexId().equals(analysisServiceIndexData.getId())).collect(Collectors.toList());
            analysisServiceIndexData.setAnalysisServiceIndexChildDataList(indexChildDataList);
        }
        return R.ok(list);
    }
    /**
     * 查询服务指标分析渠道商列表
     */
    @ApiOperation( value = "查询服务指标分析渠道商列表-大屏")
    @PostMapping(value = "/largeList")
    public R<List<AnalysisServiceIndexData>> largeList() {
        List<AnalysisServiceIndexData> list = analysisServiceIndexDataService.list();
        List<AnalysisServiceIndexChildData> analysisServiceIndexChildDataList = analysisServiceIndexChildDataService.list();
        for (AnalysisServiceIndexData analysisServiceIndexData : list) {
            List<AnalysisServiceIndexChildData> indexChildDataList = analysisServiceIndexChildDataList.stream().filter(e -> e.getServiceIndexId().equals(analysisServiceIndexData.getId())).collect(Collectors.toList());
            analysisServiceIndexData.setAnalysisServiceIndexChildDataList(indexChildDataList);
        }
        return R.ok(list);
    }
 
 
    /**
     * 添加服务指标分析渠道商管理
     */
    @ApiOperation( value = "添加服务指标分析渠道商")
    @PostMapping(value = "/add")
    public R<Boolean> add(@RequestBody AnalysisServiceIndexData dto) {
        return R.ok(analysisServiceIndexDataService.save(dto));
    }
 
    /**
     * 删除服务指标分析渠道商
     */
    @ApiOperation( value = "删除服务指标分析渠道商")
    @DeleteMapping(value = "/deleteById")
    public R<Boolean> deleteById(@RequestParam("id") Long id) {
        // 删除服务指标分析
        analysisServiceIndexChildDataService.remove(Wrappers.lambdaQuery(AnalysisServiceIndexChildData.class)
                .eq(AnalysisServiceIndexChildData::getServiceIndexId, id));
        return R.ok(analysisServiceIndexDataService.removeById(id));
    }
 
}