|
|
@ -1,11 +1,10 @@
|
|
|
|
package com.ruoyi.system.service.impl;
|
|
|
|
package com.ruoyi.system.service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.ruoyi.common.constant.Constants;
|
|
|
|
|
|
|
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
|
|
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
|
|
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
|
|
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
|
import com.ruoyi.common.utils.MessageUtils;
|
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
|
import com.ruoyi.common.utils.http.HttpUtils;
|
|
|
|
import com.ruoyi.common.utils.http.HttpUtils;
|
|
|
|
import com.ruoyi.common.utils.ip.IpUtils;
|
|
|
|
import com.ruoyi.common.utils.ip.IpUtils;
|
|
|
@ -20,10 +19,12 @@ import com.ruoyi.system.domain.resp.GetOpenidResp;
|
|
|
|
import com.ruoyi.system.mapper.TDoctorMapper;
|
|
|
|
import com.ruoyi.system.mapper.TDoctorMapper;
|
|
|
|
import com.ruoyi.system.mapper.TPatientMapper;
|
|
|
|
import com.ruoyi.system.mapper.TPatientMapper;
|
|
|
|
import com.ruoyi.system.mapper.TWechatUserMapper;
|
|
|
|
import com.ruoyi.system.mapper.TWechatUserMapper;
|
|
|
|
|
|
|
|
import com.ruoyi.system.service.ISysUserService;
|
|
|
|
import com.ruoyi.system.service.IWechatService;
|
|
|
|
import com.ruoyi.system.service.IWechatService;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
|
@ -66,6 +67,9 @@ public class WechatServiceImpl implements IWechatService {
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private UserTokenService userTokenService;
|
|
|
|
private UserTokenService userTokenService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private ISysUserService userService;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public GetOpenidResp getOpenid(GetOpenidReq req, HttpServletRequest request) {
|
|
|
|
public GetOpenidResp getOpenid(GetOpenidReq req, HttpServletRequest request) {
|
|
|
|
//查询openid
|
|
|
|
//查询openid
|
|
|
@ -151,12 +155,24 @@ public class WechatServiceImpl implements IWechatService {
|
|
|
|
wechatUser.setUserId(currentDoctor.getId());
|
|
|
|
wechatUser.setUserId(currentDoctor.getId());
|
|
|
|
tDoctor.setId(currentDoctor.getId());
|
|
|
|
tDoctor.setId(currentDoctor.getId());
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// 不存在 患者信息入库
|
|
|
|
SysUser sysUser = new SysUser();
|
|
|
|
|
|
|
|
sysUser.setPhonenumber(req.getPhone());
|
|
|
|
|
|
|
|
sysUser.setUserName(req.getPhone());
|
|
|
|
|
|
|
|
sysUser.setNickName(req.getName());
|
|
|
|
|
|
|
|
sysUser.setStatus("0");
|
|
|
|
|
|
|
|
sysUser.setDelFlag("0");
|
|
|
|
|
|
|
|
sysUser.setPassword(SecurityUtils.encryptPassword("123456"));
|
|
|
|
|
|
|
|
Long[] roles = new Long[]{3L};
|
|
|
|
|
|
|
|
sysUser.setRoleIds(roles);
|
|
|
|
|
|
|
|
userService.insertUser(sysUser);
|
|
|
|
|
|
|
|
// 不存在 医生信息入库
|
|
|
|
tDoctor.setDelFlag("0");
|
|
|
|
tDoctor.setDelFlag("0");
|
|
|
|
tDoctor.setCreateTime(new Date());
|
|
|
|
tDoctor.setCreateTime(new Date());
|
|
|
|
tDoctor.setUpdateTime(new Date());
|
|
|
|
tDoctor.setUpdateTime(new Date());
|
|
|
|
|
|
|
|
tDoctor.setUserId(sysUser.getUserId());
|
|
|
|
tDoctorMapper.insertTDoctor(tDoctor);
|
|
|
|
tDoctorMapper.insertTDoctor(tDoctor);
|
|
|
|
wechatUser.setUserId(tDoctor.getId());
|
|
|
|
wechatUser.setUserId(tDoctor.getId());
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 绑定openid
|
|
|
|
// 绑定openid
|
|
|
|
wechatUser.setUnionid(req.getUnionid());
|
|
|
|
wechatUser.setUnionid(req.getUnionid());
|
|
|
@ -183,6 +199,7 @@ public class WechatServiceImpl implements IWechatService {
|
|
|
|
String url = String.format(WechatKeys.WECHAT_CODE_TO_UNIONID_URL, wechatAppId, wechatSecret, req.getCode());
|
|
|
|
String url = String.format(WechatKeys.WECHAT_CODE_TO_UNIONID_URL, wechatAppId, wechatSecret, req.getCode());
|
|
|
|
String json = HttpUtils.sendGet(url);
|
|
|
|
String json = HttpUtils.sendGet(url);
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(json);
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(json);
|
|
|
|
|
|
|
|
logger.info("login wechat user info :{}", jsonObject.toJSONString());
|
|
|
|
String unionid = (String) jsonObject.get("unionid");
|
|
|
|
String unionid = (String) jsonObject.get("unionid");
|
|
|
|
logger.info("login openid:{}", unionid);
|
|
|
|
logger.info("login openid:{}", unionid);
|
|
|
|
if (StringUtils.isEmpty(unionid)) {
|
|
|
|
if (StringUtils.isEmpty(unionid)) {
|
|
|
@ -256,7 +273,8 @@ public class WechatServiceImpl implements IWechatService {
|
|
|
|
loginUser.setUserId(tDoctor.getUserId());
|
|
|
|
loginUser.setUserId(tDoctor.getUserId());
|
|
|
|
SysUser user = new SysUser();
|
|
|
|
SysUser user = new SysUser();
|
|
|
|
user.setUserId(tDoctor.getUserId());
|
|
|
|
user.setUserId(tDoctor.getUserId());
|
|
|
|
user.setUserName(tDoctor.getName());
|
|
|
|
user.setUserName(tDoctor.getPhone());
|
|
|
|
|
|
|
|
user.setNickName(tDoctor.getName());
|
|
|
|
user.setDelFlag(tDoctor.getDelFlag());
|
|
|
|
user.setDelFlag(tDoctor.getDelFlag());
|
|
|
|
user.setSex(tDoctor.getSex());
|
|
|
|
user.setSex(tDoctor.getSex());
|
|
|
|
user.setPhonenumber(tDoctor.getPhone());
|
|
|
|
user.setPhonenumber(tDoctor.getPhone());
|
|
|
|