【代码修复】SYSTEM:角色标识的提示不正确问题

pull/137/MERGE
YunaiV 2024-08-31 13:29:34 +08:00
parent df5077f499
commit 047252d4fc
7 changed files with 26 additions and 73 deletions

View File

@ -25,13 +25,13 @@ import java.util.concurrent.TimeUnit;
* *
* @author * @author
*/ */
@AutoConfiguration(before = MybatisPlusAutoConfiguration.class) @AutoConfiguration(before = MybatisPlusAutoConfiguration.class) // 目的:先于 MyBatis Plus 自动配置,避免 @MapperScan 可能扫描不到 Mapper 打印 warn 日志
// 目的:先于 MyBatis Plus 自动配置,避免 @MapperScan 可能扫描不到 Mapper 打印 warn 日志
@MapperScan(value = "${yudao.info.base-package}", annotationClass = Mapper.class, @MapperScan(value = "${yudao.info.base-package}", annotationClass = Mapper.class,
lazyInitialization = "${mybatis.lazy-initialization:false}") // Mapper 懒加载,目前仅用于单元测试 lazyInitialization = "${mybatis.lazy-initialization:false}") // Mapper 懒加载,目前仅用于单元测试
public class YudaoMybatisAutoConfiguration { public class YudaoMybatisAutoConfiguration {
static { static {
// 动态 SQL 智能优化支持本地缓存加速解析,更完善的租户复杂 XML 动态 SQL 支持,静态注入缓存
JsqlParserGlobal.setJsqlParseCache(new JdkSerialCaffeineJsqlParseCache( JsqlParserGlobal.setJsqlParseCache(new JdkSerialCaffeineJsqlParseCache(
(cache) -> cache.maximumSize(1024) (cache) -> cache.maximumSize(1024)
.expireAfterWrite(5, TimeUnit.SECONDS)) .expireAfterWrite(5, TimeUnit.SECONDS))
@ -73,5 +73,4 @@ public class YudaoMybatisAutoConfiguration {
throw new IllegalArgumentException(StrUtil.format("DbType{} 找不到合适的 IKeyGenerator 实现类", dbType)); throw new IllegalArgumentException(StrUtil.format("DbType{} 找不到合适的 IKeyGenerator 实现类", dbType));
} }
} }

View File

@ -165,5 +165,4 @@ public class ApiSignatureAspect {
return sortedMap; return sortedMap;
} }
} }

View File

@ -4,19 +4,21 @@ import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils;
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
import cn.iocoder.yudao.framework.security.core.LoginUser; import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.system.api.logger.OperateLogApi;
import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogCreateReqDTO; import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogCreateReqDTO;
import com.mzt.logapi.beans.LogRecord; import com.mzt.logapi.beans.LogRecord;
import com.mzt.logapi.service.ILogRecordService; import com.mzt.logapi.service.ILogRecordService;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import java.util.List; import java.util.List;
/** /**
* ILogRecordService * ILogRecordService
* *
* {@link OperateLogFrameworkService} * {@link OperateLogApi}
* *
* @author HUIHUI * @author HUIHUI
*/ */
@ -24,22 +26,27 @@ import java.util.List;
public class LogRecordServiceImpl implements ILogRecordService { public class LogRecordServiceImpl implements ILogRecordService {
@Resource @Resource
OperateLogFrameworkService operateLogFrameworkService; private OperateLogApi operateLogApi;
@Override @Override
@Async
public void record(LogRecord logRecord) { public void record(LogRecord logRecord) {
// 1. 补全通用字段
OperateLogCreateReqDTO reqDTO = new OperateLogCreateReqDTO(); OperateLogCreateReqDTO reqDTO = new OperateLogCreateReqDTO();
reqDTO.setTraceId(TracerUtils.getTraceId()); try {
// 补充用户信息 reqDTO.setTraceId(TracerUtils.getTraceId());
fillUserFields(reqDTO); // 补充用户信息
// 补全模块信息 fillUserFields(reqDTO);
fillModuleFields(reqDTO, logRecord); // 补全模块信息
// 补全请求信息 fillModuleFields(reqDTO, logRecord);
fillRequestFields(reqDTO); // 补全请求信息
fillRequestFields(reqDTO);
// 2. 异步记录日志 // 2. 异步记录日志
operateLogFrameworkService.createOperateLog(reqDTO); operateLogApi.createOperateLog(reqDTO).getCheckedData();
} catch (Throwable ex) {
// 由于 @Async 异步调用,这里打印下日志,更容易跟进
log.error("[record][url({}) log({}) 发生异常]", reqDTO.getRequestUrl(), reqDTO, ex);
}
} }
private static void fillUserFields(OperateLogCreateReqDTO reqDTO) { private static void fillUserFields(OperateLogCreateReqDTO reqDTO) {

View File

@ -1,19 +0,0 @@
package cn.iocoder.yudao.framework.operatelog.core.service;
import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogCreateReqDTO;
/**
* API Framework Service
*
* @author
*/
public interface OperateLogFrameworkService {
/**
*
*
* @param reqDTO API
*/
void createOperateLog(OperateLogCreateReqDTO reqDTO);
}

View File

@ -1,33 +0,0 @@
package cn.iocoder.yudao.framework.operatelog.core.service;
import cn.iocoder.yudao.module.system.api.logger.OperateLogApi;
import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogCreateReqDTO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
/**
* API Framework Service
*
* {@link OperateLogApi}
*
* @author
*/
@RequiredArgsConstructor
@Slf4j
public class OperateLogFrameworkServiceImpl implements OperateLogFrameworkService {
private final OperateLogApi operateLogApi;
@Override
@Async
public void createOperateLog(OperateLogCreateReqDTO reqDTO) {
try {
operateLogApi.createOperateLog(reqDTO);
} catch (Throwable ex) {
// 由于 @Async 异步调用,这里打印下日志,更容易跟进
log.error("[createOperateLog][url({}) log({}) 发生异常]", reqDTO.getRequestUrl(), reqDTO, ex);
}
}
}

View File

@ -24,7 +24,7 @@ import org.springframework.security.web.access.AccessDeniedHandler;
/** /**
* Spring Security * Spring Security
* <p> *
* {@link YudaoWebSecurityConfigurerAdapter} * {@link YudaoWebSecurityConfigurerAdapter}
* https://stackoverflow.com/questions/53847050/spring-boot-delegatebuilder-cannot-be-null-on-autowiring-authenticationmanager 文档。 * https://stackoverflow.com/questions/53847050/spring-boot-delegatebuilder-cannot-be-null-on-autowiring-authenticationmanager 文档。
* *

View File

@ -97,7 +97,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
} }
if (ArrayUtil.isNotEmpty(pageVO.getCreateTime())) { if (ArrayUtil.isNotEmpty(pageVO.getCreateTime())) {
taskQuery.taskCreatedAfter(DateUtils.of(pageVO.getCreateTime()[0])); taskQuery.taskCreatedAfter(DateUtils.of(pageVO.getCreateTime()[0]));
taskQuery.taskCreatedAfter(DateUtils.of(pageVO.getCreateTime()[1])); taskQuery.taskCreatedBefore(DateUtils.of(pageVO.getCreateTime()[1]));
} }
long count = taskQuery.count(); long count = taskQuery.count();
if (count == 0) { if (count == 0) {
@ -119,7 +119,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
} }
if (ArrayUtil.isNotEmpty(pageVO.getCreateTime())) { if (ArrayUtil.isNotEmpty(pageVO.getCreateTime())) {
taskQuery.taskCreatedAfter(DateUtils.of(pageVO.getCreateTime()[0])); taskQuery.taskCreatedAfter(DateUtils.of(pageVO.getCreateTime()[0]));
taskQuery.taskCreatedAfter(DateUtils.of(pageVO.getCreateTime()[1])); taskQuery.taskCreatedBefore(DateUtils.of(pageVO.getCreateTime()[1]));
} }
// 执行查询 // 执行查询
long count = taskQuery.count(); long count = taskQuery.count();
@ -141,7 +141,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
} }
if (ArrayUtil.isNotEmpty(pageVO.getCreateTime())) { if (ArrayUtil.isNotEmpty(pageVO.getCreateTime())) {
taskQuery.taskCreatedAfter(DateUtils.of(pageVO.getCreateTime()[0])); taskQuery.taskCreatedAfter(DateUtils.of(pageVO.getCreateTime()[0]));
taskQuery.taskCreatedAfter(DateUtils.of(pageVO.getCreateTime()[1])); taskQuery.taskCreatedBefore(DateUtils.of(pageVO.getCreateTime()[1]));
} }
// 执行查询 // 执行查询
long count = taskQuery.count(); long count = taskQuery.count();