├── .gitignore ├── images ├── SSO.png ├── code.png ├── menu.png ├── role.png ├── table.png ├── user.png ├── config.png ├── system.png ├── datasource.png ├── template.png ├── menuResource.png └── menuResource_edit.png ├── .mvn └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── vickze-common ├── src │ └── main │ │ └── java │ │ └── io │ │ └── vickze │ │ └── common │ │ ├── enums │ │ └── DBOrder.java │ │ ├── validation │ │ ├── Insert.java │ │ ├── Update.java │ │ └── Phone.java │ │ ├── domain │ │ ├── DTO │ │ │ ├── MessageResultDTO.java │ │ │ ├── BusinessResultDTO.java │ │ │ └── QueryDTO.java │ │ ├── Interface.java │ │ └── RPageRequest.java │ │ ├── exception │ │ ├── MessageException.java │ │ ├── BusinessException.java │ │ ├── ClientException.java │ │ └── FeignExceptionErrorDecoder.java │ │ ├── serializer │ │ ├── BirthdaySerializer.java │ │ ├── ZeroBigDecimalSerializer.java │ │ ├── ZeroCeilingBigDecimalSerializer.java │ │ ├── TwoBigDecimalSerializer.java │ │ └── EmailSerializer.java │ │ ├── util │ │ ├── SQLUtil.java │ │ ├── InterfaceUtil.java │ │ └── JsonUtil.java │ │ └── deserializer │ │ └── ZonedDateTimeDeserializer.java └── pom.xml ├── vickze-generator ├── src │ ├── main │ │ ├── java │ │ │ └── io │ │ │ │ └── vickze │ │ │ │ └── generator │ │ │ │ ├── domain │ │ │ │ ├── DTO │ │ │ │ │ ├── DataSourceDTO.java │ │ │ │ │ ├── GeneratorQueryDTO.java │ │ │ │ │ ├── SaveDataSourceDTO.java │ │ │ │ │ ├── GeneratorCodeDTO.java │ │ │ │ │ ├── TemplateQueryDTO.java │ │ │ │ │ ├── ConfigQueryDTO.java │ │ │ │ │ ├── TableDTO.java │ │ │ │ │ └── ColumnDTO.java │ │ │ │ └── DO │ │ │ │ │ ├── TableDO.java │ │ │ │ │ ├── ColumnDO.java │ │ │ │ │ ├── TemplateDO.java │ │ │ │ │ └── ConfigDO.java │ │ │ │ ├── mapper │ │ │ │ ├── ColumnMapper.java │ │ │ │ ├── ConfigMapper.java │ │ │ │ ├── TableMapper.java │ │ │ │ └── TemplateMapper.java │ │ │ │ ├── constant │ │ │ │ ├── ConfigConstant.java │ │ │ │ └── TemplateConstant.java │ │ │ │ ├── repository │ │ │ │ └── ConfigRepository.java │ │ │ │ ├── service │ │ │ │ ├── ConfigService.java │ │ │ │ ├── GeneratorService.java │ │ │ │ ├── TemplateService.java │ │ │ │ └── impl │ │ │ │ │ ├── TemplateServiceImpl.java │ │ │ │ │ └── ConfigServiceImpl.java │ │ │ │ ├── config │ │ │ │ ├── WebMvcConfiguration.java │ │ │ │ └── MybatisPlusConfiguration.java │ │ │ │ ├── GeneratorApplication.java │ │ │ │ ├── exception │ │ │ │ └── GeneratorExceptionHandler.java │ │ │ │ ├── controller │ │ │ │ ├── TemplateController.java │ │ │ │ ├── ConfigController.java │ │ │ │ └── GeneratorController.java │ │ │ │ ├── util │ │ │ │ └── GeneratorUtil.java │ │ │ │ └── swagger │ │ │ │ └── SwaggerConfig.java │ │ └── resources │ │ │ ├── bootstrap.yml │ │ │ └── application.yml │ └── test │ │ └── java │ │ └── io │ │ └── vickze │ │ └── TemplateTest.java ├── Dockerfile └── pom.xml ├── vickze-auth ├── vickze-auth-common │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── io │ │ │ └── vickze │ │ │ └── auth │ │ │ ├── domain │ │ │ └── DTO │ │ │ │ ├── AuthUserDTO.java │ │ │ │ └── CheckPermissionDTO.java │ │ │ └── constant │ │ │ ├── TokenConstant.java │ │ │ └── GlobalConstant.java │ └── pom.xml ├── vickze-auth-server │ ├── src │ │ ├── main │ │ │ ├── java │ │ │ │ └── io │ │ │ │ │ └── vickze │ │ │ │ │ └── auth │ │ │ │ │ ├── domain │ │ │ │ │ ├── DTO │ │ │ │ │ │ ├── CreateTokenDTO.java │ │ │ │ │ │ ├── TokenDTO.java │ │ │ │ │ │ ├── AssignMenuResourceDTO.java │ │ │ │ │ │ ├── CurrentUserDTO.java │ │ │ │ │ │ ├── MenuResourceQueryDTO.java │ │ │ │ │ │ ├── RoleQueryDTO.java │ │ │ │ │ │ ├── SystemQueryDTO.java │ │ │ │ │ │ ├── MenuTreeDTO.java │ │ │ │ │ │ ├── MenuQueryDTO.java │ │ │ │ │ │ ├── UserQueryDTO.java │ │ │ │ │ │ ├── MenuResourceDTO.java │ │ │ │ │ │ └── UserDTO.java │ │ │ │ │ └── DO │ │ │ │ │ │ ├── UserRoleDO.java │ │ │ │ │ │ ├── RoleMenuResourceDO.java │ │ │ │ │ │ ├── RoleDO.java │ │ │ │ │ │ ├── MenuDO.java │ │ │ │ │ │ ├── SystemDO.java │ │ │ │ │ │ ├── MenuResourceDO.java │ │ │ │ │ │ ├── MenuResourceInterfaceDO.java │ │ │ │ │ │ └── UserDO.java │ │ │ │ │ ├── service │ │ │ │ │ ├── CheckPermissionService.java │ │ │ │ │ ├── TokenService.java │ │ │ │ │ ├── SystemService.java │ │ │ │ │ ├── MenuService.java │ │ │ │ │ ├── UserService.java │ │ │ │ │ ├── MenuResourceService.java │ │ │ │ │ ├── RoleService.java │ │ │ │ │ └── impl │ │ │ │ │ │ ├── SystemServiceImpl.java │ │ │ │ │ │ ├── UUIDTokenServiceImpl.java │ │ │ │ │ │ ├── JwtServiceImpl.java │ │ │ │ │ │ └── CheckPermissionServiceImpl.java │ │ │ │ │ ├── enums │ │ │ │ │ └── UserStatus.java │ │ │ │ │ ├── mapper │ │ │ │ │ ├── MenuMapper.java │ │ │ │ │ ├── RoleMapper.java │ │ │ │ │ ├── UserMapper.java │ │ │ │ │ ├── SystemMapper.java │ │ │ │ │ ├── UserRoleMapper.java │ │ │ │ │ ├── MenuResourceMapper.java │ │ │ │ │ ├── MenuResourceInterfaceMapper.java │ │ │ │ │ └── RoleMenuResourceMapper.java │ │ │ │ │ ├── properties │ │ │ │ │ ├── JwtProperties.java │ │ │ │ │ ├── UUIDTokenProperties.java │ │ │ │ │ └── AuthCheckPermissionProperties.java │ │ │ │ │ ├── AuthApplication.java │ │ │ │ │ ├── controller │ │ │ │ │ ├── CheckPermissionController.java │ │ │ │ │ ├── TokenController.java │ │ │ │ │ ├── SystemController.java │ │ │ │ │ ├── MenuResourceController.java │ │ │ │ │ ├── MenuController.java │ │ │ │ │ ├── RoleController.java │ │ │ │ │ └── UserController.java │ │ │ │ │ ├── config │ │ │ │ │ ├── WebMvcConfiguration.java │ │ │ │ │ └── MybatisPlusConfiguration.java │ │ │ │ │ └── swagger │ │ │ │ │ └── SwaggerConfig.java │ │ │ └── resources │ │ │ │ ├── bootstrap.yml │ │ │ │ └── application.yml │ │ └── test │ │ │ └── java │ │ │ └── io │ │ │ └── vickze │ │ │ └── auth │ │ │ ├── UriTest.java │ │ │ └── BCryptTest.java │ └── Dockerfile ├── vickze-auth-client │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── io │ │ │ └── vickze │ │ │ └── auth │ │ │ ├── resovler │ │ │ ├── AuthUser.java │ │ │ └── AuthUserHandlerMethodArgumentResolver.java │ │ │ ├── client │ │ │ ├── fallback │ │ │ │ ├── TokenClientFallback.java │ │ │ │ ├── UserClientFallback.java │ │ │ │ └── CheckPermissionClientFallback.java │ │ │ ├── CheckPermissionClient.java │ │ │ ├── TokenClient.java │ │ │ └── UserClient.java │ │ │ ├── exception │ │ │ ├── UnauthorizedException.java │ │ │ ├── ForbiddenException.java │ │ │ └── AuthExceptionHandler.java │ │ │ ├── properties │ │ │ └── FeignOkhttpProperties.java │ │ │ ├── interceptor │ │ │ └── AuthInterceptor.java │ │ │ └── config │ │ │ └── FeignOkHttpConfig.java │ └── pom.xml └── pom.xml ├── vickze-sso ├── src │ └── main │ │ ├── resources │ │ ├── bootstrap.yml │ │ └── application.yml │ │ └── java │ │ └── io │ │ └── vickze │ │ └── sso │ │ ├── properties │ │ └── SsoProperties.java │ │ ├── SsoApplication.java │ │ ├── swagger │ │ └── SwaggerConfig.java │ │ └── controller │ │ └── SsoController.java ├── Dockerfile └── pom.xml ├── vickze-gateway ├── src │ └── main │ │ ├── resources │ │ └── bootstrap.yml │ │ └── java │ │ └── io │ │ └── vickze │ │ └── gateway │ │ ├── resolver │ │ └── IpAddressKeyResolver.java │ │ ├── properties │ │ └── AccessForbiddenProperties.java │ │ ├── GatewayApplication.java │ │ └── swagger │ │ ├── GatewaySwaggerResourcesProvider.java │ │ └── SwaggerConfig.java ├── Dockerfile └── pom.xml ├── example ├── nacos │ └── custom.properties └── prometheus │ └── prometheus-standalone.yaml └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | *.iml 3 | */target 4 | log/ 5 | 6 | */*/target/ 7 | 8 | 9 | -------------------------------------------------------------------------------- /images/SSO.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vickze/vickze-cloud-admin/HEAD/images/SSO.png -------------------------------------------------------------------------------- /images/code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vickze/vickze-cloud-admin/HEAD/images/code.png -------------------------------------------------------------------------------- /images/menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vickze/vickze-cloud-admin/HEAD/images/menu.png -------------------------------------------------------------------------------- /images/role.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vickze/vickze-cloud-admin/HEAD/images/role.png -------------------------------------------------------------------------------- /images/table.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vickze/vickze-cloud-admin/HEAD/images/table.png -------------------------------------------------------------------------------- /images/user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vickze/vickze-cloud-admin/HEAD/images/user.png -------------------------------------------------------------------------------- /images/config.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vickze/vickze-cloud-admin/HEAD/images/config.png -------------------------------------------------------------------------------- /images/system.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vickze/vickze-cloud-admin/HEAD/images/system.png -------------------------------------------------------------------------------- /images/datasource.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vickze/vickze-cloud-admin/HEAD/images/datasource.png -------------------------------------------------------------------------------- /images/template.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vickze/vickze-cloud-admin/HEAD/images/template.png -------------------------------------------------------------------------------- /images/menuResource.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vickze/vickze-cloud-admin/HEAD/images/menuResource.png -------------------------------------------------------------------------------- /images/menuResource_edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vickze/vickze-cloud-admin/HEAD/images/menuResource_edit.png -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vickze/vickze-cloud-admin/HEAD/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /vickze-common/src/main/java/io/vickze/common/enums/DBOrder.java: -------------------------------------------------------------------------------- 1 | package io.vickze.common.enums; 2 | 3 | public enum DBOrder { 4 | 5 | ASC, 6 | 7 | DESC 8 | } 9 | -------------------------------------------------------------------------------- /vickze-common/src/main/java/io/vickze/common/validation/Insert.java: -------------------------------------------------------------------------------- 1 | package io.vickze.common.validation; 2 | 3 | /** 4 | * @author vick.zeng 5 | */ 6 | public interface Insert { 7 | } 8 | -------------------------------------------------------------------------------- /vickze-common/src/main/java/io/vickze/common/validation/Update.java: -------------------------------------------------------------------------------- 1 | package io.vickze.common.validation; 2 | 3 | /** 4 | * @author vick.zeng 5 | */ 6 | public interface Update { 7 | } 8 | -------------------------------------------------------------------------------- /vickze-generator/src/main/java/io/vickze/generator/domain/DTO/DataSourceDTO.java: -------------------------------------------------------------------------------- 1 | package io.vickze.generator.domain.DTO; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class DataSourceDTO { 7 | private String jdbcUrl; 8 | } 9 | -------------------------------------------------------------------------------- /vickze-common/src/main/java/io/vickze/common/domain/DTO/MessageResultDTO.java: -------------------------------------------------------------------------------- 1 | package io.vickze.common.domain.DTO; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class MessageResultDTO { 7 | 8 | private String message; 9 | } 10 | -------------------------------------------------------------------------------- /vickze-common/src/main/java/io/vickze/common/exception/MessageException.java: -------------------------------------------------------------------------------- 1 | package io.vickze.common.exception; 2 | 3 | public class MessageException extends RuntimeException { 4 | 5 | public MessageException(String message) { 6 | super(message); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-common/src/main/java/io/vickze/auth/domain/DTO/AuthUserDTO.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.domain.DTO; 2 | 3 | 4 | import lombok.Data; 5 | 6 | import java.util.Set; 7 | 8 | @Data 9 | public class AuthUserDTO { 10 | 11 | private Long userId; 12 | 13 | private String username; 14 | } 15 | -------------------------------------------------------------------------------- /vickze-generator/src/main/java/io/vickze/generator/domain/DTO/GeneratorQueryDTO.java: -------------------------------------------------------------------------------- 1 | package io.vickze.generator.domain.DTO; 2 | 3 | import io.vickze.common.domain.DTO.QueryDTO; 4 | import lombok.Data; 5 | 6 | @Data 7 | public class GeneratorQueryDTO extends QueryDTO { 8 | 9 | private String tableName; 10 | } 11 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/domain/DTO/CreateTokenDTO.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.domain.DTO; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class CreateTokenDTO { 7 | 8 | private String systemKey; 9 | 10 | private String username; 11 | 12 | private String password; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/domain/DTO/TokenDTO.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.domain.DTO; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.Set; 6 | 7 | @Data 8 | public class TokenDTO { 9 | 10 | private String token; 11 | 12 | private long expire; 13 | 14 | private Set permissions; 15 | } 16 | -------------------------------------------------------------------------------- /vickze-generator/src/main/java/io/vickze/generator/domain/DTO/SaveDataSourceDTO.java: -------------------------------------------------------------------------------- 1 | package io.vickze.generator.domain.DTO; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class SaveDataSourceDTO { 7 | 8 | private String ds; 9 | 10 | private String jdbcUrl; 11 | 12 | private String username; 13 | 14 | private String password; 15 | } 16 | -------------------------------------------------------------------------------- /vickze-generator/src/main/java/io/vickze/generator/mapper/ColumnMapper.java: -------------------------------------------------------------------------------- 1 | package io.vickze.generator.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import io.vickze.generator.domain.DO.ColumnDO; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | @Mapper 8 | public interface ColumnMapper extends BaseMapper { 9 | } 10 | -------------------------------------------------------------------------------- /vickze-generator/src/main/java/io/vickze/generator/mapper/ConfigMapper.java: -------------------------------------------------------------------------------- 1 | package io.vickze.generator.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import io.vickze.generator.domain.DO.ConfigDO; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | @Mapper 8 | public interface ConfigMapper extends BaseMapper { 9 | } 10 | -------------------------------------------------------------------------------- /vickze-generator/src/main/java/io/vickze/generator/mapper/TableMapper.java: -------------------------------------------------------------------------------- 1 | package io.vickze.generator.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import io.vickze.generator.domain.DO.TableDO; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | @Mapper 8 | public interface TableMapper extends BaseMapper { 9 | } 10 | -------------------------------------------------------------------------------- /vickze-generator/src/main/java/io/vickze/generator/domain/DTO/GeneratorCodeDTO.java: -------------------------------------------------------------------------------- 1 | package io.vickze.generator.domain.DTO; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.List; 6 | 7 | @Data 8 | public class GeneratorCodeDTO { 9 | 10 | private Long configId; 11 | 12 | private List templateIds; 13 | 14 | private List tableNames; 15 | } 16 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/domain/DTO/AssignMenuResourceDTO.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.domain.DTO; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.List; 6 | 7 | @Data 8 | public class AssignMenuResourceDTO { 9 | 10 | private Long roleId; 11 | 12 | private Long systemId; 13 | 14 | private List menuResourceIds; 15 | } 16 | -------------------------------------------------------------------------------- /vickze-generator/src/main/java/io/vickze/generator/domain/DTO/TemplateQueryDTO.java: -------------------------------------------------------------------------------- 1 | package io.vickze.generator.domain.DTO; 2 | 3 | import io.vickze.common.domain.DTO.QueryDTO; 4 | import lombok.Data; 5 | 6 | import java.util.List; 7 | 8 | @Data 9 | public class TemplateQueryDTO extends QueryDTO { 10 | 11 | private String name; 12 | 13 | private List type; 14 | } 15 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-common/src/main/java/io/vickze/auth/constant/TokenConstant.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.constant; 2 | 3 | /** 4 | * @author vick.zeng 5 | * @email zyk@yk95.top 6 | * @create 2019-05-10 15:31 7 | */ 8 | public class TokenConstant { 9 | 10 | public static final String TOKEN_HEADER = "Authorization"; 11 | 12 | private TokenConstant() { 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/service/CheckPermissionService.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.service; 2 | 3 | import io.vickze.auth.domain.DTO.CheckPermissionDTO; 4 | 5 | /** 6 | * @author vick.zeng 7 | * @email zyk@yk95.top 8 | * @create 2019-06-03 14:17 9 | */ 10 | public interface CheckPermissionService { 11 | 12 | void checkPermission(CheckPermissionDTO checkPermissionDTO); 13 | } 14 | -------------------------------------------------------------------------------- /vickze-generator/src/main/java/io/vickze/generator/constant/ConfigConstant.java: -------------------------------------------------------------------------------- 1 | package io.vickze.generator.constant; 2 | 3 | /** 4 | * @author vick.zeng 5 | * @email zyk@yk95.top 6 | * @create 2019-07-03 17:26 7 | */ 8 | public class ConfigConstant { 9 | 10 | public static final int PROPERTIES = 0; 11 | 12 | public static final int YAML = 1; 13 | 14 | 15 | private ConfigConstant() { 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /vickze-generator/src/main/java/io/vickze/generator/constant/TemplateConstant.java: -------------------------------------------------------------------------------- 1 | package io.vickze.generator.constant; 2 | 3 | /** 4 | * @author vick.zeng 5 | * @email zyk@yk95.top 6 | * @create 2019-07-03 17:26 7 | */ 8 | public class TemplateConstant { 9 | 10 | public static final Integer VELOCITY = 0; 11 | 12 | public static final Integer FREEMARKER = 1; 13 | 14 | private TemplateConstant() { 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/service/TokenService.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.service; 2 | 3 | import io.vickze.auth.domain.DTO.AuthUserDTO; 4 | import io.vickze.auth.domain.DTO.CreateTokenDTO; 5 | import io.vickze.auth.domain.DTO.TokenDTO; 6 | 7 | public interface TokenService { 8 | 9 | TokenDTO create(AuthUserDTO authUserDTO); 10 | 11 | AuthUserDTO validate(String token); 12 | 13 | void delete(String token); 14 | } 15 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/test/java/io/vickze/auth/UriTest.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth; 2 | 3 | import org.junit.Test; 4 | 5 | /** 6 | * @author vick.zeng 7 | * @email zyk@yk95.top 8 | * @create 2019-05-23 16:52 9 | */ 10 | public class UriTest { 11 | 12 | @Test 13 | public void test() { 14 | String uri = "/menu/tree/"; 15 | uri = uri.replaceAll("[a-zA-Z\\\\d\\/]+", ""); 16 | System.out.println(uri); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /vickze-common/src/main/java/io/vickze/common/domain/DTO/BusinessResultDTO.java: -------------------------------------------------------------------------------- 1 | package io.vickze.common.domain.DTO; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * 返回数据(用于处理Http状态码不能够表示的情况) 7 | * 8 | * @author vick.zeng 9 | */ 10 | @Data 11 | public class BusinessResultDTO { 12 | public static final String SUCCESS = "0"; 13 | /** 14 | * 业务状态码 15 | */ 16 | private String code; 17 | 18 | private String msg; 19 | 20 | private Object data; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /vickze-sso/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: vickze-sso 4 | main: 5 | allow-bean-definition-overriding: true 6 | # #使用alibaba nacos注册中心 7 | cloud: 8 | nacos: 9 | discovery: 10 | server-addr: ${NACOS_ADDR:127.0.0.1:8848} 11 | config: 12 | server-addr: ${NACOS_ADDR:127.0.0.1:8848} 13 | file-extension: yml 14 | profiles: 15 | active: dev 16 | 17 | server: 18 | port: 16003 -------------------------------------------------------------------------------- /vickze-gateway/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: vickze-gateway 4 | main: 5 | allow-bean-definition-overriding: true 6 | # #使用alibaba nacos注册中心 7 | cloud: 8 | nacos: 9 | discovery: 10 | server-addr: ${NACOS_ADDR:127.0.0.1:8848} 11 | config: 12 | server-addr: ${NACOS_ADDR:127.0.0.1:8848} 13 | file-extension: yml 14 | profiles: 15 | active: dev 16 | 17 | server: 18 | port: 16000 -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/domain/DTO/CurrentUserDTO.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.domain.DTO; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.Set; 6 | 7 | /** 8 | * @author vick.zeng 9 | * @email zyk@yk95.top 10 | * @create 2019-06-03 15:20 11 | */ 12 | @Data 13 | public class CurrentUserDTO { 14 | 15 | 16 | private Long userId; 17 | 18 | private String username; 19 | 20 | private Set permissions; 21 | } 22 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/enums/UserStatus.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.enums; 2 | 3 | import lombok.Getter; 4 | 5 | public enum UserStatus { 6 | 7 | ENABLED(1, "启用"), 8 | DISABLED(0,"禁用"); 9 | 10 | @Getter 11 | private Integer code; 12 | 13 | @Getter 14 | private String value; 15 | 16 | UserStatus(Integer code, String value) { 17 | this.code = code; 18 | this.value = value; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /vickze-generator/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: vickze-generator 4 | main: 5 | allow-bean-definition-overriding: true 6 | # #使用alibaba nacos注册中心 7 | cloud: 8 | nacos: 9 | discovery: 10 | server-addr: ${NACOS_ADDR:127.0.0.1:8848} 11 | config: 12 | server-addr: ${NACOS_ADDR:127.0.0.1:8848} 13 | file-extension: yml 14 | profiles: 15 | active: dev 16 | 17 | server: 18 | port: 16002 -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-common/src/main/java/io/vickze/auth/domain/DTO/CheckPermissionDTO.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.domain.DTO; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * @author vick.zeng 7 | * @email zyk@yk95.top 8 | * @create 2019-06-03 11:32 9 | */ 10 | @Data 11 | public class CheckPermissionDTO { 12 | 13 | private String requestUri; 14 | 15 | private String method; 16 | 17 | private String systemKey; 18 | 19 | private String token; 20 | 21 | } 22 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/mapper/MenuMapper.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import io.vickze.auth.domain.DO.MenuDO; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * 菜单 9 | * 10 | * @author vick.zeng 11 | * @email zyk@yk95.top 12 | * @create 2019-05-15 15:16:39 13 | */ 14 | @Mapper 15 | public interface MenuMapper extends BaseMapper { 16 | } 17 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/mapper/RoleMapper.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import io.vickze.auth.domain.DO.RoleDO; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * 角色 9 | * 10 | * @author vick.zeng 11 | * @email zyk@yk95.top 12 | * @create 2019-04-16 11:16:31 13 | */ 14 | @Mapper 15 | public interface RoleMapper extends BaseMapper { 16 | } 17 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/mapper/UserMapper.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import io.vickze.auth.domain.DO.UserDO; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * 用户 9 | * 10 | * @author vick.zeng 11 | * @email zyk@yk95.top 12 | * @create 2019-04-16 11:16:31 13 | */ 14 | @Mapper 15 | public interface UserMapper extends BaseMapper { 16 | } 17 | -------------------------------------------------------------------------------- /vickze-common/src/main/java/io/vickze/common/domain/Interface.java: -------------------------------------------------------------------------------- 1 | package io.vickze.common.domain; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | /** 8 | * @author vick.zeng 9 | * @email zyk@yk95.top 10 | * @create 2019-08-14 11:42 11 | */ 12 | @Data 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | public class Interface { 16 | 17 | private String method; 18 | 19 | private String uri; 20 | } 21 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: vickze-auth 4 | # #使用alibaba nacos注册中心 5 | main: 6 | allow-bean-definition-overriding: true 7 | cloud: 8 | nacos: 9 | discovery: 10 | server-addr: ${NACOS_ADDR:127.0.0.1:8848} 11 | config: 12 | server-addr: ${NACOS_ADDR:127.0.0.1:8848} 13 | file-extension: yml 14 | profiles: 15 | active: dev 16 | 17 | server: 18 | port: 16001 -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/mapper/SystemMapper.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import io.vickze.auth.domain.DO.SystemDO; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * 系统 9 | * 10 | * @author vick.zeng 11 | * @email zyk@yk95.top 12 | * @create 2019-05-14 11:24:11 13 | */ 14 | @Mapper 15 | public interface SystemMapper extends BaseMapper { 16 | } 17 | -------------------------------------------------------------------------------- /vickze-generator/src/main/java/io/vickze/generator/mapper/TemplateMapper.java: -------------------------------------------------------------------------------- 1 | package io.vickze.generator.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import io.vickze.generator.domain.DO.TemplateDO; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * 模版 9 | * 10 | * @author vick.zeng 11 | * @email zyk@yk95.top 12 | * @create 2019-03-29 16:24:22 13 | */ 14 | @Mapper 15 | public interface TemplateMapper extends BaseMapper { 16 | } 17 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/domain/DTO/MenuResourceQueryDTO.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.domain.DTO; 2 | 3 | import io.vickze.common.domain.DTO.QueryDTO; 4 | import lombok.Data; 5 | 6 | /** 7 | * 菜单资源 8 | * 9 | * @author vick.zeng 10 | * @email zyk@yk95.top 11 | * @create 2019-04-29 15:01:06 12 | */ 13 | @Data 14 | public class MenuResourceQueryDTO extends QueryDTO { 15 | 16 | /** 17 | * 菜单唯一标识 18 | */ 19 | private String menuId; 20 | 21 | } 22 | -------------------------------------------------------------------------------- /vickze-generator/src/main/java/io/vickze/generator/domain/DO/TableDO.java: -------------------------------------------------------------------------------- 1 | package io.vickze.generator.domain.DO; 2 | 3 | import com.baomidou.mybatisplus.annotation.TableName; 4 | import lombok.Data; 5 | import java.time.LocalDateTime; 6 | 7 | @TableName("information_schema.tables") 8 | @Data 9 | public class TableDO { 10 | 11 | private String tableName; 12 | 13 | private String tableComment; 14 | 15 | private String engine; 16 | 17 | private LocalDateTime createTime; 18 | } 19 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/mapper/UserRoleMapper.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import io.vickze.auth.domain.DO.UserRoleDO; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * 用户与角色对应关系 9 | * 10 | * @author vick.zeng 11 | * @email zyk@yk95.top 12 | * @create 2019-04-16 11:19:31 13 | */ 14 | @Mapper 15 | public interface UserRoleMapper extends BaseMapper { 16 | } 17 | -------------------------------------------------------------------------------- /vickze-generator/src/main/java/io/vickze/generator/domain/DTO/ConfigQueryDTO.java: -------------------------------------------------------------------------------- 1 | package io.vickze.generator.domain.DTO; 2 | 3 | import io.vickze.common.domain.DTO.QueryDTO; 4 | import lombok.Data; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * 配置 10 | * 11 | * @author vick.zeng 12 | * @email zyk@yk95.top 13 | * @create 2019-03-29 16:04:44 14 | */ 15 | @Data 16 | public class ConfigQueryDTO extends QueryDTO { 17 | 18 | private String name; 19 | 20 | private List type; 21 | } 22 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/mapper/MenuResourceMapper.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import io.vickze.auth.domain.DO.MenuResourceDO; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * 菜单资源 9 | * 10 | * @author vick.zeng 11 | * @email zyk@yk95.top 12 | * @create 2019-04-29 15:01:06 13 | */ 14 | @Mapper 15 | public interface MenuResourceMapper extends BaseMapper { 16 | } 17 | -------------------------------------------------------------------------------- /vickze-common/src/main/java/io/vickze/common/exception/BusinessException.java: -------------------------------------------------------------------------------- 1 | package io.vickze.common.exception; 2 | 3 | public class BusinessException extends RuntimeException { 4 | 5 | private String code; 6 | 7 | public BusinessException(String msg) { 8 | super(msg); 9 | } 10 | 11 | public BusinessException(String msg, String code) { 12 | super(msg); 13 | this.code = code; 14 | } 15 | 16 | public String getCode() { 17 | return code; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-client/src/main/java/io/vickze/auth/resovler/AuthUser.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.resovler; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * @author vick.zeng 10 | * @email zyk@yk95.top 11 | * @date 2017-12-12 15:08 12 | */ 13 | @Target(ElementType.PARAMETER) 14 | @Retention(RetentionPolicy.RUNTIME) 15 | public @interface AuthUser { 16 | } 17 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/domain/DTO/RoleQueryDTO.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.domain.DTO; 2 | 3 | import io.vickze.common.domain.DTO.QueryDTO; 4 | import lombok.Data; 5 | 6 | /** 7 | * 角色 8 | * 9 | * @author vick.zeng 10 | * @email zyk@yk95.top 11 | * @create 2019-04-16 11:15:36 12 | */ 13 | @Data 14 | public class RoleQueryDTO extends QueryDTO { 15 | 16 | /** 17 | * 角色名称 18 | */ 19 | private String name; 20 | /** 21 | * 备注 22 | */ 23 | private String remark; 24 | } 25 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/domain/DTO/SystemQueryDTO.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.domain.DTO; 2 | 3 | import io.vickze.common.domain.DTO.QueryDTO; 4 | import lombok.Data; 5 | 6 | /** 7 | * 系统 8 | * 9 | * @author vick.zeng 10 | * @email zyk@yk95.top 11 | * @create 2019-05-15 14:49:10 12 | */ 13 | @Data 14 | public class SystemQueryDTO extends QueryDTO { 15 | 16 | /** 17 | * 名称 18 | */ 19 | private String name; 20 | /** 21 | * Key 22 | */ 23 | private String key; 24 | } 25 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/domain/DTO/MenuTreeDTO.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.domain.DTO; 2 | 3 | 4 | import lombok.Data; 5 | 6 | import java.util.List; 7 | 8 | @Data 9 | public class MenuTreeDTO { 10 | 11 | /** 12 | * 13 | */ 14 | private Long id; 15 | /** 16 | * 子菜单列表 17 | */ 18 | private List children; 19 | /** 20 | * 菜单名称 21 | */ 22 | private String name; 23 | /** 24 | * 菜单图标 25 | */ 26 | private String icon; 27 | 28 | } 29 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/mapper/MenuResourceInterfaceMapper.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import io.vickze.auth.domain.DO.MenuResourceInterfaceDO; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * 菜单资源与接口对应关系 9 | * 10 | * @author vick.zeng 11 | * @email zyk@yk95.top 12 | * @create 2019-05-16 11:09:46 13 | */ 14 | @Mapper 15 | public interface MenuResourceInterfaceMapper extends BaseMapper { 16 | } 17 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/properties/JwtProperties.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.properties; 2 | 3 | import lombok.Data; 4 | import org.springframework.boot.context.properties.ConfigurationProperties; 5 | import org.springframework.cloud.context.config.annotation.RefreshScope; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Data 9 | @Component 10 | @RefreshScope 11 | @ConfigurationProperties("token.jwt") 12 | public class JwtProperties { 13 | 14 | private String secret; 15 | 16 | private long expire; 17 | } 18 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/properties/UUIDTokenProperties.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.properties; 2 | 3 | import lombok.Data; 4 | import org.springframework.boot.context.properties.ConfigurationProperties; 5 | import org.springframework.cloud.context.config.annotation.RefreshScope; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Data 9 | @Component 10 | @RefreshScope 11 | @ConfigurationProperties("token.uuid") 12 | public class UUIDTokenProperties { 13 | 14 | private long expire; 15 | 16 | private boolean updateExpire; 17 | } 18 | -------------------------------------------------------------------------------- /vickze-generator/src/main/java/io/vickze/generator/domain/DO/ColumnDO.java: -------------------------------------------------------------------------------- 1 | package io.vickze.generator.domain.DO; 2 | 3 | import com.baomidou.mybatisplus.annotation.TableName; 4 | import lombok.Data; 5 | 6 | @TableName("information_schema.columns") 7 | @Data 8 | public class ColumnDO { 9 | 10 | private String columnName; 11 | 12 | private String dataType; 13 | 14 | private String characterMaximumLength; 15 | 16 | private String columnComment; 17 | 18 | private String columnKey; 19 | 20 | private String extra; 21 | 22 | private String isNullable; 23 | } 24 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/domain/DTO/MenuQueryDTO.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.domain.DTO; 2 | 3 | import io.vickze.common.domain.DTO.QueryDTO; 4 | import lombok.Data; 5 | 6 | /** 7 | * 菜单 8 | * 9 | * @author vick.zeng 10 | * @email zyk@yk95.top 11 | * @create 2019-05-15 15:16:39 12 | */ 13 | @Data 14 | public class MenuQueryDTO extends QueryDTO { 15 | 16 | /** 17 | * 系统ID 18 | */ 19 | private Long systemId; 20 | /** 21 | * 父ID 22 | */ 23 | private Long parentId; 24 | /** 25 | * 名称 26 | */ 27 | private String name; 28 | } 29 | -------------------------------------------------------------------------------- /vickze-generator/src/main/java/io/vickze/generator/domain/DTO/TableDTO.java: -------------------------------------------------------------------------------- 1 | package io.vickze.generator.domain.DTO; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.List; 6 | 7 | @Data 8 | public class TableDTO { 9 | //表的名称 10 | private String name; 11 | //表的备注 12 | private String comments; 13 | //表的主键 14 | private ColumnDTO pk; 15 | //表的列名(不包含主键) 16 | private List columns; 17 | 18 | //类名(第一个字母大写),如:sys_user => SysUser 大写驼峰 19 | private String classNameUpperCamel; 20 | //类名(第一个字母小写),如:sys_user => sysUser 小写驼峰 21 | private String classNameLowerCamel; 22 | } 23 | -------------------------------------------------------------------------------- /vickze-generator/src/main/java/io/vickze/generator/repository/ConfigRepository.java: -------------------------------------------------------------------------------- 1 | package io.vickze.generator.repository; 2 | 3 | import io.vickze.generator.domain.DO.ConfigDO; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; 6 | import org.springframework.stereotype.Repository; 7 | 8 | /** 9 | * 配置 10 | * 11 | * @author vick.zeng 12 | * @email zyk@yk95.top 13 | * @create 2019-03-29 16:04:44 14 | */ 15 | @Repository 16 | public interface ConfigRepository extends JpaRepository, 17 | JpaSpecificationExecutor { 18 | } 19 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/mapper/RoleMenuResourceMapper.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import io.vickze.auth.domain.DO.MenuResourceDO; 5 | import io.vickze.auth.domain.DO.RoleMenuResourceDO; 6 | import org.apache.ibatis.annotations.Mapper; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * 角色与菜单资源对应关系 12 | * 13 | * @author vick.zeng 14 | * @email zyk@yk95.top 15 | * @create 2019-04-30 15:32:48 16 | */ 17 | @Mapper 18 | public interface RoleMenuResourceMapper extends BaseMapper { 19 | List getPermissionByRoleId(Long id); 20 | } 21 | -------------------------------------------------------------------------------- /vickze-sso/src/main/java/io/vickze/sso/properties/SsoProperties.java: -------------------------------------------------------------------------------- 1 | package io.vickze.sso.properties; 2 | 3 | import lombok.Data; 4 | import org.springframework.boot.context.properties.ConfigurationProperties; 5 | import org.springframework.cloud.context.config.annotation.RefreshScope; 6 | import org.springframework.stereotype.Component; 7 | 8 | import java.util.List; 9 | import java.util.Map; 10 | 11 | /** 12 | * @author vick.zeng 13 | * @email zyk@yk95.top 14 | * @create 2019-07-11 11:16 15 | */ 16 | @Data 17 | @Component 18 | @RefreshScope 19 | @ConfigurationProperties("sso") 20 | public class SsoProperties { 21 | 22 | private Map> system; 23 | } 24 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-client/src/main/java/io/vickze/auth/client/fallback/TokenClientFallback.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.client.fallback; 2 | 3 | import io.vickze.auth.client.TokenClient; 4 | import io.vickze.auth.domain.DTO.AuthUserDTO; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.stereotype.Service; 7 | 8 | /** 9 | * @author vick.zeng 10 | * @email zyk@yk95.top 11 | * @create 2019-05-10 15:34 12 | */ 13 | @Slf4j 14 | @Service 15 | public class TokenClientFallback implements TokenClient { 16 | @Override 17 | public AuthUserDTO validate(String token) { 18 | log.error("TokenClient validate fallback."); 19 | return null; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /vickze-gateway/src/main/java/io/vickze/gateway/resolver/IpAddressKeyResolver.java: -------------------------------------------------------------------------------- 1 | package io.vickze.gateway.resolver; 2 | 3 | import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver; 4 | import org.springframework.stereotype.Component; 5 | import org.springframework.web.server.ServerWebExchange; 6 | import reactor.core.publisher.Mono; 7 | 8 | /** 9 | * @author vick.zeng 10 | * date-time: 2018/11/19 15:02 11 | **/ 12 | @Component 13 | public class IpAddressKeyResolver implements KeyResolver { 14 | 15 | @Override 16 | public Mono resolve(ServerWebExchange exchange) { 17 | return Mono.just(exchange.getRequest().getRemoteAddress().getAddress().getHostAddress()); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /vickze-generator/src/main/java/io/vickze/generator/service/ConfigService.java: -------------------------------------------------------------------------------- 1 | package io.vickze.generator.service; 2 | 3 | import io.vickze.generator.domain.DO.ConfigDO; 4 | import io.vickze.generator.domain.DTO.ConfigQueryDTO; 5 | import org.apache.commons.lang3.tuple.Pair; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * 配置 11 | * 12 | * @author vick.zeng 13 | * @email zyk@yk95.top 14 | * @create 2019-03-29 16:04:44 15 | */ 16 | public interface ConfigService { 17 | 18 | Pair, Long> list(ConfigQueryDTO queryDTO); 19 | 20 | ConfigDO get(Long id); 21 | 22 | void insert(ConfigDO configDO); 23 | 24 | void update(ConfigDO configDO); 25 | 26 | void delete(Long... ids); 27 | } 28 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/domain/DTO/UserQueryDTO.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.domain.DTO; 2 | 3 | import io.vickze.common.domain.DTO.QueryDTO; 4 | import lombok.Data; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * 用户 10 | * 11 | * @author vick.zeng 12 | * @email zyk@yk95.top 13 | * @create 2019-04-16 11:15:36 14 | */ 15 | @Data 16 | public class UserQueryDTO extends QueryDTO { 17 | 18 | /** 19 | * 用户名 20 | */ 21 | private String username; 22 | /** 23 | * 邮箱 24 | */ 25 | private String email; 26 | /** 27 | * 手机号 28 | */ 29 | private String mobile; 30 | /** 31 | * 状态 0:禁用 1:正常 32 | */ 33 | private List status; 34 | } 35 | -------------------------------------------------------------------------------- /vickze-generator/src/main/java/io/vickze/generator/domain/DTO/ColumnDTO.java: -------------------------------------------------------------------------------- 1 | package io.vickze.generator.domain.DTO; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class ColumnDTO { 7 | //列名 8 | private String name; 9 | //列名类型 10 | private String dataType; 11 | // 12 | private String characterMaximumLength; 13 | //列名备注 14 | private String comment; 15 | 16 | //属性名称(第一个字母大写),如:user_name => UserName 大写驼峰 17 | private String attrNameUpperCamel; 18 | //属性名称(第一个字母小写),如:user_name => userName 小写驼峰 19 | private String attrNameLowerCamel; 20 | //属性类型 21 | private String attrType; 22 | //auto_increment 23 | private String extra; 24 | 25 | private String isNullable; 26 | } 27 | -------------------------------------------------------------------------------- /vickze-generator/src/main/java/io/vickze/generator/service/GeneratorService.java: -------------------------------------------------------------------------------- 1 | package io.vickze.generator.service; 2 | 3 | import io.vickze.generator.domain.DO.TableDO; 4 | import io.vickze.generator.domain.DTO.GeneratorCodeDTO; 5 | import io.vickze.generator.domain.DTO.GeneratorQueryDTO; 6 | import org.apache.commons.lang3.tuple.Pair; 7 | import org.apache.commons.configuration.ConfigurationException; 8 | 9 | import java.io.IOException; 10 | import java.util.List; 11 | 12 | public interface GeneratorService { 13 | 14 | Pair, Long> tableList(GeneratorQueryDTO queryDTO); 15 | 16 | /** 17 | * 生成代码 18 | * @param generatorCode 19 | */ 20 | byte[] generatorCode(GeneratorCodeDTO generatorCode); 21 | } 22 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/service/SystemService.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.service; 2 | 3 | import io.vickze.auth.domain.DO.SystemDO; 4 | import io.vickze.auth.domain.DTO.SystemQueryDTO; 5 | import org.apache.commons.lang3.tuple.Pair; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * 系统 11 | * 12 | * @author vick.zeng 13 | * @email zyk@yk95.top 14 | * @create 2019-05-14 11:24:11 15 | */ 16 | public interface SystemService { 17 | 18 | Pair, Long> list(SystemQueryDTO queryDTO); 19 | 20 | SystemDO get(Long id); 21 | 22 | void insert(SystemDO systemDO); 23 | 24 | void update(SystemDO systemDO); 25 | 26 | void delete(Long... ids); 27 | 28 | SystemDO selectByKey(String systemKey); 29 | } 30 | -------------------------------------------------------------------------------- /vickze-auth/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | vickze-cloud-admin 7 | io.vickze 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | vickze-auth 13 | pom 14 | 15 | vickze-auth-common 16 | vickze-auth-client 17 | vickze-auth-server 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/AuthApplication.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | import org.springframework.cloud.openfeign.EnableFeignClients; 7 | import org.springframework.context.annotation.ComponentScan; 8 | 9 | @EnableDiscoveryClient 10 | @SpringBootApplication 11 | @ComponentScan("io.vickze") 12 | @EnableFeignClients({"io.vickze.auth.client", "io.vickze.auth.client.fallback"}) 13 | public class AuthApplication { 14 | 15 | public static void main(String[] args) { 16 | SpringApplication.run(AuthApplication.class, args); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/service/MenuService.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.service; 2 | 3 | import io.vickze.auth.domain.DO.MenuDO; 4 | import io.vickze.auth.domain.DTO.MenuQueryDTO; 5 | import io.vickze.auth.domain.DTO.MenuTreeDTO; 6 | import org.apache.commons.lang3.tuple.Pair; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * 菜单 12 | * 13 | * @author vick.zeng 14 | * @email zyk@yk95.top 15 | * @create 2019-05-15 15:16:39 16 | */ 17 | public interface MenuService { 18 | 19 | List tree(Long systemId); 20 | 21 | Pair, Long> list(MenuQueryDTO queryDTO); 22 | 23 | MenuDO get(Long id); 24 | 25 | void insert(MenuDO menuDO); 26 | 27 | void update(MenuDO menuDO); 28 | 29 | void delete(Long... ids); 30 | } 31 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-client/src/main/java/io/vickze/auth/client/CheckPermissionClient.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.client; 2 | 3 | import io.vickze.auth.client.fallback.CheckPermissionClientFallback; 4 | import io.vickze.auth.domain.DTO.CheckPermissionDTO; 5 | import org.springframework.cloud.openfeign.FeignClient; 6 | import org.springframework.web.bind.annotation.PostMapping; 7 | import org.springframework.web.bind.annotation.RequestBody; 8 | 9 | /** 10 | * @author vick.zeng 11 | * @email zyk@yk95.top 12 | * @create 2019-06-03 14:56 13 | */ 14 | @FeignClient(value = "vickze-auth", fallback = CheckPermissionClientFallback.class) 15 | public interface CheckPermissionClient { 16 | 17 | @PostMapping("/checkPermission") 18 | void checkPermission(@RequestBody CheckPermissionDTO checkPermissionDTO); 19 | } 20 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-client/src/main/java/io/vickze/auth/client/fallback/UserClientFallback.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.client.fallback; 2 | 3 | import io.vickze.auth.client.UserClient; 4 | import io.vickze.common.exception.ClientException; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.stereotype.Service; 7 | 8 | /** 9 | * @author vick.zeng 10 | * @email zyk@yk95.top 11 | * @create 2019-05-09 17:46 12 | */ 13 | @Slf4j 14 | @Service 15 | public class UserClientFallback implements UserClient { 16 | 17 | @Override 18 | public void checkSystemAccess(String systemKey, Long userId) { 19 | log.error("UserClient checkSystemAccess fallback."); 20 | //抛出异常使fallback失败 21 | throw new ClientException("UserClient checkSystemAccess fallback fail."); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /example/nacos/custom.properties: -------------------------------------------------------------------------------- 1 | #spring.security.enabled=false 2 | #management.security=false 3 | #security.basic.enabled=false 4 | #nacos.security.ignore.urls=/** 5 | #management.metrics.export.elastic.host=http://localhost:9200 6 | # metrics for prometheus 7 | management.endpoints.web.exposure.include=* 8 | 9 | # metrics for elastic search 10 | #management.metrics.export.elastic.enabled=false 11 | #management.metrics.export.elastic.host=http://localhost:9200 12 | 13 | # metrics for influx 14 | #management.metrics.export.influx.enabled=false 15 | #management.metrics.export.influx.db=springboot 16 | #management.metrics.export.influx.uri=http://localhost:8086 17 | #management.metrics.export.influx.auto-create-db=true 18 | #management.metrics.export.influx.consistency=one 19 | #management.metrics.export.influx.compressed=true -------------------------------------------------------------------------------- /vickze-common/src/main/java/io/vickze/common/exception/ClientException.java: -------------------------------------------------------------------------------- 1 | package io.vickze.common.exception; 2 | 3 | import com.netflix.hystrix.exception.HystrixBadRequestException; 4 | import lombok.Data; 5 | import lombok.Getter; 6 | 7 | /** 8 | * @author vick.zeng 9 | * @email zyk@yk95.top 10 | * @create 2019-06-04 14:43 11 | */ 12 | public class ClientException extends HystrixBadRequestException { 13 | 14 | @Getter 15 | private boolean serializeExceptionClass; 16 | 17 | public ClientException(String message) { 18 | super(message); 19 | this.serializeExceptionClass = true; 20 | } 21 | 22 | public ClientException(String message, boolean serializeExceptionClass) { 23 | super(message); 24 | this.serializeExceptionClass = serializeExceptionClass; 25 | } 26 | } 27 | 28 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-common/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | vickze-auth 7 | io.vickze 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | vickze-auth-common 13 | 14 | 15 | 16 | public 17 | aliyun nexus 18 | http://maven.aliyun.com/nexus/content/groups/public/ 19 | 20 | 21 | -------------------------------------------------------------------------------- /vickze-generator/src/main/java/io/vickze/generator/service/TemplateService.java: -------------------------------------------------------------------------------- 1 | package io.vickze.generator.service; 2 | 3 | import io.vickze.generator.domain.DO.TemplateDO; 4 | import io.vickze.generator.domain.DTO.TemplateQueryDTO; 5 | import org.apache.commons.lang3.tuple.Pair; 6 | 7 | import java.util.Collection; 8 | import java.util.List; 9 | 10 | /** 11 | * 模版 12 | * 13 | * @author vick.zeng 14 | * @email zyk@yk95.top 15 | * @create 2019-03-29 16:24:22 16 | */ 17 | public interface TemplateService { 18 | 19 | Pair, Long> list(TemplateQueryDTO queryDTO); 20 | 21 | TemplateDO get(Long id); 22 | 23 | void insert(TemplateDO templateDO); 24 | 25 | void update(TemplateDO templateDO); 26 | 27 | void delete(Long... ids); 28 | 29 | Collection listByIds(List templateIds); 30 | } 31 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-client/src/main/java/io/vickze/auth/exception/UnauthorizedException.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.exception; 2 | 3 | import io.vickze.auth.constant.GlobalConstant; 4 | import io.vickze.common.exception.ClientException; 5 | 6 | public class UnauthorizedException extends ClientException { 7 | 8 | public UnauthorizedException() { 9 | super(GlobalConstant.UNAUTHORIZED_CODE); 10 | } 11 | 12 | public UnauthorizedException(boolean serializeExceptionClass) { 13 | super(GlobalConstant.UNAUTHORIZED_CODE, serializeExceptionClass); 14 | } 15 | 16 | public UnauthorizedException(String message) { 17 | super(message); 18 | } 19 | 20 | 21 | public UnauthorizedException(String message, boolean serializeExceptionClass) { 22 | super(message, serializeExceptionClass); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /vickze-sso/src/main/java/io/vickze/sso/SsoApplication.java: -------------------------------------------------------------------------------- 1 | package io.vickze.sso; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | import org.springframework.cloud.openfeign.EnableFeignClients; 7 | import org.springframework.context.annotation.ComponentScan; 8 | 9 | /** 10 | * @author vick.zeng 11 | * @email zyk@yk95.top 12 | * @create 2019-07-11 11:15 13 | */ 14 | @EnableDiscoveryClient 15 | @ComponentScan(basePackages = "io.vickze") 16 | @SpringBootApplication 17 | @EnableFeignClients({"io.vickze.auth.client", "io.vickze.auth.client.fallback"}) 18 | public class SsoApplication { 19 | 20 | public static void main(String[] args) { 21 | SpringApplication.run(SsoApplication.class, args); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /vickze-common/src/main/java/io/vickze/common/serializer/BirthdaySerializer.java: -------------------------------------------------------------------------------- 1 | package io.vickze.common.serializer; 2 | 3 | import com.fasterxml.jackson.core.JsonGenerator; 4 | import com.fasterxml.jackson.databind.JsonSerializer; 5 | import com.fasterxml.jackson.databind.SerializerProvider; 6 | 7 | import java.io.IOException; 8 | import java.text.SimpleDateFormat; 9 | import java.util.Date; 10 | import java.util.Locale; 11 | 12 | public class BirthdaySerializer extends JsonSerializer { 13 | @Override 14 | public void serialize(Date d, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException { 15 | if (d == null) { 16 | jsonGenerator.writeNull(); 17 | } 18 | SimpleDateFormat dateFormat = new SimpleDateFormat("d MMM ****", Locale.ENGLISH); 19 | jsonGenerator.writeString(dateFormat.format(d)); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-client/src/main/java/io/vickze/auth/exception/ForbiddenException.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.exception; 2 | 3 | import io.vickze.auth.constant.GlobalConstant; 4 | import io.vickze.common.exception.ClientException; 5 | import lombok.Data; 6 | import lombok.Getter; 7 | 8 | import java.io.Serializable; 9 | 10 | public class ForbiddenException extends ClientException { 11 | 12 | public ForbiddenException() { 13 | super(GlobalConstant.FORBIDDEN_CODE); 14 | } 15 | 16 | public ForbiddenException(boolean serializeExceptionClass) { 17 | super(GlobalConstant.FORBIDDEN_CODE, serializeExceptionClass); 18 | } 19 | 20 | public ForbiddenException(String message) { 21 | super(message); 22 | } 23 | 24 | public ForbiddenException(String message, boolean serializeExceptionClass) { 25 | super(message, serializeExceptionClass); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/controller/CheckPermissionController.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.controller; 2 | 3 | import io.vickze.auth.client.CheckPermissionClient; 4 | import io.vickze.auth.domain.DTO.CheckPermissionDTO; 5 | import io.vickze.auth.service.CheckPermissionService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | /** 10 | * @author vick.zeng 11 | * @email zyk@yk95.top 12 | * @create 2019-06-03 14:55 13 | */ 14 | @RestController 15 | public class CheckPermissionController implements CheckPermissionClient { 16 | @Autowired 17 | private CheckPermissionService checkPermissionService; 18 | 19 | @Override 20 | public void checkPermission(CheckPermissionDTO checkPermissionDTO) { 21 | checkPermissionService.checkPermission(checkPermissionDTO); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /vickze-gateway/src/main/java/io/vickze/gateway/properties/AccessForbiddenProperties.java: -------------------------------------------------------------------------------- 1 | package io.vickze.gateway.properties; 2 | 3 | import io.vickze.common.domain.Interface; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | import org.springframework.boot.context.properties.ConfigurationProperties; 8 | import org.springframework.cloud.context.config.annotation.RefreshScope; 9 | import org.springframework.stereotype.Component; 10 | 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | 14 | /** 15 | * @author vick.zeng 16 | * @email zyk@yk95.top 17 | * @create 2019-08-14 11:42 18 | */ 19 | @Data 20 | @RefreshScope 21 | @ConfigurationProperties(value = "access", ignoreUnknownFields = false) 22 | @Component 23 | public class AccessForbiddenProperties { 24 | 25 | private List forbiddenInterfaces = new ArrayList<>(); 26 | 27 | } 28 | 29 | -------------------------------------------------------------------------------- /vickze-common/src/main/java/io/vickze/common/serializer/ZeroBigDecimalSerializer.java: -------------------------------------------------------------------------------- 1 | package io.vickze.common.serializer; 2 | 3 | import com.fasterxml.jackson.core.JsonGenerator; 4 | import com.fasterxml.jackson.databind.JsonSerializer; 5 | import com.fasterxml.jackson.databind.SerializerProvider; 6 | 7 | import java.io.IOException; 8 | import java.math.BigDecimal; 9 | import java.math.RoundingMode; 10 | 11 | /** 12 | * 四舍五入不保留小数点 13 | * 14 | * @author vick.zeng 15 | * date-time: 2018/10/22 14:19 16 | **/ 17 | public class ZeroBigDecimalSerializer extends JsonSerializer { 18 | @Override 19 | public void serialize(BigDecimal value, JsonGenerator gen, SerializerProvider serializers) throws IOException { 20 | if (value == null) { 21 | gen.writeNull(); 22 | return; 23 | } 24 | gen.writeNumber(value.setScale(0, RoundingMode.HALF_UP)); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-common/src/main/java/io/vickze/auth/constant/GlobalConstant.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.constant; 2 | 3 | /** 4 | * @author vick.zeng 5 | * @email zyk@yk95.top 6 | * @create 2019-05-24 10:38 7 | */ 8 | public class GlobalConstant { 9 | 10 | public static final String SYSTEM_HEADER = "System-Key"; 11 | 12 | public static final String UNAUTHORIZED_CODE = "app.response.status.401"; 13 | 14 | public static final String FORBIDDEN_CODE = "app.response.status.403"; 15 | 16 | public static final String SYSTEM_NOT_RESOURCE_CODE = "app.system.notResource"; 17 | 18 | public static final String USER_NOT_EXIST_CODE = "app.user.notExist"; 19 | 20 | public static final String USER_PASSWORD_ERROR_CODE = "app.user.password.error"; 21 | 22 | public static final String USER_DISABLED_CODE = "app.user.disabled"; 23 | 24 | 25 | 26 | private GlobalConstant() { 27 | 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-client/src/main/java/io/vickze/auth/client/fallback/CheckPermissionClientFallback.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.client.fallback; 2 | 3 | import io.vickze.auth.client.CheckPermissionClient; 4 | import io.vickze.auth.domain.DTO.CheckPermissionDTO; 5 | import io.vickze.common.exception.ClientException; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | * @author vick.zeng 11 | * @email zyk@yk95.top 12 | * @create 2019-06-03 14:56 13 | */ 14 | @Slf4j 15 | @Service 16 | public class CheckPermissionClientFallback implements CheckPermissionClient { 17 | @Override 18 | public void checkPermission(CheckPermissionDTO checkPermissionDTO) { 19 | log.error("CheckPermissionClientFallback checkPermission fallback."); 20 | //抛出异常使fallback失败 21 | throw new ClientException("CheckPermissionClient checkPermission fallback fail."); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-client/src/main/java/io/vickze/auth/client/TokenClient.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.client; 2 | 3 | import io.vickze.auth.client.fallback.TokenClientFallback; 4 | import io.vickze.auth.constant.GlobalConstant; 5 | import io.vickze.auth.constant.TokenConstant; 6 | import io.vickze.auth.domain.DTO.AuthUserDTO; 7 | import org.springframework.cloud.openfeign.FeignClient; 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.RequestHeader; 10 | import org.springframework.web.bind.annotation.RequestParam; 11 | 12 | /** 13 | * @author vick.zeng 14 | * @email zyk@yk95.top 15 | * @create 2019-05-10 15:02 16 | */ 17 | @FeignClient(value = "vickze-auth", path="/token", fallback = TokenClientFallback.class) 18 | public interface TokenClient { 19 | 20 | @GetMapping("/validate") 21 | AuthUserDTO validate(@RequestHeader(TokenConstant.TOKEN_HEADER) String token); 22 | } 23 | -------------------------------------------------------------------------------- /vickze-common/src/main/java/io/vickze/common/serializer/ZeroCeilingBigDecimalSerializer.java: -------------------------------------------------------------------------------- 1 | package io.vickze.common.serializer; 2 | 3 | import com.fasterxml.jackson.core.JsonGenerator; 4 | import com.fasterxml.jackson.databind.JsonSerializer; 5 | import com.fasterxml.jackson.databind.SerializerProvider; 6 | 7 | import java.io.IOException; 8 | import java.math.BigDecimal; 9 | import java.math.RoundingMode; 10 | 11 | /** 12 | * 向上取整不保留小数点 13 | * 14 | * @author vick.zeng 15 | * date-time: 2018/10/22 14:19 16 | **/ 17 | public class ZeroCeilingBigDecimalSerializer extends JsonSerializer { 18 | @Override 19 | public void serialize(BigDecimal value, JsonGenerator gen, SerializerProvider serializers) throws IOException { 20 | if (value == null) { 21 | gen.writeNull(); 22 | return; 23 | } 24 | gen.writeString(value.setScale(0, RoundingMode.CEILING).toString()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-client/src/main/java/io/vickze/auth/client/UserClient.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.client; 2 | 3 | import io.vickze.auth.client.fallback.UserClientFallback; 4 | import io.vickze.auth.domain.DTO.CheckPermissionDTO; 5 | import org.springframework.cloud.openfeign.FeignClient; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.PathVariable; 8 | import org.springframework.web.bind.annotation.RequestBody; 9 | import org.springframework.web.bind.annotation.RequestParam; 10 | 11 | import java.util.Set; 12 | 13 | /** 14 | * @author vick.zeng 15 | * @email zyk@yk95.top 16 | * @create 2019-05-09 17:39 17 | */ 18 | @FeignClient(value = "vickze-auth", path="/user", fallback = UserClientFallback.class) 19 | public interface UserClient { 20 | 21 | @GetMapping("/systemAccess") 22 | void checkSystemAccess(@RequestParam String systemKey, @RequestParam Long userId); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-client/src/main/java/io/vickze/auth/properties/FeignOkhttpProperties.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.properties; 2 | 3 | import lombok.Data; 4 | import org.springframework.boot.context.properties.ConfigurationProperties; 5 | import org.springframework.cloud.context.config.annotation.RefreshScope; 6 | 7 | import java.util.concurrent.TimeUnit; 8 | 9 | /** 10 | * @author vick.zeng 11 | * @email zyk@yk95.top 12 | * @create 2019-06-05 15:01 13 | */ 14 | @Data 15 | @RefreshScope 16 | @ConfigurationProperties("feign.okhttp") 17 | public class FeignOkhttpProperties { 18 | 19 | 20 | private int readTimeout = 10000; 21 | private int writeTimeout = 10000; 22 | private int connectionTimeout = 2000; 23 | private int maxConnections = 200; 24 | private long timeToLive = 900L; 25 | private TimeUnit timeToLiveUnit = TimeUnit.SECONDS; 26 | private boolean followRedirects = true; 27 | private boolean retryOnConnectionFailure = true; 28 | 29 | } 30 | -------------------------------------------------------------------------------- /vickze-common/src/main/java/io/vickze/common/serializer/TwoBigDecimalSerializer.java: -------------------------------------------------------------------------------- 1 | package io.vickze.common.serializer; 2 | 3 | import com.fasterxml.jackson.core.JsonGenerator; 4 | import com.fasterxml.jackson.databind.JsonSerializer; 5 | import com.fasterxml.jackson.databind.SerializerProvider; 6 | 7 | import java.io.IOException; 8 | import java.math.BigDecimal; 9 | import java.math.RoundingMode; 10 | 11 | /** 12 | * @author vick.zeng 13 | * date-time: 2018/10/22 14:19 14 | **/ 15 | public class TwoBigDecimalSerializer extends JsonSerializer { 16 | @Override 17 | public void serialize(BigDecimal value, JsonGenerator gen, SerializerProvider serializers) throws IOException { 18 | if (value == null) { 19 | gen.writeNull(); 20 | return; 21 | } 22 | //使用writeNumber,小数点为.00序列化到前端会被清除,可以用spring注入的ObjectMapper writeString又存在,目前暂不清楚是哪里出了问题 23 | gen.writeNumber(value.setScale(2, RoundingMode.HALF_UP)); 24 | } 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /vickze-generator/src/main/java/io/vickze/generator/config/WebMvcConfiguration.java: -------------------------------------------------------------------------------- 1 | package io.vickze.generator.config; 2 | 3 | import io.vickze.auth.resovler.AuthUserHandlerMethodArgumentResolver; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.web.method.support.HandlerMethodArgumentResolver; 7 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @author vick.zeng 13 | * @email zyk@yk95.top 14 | * @date 2017-12-12 15:24 15 | */ 16 | @Configuration 17 | public class WebMvcConfiguration implements WebMvcConfigurer { 18 | @Autowired 19 | private AuthUserHandlerMethodArgumentResolver authUserHandlerMethodArgumentResolver; 20 | 21 | 22 | @Override 23 | public void addArgumentResolvers(List argumentResolvers) { 24 | argumentResolvers.add(authUserHandlerMethodArgumentResolver); 25 | } 26 | } -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/config/WebMvcConfiguration.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.config; 2 | 3 | import io.vickze.auth.resovler.AuthUserHandlerMethodArgumentResolver; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.web.method.support.HandlerMethodArgumentResolver; 7 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @author vick.zeng 13 | * @email zyk@yk95.top 14 | * @date 2017-12-12 15:24 15 | */ 16 | @Configuration 17 | public class WebMvcConfiguration implements WebMvcConfigurer { 18 | @Autowired 19 | private AuthUserHandlerMethodArgumentResolver authUserHandlerMethodArgumentResolver; 20 | 21 | 22 | @Override 23 | public void addArgumentResolvers(List argumentResolvers) { 24 | argumentResolvers.add(authUserHandlerMethodArgumentResolver); 25 | } 26 | } -------------------------------------------------------------------------------- /vickze-generator/src/main/java/io/vickze/generator/GeneratorApplication.java: -------------------------------------------------------------------------------- 1 | package io.vickze.generator; 2 | 3 | import io.vickze.auth.exception.AuthExceptionHandler; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 7 | import org.springframework.cloud.openfeign.EnableFeignClients; 8 | import org.springframework.context.annotation.ComponentScan; 9 | import org.springframework.context.annotation.FilterType; 10 | import org.springframework.data.jpa.repository.config.EnableJpaAuditing; 11 | 12 | @EnableJpaAuditing 13 | @EnableDiscoveryClient 14 | @SpringBootApplication 15 | @ComponentScan(basePackages = "io.vickze") 16 | @EnableFeignClients({"io.vickze.auth.client", "io.vickze.auth.client.fallback"}) 17 | public class GeneratorApplication { 18 | 19 | public static void main(String[] args) { 20 | SpringApplication.run(GeneratorApplication.class, args); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/service/UserService.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.service; 2 | 3 | import io.vickze.auth.domain.DO.UserDO; 4 | import io.vickze.auth.domain.DTO.*; 5 | import org.apache.commons.lang3.tuple.Pair; 6 | 7 | import java.util.List; 8 | import java.util.Set; 9 | 10 | /** 11 | * 用户 12 | * 13 | * @author vick.zeng 14 | * @email zyk@yk95.top 15 | * @create 2019-04-16 11:16:31 16 | */ 17 | public interface UserService { 18 | 19 | Pair, Long> list(UserQueryDTO queryDTO); 20 | 21 | UserDTO get(Long id); 22 | 23 | void insert(UserDTO userDTO); 24 | 25 | void update(UserDTO userDTO); 26 | 27 | void delete(Long... ids); 28 | 29 | TokenDTO createToken(CreateTokenDTO createTokenDTO); 30 | 31 | UserDO getByUsername(String username); 32 | 33 | Set getMenuPermissions(String systemKey, Long userId); 34 | 35 | Set getMenuPermissions(Long systemId, Long userId); 36 | 37 | void checkSystemAccess(String systemKey, Long userId); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /vickze-common/src/main/java/io/vickze/common/util/SQLUtil.java: -------------------------------------------------------------------------------- 1 | package io.vickze.common.util; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | 5 | import java.util.regex.Pattern; 6 | 7 | /** 8 | * SQL过滤 9 | * 10 | * @author vick.zeng 11 | */ 12 | @Slf4j 13 | public class SQLUtil { 14 | 15 | /** 16 | * 正则表达式 17 | **/ 18 | private static String reg = "(?:')|(?:--)|(/\\*(?:.|[\\n\\r])*?\\*/)|" 19 | + "(\\b(select|update|union|and|or|delete|insert|trancate|char|into|substr|ascii|declare|exec|count|master|into|drop|execute)\\b)"; 20 | 21 | //\\b 表示 限定单词边界 比如 select 不通过 1select则是可以的 22 | private static Pattern sqlPattern = Pattern.compile(reg, Pattern.CASE_INSENSITIVE); 23 | 24 | /** 25 | * SQL注入检查 26 | * 27 | * @param str 待验证的字符串 28 | */ 29 | public static void checkSqlInject(String str) { 30 | if (sqlPattern.matcher(str).find()) 31 | { 32 | log.error("存在sql注入风险:str={}", str); 33 | throw new RuntimeException("包含非法字符"); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/test/java/io/vickze/auth/BCryptTest.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth; 2 | 3 | import org.junit.Test; 4 | import org.springframework.security.crypto.bcrypt.BCrypt; 5 | 6 | public class BCryptTest { 7 | 8 | @Test 9 | public void test() { 10 | long start = System.currentTimeMillis(); 11 | String s = BCrypt.hashpw("test", BCrypt.gensalt()); 12 | System.out.println(s); 13 | System.out.println(System.currentTimeMillis() - start + "ms"); 14 | 15 | start = System.currentTimeMillis(); 16 | System.out.println(BCrypt.checkpw(s, s)); 17 | System.out.println(System.currentTimeMillis() - start + "ms"); 18 | 19 | 20 | start = System.currentTimeMillis(); 21 | System.out.println(BCrypt.checkpw("123", s)); 22 | System.out.println(System.currentTimeMillis() - start + "ms"); 23 | 24 | start = System.currentTimeMillis(); 25 | System.out.println(BCrypt.checkpw("test ", s)); 26 | System.out.println(System.currentTimeMillis() - start + "ms"); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/controller/TokenController.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.controller; 2 | 3 | import io.vickze.auth.client.TokenClient; 4 | import io.vickze.auth.constant.GlobalConstant; 5 | import io.vickze.auth.constant.TokenConstant; 6 | import io.vickze.auth.domain.DTO.AuthUserDTO; 7 | import io.vickze.auth.domain.DTO.CreateTokenDTO; 8 | import io.vickze.auth.domain.DTO.TokenDTO; 9 | import io.vickze.auth.service.TokenService; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.web.bind.annotation.*; 12 | 13 | @RestController 14 | @RequestMapping("/token") 15 | public class TokenController implements TokenClient { 16 | 17 | @Autowired 18 | private TokenService tokenService; 19 | 20 | @Override 21 | public AuthUserDTO validate(String token) { 22 | return tokenService.validate(token); 23 | } 24 | 25 | @DeleteMapping 26 | public void delete(@RequestHeader(TokenConstant.TOKEN_HEADER) String token) { 27 | tokenService.delete(token); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/properties/AuthCheckPermissionProperties.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.properties; 2 | 3 | import io.vickze.common.domain.Interface; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | import org.springframework.boot.context.properties.ConfigurationProperties; 8 | import org.springframework.cloud.context.config.annotation.RefreshScope; 9 | import org.springframework.stereotype.Component; 10 | 11 | import java.util.ArrayList; 12 | import java.util.HashSet; 13 | import java.util.List; 14 | import java.util.Set; 15 | 16 | /** 17 | * @author vick.zeng 18 | * @email zyk@yk95.top 19 | * @create 2019-05-24 21:38 20 | */ 21 | @Data 22 | @RefreshScope 23 | @ConfigurationProperties(value = "auth.check-permission", ignoreUnknownFields = false) 24 | @Component 25 | public class AuthCheckPermissionProperties { 26 | 27 | private List ignoreInterfaces = new ArrayList<>(); 28 | 29 | private List ignoreInterfacesWithoutLogin = new ArrayList<>(); 30 | 31 | } 32 | 33 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/domain/DO/UserRoleDO.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.domain.DO; 2 | 3 | import com.baomidou.mybatisplus.annotation.*; 4 | import com.fasterxml.jackson.annotation.JsonIgnore; 5 | import lombok.Data; 6 | import io.vickze.common.validation.Insert; 7 | import io.vickze.common.validation.Update; 8 | import javax.validation.constraints.NotBlank; 9 | import javax.validation.constraints.NotNull; 10 | import java.time.LocalDateTime; 11 | 12 | /** 13 | * 用户与角色对应关系 14 | * 15 | * @author vick.zeng 16 | * @email zyk@yk95.top 17 | * @create 2019-04-16 11:14:40 18 | */ 19 | @Data 20 | @TableName("user_role") 21 | public class UserRoleDO { 22 | 23 | /** 24 | * 25 | */ 26 | @TableId(type = IdType.AUTO) 27 | @NotNull(groups = Update.class) 28 | private Long id; 29 | /** 30 | * 用户ID 31 | */ 32 | private Long userId; 33 | /** 34 | * 角色ID 35 | */ 36 | private Long roleId; 37 | /** 38 | * 创建时间 39 | */ 40 | @TableField(fill = FieldFill.INSERT) 41 | private LocalDateTime createTime; 42 | } 43 | -------------------------------------------------------------------------------- /vickze-gateway/src/main/java/io/vickze/gateway/GatewayApplication.java: -------------------------------------------------------------------------------- 1 | package io.vickze.gateway; 2 | 3 | import io.vickze.auth.exception.AuthExceptionHandler; 4 | import io.vickze.auth.resovler.AuthUserHandlerMethodArgumentResolver; 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.cloud.client.SpringCloudApplication; 7 | import org.springframework.cloud.openfeign.EnableFeignClients; 8 | import org.springframework.context.annotation.ComponentScan; 9 | import org.springframework.context.annotation.FilterType; 10 | 11 | 12 | /** 13 | * @author vick.zeng 14 | * date-time: 2018/11/19 15:02 15 | **/ 16 | @SpringCloudApplication 17 | @ComponentScan(basePackages = "io.vickze", excludeFilters = { 18 | @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = {AuthExceptionHandler.class, AuthUserHandlerMethodArgumentResolver.class}) 19 | }) 20 | @EnableFeignClients({"io.vickze.auth.client", "io.vickze.auth.client.fallback"}) 21 | public class GatewayApplication { 22 | public static void main(String[] args) { 23 | SpringApplication.run(GatewayApplication.class, args); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /vickze-common/src/main/java/io/vickze/common/domain/DTO/QueryDTO.java: -------------------------------------------------------------------------------- 1 | package io.vickze.common.domain.DTO; 2 | 3 | import io.vickze.common.enums.DBOrder; 4 | import io.vickze.common.util.SQLUtil; 5 | import lombok.Data; 6 | 7 | /** 8 | * 查询参数 9 | * 10 | * @author vick.zeng 11 | */ 12 | @Data 13 | public class QueryDTO { 14 | 15 | private long offset = 0; 16 | 17 | private long limit = 10; 18 | 19 | //排序字段 20 | private String field; 21 | //排序方式 asc、desc 22 | private String order; 23 | 24 | public void setLimit(long limit) { 25 | //限制最大查询条数 26 | if (limit > 1000) { 27 | throw new RuntimeException(); 28 | } 29 | this.limit = limit; 30 | } 31 | 32 | public void setField(String field) { 33 | //防止SQL注入 34 | SQLUtil.checkSqlInject(field); 35 | this.field = field; 36 | } 37 | 38 | public void setOrder(String order) { 39 | if (DBOrder.ASC.name().equalsIgnoreCase(order)) { 40 | this.order = DBOrder.ASC.name(); 41 | } else { 42 | this.order = DBOrder.DESC.name(); 43 | } 44 | 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/service/MenuResourceService.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.service; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 4 | import io.vickze.auth.domain.DO.MenuResourceDO; 5 | import io.vickze.auth.domain.DTO.MenuResourceDTO; 6 | import io.vickze.auth.domain.DTO.MenuResourceQueryDTO; 7 | import org.apache.commons.lang3.tuple.Pair; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * 菜单资源 13 | * 14 | * @author vick.zeng 15 | * @email zyk@yk95.top 16 | * @create 2019-04-29 15:01:06 17 | */ 18 | public interface MenuResourceService { 19 | 20 | Pair, Long> list(MenuResourceQueryDTO queryDTO); 21 | 22 | MenuResourceDTO get(Long id); 23 | 24 | void insert(MenuResourceDTO menuResourceDTO); 25 | 26 | void update(MenuResourceDTO menuResourceDTO); 27 | 28 | void delete(Long... ids); 29 | 30 | List getPermissions(String systemKey, String uri, String method); 31 | 32 | List getPermissions(Long systemId, String uri, String method); 33 | 34 | List selectList(QueryWrapper menuResourceDOQueryWrapper); 35 | } 36 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/service/RoleService.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.service; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.Wrapper; 4 | import io.vickze.auth.domain.DO.MenuResourceDO; 5 | import io.vickze.auth.domain.DO.RoleDO; 6 | import io.vickze.auth.domain.DTO.AssignMenuResourceDTO; 7 | import io.vickze.auth.domain.DTO.RoleQueryDTO; 8 | import org.apache.commons.lang3.tuple.Pair; 9 | 10 | import java.util.Arrays; 11 | import java.util.List; 12 | 13 | /** 14 | * 角色 15 | * 16 | * @author vick.zeng 17 | * @email zyk@yk95.top 18 | * @create 2019-04-16 11:16:31 19 | */ 20 | public interface RoleService { 21 | 22 | Pair, Long> list(RoleQueryDTO queryDTO); 23 | 24 | RoleDO get(Long id); 25 | 26 | void insert(RoleDO roleDO); 27 | 28 | void update(RoleDO roleDO); 29 | 30 | void delete(Long... ids); 31 | 32 | void assignMenuResource(AssignMenuResourceDTO assignMenuResourceDTO); 33 | 34 | List getMenuResources(String systemKey, Long... roleIds); 35 | 36 | List selectByUserId(Long id); 37 | 38 | List getMenuResources(Long systemId, Long... roleIds); 39 | } 40 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/domain/DO/RoleMenuResourceDO.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.domain.DO; 2 | 3 | import com.baomidou.mybatisplus.annotation.*; 4 | import com.fasterxml.jackson.annotation.JsonIgnore; 5 | import lombok.Data; 6 | import io.vickze.common.validation.Insert; 7 | import io.vickze.common.validation.Update; 8 | import javax.validation.constraints.NotBlank; 9 | import javax.validation.constraints.NotNull; 10 | import java.time.LocalDateTime; 11 | 12 | /** 13 | * 角色与菜单资源对应关系 14 | * 15 | * @author vick.zeng 16 | * @email zyk@yk95.top 17 | * @create 2019-04-30 15:32:48 18 | */ 19 | @Data 20 | @TableName("role_menu_resource") 21 | public class RoleMenuResourceDO { 22 | 23 | /** 24 | * 25 | */ 26 | @TableId(type = IdType.AUTO) 27 | @NotNull(groups = Update.class) 28 | private Long id; 29 | /** 30 | * 角色ID 31 | */ 32 | private Long roleId; 33 | /** 34 | * 角色ID 35 | */ 36 | private Long systemId; 37 | /** 38 | * 菜单资源ID 39 | */ 40 | private Long menuResourceId; 41 | /** 42 | * 创建时间 43 | */ 44 | @TableField(fill = FieldFill.INSERT) 45 | private LocalDateTime createTime; 46 | } 47 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/domain/DO/RoleDO.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.domain.DO; 2 | 3 | import com.baomidou.mybatisplus.annotation.*; 4 | import com.fasterxml.jackson.annotation.JsonIgnore; 5 | import lombok.Data; 6 | import io.vickze.common.validation.Insert; 7 | import io.vickze.common.validation.Update; 8 | import javax.validation.constraints.NotBlank; 9 | import javax.validation.constraints.NotNull; 10 | import java.time.LocalDateTime; 11 | 12 | /** 13 | * 角色 14 | * 15 | * @author vick.zeng 16 | * @email zyk@yk95.top 17 | * @create 2019-04-16 11:14:40 18 | */ 19 | @Data 20 | @TableName("role") 21 | public class RoleDO { 22 | 23 | /** 24 | * 25 | */ 26 | @TableId(type = IdType.AUTO) 27 | @NotNull(groups = Update.class) 28 | private Long id; 29 | /** 30 | * 角色名称 31 | */ 32 | private String name; 33 | /** 34 | * 备注 35 | */ 36 | private String remark; 37 | /** 38 | * 创建时间 39 | */ 40 | @TableField(fill = FieldFill.INSERT) 41 | private LocalDateTime createTime; 42 | /** 43 | * 最后修改时间 44 | */ 45 | @TableField(fill = FieldFill.INSERT_UPDATE) 46 | private LocalDateTime updateTime; 47 | } 48 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-client/src/main/java/io/vickze/auth/interceptor/AuthInterceptor.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.interceptor; 2 | 3 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 4 | import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; 5 | import org.springframework.stereotype.Component; 6 | import org.springframework.web.servlet.DispatcherServlet; 7 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 8 | import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; 9 | 10 | import javax.servlet.Servlet; 11 | import javax.servlet.http.HttpServletRequest; 12 | import javax.servlet.http.HttpServletResponse; 13 | 14 | /** 15 | * @author vick.zeng 16 | * @email zyk@yk95.top 17 | * @create 2019-07-17 14:44 18 | */ 19 | @ConditionalOnWebApplication( 20 | type = ConditionalOnWebApplication.Type.SERVLET 21 | ) 22 | @ConditionalOnClass({Servlet.class, DispatcherServlet.class, WebMvcConfigurer.class}) 23 | @Component 24 | public class AuthInterceptor extends HandlerInterceptorAdapter { 25 | 26 | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { 27 | return true; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /vickze-common/src/main/java/io/vickze/common/deserializer/ZonedDateTimeDeserializer.java: -------------------------------------------------------------------------------- 1 | package io.vickze.common.deserializer; 2 | 3 | import com.fasterxml.jackson.core.JsonParser; 4 | import com.fasterxml.jackson.core.JsonProcessingException; 5 | import com.fasterxml.jackson.databind.DeserializationContext; 6 | import com.fasterxml.jackson.databind.JsonDeserializer; 7 | 8 | import java.io.IOException; 9 | import java.time.ZonedDateTime; 10 | import java.time.format.DateTimeFormatter; 11 | 12 | 13 | /** 14 | * @author vick.zeng 15 | * date-time: 2018/11/6 14:07 16 | **/ 17 | public class ZonedDateTimeDeserializer extends JsonDeserializer { 18 | 19 | private DateTimeFormatter dateTimeFormatter; 20 | 21 | public static final ZonedDateTimeDeserializer INSTANCE = new ZonedDateTimeDeserializer(DateTimeFormatter.ISO_OFFSET_DATE_TIME); 22 | 23 | public ZonedDateTimeDeserializer(DateTimeFormatter dateTimeFormatter) { 24 | this.dateTimeFormatter = dateTimeFormatter; 25 | } 26 | 27 | @Override 28 | public ZonedDateTime deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException { 29 | return ZonedDateTime.parse(p.getValueAsString(), dateTimeFormatter); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /vickze-gateway/Dockerfile: -------------------------------------------------------------------------------- 1 | # ../mvnw install -DskipTests 2 | # mkdir -p target/dependency && (cd target/dependency; jar -xf ../*.jar) 3 | # docker build -t io.vickze/vickze-gateway . 4 | # docker run -it --rm \ 5 | # -p 16000:16000 6 | # -v application-log:/log -v /etc/localtime:/etc/localtime \ 7 | # -e NACOS_ADDR=nacos-standalone:8848 -e JAVA_OPTS="-Xmx128m -Duser.timezone=GMT+8" -e COMMAND_ARGS="--REDIS_HOST=redis" \ 8 | # --label type=springboot --label name=vickze-gateway \ 9 | # --log-driver json-file --log-opt labels=type,name --log-opt max-size=10m --log-opt max-file=10 \ 10 | # --net vickze-cloud-admin \ 11 | # io.vickze/vickze-gateway 12 | FROM openjdk:8-jdk-alpine 13 | VOLUME /tmp 14 | ARG DEPENDENCY=target/dependency 15 | COPY ${DEPENDENCY}/BOOT-INF/lib /app/lib 16 | COPY ${DEPENDENCY}/META-INF /app/META-INF 17 | COPY ${DEPENDENCY}/BOOT-INF/classes /app 18 | # ENTRYPOINT ["java","-cp","app:app/lib/*","io.vickze.gateway.GatewayApplication"] 19 | 20 | # JAVA_OPTS 用于JVM启动参数 21 | # COMMAND_ARGS 用于命令行参数 22 | # 三种方式可以传入SpringBoot配置,环境变量、JVM启动参数、命令行参数 main方法中的String[] args, 对应 docker -e name=value; docker -e JAVA_OPTS JVM启动参数 -Dname=value; docker -e COMMAND_ARGS 命令行参数 --name=value 23 | # 优先级为命令行参数、JVM启动参数、环境变量 24 | ENV JAVA_OPTS="" 25 | ENV COMMAND_ARGS="" 26 | ENTRYPOINT exec java $JAVA_OPTS -cp app:app/lib/* io.vickze.gateway.GatewayApplication $COMMAND_ARGS 27 | 28 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/domain/DO/MenuDO.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.domain.DO; 2 | 3 | import com.baomidou.mybatisplus.annotation.*; 4 | import com.fasterxml.jackson.annotation.JsonIgnore; 5 | import lombok.Data; 6 | import io.vickze.common.validation.Insert; 7 | import io.vickze.common.validation.Update; 8 | import javax.validation.constraints.NotBlank; 9 | import javax.validation.constraints.NotNull; 10 | import java.time.LocalDateTime; 11 | 12 | /** 13 | * 菜单 14 | * 15 | * @author vick.zeng 16 | * @email zyk@yk95.top 17 | * @create 2019-05-15 15:35:39 18 | */ 19 | @Data 20 | @TableName("menu") 21 | public class MenuDO { 22 | 23 | /** 24 | * 25 | */ 26 | @TableId(type = IdType.AUTO) 27 | @NotNull(groups = Update.class) 28 | private Long id; 29 | /** 30 | * 系统ID 31 | */ 32 | @NotNull(groups = {Insert.class, Update.class}) 33 | private Long systemId; 34 | /** 35 | * 父ID 36 | */ 37 | private Long parentId; 38 | /** 39 | * 名称 40 | */ 41 | @NotBlank(groups = {Insert.class, Update.class}) 42 | private String name; 43 | /** 44 | * 创建时间 45 | */ 46 | @TableField(fill = FieldFill.INSERT) 47 | private LocalDateTime createTime; 48 | /** 49 | * 最后修改时间 50 | */ 51 | @TableField(fill = FieldFill.INSERT_UPDATE) 52 | private LocalDateTime updateTime; 53 | } 54 | -------------------------------------------------------------------------------- /vickze-common/src/main/java/io/vickze/common/serializer/EmailSerializer.java: -------------------------------------------------------------------------------- 1 | package io.vickze.common.serializer; 2 | 3 | import com.fasterxml.jackson.core.JsonGenerator; 4 | import com.fasterxml.jackson.databind.JsonSerializer; 5 | import com.fasterxml.jackson.databind.SerializerProvider; 6 | 7 | import java.io.IOException; 8 | 9 | public class EmailSerializer extends JsonSerializer { 10 | @Override 11 | public void serialize(String s, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException { 12 | try { 13 | String result = ""; 14 | String[] split = s.split("@"); 15 | String s1 = split[0]; 16 | String s2 = split[1]; 17 | if (s == null) { 18 | jsonGenerator.writeNull(); 19 | return; 20 | } else if (s1.length() <= 4) { 21 | if (s1.length() <= 2) { 22 | result = s1; 23 | } else { 24 | result = s1.substring(0, 2) + s1.substring(2).replaceAll(".", "*"); 25 | } 26 | } else { 27 | result = s1.substring(0, 4) + s1.substring(4).replaceAll(".", "*"); 28 | } 29 | jsonGenerator.writeString(result + "@" + s2); 30 | } catch (Exception e) { 31 | jsonGenerator.writeString(s); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vickze-cloud-admin 2 | 3 | 4 | 中后台前后端分离解决方案,后端基于Spring Cloud开发,前端采用ant-design-pro,主要解决微服务架构多系统下的权限控制,目前包括权限控制中心、代码生成 5 | 6 | 7 | ### 环境 8 | 9 | * mysql、redis、alibaba nacos 10 | * jdk1.8 11 | * IDE lombok插件 12 | 13 | ### 启动步骤 14 | 15 | * 初始化 vickze-auth/init.sql、vickze-generator/init.sql 16 | * 启动mysql、redis、alibaba nacos 17 | * 各个服务注释的配置导入到alibaba nacos 18 | * 启动AuthApplication、GeneratorApplication、GatewayApplication 19 | * 启动前端工程 [https://github.com/vickze/vickze-auth-ui](https://github.com/vickze/vickze-auth-ui) [https://github.com/vickze/vickze-generator-ui](https://github.com/vickze/vickze-generator-ui) 账号密码 admin/admin 20 | 21 | ### 单点启动 22 | * 启动前端工程[https://github.com/vickze/vickze-sso-ui](https://github.com/vickze/vickze-sso-ui) 23 | * vickze-auth-ui、vickze-generator-ui根据单点启动命令启动 24 | * 启动SSOApplication并修改配置sso.system为前端地址 25 | 26 | ### 功能截图 27 | 28 | 权限控制中心 29 | 30 | ![](https://raw.githubusercontent.com/vickze/vickze-cloud-admin/master/images/menuResource.png) 31 | 32 | ![](https://raw.githubusercontent.com/vickze/vickze-cloud-admin/master/images/menuResource_edit.png) 33 | 34 | 代码生成系统 35 | 36 | ![](https://raw.githubusercontent.com/vickze/vickze-cloud-admin/master/images/code.png) 37 | 38 | ![](https://raw.githubusercontent.com/vickze/vickze-cloud-admin/master/images/config.png) 39 | 40 | 41 | 42 | #### 关于领域驱动设计(DDD,Domain-Driven Design)的理解应用 43 | 44 | 在前后端分离下所有传输的对象都可以理解成DTO 45 | 46 | 在本项目中只存在DO、DTO,并且DO可以满足的时候,不另建DTO 47 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/domain/DO/SystemDO.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.domain.DO; 2 | 3 | import com.baomidou.mybatisplus.annotation.*; 4 | import com.fasterxml.jackson.annotation.JsonIgnore; 5 | import lombok.Data; 6 | import io.vickze.common.validation.Insert; 7 | import io.vickze.common.validation.Update; 8 | import javax.validation.constraints.NotBlank; 9 | import javax.validation.constraints.NotNull; 10 | import java.time.LocalDateTime; 11 | 12 | /** 13 | * 系统 14 | * 15 | * @author vick.zeng 16 | * @email zyk@yk95.top 17 | * @create 2019-05-15 14:49:10 18 | */ 19 | @Data 20 | @TableName("`system`") 21 | public class SystemDO { 22 | 23 | /** 24 | * 25 | */ 26 | @TableId(type = IdType.AUTO) 27 | @NotNull(groups = Update.class) 28 | private Long id; 29 | /** 30 | * 名称 31 | */ 32 | @NotBlank(groups = {Insert.class, Update.class}) 33 | private String name; 34 | /** 35 | * Key 36 | */ 37 | @NotBlank(groups = {Insert.class, Update.class}) 38 | @TableField("`key`") 39 | private String key; 40 | 41 | /** 42 | * 是否允许无菜单资源权限登录 43 | */ 44 | private Boolean notResourceLogin; 45 | /** 46 | * 创建时间 47 | */ 48 | @TableField(fill = FieldFill.INSERT) 49 | private LocalDateTime createTime; 50 | /** 51 | * 最后修改时间 52 | */ 53 | @TableField(fill = FieldFill.INSERT_UPDATE) 54 | private LocalDateTime updateTime; 55 | } 56 | -------------------------------------------------------------------------------- /vickze-common/src/main/java/io/vickze/common/exception/FeignExceptionErrorDecoder.java: -------------------------------------------------------------------------------- 1 | package io.vickze.common.exception; 2 | 3 | import feign.FeignException; 4 | import feign.Response; 5 | import feign.Util; 6 | import feign.codec.ErrorDecoder; 7 | import io.vickze.common.util.JsonUtil; 8 | import lombok.Data; 9 | import lombok.extern.slf4j.Slf4j; 10 | import org.springframework.stereotype.Component; 11 | 12 | /** 13 | * @author vick.zeng 14 | * @email zyk@yk95.top 15 | * @create 2019-06-04 11:00 16 | */ 17 | @Slf4j 18 | @Component 19 | public class FeignExceptionErrorDecoder implements ErrorDecoder { 20 | @Override 21 | public Exception decode(String methodKey, Response response) { 22 | try { 23 | if (response.body() != null) { 24 | ExceptionInfo exceptionInfo = JsonUtil.fromJson(Util.toString(response.body().asReader()), ExceptionInfo.class); 25 | Class clazz = Class.forName(exceptionInfo.getExceptionClass()); 26 | return (Exception) clazz.getDeclaredConstructor(String.class).newInstance(exceptionInfo.getMessage()); 27 | } 28 | } catch (Exception e) { 29 | log.error(e.getMessage(), e); 30 | } 31 | 32 | return FeignException.errorStatus(methodKey, response); 33 | } 34 | 35 | @Data 36 | public static class ExceptionInfo { 37 | 38 | private String exceptionClass; 39 | 40 | private String message; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/Dockerfile: -------------------------------------------------------------------------------- 1 | # (cd ../../vickze-common; ../mvnw install -DskipTests) 2 | # (cd ../vickze-auth-common; ../../mvnw install -DskipTests) 3 | # (cd ../vickze-auth-client; ../../mvnw install -DskipTests) 4 | # ../../mvnw install -DskipTests 5 | # mkdir -p target/dependency && (cd target/dependency; jar -xf ../*.jar) 6 | # docker build -t io.vickze/vickze-auth . 7 | # docker run -it --rm \ 8 | # -v application-log:/log -v /etc/localtime:/etc/localtime \ 9 | # -e NACOS_ADDR=nacos-standalone:8848 -e JAVA_OPTS="-Xmx128m -DMYSQL_HOST=mysql -Duser.timezone=GMT+8" -e COMMAND_ARGS="--REDIS_HOST=redis" \ 10 | # --label type=springboot --label name=vickze-auth \ 11 | # --log-driver json-file --log-opt labels=type,name --log-opt max-size=10m --log-opt max-file=10 \ 12 | # --net vickze-cloud-admin \ 13 | # io.vickze/vickze-auth 14 | 15 | FROM openjdk:8-jdk-alpine 16 | VOLUME /tmp 17 | ARG DEPENDENCY=target/dependency 18 | COPY ${DEPENDENCY}/BOOT-INF/lib /app/lib 19 | COPY ${DEPENDENCY}/META-INF /app/META-INF 20 | COPY ${DEPENDENCY}/BOOT-INF/classes /app 21 | # ENTRYPOINT ["java","-cp","app:app/lib/*","io.vickze.auth.AuthApplication"] 22 | 23 | # JAVA_OPTS 用于JVM启动参数 24 | # COMMAND_ARGS 用于命令行参数 25 | # 三种方式可以传入SpringBoot配置,环境变量、JVM启动参数、命令行参数 main方法中的String[] args, 对应 docker -e name=value; docker -e JAVA_OPTS JVM启动参数 -Dname=value; docker -e COMMAND_ARGS 命令行参数 --name=value 26 | # 优先级为命令行参数、JVM启动参数、环境变量 27 | ENV JAVA_OPTS="" 28 | ENV COMMAND_ARGS="" 29 | ENTRYPOINT exec java $JAVA_OPTS -cp app:app/lib/* io.vickze.auth.AuthApplication $COMMAND_ARGS 30 | 31 | -------------------------------------------------------------------------------- /vickze-common/src/main/java/io/vickze/common/validation/Phone.java: -------------------------------------------------------------------------------- 1 | package io.vickze.common.validation; 2 | 3 | import javax.validation.Constraint; 4 | import javax.validation.OverridesAttribute; 5 | import javax.validation.Payload; 6 | import javax.validation.ReportAsSingleViolation; 7 | import javax.validation.constraints.Pattern; 8 | import java.lang.annotation.*; 9 | 10 | /** 11 | * Created by vick.zeng on 2017-06-30. 12 | */ 13 | @Documented 14 | @Constraint( 15 | validatedBy = {} 16 | ) 17 | @Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.PARAMETER}) 18 | @Retention(RetentionPolicy.RUNTIME) 19 | @ReportAsSingleViolation 20 | @Pattern( 21 | regexp = "" 22 | ) 23 | public @interface Phone { 24 | String message() default "手机号码格式错误"; 25 | 26 | Class[] groups() default {}; 27 | 28 | Class[] payload() default {}; 29 | 30 | @OverridesAttribute( 31 | constraint = Pattern.class, 32 | name = "regexp" 33 | ) 34 | 35 | /** 36 | * 手机号宽松校验,只校验第一位数字为1+位数为11位 37 | */ 38 | String regexp() default "^1\\d{10}$"; 39 | 40 | @OverridesAttribute( 41 | constraint = Pattern.class, 42 | name = "flags" 43 | ) 44 | Pattern.Flag[] flags() default {}; 45 | 46 | @Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.PARAMETER}) 47 | @Retention(RetentionPolicy.RUNTIME) 48 | @Documented 49 | @interface List { 50 | Phone[] value(); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /vickze-sso/Dockerfile: -------------------------------------------------------------------------------- 1 | # (cd ../vickze-common; ../mvnw install -DskipTests) 2 | # ../mvnw install -DskipTests 3 | # mkdir -p target/dependency && (cd target/dependency; jar -xf ../*.jar) 4 | # docker build -t io.vickze/vickze-sso . 5 | # docker run -it --rm -v /usr/local/log:/log -v /etc/localtime:/etc/localtime -e NACOS_ADDR=nacos-standalone:8848 -e JAVA_OPTS="-Xmx128m -DMASTER_MYSQL_HOST=mysql" -e COMMAND_ARGS="--GENERATOR_MYSQL_HOST=mysql" --net vickze-cloud-admin io.vickze/vickze-sso 6 | 7 | # docker run -it --rm \ 8 | # -v application-log:/log -v /etc/localtime:/etc/localtime \ 9 | # -e NACOS_ADDR=nacos-standalone:8848 -e JAVA_OPTS="-Xmx128m -Duser.timezone=GMT+8" \ 10 | # --label type=springboot --label name=vickze-sso \ 11 | # --log-driver json-file --log-opt labels=type,name --log-opt max-size=10m --log-opt max-file=10 \ 12 | # --net vickze-cloud-admin \ 13 | # io.vickze/vickze-sso 14 | 15 | FROM openjdk:8-jdk-alpine 16 | VOLUME /tmp 17 | ARG DEPENDENCY=target/dependency 18 | COPY ${DEPENDENCY}/BOOT-INF/lib /app/lib 19 | COPY ${DEPENDENCY}/META-INF /app/META-INF 20 | COPY ${DEPENDENCY}/BOOT-INF/classes /app 21 | # ENTRYPOINT ["java","-cp","app:app/lib/*","io.vickze.sso.SsoApplication"] 22 | 23 | # JAVA_OPTS 用于JVM启动参数 24 | # COMMAND_ARGS 用于命令行参数 25 | # 三种方式可以传入SpringBoot配置,环境变量、JVM启动参数、命令行参数 main方法中的String[] args, 对应 docker -e name=value; docker -e JAVA_OPTS JVM启动参数 -Dname=value; docker -e COMMAND_ARGS 命令行参数 --name=value 26 | # 优先级为命令行参数、JVM启动参数、环境变量 27 | ENV JAVA_OPTS="" 28 | ENV COMMAND_ARGS="" 29 | ENTRYPOINT exec java $JAVA_OPTS -cp app:app/lib/* io.vickze.sso.SsoApplication $COMMAND_ARGS 30 | 31 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/domain/DO/MenuResourceDO.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.domain.DO; 2 | 3 | import com.baomidou.mybatisplus.annotation.*; 4 | import com.fasterxml.jackson.annotation.JsonIgnore; 5 | import lombok.Data; 6 | import io.vickze.common.validation.Insert; 7 | import io.vickze.common.validation.Update; 8 | import javax.validation.constraints.NotBlank; 9 | import javax.validation.constraints.NotNull; 10 | import java.time.LocalDateTime; 11 | 12 | /** 13 | * 菜单资源 14 | * 15 | * @author vick.zeng 16 | * @email zyk@yk95.top 17 | * @create 2019-05-15 15:49:58 18 | */ 19 | @Data 20 | @TableName("menu_resource") 21 | public class MenuResourceDO { 22 | 23 | /** 24 | * 25 | */ 26 | @TableId(type = IdType.AUTO) 27 | @NotNull(groups = Update.class) 28 | private Long id; 29 | /** 30 | * 系统ID 31 | */ 32 | @NotNull(groups = {Insert.class, Update.class}) 33 | private Long systemId; 34 | /** 35 | * 菜单ID 36 | */ 37 | @NotNull(groups = {Insert.class, Update.class}) 38 | private Long menuId; 39 | /** 40 | * 名称 41 | */ 42 | @NotBlank(groups = {Insert.class, Update.class}) 43 | private String name; 44 | /** 45 | * 权限标识 46 | */ 47 | @NotBlank(groups = {Insert.class, Update.class}) 48 | private String permission; 49 | /** 50 | * 创建时间 51 | */ 52 | @TableField(fill = FieldFill.INSERT) 53 | private LocalDateTime createTime; 54 | /** 55 | * 最后修改时间 56 | */ 57 | @TableField(fill = FieldFill.INSERT_UPDATE) 58 | private LocalDateTime updateTime; 59 | } 60 | -------------------------------------------------------------------------------- /vickze-sso/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | #sso: 2 | # system: 3 | # vickze-auth: 4 | # - http://localhost:8000/ 5 | # vickze-generator: 6 | # - http://localhost:8002/ 7 | # 8 | #logging: 9 | # file: ./log/vickze-sso.log 10 | # level: 11 | # io.vickze: DEBUG 12 | # com.alibaba.nacos.client.naming: ERROR 13 | # 14 | #management: 15 | # endpoints: 16 | # web: 17 | # exposure: 18 | # include: '*' 19 | # endpoint: 20 | # health: 21 | # show-details: ALWAYS 22 | # metrics: 23 | # tags: 24 | # application: ${spring.application.name} 25 | # 26 | #feign: 27 | # hystrix: 28 | # enabled: true 29 | # httpclient: 30 | # enabled: false 31 | # okhttp: 32 | # enabled: true #使用okhttp,默认时 FeignExceptionErrorDecoder response body为null,原因是feign.Client类 connection.getErrorStream() 为null 33 | # read-timeout: 10000 #okhttp client超时时间配置 翻看源码发现,实际调用read-timeout、connect-timeout、followRedirects会被ribbon的覆盖 相关类LoadBalancerFeignClient 34 | # 35 | ##负载均衡 36 | #ribbon: 37 | # OkToRetryOnAllOperations: false #对所有操作请求都进行重试,默认false 38 | # ReadTimeout: 5000 #负载均衡超时时间,默认值5000 39 | # ConnectTimeout: 3000 #ribbon请求连接的超时时间,默认值2000 40 | # MaxAutoRetries: 0 #对当前实例的重试次数,默认0 41 | # MaxAutoRetriesNextServer: 1 #对切换实例的重试次数,默认1 42 | # 43 | ##熔断 44 | #hystrix: 45 | # command: 46 | # default: #default全局有效,service id指定应用有效 47 | # execution: 48 | # timeout: 49 | # #如果enabled设置为false,则请求超时交给ribbon控制,为true,则超时作为熔断根据 50 | # #尝试了下发现需要配置ribbon超时时间才会生效 51 | # enabled: false 52 | # isolation: 53 | # thread: 54 | # timeoutInMilliseconds: 1000 #断路器超时时间,默认1000ms -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/domain/DO/MenuResourceInterfaceDO.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.domain.DO; 2 | 3 | import com.baomidou.mybatisplus.annotation.*; 4 | import com.fasterxml.jackson.annotation.JsonIgnore; 5 | import lombok.Data; 6 | import io.vickze.common.validation.Insert; 7 | import io.vickze.common.validation.Update; 8 | import javax.validation.constraints.NotBlank; 9 | import javax.validation.constraints.NotNull; 10 | import java.time.LocalDateTime; 11 | 12 | /** 13 | * 菜单资源与接口对应关系 14 | * 15 | * @author vick.zeng 16 | * @email zyk@yk95.top 17 | * @create 2019-05-16 11:09:46 18 | */ 19 | @Data 20 | @TableName("menu_resource_interface") 21 | public class MenuResourceInterfaceDO { 22 | 23 | /** 24 | * 25 | */ 26 | @TableId(type = IdType.AUTO) 27 | @NotNull(groups = Update.class) 28 | private Long id; 29 | /** 30 | * 系统ID 31 | */ 32 | @NotNull(groups = {Insert.class, Update.class}) 33 | private Long systemId; 34 | /** 35 | * 菜单ID 36 | */ 37 | @NotNull(groups = {Insert.class, Update.class}) 38 | private Long menuId; 39 | /** 40 | * 菜单资源ID 41 | */ 42 | @NotNull(groups = {Insert.class, Update.class}) 43 | private Long menuResourceId; 44 | /** 45 | * 接口uri 46 | */ 47 | @NotBlank(groups = {Insert.class, Update.class}) 48 | private String interfaceUri; 49 | /** 50 | * 接口方法 51 | */ 52 | @NotBlank(groups = {Insert.class, Update.class}) 53 | private String interfaceMethod; 54 | /** 55 | * 创建时间 56 | */ 57 | @TableField(fill = FieldFill.INSERT) 58 | private LocalDateTime createTime; 59 | } 60 | -------------------------------------------------------------------------------- /vickze-generator/src/main/java/io/vickze/generator/exception/GeneratorExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package io.vickze.generator.exception; 2 | 3 | import io.vickze.auth.exception.AuthExceptionHandler; 4 | import io.vickze.auth.exception.UnauthorizedException; 5 | import io.vickze.common.domain.DTO.MessageResultDTO; 6 | import io.vickze.common.exception.FeignExceptionErrorDecoder; 7 | import lombok.extern.slf4j.Slf4j; 8 | import org.springframework.context.annotation.Primary; 9 | import org.springframework.http.HttpStatus; 10 | import org.springframework.web.bind.annotation.ExceptionHandler; 11 | import org.springframework.web.bind.annotation.ResponseStatus; 12 | import org.springframework.web.bind.annotation.RestControllerAdvice; 13 | 14 | /** 15 | * @author vick.zeng 16 | * @email zyk@yk95.top 17 | * @create 2019-06-14 11:28 18 | */ 19 | @RestControllerAdvice 20 | @Slf4j 21 | //继承test 22 | public class GeneratorExceptionHandler extends AuthExceptionHandler { 23 | 24 | public GeneratorExceptionHandler() { 25 | log.debug("GeneratorExceptionHandler init."); 26 | } 27 | 28 | 29 | @ResponseStatus(HttpStatus.UNAUTHORIZED) 30 | @ExceptionHandler(UnauthorizedException.class) 31 | public FeignExceptionErrorDecoder.ExceptionInfo handleUnauthorizedException(UnauthorizedException e) { 32 | log.debug("GeneratorExceptionHandler handleUnauthorizedException."); 33 | FeignExceptionErrorDecoder.ExceptionInfo exceptionInfo = new FeignExceptionErrorDecoder.ExceptionInfo(); 34 | exceptionInfo.setExceptionClass(e.getClass().getName()); 35 | exceptionInfo.setMessage(e.getMessage()); 36 | return exceptionInfo; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/domain/DO/UserDO.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.domain.DO; 2 | 3 | import com.baomidou.mybatisplus.annotation.*; 4 | import com.fasterxml.jackson.annotation.JsonIgnore; 5 | import com.fasterxml.jackson.annotation.JsonProperty; 6 | import lombok.Data; 7 | import io.vickze.common.validation.Insert; 8 | import io.vickze.common.validation.Update; 9 | import javax.validation.constraints.NotBlank; 10 | import javax.validation.constraints.NotNull; 11 | import java.time.LocalDateTime; 12 | 13 | /** 14 | * 用户 15 | * 16 | * @author vick.zeng 17 | * @email zyk@yk95.top 18 | * @create 2019-04-16 11:14:40 19 | */ 20 | @Data 21 | @TableName("user") 22 | public class UserDO { 23 | 24 | /** 25 | * 26 | */ 27 | @TableId(type = IdType.AUTO) 28 | @NotNull(groups = Update.class) 29 | private Long id; 30 | /** 31 | * 用户名 32 | */ 33 | @NotBlank(groups = {Insert.class, Update.class}) 34 | private String username; 35 | /** 36 | * 密码 37 | */ 38 | @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) 39 | @NotBlank(groups = {Insert.class, Update.class}) 40 | private String password; 41 | /** 42 | * 邮箱 43 | */ 44 | private String email; 45 | /** 46 | * 手机号 47 | */ 48 | private String mobile; 49 | /** 50 | * 状态 0:禁用 1:正常 51 | */ 52 | @NotNull(groups = {Insert.class, Update.class}) 53 | private Integer status; 54 | /** 55 | * 创建时间 56 | */ 57 | @TableField(fill = FieldFill.INSERT) 58 | private LocalDateTime createTime; 59 | /** 60 | * 最后修改时间 61 | */ 62 | @TableField(fill = FieldFill.INSERT_UPDATE) 63 | private LocalDateTime updateTime; 64 | } 65 | -------------------------------------------------------------------------------- /vickze-generator/Dockerfile: -------------------------------------------------------------------------------- 1 | # (cd ../vickze-common; ../mvnw install -DskipTests) 2 | # ../mvnw install -DskipTests 3 | # mkdir -p target/dependency && (cd target/dependency; jar -xf ../*.jar) 4 | # docker build -t io.vickze/vickze-generator . 5 | # docker run -it -v /usr/local/log:/log -v /etc/localtime:/etc/localtime --rm -e NACOS_ADDR=nacos-standalone:8848 -e JAVA_OPTS="-Xmx128m -DMASTER_MYSQL_HOST=mysql" -e COMMAND_ARGS="--GENERATOR_MYSQL_HOST=mysql" --net vickze-cloud-admin io.vickze/vickze-generator 6 | 7 | # docker run -it --rm \ 8 | # -v application-log:/log -v /etc/localtime:/etc/localtime \ 9 | # -e NACOS_ADDR=nacos-standalone:8848 -e JAVA_OPTS="-Xmx128m -Duser.timezone=GMT+8 -DMASTER_MYSQL_HOST=mysql" -e COMMAND_ARGS="--GENERATOR_MYSQL_HOST=mysql" \ 10 | # --label type=springboot --label name=vickze-generator \ 11 | # --log-driver json-file --log-opt labels=type,name --log-opt max-size=10m --log-opt max-file=10 \ 12 | # --net vickze-cloud-admin \ 13 | # io.vickze/vickze-generator 14 | 15 | FROM openjdk:8-jdk-alpine 16 | VOLUME /tmp 17 | ARG DEPENDENCY=target/dependency 18 | COPY ${DEPENDENCY}/BOOT-INF/lib /app/lib 19 | COPY ${DEPENDENCY}/META-INF /app/META-INF 20 | COPY ${DEPENDENCY}/BOOT-INF/classes /app 21 | # ENTRYPOINT ["java","-cp","app:app/lib/*","io.vickze.generator.GeneratorApplication"] 22 | 23 | # JAVA_OPTS 用于JVM启动参数 24 | # COMMAND_ARGS 用于命令行参数 25 | # 三种方式可以传入SpringBoot配置,环境变量、JVM启动参数、命令行参数 main方法中的String[] args, 对应 docker -e name=value; docker -e JAVA_OPTS JVM启动参数 -Dname=value; docker -e COMMAND_ARGS 命令行参数 --name=value 26 | # 优先级为命令行参数、JVM启动参数、环境变量 27 | ENV JAVA_OPTS="" 28 | ENV COMMAND_ARGS="" 29 | ENTRYPOINT exec java $JAVA_OPTS -cp app:app/lib/* io.vickze.generator.GeneratorApplication $COMMAND_ARGS 30 | 31 | -------------------------------------------------------------------------------- /vickze-common/src/main/java/io/vickze/common/domain/RPageRequest.java: -------------------------------------------------------------------------------- 1 | package io.vickze.common.domain; 2 | 3 | import org.springframework.data.domain.AbstractPageRequest; 4 | import org.springframework.data.domain.Pageable; 5 | import org.springframework.data.domain.Sort; 6 | 7 | public class RPageRequest extends AbstractPageRequest { 8 | 9 | private static final long serialVersionUID = -4541509938956089562L; 10 | 11 | private final Sort sort; 12 | 13 | public RPageRequest(int page, int size, Sort sort) { 14 | super(page, size); 15 | 16 | this.sort = sort; 17 | } 18 | 19 | @Override 20 | public Sort getSort() { 21 | return sort; 22 | } 23 | 24 | @Override 25 | public Pageable next() { 26 | return new RPageRequest(getPageNumber() + 1, getPageSize(), getSort()); 27 | } 28 | 29 | @Override 30 | public Pageable previous() { 31 | return getPageNumber() == 0 ? this : new RPageRequest(getPageNumber() - 1, getPageSize(), getSort()); 32 | } 33 | 34 | @Override 35 | public Pageable first() { 36 | return new RPageRequest(0, getPageSize(), getSort()); 37 | } 38 | 39 | @Override 40 | public long getOffset() { 41 | return getPageNumber(); 42 | } 43 | 44 | 45 | public static RPageRequest of(int page, int size) { 46 | return of(page, size, Sort.unsorted()); 47 | } 48 | 49 | public static RPageRequest of(int page, int size, Sort sort) { 50 | return new RPageRequest(page, size, sort); 51 | } 52 | 53 | public static RPageRequest of(int page, int size, Sort.Direction direction, String... properties) { 54 | return of(page, size, Sort.by(direction, properties)); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/domain/DTO/MenuResourceDTO.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.domain.DTO; 2 | 3 | import com.baomidou.mybatisplus.annotation.FieldFill; 4 | import com.baomidou.mybatisplus.annotation.IdType; 5 | import com.baomidou.mybatisplus.annotation.TableField; 6 | import com.baomidou.mybatisplus.annotation.TableId; 7 | import io.vickze.auth.domain.DO.MenuResourceInterfaceDO; 8 | import io.vickze.common.validation.Insert; 9 | import io.vickze.common.validation.Update; 10 | import lombok.Data; 11 | 12 | import javax.validation.constraints.NotBlank; 13 | import javax.validation.constraints.NotEmpty; 14 | import javax.validation.constraints.NotNull; 15 | import java.time.LocalDateTime; 16 | import java.util.List; 17 | 18 | /** 19 | * @author vick.zeng 20 | * @email zyk@yk95.top 21 | * @create 2019-05-16 11:07 22 | */ 23 | @Data 24 | public class MenuResourceDTO { 25 | 26 | 27 | /** 28 | * 29 | */ 30 | @NotNull(groups = Update.class) 31 | private Long id; 32 | /** 33 | * 系统ID 34 | */ 35 | @NotNull(groups = {Insert.class, Update.class}) 36 | private Long systemId; 37 | /** 38 | * 菜单ID 39 | */ 40 | @NotNull(groups = {Insert.class, Update.class}) 41 | private Long menuId; 42 | /** 43 | * 名称 44 | */ 45 | @NotBlank(groups = {Insert.class, Update.class}) 46 | private String name; 47 | /** 48 | * 权限标识 49 | */ 50 | @NotBlank(groups = {Insert.class, Update.class}) 51 | private String permission; 52 | 53 | /** 54 | * 创建时间 55 | */ 56 | private LocalDateTime createTime; 57 | /** 58 | * 最后修改时间 59 | */ 60 | private LocalDateTime updateTime; 61 | 62 | private List interfaces; 63 | } 64 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-client/src/main/java/io/vickze/auth/config/FeignOkHttpConfig.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.config; 2 | 3 | import feign.Feign; 4 | import io.vickze.auth.properties.FeignOkhttpProperties; 5 | import okhttp3.ConnectionPool; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.boot.autoconfigure.AutoConfigureBefore; 8 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 9 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 10 | import org.springframework.cloud.openfeign.FeignAutoConfiguration; 11 | import org.springframework.context.annotation.Bean; 12 | import org.springframework.context.annotation.Configuration; 13 | 14 | import java.util.concurrent.TimeUnit; 15 | 16 | @AutoConfigureBefore(FeignAutoConfiguration.class) 17 | @Configuration 18 | @ConditionalOnClass(Feign.class) 19 | @EnableConfigurationProperties(FeignOkhttpProperties.class) 20 | public class FeignOkHttpConfig { 21 | 22 | @Autowired 23 | private FeignOkhttpProperties feignOkhttpProperties; 24 | 25 | @Bean 26 | public okhttp3.OkHttpClient okHttpClient() { 27 | return new okhttp3.OkHttpClient.Builder() 28 | .readTimeout(feignOkhttpProperties.getReadTimeout(), TimeUnit.MILLISECONDS) 29 | .writeTimeout(feignOkhttpProperties.getWriteTimeout(), TimeUnit.MILLISECONDS) 30 | .connectTimeout(feignOkhttpProperties.getConnectionTimeout(), TimeUnit.MILLISECONDS) 31 | .connectionPool(new ConnectionPool(feignOkhttpProperties.getMaxConnections(), feignOkhttpProperties.getTimeToLive(), feignOkhttpProperties.getTimeToLiveUnit())) 32 | .followRedirects(feignOkhttpProperties.isFollowRedirects()) 33 | .retryOnConnectionFailure(feignOkhttpProperties.isRetryOnConnectionFailure()) 34 | .build(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /vickze-generator/src/main/java/io/vickze/generator/domain/DO/TemplateDO.java: -------------------------------------------------------------------------------- 1 | package io.vickze.generator.domain.DO; 2 | 3 | import com.baomidou.mybatisplus.annotation.*; 4 | import com.fasterxml.jackson.annotation.JsonIgnore; 5 | import lombok.Data; 6 | import io.vickze.common.validation.Insert; 7 | import io.vickze.common.validation.Update; 8 | import javax.validation.constraints.NotBlank; 9 | import javax.validation.constraints.NotNull; 10 | import java.time.LocalDateTime; 11 | 12 | /** 13 | * 模版 14 | * 15 | * @author vick.zeng 16 | * @email zyk@yk95.top 17 | * @create 2019-03-29 16:23:41 18 | */ 19 | @Data 20 | @TableName("template") 21 | public class TemplateDO { 22 | 23 | /** 24 | * 25 | */ 26 | @TableId(type = IdType.AUTO) 27 | @NotNull(groups = Update.class) 28 | private Long id; 29 | /** 30 | * 名称 31 | */ 32 | @NotBlank(groups = {Insert.class, Update.class}) 33 | private String name; 34 | /** 35 | * 文件名称 36 | */ 37 | @NotBlank(groups = {Insert.class, Update.class}) 38 | private String fileName; 39 | /** 40 | * 内容 41 | */ 42 | @NotBlank(groups = {Insert.class, Update.class}) 43 | private String content; 44 | /** 45 | * 类型 0-Velocity 1-Freemarker 46 | */ 47 | @NotNull(groups = {Insert.class, Update.class}) 48 | private Integer type; 49 | /** 50 | * 版本号 51 | */ 52 | @Version 53 | private Integer version; 54 | /** 55 | * 删除标志 56 | */ 57 | @JsonIgnore 58 | @TableLogic 59 | private Integer deleted; 60 | /** 61 | * 创建时间 62 | */ 63 | @TableField(fill = FieldFill.INSERT) 64 | private LocalDateTime createTime; 65 | /** 66 | * 最后修改时间 67 | */ 68 | @TableField(fill = FieldFill.INSERT_UPDATE) 69 | private LocalDateTime updateTime; 70 | } 71 | -------------------------------------------------------------------------------- /vickze-generator/src/main/java/io/vickze/generator/config/MybatisPlusConfiguration.java: -------------------------------------------------------------------------------- 1 | package io.vickze.generator.config; 2 | 3 | import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; 4 | import com.baomidou.mybatisplus.core.injector.ISqlInjector; 5 | import com.baomidou.mybatisplus.extension.injector.LogicSqlInjector; 6 | import com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor; 7 | import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; 8 | import org.apache.ibatis.plugin.Interceptor; 9 | import org.apache.ibatis.reflection.MetaObject; 10 | import org.springframework.context.annotation.Bean; 11 | import org.springframework.context.annotation.Configuration; 12 | 13 | import java.time.LocalDateTime; 14 | 15 | @Configuration 16 | public class MybatisPlusConfiguration { 17 | @Bean 18 | public ISqlInjector sqlInjector() { 19 | return new LogicSqlInjector(); 20 | } 21 | 22 | @Bean 23 | public Interceptor optimisticLockerInterceptor() { 24 | return new OptimisticLockerInterceptor(); 25 | } 26 | 27 | @Bean 28 | public PaginationInterceptor paginationInterceptor() { 29 | return new PaginationInterceptor(); 30 | } 31 | 32 | 33 | @Bean 34 | public MetaObjectHandler timeMetaObjectHandler() { 35 | return new MetaObjectHandler() { 36 | @Override 37 | public void insertFill(MetaObject metaObject) { 38 | LocalDateTime now = LocalDateTime.now(); 39 | setFieldValByName("createTime", now, metaObject); 40 | setFieldValByName("updateTime", now, metaObject); 41 | } 42 | 43 | @Override 44 | public void updateFill(MetaObject metaObject) { 45 | setFieldValByName("updateTime", LocalDateTime.now(), metaObject); 46 | } 47 | }; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/config/MybatisPlusConfiguration.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.config; 2 | 3 | import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; 4 | import com.baomidou.mybatisplus.core.injector.ISqlInjector; 5 | import com.baomidou.mybatisplus.extension.injector.LogicSqlInjector; 6 | import com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor; 7 | import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; 8 | import org.apache.ibatis.plugin.Interceptor; 9 | import org.apache.ibatis.reflection.MetaObject; 10 | import org.springframework.context.annotation.Bean; 11 | import org.springframework.context.annotation.Configuration; 12 | 13 | import java.time.LocalDateTime; 14 | 15 | @Configuration 16 | public class MybatisPlusConfiguration { 17 | @Bean 18 | public ISqlInjector sqlInjector() { 19 | return new LogicSqlInjector(); 20 | } 21 | 22 | @Bean 23 | public Interceptor optimisticLockerInterceptor() { 24 | return new OptimisticLockerInterceptor(); 25 | } 26 | 27 | @Bean 28 | public PaginationInterceptor paginationInterceptor() { 29 | return new PaginationInterceptor(); 30 | } 31 | 32 | 33 | @Bean 34 | public MetaObjectHandler timeMetaObjectHandler() { 35 | return new MetaObjectHandler() { 36 | @Override 37 | public void insertFill(MetaObject metaObject) { 38 | LocalDateTime now = LocalDateTime.now(); 39 | setFieldValByName("createTime", now, metaObject); 40 | setFieldValByName("updateTime", now, metaObject); 41 | } 42 | 43 | @Override 44 | public void updateFill(MetaObject metaObject) { 45 | setFieldValByName("updateTime", LocalDateTime.now(), metaObject); 46 | } 47 | }; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/controller/SystemController.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.controller; 2 | 3 | import io.vickze.auth.domain.DO.SystemDO; 4 | import io.vickze.auth.domain.DTO.SystemQueryDTO; 5 | import io.vickze.auth.service.SystemService; 6 | import io.vickze.common.validation.Insert; 7 | import io.vickze.common.validation.Update; 8 | import org.apache.commons.lang3.tuple.Pair; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.validation.annotation.Validated; 11 | import org.springframework.web.bind.annotation.*; 12 | import javax.servlet.http.HttpServletResponse; 13 | import java.util.List; 14 | 15 | /** 16 | * 系统 17 | * 18 | * @author vick.zeng 19 | * @email zyk@yk95.top 20 | * @create 2019-05-15 14:52:18 21 | */ 22 | @RestController 23 | @RequestMapping("/system") 24 | public class SystemController { 25 | 26 | @Autowired 27 | private SystemService systemService; 28 | 29 | @GetMapping 30 | public List list(SystemQueryDTO queryDTO, HttpServletResponse response) { 31 | Pair, Long> result = systemService.list(queryDTO); 32 | response.addHeader("X-Total-Count", String.valueOf(result.getValue())); 33 | return result.getKey(); 34 | } 35 | 36 | @GetMapping("/{id}") 37 | public SystemDO get(@PathVariable("id") Long id) { 38 | return systemService.get(id); 39 | } 40 | 41 | @PostMapping 42 | public void insert(@RequestBody @Validated(Insert.class) SystemDO systemDO) { 43 | systemService.insert(systemDO); 44 | } 45 | 46 | @PutMapping 47 | public void update(@RequestBody @Validated(Update.class) SystemDO systemDO) { 48 | systemService.update(systemDO); 49 | } 50 | 51 | @DeleteMapping 52 | public void delete(@RequestBody Long... ids) { 53 | systemService.delete(ids); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-client/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | vickze-auth 7 | io.vickze 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | vickze-auth-client 13 | 14 | 15 | io.vickze 16 | vickze-common 17 | 18 | 19 | org.springframework 20 | spring-context 21 | 22 | 23 | 24 | org.springframework.cloud 25 | spring-cloud-starter-openfeign 26 | 27 | 28 | io.vickze 29 | vickze-auth-common 30 | 31 | 32 | io.github.openfeign 33 | feign-okhttp 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-starter-web 38 | provided 39 | 40 | 41 | 42 | 43 | 44 | public 45 | aliyun nexus 46 | http://maven.aliyun.com/nexus/content/groups/public/ 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /vickze-generator/src/main/java/io/vickze/generator/controller/TemplateController.java: -------------------------------------------------------------------------------- 1 | package io.vickze.generator.controller; 2 | 3 | import io.vickze.generator.domain.DO.TemplateDO; 4 | import io.vickze.generator.domain.DTO.TemplateQueryDTO; 5 | import io.vickze.generator.service.TemplateService; 6 | import io.vickze.common.validation.Insert; 7 | import io.vickze.common.validation.Update; 8 | import org.apache.commons.lang3.tuple.Pair; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.validation.annotation.Validated; 11 | import org.springframework.web.bind.annotation.*; 12 | import javax.servlet.http.HttpServletResponse; 13 | import java.util.List; 14 | 15 | /** 16 | * 模版 17 | * 18 | * @author vick.zeng 19 | * @email zyk@yk95.top 20 | * @create 2019-03-29 16:24:22 21 | */ 22 | @RestController 23 | @RequestMapping("/template") 24 | public class TemplateController { 25 | 26 | @Autowired 27 | private TemplateService templateService; 28 | 29 | @GetMapping 30 | public List list(TemplateQueryDTO queryDTO, HttpServletResponse response) { 31 | Pair, Long> result = templateService.list(queryDTO); 32 | response.addHeader("X-Total-Count", String.valueOf(result.getValue())); 33 | return result.getKey(); 34 | } 35 | 36 | @GetMapping("/{id}") 37 | public TemplateDO get(@PathVariable("id") Long id) { 38 | return templateService.get(id); 39 | } 40 | 41 | @PostMapping 42 | public void insert(@RequestBody @Validated(Insert.class) TemplateDO template) { 43 | templateService.insert(template); 44 | } 45 | 46 | @PutMapping 47 | public void update(@RequestBody @Validated(Update.class) TemplateDO template) { 48 | templateService.update(template); 49 | } 50 | 51 | @DeleteMapping 52 | public void delete(@RequestBody Long... ids) { 53 | templateService.delete(ids); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/controller/MenuResourceController.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.controller; 2 | 3 | import io.vickze.auth.domain.DTO.MenuResourceDTO; 4 | import io.vickze.auth.domain.DTO.MenuResourceQueryDTO; 5 | import io.vickze.auth.service.MenuResourceService; 6 | import io.vickze.common.validation.Insert; 7 | import io.vickze.common.validation.Update; 8 | import org.apache.commons.lang3.tuple.Pair; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.validation.annotation.Validated; 11 | import org.springframework.web.bind.annotation.*; 12 | import javax.servlet.http.HttpServletResponse; 13 | import java.util.List; 14 | 15 | /** 16 | * 菜单资源 17 | * 18 | * @author vick.zeng 19 | * @email zyk@yk95.top 20 | * @create 2019-04-29 15:01:06 21 | */ 22 | @RestController 23 | @RequestMapping("/menuResource") 24 | public class MenuResourceController { 25 | 26 | @Autowired 27 | private MenuResourceService menuResourceService; 28 | 29 | @GetMapping 30 | public List list(MenuResourceQueryDTO queryDTO, HttpServletResponse response) { 31 | Pair, Long> result = menuResourceService.list(queryDTO); 32 | response.addHeader("X-Total-Count", String.valueOf(result.getValue())); 33 | return result.getKey(); 34 | } 35 | 36 | @GetMapping("/{id}") 37 | public MenuResourceDTO get(@PathVariable("id") Long id) { 38 | return menuResourceService.get(id); 39 | } 40 | 41 | @PostMapping 42 | public void insert(@RequestBody @Validated(Insert.class) MenuResourceDTO menuResourceDTO) { 43 | menuResourceService.insert(menuResourceDTO); 44 | } 45 | 46 | @PutMapping 47 | public void update(@RequestBody @Validated(Update.class) MenuResourceDTO menuResourceDTO) { 48 | menuResourceService.update(menuResourceDTO); 49 | } 50 | 51 | @DeleteMapping 52 | public void delete(@RequestBody Long... ids) { 53 | menuResourceService.delete(ids); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /example/prometheus/prometheus-standalone.yaml: -------------------------------------------------------------------------------- 1 | # my global config 2 | global: 3 | scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. 4 | evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. 5 | # scrape_timeout is set to the global default (10s). 6 | 7 | # Alertmanager configuration 8 | alerting: 9 | alertmanagers: 10 | - static_configs: 11 | - targets: 12 | # - alertmanager:9093 13 | 14 | # Load rules once and periodically evaluate them according to the global 'evaluation_interval'. 15 | rule_files: 16 | # - "first_rules.yml" 17 | # - "second_rules.yml" 18 | 19 | # A scrape configuration containing exactly one endpoint to scrape: 20 | # Here it's Prometheus itself. 21 | scrape_configs: 22 | # The job name is added as a label `job=` to any timeseries scraped from this config. 23 | - job_name: 'prometheus' 24 | 25 | # metrics_path defaults to '/metrics' 26 | # scheme defaults to 'http'. 27 | 28 | static_configs: 29 | - targets: ['localhost:9090'] 30 | 31 | - job_name: 'nacos' 32 | metrics_path: '/nacos/actuator/prometheus' 33 | static_configs: 34 | - targets: ['nacos:8848'] 35 | - job_name: 'vickze-gateway' 36 | metrics_path: '/actuator/prometheus' 37 | static_configs: 38 | - targets: ['vickze-gateway:16000'] 39 | - job_name: 'vickze-auth' 40 | metrics_path: '/actuator/prometheus' 41 | static_configs: 42 | - targets: ['vickze-auth:16001'] 43 | - job_name: 'vickze-generator' 44 | metrics_path: '/actuator/prometheus' 45 | static_configs: 46 | - targets: ['vickze-generator:16002'] 47 | - job_name: 'vickze-sso' 48 | metrics_path: '/actuator/prometheus' 49 | static_configs: 50 | - targets: ['vickze-sso:16003'] 51 | - job_name: 'node' 52 | static_configs: 53 | - targets: ['node-exporter:9100'] 54 | - job_name: 'mysql' 55 | static_configs: 56 | - targets: ['mysqld-exporter:9104'] 57 | - job_name: 'redis' 58 | static_configs: 59 | - targets: ['redis_exporter:9121'] -------------------------------------------------------------------------------- /vickze-common/src/main/java/io/vickze/common/util/InterfaceUtil.java: -------------------------------------------------------------------------------- 1 | package io.vickze.common.util; 2 | 3 | import io.vickze.common.domain.Interface; 4 | import org.apache.commons.lang3.StringUtils; 5 | 6 | import java.util.List; 7 | import java.util.regex.Pattern; 8 | 9 | /** 10 | * @author vick.zeng 11 | * @email zyk@yk95.top 12 | * @create 2019-07-17 15:25 13 | */ 14 | public class InterfaceUtil { 15 | 16 | /** 17 | * 正则匹配,requestUri是否匹配uri,{}自动替换,如uri为 /auth/user/{id} 替换为/auth/user/\{[a-zA-Z\d]+\} 18 | * 19 | * @param requestUri 请求uri 20 | * @param uri 匹配uri 21 | * @return 22 | */ 23 | public static boolean uriMatch(String requestUri, String uri) { 24 | //去掉最后的/ 25 | if (requestUri.endsWith("/")) { 26 | requestUri = requestUri.substring(0, requestUri.lastIndexOf("/")); 27 | } 28 | if (uri.endsWith("/")) { 29 | uri = uri.substring(0, uri.lastIndexOf("/")); 30 | } 31 | 32 | if (requestUri.equals(uri)) { 33 | return true; 34 | } 35 | 36 | String regEx = uri; 37 | 38 | if (regEx.indexOf("{") > 0) { 39 | //替换{...} 英文数字 40 | regEx = regEx.replaceAll("\\{[a-zA-Z\\d]+\\}", "[a-zA-Z\\\\d]+"); 41 | } 42 | 43 | if (Pattern.compile(regEx).matcher(requestUri).find()) { 44 | return true; 45 | } 46 | return false; 47 | } 48 | 49 | public static boolean interfaceMatch(Interface requestInterface, Interface _interface) { 50 | if (!StringUtils.equals(requestInterface.getMethod(), _interface.getMethod())) { 51 | return false; 52 | } 53 | return uriMatch(requestInterface.getUri(), _interface.getUri()); 54 | } 55 | 56 | public static boolean interfaceContains(Interface requestInterface, List _interfaces) { 57 | for (Interface _interface : _interfaces) { 58 | if (interfaceMatch(requestInterface, _interface)) { 59 | return true; 60 | } 61 | } 62 | 63 | return false; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /vickze-generator/src/main/java/io/vickze/generator/domain/DO/ConfigDO.java: -------------------------------------------------------------------------------- 1 | package io.vickze.generator.domain.DO; 2 | 3 | import org.hibernate.annotations.SQLDelete; 4 | import org.hibernate.annotations.Where; 5 | import org.springframework.data.annotation.CreatedDate; 6 | import org.springframework.data.annotation.LastModifiedDate; 7 | import org.springframework.data.jpa.domain.support.AuditingEntityListener; 8 | import javax.persistence.*; 9 | import com.fasterxml.jackson.annotation.JsonIgnore; 10 | import lombok.Data; 11 | import io.vickze.common.validation.Insert; 12 | import io.vickze.common.validation.Update; 13 | import javax.validation.constraints.NotBlank; 14 | import javax.validation.constraints.NotNull; 15 | import java.time.LocalDateTime; 16 | 17 | /** 18 | * 配置 19 | * 20 | * @author vick.zeng 21 | * @email zyk@yk95.top 22 | * @create 2019-03-29 16:04:44 23 | */ 24 | @Data 25 | @Entity 26 | @Table(name = "config") 27 | @SQLDelete(sql = "update config set deleted = 1 where id = ? and version = ?") 28 | @Where(clause = "deleted = 0") 29 | @EntityListeners(AuditingEntityListener.class) 30 | public class ConfigDO { 31 | 32 | /** 33 | * 34 | */ 35 | @Id 36 | @GeneratedValue(strategy = GenerationType.IDENTITY) 37 | @NotNull(groups = Update.class) 38 | private Long id; 39 | /** 40 | * 名称 41 | */ 42 | @NotBlank(groups = {Insert.class, Update.class}) 43 | private String name; 44 | /** 45 | * 内容 46 | */ 47 | @NotBlank(groups = {Insert.class, Update.class}) 48 | private String content; 49 | /** 50 | * 类型 0-properties 1-yaml 51 | */ 52 | @NotNull(groups = {Insert.class, Update.class}) 53 | private Integer type; 54 | /** 55 | * 版本号 56 | */ 57 | @Version 58 | private Integer version; 59 | /** 60 | * 删除标志 61 | */ 62 | @JsonIgnore 63 | private Integer deleted; 64 | /** 65 | * 创建时间 66 | */ 67 | @CreatedDate 68 | private LocalDateTime createTime; 69 | /** 70 | * 最后修改时间 71 | */ 72 | @LastModifiedDate 73 | private LocalDateTime updateTime; 74 | } 75 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/domain/DTO/UserDTO.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.domain.DTO; 2 | 3 | import com.baomidou.mybatisplus.annotation.FieldFill; 4 | import com.baomidou.mybatisplus.annotation.IdType; 5 | import com.baomidou.mybatisplus.annotation.TableField; 6 | import com.baomidou.mybatisplus.annotation.TableId; 7 | import com.fasterxml.jackson.annotation.JsonProperty; 8 | import io.swagger.annotations.ApiModelProperty; 9 | import io.vickze.auth.domain.DO.RoleDO; 10 | import io.vickze.common.validation.Insert; 11 | import io.vickze.common.validation.Phone; 12 | import io.vickze.common.validation.Update; 13 | import lombok.Data; 14 | 15 | import javax.validation.constraints.Email; 16 | import javax.validation.constraints.NotBlank; 17 | import javax.validation.constraints.NotNull; 18 | import java.time.LocalDateTime; 19 | import java.util.List; 20 | 21 | /** 22 | * @author vick.zeng 23 | * @email zyk@yk95.top 24 | * @create 2019-05-27 14:38 25 | */ 26 | @Data 27 | public class UserDTO { 28 | /** 29 | * 30 | */ 31 | @NotNull(groups = Update.class) 32 | private Long id; 33 | /** 34 | * 用户名 35 | */ 36 | @NotBlank(groups = {Insert.class, Update.class}) 37 | private String username; 38 | /** 39 | * 密码 40 | */ 41 | @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) 42 | @NotBlank(groups = {Insert.class, Update.class}) 43 | @ApiModelProperty 44 | private String password; 45 | /** 46 | * 邮箱 47 | */ 48 | @Email(groups = {Insert.class, Update.class}) 49 | private String email; 50 | /** 51 | * 手机号 52 | */ 53 | @Phone(groups = {Insert.class, Update.class}) 54 | private String mobile; 55 | /** 56 | * 状态 0:禁用 1:正常 57 | */ 58 | @NotNull(groups = {Insert.class, Update.class}) 59 | private Integer status; 60 | /** 61 | * 创建时间 62 | */ 63 | private LocalDateTime createTime; 64 | /** 65 | * 最后修改时间 66 | */ 67 | private LocalDateTime updateTime; 68 | 69 | /** 70 | * 用户角色列表 71 | */ 72 | private List roles; 73 | 74 | } 75 | -------------------------------------------------------------------------------- /vickze-generator/src/main/java/io/vickze/generator/controller/ConfigController.java: -------------------------------------------------------------------------------- 1 | package io.vickze.generator.controller; 2 | 3 | import io.vickze.auth.domain.DTO.AuthUserDTO; 4 | import io.vickze.auth.resovler.AuthUser; 5 | import io.vickze.generator.domain.DO.ConfigDO; 6 | import io.vickze.generator.domain.DTO.ConfigQueryDTO; 7 | import io.vickze.generator.service.ConfigService; 8 | import io.vickze.common.validation.Insert; 9 | import io.vickze.common.validation.Update; 10 | import org.apache.commons.lang3.tuple.Pair; 11 | import lombok.extern.slf4j.Slf4j; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.validation.annotation.Validated; 14 | import org.springframework.web.bind.annotation.*; 15 | import javax.servlet.http.HttpServletResponse; 16 | import java.util.List; 17 | 18 | /** 19 | * 配置 20 | * 21 | * @author vick.zeng 22 | * @email zyk@yk95.top 23 | * @create 2019-03-29 16:04:44 24 | */ 25 | @Slf4j 26 | @RestController 27 | @RequestMapping("/config") 28 | public class ConfigController { 29 | 30 | @Autowired 31 | private ConfigService configService; 32 | 33 | @ResponseBody 34 | @GetMapping 35 | public List list(ConfigQueryDTO queryDTO, HttpServletResponse response, @AuthUser AuthUserDTO authUserDTO) { 36 | Pair, Long> result = configService.list(queryDTO); 37 | response.addHeader("X-Total-Count", String.valueOf(result.getValue())); 38 | return result.getKey(); 39 | } 40 | 41 | @GetMapping("/{id}") 42 | public ConfigDO get(@PathVariable("id") Long id) { 43 | return configService.get(id); 44 | } 45 | 46 | @PostMapping 47 | public void insert(@RequestBody @Validated(Insert.class) ConfigDO config) { 48 | configService.insert(config); 49 | } 50 | 51 | @PutMapping 52 | public void update(@RequestBody @Validated(Update.class) ConfigDO config, @AuthUser AuthUserDTO authUserDTO) { 53 | log.info("操作用户:{}-{}", authUserDTO.getUserId(), authUserDTO.getUsername()); 54 | configService.update(config); 55 | } 56 | 57 | @DeleteMapping 58 | public void delete(@RequestBody Long... ids) { 59 | configService.delete(ids); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/controller/MenuController.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.controller; 2 | 3 | import io.vickze.auth.domain.DO.MenuDO; 4 | import io.vickze.auth.domain.DO.SystemDO; 5 | import io.vickze.auth.domain.DTO.MenuQueryDTO; 6 | import io.vickze.auth.domain.DTO.MenuTreeDTO; 7 | import io.vickze.auth.service.MenuService; 8 | import io.vickze.auth.service.SystemService; 9 | import io.vickze.common.validation.Insert; 10 | import io.vickze.common.validation.Update; 11 | import lombok.extern.slf4j.Slf4j; 12 | import org.apache.commons.lang3.tuple.Pair; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.validation.annotation.Validated; 15 | import org.springframework.web.bind.annotation.*; 16 | import javax.servlet.http.HttpServletResponse; 17 | import java.util.List; 18 | 19 | /** 20 | * 菜单 21 | * 22 | * @author vick.zeng 23 | * @email zyk@yk95.top 24 | * @create 2019-05-15 15:16:39 25 | */ 26 | @RestController 27 | @RequestMapping("/menu") 28 | public class MenuController { 29 | 30 | @Autowired 31 | private SystemService systemService; 32 | @Autowired 33 | private MenuService menuService; 34 | 35 | @GetMapping("/tree") 36 | public List tree(Long systemId) { 37 | return menuService.tree(systemId); 38 | } 39 | 40 | @GetMapping 41 | public List list(MenuQueryDTO queryDTO, HttpServletResponse response) { 42 | Pair, Long> result = menuService.list(queryDTO); 43 | response.addHeader("X-Total-Count", String.valueOf(result.getValue())); 44 | return result.getKey(); 45 | } 46 | 47 | @GetMapping("/{id}") 48 | public MenuDO get(@PathVariable("id") Long id) { 49 | return menuService.get(id); 50 | } 51 | 52 | @PostMapping 53 | public void insert(@RequestBody @Validated(Insert.class) MenuDO menuDO) { 54 | menuService.insert(menuDO); 55 | } 56 | 57 | @PutMapping 58 | public void update(@RequestBody @Validated(Update.class) MenuDO menuDO) { 59 | menuService.update(menuDO); 60 | } 61 | 62 | @DeleteMapping 63 | public void delete(@RequestBody Long... ids) { 64 | menuService.delete(ids); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /vickze-gateway/src/main/java/io/vickze/gateway/swagger/GatewaySwaggerResourcesProvider.java: -------------------------------------------------------------------------------- 1 | package io.vickze.gateway.swagger; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.cloud.gateway.config.GatewayProperties; 5 | import org.springframework.cloud.gateway.route.RouteLocator; 6 | import org.springframework.cloud.gateway.support.NameUtils; 7 | import org.springframework.context.annotation.Primary; 8 | import org.springframework.stereotype.Component; 9 | import springfox.documentation.swagger.web.SwaggerResource; 10 | import springfox.documentation.swagger.web.SwaggerResourcesProvider; 11 | 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | 15 | 16 | @Component 17 | @Primary 18 | public class GatewaySwaggerResourcesProvider implements SwaggerResourcesProvider { 19 | public static final String API_URI = "/v2/api-docs"; 20 | @Autowired 21 | private RouteLocator routeLocator; 22 | @Autowired 23 | private GatewayProperties gatewayProperties; 24 | 25 | 26 | @Override 27 | public List get() { 28 | List resources = new ArrayList<>(); 29 | List routes = new ArrayList<>(); 30 | routeLocator.getRoutes().subscribe(route -> routes.add(route.getId())); 31 | gatewayProperties.getRoutes().stream().filter(routeDefinition -> routes.contains(routeDefinition.getId())) 32 | .forEach(routeDefinition -> routeDefinition.getPredicates().stream() 33 | .filter(predicateDefinition -> ("Path").equalsIgnoreCase(predicateDefinition.getName())) 34 | .forEach(predicateDefinition -> resources.add(swaggerResource(routeDefinition.getId(), 35 | predicateDefinition.getArgs().get(NameUtils.GENERATED_NAME_PREFIX + "0") 36 | .replace("/**", API_URI))))); 37 | return resources; 38 | } 39 | 40 | private SwaggerResource swaggerResource(String name, String location) { 41 | SwaggerResource swaggerResource = new SwaggerResource(); 42 | swaggerResource.setName(name); 43 | swaggerResource.setLocation(location); 44 | swaggerResource.setSwaggerVersion("2.0"); 45 | return swaggerResource; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/controller/RoleController.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.controller; 2 | 3 | import io.vickze.auth.constant.GlobalConstant; 4 | import io.vickze.auth.domain.DO.MenuResourceDO; 5 | import io.vickze.auth.domain.DO.RoleDO; 6 | import io.vickze.auth.domain.DTO.AssignMenuResourceDTO; 7 | import io.vickze.auth.domain.DTO.RoleQueryDTO; 8 | import io.vickze.auth.service.RoleService; 9 | import io.vickze.common.validation.Insert; 10 | import io.vickze.common.validation.Update; 11 | import org.apache.commons.lang3.tuple.Pair; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.validation.annotation.Validated; 14 | import org.springframework.web.bind.annotation.*; 15 | import javax.servlet.http.HttpServletResponse; 16 | import java.util.List; 17 | 18 | /** 19 | * 角色 20 | * 21 | * @author vick.zeng 22 | * @email zyk@yk95.top 23 | * @create 2019-04-16 11:18:06 24 | */ 25 | @RestController 26 | @RequestMapping("/role") 27 | public class RoleController { 28 | 29 | @Autowired 30 | private RoleService roleService; 31 | 32 | @GetMapping 33 | public List list(RoleQueryDTO queryDTO, HttpServletResponse response) { 34 | Pair, Long> result = roleService.list(queryDTO); 35 | response.addHeader("X-Total-Count", String.valueOf(result.getValue())); 36 | return result.getKey(); 37 | } 38 | 39 | @GetMapping("/{id}") 40 | public RoleDO get(@PathVariable("id") Long id) { 41 | return roleService.get(id); 42 | } 43 | 44 | @PostMapping 45 | public void insert(@RequestBody @Validated(Insert.class) RoleDO role) { 46 | roleService.insert(role); 47 | } 48 | 49 | @PutMapping 50 | public void update(@RequestBody @Validated(Update.class) RoleDO role) { 51 | roleService.update(role); 52 | } 53 | 54 | @DeleteMapping 55 | public void delete(@RequestBody Long... ids) { 56 | roleService.delete(ids); 57 | } 58 | 59 | @PostMapping("/assignMenuResource") 60 | public void assignMenuResource(@RequestBody AssignMenuResourceDTO assignMenuResourceDTO) { 61 | roleService.assignMenuResource(assignMenuResourceDTO); 62 | } 63 | 64 | 65 | @GetMapping("/menuResource") 66 | public List getMenuResources(@RequestParam Long systemId, @RequestParam Long roleId) { 67 | return roleService.getMenuResources(systemId, roleId); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-client/src/main/java/io/vickze/auth/resovler/AuthUserHandlerMethodArgumentResolver.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.resovler; 2 | 3 | 4 | import io.vickze.auth.client.TokenClient; 5 | import io.vickze.auth.constant.TokenConstant; 6 | import io.vickze.auth.domain.DTO.AuthUserDTO; 7 | import io.vickze.auth.exception.UnauthorizedException; 8 | import lombok.extern.slf4j.Slf4j; 9 | import org.apache.commons.lang3.StringUtils; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 12 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 13 | import org.springframework.core.MethodParameter; 14 | import org.springframework.stereotype.Component; 15 | import org.springframework.web.bind.support.WebDataBinderFactory; 16 | import org.springframework.web.context.request.NativeWebRequest; 17 | import org.springframework.web.method.support.HandlerMethodArgumentResolver; 18 | import org.springframework.web.method.support.ModelAndViewContainer; 19 | 20 | /** 21 | * @author vick.zeng 22 | * @email zyk@yk95.top 23 | * @date 2017-12-12 15:41 24 | */ 25 | @Component 26 | @Slf4j 27 | public class AuthUserHandlerMethodArgumentResolver implements HandlerMethodArgumentResolver { 28 | @Autowired 29 | private TokenClient tokenClient; 30 | 31 | public AuthUserHandlerMethodArgumentResolver() { 32 | log.debug("AuthUserHandlerMethodArgumentResolver init."); 33 | } 34 | 35 | @Override 36 | public boolean supportsParameter(MethodParameter methodParameter) { 37 | return methodParameter.getParameterType().isAssignableFrom(AuthUserDTO.class) 38 | && methodParameter.hasParameterAnnotation(AuthUser.class); 39 | } 40 | 41 | @Override 42 | public Object resolveArgument(MethodParameter methodParameter, ModelAndViewContainer modelAndViewContainer, 43 | NativeWebRequest nativeWebRequest, WebDataBinderFactory webDataBinderFactory) throws Exception { 44 | 45 | //header 46 | String token = nativeWebRequest.getHeader(TokenConstant.TOKEN_HEADER); 47 | if (StringUtils.isBlank(token)) { 48 | //url 49 | token = nativeWebRequest.getParameter(TokenConstant.TOKEN_HEADER); 50 | } 51 | if (StringUtils.isBlank(token)) { 52 | throw new UnauthorizedException(false); 53 | } 54 | 55 | return tokenClient.validate(token); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /vickze-gateway/src/main/java/io/vickze/gateway/swagger/SwaggerConfig.java: -------------------------------------------------------------------------------- 1 | package io.vickze.gateway.swagger; 2 | 3 | 4 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import springfox.documentation.builders.ApiInfoBuilder; 8 | import springfox.documentation.builders.PathSelectors; 9 | import springfox.documentation.builders.RequestHandlerSelectors; 10 | import springfox.documentation.service.*; 11 | import springfox.documentation.spi.DocumentationType; 12 | import springfox.documentation.spi.service.contexts.SecurityContext; 13 | import springfox.documentation.spring.web.plugins.Docket; 14 | import springfox.documentation.swagger2.annotations.EnableSwagger2WebFlux; 15 | 16 | import java.util.List; 17 | 18 | import static com.google.common.collect.Lists.newArrayList; 19 | 20 | @ConditionalOnProperty( 21 | name = {"swagger.enabled"}, 22 | matchIfMissing = true 23 | ) 24 | @Configuration 25 | @EnableSwagger2WebFlux 26 | public class SwaggerConfig { 27 | 28 | @Bean 29 | public Docket createRestApi() { 30 | return new Docket(DocumentationType.SWAGGER_2) 31 | .apiInfo(apiInfo()) 32 | .select() 33 | .apis(RequestHandlerSelectors.none()) 34 | .paths(PathSelectors.any()) 35 | .build() 36 | .securitySchemes(securitySchemes()) 37 | .securityContexts(securityContexts()); 38 | } 39 | 40 | private ApiInfo apiInfo() { 41 | return new ApiInfoBuilder() 42 | .contact(new Contact("vick.zeng", "https://blog.yk95.top/", "zyk@yk95.top")) 43 | .build(); 44 | } 45 | 46 | private List securitySchemes() { 47 | return newArrayList( 48 | new ApiKey("Authorization", "Authorization", "header")); 49 | } 50 | 51 | private List securityContexts() { 52 | return newArrayList( 53 | SecurityContext.builder() 54 | .securityReferences(defaultAuth()) 55 | .forPaths(PathSelectors.regex("/*.*")) 56 | .build() 57 | ); 58 | } 59 | 60 | private List defaultAuth() { 61 | AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything"); 62 | AuthorizationScope[] authorizationScopes = new AuthorizationScope[1]; 63 | authorizationScopes[0] = authorizationScope; 64 | return newArrayList( 65 | new SecurityReference("Authorization", authorizationScopes)); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /vickze-sso/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | vickze-cloud-admin 7 | io.vickze 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | vickze-sso 13 | 14 | 15 | 16 | io.vickze 17 | vickze-common 18 | 19 | 20 | io.vickze 21 | vickze-auth-client 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-web 26 | 27 | 28 | org.springframework.cloud 29 | spring-cloud-starter-alibaba-nacos-discovery 30 | 31 | 32 | org.springframework.cloud 33 | spring-cloud-starter-alibaba-nacos-config 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-starter-actuator 38 | 39 | 40 | io.micrometer 41 | micrometer-registry-prometheus 42 | 43 | 44 | 45 | 46 | io.springfox 47 | springfox-swagger-ui 48 | 49 | 50 | io.springfox 51 | springfox-swagger2 52 | 53 | 54 | 55 | 56 | 57 | 58 | org.springframework.boot 59 | spring-boot-maven-plugin 60 | 61 | 62 | 63 | 64 | 65 | 66 | public 67 | aliyun nexus 68 | http://maven.aliyun.com/nexus/content/groups/public/ 69 | 70 | 71 | -------------------------------------------------------------------------------- /vickze-sso/src/main/java/io/vickze/sso/swagger/SwaggerConfig.java: -------------------------------------------------------------------------------- 1 | package io.vickze.sso.swagger; 2 | 3 | 4 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import springfox.documentation.builders.ApiInfoBuilder; 8 | import springfox.documentation.builders.ParameterBuilder; 9 | import springfox.documentation.builders.PathSelectors; 10 | import springfox.documentation.builders.RequestHandlerSelectors; 11 | import springfox.documentation.schema.ModelRef; 12 | import springfox.documentation.service.*; 13 | import springfox.documentation.spi.DocumentationType; 14 | import springfox.documentation.spi.service.contexts.SecurityContext; 15 | import springfox.documentation.spring.web.plugins.Docket; 16 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 17 | 18 | import java.util.List; 19 | 20 | import static com.google.common.collect.Lists.newArrayList; 21 | 22 | @ConditionalOnProperty( 23 | name = {"swagger.enabled"}, 24 | matchIfMissing = true 25 | ) 26 | @Configuration 27 | @EnableSwagger2 28 | public class SwaggerConfig { 29 | 30 | @Bean 31 | public Docket createRestApi() { 32 | return new Docket(DocumentationType.SWAGGER_2) 33 | .apiInfo(apiInfo()) 34 | .select() 35 | .apis(RequestHandlerSelectors.basePackage("io.vickze")) 36 | .paths(PathSelectors.any()) 37 | .build() 38 | .securitySchemes(securitySchemes()) 39 | .securityContexts(securityContexts()); 40 | } 41 | 42 | 43 | 44 | private ApiInfo apiInfo() { 45 | return new ApiInfoBuilder() 46 | .contact(new Contact("vick.zeng", "https://blog.yk95.top/", "zyk@yk95.top")) 47 | .build(); 48 | } 49 | 50 | private List securitySchemes() { 51 | return newArrayList( 52 | new ApiKey("Authorization", "Authorization", "header")); 53 | } 54 | 55 | private List securityContexts() { 56 | return newArrayList( 57 | SecurityContext.builder() 58 | .securityReferences(defaultAuth()) 59 | .forPaths(PathSelectors.regex("/*.*")) 60 | .build() 61 | ); 62 | } 63 | 64 | private List defaultAuth() { 65 | AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything"); 66 | AuthorizationScope[] authorizationScopes = new AuthorizationScope[1]; 67 | authorizationScopes[0] = authorizationScope; 68 | return newArrayList( 69 | new SecurityReference("Authorization", authorizationScopes)); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /vickze-generator/src/main/java/io/vickze/generator/util/GeneratorUtil.java: -------------------------------------------------------------------------------- 1 | package io.vickze.generator.util; 2 | 3 | 4 | import freemarker.template.Template; 5 | import freemarker.template.TemplateException; 6 | import org.apache.commons.configuration.Configuration; 7 | import org.apache.commons.configuration.ConfigurationException; 8 | import org.apache.commons.configuration.PropertiesConfiguration; 9 | import org.apache.commons.lang.StringUtils; 10 | import org.apache.commons.lang.WordUtils; 11 | import org.apache.velocity.VelocityContext; 12 | import org.apache.velocity.app.Velocity; 13 | 14 | import java.io.IOException; 15 | import java.io.StringReader; 16 | import java.io.StringWriter; 17 | import java.util.Map; 18 | 19 | /** 20 | * 代码生成器工具类 21 | * 22 | * @author vick.zeng 23 | * @email 2512522383@qq.com 24 | * @create 2017-09-08 21:56 25 | */ 26 | public class GeneratorUtil { 27 | /** 28 | * 表名转换权限字符串 29 | */ 30 | public static String tableToPermission(String tableName) { 31 | return StringUtils.replace(tableName, "_", ":"); 32 | } 33 | 34 | /** 35 | * 列名转换成Java属性名 36 | */ 37 | public static String columnToJava(String columnName) { 38 | return WordUtils.capitalizeFully(columnName, new char[]{'_'}).replace("_", ""); 39 | } 40 | 41 | /** 42 | * 表名转换成Java类名 43 | */ 44 | public static String tableToJava(String tableName, String tablePrefix) { 45 | if (StringUtils.isNotBlank(tablePrefix)) { 46 | tableName = tableName.replace(tablePrefix, ""); 47 | } 48 | return columnToJava(tableName); 49 | } 50 | 51 | /** 52 | * 获取配置信息 53 | */ 54 | public static Configuration getConfig() { 55 | try { 56 | return new PropertiesConfiguration("generator.properties"); 57 | } catch (ConfigurationException e) { 58 | throw new RuntimeException("获取配置文件失败,", e); 59 | } 60 | } 61 | 62 | /** 63 | * 获取文件名 64 | */ 65 | public static String getFileName(VelocityContext velocityContext, String template, String className, String classname, String packageName) { 66 | // 输出流 67 | StringWriter writer = new StringWriter(); 68 | 69 | // 转换输出 70 | Velocity.evaluate(velocityContext, writer, "", template); // 关键方法 71 | 72 | return writer.toString(); 73 | } 74 | 75 | /** 76 | * 获取文件名 77 | */ 78 | public static String getFileName(freemarker.template.Configuration configuration, String fileName, Map config) throws IOException, TemplateException { 79 | // 输出流 80 | StringWriter writer = new StringWriter(); 81 | 82 | // 转换输出 83 | new Template("template", new StringReader(fileName), configuration).process(config, writer); // 关键方法 84 | 85 | 86 | return writer.toString(); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-client/src/main/java/io/vickze/auth/exception/AuthExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.exception; 2 | 3 | 4 | import io.vickze.common.domain.DTO.BusinessResultDTO; 5 | import io.vickze.common.domain.DTO.MessageResultDTO; 6 | import io.vickze.common.exception.BusinessException; 7 | import io.vickze.common.exception.FeignExceptionErrorDecoder; 8 | import io.vickze.common.exception.MessageException; 9 | import lombok.extern.slf4j.Slf4j; 10 | import org.springframework.http.HttpStatus; 11 | import org.springframework.web.bind.annotation.ExceptionHandler; 12 | import org.springframework.web.bind.annotation.ResponseStatus; 13 | import org.springframework.web.bind.annotation.RestControllerAdvice; 14 | 15 | /** 16 | * 异常处理器 17 | * 18 | * @author vick.zeng 19 | * @email zyk@yk95.top 20 | * @create 2017-09-08 22:07 21 | */ 22 | @RestControllerAdvice 23 | @Slf4j 24 | public class AuthExceptionHandler { 25 | 26 | public AuthExceptionHandler() { 27 | log.debug("AuthExceptionHandler init."); 28 | } 29 | 30 | @ResponseStatus(HttpStatus.UNAUTHORIZED) 31 | @ExceptionHandler(UnauthorizedException.class) 32 | public FeignExceptionErrorDecoder.ExceptionInfo handleUnauthorizedException(UnauthorizedException e) { 33 | FeignExceptionErrorDecoder.ExceptionInfo exceptionInfo = new FeignExceptionErrorDecoder.ExceptionInfo(); 34 | if (e.isSerializeExceptionClass()) { 35 | exceptionInfo.setExceptionClass(e.getClass().getName()); 36 | } 37 | exceptionInfo.setMessage(e.getMessage()); 38 | return exceptionInfo; 39 | } 40 | 41 | @ResponseStatus(HttpStatus.FORBIDDEN) 42 | @ExceptionHandler(ForbiddenException.class) 43 | public FeignExceptionErrorDecoder.ExceptionInfo handleForbiddenException(ForbiddenException e) { 44 | FeignExceptionErrorDecoder.ExceptionInfo exceptionInfo = new FeignExceptionErrorDecoder.ExceptionInfo(); 45 | if (e.isSerializeExceptionClass()) { 46 | exceptionInfo.setExceptionClass(e.getClass().getName()); 47 | } 48 | exceptionInfo.setMessage(e.getMessage()); 49 | return exceptionInfo; 50 | } 51 | 52 | @ResponseStatus(HttpStatus.BAD_REQUEST) 53 | @ExceptionHandler(MessageException.class) 54 | public MessageResultDTO handleMsgException(MessageException e) { 55 | MessageResultDTO messageResultDTO = new MessageResultDTO(); 56 | messageResultDTO.setMessage(e.getMessage()); 57 | return messageResultDTO; 58 | } 59 | 60 | 61 | @ExceptionHandler(BusinessException.class) 62 | public BusinessResultDTO handleBusinessException(BusinessException e) { 63 | BusinessResultDTO businessResultDTO = new BusinessResultDTO(); 64 | businessResultDTO.setCode(e.getCode()); 65 | businessResultDTO.setMsg(e.getMessage()); 66 | return businessResultDTO; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /vickze-generator/src/test/java/io/vickze/TemplateTest.java: -------------------------------------------------------------------------------- 1 | package io.vickze; 2 | 3 | import org.apache.velocity.VelocityContext; 4 | import org.apache.velocity.app.VelocityEngine; 5 | import org.junit.Test; 6 | import org.yaml.snakeyaml.Yaml; 7 | 8 | import java.io.IOException; 9 | import java.io.StringReader; 10 | import java.io.StringWriter; 11 | import java.util.Date; 12 | import java.util.HashMap; 13 | import java.util.Map; 14 | import java.util.Properties; 15 | 16 | public class TemplateTest { 17 | 18 | @Test 19 | public void propertiesTest() throws IOException { 20 | Properties properties = new Properties(); 21 | String stringBuilder = "test1=111" + System.getProperty("line.separator") + 22 | "test2.1=2221" + System.getProperty("line.separator") + 23 | "test2.2=2222" + System.getProperty("line.separator") + 24 | "test3=333" + System.getProperty("line.separator") + 25 | "tes4=444" + System.getProperty("line.separator") + 26 | "test5=555" + System.getProperty("line.separator"); 27 | properties.load(new StringReader(stringBuilder)); 28 | System.out.println(properties); 29 | } 30 | 31 | @Test 32 | public void yamlTest() { 33 | Yaml yaml = new Yaml(); 34 | String stringBuilder = "test1: 111" + System.getProperty("line.separator") + 35 | "test2: 222" + System.getProperty("line.separator") + 36 | "test3.1: 333" + System.getProperty("line.separator") + 37 | "test4: " + System.getProperty("line.separator") + 38 | " test5: 445" + System.getProperty("line.separator"); 39 | Map map = yaml.load(stringBuilder); 40 | System.out.println(map); 41 | } 42 | 43 | @Test 44 | public void velocityTest() { 45 | // 初始化并取得Velocity引擎 46 | VelocityEngine ve = new VelocityEngine(); 47 | ve.init(); 48 | // 取得velocity的模版内容, 模板内容来自字符传 49 | String content = ""; 50 | content += "Welcome  $name  to Javayou.com! "; 51 | content += " today is  $date."; 52 | content += " a is  $test.a"; 53 | content += " b is  $test.b"; 54 | content += " c is  \"$test.1\""; 55 | 56 | // 取得velocity的上下文context 57 | VelocityContext context = new VelocityContext(); 58 | 59 | // 把数据填入上下文 60 | context.put("name", "javaboy2012"); 61 | 62 | context.put("date", (new Date()).toString()); 63 | 64 | Map map = new HashMap<>(); 65 | map.put("a", "a"); 66 | map.put("b", "b"); 67 | context.put("test", map); 68 | context.put("test.1", "c"); 69 | 70 | // 输出流 71 | StringWriter writer = new StringWriter(); 72 | 73 | // 转换输出 74 | 75 | ve.evaluate(context, writer, "", content); // 关键方法 76 | 77 | System.out.println(writer.toString()); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/service/impl/SystemServiceImpl.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.service.impl; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 4 | import com.baomidou.mybatisplus.core.metadata.IPage; 5 | import io.vickze.auth.mapper.SystemMapper; 6 | import io.vickze.common.domain.RPage; 7 | import io.vickze.auth.domain.DO.SystemDO; 8 | import io.vickze.auth.domain.DTO.SystemQueryDTO; 9 | import io.vickze.common.enums.DBOrder; 10 | import io.vickze.auth.service.SystemService; 11 | import java.util.ArrayList; 12 | import org.apache.commons.lang3.tuple.Pair; 13 | import org.springframework.beans.BeanUtils; 14 | import org.apache.commons.lang.StringUtils; 15 | import org.springframework.beans.factory.annotation.Autowired; 16 | import org.springframework.stereotype.Service; 17 | import org.springframework.util.CollectionUtils; 18 | import java.util.Arrays; 19 | import java.util.Collection; 20 | import java.util.List; 21 | 22 | /** 23 | * 系统 24 | * 25 | * @author vick.zeng 26 | * @email zyk@yk95.top 27 | * @create 2019-05-15 14:52:47 28 | */ 29 | @Service 30 | public class SystemServiceImpl implements SystemService { 31 | @Autowired 32 | private SystemMapper systemMapper; 33 | 34 | @Override 35 | public Pair, Long> list(SystemQueryDTO queryDTO) { 36 | IPage page = new RPage<>(queryDTO.getOffset(), queryDTO.getLimit()); 37 | QueryWrapper wrapper = new QueryWrapper<>(); 38 | if (StringUtils.isNotBlank(queryDTO.getName())) { 39 | wrapper = wrapper.eq("name", queryDTO.getName()); 40 | } 41 | if (StringUtils.isNotBlank(queryDTO.getKey())) { 42 | wrapper = wrapper.eq("key", queryDTO.getKey()); 43 | } 44 | if (queryDTO.getField() != null) { 45 | wrapper = wrapper.orderBy(true, DBOrder.ASC.name().equals(queryDTO.getOrder()), 46 | com.baomidou.mybatisplus.core.toolkit.StringUtils.camelToUnderline(queryDTO.getField())); 47 | } else { 48 | wrapper = wrapper.orderByDesc("id"); 49 | } 50 | systemMapper.selectPage(page, wrapper); 51 | return Pair.of(page.getRecords(), page.getTotal()); 52 | } 53 | 54 | @Override 55 | public SystemDO get(Long id) { 56 | return systemMapper.selectById(id); 57 | } 58 | 59 | @Override 60 | public void insert(SystemDO systemDO) { 61 | systemMapper.insert(systemDO); 62 | } 63 | 64 | @Override 65 | public void update(SystemDO systemDO) { 66 | systemMapper.updateById(systemDO); 67 | } 68 | 69 | @Override 70 | public void delete(Long... ids) { 71 | systemMapper.deleteBatchIds(Arrays.asList(ids)); 72 | } 73 | 74 | @Override 75 | public SystemDO selectByKey(String systemKey) { 76 | QueryWrapper wrapper = new QueryWrapper<>(); 77 | wrapper.eq("`key`", systemKey); 78 | return systemMapper.selectOne(wrapper); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /vickze-generator/src/main/java/io/vickze/generator/service/impl/TemplateServiceImpl.java: -------------------------------------------------------------------------------- 1 | package io.vickze.generator.service.impl; 2 | 3 | import com.baomidou.dynamic.datasource.annotation.DS; 4 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 5 | import com.baomidou.mybatisplus.core.metadata.IPage; 6 | import io.vickze.generator.domain.DO.TemplateDO; 7 | import io.vickze.generator.service.TemplateService; 8 | import io.vickze.generator.mapper.TemplateMapper; 9 | import io.vickze.common.domain.RPage; 10 | import io.vickze.generator.domain.DTO.TemplateQueryDTO; 11 | import io.vickze.common.enums.DBOrder; 12 | import org.apache.commons.lang3.tuple.Pair; 13 | import org.apache.commons.collections.CollectionUtils; 14 | import org.apache.commons.lang.StringUtils; 15 | import org.springframework.beans.factory.annotation.Autowired; 16 | import org.springframework.stereotype.Service; 17 | 18 | import java.util.Arrays; 19 | import java.util.Collection; 20 | import java.util.List; 21 | 22 | /** 23 | * 模版 24 | * 25 | * @author vick.zeng 26 | * @email zyk@yk95.top 27 | * @create 2019-03-29 16:24:22 28 | */ 29 | @Service 30 | @DS("master") 31 | public class TemplateServiceImpl implements TemplateService { 32 | @Autowired 33 | private TemplateMapper templateMapper; 34 | 35 | @Override 36 | public Pair, Long> list(TemplateQueryDTO queryDTO) { 37 | IPage page = new RPage<>(queryDTO.getOffset(), queryDTO.getLimit()); 38 | QueryWrapper wrapper = new QueryWrapper<>(); 39 | if (StringUtils.isNotBlank(queryDTO.getName())) { 40 | wrapper = wrapper.like("name", queryDTO.getName()); 41 | } 42 | if (CollectionUtils.isNotEmpty(queryDTO.getType())) { 43 | wrapper = wrapper.in("type", queryDTO.getType()); 44 | } 45 | if (queryDTO.getField() != null) { 46 | wrapper = wrapper.orderBy(true, DBOrder.ASC.name().equals(queryDTO.getOrder()), 47 | com.baomidou.mybatisplus.core.toolkit.StringUtils.camelToUnderline(queryDTO.getField())); 48 | } else { 49 | wrapper = wrapper.orderByDesc("id"); 50 | } 51 | templateMapper.selectPage(page, wrapper); 52 | return Pair.of(page.getRecords(), page.getTotal()); 53 | } 54 | 55 | @Override 56 | public TemplateDO get(Long id) { 57 | return templateMapper.selectById(id); 58 | } 59 | 60 | @Override 61 | public void insert(TemplateDO templateDO) { 62 | templateMapper.insert(templateDO); 63 | } 64 | 65 | @Override 66 | public void update(TemplateDO templateDO) { 67 | templateMapper.updateById(templateDO); 68 | } 69 | 70 | @Override 71 | public void delete(Long... ids) { 72 | templateMapper.deleteBatchIds(Arrays.asList(ids)); 73 | } 74 | 75 | @Override 76 | public Collection listByIds(List templateIds) { 77 | return templateMapper.selectBatchIds(templateIds); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.controller; 2 | 3 | import io.vickze.auth.client.UserClient; 4 | import io.vickze.auth.constant.GlobalConstant; 5 | import io.vickze.auth.domain.DTO.*; 6 | import io.vickze.auth.resovler.AuthUser; 7 | import io.vickze.auth.service.UserService; 8 | import io.vickze.common.validation.Insert; 9 | import io.vickze.common.validation.Update; 10 | import lombok.extern.slf4j.Slf4j; 11 | import org.apache.commons.lang3.tuple.Pair; 12 | import org.springframework.beans.BeanUtils; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.beans.factory.annotation.Value; 15 | import org.springframework.validation.annotation.Validated; 16 | import org.springframework.web.bind.annotation.*; 17 | 18 | import javax.servlet.http.HttpServletResponse; 19 | import java.util.List; 20 | 21 | /** 22 | * 用户 23 | * 24 | * @author vick.zeng 25 | * @email zyk@yk95.top 26 | * @create 2019-04-16 11:18:06 27 | */ 28 | @Slf4j 29 | @RestController 30 | @RequestMapping("/user") 31 | public class UserController implements UserClient { 32 | 33 | @Autowired 34 | private UserService userService; 35 | 36 | @GetMapping 37 | public List list(UserQueryDTO queryDTO, HttpServletResponse response) { 38 | Pair, Long> result = userService.list(queryDTO); 39 | response.addHeader("X-Total-Count", String.valueOf(result.getValue())); 40 | return result.getKey(); 41 | } 42 | 43 | @GetMapping("/{id}") 44 | public UserDTO get(@PathVariable("id") Long id) { 45 | return userService.get(id); 46 | } 47 | 48 | @PostMapping 49 | public void insert(@RequestBody @Validated(Insert.class) UserDTO user) { 50 | userService.insert(user); 51 | } 52 | 53 | @PutMapping 54 | public void update(@RequestBody @Validated(Update.class) UserDTO user) { 55 | userService.update(user); 56 | } 57 | 58 | @DeleteMapping 59 | public void delete(@RequestBody Long... ids) { 60 | userService.delete(ids); 61 | } 62 | 63 | @PostMapping("/token") 64 | public TokenDTO create(@RequestHeader(GlobalConstant.SYSTEM_HEADER) String systemKey, @RequestBody CreateTokenDTO createTokenDTO) { 65 | createTokenDTO.setSystemKey(systemKey); 66 | return userService.createToken(createTokenDTO); 67 | } 68 | 69 | @GetMapping("/_current") // _ 字符防止获取接口权限的时候被 /user/{id}匹配到,另外也可以配置忽略该接口权限 70 | public CurrentUserDTO current(@AuthUser AuthUserDTO authUserDTO, 71 | @RequestHeader(GlobalConstant.SYSTEM_HEADER) String systemKey) { 72 | CurrentUserDTO currentUserDTO = new CurrentUserDTO(); 73 | BeanUtils.copyProperties(authUserDTO, currentUserDTO); 74 | currentUserDTO.setPermissions(userService.getMenuPermissions(systemKey, currentUserDTO.getUserId())); 75 | return currentUserDTO; 76 | } 77 | 78 | @Override 79 | public void checkSystemAccess(String systemKey, Long userId) { 80 | userService.checkSystemAccess(systemKey, userId); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /vickze-generator/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | #spring: 2 | # jpa: 3 | # show-sql: true 4 | # datasource: 5 | # dynamic: 6 | # primary: master #设置默认的数据源或者数据源组,默认值即为master 7 | # hikari: 8 | # max-pool-size: 15 9 | # is-auto-commit: true 10 | # idle-timeout: 30000 11 | # pool-name: DatebookHikariCP 12 | # max-lifetime: 1800000 13 | # connection-timeout: 30000 14 | # connection-test-query: SELECT 1 15 | # min-idle: 5 16 | # datasource: 17 | # master: 18 | # driverClassName: com.mysql.cj.jdbc.Driver 19 | # url: jdbc:mysql://${MASTER_MYSQL_HOST:localhost}:${MASTER_MYSQL_PORT:3306}/vickze_generator?serverTimezone=Asia/Shanghai&useSSL=true&allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8 20 | # username: root 21 | # password: 123456 22 | # #连接池的配置信息 23 | # type: com.zaxxer.hikari.HikariDataSource 24 | # generator: 25 | # driverClassName: com.mysql.cj.jdbc.Driver 26 | # url: jdbc:mysql://${GENERATOR_MYSQL_HOST:localhost}:${GENERATOR_MYSQL_PORT:3306}/vickze_auth?serverTimezone=Asia/Shanghai&useSSL=true&allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8 27 | # username: root 28 | # password: 123456 29 | # #连接池的配置信息 30 | # type: com.zaxxer.hikari.HikariDataSource 31 | # 32 | #mybatis-plus: 33 | # mapper-locations: classpath:mapper/**/*.xml 34 | # configuration: 35 | # map-underscore-to-camel-case: true #驼峰下划线转换 36 | # global-config: 37 | # db-config: 38 | # field-strategy: not_empty 39 | # logic-delete-value: 1 # 逻辑已删除值(默认为 1) 40 | # logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) 41 | # 42 | #logging: 43 | # file: ./log/vickze-generator.log 44 | # level: 45 | # io.vickze: DEBUG 46 | # com.alibaba.nacos.client.naming: ERROR 47 | # 48 | #management: 49 | # endpoints: 50 | # web: 51 | # exposure: 52 | # include: '*' 53 | # endpoint: 54 | # health: 55 | # show-details: ALWAYS 56 | # metrics: 57 | # tags: 58 | # application: ${spring.application.name} 59 | # 60 | # 61 | #feign: 62 | # hystrix: 63 | # enabled: true 64 | # httpclient: 65 | # enabled: false 66 | # okhttp: 67 | # enabled: true #使用okhttp,默认时 FeignExceptionErrorDecoder response body为null,原因是feign.Client类 connection.getErrorStream() 为null 68 | # read-timeout: 10000 #okhttp client超时时间配置 翻看源码发现,实际调用read-timeout、connect-timeout、followRedirects会被ribbon的覆盖 相关类LoadBalancerFeignClient 69 | # 70 | # 71 | ##负载均衡 72 | #ribbon: 73 | # OkToRetryOnAllOperations: false #对所有操作请求都进行重试,默认false 74 | # ReadTimeout: 5000 #负载均衡超时时间,默认值5000 75 | # ConnectTimeout: 3000 #ribbon请求连接的超时时间,默认值2000 76 | # MaxAutoRetries: 0 #对当前实例的重试次数,默认0 77 | # MaxAutoRetriesNextServer: 1 #对切换实例的重试次数,默认1 78 | # 79 | ##熔断 80 | #hystrix: 81 | # command: 82 | # default: #default全局有效,service id指定应用有效 83 | # execution: 84 | # timeout: 85 | # #如果enabled设置为false,则请求超时交给ribbon控制,为true,则超时作为熔断根据 86 | # #尝试了下发现需要配置ribbon超时时间才会生效 87 | # enabled: false 88 | # isolation: 89 | # thread: 90 | # timeoutInMilliseconds: 1000 #断路器超时时间,默认1000ms -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | #spring: 2 | # datasource: 3 | # driverClassName: com.mysql.cj.jdbc.Driver 4 | # url: jdbc:mysql://${MYSQL_HOST:localhost}:${MYSQL_PORT:3306}/vickze_auth?serverTimezone=Asia/Shanghai&useSSL=true&allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8 5 | # username: root 6 | # password: 123456 7 | # #连接池的配置信息 8 | # type: com.zaxxer.hikari.HikariDataSource 9 | # redis: 10 | # host: ${REDIS_HOST:localhost} 11 | # port: ${REDIS_PORT:6379} 12 | # database: ${REDIS_DB:0} 13 | # 14 | #mybatis-plus: 15 | # mapper-locations: classpath:mapper/**/*.xml 16 | # configuration: 17 | # map-underscore-to-camel-case: true #驼峰下划线转换 18 | # global-config: 19 | # db-config: 20 | # field-strategy: not_empty 21 | # logic-delete-value: 1 # 逻辑已删除值(默认为 1) 22 | # logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) 23 | # 24 | #logging: 25 | # file: ./log/vickze-auth.log 26 | # #file.max-size: 10MB 27 | # level: 28 | # io.vickze: DEBUG 29 | # com.alibaba.nacos.client.naming: ERROR 30 | # 31 | #token: 32 | # jwt: 33 | # enabled: false 34 | # secret: aqwe~!@ZXCSQlkjiop 35 | # expire: 43200 #12小时 36 | # uuid: 37 | # enabled: true 38 | # expire: 43200 #12小时 39 | # updateExpire: true #访问时更新expire 40 | # 41 | # 42 | #auth: 43 | # check-permission: 44 | # ignore-interfaces: 45 | # - method: GET 46 | # uri: /api/auth/v2/api-docs 47 | # - method: GET 48 | # uri: /api/generator/v2/api-docs 49 | # - method: GET 50 | # uri: /api/sso/v2/api-docs 51 | # - method: GET 52 | # uri: /api/sso/validateService 53 | # - method: GET 54 | # uri: /api/sso/validateToken 55 | # #不需要登录但仍然需要System-Key 56 | # ignore-interfaces-without-login: 57 | # - method: POST 58 | # uri: /api/auth/user/token 59 | # 60 | #management: 61 | # endpoints: 62 | # web: 63 | # exposure: 64 | # include: '*' 65 | # endpoint: 66 | # health: 67 | # show-details: ALWAYS 68 | # metrics: 69 | # tags: 70 | # application: ${spring.application.name} 71 | # 72 | # 73 | #feign: 74 | # hystrix: 75 | # enabled: true 76 | # httpclient: 77 | # enabled: false 78 | # okhttp: 79 | # enabled: true #使用okhttp,默认时 FeignExceptionErrorDecoder response body为null,原因是feign.Client类 connection.getErrorStream() 为null 80 | # read-timeout: 10000 #okhttp client超时时间配置 翻看源码发现,实际调用read-timeout、connect-timeout、followRedirects会被ribbon的覆盖 相关类LoadBalancerFeignClient 81 | # 82 | # 83 | ##负载均衡 84 | #ribbon: 85 | # OkToRetryOnAllOperations: false #对所有操作请求都进行重试,默认false 86 | # ReadTimeout: 5000 #负载均衡超时时间,默认值5000 87 | # ConnectTimeout: 3000 #ribbon请求连接的超时时间,默认值2000 88 | # MaxAutoRetries: 0 #对当前实例的重试次数,默认0 89 | # MaxAutoRetriesNextServer: 1 #对切换实例的重试次数,默认1 90 | # 91 | ##熔断 92 | #hystrix: 93 | # command: 94 | # default: #default全局有效,service id指定应用有效 95 | # execution: 96 | # timeout: 97 | # #如果enabled设置为false,则请求超时交给ribbon控制,为true,则超时作为熔断根据 98 | # #尝试了下发现需要配置ribbon超时时间才会生效 99 | # enabled: false 100 | # isolation: 101 | # thread: 102 | # timeoutInMilliseconds: 1000 #断路器超时时间,默认1000ms 103 | -------------------------------------------------------------------------------- /vickze-common/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | vickze-cloud-admin 7 | io.vickze 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | vickze-common 13 | 14 | 15 | 16 | 17 | 18 | org.apache.commons 19 | commons-lang3 20 | 21 | 22 | 23 | org.slf4j 24 | slf4j-api 25 | 26 | 27 | 28 | 29 | org.apache.commons 30 | commons-csv 31 | 32 | 33 | commons-io 34 | commons-io 35 | 36 | 37 | com.fasterxml.jackson.core 38 | jackson-databind 39 | 40 | 41 | com.fasterxml.jackson.datatype 42 | jackson-datatype-jsr310 43 | 44 | 45 | org.springframework 46 | spring-core 47 | 48 | 49 | org.springframework 50 | spring-beans 51 | 52 | 53 | javax.validation 54 | validation-api 55 | 56 | 57 | com.baomidou 58 | mybatis-plus-core 59 | 60 | 61 | org.springframework.data 62 | spring-data-commons 63 | 64 | 65 | com.netflix.hystrix 66 | hystrix-core 67 | 68 | 69 | io.github.openfeign 70 | feign-core 71 | 72 | 73 | org.springframework 74 | spring-context 75 | 76 | 77 | 78 | 79 | 80 | 81 | public 82 | aliyun nexus 83 | http://maven.aliyun.com/nexus/content/groups/public/ 84 | 85 | 86 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/swagger/SwaggerConfig.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.swagger; 2 | 3 | 4 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import springfox.documentation.builders.ApiInfoBuilder; 8 | import springfox.documentation.builders.ParameterBuilder; 9 | import springfox.documentation.builders.PathSelectors; 10 | import springfox.documentation.builders.RequestHandlerSelectors; 11 | import springfox.documentation.schema.ModelRef; 12 | import springfox.documentation.service.*; 13 | import springfox.documentation.spi.DocumentationType; 14 | import springfox.documentation.spi.service.contexts.SecurityContext; 15 | import springfox.documentation.spring.web.plugins.Docket; 16 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 17 | 18 | import java.util.List; 19 | 20 | import static com.google.common.collect.Lists.newArrayList; 21 | 22 | @ConditionalOnProperty( 23 | name = {"swagger.enabled"}, 24 | matchIfMissing = true 25 | ) 26 | @Configuration 27 | @EnableSwagger2 28 | public class SwaggerConfig { 29 | 30 | @Bean 31 | public Docket createRestApi() { 32 | return new Docket(DocumentationType.SWAGGER_2) 33 | .apiInfo(apiInfo()) 34 | .select() 35 | .apis(RequestHandlerSelectors.basePackage("io.vickze")) 36 | .paths(PathSelectors.any()) 37 | .build() 38 | .globalOperationParameters(globalOperationParameters()) 39 | .securitySchemes(securitySchemes()) 40 | .securityContexts(securityContexts()); 41 | } 42 | 43 | private ApiInfo apiInfo() { 44 | return new ApiInfoBuilder() 45 | .contact(new Contact("vick.zeng", "https://blog.yk95.top/", "zyk@yk95.top")) 46 | .build(); 47 | } 48 | 49 | 50 | 51 | private List globalOperationParameters() { 52 | return newArrayList(new ParameterBuilder() 53 | .name("System-Key") 54 | .description("System Key") 55 | .modelRef(new ModelRef("string")) 56 | .parameterType("header") 57 | .required(true) 58 | .defaultValue("vickze-auth") 59 | .hidden(true).parameterAccess("READ_ONLY") 60 | .build()); 61 | } 62 | 63 | private List securitySchemes() { 64 | return newArrayList( 65 | new ApiKey("Authorization", "Authorization", "header")); 66 | } 67 | 68 | private List securityContexts() { 69 | return newArrayList( 70 | SecurityContext.builder() 71 | .securityReferences(defaultAuth()) 72 | .forPaths(PathSelectors.regex("/*.*")) 73 | .build() 74 | ); 75 | } 76 | 77 | private List defaultAuth() { 78 | AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything"); 79 | AuthorizationScope[] authorizationScopes = new AuthorizationScope[1]; 80 | authorizationScopes[0] = authorizationScope; 81 | return newArrayList( 82 | new SecurityReference("Authorization", authorizationScopes)); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /vickze-generator/src/main/java/io/vickze/generator/swagger/SwaggerConfig.java: -------------------------------------------------------------------------------- 1 | package io.vickze.generator.swagger; 2 | 3 | 4 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import springfox.documentation.builders.ApiInfoBuilder; 8 | import springfox.documentation.builders.ParameterBuilder; 9 | import springfox.documentation.builders.PathSelectors; 10 | import springfox.documentation.builders.RequestHandlerSelectors; 11 | import springfox.documentation.schema.ModelRef; 12 | import springfox.documentation.service.*; 13 | import springfox.documentation.spi.DocumentationType; 14 | import springfox.documentation.spi.service.contexts.SecurityContext; 15 | import springfox.documentation.spring.web.plugins.Docket; 16 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 17 | 18 | import java.util.Arrays; 19 | import java.util.List; 20 | 21 | import static com.google.common.collect.Lists.newArrayList; 22 | 23 | @ConditionalOnProperty( 24 | name = {"swagger.enabled"}, 25 | matchIfMissing = true 26 | ) 27 | @Configuration 28 | @EnableSwagger2 29 | public class SwaggerConfig { 30 | 31 | @Bean 32 | public Docket createRestApi() { 33 | return new Docket(DocumentationType.SWAGGER_2) 34 | .apiInfo(apiInfo()) 35 | .select() 36 | .apis(RequestHandlerSelectors.basePackage("io.vickze")) 37 | .paths(PathSelectors.any()) 38 | .build() 39 | .globalOperationParameters(globalOperationParameters()) 40 | .securitySchemes(securitySchemes()) 41 | .securityContexts(securityContexts()); 42 | } 43 | 44 | 45 | 46 | private ApiInfo apiInfo() { 47 | return new ApiInfoBuilder() 48 | .contact(new Contact("vick.zeng", "https://blog.yk95.top/", "zyk@yk95.top")) 49 | .build(); 50 | } 51 | 52 | private List globalOperationParameters() { 53 | return newArrayList(new ParameterBuilder() 54 | .name("System-Key") 55 | .description("System Key") 56 | .modelRef(new ModelRef("string")) 57 | .parameterType("header") 58 | .required(false) 59 | .defaultValue("vickze-generator") 60 | .hidden(true) 61 | .build()); 62 | } 63 | 64 | private List securitySchemes() { 65 | return newArrayList( 66 | new ApiKey("Authorization", "Authorization", "header")); 67 | } 68 | 69 | private List securityContexts() { 70 | return newArrayList( 71 | SecurityContext.builder() 72 | .securityReferences(defaultAuth()) 73 | .forPaths(PathSelectors.regex("/*.*")) 74 | .build() 75 | ); 76 | } 77 | 78 | private List defaultAuth() { 79 | AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything"); 80 | AuthorizationScope[] authorizationScopes = new AuthorizationScope[1]; 81 | authorizationScopes[0] = authorizationScope; 82 | return newArrayList( 83 | new SecurityReference("Authorization", authorizationScopes)); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /vickze-sso/src/main/java/io/vickze/sso/controller/SsoController.java: -------------------------------------------------------------------------------- 1 | package io.vickze.sso.controller; 2 | 3 | import io.vickze.auth.client.TokenClient; 4 | import io.vickze.auth.client.UserClient; 5 | import io.vickze.auth.constant.GlobalConstant; 6 | import io.vickze.auth.constant.TokenConstant; 7 | import io.vickze.auth.domain.DTO.AuthUserDTO; 8 | import io.vickze.auth.exception.ForbiddenException; 9 | import io.vickze.auth.exception.UnauthorizedException; 10 | import io.vickze.common.exception.MessageException; 11 | import io.vickze.sso.properties.SsoProperties; 12 | import org.apache.commons.lang3.StringUtils; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.http.HttpStatus; 15 | import org.springframework.web.bind.annotation.GetMapping; 16 | import org.springframework.web.bind.annotation.RequestHeader; 17 | import org.springframework.web.bind.annotation.RequestParam; 18 | import org.springframework.web.bind.annotation.RestController; 19 | 20 | import javax.servlet.http.HttpServletResponse; 21 | import java.net.MalformedURLException; 22 | import java.net.URL; 23 | import java.util.List; 24 | 25 | /** 26 | * @author vick.zeng 27 | * @email zyk@yk95.top 28 | * @create 2019-07-11 11:21 29 | */ 30 | @RestController 31 | public class SsoController { 32 | @Autowired 33 | private TokenClient tokenClient; 34 | @Autowired 35 | private UserClient userClient; 36 | @Autowired 37 | private SsoProperties ssoProperties; 38 | 39 | 40 | @GetMapping("/validateService") 41 | public void validateService(@RequestParam String systemKey, 42 | @RequestParam String service, HttpServletResponse response) throws MalformedURLException { 43 | URL url = new URL(service); 44 | String serviceOrigin = url.getProtocol() + "://" + url.getAuthority(); 45 | //可信任的地址列表 46 | List trustList = ssoProperties.getSystem().get(systemKey); 47 | if (trustList != null) { 48 | for (String trust : trustList) { 49 | if (trust.endsWith("/")) { 50 | trust = trust.substring(0, trust.lastIndexOf("/")); 51 | } 52 | if (trust.equals(serviceOrigin)) { 53 | //允许访问 54 | return; 55 | } 56 | } 57 | } 58 | 59 | //不允许访问 60 | response.setStatus(HttpStatus.FORBIDDEN.value()); 61 | } 62 | 63 | @GetMapping("/validateToken") 64 | public AuthUserDTO validateToken(@RequestHeader(GlobalConstant.SYSTEM_HEADER) String systemKey, 65 | @RequestHeader(TokenConstant.TOKEN_HEADER) String token, HttpServletResponse response) { 66 | if (StringUtils.isBlank(token)) { 67 | response.setStatus(HttpStatus.UNAUTHORIZED.value()); 68 | return null; 69 | } 70 | 71 | AuthUserDTO authUserDTO = tokenClient.validate(token); 72 | if (authUserDTO == null) { 73 | response.setStatus(HttpStatus.UNAUTHORIZED.value()); 74 | return null; 75 | } 76 | 77 | try { 78 | userClient.checkSystemAccess(systemKey, authUserDTO.getUserId()); 79 | } catch (ForbiddenException e) { 80 | throw new ForbiddenException(e.getMessage(), false); 81 | } catch (UnauthorizedException e) { 82 | throw new MessageException(GlobalConstant.SYSTEM_NOT_RESOURCE_CODE); 83 | } 84 | return authUserDTO; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /vickze-common/src/main/java/io/vickze/common/util/JsonUtil.java: -------------------------------------------------------------------------------- 1 | package io.vickze.common.util; 2 | 3 | 4 | import com.fasterxml.jackson.core.type.TypeReference; 5 | import com.fasterxml.jackson.databind.*; 6 | import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; 7 | import com.fasterxml.jackson.datatype.jsr310.ser.ZonedDateTimeSerializer; 8 | import io.vickze.common.deserializer.ZonedDateTimeDeserializer; 9 | import lombok.extern.slf4j.Slf4j; 10 | import org.springframework.beans.BeanUtils; 11 | import org.springframework.util.ClassUtils; 12 | 13 | import java.time.ZonedDateTime; 14 | import java.time.format.DateTimeFormatter; 15 | 16 | /** 17 | * Json处理工具类 18 | * 19 | * @author vick.zeng 20 | **/ 21 | @Slf4j 22 | public class JsonUtil { 23 | 24 | private static final ObjectMapper mapper = new ObjectMapper(); 25 | 26 | 27 | static { 28 | //reference from Jackson2ObjectMapperBuilder line 730 29 | Class javaTimeModuleClass = null; 30 | try { 31 | javaTimeModuleClass = (Class) 32 | ClassUtils.forName("com.fasterxml.jackson.datatype.jsr310.JavaTimeModule", JsonUtil.class.getClassLoader()); 33 | } catch (ClassNotFoundException e) { 34 | log.error(e.getMessage(), e); 35 | } 36 | JavaTimeModule javaTimeModule = (JavaTimeModule) BeanUtils.instantiateClass(javaTimeModuleClass); 37 | //ZonedDateTime序列化、反序列化 38 | javaTimeModule.addSerializer(ZonedDateTime.class, 39 | new ZonedDateTimeSerializer(DateTimeFormatter.ISO_OFFSET_DATE_TIME)); 40 | javaTimeModule.addDeserializer(ZonedDateTime.class, ZonedDateTimeDeserializer.INSTANCE); 41 | mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); 42 | mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); 43 | mapper.registerModule(javaTimeModule); 44 | } 45 | 46 | public static String toJson(T data) { 47 | try { 48 | return mapper.writeValueAsString(data); 49 | } catch (Exception e) { 50 | log.error("To json failure, data:{}", data); 51 | throw new RuntimeException(e); 52 | } 53 | } 54 | 55 | public static T fromJson(String json, Class clazz) { 56 | try { 57 | if (json == null) { 58 | return null; 59 | } 60 | return mapper.readValue(json, clazz); 61 | } catch (Exception e) { 62 | log.error("From json failure, json:{}", json); 63 | throw new RuntimeException(e); 64 | } 65 | } 66 | 67 | 68 | public static T fromJson(String json, TypeReference jsonTypeReference) { 69 | try { 70 | if (json == null) { 71 | return null; 72 | } 73 | return mapper.readValue(json, jsonTypeReference); 74 | } catch (Exception e) { 75 | log.error("From json failure, json:{}", json); 76 | throw new RuntimeException(e); 77 | } 78 | } 79 | 80 | public static T fromJson(String json, Class collectionClass, Class... elementClasses) { 81 | try { 82 | JavaType javaType = mapper.getTypeFactory().constructParametricType(collectionClass, elementClasses); 83 | return mapper.readValue(json, javaType); 84 | } catch (Exception e) { 85 | log.error("From json failure, json:{}", json); 86 | return null; 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/service/impl/UUIDTokenServiceImpl.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.service.impl; 2 | 3 | import io.vickze.auth.constant.GlobalConstant; 4 | import io.vickze.auth.domain.DO.SystemDO; 5 | import io.vickze.auth.domain.DO.UserDO; 6 | import io.vickze.auth.domain.DTO.AuthUserDTO; 7 | import io.vickze.auth.domain.DTO.CreateTokenDTO; 8 | import io.vickze.auth.domain.DTO.TokenDTO; 9 | import io.vickze.auth.exception.ForbiddenException; 10 | import io.vickze.auth.properties.UUIDTokenProperties; 11 | import io.vickze.auth.service.SystemService; 12 | import io.vickze.auth.service.TokenService; 13 | import io.vickze.auth.service.UserService; 14 | import io.vickze.common.exception.MessageException; 15 | import io.vickze.common.util.JsonUtil; 16 | import lombok.extern.slf4j.Slf4j; 17 | import org.apache.commons.lang3.StringUtils; 18 | import org.springframework.beans.factory.annotation.Autowired; 19 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 20 | import org.springframework.data.redis.core.StringRedisTemplate; 21 | import org.springframework.stereotype.Service; 22 | import org.springframework.util.CollectionUtils; 23 | 24 | import java.security.*; 25 | import java.util.Set; 26 | import java.util.UUID; 27 | import java.util.concurrent.TimeUnit; 28 | 29 | @ConditionalOnProperty( 30 | name = {"token.uuid.enabled"} 31 | ) 32 | @Slf4j 33 | @Service 34 | public class UUIDTokenServiceImpl implements TokenService { 35 | 36 | @Autowired 37 | private UUIDTokenProperties uuidTokenProperties; 38 | @Autowired 39 | private UserService userService; 40 | @Autowired 41 | private SystemService systemService; 42 | @Autowired 43 | private StringRedisTemplate stringRedisTemplate; 44 | 45 | private PublicKey publicKey; 46 | 47 | private PrivateKey privateKey; 48 | 49 | private static final String USERNAME = "username"; 50 | 51 | @Override 52 | public TokenDTO create(AuthUserDTO authUserDTO) { 53 | String token = UUID.randomUUID().toString(); 54 | String tokenKey = getTokenKey(token); 55 | 56 | stringRedisTemplate.opsForValue().set(tokenKey, JsonUtil.toJson(authUserDTO)); 57 | stringRedisTemplate.expire(tokenKey, uuidTokenProperties.getExpire(), TimeUnit.SECONDS); 58 | log.info("userId:{} token:{}", authUserDTO.getUserId(), token); 59 | 60 | TokenDTO tokenDTO = new TokenDTO(); 61 | tokenDTO.setExpire(uuidTokenProperties.getExpire()); 62 | tokenDTO.setToken(token); 63 | return tokenDTO; 64 | } 65 | 66 | @Override 67 | public AuthUserDTO validate(String token) { 68 | try { 69 | String tokenKey = getTokenKey(token); 70 | String json = stringRedisTemplate.opsForValue().get(tokenKey); 71 | if (StringUtils.isBlank(json)) { 72 | return null; 73 | } 74 | AuthUserDTO authUserDTO = JsonUtil.fromJson(json, AuthUserDTO.class); 75 | if (authUserDTO != null && uuidTokenProperties.isUpdateExpire()) { 76 | stringRedisTemplate.expire(tokenKey, uuidTokenProperties.getExpire(), TimeUnit.SECONDS); 77 | } 78 | return authUserDTO; 79 | } catch (Exception e) { 80 | log.info("无效token:{}", token); 81 | } 82 | 83 | return null; 84 | } 85 | 86 | @Override 87 | public void delete(String token) { 88 | stringRedisTemplate.delete(getTokenKey(token)); 89 | } 90 | 91 | private String getTokenKey(String token) { 92 | return "TOKEN:" + token; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /vickze-generator/src/main/java/io/vickze/generator/service/impl/ConfigServiceImpl.java: -------------------------------------------------------------------------------- 1 | package io.vickze.generator.service.impl; 2 | 3 | import com.baomidou.dynamic.datasource.annotation.DS; 4 | import io.vickze.common.domain.RPageRequest; 5 | import io.vickze.generator.repository.ConfigRepository; 6 | import org.springframework.data.domain.Page; 7 | import org.springframework.data.domain.Pageable; 8 | import org.springframework.data.domain.Sort; 9 | import org.springframework.data.jpa.domain.Specification; 10 | 11 | import javax.persistence.criteria.Predicate; 12 | import java.util.Optional; 13 | import java.util.stream.Collectors; 14 | import io.vickze.generator.domain.DO.ConfigDO; 15 | import io.vickze.generator.domain.DTO.ConfigQueryDTO; 16 | import io.vickze.generator.service.ConfigService; 17 | import java.util.ArrayList; 18 | import org.apache.commons.lang3.tuple.Pair; 19 | import org.springframework.beans.BeanUtils; 20 | import org.apache.commons.lang.StringUtils; 21 | import org.springframework.beans.factory.annotation.Autowired; 22 | import org.springframework.stereotype.Service; 23 | import org.springframework.util.CollectionUtils; 24 | import java.util.Arrays; 25 | import java.util.List; 26 | 27 | /** 28 | * 配置 29 | * 30 | * @author vick.zeng 31 | * @email zyk@yk95.top 32 | * @create 2019-03-29 16:04:44 33 | */ 34 | @Service 35 | @DS("master") 36 | public class ConfigServiceImpl implements ConfigService { 37 | @Autowired 38 | private ConfigRepository configRepository; 39 | 40 | @Override 41 | public Pair, Long> list(ConfigQueryDTO queryDTO) { 42 | Pageable pageable; 43 | if (queryDTO.getField() != null) { 44 | pageable = RPageRequest.of((int) queryDTO.getOffset(), (int) queryDTO.getLimit(), 45 | Sort.Direction.valueOf(queryDTO.getOrder()), queryDTO.getField()); 46 | } else { 47 | pageable = RPageRequest.of((int) queryDTO.getOffset(), (int) queryDTO.getLimit(), 48 | Sort.Direction.DESC, "id"); 49 | } 50 | 51 | Page page = configRepository.findAll((Specification) (root, criteriaQuery, criteriaBuilder) -> { 52 | List list = new ArrayList<>(); 53 | if (StringUtils.isNotBlank(queryDTO.getName())) { 54 | list.add(criteriaBuilder.like(root.get("name").as(String.class), "%" + queryDTO.getName() + "%")); 55 | } 56 | if (!CollectionUtils.isEmpty(queryDTO.getType())) { 57 | list.add(root.get("type").as(Integer.class).in(queryDTO.getType())); 58 | } 59 | Predicate[] predicates = new Predicate[list.size()]; 60 | return criteriaBuilder.and(list.toArray(predicates)); 61 | }, pageable); 62 | 63 | return Pair.of(page.getContent(), page.getTotalElements()); 64 | } 65 | 66 | @Override 67 | public ConfigDO get(Long id) { 68 | return configRepository.findById(id).orElse(null); 69 | } 70 | 71 | @Override 72 | public void insert(ConfigDO configDO) { 73 | configDO.setDeleted(0); 74 | configRepository.save(configDO); 75 | } 76 | 77 | @Override 78 | public void update(ConfigDO configDO) { 79 | Optional configDODB = configRepository.findById(configDO.getId()); 80 | if (configDODB.isPresent()) { 81 | BeanUtils.copyProperties(configDO, configDODB.get(), "createTime", "updateTime", "deleted"); 82 | configRepository.save(configDODB.get()); 83 | } 84 | } 85 | 86 | @Override 87 | public void delete(Long... ids) { 88 | configRepository.deleteAll(Arrays.stream(ids).map(id -> { 89 | Optional configDO = configRepository.findById(id); 90 | return configDO.orElse(null); 91 | }).collect(Collectors.toList())); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /vickze-generator/src/main/java/io/vickze/generator/controller/GeneratorController.java: -------------------------------------------------------------------------------- 1 | package io.vickze.generator.controller; 2 | 3 | import com.baomidou.dynamic.datasource.DynamicRoutingDataSource; 4 | import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceProperties; 5 | import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.hikari.HikariCpConfig; 6 | import com.zaxxer.hikari.HikariConfig; 7 | import com.zaxxer.hikari.HikariDataSource; 8 | import io.vickze.generator.domain.DO.TableDO; 9 | import io.vickze.generator.domain.DTO.GeneratorCodeDTO; 10 | import io.vickze.generator.domain.DTO.GeneratorQueryDTO; 11 | import io.vickze.generator.domain.DTO.SaveDataSourceDTO; 12 | import io.vickze.generator.domain.DTO.DataSourceDTO; 13 | import io.vickze.generator.service.GeneratorService; 14 | import org.apache.commons.lang3.tuple.Pair; 15 | import org.apache.commons.configuration.ConfigurationException; 16 | import org.apache.commons.io.IOUtils; 17 | import org.springframework.beans.factory.annotation.Autowired; 18 | import org.springframework.web.bind.annotation.*; 19 | 20 | import javax.servlet.http.HttpServletResponse; 21 | import java.io.IOException; 22 | import java.net.URLEncoder; 23 | import java.util.List; 24 | 25 | @RestController 26 | public class GeneratorController { 27 | 28 | @Autowired //在需要的地方注入,然后调用相关方法增减数据源 29 | private DynamicRoutingDataSource dynamicRoutingDataSource; 30 | @Autowired 31 | private DynamicDataSourceProperties dynamicDataSourceProperties; 32 | 33 | @Autowired 34 | private GeneratorService generatorService; 35 | 36 | @GetMapping("/table") 37 | public List tableList(GeneratorQueryDTO query, HttpServletResponse response) { 38 | Pair, Long> result = generatorService.tableList(query); 39 | response.addHeader("X-Total-Count", String.valueOf(result.getValue())); 40 | return result.getKey(); 41 | } 42 | 43 | @GetMapping("/datasource/{ds}") 44 | public DataSourceDTO getDataSource(@PathVariable("ds") String ds) { 45 | DataSourceDTO dataSourceDTO = new DataSourceDTO(); 46 | HikariDataSource dataSource = (HikariDataSource) dynamicRoutingDataSource.getCurrentDataSources().get(ds); 47 | if (dataSource == null) { 48 | return null; 49 | } 50 | dataSourceDTO.setJdbcUrl(dataSource.getJdbcUrl()); 51 | return dataSourceDTO; 52 | } 53 | 54 | @PutMapping("/datasource") 55 | public void saveDataSource(@RequestBody SaveDataSourceDTO saveDataSource) { 56 | HikariCpConfig hikariCpConfig = dynamicDataSourceProperties.getDatasource().get(saveDataSource.getDs()) == null ? 57 | new HikariCpConfig() : dynamicDataSourceProperties.getDatasource().get(saveDataSource.getDs()).getHikari(); 58 | 59 | HikariConfig config = hikariCpConfig.toHikariConfig(dynamicDataSourceProperties.getHikari()); 60 | config.setDriverClassName("com.mysql.cj.jdbc.Driver"); 61 | config.setJdbcUrl(saveDataSource.getJdbcUrl()); 62 | config.setUsername(saveDataSource.getUsername()); 63 | config.setPassword(saveDataSource.getPassword()); 64 | 65 | dynamicRoutingDataSource.addDataSource(saveDataSource.getDs(), new HikariDataSource(config)); 66 | } 67 | 68 | /** 69 | * 生成代码 70 | */ 71 | @PostMapping("/code") 72 | public void code(@RequestBody GeneratorCodeDTO generatorCode, HttpServletResponse response) throws IOException { 73 | byte[] data = generatorService.generatorCode(generatorCode); 74 | 75 | response.reset(); 76 | response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode("代码生成", "UTF-8") + ".zip"); 77 | response.addHeader("Content-Length", "" + data.length); 78 | response.setContentType("application/octet-stream; charset=UTF-8"); 79 | 80 | IOUtils.write(data, response.getOutputStream()); 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/service/impl/JwtServiceImpl.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.service.impl; 2 | 3 | import io.jsonwebtoken.Claims; 4 | import io.jsonwebtoken.Jwts; 5 | import io.jsonwebtoken.SignatureAlgorithm; 6 | import io.vickze.auth.constant.GlobalConstant; 7 | import io.vickze.auth.domain.DO.SystemDO; 8 | import io.vickze.auth.domain.DO.UserDO; 9 | import io.vickze.auth.domain.DTO.AuthUserDTO; 10 | import io.vickze.auth.domain.DTO.CreateTokenDTO; 11 | import io.vickze.auth.domain.DTO.TokenDTO; 12 | import io.vickze.auth.properties.JwtProperties; 13 | import io.vickze.auth.service.SystemService; 14 | import io.vickze.auth.service.TokenService; 15 | import io.vickze.auth.service.UserService; 16 | import io.vickze.auth.exception.ForbiddenException; 17 | import io.vickze.common.exception.MessageException; 18 | import lombok.extern.slf4j.Slf4j; 19 | import org.apache.commons.lang3.StringUtils; 20 | import org.apache.commons.lang3.time.DateUtils; 21 | import org.springframework.beans.factory.InitializingBean; 22 | import org.springframework.beans.factory.annotation.Autowired; 23 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 24 | import org.springframework.stereotype.Service; 25 | import org.springframework.util.CollectionUtils; 26 | 27 | import java.security.*; 28 | import java.util.Date; 29 | import java.util.Set; 30 | 31 | @ConditionalOnProperty( 32 | name = {"token.jwt.enabled"}, 33 | matchIfMissing = true 34 | ) 35 | @Slf4j 36 | @Service 37 | public class JwtServiceImpl implements TokenService, InitializingBean { 38 | 39 | @Autowired 40 | private JwtProperties jwtProperties; 41 | @Autowired 42 | private UserService userService; 43 | @Autowired 44 | private SystemService systemService; 45 | 46 | private PublicKey publicKey; 47 | 48 | private PrivateKey privateKey; 49 | 50 | private static final String USERNAME = "username"; 51 | 52 | 53 | //or @PostConstruct 54 | public void afterPropertiesSet() throws NoSuchAlgorithmException { 55 | KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA"); 56 | SecureRandom secureRandom = new SecureRandom(jwtProperties.getSecret().getBytes()); 57 | keyPairGenerator.initialize(2048, secureRandom); 58 | KeyPair keyPair = keyPairGenerator.genKeyPair(); 59 | 60 | publicKey = keyPair.getPublic(); 61 | privateKey = keyPair.getPrivate(); 62 | } 63 | 64 | @Override 65 | public TokenDTO create(AuthUserDTO authUserDTO) { 66 | Date now = new Date(); 67 | String jws = Jwts.builder() 68 | .setSubject(String.valueOf(authUserDTO.getUserId())) 69 | .claim(USERNAME, authUserDTO.getUsername()) 70 | .setIssuedAt(now) 71 | .setExpiration(DateUtils.addSeconds(now, (int) jwtProperties.getExpire())) 72 | .signWith(privateKey, SignatureAlgorithm.RS256) 73 | .compact(); 74 | 75 | TokenDTO tokenDTO = new TokenDTO(); 76 | tokenDTO.setExpire(jwtProperties.getExpire()); 77 | tokenDTO.setToken(jws); 78 | return tokenDTO; 79 | } 80 | 81 | @Override 82 | public AuthUserDTO validate(String token) { 83 | try { 84 | Claims claims = Jwts.parser().setSigningKey(publicKey).parseClaimsJws(token).getBody(); 85 | //返回 86 | AuthUserDTO authUserDTO = new AuthUserDTO(); 87 | authUserDTO.setUserId(Long.valueOf(claims.getSubject())); 88 | authUserDTO.setUsername(claims.get(USERNAME).toString()); 89 | return authUserDTO; 90 | } catch (Exception e) { 91 | log.info("无效token:{}", token); 92 | } 93 | 94 | return null; 95 | } 96 | 97 | @Override 98 | public void delete(String token) { 99 | //do nothing jwt应该是前端丢弃token 100 | } 101 | 102 | } 103 | -------------------------------------------------------------------------------- /vickze-auth/vickze-auth-server/src/main/java/io/vickze/auth/service/impl/CheckPermissionServiceImpl.java: -------------------------------------------------------------------------------- 1 | package io.vickze.auth.service.impl; 2 | 3 | import io.vickze.auth.domain.DO.SystemDO; 4 | import io.vickze.auth.domain.DTO.AuthUserDTO; 5 | import io.vickze.auth.domain.DTO.CheckPermissionDTO; 6 | import io.vickze.auth.properties.AuthCheckPermissionProperties; 7 | import io.vickze.auth.service.*; 8 | import io.vickze.auth.exception.ForbiddenException; 9 | import io.vickze.auth.exception.UnauthorizedException; 10 | import io.vickze.common.domain.Interface; 11 | import io.vickze.common.util.InterfaceUtil; 12 | import org.apache.commons.lang.StringUtils; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.stereotype.Service; 15 | import org.springframework.transaction.annotation.Transactional; 16 | import org.springframework.util.CollectionUtils; 17 | 18 | import java.util.List; 19 | import java.util.Set; 20 | 21 | /** 22 | * @author vick.zeng 23 | * @email zyk@yk95.top 24 | * @create 2019-06-03 14:18 25 | */ 26 | @Service 27 | public class CheckPermissionServiceImpl implements CheckPermissionService { 28 | @Autowired 29 | private SystemService systemService; 30 | @Autowired 31 | private TokenService tokenService; 32 | @Autowired 33 | private UserService userService; 34 | @Autowired 35 | private MenuResourceService menuResourceService; 36 | 37 | @Autowired 38 | private AuthCheckPermissionProperties authCheckPermissionProperties; 39 | 40 | @Override 41 | @Transactional(readOnly = true) 42 | public void checkPermission(CheckPermissionDTO checkPermissionDTO) { 43 | // 请求接口 44 | Interface requestInterface = new Interface(checkPermissionDTO.getMethod(), checkPermissionDTO.getRequestUri()); 45 | 46 | if (InterfaceUtil.interfaceContains(requestInterface, authCheckPermissionProperties.getIgnoreInterfaces())) { 47 | return; 48 | } 49 | if (StringUtils.isBlank(checkPermissionDTO.getSystemKey())) { 50 | throw new ForbiddenException(); 51 | } 52 | SystemDO systemDO = systemService.selectByKey(checkPermissionDTO.getSystemKey()); 53 | if (systemDO == null) { 54 | throw new ForbiddenException(); 55 | } 56 | 57 | if (InterfaceUtil.interfaceContains(requestInterface, authCheckPermissionProperties.getIgnoreInterfacesWithoutLogin())) { 58 | return; 59 | } 60 | 61 | //接口需要登录 62 | if (StringUtils.isBlank(checkPermissionDTO.getToken())) { 63 | throw new UnauthorizedException(); 64 | } 65 | AuthUserDTO authUserDTO = tokenService.validate(checkPermissionDTO.getToken()); 66 | if (authUserDTO == null) { 67 | throw new UnauthorizedException(); 68 | } 69 | 70 | Set userPermissions = userService.getMenuPermissions(systemDO.getId(), authUserDTO.getUserId()); 71 | //是否允许无菜单资源权限登录 72 | if (Boolean.FALSE.equals(systemDO.getNotResourceLogin()) && CollectionUtils.isEmpty(userPermissions)) { 73 | throw new UnauthorizedException(); 74 | } 75 | 76 | //一个接口可能对应多个菜单功能,比如 按钮详情->详情接口 按钮编辑->详情接口、更新接口 77 | //详情接口同时对应两个功能,用户只需要拥有其中一个功能权限即可访问该接口 78 | //注意像/menu/tree未设置权限,/menu/{id}设置了权限的话,/menu/tree会跟/menu/{id}匹配到 79 | List permissions = menuResourceService.getPermissions(systemDO.getId(), 80 | checkPermissionDTO.getRequestUri(), checkPermissionDTO.getMethod()); 81 | 82 | //判断用户是否有访问该菜单资源的权限 83 | if (!hasPermission(userPermissions, permissions)) { 84 | throw new UnauthorizedException(); 85 | } 86 | } 87 | 88 | private boolean hasPermission(Set userPermissions, List permissions) { 89 | if (CollectionUtils.isEmpty(permissions)) { 90 | return true; 91 | } 92 | for (String permission : permissions) { 93 | if (userPermissions.contains(permission)) { 94 | return true; 95 | } 96 | } 97 | return false; 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /vickze-generator/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | vickze-cloud-admin 7 | io.vickze 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | vickze-generator 13 | 14 | 15 | 16 | io.vickze 17 | vickze-common 18 | 19 | 20 | io.vickze 21 | vickze-auth-client 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-web 26 | 27 | 28 | org.springframework.cloud 29 | spring-cloud-starter-alibaba-nacos-discovery 30 | 31 | 32 | org.springframework.cloud 33 | spring-cloud-starter-alibaba-nacos-config 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-starter-actuator 38 | 39 | 40 | io.micrometer 41 | micrometer-registry-prometheus 42 | 43 | 44 | 45 | 46 | io.springfox 47 | springfox-swagger-ui 48 | 49 | 50 | io.springfox 51 | springfox-swagger2 52 | 53 | 54 | 55 | 56 | velocity 57 | org.apache.velocity 58 | 59 | 60 | org.freemarker 61 | freemarker 62 | 63 | 64 | com.baomidou 65 | mybatis-plus-boot-starter 66 | 67 | 68 | org.springframework.boot 69 | spring-boot-starter-data-jpa 70 | 71 | 72 | mysql 73 | mysql-connector-java 74 | 75 | 76 | org.yaml 77 | snakeyaml 78 | 79 | 80 | com.baomidou 81 | dynamic-datasource-spring-boot-starter 82 | 83 | 84 | commons-io 85 | commons-io 86 | 87 | 88 | commons-configuration 89 | commons-configuration 90 | 91 | 92 | 93 | 94 | 95 | 96 | org.springframework.boot 97 | spring-boot-maven-plugin 98 | 99 | 100 | 101 | 102 | 103 | 104 | public 105 | aliyun nexus 106 | http://maven.aliyun.com/nexus/content/groups/public/ 107 | 108 | 109 | -------------------------------------------------------------------------------- /vickze-gateway/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | vickze-cloud-admin 7 | io.vickze 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | vickze-gateway 13 | 14 | 15 | 16 | org.springframework.cloud 17 | spring-cloud-starter-gateway 18 | 19 | 20 | org.springframework.cloud 21 | spring-cloud-starter-alibaba-nacos-discovery 22 | 23 | 24 | org.springframework.cloud 25 | spring-cloud-starter-alibaba-nacos-config 26 | 27 | 28 | 29 | 30 | 31 | 32 | org.springframework.cloud 33 | spring-cloud-starter-netflix-hystrix 34 | 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-starter-data-redis-reactive 39 | 40 | 41 | de.codecentric 42 | spring-boot-admin-starter-client 43 | 44 | 45 | org.springframework.boot 46 | spring-boot-starter-actuator 47 | 48 | 49 | io.micrometer 50 | micrometer-registry-prometheus 51 | 52 | 53 | 54 | com.github.xiaoymin 55 | knife4j-spring-ui 56 | 57 | 58 | io.springfox 59 | springfox-swagger-ui 60 | 3.0.0-SNAPSHOT 61 | 62 | 63 | io.springfox 64 | springfox-swagger2 65 | 3.0.0-SNAPSHOT 66 | 67 | 68 | io.springfox 69 | springfox-spring-webflux 70 | 3.0.0-SNAPSHOT 71 | 72 | 73 | io.vickze 74 | vickze-auth-client 75 | 76 | 77 | io.github.openfeign 78 | feign-okhttp 79 | 80 | 81 | 82 | 83 | 84 | 85 | org.springframework.boot 86 | spring-boot-maven-plugin 87 | 88 | 89 | 90 | 91 | 92 | 93 | public 94 | aliyun nexus 95 | http://maven.aliyun.com/nexus/content/groups/public/ 96 | 97 | 98 | 99 | 100 | jcenter-snapshots 101 | jcenter 102 | http://oss.jfrog.org/artifactory/oss-snapshot-local/ 103 | 104 | 105 | --------------------------------------------------------------------------------