package com.bohuikeji.delivery.backstage.config;

import com.bohuikeji.frame.module.admin.config.RanchSwaggerConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
import java.util.logging.Logger;

/**
 * 接口文档Swagger2配置
 * @author 10552
 */
@Configuration
@EnableSwagger2WebMvc
public class SwaggerConfiguration {

    @Bean("allDoc")
    public Docket allDoc() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(RanchSwaggerConfiguration.getApiInfo()).groupName("全部接口")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.bohuikeji.delivery.backstage.controller"))
                .paths(PathSelectors.any())
                .build()
                .ignoredParameterTypes(Logger.class);
    }

    @Bean("courierApiDoc")
    public Docket courierApiDoc() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(RanchSwaggerConfiguration.getApiInfo()).groupName("【配送员】业务相关接口")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.bohuikeji.delivery.backstage.controller.api.courier"))
                .paths(PathSelectors.any())
                .build()
                .ignoredParameterTypes(Logger.class);
    }
    @Bean("customerApiDoc")
    public Docket customerApiDoc() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(RanchSwaggerConfiguration.getApiInfo()).groupName("【客户】业务相关接口")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.bohuikeji.delivery.backstage.controller.api.customer"))
                .paths(PathSelectors.any())
                .build()
                .ignoredParameterTypes(Logger.class);
    }
    @Bean("adminApiDoc")
    public Docket adminApiDoc() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(RanchSwaggerConfiguration.getApiInfo()).groupName("【管理端APP】相关接口")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.bohuikeji.delivery.backstage.controller.api.admin"))
                .paths(PathSelectors.any())
                .build()
                .ignoredParameterTypes(Logger.class);
    }
    @Bean("orderApiDoc")
    public Docket orderApiDoc() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(RanchSwaggerConfiguration.getApiInfo()).groupName("【订单】及物流相关接口")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.bohuikeji.delivery.backstage.controller.api.order"))
                .paths(PathSelectors.any())
                .build()
                .ignoredParameterTypes(Logger.class);
    }
    @Bean("payApiDoc")
    public Docket payApiDoc() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(RanchSwaggerConfiguration.getApiInfo()).groupName("【支付】相关接口")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.bohuikeji.delivery.backstage.controller.api.pay"))
                .paths(PathSelectors.any())
                .build()
                .ignoredParameterTypes(Logger.class);
    }
    @Bean("sysApiDoc")
    public Docket sysApiDoc() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(RanchSwaggerConfiguration.getApiInfo()).groupName("【系统】/字典/配置等相关接口")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.bohuikeji.delivery.backstage.controller.api.system"))
                .paths(PathSelectors.any())
                .build()
                .ignoredParameterTypes(Logger.class);
    }
    @Bean("shareApiDoc")
    public Docket shareApiDoc() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(RanchSwaggerConfiguration.getApiInfo()).groupName("【共享】/通用/强耦合相关接口")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.bohuikeji.delivery.backstage.controller.api.share"))
                .paths(PathSelectors.any())
                .build()
                .ignoredParameterTypes(Logger.class);
    }
    @Bean("otherApiDoc")
    public Docket otherApiDoc() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(RanchSwaggerConfiguration.getApiInfo()).groupName("【其他】/非核心业务相关接口")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.bohuikeji.delivery.backstage.controller.api.other"))
                .paths(PathSelectors.any())
                .build()
                .ignoredParameterTypes(Logger.class);
    }
    @Bean("openApiDoc")
    public Docket openApiDoc() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(RanchSwaggerConfiguration.getApiInfo()).groupName("【开放平台】开放平台专用接口")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.bohuikeji.delivery.backstage.controller.open"))
                .paths(PathSelectors.any())
                .build()
                .ignoredParameterTypes(Logger.class);
    }
    @Bean("jdApiDoc")
    public Docket jdApiDoc() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(RanchSwaggerConfiguration.getApiInfo()).groupName("【京东】配送业务")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.bohuikeji.delivery.backstage.controller.api.jd"))
                .paths(PathSelectors.any())
                .build()
                .ignoredParameterTypes(Logger.class);
    }
    @Bean("h5ApiDoc")
    public Docket h5ApiDoc() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(RanchSwaggerConfiguration.getApiInfo()).groupName("【H5接口】h5页面使用的接口")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.bohuikeji.delivery.backstage.controller.api.h5"))
                .paths(PathSelectors.any())
                .build()
                .ignoredParameterTypes(Logger.class);
    }
    @Bean("DiscountApiDoc")
    public Docket DiscountApiDoc() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(RanchSwaggerConfiguration.getApiInfo()).groupName("【优惠商城】优惠相关接口")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.bohuikeji.delivery.backstage.controller.api.Discount"))
                .paths(PathSelectors.any())
                .build()
                .ignoredParameterTypes(Logger.class);
    }
    @Bean("testApiDoc")
    public Docket testApiDoc() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(RanchSwaggerConfiguration.getApiInfo()).groupName("【测试专用】未发布/测试用接口")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.bohuikeji.delivery.backstage.controller.test"))
                .paths(PathSelectors.any())
                .build()
                .ignoredParameterTypes(Logger.class);
    }
    @Bean("v2ApiDoc")
    public Docket v2ApiDoc() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(RanchSwaggerConfiguration.getApiInfo()).groupName("【V2】模块接口")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.bohuikeji.delivery.backstage.controller.api.v2"))
                .paths(PathSelectors.any())
                .build()
                .ignoredParameterTypes(Logger.class);
    }
    @Bean("huolalaApiDoc")
    public Docket huolalaApiDoc() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(RanchSwaggerConfiguration.getApiInfo()).groupName("【货拉拉】模块接口")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.bohuikeji.delivery.backstage.controller.api.huolala"))
                .paths(PathSelectors.any())
                .build()
                .ignoredParameterTypes(Logger.class);
    }
    @Bean("rentalCarApiDoc")
    public Docket rentalCarApiDoc() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(RanchSwaggerConfiguration.getApiInfo()).groupName("【租车服务】模块接口")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.bohuikeji.delivery.backstage.controller.api.rental"))
                .paths(PathSelectors.any())
                .build()
                .ignoredParameterTypes(Logger.class);
    }

}
