mirror of https://gitee.com/stylefeng/roses
【8.1.0】【log】更新日志查询返回当前用户登录的公司id
parent
631da61f7a
commit
21f0baadf3
|
@ -42,7 +42,7 @@ public class AuthedLogAppender {
|
||||||
* @author fengshuonan
|
* @author fengshuonan
|
||||||
* @since 2020/10/27 18:22
|
* @since 2020/10/27 18:22
|
||||||
*/
|
*/
|
||||||
public static void appendAuthedHttpLog(LogRecordDTO logRecordDTO, String token, Long userId) {
|
public static void appendAuthedHttpLog(LogRecordDTO logRecordDTO, String token, Long userId, Long orgId) {
|
||||||
|
|
||||||
// 填充当前登录的用户信息
|
// 填充当前登录的用户信息
|
||||||
try {
|
try {
|
||||||
|
@ -51,6 +51,10 @@ public class AuthedLogAppender {
|
||||||
|
|
||||||
// 填充登录用户的userId
|
// 填充登录用户的userId
|
||||||
logRecordDTO.setUserId(userId);
|
logRecordDTO.setUserId(userId);
|
||||||
|
|
||||||
|
// 填充用户登录的机构id
|
||||||
|
logRecordDTO.setUserCurrentOrgId(orgId);
|
||||||
|
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
// 获取不到用户登录信息,就不填充
|
// 获取不到用户登录信息,就不填充
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,6 +99,14 @@ public class LogRecordDTO {
|
||||||
@SimpleFieldFormat(processClass = UserNameFormatProcess.class)
|
@SimpleFieldFormat(processClass = UserNameFormatProcess.class)
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户请求时候的登录机构id
|
||||||
|
* <p>
|
||||||
|
* 如果是http请求,并且用户已经登录,可以带这项
|
||||||
|
*/
|
||||||
|
@ChineseDescription("用户请求时候的登录机构id")
|
||||||
|
private Long userCurrentOrgId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 客户端的ip
|
* 客户端的ip
|
||||||
* <p>
|
* <p>
|
||||||
|
|
|
@ -175,7 +175,7 @@ public class RequestApiLogRecordAop implements Ordered {
|
||||||
// 填充用户登录信息
|
// 填充用户登录信息
|
||||||
LoginUser loginUserNullable = LoginContext.me().getLoginUserNullable();
|
LoginUser loginUserNullable = LoginContext.me().getLoginUserNullable();
|
||||||
if (loginUserNullable != null) {
|
if (loginUserNullable != null) {
|
||||||
AuthedLogAppender.appendAuthedHttpLog(logRecordDTO, loginUserNullable.getToken(), loginUserNullable.getUserId());
|
AuthedLogAppender.appendAuthedHttpLog(logRecordDTO, loginUserNullable.getToken(), loginUserNullable.getUserId(), loginUserNullable.getCurrentOrgId());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 填充http接口请求信息
|
// 填充http接口请求信息
|
||||||
|
|
|
@ -97,6 +97,12 @@ public class SysLog extends BaseEntity {
|
||||||
@TableField(value = "user_id")
|
@TableField(value = "user_id")
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户请求时候的登录机构id
|
||||||
|
*/
|
||||||
|
@TableField(value = "user_current_org_id")
|
||||||
|
private Long userCurrentOrgId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 请求http方法
|
* 请求http方法
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -87,7 +87,7 @@ public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> impleme
|
||||||
LambdaQueryWrapper<SysLog> wrapper = createWrapper(logManagerRequest);
|
LambdaQueryWrapper<SysLog> wrapper = createWrapper(logManagerRequest);
|
||||||
|
|
||||||
// 只查询需要字段
|
// 只查询需要字段
|
||||||
wrapper.select(SysLog::getLogId, SysLog::getRequestUrl, SysLog::getLogContent, SysLog::getUserId, SysLog::getAppName,
|
wrapper.select(SysLog::getLogId, SysLog::getRequestUrl, SysLog::getLogContent, SysLog::getUserId, SysLog::getUserCurrentOrgId, SysLog::getAppName,
|
||||||
BaseEntity::getCreateTime);
|
BaseEntity::getCreateTime);
|
||||||
|
|
||||||
// 转化实体
|
// 转化实体
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
ALTER TABLE `sys_log_api`
|
||||||
|
ADD COLUMN `user_current_org_id` bigint NULL COMMENT '用户请求时候的登录机构id' AFTER `user_id`;
|
Loading…
Reference in New Issue