package com.hs.api.controller;

import com.hs.api.common.Result;
import com.hs.api.common.annotations.CurrentUser;
import com.hs.api.common.annotations.Token;
import com.hs.api.model.reqmodel.Disease;
import com.hs.api.model.respmodel.DiseaseLevel;
import com.hs.api.model.respmodel.DiseaseName;
import com.hs.api.service.SerDiseaseService;
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.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

@Api(tags = "疾病信息Api")
@RestController
public class SerDiseaseController {

    private final static Object obj = new Object();
    @Autowired
    private SerDiseaseService serDiseaseService;

    /**
     * 根据pageId查询板块数值
     *
     * @return
     * @throws Exception
     */
    @PostMapping("disease/list")
    @Token
    @ApiOperation("根据疾病编码或者疾病等级查询疾病列表")
    public Object getDiseaseByLevel(@ApiIgnore @CurrentUser Long userId, @RequestBody Disease.DiseaseIDorLevel disease) throws InterruptedException {
        List<DiseaseLevel> diseaseLevel = serDiseaseService.selectListByIdorLevel(disease.getDate(), disease.getDisease(),
                disease.getLevel(), disease.getDoctor(), disease.getDept(), userId);
        return Result.success(diseaseLevel);
    }

    @PostMapping("disease/name")
    @Token
    @ApiOperation("根据疾病名称查询疾病信息")
    public Object getDiseaseByMdcName(@ApiIgnore @CurrentUser Long userId, @RequestBody Disease.DiseaseName disease) throws InterruptedException {
        List<DiseaseName> list = serDiseaseService.selectByMdcName(userId, disease.getDate(), disease.getMdcName(), disease.getDoctor(), disease.getDept());
        return Result.success(list);
    }

}
