|  |  |  | 
|---|
|  |  |  | import com.doumee.core.exception.BusinessException; | 
|---|
|  |  |  | import com.doumee.core.model.LoginUserInfo; | 
|---|
|  |  |  | import com.doumee.core.utils.Constants; | 
|---|
|  |  |  | import com.doumee.core.utils.DateUtil; | 
|---|
|  |  |  | import com.doumee.dao.business.model.Company; | 
|---|
|  |  |  | 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.business.CompanyService; | 
|---|
|  |  |  | import com.doumee.service.system.SystemDataPermissionService; | 
|---|
|  |  |  | import com.doumee.service.system.SystemPermissionService; | 
|---|
|  |  |  | import com.doumee.service.system.SystemRoleService; | 
|---|
|  |  |  | 
|---|
|  |  |  | import org.springframework.context.annotation.Lazy; | 
|---|
|  |  |  | import org.springframework.stereotype.Component; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SystemPermissionService systemPermissionService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Lazy | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private CompanyService companyService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 权限处理 | 
|---|
|  |  |  | * @author Eva.Caesar Liu | 
|---|
|  |  |  | 
|---|
|  |  |  | * @date 2022/03/15 09:54 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException { | 
|---|
|  |  |  | protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException{ | 
|---|
|  |  |  | // 获取用户名 | 
|---|
|  |  |  | String username = authenticationToken.getPrincipal().toString(); | 
|---|
|  |  |  | // 根据用户名查询用户对象 | 
|---|
|  |  |  | 
|---|
|  |  |  | if(user == null){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,账号或密码不正确!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(!Constants.equalsInteger(user.getType(),Constants.UserType.COMPANY.getKey()) && !Constants.equalsInteger(user.getType(),Constants.UserType.ZHUBO.getKey())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,账号或密码不正确!!"); | 
|---|
|  |  |  | if(!Constants.equalsInteger(user.getType(),Constants.UserType.COMPANY.getKey())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,非企业账户身份,无法登录该平台!!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(!Constants.equalsInteger(user.getStatus(),Constants.ZERO)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,账号信息已被禁用,如有疑问请联系系统管理员!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(!user.getType().equals(Constants.UserType.SYSTEM)){ | 
|---|
|  |  |  | Company company = companyService.findById(user.getCompanyId()); | 
|---|
|  |  |  | if(company.getStatus().equals(Constants.ONE)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,企业信息已被禁用,如有疑问请联系系统管理员!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(DateUtil.compareDate(new Date(),DateUtil.addDaysToDate(company.getOepnValidDate(),1))<=Constants.ZERO){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"企业账号已过期,如需继续使用,请联系您的业务经理"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | user.setCompany(company); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 获取登录用户信息 | 
|---|
|  |  |  | List<SystemRole> roles = systemRoleService.findByUserId(user.getId()); | 
|---|
|  |  |  | List<SystemPermission> permissions = systemPermissionService.findByUserId(user.getId()); | 
|---|