调整 API 访问日志,从 system 归到 infra 更合适

pull/2/head
YunaiV 2021-02-27 11:20:10 +08:00
parent 0678fb7ca0
commit c6734c4bbc
25 changed files with 382 additions and 201 deletions

View File

@ -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);
}
};
}
}

View File

@ -1,35 +0,0 @@
# 项目相关配置
ruoyi:
# 名称
name: RuoYi
# 版本
version: 3.3.0
# 版权年份
copyrightYear: 2020
# 实例演示开关
demoEnabled: true
# 文件路径 示例( Windows配置D:/ruoyi/uploadPathLinux配置 /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

View File

@ -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'
})
}

View File

@ -6,6 +6,8 @@
import store from '@/store' import store from '@/store'
export const DICT_TYPE = { export const DICT_TYPE = {
USER_TYPE: 'user_type',
SYS_COMMON_STATUS: 'sys_common_status', SYS_COMMON_STATUS: 'sys_common_status',
SYS_MENU_TYPE: 'sys_menu_type', SYS_MENU_TYPE: 'sys_menu_type',
SYS_ROLE_TYPE: 'sys_role_type', SYS_ROLE_TYPE: 'sys_role_type',

View File

@ -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>

View File

@ -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 de.codecentric.boot.admin.server.config.EnableAdminServer;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;

View File

@ -1 +1,4 @@
/**
* 使 MyBatis Plus 使 MyBatis
*/
package cn.iocoder.dashboard.framework.mybatis; package cn.iocoder.dashboard.framework.mybatis;

View File

@ -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.CommonResult;
import cn.iocoder.dashboard.common.pojo.PageResult; import cn.iocoder.dashboard.common.pojo.PageResult;
import cn.iocoder.dashboard.framework.excel.core.util.ExcelUtils; import cn.iocoder.dashboard.framework.excel.core.util.ExcelUtils;
import cn.iocoder.dashboard.framework.logger.operatelog.core.annotations.OperateLog; 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.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogExcelVO;
import cn.iocoder.dashboard.modules.system.controller.logger.vo.apiaccesslog.SysApiAccessLogExportReqVO; import cn.iocoder.dashboard.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogExportReqVO;
import cn.iocoder.dashboard.modules.system.controller.logger.vo.apiaccesslog.SysApiAccessLogPageReqVO; import cn.iocoder.dashboard.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogPageReqVO;
import cn.iocoder.dashboard.modules.system.controller.logger.vo.apiaccesslog.SysApiAccessLogRespVO; import cn.iocoder.dashboard.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogRespVO;
import cn.iocoder.dashboard.modules.system.convert.logger.SysApiAccessLogConvert; import cn.iocoder.dashboard.modules.infra.convert.logger.InfApiAccessLogConvert;
import cn.iocoder.dashboard.modules.system.dal.dataobject.logger.SysApiAccessLogDO; import cn.iocoder.dashboard.modules.infra.dal.dataobject.logger.InfApiAccessLogDO;
import cn.iocoder.dashboard.modules.system.service.logger.SysApiAccessLogService; import cn.iocoder.dashboard.modules.infra.service.logger.InfApiAccessLogService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -32,40 +32,40 @@ import static cn.iocoder.dashboard.framework.logger.operatelog.core.enums.Operat
@Api(tags = "API 访问日志") @Api(tags = "API 访问日志")
@RestController @RestController
@RequestMapping("/system/api-access-log") @RequestMapping("/infra/api-access-log")
@Validated @Validated
public class SysApiAccessLogController { public class InfApiAccessLogController {
@Resource @Resource
private SysApiAccessLogService apiAccessLogService; private InfApiAccessLogService apiAccessLogService;
@GetMapping("/get") @GetMapping("/get")
@ApiOperation("获得API 访问日志") @ApiOperation("获得API 访问日志")
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
@PreAuthorize("@ss.hasPermission('system:api-access-log:query')") @PreAuthorize("@ss.hasPermission('infra:api-access-log:query')")
public CommonResult<SysApiAccessLogRespVO> getApiAccessLog(@RequestParam("id") Long id) { public CommonResult<InfApiAccessLogRespVO> getApiAccessLog(@RequestParam("id") Long id) {
SysApiAccessLogDO apiAccessLog = apiAccessLogService.getApiAccessLog(id); InfApiAccessLogDO apiAccessLog = apiAccessLogService.getApiAccessLog(id);
return success(SysApiAccessLogConvert.INSTANCE.convert(apiAccessLog)); return success(InfApiAccessLogConvert.INSTANCE.convert(apiAccessLog));
} }
@GetMapping("/page") @GetMapping("/page")
@ApiOperation("获得API 访问日志分页") @ApiOperation("获得API 访问日志分页")
@PreAuthorize("@ss.hasPermission('system:api-access-log:query')") @PreAuthorize("@ss.hasPermission('infra:api-access-log:query')")
public CommonResult<PageResult<SysApiAccessLogRespVO>> getApiAccessLogPage(@Valid SysApiAccessLogPageReqVO pageVO) { public CommonResult<PageResult<InfApiAccessLogRespVO>> getApiAccessLogPage(@Valid InfApiAccessLogPageReqVO pageVO) {
PageResult<SysApiAccessLogDO> pageResult = apiAccessLogService.getApiAccessLogPage(pageVO); PageResult<InfApiAccessLogDO> pageResult = apiAccessLogService.getApiAccessLogPage(pageVO);
return success(SysApiAccessLogConvert.INSTANCE.convertPage(pageResult)); return success(InfApiAccessLogConvert.INSTANCE.convertPage(pageResult));
} }
@GetMapping("/export-excel") @GetMapping("/export-excel")
@ApiOperation("导出API 访问日志 Excel") @ApiOperation("导出API 访问日志 Excel")
@PreAuthorize("@ss.hasPermission('system:api-access-log:export')") @PreAuthorize("@ss.hasPermission('infra:api-access-log:export')")
@OperateLog(type = EXPORT) @OperateLog(type = EXPORT)
public void exportApiAccessLogExcel(@Valid SysApiAccessLogExportReqVO exportReqVO, public void exportApiAccessLogExcel(@Valid InfApiAccessLogExportReqVO exportReqVO,
HttpServletResponse response) throws IOException { HttpServletResponse response) throws IOException {
List<SysApiAccessLogDO> list = apiAccessLogService.getApiAccessLogList(exportReqVO); List<InfApiAccessLogDO> list = apiAccessLogService.getApiAccessLogList(exportReqVO);
// 导出 Excel // 导出 Excel
List<SysApiAccessLogExcelVO> datas = SysApiAccessLogConvert.INSTANCE.convertList02(list); List<InfApiAccessLogExcelVO> datas = InfApiAccessLogConvert.INSTANCE.convertList02(list);
ExcelUtils.write(response, "API 访问日志.xls", "数据", SysApiAccessLogExcelVO.class, datas); ExcelUtils.write(response, "API 访问日志.xls", "数据", InfApiAccessLogExcelVO.class, datas);
} }
} }

View File

@ -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 io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@ -14,7 +14,7 @@ import static cn.iocoder.dashboard.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOU
* VO Swagger * VO Swagger
*/ */
@Data @Data
public class SysApiAccessLogBaseVO { public class InfApiAccessLogBaseVO {
@ApiModelProperty(value = "链路追踪编号", required = true, example = "66600cb6-7852-11eb-9439-0242ac130002") @ApiModelProperty(value = "链路追踪编号", required = true, example = "66600cb6-7852-11eb-9439-0242ac130002")
@NotNull(message = "链路追踪编号不能为空") @NotNull(message = "链路追踪编号不能为空")

View File

@ -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.annotations.DictFormat;
import cn.iocoder.dashboard.framework.excel.core.convert.DictConvert; 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 * @author
*/ */
@Data @Data
public class SysApiAccessLogExcelVO { public class InfApiAccessLogExcelVO {
@ExcelProperty("日志主键") @ExcelProperty("日志主键")
private Long id; private Long id;

View File

@ -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.ApiModel;
import io.swagger.annotations.ApiModelProperty; 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; 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 @Data
public class SysApiAccessLogExportReqVO { public class InfApiAccessLogExportReqVO {
@ApiModelProperty(value = "用户编号", example = "666") @ApiModelProperty(value = "用户编号", example = "666")
private Long userId; private Long userId;

View File

@ -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 cn.iocoder.dashboard.common.pojo.PageParam;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
@ -16,7 +16,7 @@ import static cn.iocoder.dashboard.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOU
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true) @ToString(callSuper = true)
public class SysApiAccessLogPageReqVO extends PageParam { public class InfApiAccessLogPageReqVO extends PageParam {
@ApiModelProperty(value = "用户编号", example = "666") @ApiModelProperty(value = "用户编号", example = "666")
private Long userId; private Long userId;

View File

@ -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.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
@ -12,7 +12,7 @@ import java.util.Date;
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true) @ToString(callSuper = true)
public class SysApiAccessLogRespVO extends SysApiAccessLogBaseVO { public class InfApiAccessLogRespVO extends InfApiAccessLogBaseVO {
@ApiModelProperty(value = "日志主键", required = true, example = "1024") @ApiModelProperty(value = "日志主键", required = true, example = "1024")
private Long id; private Long id;

View File

@ -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);
}

View File

@ -0,0 +1,6 @@
/**
* POJO
*
* 使 MapStruct
*/
package cn.iocoder.dashboard.modules.infra.convert;

View File

@ -0,0 +1 @@
<http://www.iocoder.cn/Spring-Boot/MapStruct/?yudao>

View File

@ -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.enums.UserTypeEnum;
import cn.iocoder.dashboard.common.pojo.CommonResult; import cn.iocoder.dashboard.common.pojo.CommonResult;
@ -14,14 +14,14 @@ import java.util.Date;
* *
* @author * @author
*/ */
@TableName("sys_api_access_log") @TableName("inf_api_access_log")
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true) @ToString(callSuper = true)
@Builder @Builder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class SysApiAccessLogDO extends BaseDO { public class InfApiAccessLogDO extends BaseDO {
/** /**
* *

View File

@ -0,0 +1,4 @@
package cn.iocoder.dashboard.modules.infra.dal.dataobject.logger;
public class InfApiErrorLogDO {
}

View File

@ -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.common.pojo.PageResult;
import cn.iocoder.dashboard.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.dashboard.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.dashboard.framework.mybatis.core.query.QueryWrapperX; 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.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogExportReqVO;
import cn.iocoder.dashboard.modules.system.controller.logger.vo.apiaccesslog.SysApiAccessLogPageReqVO; import cn.iocoder.dashboard.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogPageReqVO;
import cn.iocoder.dashboard.modules.system.dal.dataobject.logger.SysApiAccessLogDO; import cn.iocoder.dashboard.modules.infra.dal.dataobject.logger.InfApiAccessLogDO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import java.util.List; import java.util.List;
@ -16,10 +16,10 @@ import java.util.List;
* @author * @author
*/ */
@Mapper @Mapper
public interface SysApiAccessLogMapper extends BaseMapperX<SysApiAccessLogDO> { public interface InfApiAccessLogMapper extends BaseMapperX<InfApiAccessLogDO> {
default PageResult<SysApiAccessLogDO> selectPage(SysApiAccessLogPageReqVO reqVO) { default PageResult<InfApiAccessLogDO> selectPage(InfApiAccessLogPageReqVO reqVO) {
return selectPage(reqVO, new QueryWrapperX<SysApiAccessLogDO>() return selectPage(reqVO, new QueryWrapperX<InfApiAccessLogDO>()
.eqIfPresent("user_id", reqVO.getUserId()) .eqIfPresent("user_id", reqVO.getUserId())
.eqIfPresent("user_type", reqVO.getUserType()) .eqIfPresent("user_type", reqVO.getUserType())
.eqIfPresent("application_name", reqVO.getApplicationName()) .eqIfPresent("application_name", reqVO.getApplicationName())
@ -27,11 +27,12 @@ public interface SysApiAccessLogMapper extends BaseMapperX<SysApiAccessLogDO> {
.betweenIfPresent("begin_time", reqVO.getBeginBeginTime(), reqVO.getEndBeginTime()) .betweenIfPresent("begin_time", reqVO.getBeginBeginTime(), reqVO.getEndBeginTime())
.geIfPresent("duration", reqVO.getDuration()) .geIfPresent("duration", reqVO.getDuration())
.eqIfPresent("result_code", reqVO.getResultCode()) .eqIfPresent("result_code", reqVO.getResultCode())
.orderByDesc("id")
); );
} }
default List<SysApiAccessLogDO> selectList(SysApiAccessLogExportReqVO reqVO) { default List<InfApiAccessLogDO> selectList(InfApiAccessLogExportReqVO reqVO) {
return selectList(new QueryWrapperX<SysApiAccessLogDO>() return selectList(new QueryWrapperX<InfApiAccessLogDO>()
.eqIfPresent("user_id", reqVO.getUserId()) .eqIfPresent("user_id", reqVO.getUserId())
.eqIfPresent("user_type", reqVO.getUserType()) .eqIfPresent("user_type", reqVO.getUserType())
.eqIfPresent("application_name", reqVO.getApplicationName()) .eqIfPresent("application_name", reqVO.getApplicationName())
@ -39,6 +40,7 @@ public interface SysApiAccessLogMapper extends BaseMapperX<SysApiAccessLogDO> {
.betweenIfPresent("begin_time", reqVO.getBeginBeginTime(), reqVO.getEndBeginTime()) .betweenIfPresent("begin_time", reqVO.getBeginBeginTime(), reqVO.getEndBeginTime())
.geIfPresent("duration", reqVO.getDuration()) .geIfPresent("duration", reqVO.getDuration())
.eqIfPresent("result_code", reqVO.getResultCode()) .eqIfPresent("result_code", reqVO.getResultCode())
.orderByDesc("id")
); );
} }

View File

@ -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.common.pojo.PageResult;
import cn.iocoder.dashboard.framework.logger.apilog.core.service.ApiAccessLogFrameworkService; 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.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogExportReqVO;
import cn.iocoder.dashboard.modules.system.controller.logger.vo.apiaccesslog.SysApiAccessLogPageReqVO; import cn.iocoder.dashboard.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogPageReqVO;
import cn.iocoder.dashboard.modules.system.dal.dataobject.logger.SysApiAccessLogDO; import cn.iocoder.dashboard.modules.infra.dal.dataobject.logger.InfApiAccessLogDO;
import java.util.List; import java.util.List;
@ -13,7 +13,7 @@ import java.util.List;
* *
* @author * @author
*/ */
public interface SysApiAccessLogService extends ApiAccessLogFrameworkService { public interface InfApiAccessLogService extends ApiAccessLogFrameworkService {
/** /**
* API 访 * API 访
@ -21,7 +21,7 @@ public interface SysApiAccessLogService extends ApiAccessLogFrameworkService {
* @param id * @param id
* @return API 访 * @return API 访
*/ */
SysApiAccessLogDO getApiAccessLog(Long id); InfApiAccessLogDO getApiAccessLog(Long id);
/** /**
* API 访 * API 访
@ -29,7 +29,7 @@ public interface SysApiAccessLogService extends ApiAccessLogFrameworkService {
* @param pageReqVO * @param pageReqVO
* @return API 访 * @return API 访
*/ */
PageResult<SysApiAccessLogDO> getApiAccessLogPage(SysApiAccessLogPageReqVO pageReqVO); PageResult<InfApiAccessLogDO> getApiAccessLogPage(InfApiAccessLogPageReqVO pageReqVO);
/** /**
* API 访, Excel * API 访, Excel
@ -37,6 +37,6 @@ public interface SysApiAccessLogService extends ApiAccessLogFrameworkService {
* @param exportReqVO * @param exportReqVO
* @return API 访 * @return API 访
*/ */
List<SysApiAccessLogDO> getApiAccessLogList(SysApiAccessLogExportReqVO exportReqVO); List<InfApiAccessLogDO> getApiAccessLogList(InfApiAccessLogExportReqVO exportReqVO);
} }

View File

@ -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.common.pojo.PageResult;
import cn.iocoder.dashboard.framework.logger.apilog.core.service.dto.ApiAccessLogCreateDTO; 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.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogExportReqVO;
import cn.iocoder.dashboard.modules.system.controller.logger.vo.apiaccesslog.SysApiAccessLogPageReqVO; import cn.iocoder.dashboard.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogPageReqVO;
import cn.iocoder.dashboard.modules.system.convert.logger.SysApiAccessLogConvert; import cn.iocoder.dashboard.modules.infra.convert.logger.InfApiAccessLogConvert;
import cn.iocoder.dashboard.modules.system.dal.dataobject.logger.SysApiAccessLogDO; import cn.iocoder.dashboard.modules.infra.dal.dataobject.logger.InfApiAccessLogDO;
import cn.iocoder.dashboard.modules.system.dal.mysql.logger.SysApiAccessLogMapper; import cn.iocoder.dashboard.modules.infra.dal.mysql.logger.InfApiAccessLogMapper;
import cn.iocoder.dashboard.modules.system.service.logger.SysApiAccessLogService; import cn.iocoder.dashboard.modules.infra.service.logger.InfApiAccessLogService;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -23,31 +23,31 @@ import java.util.List;
*/ */
@Service @Service
@Validated @Validated
public class SysApiAccessLogServiceImpl implements SysApiAccessLogService { public class InfApiAccessLogServiceImpl implements InfApiAccessLogService {
@Resource @Resource
private SysApiAccessLogMapper apiAccessLogMapper; private InfApiAccessLogMapper apiAccessLogMapper;
@Override @Override
@Async @Async
public void createApiAccessLogAsync(@Valid ApiAccessLogCreateDTO createDTO) { public void createApiAccessLogAsync(@Valid ApiAccessLogCreateDTO createDTO) {
// 插入 // 插入
SysApiAccessLogDO apiAccessLog = SysApiAccessLogConvert.INSTANCE.convert(createDTO); InfApiAccessLogDO apiAccessLog = InfApiAccessLogConvert.INSTANCE.convert(createDTO);
apiAccessLogMapper.insert(apiAccessLog); apiAccessLogMapper.insert(apiAccessLog);
} }
@Override @Override
public SysApiAccessLogDO getApiAccessLog(Long id) { public InfApiAccessLogDO getApiAccessLog(Long id) {
return apiAccessLogMapper.selectById(id); return apiAccessLogMapper.selectById(id);
} }
@Override @Override
public PageResult<SysApiAccessLogDO> getApiAccessLogPage(SysApiAccessLogPageReqVO pageReqVO) { public PageResult<InfApiAccessLogDO> getApiAccessLogPage(InfApiAccessLogPageReqVO pageReqVO) {
return apiAccessLogMapper.selectPage(pageReqVO); return apiAccessLogMapper.selectPage(pageReqVO);
} }
@Override @Override
public List<SysApiAccessLogDO> getApiAccessLogList(SysApiAccessLogExportReqVO exportReqVO) { public List<InfApiAccessLogDO> getApiAccessLogList(InfApiAccessLogExportReqVO exportReqVO) {
return apiAccessLogMapper.selectList(exportReqVO); return apiAccessLogMapper.selectList(exportReqVO);
} }

View File

@ -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);
}

View File

@ -1 +1 @@
<http://www.iocoder.cn/Spring-Boot/MapStruct/?dashboard> <http://www.iocoder.cn/Spring-Boot/MapStruct/?yudao>

View File

@ -1,4 +0,0 @@
package cn.iocoder.dashboard.modules.system.dal.dataobject.logger;
public class SysApiErrorLogDO {
}

View File

@ -52,12 +52,13 @@ public interface ${table.className}Mapper extends BaseMapperX<${table.className}
default PageResult<${table.className}DO> selectPage(${table.className}PageReqVO reqVO) { default PageResult<${table.className}DO> selectPage(${table.className}PageReqVO reqVO) {
return selectPage(reqVO, new QueryWrapperX<${table.className}DO>() return selectPage(reqVO, new QueryWrapperX<${table.className}DO>()
#listCondition() #listCondition()
.orderByDesc("id")# 大多数情况下id 倒序
); );
} }
default List<${table.className}DO> selectList(${table.className}ExportReqVO reqVO) { default List<${table.className}DO> selectList(${table.className}ExportReqVO reqVO) {
return selectList(new QueryWrapperX<${table.className}DO>() return selectList(new QueryWrapperX<${table.className}DO>()
#listCondition() #listCondition()# 大多数情况下id 倒序
); );
} }