龚焕茏
2024-03-11 2bacd2670e0f1b495e9cfda6023d8bccc32a5572
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
package org.dromara.demo.controller;
 
import java.util.List;
 
import lombok.RequiredArgsConstructor;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.web.core.BaseController;
import org.dromara.common.mybatis.core.page.PageQuery;
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.log.enums.BusinessType;
import org.dromara.common.excel.utils.ExcelUtil;
import org.dromara.demo.domain.vo.RsTrafficAccidentVo;
import org.dromara.demo.domain.bo.RsTrafficAccidentBo;
import org.dromara.demo.service.IRsTrafficAccidentService;
import org.dromara.common.mybatis.core.page.TableDataInfo;
 
/**
 * 交通事故
 *
 * @author gonghl
 * @date 2024-03-11
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/demo/trafficAccident")
public class RsTrafficAccidentController extends BaseController {
 
    private final IRsTrafficAccidentService rsTrafficAccidentService;
 
    /**
     * 查询交通事故列表
     */
    @SaCheckPermission("demo:trafficAccident:list")
    @GetMapping("/list")
    public TableDataInfo<RsTrafficAccidentVo> list(RsTrafficAccidentBo bo, PageQuery pageQuery) {
        return rsTrafficAccidentService.queryPageList(bo, pageQuery);
    }
 
    /**
     * 导出交通事故列表
     */
    @SaCheckPermission("demo:trafficAccident:export")
    @Log(title = "交通事故", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(RsTrafficAccidentBo bo, HttpServletResponse response) {
        List<RsTrafficAccidentVo> list = rsTrafficAccidentService.queryList(bo);
        ExcelUtil.exportExcel(list, "交通事故", RsTrafficAccidentVo.class, response);
    }
 
    /**
     * 获取交通事故详细信息
     *
     * @param id 主键
     */
    @SaCheckPermission("demo:trafficAccident:query")
    @GetMapping("/{id}")
    public R<RsTrafficAccidentVo> getInfo(@NotNull(message = "主键不能为空")
                                     @PathVariable String id) {
        return R.ok(rsTrafficAccidentService.queryById(id));
    }
 
    /**
     * 新增交通事故
     */
    @SaCheckPermission("demo:trafficAccident:add")
    @Log(title = "交通事故", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody RsTrafficAccidentBo bo) {
        return toAjax(rsTrafficAccidentService.insertByBo(bo));
    }
 
    /**
     * 修改交通事故
     */
    @SaCheckPermission("demo:trafficAccident:edit")
    @Log(title = "交通事故", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody RsTrafficAccidentBo bo) {
        return toAjax(rsTrafficAccidentService.updateByBo(bo));
    }
 
    /**
     * 删除交通事故
     *
     * @param ids 主键串
     */
    @SaCheckPermission("demo:trafficAccident:remove")
    @Log(title = "交通事故", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable String[] ids) {
        return toAjax(rsTrafficAccidentService.deleteWithValidByIds(List.of(ids), true));
    }
}