cjl
2023-11-15 28776b56db3bbd2fbbfd64394e40aa11a6b7ea29
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
package com.moral.api.controller;
 
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.Map;
 
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.moral.api.entity.UserLog;
import com.moral.api.service.UserLogService;
import com.moral.constant.ResultMessage;
import com.moral.util.PageResult;
 
@Slf4j
@RestController
@RequestMapping("/log")
@Api(tags = "日志管理")
public class LogController {
 
    @Autowired
    private UserLogService userLogService;
 
    @ApiOperation(value = "分页查询日志", notes = "分页查询日志")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "当前页", required = false, paramType = "query", dataType = "Integer"),
            @ApiImplicitParam(name = "size", value = "每页条数", required = false, paramType = "query", dataType = "Integer"),
            @ApiImplicitParam(name = "type", value = "操作类型,0:登陆,1:添加,2:修改,3:删除", required = false, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String")
    })
    @RequestMapping(value = "select", method = RequestMethod.POST)
    public ResultMessage select(@RequestBody Map<String, Object> parameters) {
        Page<UserLog> userLogPage = userLogService.selectLogs(parameters);
        PageResult pageResult = new PageResult<>(
                userLogPage.getTotal(), userLogPage.getPages(), userLogPage.getRecords()
        );
        return ResultMessage.ok(pageResult);
    }
}