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

import com.bonus.boot.manager.basic.dao.HospitalDao;
import com.bonus.boot.manager.basic.entity.HospitalBean;
import com.bonus.boot.manager.basic.entity.MapBean;
import com.bonus.boot.manager.basic.entity.PersonnelLibraryBean;
import com.bonus.boot.manager.basic.service.HospitalService;
import com.bonus.boot.manager.manager.annotation.LogAnnotation;
import com.bonus.boot.manager.manager.entity.R;
import com.bonus.boot.manager.manager.utils.AjaxRes;
import com.bonus.boot.manager.manager.utils.GlobalConst;
import com.bonus.boot.manager.physical.service.RetiremenService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/** 离退休体检预约
 * @author xliu
 * @Data 2023/5/31 9:30
 */
@RestController
@RequestMapping("retirement")
public class RetirementController {
    /**
     * 服务对象
     */
    @Resource
    private RetiremenService service;


    @LogAnnotation
    @PostMapping("getMsgContent")
    @ApiOperation(value = "离退休体检预约-列表")
    public R getList(PersonnelLibraryBean o){
        System.err.println("PersonnelLibraryBean="+o);
        List<PersonnelLibraryBean> list = service.getList(o);
        return list.size() > 0 ? R.okTable(list, list.size()):R.failTable("暂无数据");
    }


    //
    @LogAnnotation
    @PostMapping("addReservationData")
    @ApiOperation(value = "离退休体检-批量预约")
    public R addReservationData(PersonnelLibraryBean o){
        System.err.println("addReservationData PersonnelLibraryBean="+o);
        return service.addReservationData(o);
    }

    @LogAnnotation
    @PostMapping("cancelReservation")
    @ApiOperation(value = "离退休体检-批量预约")
    public R cancelReservation(String ifCancel,String id){
        System.err.println("cancelReservation ifCancel="+ifCancel+" ,id="+id);
        int num = service.cancelReservation(ifCancel,id);;
        return num > 0 ? R.okTable("取消预约成功！", 1):R.okTable("取消预约失败！", 0);
    }


    @LogAnnotation
    @PostMapping("getRetirementNum")
    @ApiOperation(value = "查询体检预约上限人数")
    public R getRetirementNum(MapBean o){
        System.err.println("getRetirementNum MapBean="+o);
        return R.okTable(service.getRetirementNum(o), 1);
    }


}

