提交 b1e2b7c3 编写于 作者: dong.an's avatar dong.an

微信登录修改

上级 cc6e2800
流水线 #16778 已失败 于阶段
in 0 second
...@@ -22,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -22,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
@Api(description = "登录资源") @Api(description = "登录资源")
...@@ -121,8 +122,10 @@ public class LoginController extends AccountBaseController { ...@@ -121,8 +122,10 @@ public class LoginController extends AccountBaseController {
public PicaResponse bindWeChat(@RequestBody EncryptEntity entity) throws Exception { public PicaResponse bindWeChat(@RequestBody EncryptEntity entity) throws Exception {
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class); BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
long doctorId = super.getDoctorIdByToken(); long doctorId = super.getDoctorIdByToken();
loginService.bindWeChat(doctorId, request); String nickname = loginService.bindWeChat(doctorId, request);
return PicaResponse.toResponse(); Map<String, String> map = new HashMap();
map.put("nickname", nickname);
return PicaResponse.toResponse(map);
} }
@ApiOperation("微信解除绑定接口") @ApiOperation("微信解除绑定接口")
......
...@@ -49,7 +49,7 @@ public interface LoginService { ...@@ -49,7 +49,7 @@ public interface LoginService {
* *
* @param request 参数模型 * @param request 参数模型
*/ */
void bindWeChat(long doctorId, BaseRequest request); String bindWeChat(long doctorId, BaseRequest request);
PICAPDoctor queryDoctor(long doctorId); PICAPDoctor queryDoctor(long doctorId);
} }
...@@ -270,7 +270,7 @@ public class LoginServiceImpl implements LoginService { ...@@ -270,7 +270,7 @@ public class LoginServiceImpl implements LoginService {
@Override @Override
@Transactional @Transactional
public void bindWeChat(long doctorId, BaseRequest request) { public String bindWeChat(long doctorId, BaseRequest request) {
WeChatEntity weChatEntity = WeChatUtils.getAuthorizationInfo(appId, appSecret, request.getWeChatCode()); WeChatEntity weChatEntity = WeChatUtils.getAuthorizationInfo(appId, appSecret, request.getWeChatCode());
Map map = new HashMap(); Map map = new HashMap();
map.put("access_token", weChatEntity.getAccess_token()); map.put("access_token", weChatEntity.getAccess_token());
...@@ -281,9 +281,12 @@ public class LoginServiceImpl implements LoginService { ...@@ -281,9 +281,12 @@ public class LoginServiceImpl implements LoginService {
AccountWeChatInfoEntity entity = accountWeChatInfoMapper.selectByUnionId(unionId); AccountWeChatInfoEntity entity = accountWeChatInfoMapper.selectByUnionId(unionId);
if (entity == null) { if (entity == null) {
processWeChatInfoUser(weChatUserInfoEntity, request.getWeChatLoginType()); processWeChatInfoUser(weChatUserInfoEntity, request.getWeChatLoginType());
} else {
updateWechatInfoUser(entity, weChatUserInfoEntity);
} }
Integer acctId = doctorInfoMapper.getAcctIdByDoctorId(doctorId); Integer acctId = doctorInfoMapper.getAcctIdByDoctorId(doctorId);
processAccountUnion(acctId, unionId); processAccountUnion(acctId, unionId);
return weChatUserInfoEntity.getNickname();
} }
/** /**
...@@ -335,6 +338,16 @@ public class LoginServiceImpl implements LoginService { ...@@ -335,6 +338,16 @@ public class LoginServiceImpl implements LoginService {
accountWeChatInfoMapper.insertSelective(accountWeChatInfoEntity); accountWeChatInfoMapper.insertSelective(accountWeChatInfoEntity);
} }
private void updateWechatInfoUser(AccountWeChatInfoEntity entity, WeChatUserInfoEntity weChatUserInfoEntity) {
String nickname = weChatUserInfoEntity.getNickname();
if (StringUtils.isNotEmpty(nickname) && !nickname.equals(entity.getNickname())) {
AccountWeChatInfoEntity info = new AccountWeChatInfoEntity();
info.setId(entity.getId());
info.setNickname(nickname);
accountWeChatInfoMapper.updateByPrimaryKeySelective(info);
}
}
public PICAPDoctor queryDoctor(long doctorId) { public PICAPDoctor queryDoctor(long doctorId) {
PICAPDoctor doctor = doctorInfoMapper.queryDoctor(doctorId); PICAPDoctor doctor = doctorInfoMapper.queryDoctor(doctorId);
if (doctor == null) { if (doctor == null) {
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册