获取角色

This commit is contained in:
sxu 2025-03-05 14:06:46 +08:00
parent b594133df9
commit c73e71111d
1 changed files with 5 additions and 0 deletions

View File

@ -23,6 +23,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Optional;
@Service
public class MgrAuthApi {
@ -51,6 +52,10 @@ public class MgrAuthApi {
user.setUserid(SecurityUtils.getUserId());
user.setUsername(SecurityUtils.getUsername());
String roleCode = (String) SecureManager.getSubjectData().get("roleCode");
Optional<String> firstElement = user.getRoles().stream().findFirst();
if (firstElement.isPresent()) {
roleCode = firstElement.get();
}
if (ObjectUtil.isEmpty(roleCode)) {
throw new ServiceException(I18n.getMessage("auth_user_no_role_code", new Object[0]));
} else {