package com.emr.controller;

import com.emr.entity.Emr_Staff_Remark;
import com.emr.service.Emr_Staff_RemarkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Controller
@RequestMapping("/staffRemark")
public class Emr_Staff_RemarkController {

    @Autowired
    private Emr_Staff_RemarkService emrStaffRemarkService;

    @ResponseBody
    @RequestMapping(value = "/staffRemarkList")
    public List<Emr_Staff_Remark> faultTypeList(HttpServletRequest request, HttpServletResponse response, Emr_Staff_Remark emrStaffRemark) {
        List<Emr_Staff_Remark> list = emrStaffRemarkService.selectByCol(emrStaffRemark);
        return list;
    }

    @ResponseBody
    @RequestMapping(value = "/updateByClo")
    public int updateByClo(HttpServletRequest request, HttpServletResponse response, Emr_Staff_Remark emrStaffRemark) {
        int bol=0;
        //判断id是否存在
        if(emrStaffRemark.getId()!=null){
            //判断是否存在记录
            if (emrStaffRemarkService.selectById(emrStaffRemark.getId()) != null) {
                bol = emrStaffRemarkService.updateByClo(emrStaffRemark);
            }
        }else{
            //不存在则添加记录
            bol= emrStaffRemarkService.insertClo(emrStaffRemark);
        }
        return bol;

    }


    @ResponseBody
    @RequestMapping(value = "/delById")
    public int delById(HttpServletRequest request, HttpServletResponse response,Integer id) {
        int bol = 0;
        //判断id是否存在
        if (id!= null) {
            //判断是否存在记录
            bol = emrStaffRemarkService.delById(id);
        }
        return bol;

    }
}
