diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/FavorController.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/FavorController.java index 429ffb9..e1f667d 100644 --- a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/FavorController.java +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/FavorController.java @@ -2,8 +2,12 @@ package com.lyms.talkonlineweb.controller; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.lyms.talkonlineweb.domain.LymsFavor; +import com.lyms.talkonlineweb.domain.LymsHdepart; import com.lyms.talkonlineweb.result.BaseResponse; +import com.lyms.talkonlineweb.service.LymsDepartillService; import com.lyms.talkonlineweb.service.LymsFavorService; +import com.lyms.talkonlineweb.service.LymsHdepartService; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -19,15 +23,30 @@ public class FavorController { @Autowired private LymsFavorService lymsFavorService;//感兴趣的科室 + + @Autowired + private LymsHdepartService lymsHdepartService;//医院科室 /** * 保存患者感兴趣的科室 - * @param favor + * @param pid 患者ID + * @param dpids 科室ID需要用逗号分隔 * @return */ @PostMapping("saveFavor") - public BaseResponse saveFavor(LymsFavor favor){ + public BaseResponse saveFavor(String pid,String dpids){ BaseResponse baseResponse=new BaseResponse(); - boolean f=lymsFavorService.saveOrUpdate(favor); + boolean f=false; + String[] dpidArr=dpids.split(","); + + for (int i = 0; i < dpidArr.length; i++) { + LymsFavor favor =new LymsFavor(); + LymsHdepart depart=new LymsHdepart(); + depart=lymsHdepartService.getById(dpidArr[i]); + BeanUtils.copyProperties(depart,favor); + favor.setIid(Integer.parseInt(pid)); + f=lymsFavorService.saveOrUpdate(favor); + } + baseResponse.setErrorcode(f==true?0:1); return baseResponse; }