|
|
@@ -19,6 +19,8 @@ import com.nb.app.msg.enums.MsgEnum;
|
|
|
import com.nb.app.msg.event.SaveMsgEvent;
|
|
|
import com.nb.auth.utils.SecurityUtil;
|
|
|
import com.nb.common.crud.BaseService;
|
|
|
+import com.nb.core.exception.CustomException;
|
|
|
+import com.nb.web.api.feign.IPatientClient;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
@@ -39,6 +41,11 @@ public class LocalAssistantUserBindService extends BaseService<AssistantUserBind
|
|
|
@Autowired
|
|
|
@Lazy
|
|
|
private LocalAssistantUserService userService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ @Lazy
|
|
|
+ private IPatientClient patientClient;
|
|
|
+
|
|
|
@Override
|
|
|
public void validateBeforeSave(AssistantUserBindEntity entity) {
|
|
|
|
|
|
@@ -140,6 +147,28 @@ public class LocalAssistantUserBindService extends BaseService<AssistantUserBind
|
|
|
@Override
|
|
|
public boolean handleBindResult(HandleBindResult source) {
|
|
|
//todo 发送处理结果信息
|
|
|
+ AssistantUserBindEntity userBind = this.findById(source.getBindId());
|
|
|
+ if(source.getAgree()){
|
|
|
+ //判断是否重复绑定
|
|
|
+ AssistantUserBindEntity existBind = this.getOne(new QueryWrapper<AssistantUserBindEntity>()
|
|
|
+ .lambda()
|
|
|
+ .eq(AssistantUserBindEntity::getPatientId, userBind.getPatientId())
|
|
|
+ .eq(AssistantUserBindEntity::getStatus, BindEnum.SUCCESS)
|
|
|
+ .last("limit 1"));
|
|
|
+ if(existBind!=null){
|
|
|
+ throw new CustomException("该用户已被看护,请勿重复绑定");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ boolean result = this.update(new UpdateWrapper<AssistantUserBindEntity>()
|
|
|
+ .lambda()
|
|
|
+ .eq(AssistantUserBindEntity::getId, source.getBindId())
|
|
|
+ .set(AssistantUserBindEntity::getDoctorId, source.getDoctorId())
|
|
|
+ .set(AssistantUserBindEntity::getStatus, source.getAgree() ? BindEnum.SUCCESS : BindEnum.REFUSE)
|
|
|
+ .set(!source.getAgree(), AssistantUserBindEntity::getRefuseReason, source.getRefuseReason()));
|
|
|
+ if(result&&source.getAgree()&&StrUtil.isNotEmpty(userBind.getInviteCode())){
|
|
|
+ //绑定成功后删除邀请码
|
|
|
+ patientClient.delInviteCode(userBind.getInviteCode());
|
|
|
+ }
|
|
|
return this.update(new UpdateWrapper<AssistantUserBindEntity>()
|
|
|
.lambda()
|
|
|
.eq(AssistantUserBindEntity::getId,source.getBindId())
|