调整 API 访问日志,从 system 归到 infra 更合适
This commit is contained in:
@@ -1,71 +0,0 @@
|
||||
package cn.iocoder.dashboard.modules.system.controller.logger;
|
||||
|
||||
import cn.iocoder.dashboard.common.pojo.CommonResult;
|
||||
import cn.iocoder.dashboard.common.pojo.PageResult;
|
||||
import cn.iocoder.dashboard.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.dashboard.framework.logger.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.dashboard.modules.system.controller.logger.vo.apiaccesslog.SysApiAccessLogExcelVO;
|
||||
import cn.iocoder.dashboard.modules.system.controller.logger.vo.apiaccesslog.SysApiAccessLogExportReqVO;
|
||||
import cn.iocoder.dashboard.modules.system.controller.logger.vo.apiaccesslog.SysApiAccessLogPageReqVO;
|
||||
import cn.iocoder.dashboard.modules.system.controller.logger.vo.apiaccesslog.SysApiAccessLogRespVO;
|
||||
import cn.iocoder.dashboard.modules.system.convert.logger.SysApiAccessLogConvert;
|
||||
import cn.iocoder.dashboard.modules.system.dal.dataobject.logger.SysApiAccessLogDO;
|
||||
import cn.iocoder.dashboard.modules.system.service.logger.SysApiAccessLogService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.dashboard.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.dashboard.framework.logger.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||
|
||||
@Api(tags = "API 访问日志")
|
||||
@RestController
|
||||
@RequestMapping("/system/api-access-log")
|
||||
@Validated
|
||||
public class SysApiAccessLogController {
|
||||
|
||||
@Resource
|
||||
private SysApiAccessLogService apiAccessLogService;
|
||||
|
||||
@GetMapping("/get")
|
||||
@ApiOperation("获得API 访问日志")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
|
||||
@PreAuthorize("@ss.hasPermission('system:api-access-log:query')")
|
||||
public CommonResult<SysApiAccessLogRespVO> getApiAccessLog(@RequestParam("id") Long id) {
|
||||
SysApiAccessLogDO apiAccessLog = apiAccessLogService.getApiAccessLog(id);
|
||||
return success(SysApiAccessLogConvert.INSTANCE.convert(apiAccessLog));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("获得API 访问日志分页")
|
||||
@PreAuthorize("@ss.hasPermission('system:api-access-log:query')")
|
||||
public CommonResult<PageResult<SysApiAccessLogRespVO>> getApiAccessLogPage(@Valid SysApiAccessLogPageReqVO pageVO) {
|
||||
PageResult<SysApiAccessLogDO> pageResult = apiAccessLogService.getApiAccessLogPage(pageVO);
|
||||
return success(SysApiAccessLogConvert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@ApiOperation("导出API 访问日志 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('system:api-access-log:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportApiAccessLogExcel(@Valid SysApiAccessLogExportReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<SysApiAccessLogDO> list = apiAccessLogService.getApiAccessLogList(exportReqVO);
|
||||
// 导出 Excel
|
||||
List<SysApiAccessLogExcelVO> datas = SysApiAccessLogConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "API 访问日志.xls", "数据", SysApiAccessLogExcelVO.class, datas);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
package cn.iocoder.dashboard.modules.system.controller.logger.vo.apiaccesslog;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Date;
|
||||
|
||||
import static cn.iocoder.dashboard.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
/**
|
||||
* API 访问日志 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Data
|
||||
public class SysApiAccessLogBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "链路追踪编号", required = true, example = "66600cb6-7852-11eb-9439-0242ac130002")
|
||||
@NotNull(message = "链路追踪编号不能为空")
|
||||
private String traceId;
|
||||
|
||||
@ApiModelProperty(value = "用户编号", required = true, example = "666")
|
||||
@NotNull(message = "用户编号不能为空")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty(value = "用户类型", required = true, example = "2", notes = "参见 UserTypeEnum 枚举")
|
||||
@NotNull(message = "用户类型不能为空")
|
||||
private Integer userType;
|
||||
|
||||
@ApiModelProperty(value = "应用名", required = true, example = "dashboard")
|
||||
@NotNull(message = "应用名不能为空")
|
||||
private String applicationName;
|
||||
|
||||
@ApiModelProperty(value = "请求方法名", required = true, example = "GET")
|
||||
@NotNull(message = "请求方法名不能为空")
|
||||
private String requestMethod;
|
||||
|
||||
@ApiModelProperty(value = "请求地址", required = true, example = "/xxx/yyy")
|
||||
@NotNull(message = "请求地址不能为空")
|
||||
private String requestUrl;
|
||||
|
||||
@ApiModelProperty(value = "Java 方法的参数")
|
||||
private String requestParams;
|
||||
|
||||
@ApiModelProperty(value = "用户 IP", required = true, example = "127.0.0.1")
|
||||
@NotNull(message = "用户 IP不能为空")
|
||||
private String userIp;
|
||||
|
||||
@ApiModelProperty(value = "浏览器 UA", required = true, example = "Mozilla/5.0")
|
||||
@NotNull(message = "浏览器 UA不能为空")
|
||||
private String userAgent;
|
||||
|
||||
@ApiModelProperty(value = "开始请求时间", required = true)
|
||||
@NotNull(message = "开始请求时间不能为空")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private Date beginTime;
|
||||
|
||||
@ApiModelProperty(value = "结束请求时间", required = true)
|
||||
@NotNull(message = "结束请求时间不能为空")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private Date endTime;
|
||||
|
||||
@ApiModelProperty(value = "执行时长", required = true, example = "100")
|
||||
@NotNull(message = "执行时长不能为空")
|
||||
private Integer duration;
|
||||
|
||||
@ApiModelProperty(value = "结果码", required = true, example = "0")
|
||||
@NotNull(message = "结果码不能为空")
|
||||
private Integer resultCode;
|
||||
|
||||
@ApiModelProperty(value = "结果提示", example = "芋道源码,牛逼!")
|
||||
private String resultMsg;
|
||||
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
package cn.iocoder.dashboard.modules.system.controller.logger.vo.apiaccesslog;
|
||||
|
||||
import cn.iocoder.dashboard.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.dashboard.framework.excel.core.convert.DictConvert;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static cn.iocoder.dashboard.modules.system.enums.dict.SysDictTypeEnum.USER_TYPE;
|
||||
|
||||
/**
|
||||
* API 访问日志 Excel VO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Data
|
||||
public class SysApiAccessLogExcelVO {
|
||||
|
||||
@ExcelProperty("日志主键")
|
||||
private Long id;
|
||||
|
||||
@ExcelProperty("链路追踪编号")
|
||||
private String traceId;
|
||||
|
||||
@ExcelProperty("用户编号")
|
||||
private Long userId;
|
||||
|
||||
@ExcelProperty(value = "用户类型", converter = DictConvert.class)
|
||||
@DictFormat(USER_TYPE)
|
||||
private Integer userType;
|
||||
|
||||
@ExcelProperty("应用名")
|
||||
private String applicationName;
|
||||
|
||||
@ExcelProperty("请求方法名")
|
||||
private String requestMethod;
|
||||
|
||||
@ExcelProperty("请求地址")
|
||||
private String requestUrl;
|
||||
|
||||
@ExcelProperty("Java 方法的参数")
|
||||
private String requestParams;
|
||||
|
||||
@ExcelProperty("用户 IP")
|
||||
private String userIp;
|
||||
|
||||
@ExcelProperty("浏览器 UA")
|
||||
private String userAgent;
|
||||
|
||||
@ExcelProperty("开始请求时间")
|
||||
private Date beginTime;
|
||||
|
||||
@ExcelProperty("结束请求时间")
|
||||
private Date endTime;
|
||||
|
||||
@ExcelProperty("执行时长")
|
||||
private Integer duration;
|
||||
|
||||
@ExcelProperty("结果码")
|
||||
private Integer resultCode;
|
||||
|
||||
@ExcelProperty("结果提示")
|
||||
private String resultMsg;
|
||||
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package cn.iocoder.dashboard.modules.system.controller.logger.vo.apiaccesslog;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static cn.iocoder.dashboard.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@ApiModel(value = "API 访问日志 Excel 导出 Request VO", description = "参数和 SysApiAccessLogPageReqVO 是一致的")
|
||||
@Data
|
||||
public class SysApiAccessLogExportReqVO {
|
||||
|
||||
@ApiModelProperty(value = "用户编号", example = "666")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty(value = "用户类型", example = "2")
|
||||
private Integer userType;
|
||||
|
||||
@ApiModelProperty(value = "应用名", example = "dashboard")
|
||||
private String applicationName;
|
||||
|
||||
@ApiModelProperty(value = "请求地址", example = "/xxx/yyy", notes = "模糊匹配")
|
||||
private String requestUrl;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始开始请求时间")
|
||||
private Date beginBeginTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束开始请求时间")
|
||||
private Date endBeginTime;
|
||||
|
||||
@ApiModelProperty(value = "执行时长", example = "100", notes = "大于等于,单位:毫秒")
|
||||
private Integer duration;
|
||||
|
||||
@ApiModelProperty(value = "结果码", example = "0")
|
||||
private Integer resultCode;
|
||||
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package cn.iocoder.dashboard.modules.system.controller.logger.vo.apiaccesslog;
|
||||
|
||||
import cn.iocoder.dashboard.common.pojo.PageParam;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static cn.iocoder.dashboard.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@ApiModel("API 访问日志分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class SysApiAccessLogPageReqVO extends PageParam {
|
||||
|
||||
@ApiModelProperty(value = "用户编号", example = "666")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty(value = "用户类型", example = "2")
|
||||
private Integer userType;
|
||||
|
||||
@ApiModelProperty(value = "应用名", example = "dashboard")
|
||||
private String applicationName;
|
||||
|
||||
@ApiModelProperty(value = "请求地址", example = "/xxx/yyy", notes = "模糊匹配")
|
||||
private String requestUrl;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始开始请求时间")
|
||||
private Date beginBeginTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束开始请求时间")
|
||||
private Date endBeginTime;
|
||||
|
||||
@ApiModelProperty(value = "执行时长", example = "100", notes = "大于等于,单位:毫秒")
|
||||
private Integer duration;
|
||||
|
||||
@ApiModelProperty(value = "结果码", example = "0")
|
||||
private Integer resultCode;
|
||||
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package cn.iocoder.dashboard.modules.system.controller.logger.vo.apiaccesslog;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ApiModel("API 访问日志 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class SysApiAccessLogRespVO extends SysApiAccessLogBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "日志主键", required = true, example = "1024")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "创建时间", required = true)
|
||||
private Date createTime;
|
||||
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package cn.iocoder.dashboard.modules.system.convert.logger;
|
||||
|
||||
import cn.iocoder.dashboard.common.pojo.PageResult;
|
||||
import cn.iocoder.dashboard.framework.logger.apilog.core.service.dto.ApiAccessLogCreateDTO;
|
||||
import cn.iocoder.dashboard.modules.system.controller.logger.vo.apiaccesslog.SysApiAccessLogExcelVO;
|
||||
import cn.iocoder.dashboard.modules.system.controller.logger.vo.apiaccesslog.SysApiAccessLogRespVO;
|
||||
import cn.iocoder.dashboard.modules.system.dal.dataobject.logger.SysApiAccessLogDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* API 访问日志 Convert
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysApiAccessLogConvert {
|
||||
|
||||
SysApiAccessLogConvert INSTANCE = Mappers.getMapper(SysApiAccessLogConvert.class);
|
||||
|
||||
SysApiAccessLogDO convert(ApiAccessLogCreateDTO bean);
|
||||
|
||||
SysApiAccessLogRespVO convert(SysApiAccessLogDO bean);
|
||||
|
||||
List<SysApiAccessLogRespVO> convertList(List<SysApiAccessLogDO> list);
|
||||
|
||||
PageResult<SysApiAccessLogRespVO> convertPage(PageResult<SysApiAccessLogDO> page);
|
||||
|
||||
List<SysApiAccessLogExcelVO> convertList02(List<SysApiAccessLogDO> list);
|
||||
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
<http://www.iocoder.cn/Spring-Boot/MapStruct/?dashboard>
|
||||
<http://www.iocoder.cn/Spring-Boot/MapStruct/?yudao>
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
package cn.iocoder.dashboard.modules.system.dal.dataobject.logger;
|
||||
|
||||
import cn.iocoder.dashboard.common.enums.UserTypeEnum;
|
||||
import cn.iocoder.dashboard.common.pojo.CommonResult;
|
||||
import cn.iocoder.dashboard.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* API 访问日志
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@TableName("sys_api_access_log")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SysApiAccessLogDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
@TableId
|
||||
private Integer id;
|
||||
/**
|
||||
* 链路追踪编号
|
||||
*
|
||||
* 一般来说,通过链路追踪编号,可以将访问日志,错误日志,链路追踪日志,logger 打印日志等,结合在一起,从而进行排错。
|
||||
*/
|
||||
private String traceId;
|
||||
/**
|
||||
* 用户编号
|
||||
*/
|
||||
private Integer userId;
|
||||
/**
|
||||
* 用户类型
|
||||
*
|
||||
* 枚举 {@link UserTypeEnum}
|
||||
*/
|
||||
private Integer userType;
|
||||
/**
|
||||
* 应用名
|
||||
*
|
||||
* 目前读取 `spring.application.name` 配置项
|
||||
*/
|
||||
private String applicationName;
|
||||
|
||||
/**
|
||||
* 请求方法名
|
||||
*/
|
||||
private String requestMethod;
|
||||
/**
|
||||
* 访问地址
|
||||
*/
|
||||
private String requestUrl;
|
||||
/**
|
||||
* 请求参数
|
||||
*
|
||||
* query: Query String
|
||||
* body: Quest Body
|
||||
*/
|
||||
private String requestParams;
|
||||
/**
|
||||
* 用户 IP
|
||||
*/
|
||||
private String userIp;
|
||||
/**
|
||||
* 浏览器 UA
|
||||
*/
|
||||
private String userAgent;
|
||||
|
||||
/**
|
||||
* 开始请求时间
|
||||
*/
|
||||
private Date beginTime;
|
||||
/**
|
||||
* 结束请求时间
|
||||
*/
|
||||
private Date endTime;
|
||||
/**
|
||||
* 执行时长,单位:毫秒
|
||||
*/
|
||||
private Integer duration;
|
||||
/**
|
||||
* 结果码
|
||||
*
|
||||
* 目前使用的 {@link CommonResult#getCode()} 属性
|
||||
*/
|
||||
private Integer resultCode;
|
||||
/**
|
||||
* 结果提示
|
||||
*
|
||||
* 目前使用的 {@link CommonResult#getMsg()} 属性
|
||||
*/
|
||||
private String resultMsg;
|
||||
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package cn.iocoder.dashboard.modules.system.dal.dataobject.logger;
|
||||
|
||||
public class SysApiErrorLogDO {
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package cn.iocoder.dashboard.modules.system.dal.mysql.logger;
|
||||
|
||||
import cn.iocoder.dashboard.common.pojo.PageResult;
|
||||
import cn.iocoder.dashboard.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.dashboard.framework.mybatis.core.query.QueryWrapperX;
|
||||
import cn.iocoder.dashboard.modules.system.controller.logger.vo.apiaccesslog.SysApiAccessLogExportReqVO;
|
||||
import cn.iocoder.dashboard.modules.system.controller.logger.vo.apiaccesslog.SysApiAccessLogPageReqVO;
|
||||
import cn.iocoder.dashboard.modules.system.dal.dataobject.logger.SysApiAccessLogDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* API 访问日志 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysApiAccessLogMapper extends BaseMapperX<SysApiAccessLogDO> {
|
||||
|
||||
default PageResult<SysApiAccessLogDO> selectPage(SysApiAccessLogPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new QueryWrapperX<SysApiAccessLogDO>()
|
||||
.eqIfPresent("user_id", reqVO.getUserId())
|
||||
.eqIfPresent("user_type", reqVO.getUserType())
|
||||
.eqIfPresent("application_name", reqVO.getApplicationName())
|
||||
.likeIfPresent("request_url", reqVO.getRequestUrl())
|
||||
.betweenIfPresent("begin_time", reqVO.getBeginBeginTime(), reqVO.getEndBeginTime())
|
||||
.geIfPresent("duration", reqVO.getDuration())
|
||||
.eqIfPresent("result_code", reqVO.getResultCode())
|
||||
);
|
||||
}
|
||||
|
||||
default List<SysApiAccessLogDO> selectList(SysApiAccessLogExportReqVO reqVO) {
|
||||
return selectList(new QueryWrapperX<SysApiAccessLogDO>()
|
||||
.eqIfPresent("user_id", reqVO.getUserId())
|
||||
.eqIfPresent("user_type", reqVO.getUserType())
|
||||
.eqIfPresent("application_name", reqVO.getApplicationName())
|
||||
.likeIfPresent("request_url", reqVO.getRequestUrl())
|
||||
.betweenIfPresent("begin_time", reqVO.getBeginBeginTime(), reqVO.getEndBeginTime())
|
||||
.geIfPresent("duration", reqVO.getDuration())
|
||||
.eqIfPresent("result_code", reqVO.getResultCode())
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package cn.iocoder.dashboard.modules.system.service.logger;
|
||||
|
||||
import cn.iocoder.dashboard.common.pojo.PageResult;
|
||||
import cn.iocoder.dashboard.framework.logger.apilog.core.service.ApiAccessLogFrameworkService;
|
||||
import cn.iocoder.dashboard.modules.system.controller.logger.vo.apiaccesslog.SysApiAccessLogExportReqVO;
|
||||
import cn.iocoder.dashboard.modules.system.controller.logger.vo.apiaccesslog.SysApiAccessLogPageReqVO;
|
||||
import cn.iocoder.dashboard.modules.system.dal.dataobject.logger.SysApiAccessLogDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* API 访问日志 Service 接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface SysApiAccessLogService extends ApiAccessLogFrameworkService {
|
||||
|
||||
/**
|
||||
* 获得 API 访问日志
|
||||
*
|
||||
* @param id 编号
|
||||
* @return API 访问日志
|
||||
*/
|
||||
SysApiAccessLogDO getApiAccessLog(Long id);
|
||||
|
||||
/**
|
||||
* 获得 API 访问日志分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return API 访问日志分页
|
||||
*/
|
||||
PageResult<SysApiAccessLogDO> getApiAccessLogPage(SysApiAccessLogPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得 API 访问日志列表, 用于 Excel 导出
|
||||
*
|
||||
* @param exportReqVO 查询条件
|
||||
* @return API 访问日志分页
|
||||
*/
|
||||
List<SysApiAccessLogDO> getApiAccessLogList(SysApiAccessLogExportReqVO exportReqVO);
|
||||
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package cn.iocoder.dashboard.modules.system.service.logger.impl;
|
||||
|
||||
import cn.iocoder.dashboard.common.pojo.PageResult;
|
||||
import cn.iocoder.dashboard.framework.logger.apilog.core.service.dto.ApiAccessLogCreateDTO;
|
||||
import cn.iocoder.dashboard.modules.system.controller.logger.vo.apiaccesslog.SysApiAccessLogExportReqVO;
|
||||
import cn.iocoder.dashboard.modules.system.controller.logger.vo.apiaccesslog.SysApiAccessLogPageReqVO;
|
||||
import cn.iocoder.dashboard.modules.system.convert.logger.SysApiAccessLogConvert;
|
||||
import cn.iocoder.dashboard.modules.system.dal.dataobject.logger.SysApiAccessLogDO;
|
||||
import cn.iocoder.dashboard.modules.system.dal.mysql.logger.SysApiAccessLogMapper;
|
||||
import cn.iocoder.dashboard.modules.system.service.logger.SysApiAccessLogService;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* API 访问日志 Service 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class SysApiAccessLogServiceImpl implements SysApiAccessLogService {
|
||||
|
||||
@Resource
|
||||
private SysApiAccessLogMapper apiAccessLogMapper;
|
||||
|
||||
@Override
|
||||
@Async
|
||||
public void createApiAccessLogAsync(@Valid ApiAccessLogCreateDTO createDTO) {
|
||||
// 插入
|
||||
SysApiAccessLogDO apiAccessLog = SysApiAccessLogConvert.INSTANCE.convert(createDTO);
|
||||
apiAccessLogMapper.insert(apiAccessLog);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysApiAccessLogDO getApiAccessLog(Long id) {
|
||||
return apiAccessLogMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<SysApiAccessLogDO> getApiAccessLogPage(SysApiAccessLogPageReqVO pageReqVO) {
|
||||
return apiAccessLogMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysApiAccessLogDO> getApiAccessLogList(SysApiAccessLogExportReqVO exportReqVO) {
|
||||
return apiAccessLogMapper.selectList(exportReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user