package com.unis.reserveLayout.config;

import com.github.xiaoymin.knife4j.spring.extension.OpenApiExtensionResolver;
import com.unis.common.pojo.CommonResult;
import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.RequestMethod;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import javax.annotation.Resource;

/**
 * @author qingsong.han
 * @description: 储备布局地理信息
 * @create 2024-06-07 10:48
 */
@Configuration
public class ReserveLayoutConfigure {

    @Resource
    private OpenApiExtensionResolver openApiExtensionResolver;

    /**
     * API文档分组配置
     *
     * @author TS
     * @date 2024/4/3 16:18
     **/
    @Bean(value = "reserveLayoutDocApi")
    public Docket reserveLayoutDocApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(new ApiInfoBuilder()
                        .title("储备布局地理信息")
                        .description("储备布局地理信息")
                        .termsOfServiceUrl("https://www.xiaonuo.vip")
                        .contact(new Contact("UNIS_TEAM","https://www.xiaonuo.vip", "xuyuxiang29@foxmail.com"))
                        .version("2.12.0")
                        .build())
                .globalResponseMessage(RequestMethod.GET, CommonResult.responseList())
                .globalResponseMessage(RequestMethod.POST, CommonResult.responseList())
                .groupName("储备布局地理信息")
                .select()
                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
                .apis(RequestHandlerSelectors.basePackage("com.unis.reserveLayout"))
                .paths(PathSelectors.any())
                .build().extensions(openApiExtensionResolver.buildExtensions("储备布局地理信息"));
    }

}
