package com.diagbot.web;


import com.diagbot.dto.QuestionDTO;
import com.diagbot.dto.RespDTO;
import com.diagbot.facade.QuestionFacade;
import com.diagbot.vo.QuestionIdsVO;
import com.diagbot.vo.QuestionVO;
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 java.util.Map;

/**
 * <p>
 * 标签基础表 前端控制器
 * </p>
 *
 * @author zhoutg
 * @since 2018-11-15
 */
@RequestMapping("/questionInfo")
@RestController
@Api(value = "标签相关API", tags = { "标签相关API" })
@SuppressWarnings("unchecked")
public class QuestionInfoController {

    @Autowired
    QuestionFacade questionFacade;

    @ApiOperation(value = "根据参数返回标签内容[by:zhoutg]",
            notes = "id: questionId<br>" +
                    "sexType：性别，1：男，2：女<br>" +
                    "age：年龄")
    @PostMapping("/getById")
    public RespDTO<QuestionDTO> getById(@RequestBody QuestionVO questionVO) {
        QuestionDTO data = questionFacade.getById(questionVO);
        return RespDTO.onSuc(data);
    }


    @ApiOperation(value = "查询多个id返回标签内容[by:zhoutg]",
            notes = "ids: 多个questionId<br>" +
                    "sexType：性别，1：男，2：女<br>" +
                    "age：年龄")
    @PostMapping("/getByIds")
    public RespDTO<Map<Long, Object>> getByIds(@RequestBody QuestionIdsVO questionIdsVO) {
        Map<Long, Object> data = questionFacade.getByIds(questionIdsVO);
        return RespDTO.onSuc(data);
    }
}
