package com.test.bijihoudaun.config;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;

@Configuration
@Profile("!prod") // 只在非生产环境激活
@ConditionalOnProperty(name = "knife4j.enable", havingValue = "true", matchIfMissing = true)
public class Knife4jConfig {

    @Bean
    public OpenAPI customOpenAPI() {
        return new OpenAPI()
                .info(new Info()
                        .title("API文档")
                        .version("1.0")
                        .description("系统API文档")

                );
    }
    @Bean
    public GroupedOpenApi commonApi() {
        return GroupedOpenApi.builder()
                .group("图片接口")
                .pathsToMatch("/api/images/**")
                .build();
    }

    @Bean
    public GroupedOpenApi tokenApi() {
        return GroupedOpenApi.builder()
                .group("markdown接口")
                .pathsToMatch("/api/markdown/**")
                .build();
    }

    @Bean
    public GroupedOpenApi LotteryResultsApi() {
        return GroupedOpenApi.builder()
                .group("用户接口")
                .pathsToMatch("/api/user/**")
                .build();
    }
    @Bean
    public GroupedOpenApi GroupingApi() {
        return GroupedOpenApi.builder()
                .group("分组接口")
                .pathsToMatch("/api/groupings/**")
                .build();
    }


}
