| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.dingtalk.api.response.OapiV2DepartmentGetResponse; |
| | | import com.dingtalk.api.response.OapiV2UserGetResponse; |
| | | import com.dingtalk.api.response.OapiV2UserGetuserinfoResponse; |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | import com.doumee.config.DataSyncConfig; |
| | | import com.doumee.core.annotation.excel.ExcelImporter; |
| | |
| | | import com.doumee.core.haikang.model.param.respose.UserAddResponse; |
| | | import com.doumee.core.haikang.model.param.respose.UserDelResponse; |
| | | import com.doumee.core.haikang.service.HKService; |
| | | import com.doumee.dao.web.response.DDAuthorizeVO; |
| | | import com.doumee.service.business.third.TmsService; |
| | | import com.doumee.service.business.third.model.LoginUserInfo; |
| | | import com.doumee.service.business.third.model.PageData; |
| | |
| | | return wxAuthorizeVO; |
| | | } |
| | | |
| | | /** |
| | | * 微信授权 内部人员登录 |
| | | * @param wxAuthorizeVO |
| | | * @param openId |
| | | * @param source |
| | | */ |
| | | private void dealSystemUserAuthBiz(WxAuthorizeVO wxAuthorizeVO, String openId, Integer source) { |
| | | SystemUser user = systemUserMapper.selectOne(new QueryWrapper<SystemUser>().lambda() |
| | | .eq(SystemUser::getOpenid,openId) |
| | |
| | | wxAuthorizeVO.setToken(token); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 钉钉授权获取内部人员登录信息 |
| | | * @param ddAuthorizeVO |
| | | * @param unionId |
| | | * @param source |
| | | */ |
| | | private void dealSystemUserAuthBizByDD(DDAuthorizeVO ddAuthorizeVO, String unionId, Integer source) { |
| | | SystemUser user = systemUserMapper.selectOne(new QueryWrapper<SystemUser>().lambda() |
| | | .eq(SystemUser::getDdUnionId,unionId) |
| | | .in(SystemUser::getType,Constants.memberType.internal) |
| | | .eq(SystemUser::getDeleted,Constants.ZERO) |
| | | .last(" limit 1 ")); |
| | | //非访客用户 进行判断是否存在用户 |
| | | if(!Objects.isNull(user)){ |
| | | Member member = memberMapper.selectById(user.getMemberId()); |
| | | if(member == null || member.getIsdeleted() == Constants.ONE){ |
| | | return; |
| | | // throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"用户已删除,请联系管理员"); |
| | | } |
| | | if(member.getStatus() != Constants.ZERO){ |
| | | return; |
| | | // throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"用户已禁用,请联系管理员"); |
| | | } |
| | | if(StringUtils.isNotBlank(member.getIdcardNo())){ |
| | | member.setIdcardDecode(DESUtil.decrypt(Constants.EDS_PWD, member.getIdcardNo())); |
| | | } |
| | | String prefixUrl = systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_RESOURCE_PATH).getCode() + |
| | | systemDictDataBiz.queryByCode(Constants.FTP,Constants.MEMBER_IMG).getCode(); |
| | | member.setPrefixUrl(prefixUrl); |
| | | ddAuthorizeVO.setMember(member); |
| | | //司机 与 内部人员 提供token |
| | | String token = systemLoginService.loginByUserId(user.getId()); |
| | | ddAuthorizeVO.setToken(token); |
| | | } |
| | | } |
| | | |
| | | |
| | | private void dealDriverUserAuthBiz(WxAuthorizeVO wxAuthorizeVO, String openId, Integer source) { |
| | | SystemUser user = systemUserMapper.selectOne(new QueryWrapper<SystemUser>().lambda() |
| | | .eq(SystemUser::getOpenid,openId) |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 钉钉授权登录 |
| | | * @param code |
| | | * @param source |
| | | * @return |
| | | * @throws ApiException |
| | | */ |
| | | @Override |
| | | public DDAuthorizeVO ddAuthorize(String code, Integer source) throws ApiException { |
| | | if(StringUtils.isBlank(code)||Objects.isNull(source)){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | OapiV2UserGetuserinfoResponse.UserGetByCodeResponse userGetByCodeResponse = dingTalk.getDDUserByCode(code); |
| | | if(Objects.isNull(userGetByCodeResponse) |
| | | || StringUtils.isBlank(userGetByCodeResponse.getUnionid())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"钉钉授权失败"); |
| | | } |
| | | String unionId = userGetByCodeResponse.getUnionid(); |
| | | |
| | | DDAuthorizeVO ddAuthorizeVO = new DDAuthorizeVO(); |
| | | if(StringUtils.isBlank(unionId)){ |
| | | return ddAuthorizeVO; |
| | | } |
| | | ddAuthorizeVO.setUnionId(unionId); |
| | | // if(source==1){ |
| | | // //处理普通访客人员自动授权逻辑 |
| | | // dealVisitUserAuthBiz(wxAuthorizeVO,openId,source); |
| | | // }else if(source == 3){ |
| | | // //处理tms管控人员自动授权逻辑 |
| | | // dealGkUserAuthBiz(wxAuthorizeVO,openId,source); |
| | | // }else if(source == 0){ |
| | | // //如果是司机,则从system_user查询 |
| | | // dealDriverUserAuthBiz(wxAuthorizeVO,openId,source); |
| | | // }else{ |
| | | //如果是内部人员,则从system_user查询 |
| | | dealSystemUserAuthBizByDD(ddAuthorizeVO,unionId,source); |
| | | // } |
| | | return ddAuthorizeVO; |
| | | } |
| | | |
| | | |
| | | } |