gpt4 book ai didi

mysql - 获取 jhi_persistenet_audit_event 表的当前记录用户详细信息

转载 作者:行者123 更新时间:2023-11-29 09:48:00 25 4
gpt4 key购买 nike

我正在与 jhipster 合作。我需要创建一个新表来审核数据库更改,并将其与 Jhipster 生成的默认 jhi_persistenet_audit_event 表链接。如何从 jhi_persistenet_audit_event 表中获取当前记录的用户记录,以将该 ID 链接到我的新表?

最佳答案

Solution 1: Principal principal

    @RequestMapping(value = {"/", ""})
public String start(Principal principal, Model model) {
String currentUser = principal.getName();
return currentUser;
}
<小时/>

Solution 2: Authentication authentication

@RequestMapping(value = {"/", ""})
public String currentUserName(Authentication authentication) {
return authentication.getName();
}
<小时/>

Solution 3: SecurityContextHolder

Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
if (principal instanceof UserDetails) {
String username = ((UserDetails)principal).getUsername();
} else {
String username = principal.toString();
}

Details 1 Details 2

关于mysql - 获取 jhi_persistenet_audit_event 表的当前记录用户详细信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55320534/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com