diff --git a/pom.xml b/pom.xml
index c760cfd0..23e2d066 100644
--- a/pom.xml
+++ b/pom.xml
@@ -65,6 +65,7 @@
27.1-jre
1.5.21
2.9.2
+ 2.9.2
1.16.9
@@ -121,6 +122,11 @@
swagger-annotations
${swagger.version}
+
+ io.springfox
+ springfox-swagger2
+ ${springfox-swagger2.version}
+
net.oschina.durcframework
diff --git a/sop-common/sop-service-common/pom.xml b/sop-common/sop-service-common/pom.xml
index 34f7df4e..70eb1034 100644
--- a/sop-common/sop-service-common/pom.xml
+++ b/sop-common/sop-service-common/pom.xml
@@ -60,7 +60,7 @@
io.springfox
- springfox-spring-web
+ springfox-swagger2
true
diff --git a/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/swagger/CustomModelToSwaggerMapper.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/swagger/CustomModelToSwaggerMapper.java
new file mode 100644
index 00000000..0f2c9a64
--- /dev/null
+++ b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/swagger/CustomModelToSwaggerMapper.java
@@ -0,0 +1,20 @@
+package com.gitee.sop.servercommon.swagger;
+
+import io.swagger.models.parameters.Parameter;
+import springfox.documentation.swagger2.mappers.ServiceModelToSwagger2MapperImpl;
+
+import java.util.Comparator;
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class CustomModelToSwaggerMapper extends ServiceModelToSwagger2MapperImpl {
+
+ @Override
+ protected List parameterListToParameterList(List list) {
+ // list需要根据order|postion排序
+ list = list.stream()
+ .sorted(Comparator.comparingInt(springfox.documentation.service.Parameter::getOrder))
+ .collect(Collectors.toList());
+ return super.parameterListToParameterList(list);
+ }
+}
diff --git a/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/swagger/CustomSwaggerParameterBuilder.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/swagger/CustomSwaggerParameterBuilder.java
new file mode 100644
index 00000000..b3e4974b
--- /dev/null
+++ b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/swagger/CustomSwaggerParameterBuilder.java
@@ -0,0 +1,127 @@
+package com.gitee.sop.servercommon.swagger;
+
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+import com.google.common.base.Strings;
+import com.google.common.collect.Lists;
+import io.swagger.annotations.ApiModelProperty;
+import io.swagger.annotations.ApiParam;
+import springfox.documentation.builders.ParameterBuilder;
+import springfox.documentation.service.AllowableListValues;
+import springfox.documentation.service.AllowableValues;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spi.schema.EnumTypeDeterminer;
+import springfox.documentation.spi.service.ExpandedParameterBuilderPlugin;
+import springfox.documentation.spi.service.contexts.ParameterExpansionContext;
+import springfox.documentation.spring.web.DescriptionResolver;
+import springfox.documentation.swagger.common.SwaggerPluginSupport;
+import springfox.documentation.swagger.readers.parameter.Examples;
+import springfox.documentation.swagger.schema.ApiModelProperties;
+
+import java.util.Arrays;
+import java.util.List;
+
+import static springfox.documentation.swagger.common.SwaggerPluginSupport.SWAGGER_PLUGIN_ORDER;
+
+/**
+ * Created by wujie on 2019/2/16.
+ * 自定义ExpandedParameterBuilderPlugin,主要是修正源码query传入请求参数postion无效
+ * 这里,将postion赋值给order
+ *
+ * https://blog.csdn.net/qq_38316721/article/details/103908793
+ */
+public class CustomSwaggerParameterBuilder implements ExpandedParameterBuilderPlugin {
+
+ private final DescriptionResolver descriptions;
+ private final EnumTypeDeterminer enumTypeDeterminer;
+
+ public CustomSwaggerParameterBuilder(
+ DescriptionResolver descriptions,
+ EnumTypeDeterminer enumTypeDeterminer) {
+ this.descriptions = descriptions;
+ this.enumTypeDeterminer = enumTypeDeterminer;
+ }
+
+ @Override
+ public void apply(ParameterExpansionContext context) {
+ Optional apiModelPropertyOptional = context.findAnnotation(ApiModelProperty.class);
+ if (apiModelPropertyOptional.isPresent()) {
+ fromApiModelProperty(context, apiModelPropertyOptional.get());
+ }
+ Optional apiParamOptional = context.findAnnotation(ApiParam.class);
+ if (apiParamOptional.isPresent()) {
+ fromApiParam(context, apiParamOptional.get());
+ }
+ }
+
+ @Override
+ public boolean supports(DocumentationType delimiter) {
+ return SwaggerPluginSupport.pluginDoesApply(delimiter);
+ }
+
+ private void fromApiParam(ParameterExpansionContext context, ApiParam apiParam) {
+ String allowableProperty = Strings.emptyToNull(apiParam.allowableValues());
+ AllowableValues allowable = allowableValues(
+ Optional.fromNullable(allowableProperty),
+ context.getFieldType().getErasedType());
+
+ maybeSetParameterName(context, apiParam.name())
+ .description(descriptions.resolve(apiParam.value()))
+ .defaultValue(apiParam.defaultValue())
+ .required(apiParam.required())
+ .allowMultiple(apiParam.allowMultiple())
+ .allowableValues(allowable)
+ .parameterAccess(apiParam.access())
+ .hidden(apiParam.hidden())
+ .scalarExample(apiParam.example())
+ .complexExamples(Examples.examples(apiParam.examples()))
+ .order(SWAGGER_PLUGIN_ORDER)
+ .build();
+ }
+
+ private void fromApiModelProperty(ParameterExpansionContext context, ApiModelProperty apiModelProperty) {
+ String allowableProperty = Strings.emptyToNull(apiModelProperty.allowableValues());
+ AllowableValues allowable = allowableValues(
+ Optional.fromNullable(allowableProperty),
+ context.getFieldType().getErasedType());
+
+ maybeSetParameterName(context, apiModelProperty.name())
+ .description(descriptions.resolve(apiModelProperty.value()))
+ .required(apiModelProperty.required())
+ .allowableValues(allowable)
+ .parameterAccess(apiModelProperty.access())
+ .hidden(apiModelProperty.hidden())
+ .scalarExample(apiModelProperty.example())
+ //源码这里是: SWAGGER_PLUGIN_ORDER,需要修正
+ .order(apiModelProperty.position())
+ .build();
+ }
+
+ private ParameterBuilder maybeSetParameterName(ParameterExpansionContext context, String parameterName) {
+ if (!Strings.isNullOrEmpty(parameterName)) {
+ context.getParameterBuilder().name(parameterName);
+ }
+ return context.getParameterBuilder();
+ }
+
+ private AllowableValues allowableValues(final Optional optionalAllowable, Class> fieldType) {
+
+ AllowableValues allowable = null;
+ if (enumTypeDeterminer.isEnum(fieldType)) {
+ allowable = new AllowableListValues(getEnumValues(fieldType), "LIST");
+ } else if (optionalAllowable.isPresent()) {
+ allowable = ApiModelProperties.allowableValueFromString(optionalAllowable.get());
+ }
+ return allowable;
+ }
+
+ private List getEnumValues(final Class> subject) {
+ return Lists.transform(Arrays.asList(subject.getEnumConstants()), new Function