调整 API 访问日志,从 system 归到 infra 更合适
parent
0678fb7ca0
commit
c6734c4bbc
|
@ -1,58 +0,0 @@
|
|||
package com.ruoyi.framework.config;
|
||||
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
import org.apache.commons.lang3.concurrent.BasicThreadFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import com.ruoyi.common.utils.Threads;
|
||||
|
||||
/**
|
||||
* 线程池配置
|
||||
*
|
||||
* @author ruoyi
|
||||
**/
|
||||
@Configuration
|
||||
public class ThreadPoolConfig {
|
||||
// 核心线程池大小
|
||||
private int corePoolSize = 50;
|
||||
|
||||
// 最大可创建的线程数
|
||||
private int maxPoolSize = 200;
|
||||
|
||||
// 队列最大长度
|
||||
private int queueCapacity = 1000;
|
||||
|
||||
// 线程池维护线程所允许的空闲时间
|
||||
private int keepAliveSeconds = 300;
|
||||
|
||||
@Bean(name = "threadPoolTaskExecutor")
|
||||
public ThreadPoolTaskExecutor threadPoolTaskExecutor() {
|
||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||
executor.setMaxPoolSize(maxPoolSize);
|
||||
executor.setCorePoolSize(corePoolSize);
|
||||
executor.setQueueCapacity(queueCapacity);
|
||||
executor.setKeepAliveSeconds(keepAliveSeconds);
|
||||
// 线程池对拒绝任务(无线程可用)的处理策略
|
||||
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
||||
return executor;
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行周期性或定时任务
|
||||
*/
|
||||
@Bean(name = "scheduledExecutorService")
|
||||
protected ScheduledExecutorService scheduledExecutorService() {
|
||||
return new ScheduledThreadPoolExecutor(corePoolSize,
|
||||
new BasicThreadFactory.Builder().namingPattern("schedule-pool-%d").daemon(true).build()) {
|
||||
@Override
|
||||
protected void afterExecute(Runnable r, Throwable t) {
|
||||
super.afterExecute(r, t);
|
||||
Threads.printException(r, t);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
# 项目相关配置
|
||||
ruoyi:
|
||||
# 名称
|
||||
name: RuoYi
|
||||
# 版本
|
||||
version: 3.3.0
|
||||
# 版权年份
|
||||
copyrightYear: 2020
|
||||
# 实例演示开关
|
||||
demoEnabled: true
|
||||
# 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
|
||||
profile: D:/ruoyi/uploadPath
|
||||
# 获取ip地址开关
|
||||
addressEnabled: false
|
||||
|
||||
# 开发环境配置
|
||||
server:
|
||||
# 服务器的HTTP端口,默认为8080
|
||||
port: 8080
|
||||
servlet:
|
||||
# 应用的访问路径
|
||||
context-path: /
|
||||
tomcat:
|
||||
# tomcat的URI编码
|
||||
uri-encoding: UTF-8
|
||||
# tomcat最大线程数,默认为200
|
||||
max-threads: 800
|
||||
# Tomcat启动初始化的线程数,默认值25
|
||||
min-spare-threads: 30
|
||||
|
||||
# 日志配置
|
||||
logging:
|
||||
level:
|
||||
com.ruoyi: debug
|
||||
org.springframework: warn
|
|
@ -0,0 +1,55 @@
|
|||
import request from '@/utils/request'
|
||||
|
||||
// 创建API 访问日志
|
||||
export function createApiAccessLog(data) {
|
||||
return request({
|
||||
url: '/infra/api-access-log/create',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 更新API 访问日志
|
||||
export function updateApiAccessLog(data) {
|
||||
return request({
|
||||
url: '/infra/api-access-log/update',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 删除API 访问日志
|
||||
export function deleteApiAccessLog(id) {
|
||||
return request({
|
||||
url: '/infra/api-access-log/delete?id=' + id,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
// 获得API 访问日志
|
||||
export function getApiAccessLog(id) {
|
||||
return request({
|
||||
url: '/infra/api-access-log/get?id=' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 获得API 访问日志分页
|
||||
export function getApiAccessLogPage(query) {
|
||||
return request({
|
||||
url: '/infra/api-access-log/page',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 导出API 访问日志 Excel
|
||||
export function exportApiAccessLogExcel(query) {
|
||||
return request({
|
||||
url: '/infra/api-access-log/export-excel',
|
||||
method: 'get',
|
||||
params: query,
|
||||
responseType: 'blob'
|
||||
})
|
||||
}
|
|
@ -6,6 +6,8 @@
|
|||
import store from '@/store'
|
||||
|
||||
export const DICT_TYPE = {
|
||||
USER_TYPE: 'user_type',
|
||||
|
||||
SYS_COMMON_STATUS: 'sys_common_status',
|
||||
SYS_MENU_TYPE: 'sys_menu_type',
|
||||
SYS_ROLE_TYPE: 'sys_role_type',
|
||||
|
|
|
@ -0,0 +1,204 @@
|
|||
<template>
|
||||
<div class="app-container">
|
||||
|
||||
<!-- 搜索工作栏 -->
|
||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="用户编号" prop="userId">
|
||||
<el-input v-model="queryParams.userId" placeholder="请输入用户编号" clearable size="small" @keyup.enter.native="handleQuery"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="用户类型" prop="userType">
|
||||
<el-select v-model="queryParams.userType" placeholder="请选择用户类型" clearable size="small">
|
||||
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.USER_TYPE)"
|
||||
:key="dict.value" :label="dict.label" :value="dict.value"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="应用名" prop="applicationName">
|
||||
<el-input v-model="queryParams.applicationName" placeholder="请输入应用名" clearable size="small" @keyup.enter.native="handleQuery"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="请求地址" prop="requestUrl">
|
||||
<el-input v-model="queryParams.requestUrl" placeholder="请输入请求地址" clearable size="small" @keyup.enter.native="handleQuery"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="开始请求时间">
|
||||
<el-date-picker v-model="dateRangeBeginTime" size="small" style="width: 240px" value-format="yyyy-MM-dd"
|
||||
type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" />
|
||||
</el-form-item>
|
||||
<el-form-item label="执行时长" prop="duration">
|
||||
<el-input v-model="queryParams.duration" placeholder="请输入执行时长" clearable size="small" @keyup.enter.native="handleQuery"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="结果码" prop="resultCode">
|
||||
<el-input v-model="queryParams.resultCode" placeholder="请输入结果码" clearable size="small" @keyup.enter.native="handleQuery"/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<!-- 操作工具栏 -->
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
|
||||
v-hasPermi="['infra:api-access-log:export']">导出</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<!-- 列表 -->
|
||||
<el-table v-loading="loading" :data="list">
|
||||
<el-table-column label="日志主键" align="center" prop="id" />
|
||||
<el-table-column label="链路追踪编号" align="center" prop="traceId" />
|
||||
<el-table-column label="用户编号" align="center" prop="userId" />
|
||||
<el-table-column label="用户类型" align="center" prop="userType">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ getDictDataLabel(DICT_TYPE.USER_TYPE, scope.row.userType) }}</span>
|
||||
</template>
|
||||
</el-table-column>>
|
||||
<el-table-column label="应用名" align="center" prop="applicationName" />
|
||||
<el-table-column label="请求方法名" align="center" prop="requestMethod" />
|
||||
<el-table-column label="请求地址" align="center" prop="requestUrl" />
|
||||
<el-table-column label="Java 方法的参数" align="center" prop="requestParams" />
|
||||
<el-table-column label="用户 IP" align="center" prop="userIp" />
|
||||
<el-table-column label="浏览器 UA" align="center" prop="userAgent" />
|
||||
<el-table-column label="开始请求时间" align="center" prop="beginTime" width="180">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.beginTime, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="结束请求时间" align="center" prop="endTime" width="180">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.endTime, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="执行时长" align="center" prop="duration" />
|
||||
<el-table-column label="结果码" align="center" prop="resultCode" />
|
||||
<el-table-column label="结果提示" align="center" prop="resultMsg" />
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!-- 分页组件 -->
|
||||
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"/>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getApiAccessLog, getApiAccessLogPage, exportApiAccessLogExcel } from "@/api/infra/apiAccessLog";
|
||||
|
||||
export default {
|
||||
name: "ApiAccessLog",
|
||||
components: {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// API 访问日志列表
|
||||
list: [],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
dateRangeBeginTime: [],
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
userId: null,
|
||||
userType: null,
|
||||
applicationName: null,
|
||||
requestUrl: null,
|
||||
duration: null,
|
||||
resultCode: null,
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
/** 查询列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
// 处理查询参数
|
||||
let params = {...this.queryParams};
|
||||
this.addBeginAndEndTime(params, this.dateRangeBeginTime, 'beginTime');
|
||||
// 执行查询
|
||||
getApiAccessLogPage(params).then(response => {
|
||||
this.list = response.data.list;
|
||||
this.total = response.data.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
/** 取消按钮 */
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
},
|
||||
/** 表单重置 */
|
||||
reset() {
|
||||
this.form = {
|
||||
id: undefined,
|
||||
traceId: undefined,
|
||||
userId: undefined,
|
||||
userType: undefined,
|
||||
applicationName: undefined,
|
||||
requestMethod: undefined,
|
||||
requestUrl: undefined,
|
||||
requestParams: undefined,
|
||||
userIp: undefined,
|
||||
userAgent: undefined,
|
||||
beginTime: undefined,
|
||||
endTime: undefined,
|
||||
duration: undefined,
|
||||
resultCode: undefined,
|
||||
resultMsg: undefined,
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNo = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.dateRangeBeginTime = [];
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
// 处理查询参数
|
||||
let params = {...this.queryParams};
|
||||
params.pageNo = undefined;
|
||||
params.pageSize = undefined;
|
||||
this.addBeginAndEndTime(params, this.dateRangeBeginTime, 'beginTime');
|
||||
// 执行导出
|
||||
this.$confirm('是否确认导出所有API 访问日志数据项?', "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
}).then(function() {
|
||||
return exportApiAccessLogExcel(params);
|
||||
}).then(response => {
|
||||
this.downloadExcel(response, 'API 访问日志.xls');
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
|
@ -1,4 +1,4 @@
|
|||
package cn.iocoder.dashboard.framework.monitor;
|
||||
package cn.iocoder.dashboard.framework.monitor.config;
|
||||
|
||||
import de.codecentric.boot.admin.server.config.EnableAdminServer;
|
||||
import org.springframework.context.annotation.Configuration;
|
|
@ -1 +1,4 @@
|
|||
/**
|
||||
* 使用 MyBatis Plus 提升使用 MyBatis 的开发效率
|
||||
*/
|
||||
package cn.iocoder.dashboard.framework.mybatis;
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
package cn.iocoder.dashboard.modules.system.controller.logger;
|
||||
package cn.iocoder.dashboard.modules.infra.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 cn.iocoder.dashboard.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogExcelVO;
|
||||
import cn.iocoder.dashboard.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogExportReqVO;
|
||||
import cn.iocoder.dashboard.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogPageReqVO;
|
||||
import cn.iocoder.dashboard.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogRespVO;
|
||||
import cn.iocoder.dashboard.modules.infra.convert.logger.InfApiAccessLogConvert;
|
||||
import cn.iocoder.dashboard.modules.infra.dal.dataobject.logger.InfApiAccessLogDO;
|
||||
import cn.iocoder.dashboard.modules.infra.service.logger.InfApiAccessLogService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
@ -32,40 +32,40 @@ import static cn.iocoder.dashboard.framework.logger.operatelog.core.enums.Operat
|
|||
|
||||
@Api(tags = "API 访问日志")
|
||||
@RestController
|
||||
@RequestMapping("/system/api-access-log")
|
||||
@RequestMapping("/infra/api-access-log")
|
||||
@Validated
|
||||
public class SysApiAccessLogController {
|
||||
public class InfApiAccessLogController {
|
||||
|
||||
@Resource
|
||||
private SysApiAccessLogService apiAccessLogService;
|
||||
private InfApiAccessLogService 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));
|
||||
@PreAuthorize("@ss.hasPermission('infra:api-access-log:query')")
|
||||
public CommonResult<InfApiAccessLogRespVO> getApiAccessLog(@RequestParam("id") Long id) {
|
||||
InfApiAccessLogDO apiAccessLog = apiAccessLogService.getApiAccessLog(id);
|
||||
return success(InfApiAccessLogConvert.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));
|
||||
@PreAuthorize("@ss.hasPermission('infra:api-access-log:query')")
|
||||
public CommonResult<PageResult<InfApiAccessLogRespVO>> getApiAccessLogPage(@Valid InfApiAccessLogPageReqVO pageVO) {
|
||||
PageResult<InfApiAccessLogDO> pageResult = apiAccessLogService.getApiAccessLogPage(pageVO);
|
||||
return success(InfApiAccessLogConvert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@ApiOperation("导出API 访问日志 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('system:api-access-log:export')")
|
||||
@PreAuthorize("@ss.hasPermission('infra:api-access-log:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportApiAccessLogExcel(@Valid SysApiAccessLogExportReqVO exportReqVO,
|
||||
public void exportApiAccessLogExcel(@Valid InfApiAccessLogExportReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<SysApiAccessLogDO> list = apiAccessLogService.getApiAccessLogList(exportReqVO);
|
||||
List<InfApiAccessLogDO> list = apiAccessLogService.getApiAccessLogList(exportReqVO);
|
||||
// 导出 Excel
|
||||
List<SysApiAccessLogExcelVO> datas = SysApiAccessLogConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "API 访问日志.xls", "数据", SysApiAccessLogExcelVO.class, datas);
|
||||
List<InfApiAccessLogExcelVO> datas = InfApiAccessLogConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "API 访问日志.xls", "数据", InfApiAccessLogExcelVO.class, datas);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package cn.iocoder.dashboard.modules.system.controller.logger.vo.apiaccesslog;
|
||||
package cn.iocoder.dashboard.modules.infra.controller.logger.vo.apiaccesslog;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
@ -14,7 +14,7 @@ import static cn.iocoder.dashboard.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOU
|
|||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Data
|
||||
public class SysApiAccessLogBaseVO {
|
||||
public class InfApiAccessLogBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "链路追踪编号", required = true, example = "66600cb6-7852-11eb-9439-0242ac130002")
|
||||
@NotNull(message = "链路追踪编号不能为空")
|
|
@ -1,4 +1,4 @@
|
|||
package cn.iocoder.dashboard.modules.system.controller.logger.vo.apiaccesslog;
|
||||
package cn.iocoder.dashboard.modules.infra.controller.logger.vo.apiaccesslog;
|
||||
|
||||
import cn.iocoder.dashboard.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.dashboard.framework.excel.core.convert.DictConvert;
|
||||
|
@ -15,7 +15,7 @@ import static cn.iocoder.dashboard.modules.system.enums.dict.SysDictTypeEnum.USE
|
|||
* @author 芋道源码
|
||||
*/
|
||||
@Data
|
||||
public class SysApiAccessLogExcelVO {
|
||||
public class InfApiAccessLogExcelVO {
|
||||
|
||||
@ExcelProperty("日志主键")
|
||||
private Long id;
|
|
@ -1,4 +1,4 @@
|
|||
package cn.iocoder.dashboard.modules.system.controller.logger.vo.apiaccesslog;
|
||||
package cn.iocoder.dashboard.modules.infra.controller.logger.vo.apiaccesslog;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
@ -9,9 +9,9 @@ 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 是一致的")
|
||||
@ApiModel(value = "API 访问日志 Excel 导出 Request VO", description = "参数和 InfApiAccessLogPageReqVO 是一致的")
|
||||
@Data
|
||||
public class SysApiAccessLogExportReqVO {
|
||||
public class InfApiAccessLogExportReqVO {
|
||||
|
||||
@ApiModelProperty(value = "用户编号", example = "666")
|
||||
private Long userId;
|
|
@ -1,4 +1,4 @@
|
|||
package cn.iocoder.dashboard.modules.system.controller.logger.vo.apiaccesslog;
|
||||
package cn.iocoder.dashboard.modules.infra.controller.logger.vo.apiaccesslog;
|
||||
|
||||
import cn.iocoder.dashboard.common.pojo.PageParam;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
|
@ -16,7 +16,7 @@ import static cn.iocoder.dashboard.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOU
|
|||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class SysApiAccessLogPageReqVO extends PageParam {
|
||||
public class InfApiAccessLogPageReqVO extends PageParam {
|
||||
|
||||
@ApiModelProperty(value = "用户编号", example = "666")
|
||||
private Long userId;
|
|
@ -1,4 +1,4 @@
|
|||
package cn.iocoder.dashboard.modules.system.controller.logger.vo.apiaccesslog;
|
||||
package cn.iocoder.dashboard.modules.infra.controller.logger.vo.apiaccesslog;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
@ -12,7 +12,7 @@ import java.util.Date;
|
|||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class SysApiAccessLogRespVO extends SysApiAccessLogBaseVO {
|
||||
public class InfApiAccessLogRespVO extends InfApiAccessLogBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "日志主键", required = true, example = "1024")
|
||||
private Long id;
|
|
@ -0,0 +1,33 @@
|
|||
package cn.iocoder.dashboard.modules.infra.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.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogExcelVO;
|
||||
import cn.iocoder.dashboard.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogRespVO;
|
||||
import cn.iocoder.dashboard.modules.infra.dal.dataobject.logger.InfApiAccessLogDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* API 访问日志 Convert
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface InfApiAccessLogConvert {
|
||||
|
||||
InfApiAccessLogConvert INSTANCE = Mappers.getMapper(InfApiAccessLogConvert.class);
|
||||
|
||||
InfApiAccessLogDO convert(ApiAccessLogCreateDTO bean);
|
||||
|
||||
InfApiAccessLogRespVO convert(InfApiAccessLogDO bean);
|
||||
|
||||
List<InfApiAccessLogRespVO> convertList(List<InfApiAccessLogDO> list);
|
||||
|
||||
PageResult<InfApiAccessLogRespVO> convertPage(PageResult<InfApiAccessLogDO> page);
|
||||
|
||||
List<InfApiAccessLogExcelVO> convertList02(List<InfApiAccessLogDO> list);
|
||||
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
/**
|
||||
* 提供 POJO 类的实体转换
|
||||
*
|
||||
* 目前使用 MapStruct 框架
|
||||
*/
|
||||
package cn.iocoder.dashboard.modules.infra.convert;
|
|
@ -0,0 +1 @@
|
|||
<http://www.iocoder.cn/Spring-Boot/MapStruct/?yudao>
|
|
@ -1,4 +1,4 @@
|
|||
package cn.iocoder.dashboard.modules.system.dal.dataobject.logger;
|
||||
package cn.iocoder.dashboard.modules.infra.dal.dataobject.logger;
|
||||
|
||||
import cn.iocoder.dashboard.common.enums.UserTypeEnum;
|
||||
import cn.iocoder.dashboard.common.pojo.CommonResult;
|
||||
|
@ -14,14 +14,14 @@ import java.util.Date;
|
|||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@TableName("sys_api_access_log")
|
||||
@TableName("inf_api_access_log")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SysApiAccessLogDO extends BaseDO {
|
||||
public class InfApiAccessLogDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 编号
|
|
@ -0,0 +1,4 @@
|
|||
package cn.iocoder.dashboard.modules.infra.dal.dataobject.logger;
|
||||
|
||||
public class InfApiErrorLogDO {
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
package cn.iocoder.dashboard.modules.system.dal.mysql.logger;
|
||||
package cn.iocoder.dashboard.modules.infra.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 cn.iocoder.dashboard.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogExportReqVO;
|
||||
import cn.iocoder.dashboard.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogPageReqVO;
|
||||
import cn.iocoder.dashboard.modules.infra.dal.dataobject.logger.InfApiAccessLogDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -16,10 +16,10 @@ import java.util.List;
|
|||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysApiAccessLogMapper extends BaseMapperX<SysApiAccessLogDO> {
|
||||
public interface InfApiAccessLogMapper extends BaseMapperX<InfApiAccessLogDO> {
|
||||
|
||||
default PageResult<SysApiAccessLogDO> selectPage(SysApiAccessLogPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new QueryWrapperX<SysApiAccessLogDO>()
|
||||
default PageResult<InfApiAccessLogDO> selectPage(InfApiAccessLogPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new QueryWrapperX<InfApiAccessLogDO>()
|
||||
.eqIfPresent("user_id", reqVO.getUserId())
|
||||
.eqIfPresent("user_type", reqVO.getUserType())
|
||||
.eqIfPresent("application_name", reqVO.getApplicationName())
|
||||
|
@ -27,11 +27,12 @@ public interface SysApiAccessLogMapper extends BaseMapperX<SysApiAccessLogDO> {
|
|||
.betweenIfPresent("begin_time", reqVO.getBeginBeginTime(), reqVO.getEndBeginTime())
|
||||
.geIfPresent("duration", reqVO.getDuration())
|
||||
.eqIfPresent("result_code", reqVO.getResultCode())
|
||||
.orderByDesc("id")
|
||||
);
|
||||
}
|
||||
|
||||
default List<SysApiAccessLogDO> selectList(SysApiAccessLogExportReqVO reqVO) {
|
||||
return selectList(new QueryWrapperX<SysApiAccessLogDO>()
|
||||
default List<InfApiAccessLogDO> selectList(InfApiAccessLogExportReqVO reqVO) {
|
||||
return selectList(new QueryWrapperX<InfApiAccessLogDO>()
|
||||
.eqIfPresent("user_id", reqVO.getUserId())
|
||||
.eqIfPresent("user_type", reqVO.getUserType())
|
||||
.eqIfPresent("application_name", reqVO.getApplicationName())
|
||||
|
@ -39,6 +40,7 @@ public interface SysApiAccessLogMapper extends BaseMapperX<SysApiAccessLogDO> {
|
|||
.betweenIfPresent("begin_time", reqVO.getBeginBeginTime(), reqVO.getEndBeginTime())
|
||||
.geIfPresent("duration", reqVO.getDuration())
|
||||
.eqIfPresent("result_code", reqVO.getResultCode())
|
||||
.orderByDesc("id")
|
||||
);
|
||||
}
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
package cn.iocoder.dashboard.modules.system.service.logger;
|
||||
package cn.iocoder.dashboard.modules.infra.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 cn.iocoder.dashboard.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogExportReqVO;
|
||||
import cn.iocoder.dashboard.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogPageReqVO;
|
||||
import cn.iocoder.dashboard.modules.infra.dal.dataobject.logger.InfApiAccessLogDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -13,7 +13,7 @@ import java.util.List;
|
|||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface SysApiAccessLogService extends ApiAccessLogFrameworkService {
|
||||
public interface InfApiAccessLogService extends ApiAccessLogFrameworkService {
|
||||
|
||||
/**
|
||||
* 获得 API 访问日志
|
||||
|
@ -21,7 +21,7 @@ public interface SysApiAccessLogService extends ApiAccessLogFrameworkService {
|
|||
* @param id 编号
|
||||
* @return API 访问日志
|
||||
*/
|
||||
SysApiAccessLogDO getApiAccessLog(Long id);
|
||||
InfApiAccessLogDO getApiAccessLog(Long id);
|
||||
|
||||
/**
|
||||
* 获得 API 访问日志分页
|
||||
|
@ -29,7 +29,7 @@ public interface SysApiAccessLogService extends ApiAccessLogFrameworkService {
|
|||
* @param pageReqVO 分页查询
|
||||
* @return API 访问日志分页
|
||||
*/
|
||||
PageResult<SysApiAccessLogDO> getApiAccessLogPage(SysApiAccessLogPageReqVO pageReqVO);
|
||||
PageResult<InfApiAccessLogDO> getApiAccessLogPage(InfApiAccessLogPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得 API 访问日志列表, 用于 Excel 导出
|
||||
|
@ -37,6 +37,6 @@ public interface SysApiAccessLogService extends ApiAccessLogFrameworkService {
|
|||
* @param exportReqVO 查询条件
|
||||
* @return API 访问日志分页
|
||||
*/
|
||||
List<SysApiAccessLogDO> getApiAccessLogList(SysApiAccessLogExportReqVO exportReqVO);
|
||||
List<InfApiAccessLogDO> getApiAccessLogList(InfApiAccessLogExportReqVO exportReqVO);
|
||||
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
package cn.iocoder.dashboard.modules.system.service.logger.impl;
|
||||
package cn.iocoder.dashboard.modules.infra.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 cn.iocoder.dashboard.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogExportReqVO;
|
||||
import cn.iocoder.dashboard.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogPageReqVO;
|
||||
import cn.iocoder.dashboard.modules.infra.convert.logger.InfApiAccessLogConvert;
|
||||
import cn.iocoder.dashboard.modules.infra.dal.dataobject.logger.InfApiAccessLogDO;
|
||||
import cn.iocoder.dashboard.modules.infra.dal.mysql.logger.InfApiAccessLogMapper;
|
||||
import cn.iocoder.dashboard.modules.infra.service.logger.InfApiAccessLogService;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
@ -23,31 +23,31 @@ import java.util.List;
|
|||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class SysApiAccessLogServiceImpl implements SysApiAccessLogService {
|
||||
public class InfApiAccessLogServiceImpl implements InfApiAccessLogService {
|
||||
|
||||
@Resource
|
||||
private SysApiAccessLogMapper apiAccessLogMapper;
|
||||
private InfApiAccessLogMapper apiAccessLogMapper;
|
||||
|
||||
@Override
|
||||
@Async
|
||||
public void createApiAccessLogAsync(@Valid ApiAccessLogCreateDTO createDTO) {
|
||||
// 插入
|
||||
SysApiAccessLogDO apiAccessLog = SysApiAccessLogConvert.INSTANCE.convert(createDTO);
|
||||
InfApiAccessLogDO apiAccessLog = InfApiAccessLogConvert.INSTANCE.convert(createDTO);
|
||||
apiAccessLogMapper.insert(apiAccessLog);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysApiAccessLogDO getApiAccessLog(Long id) {
|
||||
public InfApiAccessLogDO getApiAccessLog(Long id) {
|
||||
return apiAccessLogMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<SysApiAccessLogDO> getApiAccessLogPage(SysApiAccessLogPageReqVO pageReqVO) {
|
||||
public PageResult<InfApiAccessLogDO> getApiAccessLogPage(InfApiAccessLogPageReqVO pageReqVO) {
|
||||
return apiAccessLogMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysApiAccessLogDO> getApiAccessLogList(SysApiAccessLogExportReqVO exportReqVO) {
|
||||
public List<InfApiAccessLogDO> getApiAccessLogList(InfApiAccessLogExportReqVO exportReqVO) {
|
||||
return apiAccessLogMapper.selectList(exportReqVO);
|
||||
}
|
||||
|
|
@ -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,4 +0,0 @@
|
|||
package cn.iocoder.dashboard.modules.system.dal.dataobject.logger;
|
||||
|
||||
public class SysApiErrorLogDO {
|
||||
}
|
|
@ -52,12 +52,13 @@ public interface ${table.className}Mapper extends BaseMapperX<${table.className}
|
|||
default PageResult<${table.className}DO> selectPage(${table.className}PageReqVO reqVO) {
|
||||
return selectPage(reqVO, new QueryWrapperX<${table.className}DO>()
|
||||
#listCondition()
|
||||
.orderByDesc("id")# 大多数情况下,id 倒序
|
||||
);
|
||||
}
|
||||
|
||||
default List<${table.className}DO> selectList(${table.className}ExportReqVO reqVO) {
|
||||
return selectList(new QueryWrapperX<${table.className}DO>()
|
||||
#listCondition()
|
||||
#listCondition()# 大多数情况下,id 倒序
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue