package com.diagbot.web;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.diagbot.annotation.SysLogger;
import com.diagbot.dto.ModelHospitalAllDTO;
import com.diagbot.dto.RespDTO;
import com.diagbot.facade.ModelHospitalFacade;
import com.diagbot.vo.ModelHospitalAllVO;
import com.diagbot.vo.ModelHospitalIdVO;
import com.diagbot.vo.ModelHospitalUpdataVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wangfeng
 * @time: 2024-05-15
 */
@RestController
@RequestMapping("/qc/modelHospital")
@Api(value = "医院数据模块相关接口API", tags = { "医院数据模块相关接口API" })
@SuppressWarnings("unchecked")
public class ModelHospitalController {

    @Autowired
    ModelHospitalFacade modelHospitalFacade;

    @ApiOperation(value = "获取全部条目[by:wangfeng]",
            notes = "获取全部条目")
    @PostMapping("/getModelHospitalAll")
    @SysLogger("getModelHospitalAll")
    public RespDTO<IPage<List<ModelHospitalAllDTO>>> getModelHospitalAll(@RequestBody ModelHospitalAllVO modelHospitalAllVO) {
        IPage<List<ModelHospitalAllDTO>> data = modelHospitalFacade.getModelHospitalAlls(modelHospitalAllVO);
        return RespDTO.onSuc(data);
    }

    @ApiOperation(value = "根据id获取医院数据[by:wangfeng]",
            notes = "根据id获取医院数据")
    @PostMapping("/getModelHospitalById")
    @SysLogger("getModelHospitalById")
    public RespDTO<ModelHospitalAllDTO> getModelHospitalById(@RequestBody @Valid ModelHospitalIdVO modelHospitalIdVO) {
        ModelHospitalAllDTO data = modelHospitalFacade.getModelHospitalById(modelHospitalIdVO.getModeId());
        return RespDTO.onSuc(data);
    }
    @ApiOperation(value = "添加和修改医院数据模块[by:wangfeng]",
            notes = "添加和修改医院数据模块")
    @PostMapping("/saveAndupdataModel")
    @SysLogger("saveAndupdataModel")
    public RespDTO<Boolean> updataModelHospital(@RequestBody @Valid ModelHospitalUpdataVO modelHospitalUpdataVO) {
        Boolean res = modelHospitalFacade.updataModelHospitals(modelHospitalUpdataVO);
        return RespDTO.onSuc(res);
    }

    @ApiOperation(value = "删除医院数据模块[by:wangfeng]",
            notes = "删除医院数据模块")
    @PostMapping("/clearModelHospital")
    @SysLogger("clearModelHospital")
    public RespDTO<Boolean> clearModelHospital(@RequestBody @Valid ModelHospitalIdVO modelHospitalIdVO) {
        Boolean res = modelHospitalFacade.clearModelHospital(modelHospitalIdVO.getModeId());
        return RespDTO.onSuc(res);
    }


}
