package top.tqx.demo_1.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.tqx.demo_1.common.PageResult;
import top.tqx.demo_1.common.Result;
import top.tqx.demo_1.service.LogService;
import top.tqx.demo_1.vo.OperationLogVO;

@Tag(name = "日志管理", description = "操作日志的查询")
@RestController
@RequestMapping("/log")
public class LogController {

    @Autowired
    private LogService logService;

    @Operation(summary = "分页查询日志", description = "根据条件分页查询操作日志")
    @GetMapping("/page")
    public Result<PageResult<OperationLogVO>> pageLogs(
            @Parameter(description = "页码", example = "1") @RequestParam(defaultValue = "1") Integer pageNum,
            @Parameter(description = "每页大小", example = "10") @RequestParam(defaultValue = "10") Integer pageSize,
            @Parameter(description = "用户名") @RequestParam(required = false) String username,
            @Parameter(description = "操作类型") @RequestParam(required = false) String operationType) {
        PageResult<OperationLogVO> result = logService.pageLogs(pageNum, pageSize, username, operationType);
        return Result.success(result);
    }
}