|
|
@@ -24,6 +24,7 @@ import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.Date;
|
|
|
+import java.util.concurrent.CompletableFuture;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
/**
|
|
|
@@ -42,27 +43,21 @@ public class OperationLogsService extends SuperService {
|
|
|
// 保存60天
|
|
|
private static Long ttlTime = 60 * 24 * 60 * 60 * 1000L;
|
|
|
|
|
|
- @Async
|
|
|
public void addLog(OperationLogsAddParam param) {
|
|
|
- try {
|
|
|
- log.error("开始等待");
|
|
|
- TimeUnit.SECONDS.sleep(5);
|
|
|
- log.error("结束...............");
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- OperationLogs logs = new OperationLogs();
|
|
|
- BeanUtils.copyProperties(param, logs);
|
|
|
- logs.setTime(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.FORMAT_LONG));
|
|
|
- logs.setTtl(new Date(System.currentTimeMillis() + ttlTime));
|
|
|
- if (StringUtils.isNotEmpty(param.getUid())) {
|
|
|
- UserAccount userAccount = userDao.findTopByUserId(param.getUid());
|
|
|
- if (ObjectUtils.isNotEmpty(userAccount)) {
|
|
|
- logs.setUserName(userAccount.getName());
|
|
|
- logs.setLoginName(userAccount.getLoginName());
|
|
|
+ CompletableFuture.runAsync(() -> {
|
|
|
+ OperationLogs logs = new OperationLogs();
|
|
|
+ BeanUtils.copyProperties(param, logs);
|
|
|
+ logs.setTime(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.FORMAT_LONG));
|
|
|
+ logs.setTtl(new Date(System.currentTimeMillis() + ttlTime));
|
|
|
+ if (StringUtils.isNotEmpty(param.getUid())) {
|
|
|
+ UserAccount userAccount = userDao.findTopByUserId(param.getUid());
|
|
|
+ if (ObjectUtils.isNotEmpty(userAccount)) {
|
|
|
+ logs.setUserName(userAccount.getName());
|
|
|
+ logs.setLoginName(userAccount.getLoginName());
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- operationLogsDao.save(logs);
|
|
|
+ operationLogsDao.save(logs);
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
public ResultContent addLogs(String content, LogsLevel level) {
|