| ÎļþÃû´Ó 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.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.model.LoginUserInfo; |
| | | import com.doumee.core.constants.Constants; |
| | | import com.doumee.core.utils.DateUtil; |
| | | import com.doumee.dao.system.model.SystemPermission; |
| | | import com.doumee.dao.system.model.SystemRole; |
| | | import com.doumee.dao.system.model.SystemUser; |
| | | import com.doumee.service.system.SystemDataPermissionService; |
| | | 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; |
| | |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | |
| | | @Lazy |
| | | @Autowired |
| | | private SystemDataPermissionService systemDataPermissionService; |
| | | @Lazy |
| | | @Autowired |
| | | private SystemUserService systemUserService; |
| | | |
| | | @Lazy |
| | | @Autowired |
| | | private SystemRoleService systemRoleService; |
| | | @Lazy |
| | | @Autowired |
| | | private SystemDictDataBiz systemDictDataBiz; |
| | | |
| | | @Lazy |
| | | @Autowired |
| | |
| | | queryDto.setDeleted(Constants.ZERO); |
| | | SystemUser user = systemUserService.findOne(queryDto); |
| | | if (user == null) { |
| | | return null; |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对ä¸èµ·ï¼è´¦å·æå¯ç 䏿£ç¡®ï¼"); |
| | | } |
| | | // è·åç»å½ç¨æ·ä¿¡æ¯ |
| | | 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()); |
| | | } |