| | |
| | | import doumeemes.dao.ext.DepartmentExtMapper; |
| | | import doumeemes.dao.ext.dto.QueryCompanyUserExtDTO; |
| | | import doumeemes.dao.ext.dto.WxLoginDTO; |
| | | import doumeemes.dao.ext.dto.WxLoginOutDTO; |
| | | import doumeemes.dao.ext.vo.CompanyUserExtListVO; |
| | | import doumeemes.dao.ext.vo.WxLoginVO; |
| | | import doumeemes.dao.system.SystemUserMapper; |
| | |
| | | |
| | | @Override |
| | | public WxLoginVO wxLogin(String code, HttpServletRequest request) { |
| | | WxLoginVO wxLoginVO = new WxLoginVO(); |
| | | |
| | | String appId = systemDictDataBiz.queryByCode(Constants.WX_CONFIG,Constants.APPID).getCode(); |
| | | String appSecret = systemDictDataBiz.queryByCode(Constants.WX_CONFIG,Constants.APPSECRET).getCode(); |
| | | String getTokenUrl = GET_ACCESS_TOKEN_URL.replace("CODE", code).replace("APPID", appId).replace("SECRET", appSecret); |
| | |
| | | String openId = tokenJson.getString("openid"); |
| | | String getUserInfoUrl = GET_USER_INFO_URL.replace("ACCESS_TOKEN", accessToken).replace("OPENID", openId); |
| | | JSONObject userInfoJson = JSONObject.parseObject(HttpsUtil.get(getUserInfoUrl,true)); |
| | | return loginByUnionIdAndReturn(userInfoJson.getString("unionid"),openId,request); |
| | | |
| | | } |
| | | |
| | | private WxLoginVO loginByUnionIdAndReturn(String unionid,String openId,HttpServletRequest request) { |
| | | WxLoginVO wxLoginVO = new WxLoginVO(); |
| | | wxLoginVO.setOpenid(openId); |
| | | wxLoginVO.setUnionid(userInfoJson.getString("unionid")); |
| | | CompanyUser companyUser = companyUserExtMapper.selectOne(new QueryWrapper<CompanyUser>().eq("openid",openId).last(" limit 1 ")); |
| | | wxLoginVO.setUnionid(unionid); |
| | | CompanyUser companyUser = companyUserExtMapper.selectOne(new QueryWrapper<CompanyUser>().lambda() |
| | | .eq(CompanyUser::getUnionid,wxLoginVO.getUnionid()) |
| | | .eq(CompanyUser::getDeleted,Constants.ZERO) |
| | | .last(" limit 1 ")); |
| | | // CompanyUser companyUser = companyUserExtMapper.selectOne(new QueryWrapper<CompanyUser>().eq("openid",openId).last(" limit 1 ")); |
| | | if(Objects.isNull(companyUser)){ |
| | | wxLoginVO.setLoginStatus(Constants.ONE); |
| | | return wxLoginVO; |
| | |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到绑定部门信息"); |
| | | } |
| | | Company company = companyExtMapper.selectById(department.getCompanyId()); |
| | | if(Objects.isNull(company)||company.getStatus().equals(Constants.ONE)){ |
| | | if(Objects.isNull(company)||company.getStatus().equals(Constants.ZERO)){ |
| | | wxLoginVO.setLoginStatus(Constants.ONE); |
| | | return wxLoginVO; |
| | | } |
| | |
| | | systemLoginLogService.create(loginLog); |
| | | throw ee; |
| | | } |
| | | return wxLoginVO; |
| | | } |
| | | |
| | | @Override |
| | | public WxLoginVO wxProgramLogin(String unionId,String openId, HttpServletRequest request) { |
| | | return loginByUnionIdAndReturn(unionId,openId,request); |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void wxLoginOut(WxLoginOutDTO wxLoginOutDTO) { |
| | | if(!Objects.isNull(wxLoginOutDTO)&&!Objects.isNull(wxLoginOutDTO.getCompanyUserId())){ |
| | | companyUserExtMapper.update(null,new UpdateWrapper<CompanyUser>() |
| | | .set("UNIONID","").set("OPENID","") |
| | | .eq("id",wxLoginOutDTO.getCompanyUserId()) |
| | | ); |
| | | } |
| | | } |
| | | |
| | | } |