|  |  | 
 |  |  | import com.doumee.core.model.LoginUserInfo; | 
 |  |  | import com.doumee.core.constants.ResponseStatus; | 
 |  |  | import com.doumee.core.utils.Utils; | 
 |  |  | import com.doumee.dao.business.dao.CompanyMapper; | 
 |  |  | import com.doumee.dao.business.model.Company; | 
 |  |  | import com.doumee.dao.system.dto.LoginDTO; | 
 |  |  | import com.doumee.dao.system.model.SystemLoginLog; | 
 |  |  | import com.doumee.dao.system.model.SystemPermission; | 
 |  |  | import com.doumee.dao.system.model.SystemRole; | 
 |  |  | import com.doumee.dao.system.model.SystemUser; | 
 |  |  | import com.doumee.dao.system.model.*; | 
 |  |  | import com.doumee.service.common.CaptchaService; | 
 |  |  | import com.doumee.service.system.*; | 
 |  |  | import lombok.extern.slf4j.Slf4j; | 
 |  |  | 
 |  |  | import javax.servlet.http.HttpServletRequest; | 
 |  |  | import java.util.Date; | 
 |  |  | import java.util.List; | 
 |  |  | import java.util.Objects; | 
 |  |  |  | 
 |  |  | @Slf4j | 
 |  |  | @Service | 
 |  |  | 
 |  |  |  | 
 |  |  |     @Lazy | 
 |  |  |     @Autowired | 
 |  |  |     private SystemDataPermissionService systemDataPermissionService; | 
 |  |  |     @Lazy | 
 |  |  |     @Autowired | 
 |  |  |     private SystemRoleService systemRoleService; | 
 |  |  |  | 
 |  |  |     @Lazy | 
 |  |  | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private SystemLoginLogService systemLoginLogService; | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private CompanyMapper companyMapper; | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public String loginByPassword(LoginDTO dto, HttpServletRequest request) { | 
 |  |  | 
 |  |  |         loginLog.setClientInfo(Utils.User_Client.getBrowser(request)); | 
 |  |  |         loginLog.setOsInfo(Utils.User_Client.getOS(request)); | 
 |  |  |         loginLog.setServerIp(Utils.Server.getIP()); | 
 |  |  |         if(isDebug == null  || !isDebug){ | 
 |  |  |         if((isDebug == null  || !isDebug) && (Objects.isNull(dto.getCheckCode()) || dto.getCheckCode()) ){ | 
 |  |  |             // 校验验证码 | 
 |  |  |             try { | 
 |  |  |                 captchaService.check(dto.getUuid(), dto.getCode()); | 
 |  |  | 
 |  |  |         } | 
 |  |  |         String pwd = Utils.Secure.encryptPassword(new String(dto.getPassword()), user.getSalt()); | 
 |  |  |         // 比较密码 | 
 |  |  |         if( StringUtils.equals(pwd, user.getPassword())){ | 
 |  |  |         if( !StringUtils.equals(pwd, user.getPassword())){ | 
 |  |  |             throw new BusinessException(ResponseStatus.ACCOUNT_INCORRECT); | 
 |  |  |         } | 
 |  |  |         Company company = new Company(); | 
 |  |  |         if(Objects.nonNull(user.getCompanyId())){ | 
 |  |  |             company = companyMapper.selectById(user.getCompanyId()); | 
 |  |  |         } | 
 |  |  |         // 获取登录用户信息 | 
 |  |  |         List<SystemRole> roles = systemRoleService.findByUserId(user.getId()); | 
 |  |  |         List<SystemPermission> permissions = systemPermissionService.findByUserId(user.getId()); | 
 |  |  |         LoginUserInfo userInfo = LoginUserInfo.from(user, roles, permissions,null); | 
 |  |  |  | 
 |  |  |         SystemRole rt = new SystemRole(); | 
 |  |  |         rt.setDeleted(Boolean.FALSE); | 
 |  |  |         //数据部门权限集合 | 
 |  |  |         user.setCompanyIdList(systemDataPermissionService.selectHighRole(new SystemDataPermission(),rt,user)); | 
 |  |  |  | 
 |  |  |         LoginUserInfo userInfo = LoginUserInfo.from(user, roles, permissions,company,null); | 
 |  |  |         return  userInfo; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | } |