|
@@ -10,6 +10,7 @@ import com.ruoyi.web.work.domain.User;
|
|
|
import com.ruoyi.web.work.domain.dto.BindDto;
|
|
|
import com.ruoyi.web.work.mapper.BindUserMapper;
|
|
|
import com.ruoyi.web.work.service.IBindUserService;
|
|
|
+import com.ruoyi.web.work.service.IPatientService;
|
|
|
import com.ruoyi.web.work.service.IUserService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -33,6 +34,9 @@ public class BindUserServiceImpl extends ServiceImpl<BindUserMapper, BindUser> i
|
|
|
@Autowired
|
|
|
private TokenServices tokenService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IPatientService patientService;
|
|
|
+
|
|
|
@Override
|
|
|
public List<BindUser> selectList(BindUser bindUser) {
|
|
|
return bindUserMapper.selectList(bindUser);
|
|
@@ -41,9 +45,9 @@ public class BindUserServiceImpl extends ServiceImpl<BindUserMapper, BindUser> i
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public AjaxResult bind(BindDto dto) throws ServerException {
|
|
|
- Patient patient = bindUserMapper.selectPatient(new Patient().setPhone(dto.getPhone()));
|
|
|
+ Patient patient = bindUserMapper.selectPatient(dto);
|
|
|
if (patient == null) {
|
|
|
- return AjaxResult.error("预留的就诊人手机号不存在");
|
|
|
+ return AjaxResult.error("预留的信息不存在或输入错误");
|
|
|
}
|
|
|
BindUser bindUser = new BindUser();
|
|
|
bindUser.setPatientId(patient.getId());
|
|
@@ -79,6 +83,14 @@ public class BindUserServiceImpl extends ServiceImpl<BindUserMapper, BindUser> i
|
|
|
if (!removeById(id)) {
|
|
|
throw new ServerException("删除就诊人失败");
|
|
|
}
|
|
|
+ //如果移除的是当前就诊人删除其缓存信息
|
|
|
+ if (bindUser.getPatientId().equals(AppUtil.getUser().getPatientId())) {
|
|
|
+ User user = AppUtil.getUser();
|
|
|
+ user.setPatientName("");
|
|
|
+ user.setPatientId(null);
|
|
|
+ userService.updateById(user);
|
|
|
+ tokenService.setLoginUser(user);
|
|
|
+ }
|
|
|
return AjaxResult.success();
|
|
|
}
|
|
|
|
|
@@ -101,4 +113,14 @@ public class BindUserServiceImpl extends ServiceImpl<BindUserMapper, BindUser> i
|
|
|
tokenService.setLoginUser(userService.getById(AppUtil.getUser().getId()).setToken(AppUtil.getUser().getToken()));
|
|
|
return AjaxResult.success();
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AjaxResult bindDetail(Long id) {
|
|
|
+ BindUser bindUser = getById(id);
|
|
|
+ if (bindUser == null || !bindUser.getUserId().equals(AppUtil.getUser().getId())) {
|
|
|
+ return AjaxResult.error("数据不存在或非法操作");
|
|
|
+ }
|
|
|
+ Patient patient = patientService.getById(bindUser.getPatientId());
|
|
|
+ return AjaxResult.success(patient);
|
|
|
+ }
|
|
|
}
|