打印消息队列新增透传参数

This commit is contained in:
谭凯凯 2024-10-09 14:48:11 +08:00 committed by Tankaikai
parent 37dc169607
commit a0d9a1f591
3 changed files with 13 additions and 0 deletions

View File

@ -12,6 +12,7 @@ import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.core.userdetails.UserDetailsService;
import java.util.List; import java.util.List;
/** /**
@ -57,6 +58,15 @@ public class SecurityUtils {
return new JSONObject(new JSONObject(userDetails).get("user")).get("id", Long.class); return new JSONObject(new JSONObject(userDetails).get("user")).get("id", Long.class);
} }
/**
* 获取系统用户nickName
* @return 系统用户NickName
*/
public static String getCurrentUserNickName() {
UserDetails userDetails = getCurrentUser();
return new JSONObject(new JSONObject(userDetails).get("user")).get("nickName", String.class);
}
/** /**
* 获取当前用户的数据权限 * 获取当前用户的数据权限
* @return / * @return /

View File

@ -9,4 +9,5 @@ public class CallNumPrintDTO {
private Long currentUserId; private Long currentUserId;
private String currentUserName; private String currentUserName;
private String currentUserNickName;
} }

View File

@ -83,6 +83,7 @@ public class RabbitMsgUtils implements RabbitTemplate.ConfirmCallback {
try { try {
printDTO.setCurrentUserId(SecurityUtils.getCurrentUserId()); printDTO.setCurrentUserId(SecurityUtils.getCurrentUserId());
printDTO.setCurrentUserName(SecurityUtils.getCurrentUsername()); printDTO.setCurrentUserName(SecurityUtils.getCurrentUsername());
printDTO.setCurrentUserNickName(SecurityUtils.getCurrentUserNickName());
}catch (Exception e){ }catch (Exception e){
log.error("获取当前用户信息失败", e); log.error("获取当前用户信息失败", e);
} }
@ -102,6 +103,7 @@ public class RabbitMsgUtils implements RabbitTemplate.ConfirmCallback {
try { try {
jsonObject.put("currentUserId", SecurityUtils.getCurrentUserId()); jsonObject.put("currentUserId", SecurityUtils.getCurrentUserId());
jsonObject.put("currentUserName", SecurityUtils.getCurrentUsername()); jsonObject.put("currentUserName", SecurityUtils.getCurrentUsername());
jsonObject.put("currentUserNickName", SecurityUtils.getCurrentUserNickName());
}catch (Exception e){ }catch (Exception e){
log.error("获取当前用户信息失败", e); log.error("获取当前用户信息失败", e);
} }