|  |  |  | 
|---|
|  |  |  | 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.*; | 
|---|
|  |  |  | import com.doumee.service.common.CaptchaService; | 
|---|
|  |  |  | 
|---|
|  |  |  | import javax.servlet.http.HttpServletRequest; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Objects; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | @Service | 
|---|
|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SystemLoginLogService systemLoginLogService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private CompanyMapper companyMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public String loginByPassword(LoginDTO dto, HttpServletRequest request) { | 
|---|
|  |  |  | SystemLoginLog loginLog = new SystemLoginLog(); | 
|---|
|  |  |  | 
|---|
|  |  |  | 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()); | 
|---|
|  |  |  | 
|---|
|  |  |  | 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()); | 
|---|
|  |  |  | 
|---|
|  |  |  | //数据部门权限集合 | 
|---|
|  |  |  | user.setCompanyIdList(systemDataPermissionService.selectHighRole(new SystemDataPermission(),rt,user)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | LoginUserInfo userInfo = LoginUserInfo.from(user, roles, permissions,null); | 
|---|
|  |  |  | LoginUserInfo userInfo = LoginUserInfo.from(user, roles, permissions,company,null); | 
|---|
|  |  |  | return  userInfo; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|