package com.tuoheng.admin.config;

import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import java.util.ArrayList;

/**
 * @author qiujinyang
 * @company 拓恒技术
 * @create 2022-07-19 21:00
 */
@Configuration
public class Swagger3Config {

    /**
     * 配置swagger的Docket bean
     * @return
     */
    @Bean
    public Docket createRestApiSystem() {
        return new Docket(DocumentationType.OAS_30)  // 指定swagger3.0版本
                .groupName("system")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.tuoheng.system.controller"))  // 指定扫描的包  常用方式
                .build()
                .apiInfo(createApiInfoSystem());
    }

    /**
     * 配置swagger的ApiInfo bean
     * @return
     */
    @Bean
    public ApiInfo createApiInfoSystem(){
        return new ApiInfo("system Swagger"
               ,"system Api Documentation"
                ,"3.0"
                ,""
                ,new Contact("拓恒", "", "")
                ,"Apache 2.0"
                ,"http://www.apache.org/licenses/LICENSE-2.0"
                ,new ArrayList());
    }


    /**
     * 配置swagger的Docket bean
     * @return
     */
    @Bean
    public Docket createRestApiLc() {
        return new Docket(DocumentationType.OAS_30)  // 指定swagger3.0版本
                .groupName("lc")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.tuoheng.admin.controller"))
                .build()
                .apiInfo(createApiInfoLc());
    }

    /**
     * 配置swagger的ApiInfo bean
     * @return
     */
    @Bean
    public ApiInfo createApiInfoLc(){
        return new ApiInfo("lc Swagger"
                ,"lc Api Documentation"
                ,"3.0"
                ,""
                ,new Contact("拓恒", "", "")
                ,"Apache 2.0"
                ,"http://www.apache.org/licenses/LICENSE-2.0"
                ,new ArrayList());
    }




}