FavorController.java 2.09 KB
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
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.*;

import java.util.List;
import java.util.Map;

/**
* 患者感兴趣内容管理
*/
@RestController
@RequestMapping("fav")
public class FavorController {

@Autowired
private LymsFavorService lymsFavorService;//感兴趣的科室

@Autowired
private LymsHdepartService lymsHdepartService;//医院科室
/**
* 保存患者感兴趣的科室
* @param pid 患者ID
* @param dpids 科室ID需要用逗号分隔
* @return
*/
@PostMapping("saveFavor")
public BaseResponse saveFavor(@RequestBody Map<String,Object> param){
BaseResponse baseResponse=new BaseResponse();
boolean f=false;
String[] dpidArr=param.get("dpids").toString().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(param.get("pid").toString()));
f=lymsFavorService.saveOrUpdate(favor);
}

baseResponse.setErrorcode(f==true?0:1);
return baseResponse;
}

/**
* 查询感兴趣的科室
* @param favor
* @return
*/
@GetMapping("getFavor")
public BaseResponse getFavor(LymsFavor favor){
BaseResponse baseResponse=new BaseResponse();
List<LymsFavor> flst=lymsFavorService.list(Wrappers.query(favor));
baseResponse.setObject(flst);
return baseResponse;
}

}