package com.diagbot.web;


import com.diagbot.dto.IntroduceDTO;
import com.diagbot.dto.RespDTO;
import com.diagbot.facade.IntroduceInfoFacade;
import com.diagbot.vo.IntroduceByQuestionVO;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * <p>
 * 提示信息 前端控制器
 * </p>
 *
 * @author zhaops
 * @since 2018-11-15
 */
@RestController
@RequestMapping("/introduceInfo")
@Api(value = "提示信息相关API", tags = { "提示信息相关API" })
@SuppressWarnings("unchecked")
public class IntroduceInfoController {

    @Autowired
    IntroduceInfoFacade introduceInfoFacade;

    @ApiOperation(value = "根据标签id获取提示信息[by:zhaops]",
            notes = "questionId: 标签id，必填<br>" +
                    "type：标签类型，必填<br>" +
                    "position：展示位置（1-推送展示，2-更多展示，3-一般治疗展示，4-手术治疗展示），必填")
    @PostMapping("/getByQuestionId")
    public RespDTO<IntroduceDTO> getByQuestionId(@RequestBody @Valid IntroduceByQuestionVO introduceByQuestionVO) {
        IntroduceDTO introduceDTO = introduceInfoFacade.getByQuestionId(introduceByQuestionVO);
        return RespDTO.onSuc(introduceDTO);
    }

    @ApiOperation(value = "根据标签名称获取提示信息[by:zhaops]",
            notes = "tagName: 标签名称，必填<br>" +
                    "type：标签类型，必填<br>" +
                    "position：展示位置（1-推送展示，2-更多展示，3-一般治疗展示，4-手术治疗展示），必填")
    @PostMapping("/getByQuestionName")
    public RespDTO<IntroduceDTO> getByQuestionName(@RequestBody @Valid IntroduceByQuestionVO introduceByQuestionVO) {
        IntroduceDTO introduceDTO = introduceInfoFacade.getByQuestionName(introduceByQuestionVO);
        return RespDTO.onSuc(introduceDTO);
    }

    @ApiOperation(value = "根据id获取提示信息[by:zhaops]",
            notes = "id: 提示信息id，必填<br>")
    @PostMapping("/getRecordById")
    public RespDTO<IntroduceDTO> getRecordById(@RequestParam Long id) {
        IntroduceDTO introduceDTO = introduceInfoFacade.getRecordById(id);
        return RespDTO.onSuc(introduceDTO);
    }
}