|
@@ -3,10 +3,7 @@ package com.sckw.auth.service.impl;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.sckw.auth.model.vo.req.ForgetPasswordReqVo;
|
|
import com.sckw.auth.model.vo.req.ForgetPasswordReqVo;
|
|
|
import com.sckw.auth.model.vo.req.LoginBase;
|
|
import com.sckw.auth.model.vo.req.LoginBase;
|
|
|
-import com.sckw.auth.model.vo.req.LoginReqVo;
|
|
|
|
|
import com.sckw.auth.model.vo.req.RegisterReqVo;
|
|
import com.sckw.auth.model.vo.req.RegisterReqVo;
|
|
|
-import com.sckw.auth.model.vo.res.DeptInfoResVo;
|
|
|
|
|
-import com.sckw.auth.model.vo.res.EntInfoResVo;
|
|
|
|
|
import com.sckw.auth.model.vo.res.LoginResVo;
|
|
import com.sckw.auth.model.vo.res.LoginResVo;
|
|
|
import com.sckw.auth.model.vo.res.LoginResVo1;
|
|
import com.sckw.auth.model.vo.res.LoginResVo1;
|
|
|
import com.sckw.auth.service.IAuthService;
|
|
import com.sckw.auth.service.IAuthService;
|
|
@@ -14,14 +11,13 @@ import com.sckw.auth.util.AsyncFactory;
|
|
|
import com.sckw.core.common.enums.enums.DictEnum;
|
|
import com.sckw.core.common.enums.enums.DictEnum;
|
|
|
import com.sckw.core.exception.SystemException;
|
|
import com.sckw.core.exception.SystemException;
|
|
|
import com.sckw.core.model.constant.Global;
|
|
import com.sckw.core.model.constant.Global;
|
|
|
|
|
+import com.sckw.core.model.constant.NumberConstant;
|
|
|
import com.sckw.core.model.enums.ClientTypeEnum;
|
|
import com.sckw.core.model.enums.ClientTypeEnum;
|
|
|
import com.sckw.core.model.enums.LoginMethodEnum;
|
|
import com.sckw.core.model.enums.LoginMethodEnum;
|
|
|
import com.sckw.core.model.enums.SystemTypeEnum;
|
|
import com.sckw.core.model.enums.SystemTypeEnum;
|
|
|
import com.sckw.core.utils.*;
|
|
import com.sckw.core.utils.*;
|
|
|
import com.sckw.core.web.constant.HttpStatus;
|
|
import com.sckw.core.web.constant.HttpStatus;
|
|
|
import com.sckw.core.web.context.LoginUserHolder;
|
|
import com.sckw.core.web.context.LoginUserHolder;
|
|
|
-import com.sckw.core.web.model.EntCertificateInfo;
|
|
|
|
|
-import com.sckw.core.web.model.LoginEntInfo;
|
|
|
|
|
import com.sckw.core.web.model.LoginUserInfo;
|
|
import com.sckw.core.web.model.LoginUserInfo;
|
|
|
import com.sckw.core.web.response.HttpResult;
|
|
import com.sckw.core.web.response.HttpResult;
|
|
|
import com.sckw.fleet.api.RemoteFleetService;
|
|
import com.sckw.fleet.api.RemoteFleetService;
|
|
@@ -33,15 +29,11 @@ import com.sckw.system.api.RemoteUserService;
|
|
|
import com.sckw.system.api.model.dto.req.ForgetPasswordReqDto;
|
|
import com.sckw.system.api.model.dto.req.ForgetPasswordReqDto;
|
|
|
import com.sckw.system.api.model.dto.req.RegisterReqDto;
|
|
import com.sckw.system.api.model.dto.req.RegisterReqDto;
|
|
|
import com.sckw.system.api.model.dto.req.UserLoginReqDto;
|
|
import com.sckw.system.api.model.dto.req.UserLoginReqDto;
|
|
|
-import com.sckw.system.api.model.dto.res.EntCacheResDto;
|
|
|
|
|
-import com.sckw.system.api.model.dto.res.FindEntUserResDto;
|
|
|
|
|
-import com.sckw.system.api.model.dto.res.KwsUserResDto;
|
|
|
|
|
-import com.sckw.system.api.model.dto.res.UserAccessMenuInfoResDto;
|
|
|
|
|
|
|
+import com.sckw.system.api.model.dto.res.*;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
-
|
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -63,119 +55,29 @@ public class AuthServiceImpl implements IAuthService {
|
|
|
private RemoteFleetService fleetService;
|
|
private RemoteFleetService fleetService;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public LoginResVo login(LoginReqVo reqDto) {
|
|
|
|
|
-// /*1、根据账号密码或者手机号校验码登录, 手机号后面处理*/
|
|
|
|
|
-// KwsUserResDto kwsUser = checkLogin(reqDto);
|
|
|
|
|
-// LoginResVo loginResVo = new LoginResVo();
|
|
|
|
|
-// loginResVo.setClientType(reqDto.getClientType());
|
|
|
|
|
-// BeanUtils.copyProperties(kwsUser, loginResVo);
|
|
|
|
|
-//
|
|
|
|
|
-// //平台管理员直接过了
|
|
|
|
|
-// if (kwsUser.getIsMain() == Global.YES && kwsUser.getSystemType().equals(SystemTypeEnum.MANAGE.getCode())) {
|
|
|
|
|
-// afterProcessor(loginResVo);
|
|
|
|
|
-// return loginResVo;
|
|
|
|
|
-// }
|
|
|
|
|
-// /*2、登录成功,查询角色信息*/
|
|
|
|
|
-// Long userId = kwsUser.getId();
|
|
|
|
|
-// List<KwsRoleResDto> kwsRoleResDtos = remoteUserService.queryRoleInfoByUserId(userId);
|
|
|
|
|
-// loginResVo.setRoleInfo(kwsRoleResDtos);
|
|
|
|
|
-//
|
|
|
|
|
-//
|
|
|
|
|
-// /*3、查询用户机构*/
|
|
|
|
|
-// List<KwsUserDeptResDto> kwsUserDeptResDtos = remoteUserService.queryUserDeptByUserId(userId);
|
|
|
|
|
-// if (CollectionUtils.isEmpty(kwsUserDeptResDtos)) {
|
|
|
|
|
-// throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.USER_DEPT_NOT_EXISTS);
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// List<Long> deptIds = kwsUserDeptResDtos.stream().map(KwsUserDeptResDto::getDeptId).toList();
|
|
|
|
|
-// List<KwsDeptResDto> kwsDepts = remoteUserService.queryDeptByIds(deptIds);
|
|
|
|
|
-// if (CollectionUtils.isEmpty(kwsDepts)) {
|
|
|
|
|
-// //数据不全,直接返回
|
|
|
|
|
-// afterProcessor(loginResVo);
|
|
|
|
|
-// return loginResVo;
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// /*3、查企业*/
|
|
|
|
|
-// //目前一个人只能归属于一个企业,所以这里取第一个就行
|
|
|
|
|
-// Long entId = kwsDepts.get(0).getEntId();
|
|
|
|
|
-// KwsEnterpriseResDto kwsEnterpriseResDto = remoteUserService.queryEnterpriseById(entId);
|
|
|
|
|
-// if (Objects.isNull(kwsEnterpriseResDto)) {
|
|
|
|
|
-// //只要查出了机构,这个if其实不会进的,做保险起见还是加上判空
|
|
|
|
|
-// afterProcessor(loginResVo);
|
|
|
|
|
-// return loginResVo;
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// EntInfoResVo entInfoResVo = new EntInfoResVo();
|
|
|
|
|
-// BeanUtils.copyProperties(kwsEnterpriseResDto, entInfoResVo);
|
|
|
|
|
-// entInfoResVo.setDeptInfo(BeanUtils.copyToList(kwsDepts, DeptInfoResVo.class));
|
|
|
|
|
-//
|
|
|
|
|
-// //查企业类型
|
|
|
|
|
-// List<EntTypeResDto> entTypeResDtos = remoteUserService.queryEntTypeById(entId);
|
|
|
|
|
-// if (CollectionUtils.isNotEmpty(entTypeResDtos)) {
|
|
|
|
|
-// entInfoResVo.setEntTypes(String.join(Global.COMMA, entTypeResDtos.stream().map(EntTypeResDto::getType).map(String::valueOf).distinct().toList()));
|
|
|
|
|
-// }
|
|
|
|
|
-// loginResVo.setEntInfo(entInfoResVo);
|
|
|
|
|
-//
|
|
|
|
|
-// /* 4、查资质*/
|
|
|
|
|
-// List<EntCertificateResDto> entCertificateResDtoList = remoteUserService.queryCertificateByEntId(entId);
|
|
|
|
|
-// entInfoResVo.setCertificateInfo(entCertificateResDtoList);
|
|
|
|
|
-//
|
|
|
|
|
-// //企业资质有效性判断 1、当前资质没过期,且状态是已认证 2、只要有认证过一次就算有效 参数判断
|
|
|
|
|
-// String checkType = String.valueOf(Global.NUMERICAL_TWO);
|
|
|
|
|
-// if (checkType.equals(Global.NUMERICAL_ONE)) {
|
|
|
|
|
-// for (EntCertificateResDto entCertificateResDto : entCertificateResDtoList) {
|
|
|
|
|
-// Date expireTime = entCertificateResDto.getExpireTime();
|
|
|
|
|
-// entInfoResVo.setValid(DateUtil.compare(new Date(), expireTime) <= 0);
|
|
|
|
|
-// }
|
|
|
|
|
-// } else {
|
|
|
|
|
-// List<EntCheckTrackResDto> entCheckTrackResDtoList = remoteUserService.checkTrackByEntId(entId);
|
|
|
|
|
-// if (CollectionUtils.isEmpty(entCheckTrackResDtoList)) {
|
|
|
|
|
-// entInfoResVo.setValid(false);
|
|
|
|
|
-// afterProcessor(loginResVo);
|
|
|
|
|
-// return loginResVo;
|
|
|
|
|
-// }
|
|
|
|
|
-// entInfoResVo.setValid(entCheckTrackResDtoList.stream().anyMatch(item -> item.getStatus() == Global.NO));
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// /*5、生成token,一些信息存redis*/
|
|
|
|
|
-// afterProcessor(loginResVo);
|
|
|
|
|
-// return loginResVo;
|
|
|
|
|
- return null;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ public HttpResult login(LoginBase loginBase) {
|
|
|
|
|
+ if (StringUtils.isNotBlank(loginBase.getCaptcha())) {
|
|
|
|
|
+ loginBase.setLoginMethod(LoginMethodEnum.SMS.getValue());
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- private KwsUserResDto checkLogin(LoginReqVo reqDto) {
|
|
|
|
|
- List<KwsUserResDto> kwsUsers = remoteUserService.checkUserBase(reqDto.getAccount(), reqDto.getSystemType());
|
|
|
|
|
- KwsUserResDto kwsUser = kwsUsers.get(0);
|
|
|
|
|
- //密码校验、验证码
|
|
|
|
|
- if (StringUtils.isNotBlank(reqDto.getPassword())) {
|
|
|
|
|
- remoteUserService.checkPassword(reqDto.getAccount(), reqDto.getPassword(), kwsUser.getPassword(), kwsUser.getSalt());
|
|
|
|
|
- } else {
|
|
|
|
|
- String key = Global.USER_LOGIN_CAPTCHA + reqDto.getSystemType() + Global.COLON + kwsUser.getAccount();
|
|
|
|
|
-// String captcha = RedissonUtils.getString(key);
|
|
|
|
|
-// if (StringUtils.isBlank(captcha) || StringUtils.isBlank(reqDto.getCaptcha()) || !reqDto.getCaptcha().equals(captcha)) {
|
|
|
|
|
-// throw new SystemException(HttpStatus.PARAMETERS_MISSING_CODE, HttpStatus.CAPCHA_ERROR);
|
|
|
|
|
-// }
|
|
|
|
|
-// RedissonUtils.delete(key);
|
|
|
|
|
- }
|
|
|
|
|
- return kwsUser;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ /*参数校验*/
|
|
|
|
|
+ HttpResult result = checkParams(loginBase);
|
|
|
|
|
+ if (result.getCode() != HttpStatus.SUCCESS_CODE) {
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * @param loginResVo 登录的返参
|
|
|
|
|
- * @desc: 生成token,存redis
|
|
|
|
|
- * @author: czh
|
|
|
|
|
- * @date: 2023/6/12
|
|
|
|
|
- */
|
|
|
|
|
- private void afterProcessor(LoginResVo loginResVo) {
|
|
|
|
|
- try {
|
|
|
|
|
- //设置token
|
|
|
|
|
- loginResVo.setToken(EncryUtil.encry(Global.PRI_KEY, String.valueOf(loginResVo.getId())));
|
|
|
|
|
|
|
+ /*运营端/企业端登录(PC/APP)*/
|
|
|
|
|
+ if (loginBase.getSystemType() == SystemTypeEnum.MANAGE.getCode()
|
|
|
|
|
+ || loginBase.getSystemType() == SystemTypeEnum.COMPANY.getCode()) {
|
|
|
|
|
+ return this.commonAuth(loginBase);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- //异步存redis
|
|
|
|
|
- AsyncFactory.execute(new AsyncProcess(loginResVo, remoteUserService));
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- throw new SystemException(HttpStatus.GLOBAL_EXCEPTION_CODE, HttpStatus.GLOBAL_EXCEPTION_MESSAGE);
|
|
|
|
|
|
|
+ /*司机端*/
|
|
|
|
|
+ if (loginBase.getSystemType() == SystemTypeEnum.DRIVER.getCode()) {
|
|
|
|
|
+ return this.driverAuth(loginBase);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ return HttpResult.error(HttpStatus.PARAMETERS_MISSING_CODE, HttpStatus.GLOBAL_EXCEPTION_MESSAGE);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -193,7 +95,6 @@ public class AuthServiceImpl implements IAuthService {
|
|
|
RedissonUtils.delete(key);
|
|
RedissonUtils.delete(key);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void forgetPassword(ForgetPasswordReqVo reqDto) {
|
|
public void forgetPassword(ForgetPasswordReqVo reqDto) {
|
|
|
ForgetPasswordReqDto forgetPasswordReqDto = new ForgetPasswordReqDto();
|
|
ForgetPasswordReqDto forgetPasswordReqDto = new ForgetPasswordReqDto();
|
|
@@ -206,156 +107,16 @@ public class AuthServiceImpl implements IAuthService {
|
|
|
remoteUserService.resetPassword(id);
|
|
remoteUserService.resetPassword(id);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- static class AsyncProcess implements Runnable {
|
|
|
|
|
-
|
|
|
|
|
- private final LoginResVo loginResVo;
|
|
|
|
|
-
|
|
|
|
|
- private final RemoteUserService remoteUserService;
|
|
|
|
|
-
|
|
|
|
|
- public AsyncProcess(LoginResVo loginResVo, RemoteUserService remoteUserService) {
|
|
|
|
|
- this.loginResVo = loginResVo;
|
|
|
|
|
- this.remoteUserService = remoteUserService;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public void run() {
|
|
|
|
|
- //存基础信息
|
|
|
|
|
- saveBaseToCache(loginResVo);
|
|
|
|
|
-
|
|
|
|
|
- //存菜单权限
|
|
|
|
|
- saveToCache(loginResVo);
|
|
|
|
|
-
|
|
|
|
|
- //存登录记录信息
|
|
|
|
|
- saveLoginInfo(loginResVo);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * @param loginResVo 返参
|
|
|
|
|
- * @desc: 存基础信息
|
|
|
|
|
- * @author: czh
|
|
|
|
|
- * @date: 2023/6/28
|
|
|
|
|
- */
|
|
|
|
|
- private void saveBaseToCache(LoginResVo loginResVo) {
|
|
|
|
|
- //存用户登录信息
|
|
|
|
|
- saveUserLoginInfo();
|
|
|
|
|
-
|
|
|
|
|
- EntInfoResVo entInfo = loginResVo.getEntInfo();
|
|
|
|
|
- if (Objects.isNull(entInfo)) {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- //单独存用户企业
|
|
|
|
|
-// RedissonUtils.putString(Global.getFullUserEntKey(loginResVo.getSystemType(), loginResVo.getId()), JSON.toJSONString(entInfo), Global.PC_TOKEN_EXPIRE);
|
|
|
|
|
-
|
|
|
|
|
- //存企业信息
|
|
|
|
|
- saveEntLoginInfo(entInfo);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * @param entInfo 企业信息
|
|
|
|
|
- * @desc: 存企业信息
|
|
|
|
|
- * @author: czh
|
|
|
|
|
- * @date: 2023/7/3
|
|
|
|
|
- */
|
|
|
|
|
- private void saveEntLoginInfo(EntInfoResVo entInfo) {
|
|
|
|
|
- LoginEntInfo loginEntInfo = new LoginEntInfo();
|
|
|
|
|
- BeanUtils.copyProperties(entInfo, loginEntInfo);
|
|
|
|
|
- loginEntInfo.setCertificateInfo(BeanUtils.copyToList(entInfo.getCertificateInfo(), EntCertificateInfo.class));
|
|
|
|
|
- RedissonUtils.putString(Global.REDIS_ENTERPRISE_PREFIX + entInfo.getId(), JSON.toJSONString(loginEntInfo), Global.PC_TOKEN_EXPIRE);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * @desc: 存用户登录信息
|
|
|
|
|
- * @author: czh
|
|
|
|
|
- * @date: 2023/6/29
|
|
|
|
|
- */
|
|
|
|
|
- private void saveUserLoginInfo() {
|
|
|
|
|
- //存用户登录信息
|
|
|
|
|
- LoginUserInfo loginUserInfo = new LoginUserInfo();
|
|
|
|
|
- loginUserInfo.setId(loginResVo.getId());
|
|
|
|
|
- loginUserInfo.setSystemType(loginResVo.getSystemType());
|
|
|
|
|
- loginUserInfo.setAccount(loginResVo.getAccount());
|
|
|
|
|
- loginUserInfo.setUserName(loginResVo.getName());
|
|
|
|
|
- loginUserInfo.setPhone(loginResVo.getPhone());
|
|
|
|
|
- loginUserInfo.setIsMain(loginResVo.getIsMain());
|
|
|
|
|
- loginUserInfo.setStatus(loginResVo.getStatus());
|
|
|
|
|
- loginUserInfo.setClientType(loginResVo.getClientType());
|
|
|
|
|
- EntInfoResVo entInfo = loginResVo.getEntInfo();
|
|
|
|
|
- if (!Objects.isNull(entInfo)) {
|
|
|
|
|
- loginUserInfo.setEntId(entInfo.getId());
|
|
|
|
|
- loginUserInfo.setEntName(entInfo.getFirmName());
|
|
|
|
|
- List<DeptInfoResVo> deptInfo = entInfo.getDeptInfo();
|
|
|
|
|
- if (!CollectionUtils.isEmpty(deptInfo)) {
|
|
|
|
|
- loginUserInfo.setDeptIds(String.join(",", deptInfo.stream().map(item -> String.valueOf(item.getId())).toList()));
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- RedissonUtils.putString(Global.getFullUserLoginKey(loginResVo.getSystemType(), loginResVo.getId(), loginResVo.getClientType()), JSON.toJSONString(loginUserInfo), Global.PC_TOKEN_EXPIRE);
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * @param loginResVo 登录返参
|
|
|
|
|
- * @desc: 存缓存
|
|
|
|
|
- * @author: czh
|
|
|
|
|
- * @date: 2023/6/28
|
|
|
|
|
- */
|
|
|
|
|
- private void saveToCache(LoginResVo loginResVo) {
|
|
|
|
|
- //存权限菜单
|
|
|
|
|
- long id = loginResVo.getId();
|
|
|
|
|
- List<UserAccessMenuInfoResDto> userAccessMenuInfo = remoteUserService.queryUserAccessMenu(id);
|
|
|
|
|
- if (CollectionUtils.isEmpty(userAccessMenuInfo)) {
|
|
|
|
|
- RedissonUtils.delete(Global.REDIS_SYS_MENU_PREFIX + loginResVo.getClientType() + Global.COLON + id);
|
|
|
|
|
- log.error("未查询到用户{}的菜单权限", id);
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- List<String> menus = new ArrayList<>();
|
|
|
|
|
- for (UserAccessMenuInfoResDto userAccessMenuInfoResDto : userAccessMenuInfo) {
|
|
|
|
|
- String links = userAccessMenuInfoResDto.getLinks();
|
|
|
|
|
- if (StringUtils.isNotBlank(links)) {
|
|
|
|
|
- menus.addAll(Arrays.asList(userAccessMenuInfoResDto.getLinks().split(",")));
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- RedissonUtils.putSet(Global.REDIS_SYS_MENU_PREFIX + loginResVo.getClientType() + Global.COLON + id, menus);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * @param loginResVo 登录返参
|
|
|
|
|
- * @desc: 存登录记录信息
|
|
|
|
|
- * @author: czh
|
|
|
|
|
- * @date: 2023/6/28
|
|
|
|
|
- */
|
|
|
|
|
- private void saveLoginInfo(LoginResVo loginResVo) {
|
|
|
|
|
- long userId = loginResVo.getId();
|
|
|
|
|
- UserLoginReqDto currentDayLogin = remoteUserService.currentDayLogin(userId);
|
|
|
|
|
- UserLoginReqDto userLoginReqDto = new UserLoginReqDto();
|
|
|
|
|
- userLoginReqDto.setPid(Objects.isNull(currentDayLogin) ? "" : String.valueOf(currentDayLogin.getId()));
|
|
|
|
|
- userLoginReqDto.setIp("");
|
|
|
|
|
- userLoginReqDto.setUserAgent("");
|
|
|
|
|
- userLoginReqDto.setUserId(loginResVo.getId());
|
|
|
|
|
- userLoginReqDto.setToken(loginResVo.getToken());
|
|
|
|
|
- userLoginReqDto.setValidTime("");
|
|
|
|
|
- userLoginReqDto.setFirst(Objects.isNull(currentDayLogin) ? Global.YES : Global.NO);
|
|
|
|
|
- userLoginReqDto.setLock(Global.NO);
|
|
|
|
|
- userLoginReqDto.setType(Global.NO);
|
|
|
|
|
- userLoginReqDto.setSource(loginResVo.getClientType());
|
|
|
|
|
- remoteUserService.saveUserLogin(userLoginReqDto);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**-------------------------------------------------------------------------------------------------------------->**/
|
|
|
|
|
/**
|
|
/**
|
|
|
* @param loginBase {}
|
|
* @param loginBase {}
|
|
|
* @desc 司机账号登陆
|
|
* @desc 司机账号登陆
|
|
|
* @author zk
|
|
* @author zk
|
|
|
* @date 2023/7/26
|
|
* @date 2023/7/26
|
|
|
**/
|
|
**/
|
|
|
- @Override
|
|
|
|
|
public HttpResult driverAuth(LoginBase loginBase) {
|
|
public HttpResult driverAuth(LoginBase loginBase) {
|
|
|
- /**查询用户信息**/
|
|
|
|
|
|
|
+ /*查询用户信息**/
|
|
|
RDriverDetailVo driver = fleetService.findDriverDetai(loginBase.getAccount());
|
|
RDriverDetailVo driver = fleetService.findDriverDetai(loginBase.getAccount());
|
|
|
- /**信息校验**/
|
|
|
|
|
|
|
+ /*信息校验**/
|
|
|
if (driver == null) {
|
|
if (driver == null) {
|
|
|
return HttpResult.error(HttpStatus.QUERY_FAIL_CODE, "账号不存在,请检查并重新输入!");
|
|
return HttpResult.error(HttpStatus.QUERY_FAIL_CODE, "账号不存在,请检查并重新输入!");
|
|
|
}
|
|
}
|
|
@@ -366,19 +127,20 @@ public class AuthServiceImpl implements IAuthService {
|
|
|
if (driver.getStatus() == Global.YES) {
|
|
if (driver.getStatus() == Global.YES) {
|
|
|
return HttpResult.error(HttpStatus.CODE_10301, "您的账号已冻结,如需帮助,请致电平台客服!");
|
|
return HttpResult.error(HttpStatus.CODE_10301, "您的账号已冻结,如需帮助,请致电平台客服!");
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
//企业信息
|
|
//企业信息
|
|
|
EntCacheResDto enterprise = systemService.queryEntDetails(driver.getEntId());
|
|
EntCacheResDto enterprise = systemService.queryEntDetails(driver.getEntId());
|
|
|
|
|
|
|
|
- /**生成token**/
|
|
|
|
|
|
|
+ /*生成token**/
|
|
|
String token = generateToken(loginBase, driver.getId());
|
|
String token = generateToken(loginBase, driver.getId());
|
|
|
if (StringUtils.isBlank(token)) {
|
|
if (StringUtils.isBlank(token)) {
|
|
|
return HttpResult.error(HttpStatus.CODE_10301, "生成密钥失败,请联系系统管理员!");
|
|
return HttpResult.error(HttpStatus.CODE_10301, "生成密钥失败,请联系系统管理员!");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**缓存信息**/
|
|
|
|
|
- AsyncFactory.execute(new AsyncProcess1(loginBase, null, driver, enterprise, remoteUserService));
|
|
|
|
|
|
|
+ /*缓存信息**/
|
|
|
|
|
+ AsyncFactory.execute(new AsyncProcess(loginBase, null, driver, enterprise, remoteUserService));
|
|
|
|
|
|
|
|
- /**数据组装**/
|
|
|
|
|
|
|
+ /*数据组装**/
|
|
|
LoginResVo1 loginRes = new LoginResVo1();
|
|
LoginResVo1 loginRes = new LoginResVo1();
|
|
|
loginRes.setId(driver.getId());
|
|
loginRes.setId(driver.getId());
|
|
|
loginRes.setName(driver.getName());
|
|
loginRes.setName(driver.getName());
|
|
@@ -401,12 +163,11 @@ public class AuthServiceImpl implements IAuthService {
|
|
|
* @author zk
|
|
* @author zk
|
|
|
* @date 2023/7/26
|
|
* @date 2023/7/26
|
|
|
**/
|
|
**/
|
|
|
- @Override
|
|
|
|
|
public HttpResult commonAuth(LoginBase loginBase) {
|
|
public HttpResult commonAuth(LoginBase loginBase) {
|
|
|
- /**查询用户信息**/
|
|
|
|
|
|
|
+ /*查询用户信息**/
|
|
|
KwsUserResDto user = systemService.queryUserDetails(loginBase.getAccount(), loginBase.getSystemType());
|
|
KwsUserResDto user = systemService.queryUserDetails(loginBase.getAccount(), loginBase.getSystemType());
|
|
|
|
|
|
|
|
- /**信息校验**/
|
|
|
|
|
|
|
+ /*信息校验**/
|
|
|
if (user == null) {
|
|
if (user == null) {
|
|
|
return HttpResult.error(HttpStatus.QUERY_FAIL_CODE, "账号不存在,请检查并重新输入!");
|
|
return HttpResult.error(HttpStatus.QUERY_FAIL_CODE, "账号不存在,请检查并重新输入!");
|
|
|
}
|
|
}
|
|
@@ -429,23 +190,32 @@ public class AuthServiceImpl implements IAuthService {
|
|
|
|
|
|
|
|
//企业信息
|
|
//企业信息
|
|
|
EntCacheResDto enterprise = systemService.queryEntDetails(user.getEntId());
|
|
EntCacheResDto enterprise = systemService.queryEntDetails(user.getEntId());
|
|
|
- if (loginBase.getSystemType() == SystemTypeEnum.COMPANY.getCode() && enterprise == null) {
|
|
|
|
|
- return HttpResult.error(HttpStatus.QUERY_FAIL_CODE, "账号没有归属企业,请检查并重新输入!");
|
|
|
|
|
|
|
+ if (loginBase.getSystemType() == SystemTypeEnum.COMPANY.getCode()) {
|
|
|
|
|
+ if (enterprise == null) {
|
|
|
|
|
+ return HttpResult.error(HttpStatus.QUERY_FAIL_CODE, "账号没有归属企业,请检查并重新输入!");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //校验平台标识码(专场)
|
|
|
|
|
+ HttpResult result = checkSpecial(loginBase, enterprise);
|
|
|
|
|
+ if (result.getCode() != HttpStatus.SUCCESS_CODE) {
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
if (enterprise != null && enterprise.getStatus() == Global.YES) {
|
|
if (enterprise != null && enterprise.getStatus() == Global.YES) {
|
|
|
return HttpResult.error(HttpStatus.QUERY_FAIL_CODE, "企业已冻结,如需帮助,请致电平台客服!");
|
|
return HttpResult.error(HttpStatus.QUERY_FAIL_CODE, "企业已冻结,如需帮助,请致电平台客服!");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**生成token**/
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /*生成token**/
|
|
|
String token = generateToken(loginBase, user.getId());
|
|
String token = generateToken(loginBase, user.getId());
|
|
|
if (StringUtils.isBlank(token)) {
|
|
if (StringUtils.isBlank(token)) {
|
|
|
return HttpResult.error(HttpStatus.CODE_10301, "生成密钥失败,请联系系统管理员!");
|
|
return HttpResult.error(HttpStatus.CODE_10301, "生成密钥失败,请联系系统管理员!");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**缓存信息**/
|
|
|
|
|
- AsyncFactory.execute(new AsyncProcess1(loginBase, user, null, enterprise, remoteUserService));
|
|
|
|
|
|
|
+ /*缓存信息**/
|
|
|
|
|
+ AsyncFactory.execute(new AsyncProcess(loginBase, user, null, enterprise, remoteUserService));
|
|
|
|
|
|
|
|
- /**数据组装**/
|
|
|
|
|
|
|
+ /*数据组装**/
|
|
|
LoginResVo1 loginRes = new LoginResVo1();
|
|
LoginResVo1 loginRes = new LoginResVo1();
|
|
|
loginRes.setId(user.getId());
|
|
loginRes.setId(user.getId());
|
|
|
loginRes.setName(user.getName());
|
|
loginRes.setName(user.getName());
|
|
@@ -476,6 +246,114 @@ public class AuthServiceImpl implements IAuthService {
|
|
|
return HttpResult.ok(loginRes);
|
|
return HttpResult.ok(loginRes);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @param params 登录参数
|
|
|
|
|
+ * @return 返回结构
|
|
|
|
|
+ * @desc 登录参数校验
|
|
|
|
|
+ * @author zk
|
|
|
|
|
+ * @date 2020/6/14 18:14
|
|
|
|
|
+ **/
|
|
|
|
|
+ public HttpResult checkParams(LoginBase params) {
|
|
|
|
|
+ if (StringUtils.isBlank(params.getSystemType())) {
|
|
|
|
|
+ return HttpResult.error(HttpStatus.PARAMETERS_MISSING_CODE, "应用服务类型不能为空!");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StringUtils.isBlank(params.getClientType())) {
|
|
|
|
|
+ return HttpResult.error(HttpStatus.PARAMETERS_MISSING_CODE, "客户端类型不能为空!");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StringUtils.isBlank(params.getAccessSpecial())) {
|
|
|
|
|
+ return HttpResult.error(HttpStatus.PARAMETERS_MISSING_CODE, "平台标识不能为空!");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StringUtils.isBlank(params.getAccount())) {
|
|
|
|
|
+ return HttpResult.error(HttpStatus.PARAMETERS_MISSING_CODE, "请输入您的账号!");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (params.getLoginMethod() == LoginMethodEnum.ORDINARY.getValue() && StringUtils.isBlank(params.getPassword())) {
|
|
|
|
|
+ return HttpResult.error(HttpStatus.PARAMETERS_MISSING_CODE, "请输入您的密码!");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (params.getLoginMethod() == LoginMethodEnum.SMS.getValue() && !RegularUtils.matchs(RegularUtils.PHONE_REG, params.getAccount())) {
|
|
|
|
|
+ return HttpResult.error(HttpStatus.PARAMETERS_PATTERN_ERROR_CODE, "手机号格式不正确,请检查并重新输入!");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (params.getLoginMethod() == LoginMethodEnum.SMS.getValue() && StringUtils.isBlank(params.getCaptcha())) {
|
|
|
|
|
+ return HttpResult.error(HttpStatus.PARAMETERS_MISSING_CODE, "请输入您的验证码!");
|
|
|
|
|
+ }
|
|
|
|
|
+ String key = StringUtils.format(RedisConstant.MESSAGE_SMS_VERIFY_CODE_VALUE_KEY, DictEnum.SMS_LOGIN.getValue(), params.getAccount());
|
|
|
|
|
+
|
|
|
|
|
+ RedissonUtils.putString(key, params.getCaptcha(), RedisConstant.SMS_VERIFY_CODE_VALID_TIME);
|
|
|
|
|
+ String smsCaptcha = RedissonUtils.getString(key);
|
|
|
|
|
+ if (params.getLoginMethod() == LoginMethodEnum.SMS.getValue() && StringUtils.isBlank(smsCaptcha)) {
|
|
|
|
|
+ return HttpResult.error(HttpStatus.PARAMETERS_MISSING_CODE, "验证码已过期,请重新获取!");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (params.getLoginMethod() == LoginMethodEnum.SMS.getValue() && StringUtils.isBlank(smsCaptcha)) {
|
|
|
|
|
+ return HttpResult.error(HttpStatus.PARAMETERS_MISSING_CODE, "验证码已过期,请重新获取!");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (params.getLoginMethod() == LoginMethodEnum.SMS.getValue() && !smsCaptcha.equals(params.getCaptcha())) {
|
|
|
|
|
+ return HttpResult.error(HttpStatus.UN_LOGIN_CODE, "验证码不正确,请检查并重新输入!");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return HttpResult.ok();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @param loginBase 登录参数
|
|
|
|
|
+ * @param enterprise 企业信息
|
|
|
|
|
+ * @return 返回校验结果
|
|
|
|
|
+ * @desc 专场标识码校验
|
|
|
|
|
+ * @author zk
|
|
|
|
|
+ * @date 2023/12/14
|
|
|
|
|
+ **/
|
|
|
|
|
+ public HttpResult checkSpecial(LoginBase loginBase, EntCacheResDto enterprise) {
|
|
|
|
|
+ //平台专场集
|
|
|
|
|
+ List<SpecialResVo> specialResVos = systemService.findSpecial();
|
|
|
|
|
+ //企业所属专场
|
|
|
|
|
+ String special = enterprise != null ? enterprise.getSpecial() : null;
|
|
|
|
|
+ //用户当前使用平台
|
|
|
|
|
+ String accessSpecial = loginBase.getAccessSpecial();
|
|
|
|
|
+
|
|
|
|
|
+ /*校验*/
|
|
|
|
|
+ //校验是否存在专场数据
|
|
|
|
|
+ if (CollectionUtils.isEmpty(specialResVos)) {
|
|
|
|
|
+ return HttpResult.error(HttpStatus.PARAMETERS_MISSING_CODE, "系统平台标识码缺失,请联系平台系统管理员确认!");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //校验Hearder中标识码是否属于系统平台标识码
|
|
|
|
|
+ boolean bool = false;
|
|
|
|
|
+ SpecialResVo specialRes = null;
|
|
|
|
|
+ for (SpecialResVo specialResVo:specialResVos) {
|
|
|
|
|
+ bool = specialResVo.getCode().equals(accessSpecial) || bool;
|
|
|
|
|
+ specialRes = specialResVo.getCode().equals(accessSpecial) ? specialResVo : null;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!bool) {
|
|
|
|
|
+ return HttpResult.error(HttpStatus.PARAMETERS_MISSING_CODE, "系统平台标识码不正确,请联系平台系统管理员确认!");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //校验专场状态
|
|
|
|
|
+ if (specialRes != null && specialRes.getIsMain() != Global.YES) {
|
|
|
|
|
+ return HttpResult.error(HttpStatus.PARAMETERS_MISSING_CODE, "您当前使用的平台暂停使用,如有疑问请联系平台系统管理员确认!");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //校验企业非专场时,Hearder中标识码是否为主平台标识码
|
|
|
|
|
+ if (StringUtils.isBlank(special) ) {
|
|
|
|
|
+ if (specialRes != null && specialRes.getIsMain() != NumberConstant.ONE) {
|
|
|
|
|
+ String msg = "请进入"+ specialRes.getName() +",平台网站为"+ specialRes.getWebsite() +",如有疑问请联系平台系统管理员确认!";
|
|
|
|
|
+ return HttpResult.error(HttpStatus.PARAMETERS_MISSING_CODE, msg);
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ List<String> specials = Arrays.asList(special.split(Global.COMMA));
|
|
|
|
|
+ if (!specials.contains(accessSpecial)) {
|
|
|
|
|
+ StringBuilder msg = new StringBuilder();
|
|
|
|
|
+ msg.append("请进入");
|
|
|
|
|
+ for (String e : specials) {
|
|
|
|
|
+ specialResVos.stream().filter(ee -> {
|
|
|
|
|
+ return e.equals(ee.getCode());
|
|
|
|
|
+ }).map(ee -> "请进入" + ee.getName() + ",平台网站为" + ee.getWebsite() + ",").forEach(msg::append);
|
|
|
|
|
+ }
|
|
|
|
|
+ msg.append("如有疑问请联系平台系统管理员确认!");
|
|
|
|
|
+ return HttpResult.error(HttpStatus.PARAMETERS_MISSING_CODE, msg.toString());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ return HttpResult.ok();
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @return LoginResVo1
|
|
* @return LoginResVo1
|
|
@@ -540,7 +418,7 @@ public class AuthServiceImpl implements IAuthService {
|
|
|
return token;
|
|
return token;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- static class AsyncProcess1 implements Runnable {
|
|
|
|
|
|
|
+ static class AsyncProcess implements Runnable {
|
|
|
private final LoginBase loginBase;
|
|
private final LoginBase loginBase;
|
|
|
|
|
|
|
|
private final KwsUserResDto user;
|
|
private final KwsUserResDto user;
|
|
@@ -551,7 +429,7 @@ public class AuthServiceImpl implements IAuthService {
|
|
|
|
|
|
|
|
private final RemoteUserService remoteUserService;
|
|
private final RemoteUserService remoteUserService;
|
|
|
|
|
|
|
|
- public AsyncProcess1(LoginBase loginBase, KwsUserResDto user, RDriverDetailVo driver, EntCacheResDto enterprise,
|
|
|
|
|
|
|
+ public AsyncProcess(LoginBase loginBase, KwsUserResDto user, RDriverDetailVo driver, EntCacheResDto enterprise,
|
|
|
RemoteUserService remoteUserService) {
|
|
RemoteUserService remoteUserService) {
|
|
|
this.loginBase = loginBase;
|
|
this.loginBase = loginBase;
|
|
|
this.user = user;
|
|
this.user = user;
|
|
@@ -662,10 +540,10 @@ public class AuthServiceImpl implements IAuthService {
|
|
|
if (user.getIsMain().equals(Global.YES)) {
|
|
if (user.getIsMain().equals(Global.YES)) {
|
|
|
//获取所以运营端账号关联的企业(客户经理关联的企业)
|
|
//获取所以运营端账号关联的企业(客户经理关联的企业)
|
|
|
List<Long> userIds = remoteUserService.selectUserBySystemType(1);
|
|
List<Long> userIds = remoteUserService.selectUserBySystemType(1);
|
|
|
- /**带有数据权限*/
|
|
|
|
|
|
|
+ /*带有数据权限*/
|
|
|
enterpriseIds = remoteUserService.findEnterpriseListByIds(userIds);
|
|
enterpriseIds = remoteUserService.findEnterpriseListByIds(userIds);
|
|
|
//无数据权限,运营账号(客户经理关联)关联的企业即可
|
|
//无数据权限,运营账号(客户经理关联)关联的企业即可
|
|
|
-// enterpriseIds = remoteUserService.findEnterpriseListByUserIds(userIds);
|
|
|
|
|
|
|
+ //enterpriseIds = remoteUserService.findEnterpriseListByUserIds(userIds);
|
|
|
} else {
|
|
} else {
|
|
|
enterpriseIds = remoteUserService.findEnterpriseIds(user.getId());
|
|
enterpriseIds = remoteUserService.findEnterpriseIds(user.getId());
|
|
|
}
|
|
}
|
|
@@ -725,6 +603,5 @@ public class AuthServiceImpl implements IAuthService {
|
|
|
userLoginReqDto.setSource(loginResVo.getClientType());
|
|
userLoginReqDto.setSource(loginResVo.getClientType());
|
|
|
remoteUserService.saveUserLogin(userLoginReqDto);
|
|
remoteUserService.saveUserLogin(userLoginReqDto);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|