Commit 93bfbc972f1f7cbef15e19f4e03f39dca82db25a
1 parent
4b3ab9e21c
Exists in
master
优化 保存患者感兴趣的科室
Showing 1 changed file with 22 additions and 3 deletions
talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/FavorController.java
View file @
93bfbc9
... | ... | @@ -2,8 +2,12 @@ |
2 | 2 | |
3 | 3 | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
4 | 4 | import com.lyms.talkonlineweb.domain.LymsFavor; |
5 | +import com.lyms.talkonlineweb.domain.LymsHdepart; | |
5 | 6 | import com.lyms.talkonlineweb.result.BaseResponse; |
7 | +import com.lyms.talkonlineweb.service.LymsDepartillService; | |
6 | 8 | import com.lyms.talkonlineweb.service.LymsFavorService; |
9 | +import com.lyms.talkonlineweb.service.LymsHdepartService; | |
10 | +import org.springframework.beans.BeanUtils; | |
7 | 11 | import org.springframework.beans.factory.annotation.Autowired; |
8 | 12 | import org.springframework.web.bind.annotation.GetMapping; |
9 | 13 | import org.springframework.web.bind.annotation.PostMapping; |
10 | 14 | |
11 | 15 | |
12 | 16 | |
... | ... | @@ -19,15 +23,30 @@ |
19 | 23 | |
20 | 24 | @Autowired |
21 | 25 | private LymsFavorService lymsFavorService;//感兴趣的科室 |
26 | + | |
27 | + @Autowired | |
28 | + private LymsHdepartService lymsHdepartService;//医院科室 | |
22 | 29 | /** |
23 | 30 | * 保存患者感兴趣的科室 |
24 | - * @param favor | |
31 | + * @param pid 患者ID | |
32 | + * @param dpids 科室ID需要用逗号分隔 | |
25 | 33 | * @return |
26 | 34 | */ |
27 | 35 | @PostMapping("saveFavor") |
28 | - public BaseResponse saveFavor(LymsFavor favor){ | |
36 | + public BaseResponse saveFavor(String pid,String dpids){ | |
29 | 37 | BaseResponse baseResponse=new BaseResponse(); |
30 | - boolean f=lymsFavorService.saveOrUpdate(favor); | |
38 | + boolean f=false; | |
39 | + String[] dpidArr=dpids.split(","); | |
40 | + | |
41 | + for (int i = 0; i < dpidArr.length; i++) { | |
42 | + LymsFavor favor =new LymsFavor(); | |
43 | + LymsHdepart depart=new LymsHdepart(); | |
44 | + depart=lymsHdepartService.getById(dpidArr[i]); | |
45 | + BeanUtils.copyProperties(depart,favor); | |
46 | + favor.setIid(Integer.parseInt(pid)); | |
47 | + f=lymsFavorService.saveOrUpdate(favor); | |
48 | + } | |
49 | + | |
31 | 50 | baseResponse.setErrorcode(f==true?0:1); |
32 | 51 | return baseResponse; |
33 | 52 | } |