feat: adding create_id auto get from user

This commit is contained in:
wzp 2023-06-07 21:18:03 +08:00
parent 42d4ae1e89
commit aca210336d

View File

@ -63,6 +63,13 @@ public class AccountController {
@RequestMapping(path = "/addStoreAdmin",method = RequestMethod.POST)
public R<JSONObject> addStoreAdmin(@RequestBody AccountAndStoreAdmin accountAndStoreAdmin){
Collection<GrantedAuthority> authorities = ((User) SecurityContextHolder
.getContext()
.getAuthentication()
.getPrincipal())
.getAuthorities();
int id = Integer.parseInt(authorities.stream().filter(e -> e.getAuthority().startsWith("ROLE_id=")).findFirst().get().getAuthority().replace("ROLE_id=", ""));
accountAndStoreAdmin.setCreateId(id);
return accountService.addStoreAdmin(accountAndStoreAdmin);
}
/* @RequestMapping(path = "/debug",method = RequestMethod.GET)