代码优化
This commit is contained in:
parent
9437a9e186
commit
895864b88d
@ -15,20 +15,11 @@
|
||||
*/
|
||||
package me.zhengjie.config;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.fasterxml.classmate.TypeResolver;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.schema.AlternateTypeRule;
|
||||
import springfox.documentation.schema.AlternateTypeRuleConvention;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.service.ApiKey;
|
||||
import springfox.documentation.service.AuthorizationScope;
|
||||
@ -38,10 +29,8 @@ import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spi.service.contexts.SecurityContext;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import static springfox.documentation.schema.AlternateTypeRules.newRule;
|
||||
|
||||
/**
|
||||
* api页面 /doc.html
|
||||
@ -115,38 +104,3 @@ public class SwaggerConfig {
|
||||
return securityReferences;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将Pageable转换展示在swagger中
|
||||
*/
|
||||
@Configuration
|
||||
class SwaggerDataConfig {
|
||||
|
||||
@Bean
|
||||
public AlternateTypeRuleConvention pageableConvention(final TypeResolver resolver) {
|
||||
return new AlternateTypeRuleConvention() {
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return Ordered.HIGHEST_PRECEDENCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AlternateTypeRule> rules() {
|
||||
return CollUtil.newArrayList(newRule(resolver.resolve(Pageable.class), resolver.resolve(Page.class)));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ApiModel
|
||||
@Data
|
||||
private static class Page {
|
||||
@ApiModelProperty("页码 (0..N)")
|
||||
private Integer page;
|
||||
|
||||
@ApiModelProperty("每页显示的数目")
|
||||
private Integer size;
|
||||
|
||||
@ApiModelProperty("以下列格式排序标准:property[,asc | desc]。 默认排序顺序为升序。 支持多种排序条件:如:id,asc")
|
||||
private List<String> sort;
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@
|
||||
AND deploy_date BETWEEN #{criteria.deployDate[0]} AND #{criteria.deployDate[1]}
|
||||
</if>
|
||||
</where>
|
||||
order by deploy_id desc
|
||||
order by deploy_date desc
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -30,7 +30,7 @@
|
||||
<if test="criteria.label != null and criteria.label != ''">
|
||||
and dd.label = #{criteria.label}
|
||||
</if>
|
||||
order by dd.dict_sort
|
||||
order by dd.dict_sort, dd.dict_id desc
|
||||
</select>
|
||||
|
||||
<select id="findByDictName" resultMap="BaseResultMap">
|
||||
|
@ -31,6 +31,6 @@
|
||||
and create_time between #{criteria.createTime[0]} and #{criteria.createTime[1]}
|
||||
</if>
|
||||
</where>
|
||||
order by job_sort
|
||||
order by job_sort, job_id desc
|
||||
</select>
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user