xuhy
2024-08-15 98e7dc8c77c30a6cad499a4a12b5334da1fe16d7
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
package com.ruoyi.web.controller.monitor;
 
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.service.ISysOperLogService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.ArrayList;
import java.util.List;
 
/**
 * 操作日志记录
 * 
 * @author ruoyi
 */
@Slf4j
@Api(tags = "操作日志记录")
@RestController
@RequestMapping("/monitor/operlog")
public class SysOperlogController extends BaseController
{
    @Autowired
    private ISysOperLogService operLogService;
 
//    @ApiOperation(value = "操作日志分页列表")
//    @PostMapping("/list")
//    public AjaxResult list(@RequestBody SysOperLogQuery query)
//    {
//        startPage(query.getPageNum(), query.getPageSize());
//        List<SysOperLogVO> list = operLogService.selectOperLogPageList(query);
//        operLogService.getLogDetail(list);
//        return AjaxResult.success(getDataTable(list));
//    }
 
    /**
     * 查询操作日志列表导出
     */
//    @ApiOperation(value = "查询操作日志列表导出")
//    @Log(title = "操作日志-查询操作日志列表导出", businessType = BusinessType.EXPORT)
//    @PostMapping("/exportOperLog")
//    public void exportOperLog(@RequestBody SysOperLogQuery query)
//    {
//        List<SysOperLogVO> list = operLogService.selectOperLogPageList(query);
//        List<TOperLogExport> operLogExports = new ArrayList<>();
//        for (SysOperLogVO sysOperLogVO : list) {
//            TOperLogExport operLogExport = new TOperLogExport();
//            BeanUtils.copyProperties(sysOperLogVO,operLogExport);
//            operLogService.getLogDetail(list);
//            operLogExports.add(operLogExport);
//        }
//        Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TOperLogExport.class, operLogExports);
//        HttpServletResponse response = WebUtils.response();
//        response.setContentType("application/vnd.ms-excel");
//        response.setCharacterEncoding("utf-8");
//        ServletOutputStream outputStream = null;
//        try {
//            String fileName = URLEncoder.encode("操作日志信息.xls", "utf-8");
//            response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
//            response.setContentType("application/vnd.ms-excel;charset=UTF-8");
//            response.setHeader("Pragma", "no-cache");
//            response.setHeader("Cache-Control", "no-cache");
//            outputStream = response.getOutputStream();
//            workbook.write(outputStream);
//        } catch (IOException e) {
//            e.printStackTrace();
//            log.error("操作日志导出信息导出失败!");
//        } finally {
//            try {
//                outputStream.close();
//            } catch (IOException e) {
//                e.printStackTrace();
//            }
//        }
//    }
 
//    @Log(title = "操作日志", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, SysOperLog operLog)
//    {
//        List<SysOperLog> list = operLogService.selectOperLogList(operLog);
//        ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class);
//        util.exportExcel(response, list, "操作日志");
//    }
 
    @Log(title = "操作日志", businessType = BusinessType.DELETE)
    @DeleteMapping("/deleteById/{operIds}")
    public AjaxResult remove(@PathVariable String operIds)
    {
        String[] split = operIds.split(",");
        List<Long> id = new ArrayList<>();
        for (String s : split) {
            id.add(Long.valueOf(s));
        }
        return AjaxResult.success(operLogService.deleteOperLogByIds(id));
    }
 
    @Log(title = "操作日志", businessType = BusinessType.CLEAN)
    @DeleteMapping("/clean")
    public AjaxResult clean()
    {
        operLogService.cleanOperLog();
        return success();
    }
}