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.BlockValues;
import com.hs.api.model.reqmodel.BlockValuesNew;
import com.hs.api.model.respmodel.BlockValue;
import com.hs.api.service.BlockValuesService;
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 BlockValuesController {

    @Autowired
    private BlockValuesService blockValuesService;


    /**
     * 根据pageId查询板块数值
     *
     * @return
     * @throws Exception
     */
    @ApiIgnore
//    @PostMapping("blockValues")
    @Token
    @ApiOperation("根据Page查询板块数值")
    public Object getBlockValuesByPageID(@RequestBody BlockValues blockValues) throws InterruptedException {

        List<BlockValue> list = blockValuesService.getBlockValuesByPageCode(blockValues.getPageCode(),
                blockValues.getDisease(),blockValues.getDoctor(),blockValues.getDepartment(),blockValues.getTime());
        return Result.success(list);
    }

    /**
     * 根据pageId查询板块数值
     *
     * @return
     * @throws Exception
     */
    @PostMapping("blockValuesNew")
    @Token
    @ApiOperation("根据Page查询板块数值")
    public Object getBlockValuesByPageIDNew(@ApiIgnore @CurrentUser Long userId,@RequestBody BlockValuesNew blockValues) throws InterruptedException {

        List<BlockValue> list = blockValuesService.getBlockValuesByPageCodeNew(userId,blockValues.getPageCode(),blockValues.getDim());
        return Result.success(list);
    }
}