package com.fs.app.controller;


import com.fs.common.core.domain.R;
import com.fs.his.domain.FsDisease;
import com.fs.his.domain.FsHospital;
import com.fs.his.param.FsDiseaseListUParam;
import com.fs.his.param.FsHospitalListUParam;
import com.fs.his.service.IFsDiseaseService;
import com.fs.his.service.IFsHospitalService;
import com.fs.his.vo.FsDiseaseListUVO;
import com.fs.his.vo.FsHospitalListUVO;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

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


@Api("医院接口")
@RestController
@RequestMapping(value="/app/hospital")
public class HospitalController extends  AppBaseController {

    @Autowired
    private IFsHospitalService hospitalService;

    @ApiOperation("获取医院列表")
    @Cacheable(value = "getHospitalList", key = "#param")
    @GetMapping("/getHospitalList")
    public R getHospitalList(FsHospitalListUParam param)
    {
        PageHelper.startPage(param.getPageNum(), param.getPageSize());
        List<FsHospitalListUVO> list=hospitalService.selectFsHospitalListUVO(param);
        PageInfo<FsHospitalListUVO> listPageInfo=new PageInfo<>(list);
        return R.ok().put("data",listPageInfo);
    }



    @ApiOperation("获取疾病详情")
    @GetMapping("/getHospitalById")
    @Cacheable(value = "getHospitalById", key = "#hospitalId")
    public R getHospitalById(@RequestParam("hospitalId")Long hospitalId){
        FsHospital disease=hospitalService.selectFsHospitalByHospitalId(hospitalId);
        return R.ok().put("data",disease);
    }

}
