|  |  |  | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  | 
|---|
|  |  |  | if(!Constants.equalsInteger(user.getStatus(),Constants.ZERO)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,账号信息已被禁用,如有疑问请联系系统管理员!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<SystemRole> roles = null; | 
|---|
|  |  |  | List<SystemPermission> permissions =null; | 
|---|
|  |  |  | // 获取登录用户信息 | 
|---|
|  |  |  | List<SystemRole> roles = systemRoleService.findByUserId(user.getId()); | 
|---|
|  |  |  | List<SystemPermission> permissions = systemPermissionService.findByUserId(user.getId()); | 
|---|
|  |  |  | if(authenticationToken.getUserType() == 0){ | 
|---|
|  |  |  | roles =   systemRoleService.findByUserId(user.getId()); | 
|---|
|  |  |  | permissions =  systemPermissionService.findByUserId(user.getId()); | 
|---|
|  |  |  | CompanyPermission c = new CompanyPermission(); | 
|---|
|  |  |  | c.setUserId(user.getId()); | 
|---|
|  |  |  | c.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,企业账号信息不正确!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | user.setCompany(company); | 
|---|
|  |  |  | if(StringUtils.equals(company.getUsername(),user.getUsername())){ | 
|---|
|  |  |  | //如果是超管, | 
|---|
|  |  |  | SystemRole role = new SystemRole(); | 
|---|
|  |  |  | role.setType(Constants.ONE); | 
|---|
|  |  |  | role.setDeleted(Boolean.FALSE); | 
|---|
|  |  |  | roles =   systemRoleService.findList(role); | 
|---|
|  |  |  | SystemPermission p = new SystemPermission(); | 
|---|
|  |  |  | permissions =  systemPermissionService.findList(p); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | roles =   systemRoleService.findByUserId(user.getId()); | 
|---|
|  |  |  | permissions =  systemPermissionService.findByUserId(user.getId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | LoginUserInfo userInfo = LoginUserInfo.from(user, roles, permissions); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 验证用户 | 
|---|
|  |  |  | return new SimpleAuthenticationInfo(userInfo, user.getPassword(), this.getName()); | 
|---|
|  |  |  | } | 
|---|