| | |
| | | import com.vincent.rsf.server.common.domain.BaseParam; |
| | | import com.vincent.rsf.server.system.entity.User; |
| | | import org.springframework.security.core.Authentication; |
| | | import org.springframework.security.core.GrantedAuthority; |
| | | import org.springframework.security.core.context.SecurityContextHolder; |
| | | |
| | | import java.util.List; |
| | |
| | | public Long getTenantId() { |
| | | User loginUser = getLoginUser(); |
| | | return loginUser == null ? null : loginUser.getTenantId(); |
| | | } |
| | | |
| | | public boolean hasAuthority(String authority) { |
| | | if (authority == null || authority.trim().isEmpty()) { |
| | | return false; |
| | | } |
| | | try { |
| | | Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); |
| | | if (authentication == null || authentication.getAuthorities() == null) { |
| | | return false; |
| | | } |
| | | for (GrantedAuthority grantedAuthority : authentication.getAuthorities()) { |
| | | if (grantedAuthority != null && authority.equals(grantedAuthority.getAuthority())) { |
| | | return true; |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | System.out.println(e.getMessage()); |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | public <T extends BaseParam> T buildParam(Map<String, Object> map, Class<T> clz) { |
| | |
| | | } |
| | | |
| | | } |
| | | |