Merge branch 'dev' of lisb/pigx into dev

This commit is contained in:
冷冷 authored and Gogs committed 2018-07-26 18:39:39 +08:00
commit fed4f6ad2e
26 files changed
+138 -262

No files matched your search

@@ -35,7 +35,7 @@ import org.springframework.security.oauth2.client.resource.OAuth2ProtectedResour
*/
@Configuration
@ConditionalOnProperty("security.oauth2.client.client-id")
public class PigxFeignClientIntercept {
public class PigxFeignClientInterceptor {
@Bean
public RequestInterceptor oauth2FeignRequestInterceptor(OAuth2ClientContext oAuth2ClientContext,
OAuth2ProtectedResourceDetails resource) {
@@ -2,4 +2,4 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.pig4cloud.pigx.common.security.component.PermissionService,\
com.pig4cloud.pigx.common.security.component.PigAccessDeniedHandler,\
com.pig4cloud.pigx.common.security.component.ResourceAuthExceptionEntryPoint,\
com.pig4cloud.pigx.common.security.interceptor.PigxFeignClientIntercept
com.pig4cloud.pigx.common.security.interceptor.PigxFeignClientInterceptor
@@ -62,7 +62,7 @@ public class SwaggerAutoConfiguration {
if (CollUtil.isEmpty(swaggerProperties.getBasePath())) {
swaggerProperties.getBasePath().add(BASE_PATH);
}
//noinspection unchecked
List<Predicate<String>> basePath = new ArrayList();
swaggerProperties.getBasePath().forEach(path -> basePath.add(PathSelectors.ant(path)));
@@ -70,13 +70,14 @@ public class SwaggerAutoConfiguration {
if (CollUtil.isEmpty(swaggerProperties.getExcludePath())) {
swaggerProperties.getExcludePath().add(DEFAULT_EXCLUDE_PATH);
}
List<Predicate<String>> excludePath = new ArrayList<>();
swaggerProperties.getExcludePath().forEach(path -> excludePath.add(PathSelectors.ant(path)));
//noinspection Guava
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo()).select()
.apis(RequestHandlerSelectors.any())
.host(swaggerProperties.getHost())
.apiInfo(apiInfo(swaggerProperties)).select()
.apis(RequestHandlerSelectors.basePackage(swaggerProperties.getBasePackage()))
.paths(Predicates.and(Predicates.not(Predicates.or(excludePath)), Predicates.or(basePath)))
.build()
.securitySchemes(Collections.singletonList(securitySchema()))
@@ -86,7 +87,7 @@ public class SwaggerAutoConfiguration {
private SecurityContext securityContext() {
return SecurityContext.builder().securityReferences(defaultAuth())
.forPaths(PathSelectors.ant("/**"))
.forPaths(PathSelectors.ant(BASE_PATH))
.build();
}
@@ -114,13 +115,15 @@ public class SwaggerAutoConfiguration {
return new OAuth("pigX OAuth", authorizationScopeList, grantTypes);
}
private ApiInfo apiInfo() {
private ApiInfo apiInfo(SwaggerProperties swaggerProperties) {
return new ApiInfoBuilder()
.title("PigX Swagger API ")
.description("https://gitee.com/log4j/pig/wikis")
.termsOfServiceUrl("https://gitee.wang/pig/pigx")
.contact(new Contact("冷冷", "https://gitee.wang/pig/pigx", "wangiegie@gmail.com"))
.version("2.0")
.title(swaggerProperties.getTitle())
.description(swaggerProperties.getDescription())
.license(swaggerProperties.getLicense())
.licenseUrl(swaggerProperties.getLicenseUrl())
.termsOfServiceUrl(swaggerProperties.getTermsOfServiceUrl())
.contact(new Contact(swaggerProperties.getContact().getName(), swaggerProperties.getContact().getUrl(), swaggerProperties.getContact().getEmail()))
.version(swaggerProperties.getVersion())
.build();
}
@@ -1,7 +1,25 @@
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.common.swagger.config;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
@@ -9,12 +27,16 @@ import java.util.List;
/**
* SwaggerProperties
*
* @author: lisb
* @author: lengleng
* @date: 2018/7/25 14:00
*/
@Data
@ConfigurationProperties("swagger")
public class SwaggerProperties {
/**
* swagger会解析的包路径
**/
private String basePackage = "";
/**
* swagger会解析的url规则
**/
@@ -23,4 +45,56 @@ public class SwaggerProperties {
* 在basePath基础上需要排除的url规则
**/
private List<String> excludePath = new ArrayList<>();
/**
* 标题
**/
private String title = "PigX Swagger API";
/**
* 描述
**/
private String description = "https://gitee.com/log4j/pig/wikis";
/**
* 版本
**/
private String version = "2.0";
/**
* 许可证
**/
private String license = "Powered By PigX";
/**
* 许可证URL
**/
private String licenseUrl = "https://gitee.com/log4j/pig/wikis";
/**
* 服务条款URL
**/
private String termsOfServiceUrl = "https://gitee.wang/pig/pigx";
/**
* 忽略的参数类型
**/
private List<Class<?>> ignoredParameterTypes = new ArrayList<>();
/**
* host信息
**/
private String host = "";
private Contact contact = new Contact();
@Data
@NoArgsConstructor
public static class Contact {
/**
* 联系人
**/
private String name = "冷冷";
/**
* 联系人url
**/
private String url = "https://gitee.wang/pig/pigx";
/**
* 联系人email
**/
private String email = "wangiegie@gmail.com";
}
}
@@ -40,4 +40,13 @@ mybatis-plus:
cache-enabled: true
# swagger相关配置
swagger:
exclude-path: /actuator/**,/error
description: '全宇宙最牛逼的Spring Cloud微服务开发脚手架'
version: '1.2.4'
#base-package: com.pig4cloud.pigx.admin.controller
exclude-path:
- /actuator/**
- /error
contact:
name: '冷冷'
email: 'wangiegie@gmail.com'
url: 'https://gitee.wang/pig/pigx'
@@ -17,7 +17,7 @@
package com.pig4cloud.pigx.gateway.config;
import com.pig4cloud.pigx.gateway.handle.*;
import com.pig4cloud.pigx.gateway.handler.*;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
@@ -15,7 +15,7 @@
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.gateway.handle;
package com.pig4cloud.pigx.gateway.handler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
@@ -15,7 +15,7 @@
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.gateway.handle;
package com.pig4cloud.pigx.gateway.handler;
import com.google.code.kaptcha.Producer;
import com.pig4cloud.pigx.gateway.filter.ImageCodeGatewayFilter;
@@ -15,7 +15,7 @@
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.gateway.handle;
package com.pig4cloud.pigx.gateway.handler;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -43,7 +43,7 @@ public class SwaggerResourceHandler implements HandlerFunction<ServerResponse> {
/**
* Handle the given request.
*
* @param request the request to handle
* @param request the request to handler
* @return the response
*/
@Override
@@ -15,7 +15,7 @@
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.gateway.handle;
package com.pig4cloud.pigx.gateway.handler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -46,7 +46,7 @@ public class SwaggerSecurityHandler implements HandlerFunction<ServerResponse> {
/**
* Handle the given request.
*
* @param request the request to handle
* @param request the request to handler
* @return the response
*/
@Override
@@ -15,7 +15,7 @@
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.gateway.handle;
package com.pig4cloud.pigx.gateway.handler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -46,7 +46,7 @@ public class SwaggerUiHandler implements HandlerFunction<ServerResponse> {
/**
* Handle the given request.
*
* @param request the request to handle
* @param request the request to handler
* @return the response
*/
@Override
@@ -20,6 +20,7 @@
package com.pig4cloud.pigx.admin.api.dto;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* @author lengleng
@@ -27,6 +28,7 @@ import lombok.Data;
* 部门树
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class DeptTree extends TreeNode {
private String name;
}
@@ -21,12 +21,14 @@ package com.pig4cloud.pigx.admin.api.dto;
import com.pig4cloud.pigx.admin.api.vo.MenuVO;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* @author lengleng
* @date 2017年11月9日23:33:27
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class MenuTree extends TreeNode {
private String icon;
private String name;
@@ -21,6 +21,7 @@ package com.pig4cloud.pigx.admin.api.dto;
import com.pig4cloud.pigx.admin.api.entity.SysRole;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* @author lengleng
@@ -28,6 +29,7 @@ import lombok.Data;
* 角色Dto
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class RoleDTO extends SysRole {
/**
* 角色部门Id
@@ -21,6 +21,7 @@ package com.pig4cloud.pigx.admin.api.dto;
import com.pig4cloud.pigx.admin.api.entity.SysUser;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
@@ -29,6 +30,7 @@ import java.util.List;
* @date 2017/11/5
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class UserDTO extends SysUser {
/**
* 角色ID
@@ -26,6 +26,7 @@ import com.baomidou.mybatisplus.annotations.TableLogic;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.util.Date;
@@ -39,6 +40,7 @@ import java.util.Date;
* @since 2018-01-22
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("sys_dept")
public class SysDept extends Model<SysDept> {
@@ -22,6 +22,7 @@ package com.pig4cloud.pigx.admin.api.entity;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
@@ -34,6 +35,7 @@ import java.io.Serializable;
* @since 2018-01-22
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("sys_dept_relation")
public class SysDeptRelation extends Model<SysDeptRelation> {
@@ -26,6 +26,7 @@ import com.baomidou.mybatisplus.annotations.TableLogic;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.math.BigDecimal;
@@ -40,6 +41,7 @@ import java.util.Date;
* @since 2017-11-19
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("sys_dict")
public class SysDict extends Model<SysDict> {
@@ -26,6 +26,7 @@ import com.baomidou.mybatisplus.annotations.TableLogic;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.util.Date;
@@ -39,6 +40,7 @@ import java.util.Date;
* @since 2017-11-08
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("sys_menu")
public class SysMenu extends Model<SysMenu> {
@@ -24,6 +24,8 @@ import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
@@ -35,6 +37,8 @@ import java.io.Serializable;
* @author lengleng
* @since 2018-05-15
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("sys_oauth_client_details")
public class SysOauthClientDetails extends Model<SysOauthClientDetails> {
@@ -60,114 +64,9 @@ public class SysOauthClientDetails extends Model<SysOauthClientDetails> {
private String additionalInformation;
private String autoapprove;
public String getClientId() {
return clientId;
}
public void setClientId(String clientId) {
this.clientId = clientId;
}
public String getResourceIds() {
return resourceIds;
}
public void setResourceIds(String resourceIds) {
this.resourceIds = resourceIds;
}
public String getClientSecret() {
return clientSecret;
}
public void setClientSecret(String clientSecret) {
this.clientSecret = clientSecret;
}
public String getScope() {
return scope;
}
public void setScope(String scope) {
this.scope = scope;
}
public String getAuthorizedGrantTypes() {
return authorizedGrantTypes;
}
public void setAuthorizedGrantTypes(String authorizedGrantTypes) {
this.authorizedGrantTypes = authorizedGrantTypes;
}
public String getWebServerRedirectUri() {
return webServerRedirectUri;
}
public void setWebServerRedirectUri(String webServerRedirectUri) {
this.webServerRedirectUri = webServerRedirectUri;
}
public String getAuthorities() {
return authorities;
}
public void setAuthorities(String authorities) {
this.authorities = authorities;
}
public Integer getAccessTokenValidity() {
return accessTokenValidity;
}
public void setAccessTokenValidity(Integer accessTokenValidity) {
this.accessTokenValidity = accessTokenValidity;
}
public Integer getRefreshTokenValidity() {
return refreshTokenValidity;
}
public void setRefreshTokenValidity(Integer refreshTokenValidity) {
this.refreshTokenValidity = refreshTokenValidity;
}
public String getAdditionalInformation() {
return additionalInformation;
}
public void setAdditionalInformation(String additionalInformation) {
this.additionalInformation = additionalInformation;
}
public String getAutoapprove() {
return autoapprove;
}
public void setAutoapprove(String autoapprove) {
this.autoapprove = autoapprove;
}
@Override
protected Serializable pkVal() {
return this.clientId;
}
@Override
public String toString() {
return "SysOauthClientDetails{" +
", clientId=" + clientId +
", resourceIds=" + resourceIds +
", clientSecret=" + clientSecret +
", scope=" + scope +
", authorizedGrantTypes=" + authorizedGrantTypes +
", webServerRedirectUri=" + webServerRedirectUri +
", authorities=" + authorities +
", accessTokenValidity=" + accessTokenValidity +
", refreshTokenValidity=" + refreshTokenValidity +
", additionalInformation=" + additionalInformation +
", autoapprove=" + autoapprove +
"}";
}
}
@@ -26,6 +26,7 @@ import com.baomidou.mybatisplus.annotations.TableLogic;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.util.Date;
@@ -39,6 +40,7 @@ import java.util.Date;
* @since 2017-10-29
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("sys_role")
public class SysRole extends Model<SysRole> {
@@ -68,16 +70,4 @@ public class SysRole extends Model<SysRole> {
return this.roleId;
}
@Override
public String toString() {
return "SysRole{" +
", roleId=" + roleId +
", roleName=" + roleName +
", roleCode=" + roleCode +
", roleDesc=" + roleDesc +
", createTime=" + createTime +
", updateTime=" + updateTime +
", delFlag=" + delFlag +
"}";
}
}
@@ -25,6 +25,7 @@ import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
@@ -37,6 +38,7 @@ import java.io.Serializable;
* @since 2018-01-20
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("sys_role_dept")
public class SysRoleDept extends Model<SysRoleDept> {
@@ -24,6 +24,7 @@ import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
@@ -36,6 +37,7 @@ import java.io.Serializable;
* @since 2017-10-29
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("sys_role_menu")
public class SysRoleMenu extends Model<SysRoleMenu> {
@@ -92,19 +92,4 @@ public class SysUser implements Serializable {
@TableField("dept_id")
private Integer deptId;
@Override
public String toString() {
return "SysUser{" +
"userId=" + userId +
", username='" + username + '\'' +
", password='" + password + '\'' +
", salt='" + salt + '\'' +
", createTime=" + createTime +
", updateTime=" + updateTime +
", delFlag='" + delFlag + '\'' +
", phone='" + phone + '\'' +
", avatar='" + avatar + '\'' +
", deptId=" + deptId +
'}';
}
}
@@ -24,6 +24,7 @@ import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
@@ -36,6 +37,7 @@ import java.io.Serializable;
* @since 2017-10-29
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("sys_user_role")
public class SysUserRole extends Model<SysUserRole> {
@@ -1,106 +0,0 @@
/*
*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*
*/
package com.pig4cloud.pigx.admin.api.entity;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableLogic;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
* 动态路由配置表
* </p>
*
* @author lengleng
* @since 2018-05-15
*/
@Data
@TableName("sys_zuul_route")
public class SysZuulRoute extends Model<SysZuulRoute> {
private static final long serialVersionUID = 1L;
/**
* router Id
*/
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
/**
* 路由路径
*/
private String path;
/**
* 服务名称
*/
@TableField("service_id")
private String serviceId;
/**
* url代理
*/
private String url;
/**
* 转发去掉前缀
*/
@TableField("strip_prefix")
private String stripPrefix;
/**
* 是否重试
*/
private String retryable;
/**
* 是否启用
*/
private String enabled;
/**
* 敏感请求头
*/
@TableField("sensitiveHeaders_list")
private String sensitiveheadersList;
/**
* 创建时间
*/
@TableField("create_time")
private Date createTime;
/**
* 更新时间
*/
@TableField("update_time")
private Date updateTime;
/**
* 删除标识(0-正常,1-删除)
*/
@TableLogic
@TableField("del_flag")
private String delFlag;
@Override
protected Serializable pkVal() {
return this.id;
}
}