本文介绍了获取jhi_persistenet_audit_event表的当前已记录用户详细信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am working with jhipster. I need to create a new table for auditing my database changes and link it with the default jhi_persistenet_audit_event table generated by the Jhipster. How I can get the current logged user record from the jhi_persistenet_audit_event table to link that id to my new table?

推荐答案

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


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


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

详细信息1 详细信息2

这篇关于获取jhi_persistenet_audit_event表的当前已记录用户详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 11:43