龚焕茏
2024-03-21 e17e3b7f70fa5abc8341e64f1ffce5813bae4bc3
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
package org.dromara.demo.controller;
 
import cn.dev33.satoken.annotation.SaCheckPermission;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import org.dromara.common.excel.utils.ExcelUtil;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.web.core.BaseController;
import org.dromara.demo.domain.bo.RsTrafficIndexBo;
import org.dromara.demo.domain.vo.RsTrafficIndexVo;
import org.dromara.demo.service.IRsTrafficIndexService;
import org.dromara.system.domain.SysOss;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
import java.util.Map;
 
/**
 * 交通指数
 *
 * @author Lion Li
 * @date 2024-02-26
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/rs/trafficIndex")
public class RsTrafficIndexController extends BaseController {
 
    private final IRsTrafficIndexService rsTrafficIndexService;
 
    /**
     * 查询交通指数列表
     */
    @SaCheckPermission("rs:trafficIndex:list")
    @GetMapping("/list")
    public TableDataInfo<RsTrafficIndexVo> list(RsTrafficIndexBo bo, PageQuery pageQuery) {
        return rsTrafficIndexService.queryPageList(bo, pageQuery);
    }
 
    /**
     * 查询交通指数图标配置
     */
    @SaCheckPermission("rs:trafficIndex:list")
    @GetMapping("/icon")
    public List<SysOss> icon() {
        return rsTrafficIndexService.icon();
    }
 
    /**
     * 导出交通指数列表
     */
    @SaCheckPermission("rs:trafficIndex:export")
    @Log(title = "交通指数", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(RsTrafficIndexBo bo, HttpServletResponse response) {
        List<RsTrafficIndexVo> list = rsTrafficIndexService.queryList(bo);
        ExcelUtil.exportExcel(list, "交通指数", RsTrafficIndexVo.class, response);
    }
 
    /**
     * 获取交通指数详细信息
     *
     * @param id 主键
     */
    @SaCheckPermission("rs:trafficIndex:query")
    @GetMapping("/{id}")
    public R<RsTrafficIndexVo> getInfo(@NotNull(message = "主键不能为空")
                                     @PathVariable Long id) {
        return R.ok(rsTrafficIndexService.queryById(id));
    }
 
    /**
     * 新增交通指数
     */
    @SaCheckPermission("rs:trafficIndex:add")
    @Log(title = "交通指数", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody RsTrafficIndexBo bo) {
        return toAjax(rsTrafficIndexService.insertByBo(bo));
    }
 
    /**
     * 修改交通指数
     */
    @SaCheckPermission("rs:trafficIndex:edit")
    @Log(title = "交通指数", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody RsTrafficIndexBo bo) {
        return toAjax(rsTrafficIndexService.updateByBo(bo));
    }
 
    /**
     * 删除交通指数
     *
     * @param ids 主键串
     */
    @SaCheckPermission("rs:trafficIndex:remove")
    @Log(title = "交通指数", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable Long[] ids) {
        return toAjax(rsTrafficIndexService.deleteWithValidByIds(List.of(ids), true));
    }
 
    /**
     * 上传图标
     * @param list 图标
     * @return 结果
     */
    @PostMapping("/uploadIcon")
    public R<String> uploadIcon(@RequestBody List<SysOss> list) {
        return rsTrafficIndexService.uploadIcon(list);
    }
 
}