package com.qmth.sop.server.api;


import com.qmth.boot.api.constant.ApiConstant;
import com.qmth.sop.business.bean.result.SysLogResult;
import com.qmth.sop.business.service.SysLogService;
import com.qmth.sop.common.contant.SystemConstant;
import com.qmth.sop.common.util.Result;
import com.qmth.sop.common.util.ResultUtil;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;

/**
 * <p>
 * 系统日志 前端控制器
 * </p>
 *
 * @author wangliang
 * @since 2023-08-01
 */
@Api(tags = "日志管理前端控制器")
@RestController
@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + SystemConstant.PREFIX_URL_LOG)
public class SysLogController {
    @Resource
    private SysLogService sysLogService;

    @ApiOperation(value = "日志管理-查询")
    @RequestMapping(value = "/page", method = RequestMethod.POST)
    @ApiResponses({@ApiResponse(code = 200, message = "查询成功", response = SysLogResult.class)})
    public Result findLogPage(@ApiParam(value = "起始时间") @RequestParam(required = false) Long startTime,
                              @ApiParam(value = "截止时间") @RequestParam(required = false) Long endTime,
                              @ApiParam(value = "内容") @RequestParam(required = false) String content,
                              @ApiParam(value = "分页页码", required = true) @RequestParam @Min(SystemConstant.PAGE_NUMBER_MIN) Integer pageNumber,
                              @ApiParam(value = "分页数", required = true) @RequestParam @Min(SystemConstant.PAGE_SIZE_MIN) @Max(SystemConstant.PAGE_SIZE_MAX) Integer pageSize) {

        return ResultUtil.ok(sysLogService.page(startTime, endTime, content, pageNumber, pageSize));
    }
}
