|
|
@@ -6,25 +6,25 @@ import com.sckw.auth.model.vo.req.*;
|
|
|
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.LoginResVo1;
|
|
|
import com.sckw.auth.util.AsyncFactory;
|
|
|
+import com.sckw.core.model.enums.ClientTypeEnum;
|
|
|
import com.sckw.core.model.enums.SystemTypeEnum;
|
|
|
-import com.sckw.core.utils.StringUtils;
|
|
|
+import com.sckw.core.utils.*;
|
|
|
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.response.HttpResult;
|
|
|
+import com.sckw.fleet.api.RemoteFleetService;
|
|
|
+import com.sckw.fleet.api.model.vo.RDriverDetailVo;
|
|
|
import com.sckw.message.api.dubbo.SmsInfoService;
|
|
|
-import com.sckw.system.api.model.dto.req.ForgetPasswordReqDto;
|
|
|
-import com.sckw.system.api.model.dto.req.UpdatePasswordReqDto;
|
|
|
-import com.sckw.system.api.model.dto.req.UserLoginReqDto;
|
|
|
+import com.sckw.system.api.RemoteSystemService;
|
|
|
+import com.sckw.system.api.model.dto.req.*;
|
|
|
import com.sckw.system.api.model.dto.res.KwsRoleResDto;
|
|
|
import com.sckw.core.exception.SystemException;
|
|
|
import com.sckw.core.model.constant.Global;
|
|
|
-import com.sckw.core.utils.BeanUtils;
|
|
|
-import com.sckw.core.utils.CollectionUtils;
|
|
|
-import com.sckw.core.utils.EncryUtil;
|
|
|
import com.sckw.core.web.constant.HttpStatus;
|
|
|
import com.sckw.redis.utils.RedissonUtils;
|
|
|
-import com.sckw.system.api.model.dto.req.RegisterReqDto;
|
|
|
import com.sckw.system.api.model.dto.res.*;
|
|
|
import com.sckw.auth.service.IAuthService;
|
|
|
import com.sckw.system.api.RemoteUserService;
|
|
|
@@ -47,9 +47,14 @@ public class AuthServiceImpl implements IAuthService {
|
|
|
@DubboReference(version = "2.0.0", group = "design", check = false)
|
|
|
private RemoteUserService remoteUserService;
|
|
|
|
|
|
+ @DubboReference(version = "2.0.0", group = "design", check = false)
|
|
|
+ private RemoteSystemService systemService;
|
|
|
+
|
|
|
@DubboReference(version = "2.0.0", group = "design", check = false)
|
|
|
private SmsInfoService smsInfoService;
|
|
|
|
|
|
+ @DubboReference(version = "1.0.0", group = "design", check = false)
|
|
|
+ private RemoteFleetService fleetService;
|
|
|
|
|
|
@Override
|
|
|
public LoginResVo login(LoginReqVo reqDto) throws SystemException {
|
|
|
@@ -353,4 +358,153 @@ public class AuthServiceImpl implements IAuthService {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**-------------------------------------------------------------------------------------------------------------->**/
|
|
|
+ @Override
|
|
|
+ public HttpResult driverAuth(LoginBase loginBase) {
|
|
|
+ /**查询用户信息**/
|
|
|
+ RDriverDetailVo driver = fleetService.findDriver(loginBase.getAccount());
|
|
|
+ /**信息校验**/
|
|
|
+ if (driver == null) {
|
|
|
+ return HttpResult.error(HttpStatus.QUERY_FAIL_CODE, "账号不存在,请检查并重新输入!");
|
|
|
+ }
|
|
|
+ if (!PasswordUtils.validatePassword(loginBase.getPassword(), driver.getPassword())) {
|
|
|
+ return HttpResult.error(HttpStatus.CODE_10301, "密码不正确,请检查并重新输入!");
|
|
|
+ }
|
|
|
+ if (driver.getStatus() == Global.YES) {
|
|
|
+ return HttpResult.error(HttpStatus.CODE_10301, "您的账号已冻结,如需帮助,请致电平台客服:400-803-6377!");
|
|
|
+ }
|
|
|
+ //企业信息
|
|
|
+ REnterpriseVo enterprise = systemService.queryEntDetails(driver.getEntId());
|
|
|
+
|
|
|
+ /**生成token**/
|
|
|
+ String token = EncryUtil.encryV1(Global.PRI_KEY, String.valueOf(driver.getId()));
|
|
|
+ if (StringUtils.isBlank(token)) {
|
|
|
+ return HttpResult.error(HttpStatus.CODE_10301, "生成密钥失败,请联系系统管理员!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**缓存司机/企业信息**/
|
|
|
+ AsyncFactory.execute(new AsyncProcess1(loginBase, driver, enterprise));
|
|
|
+
|
|
|
+ /**数据组装**/
|
|
|
+ LoginResVo1 loginRes = new LoginResVo1();
|
|
|
+ loginRes.setAccount(loginBase.getAccount());
|
|
|
+ loginRes.setFirmName(enterprise.getFirmName());
|
|
|
+ loginRes.setApproval(enterprise.getApproval());
|
|
|
+ loginRes.setEntTypeNames(enterprise.getEntTypeNames());
|
|
|
+ loginRes.setClientType(loginBase.getClientType());
|
|
|
+ loginRes.setSystemType(loginBase.getSystemType());
|
|
|
+ loginRes.setToken(token);
|
|
|
+ return HttpResult.ok(loginRes);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HttpResult entAuth(LoginBase loginBase) {
|
|
|
+ /**查询用户信息**/
|
|
|
+ KwsUserResDto user = findUser(loginBase);
|
|
|
+ /**信息校验**/
|
|
|
+ if (user == null) {
|
|
|
+ return HttpResult.error(HttpStatus.QUERY_FAIL_CODE, "账号不存在,请检查并重新输入!");
|
|
|
+ }
|
|
|
+ if (!PasswordUtils.validatePassword(loginBase.getPassword(), user.getPassword())) {
|
|
|
+ return HttpResult.error(HttpStatus.CODE_10301, "密码不正确,请检查并重新输入!");
|
|
|
+ }
|
|
|
+ if (user.getStatus() == Global.YES) {
|
|
|
+ return HttpResult.error(HttpStatus.CODE_10301, "您的账号已冻结,如需帮助,请致电平台客服:400-803-6377!");
|
|
|
+ }
|
|
|
+ //企业信息
|
|
|
+ REnterpriseVo enterprise = systemService.queryEntDetails(null);
|
|
|
+
|
|
|
+ /**生成token**/
|
|
|
+ String token = EncryUtil.encryV1(Global.PRI_KEY, String.valueOf(user.getId()));
|
|
|
+ if (StringUtils.isBlank(token)) {
|
|
|
+ return HttpResult.error(HttpStatus.CODE_10301, "生成密钥失败,请联系系统管理员!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**缓存司机/企业信息**/
|
|
|
+ AsyncFactory.execute(new AsyncProcess1(loginBase, null, enterprise));
|
|
|
+
|
|
|
+ /**数据组装**/
|
|
|
+ LoginResVo1 loginRes = new LoginResVo1();
|
|
|
+ loginRes.setAccount(loginBase.getAccount());
|
|
|
+ loginRes.setFirmName(enterprise.getFirmName());
|
|
|
+ loginRes.setApproval(enterprise.getApproval());
|
|
|
+ loginRes.setEntTypeNames(enterprise.getEntTypeNames());
|
|
|
+ loginRes.setClientType(loginBase.getClientType());
|
|
|
+ loginRes.setSystemType(loginBase.getSystemType());
|
|
|
+ loginRes.setToken(token);
|
|
|
+ return HttpResult.ok(loginRes);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HttpResult operateAuth(LoginBase loginBase) {
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private KwsUserResDto findUser(LoginBase loginBase) throws SystemException {
|
|
|
+ List<KwsUserResDto> kwsUsers = remoteUserService.checkUserBase(loginBase.getAccount(), loginBase.getSystemType());
|
|
|
+ return kwsUsers == null || kwsUsers.size() == Global.NUMERICAL_ZERO ? null : kwsUsers.get(0);
|
|
|
+ }
|
|
|
+
|
|
|
+ static class AsyncProcess1 implements Runnable {
|
|
|
+ private final LoginBase loginBase;
|
|
|
+
|
|
|
+ private final RDriverDetailVo driver;
|
|
|
+
|
|
|
+ private final REnterpriseVo enterprise;
|
|
|
+
|
|
|
+ public AsyncProcess1(LoginBase loginBase, RDriverDetailVo driver, REnterpriseVo enterprise) {
|
|
|
+ this.loginBase = loginBase;
|
|
|
+ this.driver = driver;
|
|
|
+ this.enterprise = enterprise;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ //用户信息
|
|
|
+ SaveDriverToCache(loginBase, driver);
|
|
|
+
|
|
|
+ //企业信息
|
|
|
+ SaveEntToCache(enterprise);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param ent 企业信息
|
|
|
+ * @desc: 缓存存企业信息
|
|
|
+ * @author: czh
|
|
|
+ * @date: 2023/7/3
|
|
|
+ */
|
|
|
+ private void SaveEntToCache(REnterpriseVo ent) {
|
|
|
+ if (ent == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ LoginEntInfo loginEntInfo = new LoginEntInfo();
|
|
|
+ BeanUtils.copyProperties(ent, loginEntInfo);
|
|
|
+ String key = Global.REDIS_ENTERPRISE_PREFIX + ent.getId();
|
|
|
+ RedissonUtils.putString(key, JSON.toJSONString(loginEntInfo), Global.PC_TOKEN_EXPIRE);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param loginBase 登录信息
|
|
|
+ * @param driver 司机信息
|
|
|
+ * @desc: 缓存用户业信息
|
|
|
+ * @author: czh
|
|
|
+ * @date: 2023/7/3
|
|
|
+ */
|
|
|
+ private void SaveDriverToCache(LoginBase loginBase, RDriverDetailVo driver) {
|
|
|
+ //存用户登录信息
|
|
|
+ LoginUserInfo loginUserInfo = new LoginUserInfo();
|
|
|
+ loginUserInfo.setId(driver.getId());
|
|
|
+ loginUserInfo.setSystemType(SystemTypeEnum.DRIVER.getCode());
|
|
|
+ loginUserInfo.setAccount(driver.getPhone());
|
|
|
+ loginUserInfo.setUserName(driver.getName());
|
|
|
+ loginUserInfo.setPhone(driver.getPhone());
|
|
|
+ loginUserInfo.setStatus(driver.getStatus());
|
|
|
+ loginUserInfo.setEntId(enterprise != null ? enterprise.getId() : null);
|
|
|
+ loginUserInfo.setEntName(enterprise != null ? enterprise.getFirmName() : null);
|
|
|
+ String key = Global.getFullUserLoginKey(loginUserInfo.getSystemType(), loginUserInfo.getId(), loginBase.getClientType());
|
|
|
+ RedissonUtils.putString(key, JSON.toJSONString(loginUserInfo), Global.PC_TOKEN_EXPIRE);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|