提交 952a6f45 编写于 作者: rushui.chen's avatar rushui.chen

Merge branch 'release' of 192.168.110.53:com.pica.cloud.account/pica-cloud-account into release

流水线 #17713 已失败 于阶段
in 0 second
......@@ -22,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map;
@Api(description = "登录资源")
......@@ -120,16 +121,18 @@ public class LoginController extends AccountBaseController {
@PostMapping("/login/wechat/bind")
public PicaResponse bindWeChat(@RequestBody EncryptEntity entity) throws Exception {
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
request.setAccId(super.getAcctId());
loginService.bindWeChat(request);
return PicaResponse.toResponse();
long doctorId = super.getDoctorIdByToken();
String nickname = loginService.bindWeChat(doctorId, request);
Map<String, String> map = new HashMap();
map.put("nickname", nickname);
return PicaResponse.toResponse(map);
}
@ApiOperation("微信解除绑定接口")
@PutMapping("/login/wechat/unbind")
public PicaResponse unbindWeChat() {
Integer acctId = super.getAcctId();
loginService.unbindWeChat(acctId);
long doctorId = super.getDoctorIdByToken();
loginService.unbindWeChat(doctorId);
return PicaResponse.toResponse();
}
......
......@@ -92,4 +92,6 @@ public interface DoctorMapper {
* @return
*/
//Long selectDoctorIdByMobile(String mobile);
Integer getAcctIdByDoctorId(long id);
}
\ No newline at end of file
......@@ -39,9 +39,9 @@ public interface LoginService {
/**
* 解除绑定
*
* @param acctId 账户id
* @param doctorId 账户id
*/
void unbindWeChat(Integer acctId);
void unbindWeChat(long doctorId);
/**
......@@ -49,7 +49,7 @@ public interface LoginService {
*
* @param request 参数模型
*/
void bindWeChat(BaseRequest request);
String bindWeChat(long doctorId, BaseRequest request);
PICAPDoctor queryDoctor(long doctorId);
}
......@@ -261,7 +261,8 @@ public class LoginServiceImpl implements LoginService {
@Override
@Transactional
public void unbindWeChat(Integer acctId) {
public void unbindWeChat(long doctorId) {
Integer acctId = doctorInfoMapper.getAcctIdByDoctorId(doctorId);
accountUnionMapper.updateUnbindByAcctId(acctId);
if (doubleWritingMode) {
doctorService.unbindWeChat(acctId);
......@@ -270,7 +271,7 @@ public class LoginServiceImpl implements LoginService {
@Override
@Transactional
public void bindWeChat(BaseRequest request) {
public String bindWeChat(long doctorId, BaseRequest request) {
WeChatEntity weChatEntity = WeChatUtils.getAuthorizationInfo(appId, appSecret, request.getWeChatCode());
Map map = new HashMap();
map.put("access_token", weChatEntity.getAccess_token());
......@@ -281,8 +282,12 @@ public class LoginServiceImpl implements LoginService {
AccountWeChatInfoEntity entity = accountWeChatInfoMapper.selectByUnionId(unionId);
if (entity == null) {
processWeChatInfoUser(weChatUserInfoEntity, request.getWeChatLoginType());
} else {
updateWechatInfoUser(entity, weChatUserInfoEntity);
}
processAccountUnion(request.getAccId(), unionId);
Integer acctId = doctorInfoMapper.getAcctIdByDoctorId(doctorId);
processAccountUnion(acctId, unionId);
return weChatUserInfoEntity.getNickname();
}
/**
......@@ -334,6 +339,16 @@ public class LoginServiceImpl implements LoginService {
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) {
PICAPDoctor doctor = doctorInfoMapper.queryDoctor(doctorId);
if (doctor == null) {
......
......@@ -29,7 +29,8 @@
select
<include refid="Base_Column_List"/>
from account_union
where union_id = #{unionId}
where union_id = #{unionId} and delete_flag = 1
limit 1
</select>
<!--解除绑定关系-->
......
......@@ -44,7 +44,8 @@
select
<include refid="Base_Column_List"/>
from account_wechat_info
where unionid = #{id}
where unionid = #{id} and delete_flag = 1
limit 1
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
......
......@@ -1026,4 +1026,8 @@
FROM p_doctor aa
where aa.id = #{doctorId} and aa.delete_flag = 1
</select>
<select id="getAcctIdByDoctorId" resultType="java.lang.Integer" parameterType="java.lang.Long">
select acct_id from p_doctor where id = #{id}
</select>
</mapper>
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册