package com.bonus.boot.manager.health.controller;

import com.bonus.boot.manager.basic.entity.HospitalBean;
import com.bonus.boot.manager.health.entity.PmBaseHospLimit;
import com.bonus.boot.manager.health.service.AppontdisposService;
import com.bonus.boot.manager.manager.annotation.LogAnnotation;
import com.bonus.boot.manager.manager.entity.R;
import com.bonus.boot.manager.manager.model.SysUser;
import com.bonus.boot.manager.manager.utils.AjaxRes;
import com.bonus.boot.manager.manager.utils.GlobalConst;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

/**
 * 体检人数配置后台
 * lzh
 */
@RestController
@RequestMapping("/Appontdispos")
public class AppontdisposController {
    @Autowired
    private AppontdisposService AppontService;
    @LogAnnotation
    @PostMapping("getMsgContent")
    @ApiOperation(value = "用户管理-列表")
    public R getList(PmBaseHospLimit o){
        List<PmBaseHospLimit> list = AppontService.getMsgList(o);
        return list.size() > 0 ? R.okTable(list, list.size()):R.failTable("暂无数据");
    }

    @RequestMapping(value = "addInfo", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "体检管理-预约人数配置新增")
    public AjaxRes addInfo(@RequestBody PmBaseHospLimit bean) throws Exception {
        AjaxRes ar = new AjaxRes();
        int cb = AppontService.addInfo(bean);
        ar.setFailMsg(GlobalConst.DATA_FAIL);
        if(cb>0){
            ar.setFailMsg(GlobalConst.INIT_SUCCEED);
        }
        return  ar;
    }

    @RequestMapping(value = "updateInfo", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "体检管理-预约人数配置修改")
    public AjaxRes updateInfo(@RequestBody PmBaseHospLimit bean) throws Exception {
        AjaxRes ar = new AjaxRes();
        int cb = AppontService.updateInfo(bean);
        ar.setFailMsg(GlobalConst.DATA_FAIL);
        if(cb>0){
            ar.setFailMsg(GlobalConst.INIT_SUCCEED);
        }
        return  ar;
    }

    @LogAnnotation
    @PostMapping("delById")
    @ApiOperation(value = "体检管理-预约人数配置删除")
    public AjaxRes delById(PmBaseHospLimit bean) {
        AjaxRes ar = new AjaxRes();
        int result  = AppontService.delById(bean);
        if(result==1){
            ar.setSucceedMsg(GlobalConst.DATA_SUCCEED);
        }else {
            ar.setFailMsg(GlobalConst.DATA_FAIL);
        }
        return ar;
    }

    @RequestMapping(value = "getListById", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "体检人员库-查询人员信息")
    public AjaxRes getListById(String id){
        AjaxRes ar = new AjaxRes();
        PmBaseHospLimit pmBaseHospLimit = AppontService.getListById(id);
        Map<String, Object> map = new HashMap<>();
        if(pmBaseHospLimit !=null){
            map.put("PmBaseHospLimit",pmBaseHospLimit);
        }
        ar.setSucceed(map,GlobalConst.DATA_SUCCEED);
        return ar;
    }

}
