|
@@ -58,82 +58,83 @@ public class AuthServiceImpl implements IAuthService {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public LoginResVo login(LoginReqVo reqDto) {
|
|
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;
|
|
|
|
|
|
|
+// /*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;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private KwsUserResDto checkLogin(LoginReqVo reqDto) {
|
|
private KwsUserResDto checkLogin(LoginReqVo reqDto) {
|