package com.cirle.scientific.controller.miniapp;/*
 *24901
 *2022/12/21
 *16:10
 */

import com.cirle.scientific.pojo.Result;
import com.cirle.scientific.service.QuestionnaireService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @author 24901
 */
@Controller
@RequestMapping("/app/QuestionnaireApp")
@Api(value = "问卷相关接口")
public class QuestionnaireAppController {

    private QuestionnaireService questionnaireService;

    @Autowired
    public void setQuestionnaireService(QuestionnaireService questionnaireService) {
        this.questionnaireService = questionnaireService;
    }

    @GetMapping("/findQuestionnaire")
    @ApiOperation("查询问卷")
    @ResponseBody
    public Result findQuestion(@ApiParam(name = "memCard", value = "用户唯一标识") @RequestAttribute(name = "memCard", required = false)  String memCard){
//        if(null == memCard){
//            return Result.success(BizCodeEnum.NO_LOGIN);
//        }
        return Result.success(questionnaireService.findQuestionnaire());
    }

    @GetMapping("/findQuestions")
    @ApiOperation("跟具问卷类型查询问题")
    @ResponseBody
    public Result findQuestions(@ApiParam(name = "type" , value = "类型 1:问卷") @RequestParam(name = "type") Integer type,
                                @ApiParam(name = "objId", value = "objId") @RequestParam(name = "objId") Integer objId){
        return Result.success(questionnaireService.findQuestions(type,objId));
    }

    @GetMapping("/findDoctorQuestions")
    @ApiOperation("查询当前当月医生问卷的数量")
    @ResponseBody
    public Result findDoctorQuestions(@ApiParam(name = "memCard", value = "用户唯一标识")   @RequestAttribute(name = "memCard", required = false)  String memCard){
        return Result.success(questionnaireService.findDoctorQuestions(memCard).size());
    }


}
