copy from server/src/main/java/com/doumee/config/shiro/ShiroRealm.java
copy to server/web/src/main/java/com/doumee/config/shiro/ShiroRealm.java
| 文件从 server/src/main/java/com/doumee/config/shiro/ShiroRealm.java 复制 | 
 |  |  | 
 |  |  | package com.doumee.config.shiro; | 
 |  |  |  | 
 |  |  | import com.doumee.biz.system.SystemDictDataBiz; | 
 |  |  | import com.doumee.core.constants.Constants; | 
 |  |  | import com.doumee.core.model.LoginUserInfo; | 
 |  |  | import com.doumee.dao.system.model.SystemPermission; | 
 |  |  | 
 |  |  | import com.doumee.service.system.SystemPermissionService; | 
 |  |  | import com.doumee.service.system.SystemRoleService; | 
 |  |  | import com.doumee.service.system.SystemUserService; | 
 |  |  | import org.apache.commons.lang3.StringUtils; | 
 |  |  | import org.apache.shiro.authc.AuthenticationException; | 
 |  |  | import org.apache.shiro.authc.AuthenticationInfo; | 
 |  |  | import org.apache.shiro.authc.AuthenticationToken; | 
 |  |  | 
 |  |  | /** | 
 |  |  |  * 鑷畾涔塕ealm锛屽鐞嗚璇佸拰鏉冮檺 | 
 |  |  |  * @author Eva.Caesar Liu | 
 |  |  |  * @date 2022/03/15 09:54 | 
 |  |  |  * @date 2023/03/21 14:49 | 
 |  |  |  */ | 
 |  |  | @Component | 
 |  |  | public class ShiroRealm extends AuthorizingRealm { | 
 |  |  | 
 |  |  |     @Lazy | 
 |  |  |     @Autowired | 
 |  |  |     private SystemRoleService systemRoleService; | 
 |  |  |     @Lazy | 
 |  |  |     @Autowired | 
 |  |  |     private SystemDictDataBiz systemDictDataBiz; | 
 |  |  |  | 
 |  |  |     @Lazy | 
 |  |  |     @Autowired | 
 |  |  | 
 |  |  |     /** | 
 |  |  |      * 鏉冮檺澶勭悊 | 
 |  |  |      * @author Eva.Caesar Liu | 
 |  |  |      * @date 2022/03/15 09:54 | 
 |  |  |      * @date 2023/03/21 14:49 | 
 |  |  |      */ | 
 |  |  |     @Override | 
 |  |  |     protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) { | 
 |  |  | 
 |  |  |     /** | 
 |  |  |      * 璁よ瘉澶勭悊 | 
 |  |  |      * @author Eva.Caesar Liu | 
 |  |  |      * @date 2022/03/15 09:54 | 
 |  |  |      * @date 2023/03/21 14:49 | 
 |  |  |      */ | 
 |  |  |     @Override | 
 |  |  |     protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException { | 
 |  |  | 
 |  |  |             // 鑾峰彇鐧诲綍鐢ㄦ埛淇℃伅 | 
 |  |  |         List<SystemRole>       roles = systemRoleService.findByUserId(user.getId()); | 
 |  |  |         List<SystemPermission>     permissions = systemPermissionService.findByUserId(user.getId()); | 
 |  |  |  | 
 |  |  |         String imgPath = systemDictDataBiz.queryByCode(Constants.OSS,Constants.RESOURCE_PATH).getCode()+systemDictDataBiz.queryByCode(Constants.FILES_DIR,Constants.AVATAR_FILE).getCode(); | 
 |  |  |         LoginUserInfo userInfo = LoginUserInfo.from(user, imgPath,roles, permissions); | 
 |  |  |         LoginUserInfo userInfo = LoginUserInfo.from(user, roles, permissions); | 
 |  |  |         // 楠岃瘉鐢ㄦ埛 | 
 |  |  |         return new SimpleAuthenticationInfo(userInfo, user.getPassword(), this.getName()); | 
 |  |  |     } |