package com.mvc.config;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
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;

@Configuration
public class SwaggerConfig {

    @Bean
    public Docket createRestApi_copy(){
        return new Docket(DocumentationType.OAS_30)
                .groupName("拷机业务相关API")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.mvc.controller.copy")).build()
                .enable(true)
                .apiInfo(createApiInfo_copy());
    }

    @Bean
    public Docket createRestApi_dic(){
        return new Docket(DocumentationType.OAS_30)
                .groupName("字典操作API")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.mvc.controller.dic")).build()
                .enable(true)
                .apiInfo(createApiInfo_dic());
    }

    @Bean
    public Docket createRestApi_taizhang(){
        return new Docket(DocumentationType.OAS_30)
                .groupName("台账操作API")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.mvc.controller.taizhang")).build()
                .enable(true)
                .apiInfo(createApiInfo_taizhang());
    }

    @Bean
    public Docket createRestApi_app(){
        return new Docket(DocumentationType.OAS_30)
                .groupName("App相关操作API")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.mvc.controller.app")).build()
                .enable(true)
                .apiInfo(createApiInfo_app());
    }

    @Bean
    public Docket createRestApi_all(){
        return new Docket(DocumentationType.OAS_30)
                .groupName("全部API")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.mvc.controller")).build()
                .enable(true)
                .apiInfo(createApiInfo_all());
    }

    @Bean
    public ApiInfo createApiInfo_all(){
        return new ApiInfo("全部接口API",
                "全部API",
                "1.0",
                "",
                new Contact("hege","http://hege.com","hege.com"),
                "","",
                new ArrayList<>());
    }

    @Bean
    public ApiInfo createApiInfo_dic(){
        return new ApiInfo("AI智能应用平台开发Api",
                "字段操作API",
                "1.0",
                "",
                new Contact("hege","http://hege.com","hege.com"),
                "","",
                new ArrayList<>());
    }

    @Bean
    public ApiInfo createApiInfo_taizhang(){
        return new ApiInfo("AI智能应用平台开发Api",
                "台账操作API",
                "1.0",
                "",
                new Contact("hege","http://hege.com","hege.com"),
                "","",
                new ArrayList<>());
    }

    @Bean
    public ApiInfo createApiInfo_app(){
        return new ApiInfo("AI智能应用平台开发Api",
                "APP相关操作API",
                "1.0",
                "",
                new Contact("hege","http://hege.com","hege.com"),
                "","",
                new ArrayList<>());
    }

    @Bean
    public ApiInfo createApiInfo_copy(){
        return new ApiInfo("拷机业务开发Api",
                "拷机业务开发API",
                "1.0",
                "",
                new Contact("hege","http://hege.com","hege.com"),
                "","",
                new ArrayList<>());
    }
}
