package com.diagbot.web;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.diagbot.annotation.SysLogger;
import com.diagbot.dto.ConceptDTO;
import com.diagbot.dto.LibraryInfoDTO;
import com.diagbot.dto.MedicalDTO;
import com.diagbot.dto.RespDTO;
import com.diagbot.facade.MedicalFacade;
import com.diagbot.vo.ConceptVo;
import com.diagbot.vo.TermVo;
import com.diagbot.vo.AmendTermVo;
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 javax.validation.Valid;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Weixuan Huang
 * @since 2019-01-16
 */
@RestController
@RequestMapping("/medical")
@Api(value = "标准术语医学知识API", tags = { "标准术语医学知识API" })

public class MedicalController {
    @Autowired
    MedicalFacade medicalFacade;


    @ApiOperation(value = "术语医学知识查询",
            notes = "Term：术语名称, 必填<br>Type：术语类型, 必填<br>")
    @PostMapping("/getMedicalInfo")
    @SysLogger("getMedicalInfo")
    public RespDTO<ConceptDTO> getMedicalInfo(@Valid @RequestBody TermVo termvo) {
        ConceptDTO data = medicalFacade.getMedicalInfo(termvo);

        return RespDTO.onSuc(data);
    }

    /*
    public RespDTO<ConceptDTO> getMedicalInfo(@Valid @RequestBody ConceptVo conceptVo) {
        ConceptDTO data = medicalFacade.getMedicalInfo(conceptVo);

        return RespDTO.onSuc(data);
    }
    */

    @ApiOperation(value = "术语医学知识修改",
            notes = "NewTerm: 新的术语名称, 必填<br/>NewType: 新的术语类型, 必填<br/>")
    @PostMapping("/upsertMedicalInfo")
    @SysLogger("upsertMedicalInfo")
    public RespDTO<ConceptDTO> upsertMedicalInfo(@Valid @RequestBody AmendTermVo amendTermVo) {
        ConceptDTO data = medicalFacade.upsertMedicalInfo(amendTermVo);

        return RespDTO.onSuc(data);
    }

    @ApiOperation(value = "术语医学知识删除",
            notes = "Term: 术语名称, 必填<br/>Type: 术语类型, 必填<br/>")
    @PostMapping("/removeMedicalInfo")
    @SysLogger("removeMedicalInfo")
    public RespDTO<ConceptDTO> removeMedicalInfo(@Valid @RequestBody TermVo termVo) {
        Boolean result = medicalFacade.removeMedicalInfo(termVo);

        return RespDTO.onSuc(result);
    }
}
