/*
package com.changfa.config;

import com.changfa.enums.StatusEnum;
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.RequestMethod;
import springfox.documentation.builders.*;
import springfox.documentation.schema.ModelRef;
import springfox.documentation.service.*;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spi.service.contexts.SecurityContext;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@Configuration
@EnableSwagger2WebMvc
@EnableKnife4j
public class Knife4jConfiguration {

    */
/**
     * 通过 createRestApi函数来构建一个DocketBean
     * 函数名,可以随意命名,喜欢什么命名就什么命名
     *//*

    private List<Parameter> globalOperationParameters(){
        List<Parameter>  operationParameters = new ArrayList<>();
        ParameterBuilder tokenPar = new ParameterBuilder();
        tokenPar.name("Authorizations").description("Authorizations")
                .modelRef(new ModelRef("string")).parameterType("header").required(false);
        operationParameters.add(tokenPar.build());
        return operationParameters;
    }

    private List<ResponseMessage> responseMessage(){
        //添加全局响应状态码
        List<ResponseMessage> responseMessageList = new ArrayList<>();
        Arrays.stream(StatusEnum.values()).forEach(statusEnum -> {
            responseMessageList.add(
                    new ResponseMessageBuilder().code(statusEnum.getCode()).message(statusEnum.getMessage()).responseModel(
                            new ModelRef(statusEnum.getMessage())).build()
            );
        });
        return responseMessageList;
    }

    @Bean(value = "defaultApi2")
    public Docket defaultApi2() {
        Docket docket=new Docket(DocumentationType.SWAGGER_2).globalOperationParameters(globalOperationParameters())
                .globalResponseMessage(RequestMethod.POST,responseMessage())
                .globalResponseMessage(RequestMethod.GET,responseMessage())
                .globalResponseMessage(RequestMethod.DELETE,responseMessage())
                .globalResponseMessage(RequestMethod.PUT,responseMessage())
                .apiInfo(apiInfo())
                //分组名称
                .groupName("2.X版本")
                .select()
                //这里指定Controller扫描包路径
                .apis(RequestHandlerSelectors.basePackage("com.changfa.controller"))
                .paths(PathSelectors.any())
                .build()
                .securitySchemes(securitySchemes())
                .securityContexts(securityContexts());
        return docket;
    }
    //构建 api文档的详细信息函数
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                //页面标题
                .title("北京畅发平台服务端接口文档")
                //条款地址
                .version("1.0")
                //描述
                .description("API 描述")
                .build();
    }

    private List<ApiKey> securitySchemes() {
        List<ApiKey> apiKeys = new ArrayList<>();
        apiKeys.add(new ApiKey("Authorizations", "Authorizations", "header"));
        return apiKeys;
    }

    private List<SecurityContext> securityContexts() {
        List<SecurityContext> securityContexts = new ArrayList<>();
        securityContexts.add(SecurityContext.builder()
                .securityReferences(defaultAuth())
                .forPaths(PathSelectors.regex("^(?!auth).*$")).build());
        return securityContexts;
    }
    private List<SecurityReference> defaultAuth() {
        AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
        AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
        authorizationScopes[0] = authorizationScope;
        List<SecurityReference> securityReferences = new ArrayList<>();
        securityReferences.add(new SecurityReference("Authorizations", authorizationScopes));
        return securityReferences;
    }
}*/
