package com.fs.app.controller;

import com.fs.app.annotation.Login;
import com.fs.common.core.domain.R;
import com.fs.his.service.IFsQuestionAndAnswerService;
import com.fs.his.vo.FsQuestionAndAnswerVO;
import com.fs.his.vo.OptionsVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
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 java.util.List;

@Api("问答")
@RestController
@RequestMapping(value="/app/answer")
public class QuestionAndAnswerController {

    @Autowired
    private IFsQuestionAndAnswerService questionAndAnswerService;

    @Login
    @ApiOperation("问答信息")
    @GetMapping("/getInfo")
    public R getInfo(@RequestParam("questionId") Long questionId) {
        FsQuestionAndAnswerVO vo = questionAndAnswerService.selectFsQuestionAndAnswerById(questionId);
        return R.ok().put("data", vo);
    }

    /**
     * 查询问答列表
     */
    @ApiOperation("问答列表")
    @GetMapping("/allList")
    public R answerList(@RequestParam(name = "type",required = false) Integer type)
    {
        if (type == null) {
            type = 1;
        }
        List<OptionsVO> list = questionAndAnswerService.selectAllQuestionOptions(type);
        return R.ok().put("data",list);
    }

    @ApiOperation("APP-问答列表")
    @GetMapping("/list")
    public R list() {
        List<FsQuestionAndAnswerVO> vos = questionAndAnswerService.selectFsQuestionAndAnswerVOList();
        return R.ok().put("data",vos);
    }

}
