package cn.fateverse.query.controller;

import cn.fateverse.common.core.entity.Option;
import cn.fateverse.common.core.result.Result;
import cn.fateverse.query.entity.vo.UniConVo;
import cn.fateverse.query.service.QueryToolService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Clay
 * @date 2024/4/16 16:10
 */
@Api(tags = "自定义查询工具接口管理")
@RestController
@RequestMapping("/tool")
public class QueryToolController {


    private final QueryToolService queryToolService;


    public QueryToolController(QueryToolService queryToolService) {
        this.queryToolService = queryToolService;
    }

    @ApiOperation("根据查询类型获取自定义查询")
    @GetMapping("/option/{type}")
    public Result<List<Option>> option(@PathVariable Integer type) {
        if (type == null) {
            return Result.error("查询类型不能为空");
        }
        List<Option> optionList = queryToolService.searchQueryOption(type);
        return Result.ok(optionList);
    }


    @ApiOperation("根据自定义查询id获取查询条件")
    @GetMapping("/con/{queryId}")
    public Result<List<Option>> con(@PathVariable Long queryId) {
        if (queryId == null) {
            return Result.error("查询条件不能为空");
        }
        List<Option> optionList = queryToolService.searchQueryCon(queryId);
        return Result.ok(optionList);
    }


}
