com.github.javaclub.base.web.SysLogController Maven / Gradle / Ivy
package com.github.javaclub.base.web;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.github.javaclub.base.annotation.WithApiResult;
import com.github.javaclub.base.domain.SysLog;
import com.github.javaclub.base.domain.query.SysLogQuery;
import com.github.javaclub.base.service.SysLogService;
import com.github.javaclub.sword.BizException;
import com.github.javaclub.sword.domain.QueryResult;
import com.github.javaclub.sword.web.PageResultSet;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
/**
* 系统日志
*/
@RestController
@RequestMapping("/sys/log")
@AllArgsConstructor
@Api(tags = "管理端: 系统日志")
@WithApiResult
public class SysLogController {
private final SysLogService sysLogService;
@PostMapping("/page")
@PreAuthorize("@pms.hasPermission('sys:log:page')")
@ApiOperation(value = "日志列表查询")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "鉴权token", paramType = "header", dataType = "string", required = true)
})
public PageResultSet page(@RequestBody SysLogQuery query) {
QueryResult qr = sysLogService.findListWithCount(query);
if (!qr.isSuccess()) {
throw new BizException("查询列表失败!");
}
return PageResultSet.build(query.getPageNo(), query.getPageSize(), qr.getTotalCount(), qr.getEntry());
}
}