6 天以前 0c23c1e9b9e06ffc570edac28ee45555b772b99c
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
package com.ruoyi.safety.controller;
 
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.safety.pojo.SafetyTrainingRecord;
import com.ruoyi.safety.service.SafetyTrainingRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.http.HttpServletResponse;
import java.util.List;
 
/**
 * 安环管理-培训完成记录接口。
 */
@RestController
@Api(tags = "安环管理-培训完成记录")
@RequestMapping("/safety/training/record")
public class SafetyTrainingRecordController extends SafetyControllerSupport {
 
    @Autowired
    private SafetyTrainingRecordService recordService;
 
    /**
     * 分页查询培训完成记录。
     */
    @Log(title = "安环管理-培训完成记录-分页查询", businessType = BusinessType.OTHER)
    @ApiOperation("分页查询培训完成记录")
    @GetMapping("/list")
    public AjaxResult list(Page<SafetyTrainingRecord> page, SafetyTrainingRecord query,
                           @RequestParam(value = "pageNum", required = false) Long pageNum,
                           @RequestParam(value = "pageSize", required = false) Long pageSize) {
        return AjaxResult.success(recordService.queryPage(buildPage(page, pageNum, pageSize), query));
    }
 
    /**
     * add training completion record.
     */
    @Log(title = "safety-training-record-add", businessType = BusinessType.INSERT)
    @ApiOperation("add safety training completion record")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody SafetyTrainingRecord record) {
        return toAjax(recordService.saveSafety(record));
    }
 
    /**
     * update training completion record.
     */
    @Log(title = "safety-training-record-update", businessType = BusinessType.UPDATE)
    @ApiOperation("update safety training completion record")
    @PutMapping("/update")
    public AjaxResult update(@RequestBody SafetyTrainingRecord record) {
        return toAjax(recordService.updateSafety(record));
    }
 
    /**
     * delete training completion record.
     */
    @Log(title = "safety-training-record-delete", businessType = BusinessType.DELETE)
    @ApiOperation("delete safety training completion record")
    @DeleteMapping("/delete/{id}")
    public AjaxResult delete(@PathVariable Long id) {
        return toAjax(recordService.deleteSafetyById(id));
    }
 
    /**
     * training completion record detail.
     */
    @Log(title = "safety-training-record-detail", businessType = BusinessType.OTHER)
    @ApiOperation("query safety training completion record detail")
    @GetMapping("/detail/{id}")
    public AjaxResult detail(@PathVariable Long id) {
        return AjaxResult.success(recordService.getById(id));
    }
 
    /**
     * 导出培训完成记录。
     */
    @Log(title = "安环管理-培训完成记录-导出", businessType = BusinessType.EXPORT)
    @ApiOperation("导出培训完成记录")
    @GetMapping("/export")
    public void export(HttpServletResponse response, SafetyTrainingRecord query) {
        List<SafetyTrainingRecord> records = recordService.queryPage(new Page<SafetyTrainingRecord>(1, -1), query)
                .getRecords();
        ExcelUtil<SafetyTrainingRecord> util = new ExcelUtil<SafetyTrainingRecord>(SafetyTrainingRecord.class);
        util.exportExcel(response, records, "safety_training_record");
    }
}