新增业务外部接口日志管理
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package com.ruoyi.lsfx.domain;
|
||||
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* 业务外部接口调用发起人快照。
|
||||
*/
|
||||
public record CallerContext(Long userId, String username) {
|
||||
|
||||
public CallerContext {
|
||||
if (!StringUtils.hasText(username)) {
|
||||
throw new IllegalArgumentException("接口调用账号不能为空");
|
||||
}
|
||||
}
|
||||
|
||||
public static CallerContext from(LoginUser loginUser) {
|
||||
if (loginUser == null) {
|
||||
throw new IllegalArgumentException("登录用户不能为空");
|
||||
}
|
||||
return new CallerContext(loginUser.getUserId(), loginUser.getUsername());
|
||||
}
|
||||
|
||||
public static CallerContext of(Long userId, String username) {
|
||||
return new CallerContext(userId, username);
|
||||
}
|
||||
|
||||
public static CallerContext system() {
|
||||
return new CallerContext(null, "system");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user