package com.fs.app.controller;


import com.fs.app.annotation.Login;
import com.fs.common.core.domain.R;

import com.fs.his.domain.*;
import com.fs.his.param.*;
import com.fs.his.service.*;
import com.fs.his.vo.*;
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/index")
public class IndexController extends AppBaseController {

	@Autowired
	private IFsFamousPrescribeService fsFamousPrescribeService;

	@Autowired
	private IFsQuestionsService questionsService;

	@Autowired
	private IFsMedicatedFoodService medicatedFoodService;

	@Autowired
	private IFsVesselService vesselService;

	@Autowired
	private IFsChineseMedicineService chineseMedicineService;

	@ApiOperation("获取名方列表")
	@Cacheable(value = "getFamousPrescribeList", key = "#param")
	@GetMapping("/getFamousPrescribeList")
	public R getFamousPrescribeList(FsFamousPrescribeListUParam param)
	{
		PageHelper.startPage(param.getPageNum(), param.getPageSize());
		List<FsFamousPrescribeListUVO> list=fsFamousPrescribeService.selectFsFamousPrescribeListUVO(param);
		PageInfo<FsFamousPrescribeListUVO> listPageInfo=new PageInfo<>(list);
		return R.ok().put("data",listPageInfo);
	}

	@GetMapping("/getFamousPrescribeById")
	@Cacheable(value = "getFamousPrescribeById", key = "#id")
	public R getFamousPrescribeById(@RequestParam("id")Long id)
	{
		FsFamousPrescribe fsFamousPrescribe=fsFamousPrescribeService.selectFsFamousPrescribeById(id);
		return R.ok().put("data",fsFamousPrescribe);
	}
	@ApiOperation("获取问答列表")
	@Cacheable(value = "getQuestionsList", key = "#param")
	@GetMapping("/getQuestionsList")
	public R getQuestionsList(FsQuestionsListUParam param)
	{
		PageHelper.startPage(param.getPageNum(), param.getPageSize());
		List<FsQuestionsListUVO> list=questionsService.selectFsQuestionsListUVO(param);
		PageInfo<FsQuestionsListUVO> listPageInfo=new PageInfo<>(list);
		return R.ok().put("data",listPageInfo);
	}

	@GetMapping("/getQuestionsById")
	@Cacheable(value = "getQuestionsById", key = "#id")
	public R getQuestionsById(@RequestParam("id")Long id)
	{
		FsQuestions questions=questionsService.selectFsQuestionsById(id);
		return R.ok().put("data",questions);
	}
	@ApiOperation("获取穴位列表")
	@GetMapping("/getVesselList")
	@Cacheable(value = "getVesselList", key = "#param")
	public R getVesselList(FsVesselListUParam param)
	{
		PageHelper.startPage(param.getPageNum(), param.getPageSize());
		List<FsVesselListUVO> list=vesselService.selectFsVesselListUVO(param);
		PageInfo<FsVesselListUVO> listPageInfo=new PageInfo<>(list);
		return R.ok().put("data",listPageInfo);
	}

	@GetMapping("/getVesselById")
	@Cacheable(value = "getVesselById", key = "#id")
	public R getVesselById(@RequestParam("id")Long id)
	{
		FsVessel vessel=vesselService.selectFsVesselById(id);
		return R.ok().put("data",vessel);
	}
	@ApiOperation("获取食谱列表")
	@GetMapping("/getMedicatedFoodList")
	@Cacheable(value = "getMedicatedFoodList", key = "#param")
	public R getMedicatedFoodList(FsMedicateFoodListUParam param)
	{
		PageHelper.startPage(param.getPageNum(), param.getPageSize());
		List<FsMedicateFoodListUVO> list=medicatedFoodService.selectFsMedicatedFoodListUVO(param);
		PageInfo<FsMedicateFoodListUVO> listPageInfo=new PageInfo<>(list);
		return R.ok().put("data",listPageInfo);
	}

	@GetMapping("/getMedicatedFoodById")
	@Cacheable(value = "getMedicatedFoodById", key = "#id")
	public R getMedicatedFoodById(@RequestParam("id")Long id)
	{
		FsMedicatedFood food=medicatedFoodService.selectFsMedicatedFoodById(id);
		return R.ok().put("data",food);
	}
	@ApiOperation("获取中医列表")
	@GetMapping("/getChineseMedicineList")
	@Cacheable(value = "getChineseMedicineList", key = "#param")
	public R getChineseMedicineList(FsChineseMedicineListUParam param)
	{
		PageHelper.startPage(param.getPageNum(), param.getPageSize());
		List<FsChineseMedicineListUVO> list=chineseMedicineService.selectFsChineseMedicineListUVO(param);
		PageInfo<FsChineseMedicineListUVO> listPageInfo=new PageInfo<>(list);
		return R.ok().put("data",listPageInfo);
	}

	@GetMapping("/getChineseMedicineById")
	@Cacheable(value = "getChineseMedicineById", key = "#id")
	public R getChineseMedicineById(@RequestParam("id")Long id)
	{
		FsChineseMedicine chineseMedicine=chineseMedicineService.selectFsChineseMedicineById(id);
		return R.ok().put("data",chineseMedicine);
	}

}
