From f185add54695a14f3f1ff197c469d6efde02d377 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E5=86=B7?= Date: Mon, 23 Jul 2018 15:25:22 +0800 Subject: [PATCH] :bookmark: v1.2.3 --- .editorconfig | 22 ++ .gitignore | 58 ++++ LICENSE | 14 + README.md | 51 ++++ doc/PIGX.png | Bin 0 -> 44089 bytes doc/deploy.md | 58 ++++ doc/pigx.sql | 270 ++++++++++++++++++ docker-compose.yml | 64 +++++ pigx-auth/Dockerfile | 13 + pigx-auth/pom.xml | 102 +++++++ .../pigx/auth/PigxAuthApplication.java | 39 +++ .../config/AuthorizationServerConfig.java | 102 +++++++ .../auth/config/WebSecurityConfigurer.java | 68 +++++ .../auth/endpoint/RevokeTokenEndpoint.java | 59 ++++ .../service/PigxUserDetailsServiceImpl.java | 81 ++++++ pigx-auth/src/main/resources/bootstrap.yml | 26 ++ .../code/config/KaptchaConfiguration.java | 99 +++++++ .../code/exception/ValidateCodeException.java | 25 ++ .../code/filter/ImageCodeGatewayFilter.java | 93 ++++++ .../common/code/handle/ImageCodeHandler.java | 77 +++++ pigx-common/pigx-common-core/pom.xml | 63 ++++ .../pigx/common/core/config/RedisConfig.java | 77 +++++ .../common/core/constant/CommonConstant.java | 89 ++++++ .../common/core/constant/MqQueueConstant.java | 57 ++++ .../core/constant/SecurityConstants.java | 77 +++++ .../core/constant/ServiceNameConstant.java | 37 +++ .../core/constant/enums/EnumSmsChannel.java | 45 +++ .../enums/EnumSmsChannelTemplate.java | 50 ++++ .../core/exception/CheckedException.java | 48 ++++ .../core/exception/PigDeniedException.java | 49 ++++ .../core/exception/UnloginException.java | 48 ++++ .../core/exception/ValidateCodeException.java | 32 +++ .../pigx/common/core/util/ClassUtils.java | 112 ++++++++ .../pig4cloud/pigx/common/core/util/R.java | 71 +++++ .../common/core/util/SpringContextHolder.java | 102 +++++++ .../pigx/common/core/util/WebUtils.java | 195 +++++++++++++ .../META-INF/spring-devtools.properties | 1 + .../main/resources/META-INF/spring.factories | 3 + .../main/resources/META-INF/spring.provides | 1 + pigx-common/pigx-common-log/pom.xml | 51 ++++ .../pigx/common/log/LogAutoConfiguration.java | 52 ++++ .../pigx/common/log/annotation/SysLog.java | 40 +++ .../pigx/common/log/aspect/SysLogAspect.java | 57 ++++ .../pigx/common/log/event/SysLogEvent.java | 34 +++ .../pigx/common/log/event/SysLogListener.java | 47 +++ .../pigx/common/log/util/SysLogUtils.java | 66 +++++ .../META-INF/spring-devtools.properties | 1 + .../main/resources/META-INF/spring.factories | 2 + pigx-common/pigx-common-security/pom.xml | 59 ++++ .../security/compoent/PermissionService.java | 61 ++++ .../compoent/PigAccessDeniedHandler.java | 74 +++++ .../PigxWebResponseExceptionTranslator.java | 105 +++++++ .../ResourceAuthExceptionEntryPoint.java | 62 ++++ .../exception/ForbiddenException.java | 43 +++ .../security/exception/InvalidException.java | 40 +++ .../security/exception/MethodNotAllowed.java | 42 +++ .../exception/PigxAuth2Exception.java | 34 +++ .../exception/ServerErrorException.java | 42 +++ .../exception/UnauthorizedException.java | 42 +++ .../interceptor/PigxFeignClientIntercept.java | 44 +++ .../common/security/util/SecurityUtils.java | 94 ++++++ .../META-INF/spring-devtools.properties | 1 + .../main/resources/META-INF/spring.factories | 5 + .../main/resources/META-INF/spring.provides | 1 + .../security/messages_zh_CN.properties | 64 +++++ pigx-common/pigx-common-swagger/pom.xml | 58 ++++ .../annotation/EnablePigxSwagger2.java | 36 +++ .../config/SwaggerAutoConfiguration.java | 93 ++++++ pigx-common/pom.xml | 42 +++ pigx-config/Dockerfile | 13 + pigx-config/pom.xml | 75 +++++ .../pigx/config/PigxConfigApplication.java | 38 +++ pigx-config/src/main/resources/bootstrap.yml | 29 ++ .../main/resources/config/application-dev.yml | 48 ++++ .../main/resources/config/pigx-auth-dev.yml | 8 + .../resources/config/pigx-gateway-dev.yml | 49 ++++ .../main/resources/config/pigx-upms-dev.yml | 40 +++ pigx-eureka/Dockerfile | 13 + pigx-eureka/pom.xml | 80 ++++++ .../pigx/eureka/PigxEurekaApplication.java | 39 +++ .../eureka/security/WebSecurityConfig.java | 39 +++ pigx-eureka/src/main/resources/bootstrap.yml | 32 +++ pigx-gateway/Dockerfile | 13 + pigx-gateway/pom.xml | 88 ++++++ .../pigx/gateway/PigxGatewayApplication.java | 37 +++ .../config/FilterIgnorePropertiesConfig.java | 41 +++ .../gateway/config/KaptchaConfiguration.java | 89 ++++++ .../config/RateLimiterConfiguration.java | 38 +++ .../config/RouterFunctionConfiguration.java | 61 ++++ .../pigx/gateway/config/SwaggerProvider.java | 67 +++++ .../gateway/exception/CheckedException.java | 47 +++ .../exception/ValidateCodeException.java | 25 ++ .../filter/ImageCodeGatewayFilter.java | 186 ++++++++++++ .../gateway/filter/PasswordDecoderFilter.java | 97 +++++++ .../gateway/filter/SwaggerHeaderFilter.java | 53 ++++ .../handle/HystrixFallbackHandler.java | 44 +++ .../pigx/gateway/handle/ImageCodeHandler.java | 77 +++++ .../handle/SwaggerResourceHandler.java | 55 ++++ .../handle/SwaggerSecurityHandler.java | 60 ++++ .../pigx/gateway/handle/SwaggerUiHandler.java | 60 ++++ pigx-gateway/src/main/resources/bootstrap.yml | 27 ++ pigx-monitor/Dockerfile | 13 + pigx-monitor/pom.xml | 80 ++++++ .../pigx/monitor/PigxMonitorApplication.java | 39 +++ pigx-monitor/src/main/resources/bootstrap.yml | 23 ++ pigx-upms/pigx-upms-api/pom.xml | 51 ++++ .../pigx/admin/api/dto/DeptTree.java | 32 +++ .../pigx/admin/api/dto/MenuTree.java | 71 +++++ .../pig4cloud/pigx/admin/api/dto/Query.java | 55 ++++ .../pig4cloud/pigx/admin/api/dto/RoleDTO.java | 41 +++ .../pigx/admin/api/dto/RouteConfig.java | 58 ++++ .../pigx/admin/api/dto/TreeNode.java | 40 +++ .../pig4cloud/pigx/admin/api/dto/UserDTO.java | 44 +++ .../pigx/admin/api/dto/UserInfo.java | 74 +++++ .../pigx/admin/api/entity/SysDept.java | 95 ++++++ .../admin/api/entity/SysDeptRelation.java | 64 +++++ .../pigx/admin/api/entity/SysDict.java | 115 ++++++++ .../pigx/admin/api/entity/SysLog.java | 129 +++++++++ .../pigx/admin/api/entity/SysMenu.java | 124 ++++++++ .../api/entity/SysOauthClientDetails.java | 173 +++++++++++ .../pigx/admin/api/entity/SysRole.java | 83 ++++++ .../pigx/admin/api/entity/SysRoleDept.java | 72 +++++ .../pigx/admin/api/entity/SysRoleMenu.java | 67 +++++ .../pigx/admin/api/entity/SysUser.java | 110 +++++++ .../pigx/admin/api/entity/SysUserRole.java | 68 +++++ .../pigx/admin/api/entity/SysZuulRoute.java | 106 +++++++ .../admin/api/feign/RemoteLogService.java | 44 +++ .../admin/api/feign/RemoteUserService.java | 47 +++ .../RemoteLogServiceFallbackImpl.java | 47 +++ .../RemoteUserServiceFallbackImpl.java | 47 +++ .../pigx/admin/api/vo/ErrorPojo.java | 47 +++ .../pigx/admin/api/vo/ImageCode.java | 46 +++ .../pig4cloud/pigx/admin/api/vo/LogVO.java | 37 +++ .../pig4cloud/pigx/admin/api/vo/MenuVO.java | 109 +++++++ .../pig4cloud/pigx/admin/api/vo/TreeUtil.java | 121 ++++++++ .../pig4cloud/pigx/admin/api/vo/UserVO.java | 87 ++++++ .../META-INF/spring-devtools.properties | 1 + .../main/resources/META-INF/spring.factories | 3 + .../main/resources/META-INF/spring.provides | 1 + pigx-upms/pigx-upms-biz/Dockerfile | 13 + pigx-upms/pigx-upms-biz/pom.xml | 113 ++++++++ .../pigx/admin/PigxAdminApplication.java | 40 +++ .../admin/config/MybatisPlusConfigurer.java | 43 +++ .../config/ResourceServerConfigurer.java | 64 +++++ .../pigx/admin/controller/DeptController.java | 109 +++++++ .../pigx/admin/controller/DictController.java | 134 +++++++++ .../pigx/admin/controller/LogController.java | 84 ++++++ .../pigx/admin/controller/MenuController.java | 149 ++++++++++ .../OauthClientDetailsController.java | 108 +++++++ .../pigx/admin/controller/RoleController.java | 130 +++++++++ .../pigx/admin/controller/UserController.java | 167 +++++++++++ .../pigx/admin/mapper/SysDeptMapper.java | 51 ++++ .../admin/mapper/SysDeptRelationMapper.java | 35 +++ .../pigx/admin/mapper/SysDictMapper.java | 35 +++ .../pigx/admin/mapper/SysLogMapper.java | 35 +++ .../pigx/admin/mapper/SysMenuMapper.java | 53 ++++ .../mapper/SysOauthClientDetailsMapper.java | 36 +++ .../pigx/admin/mapper/SysRoleDeptMapper.java | 35 +++ .../pigx/admin/mapper/SysRoleMapper.java | 63 ++++ .../pigx/admin/mapper/SysRoleMenuMapper.java | 36 +++ .../pigx/admin/mapper/SysUserMapper.java | 64 +++++ .../pigx/admin/mapper/SysUserRoleMapper.java | 45 +++ .../admin/service/SysDeptRelationService.java | 35 +++ .../pigx/admin/service/SysDeptService.java | 70 +++++ .../pigx/admin/service/SysDictService.java | 35 +++ .../pigx/admin/service/SysLogService.java | 42 +++ .../pigx/admin/service/SysMenuService.java | 61 ++++ .../service/SysOauthClientDetailsService.java | 35 +++ .../admin/service/SysRoleDeptService.java | 35 +++ .../admin/service/SysRoleMenuService.java | 45 +++ .../pigx/admin/service/SysRoleService.java | 81 ++++++ .../admin/service/SysUserRoleService.java | 45 +++ .../pigx/admin/service/SysUserService.java | 85 ++++++ .../impl/SysDeptRelationServiceImpl.java | 39 +++ .../service/impl/SysDeptServiceImpl.java | 160 +++++++++++ .../service/impl/SysDictServiceImpl.java | 39 +++ .../admin/service/impl/SysLogServiceImpl.java | 51 ++++ .../service/impl/SysMenuServiceImpl.java | 78 +++++ .../SysOauthClientDetailsServiceImpl.java | 39 +++ .../service/impl/SysRoleDeptServiceImpl.java | 39 +++ .../service/impl/SysRoleMenuServiceImpl.java | 59 ++++ .../service/impl/SysRoleServiceImpl.java | 133 +++++++++ .../service/impl/SysUserRoleServiceImpl.java | 51 ++++ .../service/impl/SysUserServiceImpl.java | 185 ++++++++++++ .../src/main/resources/bootstrap.yml | 26 ++ .../main/resources/mapper/SysDeptMapper.xml | 67 +++++ .../mapper/SysDeptRelationMapper.xml | 35 +++ .../main/resources/mapper/SysDictMapper.xml | 43 +++ .../main/resources/mapper/SysLogMapper.xml | 48 ++++ .../main/resources/mapper/SysMenuMapper.xml | 77 +++++ .../mapper/SysOauthClientDetailsMapper.xml | 44 +++ .../resources/mapper/SysRoleDeptMapper.xml | 36 +++ .../main/resources/mapper/SysRoleMapper.xml | 77 +++++ .../resources/mapper/SysRoleMenuMapper.xml | 30 ++ .../main/resources/mapper/SysUserMapper.xml | 150 ++++++++++ .../resources/mapper/SysUserRoleMapper.xml | 35 +++ pigx-upms/pom.xml | 40 +++ pom.xml | 174 +++++++++++ 198 files changed, 11968 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 doc/PIGX.png create mode 100644 doc/deploy.md create mode 100644 doc/pigx.sql create mode 100644 docker-compose.yml create mode 100644 pigx-auth/Dockerfile create mode 100644 pigx-auth/pom.xml create mode 100644 pigx-auth/src/main/java/com/pig4cloud/pigx/auth/PigxAuthApplication.java create mode 100644 pigx-auth/src/main/java/com/pig4cloud/pigx/auth/config/AuthorizationServerConfig.java create mode 100644 pigx-auth/src/main/java/com/pig4cloud/pigx/auth/config/WebSecurityConfigurer.java create mode 100644 pigx-auth/src/main/java/com/pig4cloud/pigx/auth/endpoint/RevokeTokenEndpoint.java create mode 100644 pigx-auth/src/main/java/com/pig4cloud/pigx/auth/service/PigxUserDetailsServiceImpl.java create mode 100644 pigx-auth/src/main/resources/bootstrap.yml create mode 100644 pigx-common/pigx-common-code/src/main/java/com/pig4cloud/pigx/common/code/config/KaptchaConfiguration.java create mode 100644 pigx-common/pigx-common-code/src/main/java/com/pig4cloud/pigx/common/code/exception/ValidateCodeException.java create mode 100644 pigx-common/pigx-common-code/src/main/java/com/pig4cloud/pigx/common/code/filter/ImageCodeGatewayFilter.java create mode 100644 pigx-common/pigx-common-code/src/main/java/com/pig4cloud/pigx/common/code/handle/ImageCodeHandler.java create mode 100644 pigx-common/pigx-common-core/pom.xml create mode 100644 pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/config/RedisConfig.java create mode 100644 pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/CommonConstant.java create mode 100644 pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/MqQueueConstant.java create mode 100644 pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/SecurityConstants.java create mode 100644 pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/ServiceNameConstant.java create mode 100644 pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/enums/EnumSmsChannel.java create mode 100644 pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/enums/EnumSmsChannelTemplate.java create mode 100644 pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/exception/CheckedException.java create mode 100644 pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/exception/PigDeniedException.java create mode 100644 pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/exception/UnloginException.java create mode 100644 pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/exception/ValidateCodeException.java create mode 100644 pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/util/ClassUtils.java create mode 100644 pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/util/R.java create mode 100644 pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/util/SpringContextHolder.java create mode 100644 pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/util/WebUtils.java create mode 100644 pigx-common/pigx-common-core/src/main/resources/META-INF/spring-devtools.properties create mode 100644 pigx-common/pigx-common-core/src/main/resources/META-INF/spring.factories create mode 100644 pigx-common/pigx-common-core/src/main/resources/META-INF/spring.provides create mode 100644 pigx-common/pigx-common-log/pom.xml create mode 100644 pigx-common/pigx-common-log/src/main/java/com/pig4cloud/pigx/common/log/LogAutoConfiguration.java create mode 100644 pigx-common/pigx-common-log/src/main/java/com/pig4cloud/pigx/common/log/annotation/SysLog.java create mode 100644 pigx-common/pigx-common-log/src/main/java/com/pig4cloud/pigx/common/log/aspect/SysLogAspect.java create mode 100644 pigx-common/pigx-common-log/src/main/java/com/pig4cloud/pigx/common/log/event/SysLogEvent.java create mode 100644 pigx-common/pigx-common-log/src/main/java/com/pig4cloud/pigx/common/log/event/SysLogListener.java create mode 100644 pigx-common/pigx-common-log/src/main/java/com/pig4cloud/pigx/common/log/util/SysLogUtils.java create mode 100644 pigx-common/pigx-common-log/src/main/resources/META-INF/spring-devtools.properties create mode 100644 pigx-common/pigx-common-log/src/main/resources/META-INF/spring.factories create mode 100644 pigx-common/pigx-common-security/pom.xml create mode 100644 pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/compoent/PermissionService.java create mode 100644 pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/compoent/PigAccessDeniedHandler.java create mode 100644 pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/compoent/PigxWebResponseExceptionTranslator.java create mode 100644 pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/compoent/ResourceAuthExceptionEntryPoint.java create mode 100644 pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/exception/ForbiddenException.java create mode 100644 pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/exception/InvalidException.java create mode 100644 pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/exception/MethodNotAllowed.java create mode 100644 pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/exception/PigxAuth2Exception.java create mode 100644 pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/exception/ServerErrorException.java create mode 100644 pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/exception/UnauthorizedException.java create mode 100644 pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/interceptor/PigxFeignClientIntercept.java create mode 100644 pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/util/SecurityUtils.java create mode 100644 pigx-common/pigx-common-security/src/main/resources/META-INF/spring-devtools.properties create mode 100644 pigx-common/pigx-common-security/src/main/resources/META-INF/spring.factories create mode 100644 pigx-common/pigx-common-security/src/main/resources/META-INF/spring.provides create mode 100644 pigx-common/pigx-common-security/src/main/resources/org/springframework/security/messages_zh_CN.properties create mode 100644 pigx-common/pigx-common-swagger/pom.xml create mode 100644 pigx-common/pigx-common-swagger/src/main/java/com/pig4cloud/pigx/common/swagger/annotation/EnablePigxSwagger2.java create mode 100644 pigx-common/pigx-common-swagger/src/main/java/com/pig4cloud/pigx/common/swagger/config/SwaggerAutoConfiguration.java create mode 100644 pigx-common/pom.xml create mode 100644 pigx-config/Dockerfile create mode 100644 pigx-config/pom.xml create mode 100644 pigx-config/src/main/java/com/pig4cloud/pigx/config/PigxConfigApplication.java create mode 100644 pigx-config/src/main/resources/bootstrap.yml create mode 100644 pigx-config/src/main/resources/config/application-dev.yml create mode 100644 pigx-config/src/main/resources/config/pigx-auth-dev.yml create mode 100644 pigx-config/src/main/resources/config/pigx-gateway-dev.yml create mode 100644 pigx-config/src/main/resources/config/pigx-upms-dev.yml create mode 100644 pigx-eureka/Dockerfile create mode 100644 pigx-eureka/pom.xml create mode 100644 pigx-eureka/src/main/java/com/pig4cloud/pigx/eureka/PigxEurekaApplication.java create mode 100644 pigx-eureka/src/main/java/com/pig4cloud/pigx/eureka/security/WebSecurityConfig.java create mode 100644 pigx-eureka/src/main/resources/bootstrap.yml create mode 100644 pigx-gateway/Dockerfile create mode 100644 pigx-gateway/pom.xml create mode 100644 pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/PigxGatewayApplication.java create mode 100644 pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/config/FilterIgnorePropertiesConfig.java create mode 100644 pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/config/KaptchaConfiguration.java create mode 100644 pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/config/RateLimiterConfiguration.java create mode 100644 pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/config/RouterFunctionConfiguration.java create mode 100644 pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/config/SwaggerProvider.java create mode 100644 pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/exception/CheckedException.java create mode 100644 pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/exception/ValidateCodeException.java create mode 100644 pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/filter/ImageCodeGatewayFilter.java create mode 100644 pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/filter/PasswordDecoderFilter.java create mode 100644 pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/filter/SwaggerHeaderFilter.java create mode 100644 pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/handle/HystrixFallbackHandler.java create mode 100644 pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/handle/ImageCodeHandler.java create mode 100644 pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/handle/SwaggerResourceHandler.java create mode 100644 pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/handle/SwaggerSecurityHandler.java create mode 100644 pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/handle/SwaggerUiHandler.java create mode 100644 pigx-gateway/src/main/resources/bootstrap.yml create mode 100644 pigx-monitor/Dockerfile create mode 100644 pigx-monitor/pom.xml create mode 100644 pigx-monitor/src/main/java/com/pig4cloud/pigx/monitor/PigxMonitorApplication.java create mode 100644 pigx-monitor/src/main/resources/bootstrap.yml create mode 100644 pigx-upms/pigx-upms-api/pom.xml create mode 100644 pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/dto/DeptTree.java create mode 100644 pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/dto/MenuTree.java create mode 100644 pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/dto/Query.java create mode 100644 pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/dto/RoleDTO.java create mode 100644 pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/dto/RouteConfig.java create mode 100644 pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/dto/TreeNode.java create mode 100644 pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/dto/UserDTO.java create mode 100644 pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/dto/UserInfo.java create mode 100644 pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysDept.java create mode 100644 pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysDeptRelation.java create mode 100644 pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysDict.java create mode 100644 pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysLog.java create mode 100644 pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysMenu.java create mode 100644 pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysOauthClientDetails.java create mode 100644 pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysRole.java create mode 100644 pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysRoleDept.java create mode 100644 pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysRoleMenu.java create mode 100644 pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysUser.java create mode 100644 pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysUserRole.java create mode 100644 pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysZuulRoute.java create mode 100644 pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/RemoteLogService.java create mode 100644 pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/RemoteUserService.java create mode 100644 pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/fallback/RemoteLogServiceFallbackImpl.java create mode 100644 pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/fallback/RemoteUserServiceFallbackImpl.java create mode 100644 pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/ErrorPojo.java create mode 100644 pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/ImageCode.java create mode 100644 pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/LogVO.java create mode 100644 pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/MenuVO.java create mode 100644 pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/TreeUtil.java create mode 100644 pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/UserVO.java create mode 100644 pigx-upms/pigx-upms-api/src/main/resources/META-INF/spring-devtools.properties create mode 100644 pigx-upms/pigx-upms-api/src/main/resources/META-INF/spring.factories create mode 100644 pigx-upms/pigx-upms-api/src/main/resources/META-INF/spring.provides create mode 100644 pigx-upms/pigx-upms-biz/Dockerfile create mode 100644 pigx-upms/pigx-upms-biz/pom.xml create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/PigxAdminApplication.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/config/MybatisPlusConfigurer.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/config/ResourceServerConfigurer.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/DeptController.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/DictController.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/LogController.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/MenuController.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/OauthClientDetailsController.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/RoleController.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/UserController.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDeptMapper.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDeptRelationMapper.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDictMapper.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysLogMapper.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysMenuMapper.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysOauthClientDetailsMapper.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysRoleDeptMapper.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysRoleMapper.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysRoleMenuMapper.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysUserMapper.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysUserRoleMapper.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysDeptRelationService.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysDeptService.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysDictService.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysLogService.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysMenuService.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysOauthClientDetailsService.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysRoleDeptService.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysRoleMenuService.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysRoleService.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysUserRoleService.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysUserService.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysDeptRelationServiceImpl.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysDeptServiceImpl.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysDictServiceImpl.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysLogServiceImpl.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysMenuServiceImpl.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysOauthClientDetailsServiceImpl.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysRoleDeptServiceImpl.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysRoleMenuServiceImpl.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysRoleServiceImpl.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysUserRoleServiceImpl.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysUserServiceImpl.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/resources/bootstrap.yml create mode 100644 pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysDeptMapper.xml create mode 100644 pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysDeptRelationMapper.xml create mode 100644 pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysDictMapper.xml create mode 100644 pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysLogMapper.xml create mode 100644 pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysMenuMapper.xml create mode 100644 pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysOauthClientDetailsMapper.xml create mode 100644 pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysRoleDeptMapper.xml create mode 100644 pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysRoleMapper.xml create mode 100644 pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysRoleMenuMapper.xml create mode 100644 pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysUserMapper.xml create mode 100644 pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysUserRoleMapper.xml create mode 100644 pigx-upms/pom.xml create mode 100644 pom.xml diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..afff4db4b --- /dev/null +++ b/.editorconfig @@ -0,0 +1,22 @@ +root = true + +# 对所有文件生效 +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.{java,xml}] +indent_style = tab +indent_size = 4 + +[*.{yml,json}] +indent_style = space +indent_size = 2 + +# 对后缀名为 md 的文件生效 +[*.md] +trim_trailing_whitespace = false diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..956f4e305 --- /dev/null +++ b/.gitignore @@ -0,0 +1,58 @@ +### gradle ### +.gradle +/build/ +!gradle/wrapper/gradle-wrapper.jar + +### STS ### +.settings/ +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +bin/ + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr +rebel.xml + +### NetBeans ### +nbproject/private/ +build/ +nbbuild/ +dist/ +nbdist/ +.nb-gradle/ + +### maven ### +target/ +*.war +*.ear +*.zip +*.tar +*.tar.gz + +### logs #### +logs + +### temp ignore ### +*.log +*.cache +*.diff +*.patch +*.tmp +*.java~ +*.properties~ +*.xml~ + +### system ignore ### +.DS_Store +Thumbs.db +Servers +.metadata +upload +gen_code diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..b1bc6888b --- /dev/null +++ b/LICENSE @@ -0,0 +1,14 @@ + Copyright (c) 2018-2025, lengleng All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + Neither the name of the pig4cloud.com developer nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + Author: lengleng (wangiegie@gmail.com) diff --git a/README.md b/README.md new file mode 100644 index 000000000..16504adaa --- /dev/null +++ b/README.md @@ -0,0 +1,51 @@ +

+ Build Status + Coverage Status + Downloads +

+ +

Supporting Pig Developer Team

+ +## 项目官网 +https://pig4cloud.com + +### 配套代码 +pigx-ui + +### pigx 和 pig 区别 + +- 基于最新的Spring Cloud Finchley.RELEASE 版本 +- 完整的oAuth 流程,资源服务器控制权限 +- 去除了部分对于开发不友好的中间件 + +### 部署说明 +[部署说明](doc/deploy.md) + +## 协议和授权 + +pigX并非一个开源软件,作者保留全部的权利。 + +### 🌹权益 + +1. 个人使用 +2. 允许用于学习、毕设等。 + +### 🚫禁止 + +1. 将本项目的部分或全部代码和资源进行任何形式的再发行(尤其上传GitHub、Gitee ) +2. 利用本项目的部分或全部代码和资源进行`任何商业行为` +3. 举报有奖,抢先体验`pigx 2.0`。 + +## 贡献代码 + +pigX并非一个开源项目,也不是社区共同创造,其全部功能由作者独立完成。 + +如果你愿意放弃所有权利,并将权利无条件转让给pigX作者,欢迎您贡献代码,当然会给予不等金额奖励。 + +## 提交反馈 + +1. 欢迎提交 issue,请写清楚遇到问题的原因,浏览器和操作系统环境,重现的流程。 +如果有开发能力,建议在本地调试出出错的代码。 + +2. 不接受`功能请求`的 issue,功能请求可能会被直接关闭,请谅解(正确的方式是打赏并附言)。 + diff --git a/doc/PIGX.png b/doc/PIGX.png new file mode 100644 index 0000000000000000000000000000000000000000..5f7a010cf77fcd3f51f0650870044c9e9e35db89 GIT binary patch literal 44089 zcmeGEbx>7r*aiwO8bM0BLqb7Pkxmf=>F!3lyHP+&TDk?KQ|XkJM!Fm6?mW--_r7Q5 z%sGFaKfdpqZ_O|ao3+<|;*RUS?(5kh^0E>bXe4M51Yt#^%}l@H z93(^$muY(mJo{y|d~KuzrfoTeUpsM~IxWGOpU^5dk>HS~w~#dIE93ttntfE&?!zc=iRw)%tz;NP_4>7HVRd69tt6IIjFTj){jfe88Nbi1TN2q3 zE)LFbNjg_ZOiZk%UV_41EGad$IF8nw&F>dVY*&x=D!dLswzLA51XHG^mV zSb`9QN_`B6htPAkT~wAs>2pb~j0y)0o4xW#lf4jv_~3RohqKj7^Oy%6%++Gzv?Cx5Ly?sl~$cPq%NiOQ)!3$-+Phcr~xIGy{CmH9# z`FG79K)6&s}Y{Y;4O51$7g07&e%MyS+8;I=>N5#+I zco8=RrUtGaf`Guls!@w7&%c9dH;veaLC@`ri;Jz!*G|P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)-#%KF5&cI68XMNxUa{ag-iGNcewj-bC%l%a^>=9B2VbSJP;$$cEfb zt*1WdntPeg!fjNo0|vFYamV6#A-Y zNi($|Fk9W6G1J6=%=dsiyb~uPINY}2wOU{YuAnycv4qxP^#$34hG}UT!h_k~N5m+^ zg!}?fH{8|H!Tvb-BzENIT9R>t>UidXkf@1tS1+&rR{%|~PH_;p>`rKoC=V;`se zLH=yD(l{#5AtupEn;?8ls0gF`5(>V42L0V)D#F?iC_n$5P$;6aSnAxnm)b#eJ2O5I z``dq_q;E(l>`tS$Nr3N^cd2s7Zr$VGr{}W%dMA6`l?7u5&AVOwcLt|=?xS*zU@L`u^f7! z*16%DTF((0nz9qKg}&cVR|V75`WtF?LT@CHTmaz45!6&sVPT + + + + 4.0.0 + + com.pig4cloud + pigx + ${pigx.version} + + + pigx-auth + ${pigx.version} + jar + + pigx-auth + pigx 认证授权中心,基于 spring security oAuth2 + + + + + org.springframework.cloud + spring-cloud-starter-config + + + + com.pig4cloud + pigx-upms-api + ${pigx.version} + + + + org.springframework.cloud + spring-cloud-starter-security + + + + spring-security-oauth2 + org.springframework.security.oauth + + + + + org.springframework.security.oauth + spring-security-oauth2 + ${security.oauth.version} + + + + mysql + mysql-connector-java + + + + org.springframework.boot + spring-boot-starter-web + + + + spring-boot-starter-tomcat + org.springframework.boot + + + + + + org.springframework.boot + spring-boot-starter-undertow + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + ${project.name} + + + + + + diff --git a/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/PigxAuthApplication.java b/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/PigxAuthApplication.java new file mode 100644 index 000000000..223a53505 --- /dev/null +++ b/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/PigxAuthApplication.java @@ -0,0 +1,39 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.auth; + + +import org.springframework.boot.SpringApplication; +import org.springframework.cloud.client.SpringCloudApplication; +import org.springframework.cloud.openfeign.EnableFeignClients; + +/** + * @author lengleng + * @date 2018年06月21日 + * 认证授权中心 + */ +@SpringCloudApplication +@EnableFeignClients({"com.pig4cloud.pigx.admin.api.feign"}) +public class PigxAuthApplication { + + public static void main(String[] args) { + SpringApplication.run(PigxAuthApplication.class, args); + } +} diff --git a/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/config/AuthorizationServerConfig.java b/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/config/AuthorizationServerConfig.java new file mode 100644 index 000000000..c13da06a6 --- /dev/null +++ b/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/config/AuthorizationServerConfig.java @@ -0,0 +1,102 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.auth.config; + +import com.pig4cloud.pigx.common.core.constant.SecurityConstants; +import com.pig4cloud.pigx.common.security.compoent.PigxWebResponseExceptionTranslator; +import lombok.AllArgsConstructor; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.redis.connection.RedisConnectionFactory; +import org.springframework.http.HttpMethod; +import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken; +import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer; +import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter; +import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer; +import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer; +import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerSecurityConfigurer; +import org.springframework.security.oauth2.provider.client.JdbcClientDetailsService; +import org.springframework.security.oauth2.provider.token.TokenEnhancer; +import org.springframework.security.oauth2.provider.token.TokenStore; +import org.springframework.security.oauth2.provider.token.store.redis.RedisTokenStore; + +import javax.sql.DataSource; +import java.util.HashMap; +import java.util.Map; + +/** + * @author lengleng + * @date 2018/6/22 + * 认证服务器配置 + */ +@Configuration +@AllArgsConstructor +@EnableAuthorizationServer +public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdapter { + private final DataSource dataSource; + private final AuthenticationManager authenticationManager; + private final RedisConnectionFactory redisConnectionFactory; + + @Override + public void configure(ClientDetailsServiceConfigurer clients) throws Exception { + JdbcClientDetailsService clientDetailsService = new JdbcClientDetailsService(dataSource); + clientDetailsService.setSelectClientDetailsSql(SecurityConstants.DEFAULT_SELECT_STATEMENT); + clientDetailsService.setFindClientDetailsSql(SecurityConstants.DEFAULT_FIND_STATEMENT); + clients.withClientDetails(clientDetailsService); + } + + @Override + public void configure(AuthorizationServerSecurityConfigurer oauthServer) throws Exception { + oauthServer + .allowFormAuthenticationForClients() + .checkTokenAccess("permitAll()"); + } + + @Override + public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { + endpoints + .allowedTokenEndpointRequestMethods(HttpMethod.GET, HttpMethod.POST) + .tokenStore(tokenStore()) + .tokenEnhancer(tokenEnhancer()) + .authenticationManager(authenticationManager) + .reuseRefreshTokens(false) + .exceptionTranslator(new PigxWebResponseExceptionTranslator()); + } + + + + @Bean + public TokenStore tokenStore() { + RedisTokenStore tokenStore = new RedisTokenStore(redisConnectionFactory); + tokenStore.setPrefix(SecurityConstants.PIGX_PREFIX + SecurityConstants.OAUTH_PREFIX); + return tokenStore; + } + + @Bean + public TokenEnhancer tokenEnhancer() { + return (accessToken, authentication) -> { + final Map additionalInfo = new HashMap<>(1); + additionalInfo.put("license", SecurityConstants.PIGX_LICENSE); + ((DefaultOAuth2AccessToken) accessToken).setAdditionalInformation(additionalInfo); + return accessToken; + }; + } +} diff --git a/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/config/WebSecurityConfigurer.java b/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/config/WebSecurityConfigurer.java new file mode 100644 index 000000000..837c086aa --- /dev/null +++ b/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/config/WebSecurityConfigurer.java @@ -0,0 +1,68 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.auth.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.core.annotation.Order; +import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.crypto.factory.PasswordEncoderFactories; +import org.springframework.security.crypto.password.PasswordEncoder; + +/** + * @author lengleng + * @date 2018/6/22 + * 认证相关配置 + */ +@Primary +@Order(90) +@Configuration +public class WebSecurityConfigurer extends WebSecurityConfigurerAdapter { + + @Override + protected void configure(HttpSecurity http) throws Exception { + http + .authorizeRequests() + .antMatchers("/actuator/**", "/oauth/removeToken").permitAll() + .anyRequest().authenticated() + .and().csrf().disable(); + } + + @Bean + @Override + public AuthenticationManager authenticationManagerBean() throws Exception { + return super.authenticationManagerBean(); + } + + /** + * https://spring.io/blog/2017/11/01/spring-security-5-0-0-rc1-released#password-storage-updated + * Encoded password does not look like BCrypt + * + * @return PasswordEncoder + */ + @Bean + public PasswordEncoder passwordEncoder() { + return PasswordEncoderFactories.createDelegatingPasswordEncoder(); + } + +} diff --git a/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/endpoint/RevokeTokenEndpoint.java b/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/endpoint/RevokeTokenEndpoint.java new file mode 100644 index 000000000..811978edd --- /dev/null +++ b/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/endpoint/RevokeTokenEndpoint.java @@ -0,0 +1,59 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.auth.endpoint; + +import cn.hutool.core.util.StrUtil; +import com.pig4cloud.pigx.common.core.util.R; +import lombok.AllArgsConstructor; +import org.springframework.security.oauth2.common.OAuth2AccessToken; +import org.springframework.security.oauth2.provider.token.TokenStore; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author lengleng + * @date 2018/6/24 + * 删除token端点 + */ +@RestController +@AllArgsConstructor +public class RevokeTokenEndpoint { + private final TokenStore tokenStore; + + /** + * 删除token + * + * @param authHeader Authorization + */ + @RequestMapping("/oauth/removeToken") + public R logout(@RequestHeader(value = "Authorization", required = false) String authHeader) { + if (StringUtils.hasText(authHeader)) { + String tokenValue = authHeader.replace("Bearer", "").trim(); + OAuth2AccessToken accessToken = tokenStore.readAccessToken(tokenValue); + if (accessToken == null || StrUtil.isBlank(accessToken.getValue())) { + return new R<>(false, "退出失败,token 为空"); + } + tokenStore.removeAccessToken(accessToken); + } + return new R<>(Boolean.TRUE); + } +} diff --git a/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/service/PigxUserDetailsServiceImpl.java b/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/service/PigxUserDetailsServiceImpl.java new file mode 100644 index 000000000..f709b31aa --- /dev/null +++ b/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/service/PigxUserDetailsServiceImpl.java @@ -0,0 +1,81 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.auth.service; + +import cn.hutool.core.util.ArrayUtil; +import cn.hutool.core.util.StrUtil; +import com.pig4cloud.pigx.admin.api.dto.UserInfo; +import com.pig4cloud.pigx.admin.api.entity.SysUser; +import com.pig4cloud.pigx.admin.api.feign.RemoteUserService; +import com.pig4cloud.pigx.common.core.constant.CommonConstant; +import com.pig4cloud.pigx.common.core.constant.SecurityConstants; +import com.pig4cloud.pigx.common.core.util.R; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.AuthorityUtils; +import org.springframework.security.core.userdetails.User; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.security.core.userdetails.UsernameNotFoundException; +import org.springframework.stereotype.Service; + +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +/** + * 用户详细信息 + * + * @author lengleng + */ +@Slf4j +@Service +@AllArgsConstructor +public class PigxUserDetailsServiceImpl implements UserDetailsService { + private final RemoteUserService remoteUserService; + + @Override + public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { + R result = remoteUserService.info(username, SecurityConstants.FROM_IN); + + if (result == null || result.getData() == null) { + throw new UsernameNotFoundException("用户不存在"); + } + + UserInfo info = result.getData(); + Set dbAuthsSet = new HashSet<>(); + if (ArrayUtil.isNotEmpty(info.getRoles())) { + // 获取角色 + Arrays.stream(info.getRoles()).forEach(role -> dbAuthsSet.add(SecurityConstants.ROLE + role)); + // 获取资源 + dbAuthsSet.addAll(Arrays.asList(info.getPermissions())); + + } + Collection authorities + = AuthorityUtils.createAuthorityList(dbAuthsSet.toArray(new String[0])); + SysUser user = info.getSysUser(); + boolean enabled = StrUtil.equals(user.getDelFlag(), CommonConstant.STATUS_NORMAL); + // 构造security用户 + return new User(username, SecurityConstants.BCRYPT + user.getPassword(), enabled, + true, true, true, authorities); + } +} diff --git a/pigx-auth/src/main/resources/bootstrap.yml b/pigx-auth/src/main/resources/bootstrap.yml new file mode 100644 index 000000000..73d9d7df3 --- /dev/null +++ b/pigx-auth/src/main/resources/bootstrap.yml @@ -0,0 +1,26 @@ +server: + port: 3000 + +spring: + application: + name: pigx-auth + # 配置中心 + cloud: + config: + fail-fast: true + name: ${spring.application.name} + profile: dev + discovery: + enabled: true + service-id: pigx-config + +# 注册中心配置 +eureka: + instance: + prefer-ip-address: true + client: + service-url: + defaultZone: http://pig:pig@localhost:1025/eureka/ +logging: + level: + root: debug diff --git a/pigx-common/pigx-common-code/src/main/java/com/pig4cloud/pigx/common/code/config/KaptchaConfiguration.java b/pigx-common/pigx-common-code/src/main/java/com/pig4cloud/pigx/common/code/config/KaptchaConfiguration.java new file mode 100644 index 000000000..aae34dbfc --- /dev/null +++ b/pigx-common/pigx-common-code/src/main/java/com/pig4cloud/pigx/common/code/config/KaptchaConfiguration.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.gateway.config; + +import com.google.code.kaptcha.impl.DefaultKaptcha; +import com.google.code.kaptcha.util.Config; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.util.Properties; + +/** + * @author lengleng + * @date 2017-12-21 21:12:18 + */ +@Configuration +public class KaptchaConfiguration { + + private static final String KAPTCHA_BORDER = "kaptcha.border"; + private static final String KAPTCHA_TEXTPRODUCER_FONT_COLOR = "kaptcha.textproducer.font.color"; + private static final String KAPTCHA_TEXTPRODUCER_CHAR_SPACE = "kaptcha.textproducer.char.space"; + private static final String KAPTCHA_IMAGE_WIDTH = "kaptcha.image.width"; + private static final String KAPTCHA_IMAGE_HEIGHT = "kaptcha.image.height"; + private static final String KAPTCHA_TEXTPRODUCER_CHAR_LENGTH = "kaptcha.textproducer.char.length"; + private static final Object KAPTCHA_IMAGE_FONT_SIZE = "kaptcha.textproducer.font.size"; + + /** + * 默认生成图形验证码宽度 + */ + String DEFAULT_IMAGE_WIDTH = "100"; + + /** + * 默认生成图像验证码高度 + */ + String DEFAULT_IMAGE_HEIGHT = "40"; + + /** + * 默认生成图形验证码长度 + */ + String DEFAULT_IMAGE_LENGTH = "4"; + + /** + * 默认生成图形验证码过期时间 + */ + int DEFAULT_IMAGE_EXPIRE = 60; + /** + * 边框颜色,合法值: r,g,b (and optional alpha) 或者 white,black,blue. + */ + String DEFAULT_COLOR_FONT = "black"; + + /** + * 图片边框 + */ + String DEFAULT_IMAGE_BORDER = "no"; + /** + * 默认图片间隔 + */ + String DEFAULT_CHAR_SPACE = "5"; + + /** + * 默认保存code的前缀 + */ + String DEFAULT_CODE_KEY = "DEFAULT_CODE_KEY"; + /** + * 验证码文字大小 + */ + String DEFAULT_IMAGE_FONT_SIZE = "30"; + + @Bean + public DefaultKaptcha producer() { + Properties properties = new Properties(); + properties.put(KAPTCHA_BORDER, DEFAULT_IMAGE_BORDER); + properties.put(KAPTCHA_TEXTPRODUCER_FONT_COLOR, DEFAULT_COLOR_FONT); + properties.put(KAPTCHA_TEXTPRODUCER_CHAR_SPACE, DEFAULT_CHAR_SPACE); + properties.put(KAPTCHA_IMAGE_WIDTH, DEFAULT_IMAGE_WIDTH); + properties.put(KAPTCHA_IMAGE_HEIGHT, DEFAULT_IMAGE_HEIGHT); + properties.put(KAPTCHA_IMAGE_FONT_SIZE, DEFAULT_IMAGE_FONT_SIZE); + properties.put(KAPTCHA_TEXTPRODUCER_CHAR_LENGTH, DEFAULT_IMAGE_LENGTH); + Config config = new Config(properties); + DefaultKaptcha defaultKaptcha = new DefaultKaptcha(); + defaultKaptcha.setConfig(config); + return defaultKaptcha; + } +} diff --git a/pigx-common/pigx-common-code/src/main/java/com/pig4cloud/pigx/common/code/exception/ValidateCodeException.java b/pigx-common/pigx-common-code/src/main/java/com/pig4cloud/pigx/common/code/exception/ValidateCodeException.java new file mode 100644 index 000000000..a86375ac3 --- /dev/null +++ b/pigx-common/pigx-common-code/src/main/java/com/pig4cloud/pigx/common/code/exception/ValidateCodeException.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.gateway.exception; + +/** + * @author lengleng + */ +public class ValidateCodeException extends Exception { + +} diff --git a/pigx-common/pigx-common-code/src/main/java/com/pig4cloud/pigx/common/code/filter/ImageCodeGatewayFilter.java b/pigx-common/pigx-common-code/src/main/java/com/pig4cloud/pigx/common/code/filter/ImageCodeGatewayFilter.java new file mode 100644 index 000000000..99fe66cff --- /dev/null +++ b/pigx-common/pigx-common-code/src/main/java/com/pig4cloud/pigx/common/code/filter/ImageCodeGatewayFilter.java @@ -0,0 +1,93 @@ +package com.pig4cloud.pigx.gateway.filter; + +import cn.hutool.core.util.StrUtil; +import com.pig4cloud.pigx.gateway.exception.ValidateCodeException; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cloud.gateway.filter.GatewayFilter; +import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.http.HttpStatus; +import org.springframework.http.server.reactive.ServerHttpRequest; +import org.springframework.http.server.reactive.ServerHttpResponse; +import org.springframework.stereotype.Component; + +/** + * @author lengleng + * @date 2018/7/4 + * 验证码处理 + */ +@Slf4j +@Component +public class ImageCodeGatewayFilter extends AbstractGatewayFilterFactory { + private static final String OAUTH_TOKEN_URL = "/oauth/token"; + public static final String DEFAULT_CODE_KEY = "DEFAULT_CODE_KEY"; + + @Autowired + private RedisTemplate redisTemplate; + + @Override + public GatewayFilter apply(Object config) { + return (exchange, chain) -> { + ServerHttpRequest request = exchange.getRequest(); + + // 不是登录请求,直接向下执行 + if (!StrUtil.containsAnyIgnoreCase(request.getURI().getPath(), OAUTH_TOKEN_URL)) { + return chain.filter(exchange); + } + try { + checkCode(request); + } catch (ValidateCodeException e) { + ServerHttpResponse response = exchange.getResponse(); + response.setStatusCode(HttpStatus.PRECONDITION_REQUIRED); + return response.setComplete(); + } + + return chain.filter(exchange); + }; + } + + + /** + * 检查code + * + * @param request + * @throws ValidateCodeException 校验异常 + */ + private void checkCode(ServerHttpRequest request) throws ValidateCodeException { + String code = request.getQueryParams().getFirst("code"); + + if (StrUtil.isBlank(code)) { + throw new ValidateCodeException(); + } + + String randomStr = request.getQueryParams().getFirst("randomStr"); + if (StrUtil.isBlank(randomStr)) { + throw new ValidateCodeException(); + } + + String key = DEFAULT_CODE_KEY + randomStr; + if (!redisTemplate.hasKey(key)) { + throw new ValidateCodeException(); + } + + Object codeObj = redisTemplate.opsForValue().get(key); + + if (codeObj == null) { + throw new ValidateCodeException(); + } + + String saveCode = codeObj.toString(); + if (StrUtil.isBlank(saveCode)) { + redisTemplate.delete(key); + throw new ValidateCodeException(); + } + + if (!StrUtil.equals(saveCode, code)) { + redisTemplate.delete(key); + throw new ValidateCodeException(); + } + + redisTemplate.delete(key); + } +} diff --git a/pigx-common/pigx-common-code/src/main/java/com/pig4cloud/pigx/common/code/handle/ImageCodeHandler.java b/pigx-common/pigx-common-code/src/main/java/com/pig4cloud/pigx/common/code/handle/ImageCodeHandler.java new file mode 100644 index 000000000..ccdb6d45f --- /dev/null +++ b/pigx-common/pigx-common-code/src/main/java/com/pig4cloud/pigx/common/code/handle/ImageCodeHandler.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.gateway.handle; + +import com.google.code.kaptcha.Producer; +import com.pig4cloud.pigx.gateway.filter.ImageCodeGatewayFilter; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.core.io.ByteArrayResource; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.stereotype.Component; +import org.springframework.util.FastByteArrayOutputStream; +import org.springframework.web.reactive.function.BodyInserters; +import org.springframework.web.reactive.function.server.HandlerFunction; +import org.springframework.web.reactive.function.server.ServerRequest; +import org.springframework.web.reactive.function.server.ServerResponse; +import reactor.core.publisher.Mono; + +import javax.imageio.ImageIO; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.util.concurrent.TimeUnit; + +/** + * @author lengleng + * @date 2018/7/5 + * 验证码生成逻辑处理类 + */ +@Slf4j +@Component +@AllArgsConstructor +public class ImageCodeHandler implements HandlerFunction { + private final Producer producer; + private final RedisTemplate redisTemplate; + + @Override + public Mono handle(ServerRequest serverRequest) { + //生成验证码 + String text = producer.createText(); + BufferedImage image = producer.createImage(text); + + //保存验证码信息 + String randomStr = serverRequest.queryParam("randomStr").get(); + redisTemplate.opsForValue().set(ImageCodeGatewayFilter.DEFAULT_CODE_KEY + randomStr, text, 60, TimeUnit.SECONDS); + + // 转换流信息写出 + FastByteArrayOutputStream os = new FastByteArrayOutputStream(); + try { + ImageIO.write(image, "jpeg", os); + } catch (IOException e) { + log.error("ImageIO write err", e); + return Mono.error(e); + } + + return ServerResponse + .status(HttpStatus.OK) + .contentType(MediaType.IMAGE_JPEG) + .body(BodyInserters.fromResource(new ByteArrayResource(os.toByteArray()))); + } +} diff --git a/pigx-common/pigx-common-core/pom.xml b/pigx-common/pigx-common-core/pom.xml new file mode 100644 index 000000000..afe5c6b8c --- /dev/null +++ b/pigx-common/pigx-common-core/pom.xml @@ -0,0 +1,63 @@ + + + + + 4.0.0 + + com.pig4cloud + pigx-common + ${pigx.version} + + + pigx-common-core + ${pigx.version} + jar + pigx-common-core + pigx 公共工具类核心包 + + + + + + cn.hutool + hutool-all + ${hutool.version} + + + + com.alibaba + fastjson + ${fastjson.version} + + + + org.springframework.boot + spring-boot-starter-data-redis + + + + javax.servlet + javax.servlet-api + ${servlet-api.version} + provided + + + diff --git a/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/config/RedisConfig.java b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/config/RedisConfig.java new file mode 100644 index 000000000..2890d8c28 --- /dev/null +++ b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/config/RedisConfig.java @@ -0,0 +1,77 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.common.core.config; + +import lombok.AllArgsConstructor; +import org.springframework.cache.annotation.EnableCaching; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.redis.connection.RedisConnectionFactory; +import org.springframework.data.redis.core.*; +import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer; +import org.springframework.data.redis.serializer.StringRedisSerializer; + +/** + * @author lengleng + * @date 2018/6/23 + * Redis 配置类 + */ +@EnableCaching +@Configuration +@AllArgsConstructor +public class RedisConfig { + private final RedisConnectionFactory factory; + + @Bean + public RedisTemplate redisTemplate() { + RedisTemplate redisTemplate = new RedisTemplate<>(); + redisTemplate.setKeySerializer(new StringRedisSerializer()); + redisTemplate.setHashKeySerializer(new StringRedisSerializer()); + redisTemplate.setValueSerializer(new JdkSerializationRedisSerializer()); + redisTemplate.setHashValueSerializer(new JdkSerializationRedisSerializer()); + redisTemplate.setConnectionFactory(factory); + return redisTemplate; + } + + @Bean + public HashOperations hashOperations(RedisTemplate redisTemplate) { + return redisTemplate.opsForHash(); + } + + @Bean + public ValueOperations valueOperations(RedisTemplate redisTemplate) { + return redisTemplate.opsForValue(); + } + + @Bean + public ListOperations listOperations(RedisTemplate redisTemplate) { + return redisTemplate.opsForList(); + } + + @Bean + public SetOperations setOperations(RedisTemplate redisTemplate) { + return redisTemplate.opsForSet(); + } + + @Bean + public ZSetOperations zSetOperations(RedisTemplate redisTemplate) { + return redisTemplate.opsForZSet(); + } +} diff --git a/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/CommonConstant.java b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/CommonConstant.java new file mode 100644 index 000000000..5b0e0c472 --- /dev/null +++ b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/CommonConstant.java @@ -0,0 +1,89 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.common.core.constant; + +/** + * @author lengleng + * @date 2017/10/29 + */ +public interface CommonConstant { + /** + * token请求头名称 + */ + String REQ_HEADER = "Authorization"; + + /** + * token分割符 + */ + String TOKEN_SPLIT = "Bearer "; + + /** + * jwt签名 + */ + String SIGN_KEY = "PIG"; + /** + * 删除 + */ + String STATUS_DEL = "1"; + /** + * 正常 + */ + String STATUS_NORMAL = "0"; + + /** + * 锁定 + */ + String STATUS_LOCK = "9"; + + /** + * 菜单 + */ + String MENU = "0"; + + /** + * 按钮 + */ + String BUTTON = "1"; + + /** + * 删除标记 + */ + String DEL_FLAG = "del_flag"; + + /** + * 编码 + */ + String UTF8 = "UTF-8"; + + /** + * JSON 资源 + */ + String CONTENT_TYPE = "application/json; charset=utf-8"; + + /** + * 阿里大鱼 + */ + String ALIYUN_SMS = "aliyun_sms"; + + /** + * 路由信息Redis保存的key + */ + String ROUTE_KEY = "_ROUTE_KEY"; +} diff --git a/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/MqQueueConstant.java b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/MqQueueConstant.java new file mode 100644 index 000000000..901b497ad --- /dev/null +++ b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/MqQueueConstant.java @@ -0,0 +1,57 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.common.core.constant; + +/** + * @author lengleng + * @date 2018/1/15 + * MQ 消息队列 + */ +public interface MqQueueConstant { + /** + * log rabbit队列名称 + */ + String LOG_QUEUE = "log"; + + /** + * 发送短信验证码队列 + */ + String MOBILE_CODE_QUEUE = "mobile_code_queue"; + + /** + * 短信服务状态队列 + */ + String MOBILE_SERVICE_STATUS_CHANGE = "mobile_service_status_change"; + + /** + * 钉钉服务状态队列 + */ + String DINGTALK_SERVICE_STATUS_CHANGE = "dingtalk_service_status_change"; + + /** + * zipkin 队列 + */ + String ZIPKIN_NAME_QUEUE = "zipkin"; + + /** + * 路由配置状态队列 + */ + String ROUTE_CONFIG_CHANGE = "route_config_change"; +} diff --git a/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/SecurityConstants.java b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/SecurityConstants.java new file mode 100644 index 000000000..e3120b138 --- /dev/null +++ b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/SecurityConstants.java @@ -0,0 +1,77 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.common.core.constant; + +/** + * @author lengleng + * @date 2017-12-18 + */ +public interface SecurityConstants { + /** + * 角色前缀 + */ + String ROLE = "ROLE_"; + /** + * 前缀 + */ + String PIGX_PREFIX = "pigx_"; + + /** + * oauth 相关前缀 + */ + String OAUTH_PREFIX = "oauth:"; + /** + * 项目的license + */ + String PIGX_LICENSE = "made by pigx"; + + /** + * 内部 + */ + String FROM_IN = "Y"; + + /** + * {bcrypt} 加密的特征码 + */ + String BCRYPT = "{bcrypt}"; + /** + * sys_oauth_client_details 表的字段,不包括client_id、client_secret + */ + String CLIENT_FIELDS = "client_id, CONCAT('{noop}',client_secret) as client_secret, resource_ids, scope, " + + "authorized_grant_types, web_server_redirect_uri, authorities, access_token_validity, " + + "refresh_token_validity, additional_information, autoapprove"; + + /** + * JdbcClientDetailsService 查询语句 + */ + String BASE_FIND_STATEMENT = "select " + CLIENT_FIELDS + + " from sys_oauth_client_details"; + + /** + * 默认的查询语句 + */ + String DEFAULT_FIND_STATEMENT = BASE_FIND_STATEMENT + " order by client_id"; + + /** + * 按条件client_id 查询 + */ + String DEFAULT_SELECT_STATEMENT = BASE_FIND_STATEMENT + " where client_id = ?"; + +} diff --git a/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/ServiceNameConstant.java b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/ServiceNameConstant.java new file mode 100644 index 000000000..da11cb17e --- /dev/null +++ b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/ServiceNameConstant.java @@ -0,0 +1,37 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.common.core.constant; + +/** + * @author lengleng + * @date 2018年06月22日16:41:01 + * 服务名称 + */ +public interface ServiceNameConstant { + /** + * 认证服务的SERVICEID(zuul 配置的对应) + */ + String AUTH_SERVICE = "pigx-auth"; + + /** + * UMPS模块 + */ + String UMPS_SERVICE = "pigx-upms"; +} diff --git a/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/enums/EnumSmsChannel.java b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/enums/EnumSmsChannel.java new file mode 100644 index 000000000..a77c77b4a --- /dev/null +++ b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/enums/EnumSmsChannel.java @@ -0,0 +1,45 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.common.core.constant.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author lengleng + * @date 2018/1/16 + * 短信通道枚举 + */ +@Getter +@AllArgsConstructor +public enum EnumSmsChannel { + /** + * 阿里大鱼短信通道 + */ + ALIYUN("ALIYUN_SMS", "阿里大鱼"); + /** + * 通道名称 + */ + private final String name; + /** + * 通道描述 + */ + private final String description; +} diff --git a/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/enums/EnumSmsChannelTemplate.java b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/enums/EnumSmsChannelTemplate.java new file mode 100644 index 000000000..cd767d9ed --- /dev/null +++ b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/enums/EnumSmsChannelTemplate.java @@ -0,0 +1,50 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.common.core.constant.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author LiXunHuan + * @date 2018/1/16 + * 短信通道模板 + */ +@Getter +@AllArgsConstructor +public enum EnumSmsChannelTemplate { + /** + * 登录验证 + */ + LOGIN_NAME_LOGIN("loginCodeChannel", "登录验证"), + /** + * 服务异常提醒 + */ + SERVICE_STATUS_CHANGE("serviceStatusChange", "Pig4Cloud"); + + /** + * 模板名称 + */ + private final String template; + /** + * 模板签名 + */ + private final String signName; +} diff --git a/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/exception/CheckedException.java b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/exception/CheckedException.java new file mode 100644 index 000000000..36201eb47 --- /dev/null +++ b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/exception/CheckedException.java @@ -0,0 +1,48 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.common.core.exception; + +import lombok.NoArgsConstructor; + +/** + * @author lengleng + * @date 😴2018年06月22日16:21:57 + */ +@NoArgsConstructor +public class CheckedException extends RuntimeException { + private static final long serialVersionUID = 1L; + + public CheckedException(String message) { + super(message); + } + + public CheckedException(Throwable cause) { + super(cause); + } + + public CheckedException(String message, Throwable cause) { + super(message, cause); + } + + public CheckedException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } + +} diff --git a/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/exception/PigDeniedException.java b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/exception/PigDeniedException.java new file mode 100644 index 000000000..f21cdc37a --- /dev/null +++ b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/exception/PigDeniedException.java @@ -0,0 +1,49 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.common.core.exception; + +import lombok.NoArgsConstructor; + +/** + * @author lengleng + * @date 2018年06月22日16:22:03 + * 403 授权拒绝 + */ +@NoArgsConstructor +public class PigDeniedException extends RuntimeException { + private static final long serialVersionUID = 1L; + + public PigDeniedException(String message) { + super(message); + } + + public PigDeniedException(Throwable cause) { + super(cause); + } + + public PigDeniedException(String message, Throwable cause) { + super(message, cause); + } + + public PigDeniedException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } + +} diff --git a/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/exception/UnloginException.java b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/exception/UnloginException.java new file mode 100644 index 000000000..4518b3231 --- /dev/null +++ b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/exception/UnloginException.java @@ -0,0 +1,48 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.common.core.exception; + +import lombok.NoArgsConstructor; + +/** + * @author lengleng + * @date 2018年06月22日16:22:10 + */ +@NoArgsConstructor +public class UnloginException extends RuntimeException { + private static final long serialVersionUID = 1L; + + public UnloginException(String message) { + super(message); + } + + public UnloginException(Throwable cause) { + super(cause); + } + + public UnloginException(String message, Throwable cause) { + super(message, cause); + } + + public UnloginException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } + +} diff --git a/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/exception/ValidateCodeException.java b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/exception/ValidateCodeException.java new file mode 100644 index 000000000..db5bb10da --- /dev/null +++ b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/exception/ValidateCodeException.java @@ -0,0 +1,32 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.common.core.exception; + +/** + * @author lengleng + * @date 2018年06月22日16:22:15 + */ +public class ValidateCodeException extends Exception { + private static final long serialVersionUID = -7285211528095468156L; + + public ValidateCodeException(String msg) { + super(msg); + } +} diff --git a/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/util/ClassUtils.java b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/util/ClassUtils.java new file mode 100644 index 000000000..61125d4aa --- /dev/null +++ b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/util/ClassUtils.java @@ -0,0 +1,112 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.common.core.util; + +import org.springframework.core.BridgeMethodResolver; +import org.springframework.core.DefaultParameterNameDiscoverer; +import org.springframework.core.MethodParameter; +import org.springframework.core.ParameterNameDiscoverer; +import org.springframework.core.annotation.AnnotatedElementUtils; +import org.springframework.core.annotation.SynthesizingMethodParameter; +import org.springframework.web.method.HandlerMethod; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; + +/** + * 类工具类 + * + * @author L.cm + */ +public class ClassUtils extends org.springframework.util.ClassUtils { + private static final ParameterNameDiscoverer PARAMETERNAMEDISCOVERER = new DefaultParameterNameDiscoverer(); + + /** + * 获取方法参数信息 + * + * @param constructor 构造器 + * @param parameterIndex 参数序号 + * @return {MethodParameter} + */ + public static MethodParameter getMethodParameter(Constructor constructor, int parameterIndex) { + MethodParameter methodParameter = new SynthesizingMethodParameter(constructor, parameterIndex); + methodParameter.initParameterNameDiscovery(PARAMETERNAMEDISCOVERER); + return methodParameter; + } + + /** + * 获取方法参数信息 + * + * @param method 方法 + * @param parameterIndex 参数序号 + * @return {MethodParameter} + */ + public static MethodParameter getMethodParameter(Method method, int parameterIndex) { + MethodParameter methodParameter = new SynthesizingMethodParameter(method, parameterIndex); + methodParameter.initParameterNameDiscovery(PARAMETERNAMEDISCOVERER); + return methodParameter; + } + + /** + * 获取Annotation + * + * @param method Method + * @param annotationType 注解类 + * @param 泛型标记 + * @return {Annotation} + */ + public static A getAnnotation(Method method, Class annotationType) { + Class targetClass = method.getDeclaringClass(); + // The method may be on an interface, but we need attributes from the target class. + // If the target class is null, the method will be unchanged. + Method specificMethod = ClassUtils.getMostSpecificMethod(method, targetClass); + // If we are dealing with method with generic parameters, find the original method. + specificMethod = BridgeMethodResolver.findBridgedMethod(specificMethod); + // 先找方法,再找方法上的类 + A annotation = AnnotatedElementUtils.findMergedAnnotation(specificMethod, annotationType); + ; + if (null != annotation) { + return annotation; + } + // 获取类上面的Annotation,可能包含组合注解,故采用spring的工具类 + return AnnotatedElementUtils.findMergedAnnotation(specificMethod.getDeclaringClass(), annotationType); + } + + /** + * 获取Annotation + * + * @param handlerMethod HandlerMethod + * @param annotationType 注解类 + * @param 泛型标记 + * @return {Annotation} + */ + public static A getAnnotation(HandlerMethod handlerMethod, Class annotationType) { + // 先找方法,再找方法上的类 + A annotation = handlerMethod.getMethodAnnotation(annotationType); + if (null != annotation) { + return annotation; + } + // 获取类上面的Annotation,可能包含组合注解,故采用spring的工具类 + Class beanType = handlerMethod.getBeanType(); + return AnnotatedElementUtils.findMergedAnnotation(beanType, annotationType); + } + +} diff --git a/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/util/R.java b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/util/R.java new file mode 100644 index 000000000..e9a14ff3c --- /dev/null +++ b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/util/R.java @@ -0,0 +1,71 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.common.core.util; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.io.Serializable; + +/** + * 响应信息主体 + * + * @param + * @author lengleng + */ +@ToString +public class R implements Serializable { + private static final int SUCCESS = 0; + private static final int FAIL = 1; + private static final long serialVersionUID = 1L; + @Getter + @Setter + private String msg = "success"; + + @Getter + @Setter + private int code = SUCCESS; + + @Getter + @Setter + private T data; + + public R() { + super(); + } + + public R(T data) { + super(); + this.data = data; + } + + public R(T data, String msg) { + super(); + this.data = data; + this.msg = msg; + } + + public R(Throwable e) { + super(); + this.msg = e.getMessage(); + this.code = FAIL; + } +} diff --git a/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/util/SpringContextHolder.java b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/util/SpringContextHolder.java new file mode 100644 index 000000000..0eacf108d --- /dev/null +++ b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/util/SpringContextHolder.java @@ -0,0 +1,102 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.common.core.util; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.DisposableBean; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.context.ApplicationEvent; +import org.springframework.context.annotation.Lazy; +import org.springframework.stereotype.Service; + +/** + * @author lengleng + * @date 2018/6/27 + * Spring 工具类 + */ +@Slf4j +@Service +@Lazy(false) +public class SpringContextHolder implements ApplicationContextAware, DisposableBean { + + private static ApplicationContext applicationContext = null; + + /** + * 取得存储在静态变量中的ApplicationContext. + */ + public static ApplicationContext getApplicationContext() { + return applicationContext; + } + + /** + * 实现ApplicationContextAware接口, 注入Context到静态变量中. + */ + @Override + public void setApplicationContext(ApplicationContext applicationContext) { + SpringContextHolder.applicationContext = applicationContext; + } + + /** + * 从静态变量applicationContext中取得Bean, 自动转型为所赋值对象的类型. + */ + @SuppressWarnings("unchecked") + public static T getBean(String name) { + return (T) applicationContext.getBean(name); + } + + /** + * 从静态变量applicationContext中取得Bean, 自动转型为所赋值对象的类型. + */ + public static T getBean(Class requiredType) { + return applicationContext.getBean(requiredType); + } + + /** + * 清除SpringContextHolder中的ApplicationContext为Null. + */ + public static void clearHolder() { + if (log.isDebugEnabled()) { + log.debug("清除SpringContextHolder中的ApplicationContext:" + applicationContext); + } + applicationContext = null; + } + + /** + * 发布事件 + * + * @param event + */ + public static void publishEvent(ApplicationEvent event) { + if (applicationContext == null) { + return; + } + applicationContext.publishEvent(event); + } + + /** + * 实现DisposableBean接口, 在Context关闭时清理静态变量. + */ + @Override + public void destroy() throws Exception { + SpringContextHolder.clearHolder(); + } + +} diff --git a/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/util/WebUtils.java b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/util/WebUtils.java new file mode 100644 index 000000000..8609e791e --- /dev/null +++ b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/util/WebUtils.java @@ -0,0 +1,195 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.common.core.util; + +import cn.hutool.json.JSONUtil; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang.StringUtils; +import org.springframework.http.MediaType; +import org.springframework.util.Assert; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import org.springframework.web.method.HandlerMethod; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintWriter; + + +/** + * Miscellaneous utilities for web applications. + * + * @author L.cm + */ +@Slf4j +public class WebUtils extends org.springframework.web.util.WebUtils { + + public static final String UNKNOWN = "unknown"; + + /** + * 判断是否ajax请求 + * spring ajax 返回含有 ResponseBody 或者 RestController注解 + * + * @param handlerMethod HandlerMethod + * @return 是否ajax请求 + */ + public static boolean isBody(HandlerMethod handlerMethod) { + ResponseBody responseBody = ClassUtils.getAnnotation(handlerMethod, ResponseBody.class); + return responseBody != null; + } + + /** + * 读取cookie + * + * @param name cookie name + * @return cookie value + */ + public static String getCookieVal(String name) { + HttpServletRequest request = WebUtils.getRequest(); + Assert.notNull(request, "request from RequestContextHolder is null"); + return getCookieVal(request, name); + } + + /** + * 读取cookie + * + * @param request HttpServletRequest + * @param name cookie name + * @return cookie value + */ + public static String getCookieVal(HttpServletRequest request, String name) { + Cookie cookie = getCookie(request, name); + return cookie != null ? cookie.getValue() : null; + } + + /** + * 清除 某个指定的cookie + * + * @param response HttpServletResponse + * @param key cookie key + */ + public static void removeCookie(HttpServletResponse response, String key) { + setCookie(response, key, null, 0); + } + + /** + * 设置cookie + * + * @param response HttpServletResponse + * @param name cookie name + * @param value cookie value + * @param maxAgeInSeconds maxage + */ + public static void setCookie(HttpServletResponse response, String name, String value, int maxAgeInSeconds) { + Cookie cookie = new Cookie(name, value); + cookie.setPath("/"); + cookie.setMaxAge(maxAgeInSeconds); + cookie.setHttpOnly(true); + response.addCookie(cookie); + } + + /** + * 获取 HttpServletRequest + * + * @return {HttpServletRequest} + */ + public static HttpServletRequest getRequest() { + return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + } + + /** + * 获取 HttpServletResponse + * + * @return {HttpServletResponse} + */ + public static HttpServletResponse getResponse() { + return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse(); + } + + /** + * 返回json + * + * @param response HttpServletResponse + * @param result 结果对象 + */ + public static void renderJson(HttpServletResponse response, Object result) { + renderJson(response, result, MediaType.APPLICATION_JSON_UTF8_VALUE); + } + + /** + * 返回json + * + * @param response HttpServletResponse + * @param result 结果对象 + * @param contentType contentType + */ + public static void renderJson(HttpServletResponse response, Object result, String contentType) { + response.setCharacterEncoding("UTF-8"); + response.setContentType(contentType); + try (PrintWriter out = response.getWriter()) { + out.append(JSONUtil.toJsonStr(result)); + } catch (IOException e) { + log.error(e.getMessage(), e); + } + } + + /** + * 获取ip + * + * @return {String} + */ + public static String getIP() { + return getIP(WebUtils.getRequest()); + } + + /** + * 获取ip + * + * @param request HttpServletRequest + * @return {String} + */ + public static String getIP(HttpServletRequest request) { + Assert.notNull(request, "HttpServletRequest is null"); + String ip = request.getHeader("X-Requested-For"); + if (StringUtils.isBlank(ip) || UNKNOWN.equalsIgnoreCase(ip)) { + ip = request.getHeader("X-Forwarded-For"); + } + if (StringUtils.isBlank(ip) || UNKNOWN.equalsIgnoreCase(ip)) { + ip = request.getHeader("Proxy-Client-IP"); + } + if (StringUtils.isBlank(ip) || UNKNOWN.equalsIgnoreCase(ip)) { + ip = request.getHeader("WL-Proxy-Client-IP"); + } + if (StringUtils.isBlank(ip) || UNKNOWN.equalsIgnoreCase(ip)) { + ip = request.getHeader("HTTP_CLIENT_IP"); + } + if (StringUtils.isBlank(ip) || UNKNOWN.equalsIgnoreCase(ip)) { + ip = request.getHeader("HTTP_X_FORWARDED_FOR"); + } + if (StringUtils.isBlank(ip) || UNKNOWN.equalsIgnoreCase(ip)) { + ip = request.getRemoteAddr(); + } + return StringUtils.isBlank(ip) ? null : ip.split(",")[0]; + } +} + diff --git a/pigx-common/pigx-common-core/src/main/resources/META-INF/spring-devtools.properties b/pigx-common/pigx-common-core/src/main/resources/META-INF/spring-devtools.properties new file mode 100644 index 000000000..f6eed4bb5 --- /dev/null +++ b/pigx-common/pigx-common-core/src/main/resources/META-INF/spring-devtools.properties @@ -0,0 +1 @@ +restart.include.pigx-common-core=/pigx-common-core[\\w-]+\.jar diff --git a/pigx-common/pigx-common-core/src/main/resources/META-INF/spring.factories b/pigx-common/pigx-common-core/src/main/resources/META-INF/spring.factories new file mode 100644 index 000000000..9046e742b --- /dev/null +++ b/pigx-common/pigx-common-core/src/main/resources/META-INF/spring.factories @@ -0,0 +1,3 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ + com.pig4cloud.pigx.common.core.config.RedisConfig,\ + com.pig4cloud.pigx.common.core.util.SpringContextHolder diff --git a/pigx-common/pigx-common-core/src/main/resources/META-INF/spring.provides b/pigx-common/pigx-common-core/src/main/resources/META-INF/spring.provides new file mode 100644 index 000000000..61afcd7b2 --- /dev/null +++ b/pigx-common/pigx-common-core/src/main/resources/META-INF/spring.provides @@ -0,0 +1 @@ +provides: hutool-all, spring-cloud-starter-openfeign, feign-okhttp, fastjson, spring-boot-starter-data-redis diff --git a/pigx-common/pigx-common-log/pom.xml b/pigx-common/pigx-common-log/pom.xml new file mode 100644 index 000000000..eb8310a0f --- /dev/null +++ b/pigx-common/pigx-common-log/pom.xml @@ -0,0 +1,51 @@ + + + + + 4.0.0 + + com.pig4cloud + pigx-common + ${pigx.version} + + + pigx-common-log + ${pigx.version} + jar + pigx-common-log + pigx 日志服务 + + + + + + com.pig4cloud + pigx-common-core + ${pigx.version} + + + + com.pig4cloud + pigx-upms-api + ${pigx.version} + + + diff --git a/pigx-common/pigx-common-log/src/main/java/com/pig4cloud/pigx/common/log/LogAutoConfiguration.java b/pigx-common/pigx-common-log/src/main/java/com/pig4cloud/pigx/common/log/LogAutoConfiguration.java new file mode 100644 index 000000000..eaa365b79 --- /dev/null +++ b/pigx-common/pigx-common-log/src/main/java/com/pig4cloud/pigx/common/log/LogAutoConfiguration.java @@ -0,0 +1,52 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.common.log; + +import com.pig4cloud.pigx.admin.api.feign.RemoteLogService; +import com.pig4cloud.pigx.common.log.aspect.SysLogAspect; +import com.pig4cloud.pigx.common.log.event.SysLogListener; +import lombok.AllArgsConstructor; +import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; +import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * @author lengleng + * @date 2018/6/28 + * 日志自动配置 + */ +@Configuration +@AllArgsConstructor +@ConditionalOnWebApplication +@EnableFeignClients({"com.pig4cloud.pigx.admin.api.feign"}) +public class LogAutoConfiguration { + private final RemoteLogService remoteLogService; + + @Bean + public SysLogListener sysLogListener() { + return new SysLogListener(remoteLogService); + } + + @Bean + public SysLogAspect sysLogAspect() { + return new SysLogAspect(); + } +} diff --git a/pigx-common/pigx-common-log/src/main/java/com/pig4cloud/pigx/common/log/annotation/SysLog.java b/pigx-common/pigx-common-log/src/main/java/com/pig4cloud/pigx/common/log/annotation/SysLog.java new file mode 100644 index 000000000..8fcd4bf1a --- /dev/null +++ b/pigx-common/pigx-common-log/src/main/java/com/pig4cloud/pigx/common/log/annotation/SysLog.java @@ -0,0 +1,40 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.common.log.annotation; + +import java.lang.annotation.*; + +/** + * @author lengleng + * @date 2018/6/28 + * 操作日志注解 + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface SysLog { + + /** + * 描述 + * + * @return {String} + */ + String value(); +} diff --git a/pigx-common/pigx-common-log/src/main/java/com/pig4cloud/pigx/common/log/aspect/SysLogAspect.java b/pigx-common/pigx-common-log/src/main/java/com/pig4cloud/pigx/common/log/aspect/SysLogAspect.java new file mode 100644 index 000000000..0b55b399b --- /dev/null +++ b/pigx-common/pigx-common-log/src/main/java/com/pig4cloud/pigx/common/log/aspect/SysLogAspect.java @@ -0,0 +1,57 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.common.log.aspect; + +import com.pig4cloud.pigx.common.log.annotation.SysLog; +import com.pig4cloud.pigx.common.log.event.SysLogEvent; +import com.pig4cloud.pigx.common.log.util.SysLogUtils; +import com.pig4cloud.pigx.common.core.util.SpringContextHolder; +import lombok.extern.slf4j.Slf4j; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; + +/** + * 操作日志使用spring event异步入库 + * + * @author L.cm + */ +@Aspect +@Slf4j +public class SysLogAspect { + + @Around("@annotation(sysLog)") + public Object aroundWxApi(ProceedingJoinPoint point, SysLog sysLog) throws Throwable { + String strClassName = point.getTarget().getClass().getName(); + String strMethodName = point.getSignature().getName(); + log.debug("[类名]:{},[方法]:{}", strClassName, strMethodName); + + com.pig4cloud.pigx.admin.api.entity.SysLog logVo = SysLogUtils.getSysLog(); + logVo.setTitle(sysLog.value()); + // 发送异步日志事件 + Long startTime = System.currentTimeMillis(); + Object obj = point.proceed(); + Long endTime = System.currentTimeMillis(); + logVo.setTime(endTime - startTime); + SpringContextHolder.publishEvent(new SysLogEvent(logVo)); + return obj; + } + +} diff --git a/pigx-common/pigx-common-log/src/main/java/com/pig4cloud/pigx/common/log/event/SysLogEvent.java b/pigx-common/pigx-common-log/src/main/java/com/pig4cloud/pigx/common/log/event/SysLogEvent.java new file mode 100644 index 000000000..17b7674be --- /dev/null +++ b/pigx-common/pigx-common-log/src/main/java/com/pig4cloud/pigx/common/log/event/SysLogEvent.java @@ -0,0 +1,34 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.common.log.event; + +import com.pig4cloud.pigx.admin.api.entity.SysLog; +import org.springframework.context.ApplicationEvent; + +/** + * @author lengleng + * 系统日志事件 + */ +public class SysLogEvent extends ApplicationEvent { + + public SysLogEvent(SysLog source) { + super(source); + } +} diff --git a/pigx-common/pigx-common-log/src/main/java/com/pig4cloud/pigx/common/log/event/SysLogListener.java b/pigx-common/pigx-common-log/src/main/java/com/pig4cloud/pigx/common/log/event/SysLogListener.java new file mode 100644 index 000000000..74d8801c5 --- /dev/null +++ b/pigx-common/pigx-common-log/src/main/java/com/pig4cloud/pigx/common/log/event/SysLogListener.java @@ -0,0 +1,47 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.common.log.event; + +import com.pig4cloud.pigx.admin.api.entity.SysLog; +import com.pig4cloud.pigx.admin.api.feign.RemoteLogService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.context.event.EventListener; +import org.springframework.core.annotation.Order; +import org.springframework.scheduling.annotation.Async; + + +/** + * @author lengleng + * 异步监听日志事件 + */ +@Slf4j +@AllArgsConstructor +public class SysLogListener { + private final RemoteLogService remoteLogService; + + @Async + @Order + @EventListener(SysLogEvent.class) + public void saveSysLog(SysLogEvent event) { + SysLog sysLog = (SysLog) event.getSource(); + remoteLogService.saveLog(sysLog); + } +} diff --git a/pigx-common/pigx-common-log/src/main/java/com/pig4cloud/pigx/common/log/util/SysLogUtils.java b/pigx-common/pigx-common-log/src/main/java/com/pig4cloud/pigx/common/log/util/SysLogUtils.java new file mode 100644 index 000000000..21cd3d7fb --- /dev/null +++ b/pigx-common/pigx-common-log/src/main/java/com/pig4cloud/pigx/common/log/util/SysLogUtils.java @@ -0,0 +1,66 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.common.log.util; + +import cn.hutool.core.util.ArrayUtil; +import cn.hutool.core.util.URLUtil; +import cn.hutool.http.HttpUtil; +import com.pig4cloud.pigx.admin.api.entity.SysLog; +import com.pig4cloud.pigx.common.core.constant.CommonConstant; +import com.pig4cloud.pigx.common.security.util.SecurityUtils; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletRequest; + +/** + * 系统日志工具类 + * + * @author L.cm + */ +public class SysLogUtils { + + private static final String PASSWORD = "password"; + + public static SysLog getSysLog() { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + StringBuilder params = new StringBuilder(); + request.getParameterMap().forEach((key, values) -> { + params.append(key).append("="); + if (PASSWORD.equalsIgnoreCase(key)) { + params.append("******"); + } else { + params.append(ArrayUtil.toString(values)); + } + params.append("&"); + }); + + SysLog sysLog = new SysLog(); + sysLog.setCreateBy(SecurityUtils.getUser()); + sysLog.setType(CommonConstant.STATUS_NORMAL); + sysLog.setRemoteAddr(HttpUtil.getClientIP(request)); + sysLog.setRequestUri(URLUtil.getPath(request.getRequestURI())); + sysLog.setMethod(request.getMethod()); + sysLog.setUserAgent(request.getHeader("user-agent")); + sysLog.setParams(HttpUtil.toParams(request.getParameterMap())); + sysLog.setServiceId(SecurityUtils.getClientId()); + return sysLog; + } +} diff --git a/pigx-common/pigx-common-log/src/main/resources/META-INF/spring-devtools.properties b/pigx-common/pigx-common-log/src/main/resources/META-INF/spring-devtools.properties new file mode 100644 index 000000000..76296deab --- /dev/null +++ b/pigx-common/pigx-common-log/src/main/resources/META-INF/spring-devtools.properties @@ -0,0 +1 @@ +restart.include.pigx-common-security=/pigx-common-log[\\w-]+\.jar diff --git a/pigx-common/pigx-common-log/src/main/resources/META-INF/spring.factories b/pigx-common/pigx-common-log/src/main/resources/META-INF/spring.factories new file mode 100644 index 000000000..0fa28a4dd --- /dev/null +++ b/pigx-common/pigx-common-log/src/main/resources/META-INF/spring.factories @@ -0,0 +1,2 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ + com.pig4cloud.pigx.common.log.LogAutoConfiguration diff --git a/pigx-common/pigx-common-security/pom.xml b/pigx-common/pigx-common-security/pom.xml new file mode 100644 index 000000000..93b02bbd6 --- /dev/null +++ b/pigx-common/pigx-common-security/pom.xml @@ -0,0 +1,59 @@ + + + + + 4.0.0 + + com.pig4cloud + pigx-common + ${pigx.version} + + + pigx-common-security + ${pigx.version} + jar + pigx-common-security + pigx 安全工具类 + + + + + + com.pig4cloud + pigx-common-core + ${pigx.version} + + + + org.springframework.cloud + spring-cloud-starter-security + + + + io.github.openfeign + feign-okhttp + + + org.springframework.cloud + spring-cloud-starter-openfeign + + + diff --git a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/compoent/PermissionService.java b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/compoent/PermissionService.java new file mode 100644 index 000000000..1c42a2812 --- /dev/null +++ b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/compoent/PermissionService.java @@ -0,0 +1,61 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.common.security.compoent; + +import cn.hutool.core.util.StrUtil; +import lombok.extern.slf4j.Slf4j; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.stereotype.Component; +import org.springframework.util.PatternMatchUtils; +import org.springframework.util.StringUtils; + +import java.util.Collection; + +/** + * @author lengleng + * @date 2018/6/22 + * 接口权限判断工具 + */ +@Slf4j +@Component("pms") +public class PermissionService { + /** + * 判断接口是否有xxx:xxx权限 + * + * @param permission 权限 + * @return {boolean} + */ + public boolean hasPermission(String permission) { + if (StrUtil.isBlank(permission)) { + return false; + } + Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + if (authentication == null) { + return false; + } + Collection authorities = authentication.getAuthorities(); + return authorities.stream() + .map(GrantedAuthority::getAuthority) + .filter(StringUtils::hasText) + .anyMatch(x -> PatternMatchUtils.simpleMatch(permission, x)); + } +} diff --git a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/compoent/PigAccessDeniedHandler.java b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/compoent/PigAccessDeniedHandler.java new file mode 100644 index 000000000..406021199 --- /dev/null +++ b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/compoent/PigAccessDeniedHandler.java @@ -0,0 +1,74 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.common.security.compoent; + +/** + * @author lengleng + * @date 2018/6/22 + */ + +import cn.hutool.http.HttpStatus; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.pig4cloud.pigx.common.core.constant.CommonConstant; +import com.pig4cloud.pigx.common.core.exception.PigDeniedException; +import com.pig4cloud.pigx.common.core.util.R; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.security.access.AccessDeniedException; +import org.springframework.security.oauth2.provider.error.OAuth2AccessDeniedHandler; +import org.springframework.stereotype.Component; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintWriter; + +/** + * @author lengleng + * 授权拒绝处理器,覆盖默认的OAuth2AccessDeniedHandler + * 包装失败信息到PigDeniedException + */ +@Slf4j +@Component +@AllArgsConstructor +public class PigAccessDeniedHandler extends OAuth2AccessDeniedHandler { + private final ObjectMapper objectMapper; + + /** + * 授权拒绝处理,使用R包装 + * + * @param request request + * @param response response + * @param authException authException + * @throws IOException IOException + * @throws ServletException ServletException + */ + @Override + public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException authException) throws IOException, ServletException { + log.info("授权失败,禁止访问 {}", request.getRequestURI()); + response.setCharacterEncoding(CommonConstant.UTF8); + response.setContentType(CommonConstant.CONTENT_TYPE); + R result = new R<>(new PigDeniedException("授权失败,禁止访问")); + response.setStatus(HttpStatus.HTTP_FORBIDDEN); + PrintWriter printWriter = response.getWriter(); + printWriter.append(objectMapper.writeValueAsString(result)); + } +} diff --git a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/compoent/PigxWebResponseExceptionTranslator.java b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/compoent/PigxWebResponseExceptionTranslator.java new file mode 100644 index 000000000..0aa33d6f2 --- /dev/null +++ b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/compoent/PigxWebResponseExceptionTranslator.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.common.security.compoent; + +import com.pig4cloud.pigx.common.security.exception.*; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.AccessDeniedException; +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.oauth2.common.DefaultThrowableAnalyzer; +import org.springframework.security.oauth2.common.OAuth2AccessToken; +import org.springframework.security.oauth2.common.exceptions.InsufficientScopeException; +import org.springframework.security.oauth2.common.exceptions.InvalidGrantException; +import org.springframework.security.oauth2.common.exceptions.OAuth2Exception; +import org.springframework.security.oauth2.provider.error.WebResponseExceptionTranslator; +import org.springframework.security.web.util.ThrowableAnalyzer; +import org.springframework.web.HttpRequestMethodNotSupportedException; + +import java.io.IOException; + +/** + * @author lengleng + * @date 2018/7/8 + * 异常处理,重写oauth 默认实现 + */ +@Slf4j +public class PigxWebResponseExceptionTranslator implements WebResponseExceptionTranslator { + + private ThrowableAnalyzer throwableAnalyzer = new DefaultThrowableAnalyzer(); + + @Override + public ResponseEntity translate(Exception e) throws Exception { + + // Try to extract a SpringSecurityException from the stacktrace + Throwable[] causeChain = throwableAnalyzer.determineCauseChain(e); + + Exception ase = (AuthenticationException) throwableAnalyzer.getFirstThrowableOfType(AuthenticationException.class, + causeChain); + if (ase != null) { + return handleOAuth2Exception(new UnauthorizedException(e.getMessage(), e)); + } + + ase = (AccessDeniedException) throwableAnalyzer + .getFirstThrowableOfType(AccessDeniedException.class, causeChain); + if (ase != null) { + return handleOAuth2Exception(new ForbiddenException(ase.getMessage(), ase)); + } + + ase = (InvalidGrantException) throwableAnalyzer + .getFirstThrowableOfType(InvalidGrantException.class, causeChain); + if (ase != null) { + return handleOAuth2Exception(new InvalidException(ase.getMessage(), ase)); + } + + ase = (HttpRequestMethodNotSupportedException) throwableAnalyzer + .getFirstThrowableOfType(HttpRequestMethodNotSupportedException.class, causeChain); + if (ase != null) { + return handleOAuth2Exception(new MethodNotAllowed(ase.getMessage(), ase)); + } + + ase = (OAuth2Exception) throwableAnalyzer.getFirstThrowableOfType( + OAuth2Exception.class, causeChain); + + if (ase != null) { + return handleOAuth2Exception((OAuth2Exception) ase); + } + + return handleOAuth2Exception(new ServerErrorException(HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase(), e)); + + } + + private ResponseEntity handleOAuth2Exception(OAuth2Exception e) throws IOException { + + int status = e.getHttpErrorCode(); + HttpHeaders headers = new HttpHeaders(); + headers.set("Cache-Control", "no-store"); + headers.set("Pragma", "no-cache"); + if (status == HttpStatus.UNAUTHORIZED.value() || (e instanceof InsufficientScopeException)) { + headers.set("WWW-Authenticate", String.format("%s %s", OAuth2AccessToken.BEARER_TYPE, e.getSummary())); + } + + ResponseEntity response = new ResponseEntity<>(new PigxAuth2Exception(e.getMessage()), headers, + HttpStatus.valueOf(status)); + + return response; + + } +} diff --git a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/compoent/ResourceAuthExceptionEntryPoint.java b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/compoent/ResourceAuthExceptionEntryPoint.java new file mode 100644 index 000000000..33d2252bf --- /dev/null +++ b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/compoent/ResourceAuthExceptionEntryPoint.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.common.security.compoent; + +import cn.hutool.http.HttpStatus; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.pig4cloud.pigx.common.core.constant.CommonConstant; +import com.pig4cloud.pigx.common.core.util.R; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.web.AuthenticationEntryPoint; +import org.springframework.stereotype.Component; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintWriter; + +/** + * @author lengleng + * @date 2018/7/8 + * 客户端异常处理 + * 1. 可以根据 AuthenticationException 不同细化异常处理 + */ +@Slf4j +@Component +@AllArgsConstructor +public class ResourceAuthExceptionEntryPoint implements AuthenticationEntryPoint { + private final ObjectMapper objectMapper; + + @Override + public void commence(HttpServletRequest request, HttpServletResponse response, + AuthenticationException authException) throws IOException { + response.setCharacterEncoding(CommonConstant.UTF8); + response.setContentType(CommonConstant.CONTENT_TYPE); + R result = new R<>(); + result.setCode(HttpStatus.HTTP_UNAUTHORIZED); + if (authException != null) { + result.setMsg("error"); + result.setData(authException.getMessage()); + } + response.setStatus(HttpStatus.HTTP_UNAUTHORIZED); + PrintWriter printWriter = response.getWriter(); + printWriter.append(objectMapper.writeValueAsString(result)); + } +} diff --git a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/exception/ForbiddenException.java b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/exception/ForbiddenException.java new file mode 100644 index 000000000..6b8236d0b --- /dev/null +++ b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/exception/ForbiddenException.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.common.security.exception; + +import org.springframework.http.HttpStatus; + +/** + * @author lengleng + * @date 2018/7/8 + */ +public class ForbiddenException extends PigxAuth2Exception { + + public ForbiddenException(String msg, Throwable t) { + super(msg); + } + + @Override + public String getOAuth2ErrorCode() { + return "access_denied"; + } + + @Override + public int getHttpErrorCode() { + return HttpStatus.FORBIDDEN.value(); + } + +} + diff --git a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/exception/InvalidException.java b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/exception/InvalidException.java new file mode 100644 index 000000000..487dc0b74 --- /dev/null +++ b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/exception/InvalidException.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.common.security.exception; + +/** + * @author lengleng + * @date 2018/7/8 + */ +public class InvalidException extends PigxAuth2Exception { + + public InvalidException(String msg, Throwable t) { + super(msg); + } + + @Override + public String getOAuth2ErrorCode() { + return "invalid_exception"; + } + + @Override + public int getHttpErrorCode() { + return 426; + } + +} diff --git a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/exception/MethodNotAllowed.java b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/exception/MethodNotAllowed.java new file mode 100644 index 000000000..e1274c2ec --- /dev/null +++ b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/exception/MethodNotAllowed.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.common.security.exception; + +import org.springframework.http.HttpStatus; + +/** + * @author lengleng + * @date 2018/7/8 + */ +public class MethodNotAllowed extends PigxAuth2Exception { + + public MethodNotAllowed(String msg, Throwable t) { + super(msg); + } + + @Override + public String getOAuth2ErrorCode() { + return "method_not_allowed"; + } + + @Override + public int getHttpErrorCode() { + return HttpStatus.METHOD_NOT_ALLOWED.value(); + } + +} diff --git a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/exception/PigxAuth2Exception.java b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/exception/PigxAuth2Exception.java new file mode 100644 index 000000000..e50e2299d --- /dev/null +++ b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/exception/PigxAuth2Exception.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.common.security.exception; + +import org.springframework.security.oauth2.common.exceptions.OAuth2Exception; + +import java.util.Map; + +/** + * @author lengleng + * @date 2018/7/8 + * 自定义OAuth2Exception + */ +public class PigxAuth2Exception extends OAuth2Exception { + + public PigxAuth2Exception(String msg) { + super(msg); + } +} diff --git a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/exception/ServerErrorException.java b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/exception/ServerErrorException.java new file mode 100644 index 000000000..53e723b28 --- /dev/null +++ b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/exception/ServerErrorException.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.common.security.exception; + +import org.springframework.http.HttpStatus; + +/** + * @author lengleng + * @date 2018/7/8 + */ +public class ServerErrorException extends PigxAuth2Exception { + + public ServerErrorException(String msg, Throwable t) { + super(msg); + } + + @Override + public String getOAuth2ErrorCode() { + return "server_error"; + } + + @Override + public int getHttpErrorCode() { + return HttpStatus.INTERNAL_SERVER_ERROR.value(); + } + +} diff --git a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/exception/UnauthorizedException.java b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/exception/UnauthorizedException.java new file mode 100644 index 000000000..0d01007c6 --- /dev/null +++ b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/exception/UnauthorizedException.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.common.security.exception; + +import org.springframework.http.HttpStatus; + +/** + * @author lengleng + * @date 2018/7/8 + */ +public class UnauthorizedException extends PigxAuth2Exception { + + public UnauthorizedException(String msg, Throwable t) { + super(msg); + } + + @Override + public String getOAuth2ErrorCode() { + return "unauthorized"; + } + + @Override + public int getHttpErrorCode() { + return HttpStatus.UNAUTHORIZED.value(); + } + +} diff --git a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/interceptor/PigxFeignClientIntercept.java b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/interceptor/PigxFeignClientIntercept.java new file mode 100644 index 000000000..141c99a36 --- /dev/null +++ b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/interceptor/PigxFeignClientIntercept.java @@ -0,0 +1,44 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.common.security.interceptor; + +import feign.RequestInterceptor; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.cloud.security.oauth2.client.feign.OAuth2FeignRequestInterceptor; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.oauth2.client.OAuth2ClientContext; +import org.springframework.security.oauth2.client.resource.OAuth2ProtectedResourceDetails; + +/** + * @author lengleng + * @date 2018/6/22 + * feign 拦截器传递 header 中oauth token, + * 使用hystrix 的信号量模式 + */ +@Configuration +@ConditionalOnProperty("security.oauth2.client.client-id") +public class PigxFeignClientIntercept { + @Bean + public RequestInterceptor oauth2FeignRequestInterceptor(OAuth2ClientContext oAuth2ClientContext, + OAuth2ProtectedResourceDetails resource) { + return new OAuth2FeignRequestInterceptor(oAuth2ClientContext, resource); + } +} diff --git a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/util/SecurityUtils.java b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/util/SecurityUtils.java new file mode 100644 index 000000000..ae1c8190e --- /dev/null +++ b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/util/SecurityUtils.java @@ -0,0 +1,94 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.common.security.util; + + +import cn.hutool.core.util.StrUtil; +import com.pig4cloud.pigx.common.core.constant.SecurityConstants; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.security.oauth2.provider.OAuth2Authentication; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +/** + * 安全工具类 + * + * @author L.cm + */ +public class SecurityUtils { + + /** + * 获取Authentication + */ + public static Authentication getAuthentication() { + return SecurityContextHolder.getContext().getAuthentication(); + } + + /** + * 获取用户 + */ + public static String getUser(Authentication authentication) { + Object principal = authentication.getPrincipal(); + if (principal == null) { + return null; + } + return (String) principal; + } + + public static String getClientId() { + Authentication authentication = getAuthentication(); + if (authentication instanceof OAuth2Authentication) { + OAuth2Authentication auth2Authentication = (OAuth2Authentication) authentication; + return auth2Authentication.getOAuth2Request().getClientId(); + } + return null; + } + + /** + * 获取用户 + */ + public static String getUser() { + Authentication authentication = getAuthentication(); + if (authentication == null) { + return null; + } + return getUser(authentication); + } + + /** + * 获取用户角色信息 + * + * @return 角色集合 + */ + public static List getRoles() { + Authentication authentication = getAuthentication(); + Collection authorities = authentication.getAuthorities(); + + List roles = new ArrayList<>(); + authorities.stream() + .filter(granted -> StrUtil.startWith(granted.getAuthority(), SecurityConstants.ROLE)) + .forEach(granted -> roles.add(StrUtil.removePrefix(granted.getAuthority(), SecurityConstants.ROLE))); + return roles; + } +} diff --git a/pigx-common/pigx-common-security/src/main/resources/META-INF/spring-devtools.properties b/pigx-common/pigx-common-security/src/main/resources/META-INF/spring-devtools.properties new file mode 100644 index 000000000..0a52a6fde --- /dev/null +++ b/pigx-common/pigx-common-security/src/main/resources/META-INF/spring-devtools.properties @@ -0,0 +1 @@ +restart.include.pigx-common-security=/pigx-common-security[\\w-]+\.jar diff --git a/pigx-common/pigx-common-security/src/main/resources/META-INF/spring.factories b/pigx-common/pigx-common-security/src/main/resources/META-INF/spring.factories new file mode 100644 index 000000000..caa397bbd --- /dev/null +++ b/pigx-common/pigx-common-security/src/main/resources/META-INF/spring.factories @@ -0,0 +1,5 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ + com.pig4cloud.pigx.common.security.compoent.PermissionService,\ + com.pig4cloud.pigx.common.security.compoent.PigAccessDeniedHandler,\ + com.pig4cloud.pigx.common.security.compoent.ResourceAuthExceptionEntryPoint,\ + com.pig4cloud.pigx.common.security.interceptor.PigxFeignClientIntercept diff --git a/pigx-common/pigx-common-security/src/main/resources/META-INF/spring.provides b/pigx-common/pigx-common-security/src/main/resources/META-INF/spring.provides new file mode 100644 index 000000000..c3a54e58e --- /dev/null +++ b/pigx-common/pigx-common-security/src/main/resources/META-INF/spring.provides @@ -0,0 +1 @@ +provides: pigx-common-core, spring-cloud-starter-security diff --git a/pigx-common/pigx-common-security/src/main/resources/org/springframework/security/messages_zh_CN.properties b/pigx-common/pigx-common-security/src/main/resources/org/springframework/security/messages_zh_CN.properties new file mode 100644 index 000000000..8a6bf9187 --- /dev/null +++ b/pigx-common/pigx-common-security/src/main/resources/org/springframework/security/messages_zh_CN.properties @@ -0,0 +1,64 @@ +# +# +# Copyright (c) 2018-2025, lengleng All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# Neither the name of the pig4cloud.com developer nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# Author: lengleng (wangiegie@gmail.com) +# +# +AbstractAccessDecisionManager.accessDenied=\u4E0D\u5141\u8BB8\u8BBF\u95EE +AbstractLdapAuthenticationProvider.emptyPassword=\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A +AbstractSecurityInterceptor.authenticationNotFound=\u672A\u5728SecurityContext\u4E2D\u67E5\u627E\u5230\u8BA4\u8BC1\u5BF9\u8C61 +AbstractUserDetailsAuthenticationProvider.badCredentials=\u7528\u6237\u540D\u4E0D\u5B58\u5728\u6216\u8005\u5BC6\u7801\u9519\u8BEF +AbstractUserDetailsAuthenticationProvider.credentialsExpired=\u7528\u6237\u51ED\u8BC1\u5DF2\u8FC7\u671F +AbstractUserDetailsAuthenticationProvider.disabled=\u7528\u6237\u672A\u6FC0\u6D3B +AbstractUserDetailsAuthenticationProvider.expired=\u7528\u6237\u5E10\u53F7\u5DF2\u8FC7\u671F +AbstractUserDetailsAuthenticationProvider.locked=\u7528\u6237\u5E10\u53F7\u5DF2\u88AB\u9501\u5B9A +AbstractUserDetailsAuthenticationProvider.onlySupports=\u4EC5\u4EC5\u652F\u6301UsernamePasswordAuthenticationToken +AccountStatusUserDetailsChecker.credentialsExpired=\u7528\u6237\u51ED\u8BC1\u5DF2\u8FC7\u671F +AccountStatusUserDetailsChecker.disabled=\u7528\u6237\u672A\u6FC0\u6D3B +AccountStatusUserDetailsChecker.expired=\u7528\u6237\u5E10\u53F7\u5DF2\u8FC7\u671F +AccountStatusUserDetailsChecker.locked=\u7528\u6237\u5E10\u53F7\u5DF2\u88AB\u9501\u5B9A +AclEntryAfterInvocationProvider.noPermission=\u7ED9\u5B9A\u7684Authentication\u5BF9\u8C61({0})\u6839\u672C\u65E0\u6743\u64CD\u63A7\u9886\u57DF\u5BF9\u8C61({1}) +AnonymousAuthenticationProvider.incorrectKey=\u5C55\u793A\u7684AnonymousAuthenticationToken\u4E0D\u542B\u6709\u9884\u671F\u7684key +BindAuthenticator.badCredentials=\u5BC6\u7801\u9519\u8BEF +BindAuthenticator.emptyPassword=\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A +CasAuthenticationProvider.incorrectKey=\u5C55\u793A\u7684CasAuthenticationToken\u4E0D\u542B\u6709\u9884\u671F\u7684key +CasAuthenticationProvider.noServiceTicket=\u672A\u80FD\u591F\u6B63\u786E\u63D0\u4F9B\u5F85\u9A8C\u8BC1\u7684CAS\u670D\u52A1\u7968\u6839 +ConcurrentSessionControlAuthenticationStrategy.exceededAllowed=\u5DF2\u7ECF\u8D85\u8FC7\u4E86\u5F53\u524D\u4E3B\u4F53({0})\u88AB\u5141\u8BB8\u7684\u6700\u5927\u4F1A\u8BDD\u6570\u91CF +DigestAuthenticationFilter.incorrectRealm=\u54CD\u5E94\u7ED3\u679C\u4E2D\u7684Realm\u540D\u5B57({0})\u540C\u7CFB\u7EDF\u6307\u5B9A\u7684Realm\u540D\u5B57({1})\u4E0D\u543B\u5408 +DigestAuthenticationFilter.incorrectResponse=\u9519\u8BEF\u7684\u54CD\u5E94\u7ED3\u679C +DigestAuthenticationFilter.missingAuth=\u9057\u6F0F\u4E86\u9488\u5BF9'auth' QOP\u7684\u3001\u5FC5\u987B\u7ED9\u5B9A\u7684\u6458\u8981\u53D6\u503C; \u63A5\u6536\u5230\u7684\u5934\u4FE1\u606F\u4E3A{0} +DigestAuthenticationFilter.missingMandatory=\u9057\u6F0F\u4E86\u5FC5\u987B\u7ED9\u5B9A\u7684\u6458\u8981\u53D6\u503C; \u63A5\u6536\u5230\u7684\u5934\u4FE1\u606F\u4E3A{0} +DigestAuthenticationFilter.nonceCompromised=Nonce\u4EE4\u724C\u5DF2\u7ECF\u5B58\u5728\u95EE\u9898\u4E86\uFF0C{0} +DigestAuthenticationFilter.nonceEncoding=Nonce\u672A\u7ECF\u8FC7Base64\u7F16\u7801; \u76F8\u5E94\u7684nonce\u53D6\u503C\u4E3A {0} +DigestAuthenticationFilter.nonceExpired=Nonce\u5DF2\u7ECF\u8FC7\u671F/\u8D85\u65F6 +DigestAuthenticationFilter.nonceNotNumeric=Nonce\u4EE4\u724C\u7684\u7B2C1\u90E8\u5206\u5E94\u8BE5\u662F\u6570\u5B57\uFF0C\u4F46\u7ED3\u679C\u5374\u662F{0} +DigestAuthenticationFilter.nonceNotTwoTokens=Nonce\u5E94\u8BE5\u7531\u4E24\u90E8\u5206\u53D6\u503C\u6784\u6210\uFF0C\u4F46\u7ED3\u679C\u5374\u662F{0} +DigestAuthenticationFilter.usernameNotFound=\u7528\u6237\u540D{0}\u672A\u627E\u5230 +JdbcDaoImpl.noAuthority=\u6CA1\u6709\u4E3A\u7528\u6237{0}\u6307\u5B9A\u89D2\u8272 +JdbcDaoImpl.notFound=\u672A\u627E\u5230\u7528\u6237{0} +LdapAuthenticationProvider.badCredentials=\u574F\u7684\u51ED\u8BC1 +LdapAuthenticationProvider.credentialsExpired=\u7528\u6237\u51ED\u8BC1\u5DF2\u8FC7\u671F +LdapAuthenticationProvider.disabled=\u7528\u6237\u672A\u6FC0\u6D3B +LdapAuthenticationProvider.expired=\u7528\u6237\u5E10\u53F7\u5DF2\u8FC7\u671F +LdapAuthenticationProvider.locked=\u7528\u6237\u5E10\u53F7\u5DF2\u88AB\u9501\u5B9A +LdapAuthenticationProvider.emptyUsername=\u7528\u6237\u540D\u4E0D\u5141\u8BB8\u4E3A\u7A7A +LdapAuthenticationProvider.onlySupports=\u4EC5\u4EC5\u652F\u6301UsernamePasswordAuthenticationToken +PasswordComparisonAuthenticator.badCredentials=\u574F\u7684\u51ED\u8BC1 +ProviderManager.providerNotFound=\u672A\u67E5\u627E\u5230\u9488\u5BF9{0}\u7684AuthenticationProvider +RememberMeAuthenticationProvider.incorrectKey=\u5C55\u793ARememberMeAuthenticationToken\u4E0D\u542B\u6709\u9884\u671F\u7684key +RunAsImplAuthenticationProvider.incorrectKey=\u5C55\u793A\u7684RunAsUserToken\u4E0D\u542B\u6709\u9884\u671F\u7684key +SubjectDnX509PrincipalExtractor.noMatching=\u672A\u5728subjectDN\: {0}\u4E2D\u627E\u5230\u5339\u914D\u7684\u6A21\u5F0F +SwitchUserFilter.noCurrentUser=\u4E0D\u5B58\u5728\u5F53\u524D\u7528\u6237 +SwitchUserFilter.noOriginalAuthentication=\u4E0D\u80FD\u591F\u67E5\u627E\u5230\u539F\u5148\u7684\u5DF2\u8BA4\u8BC1\u5BF9\u8C61 diff --git a/pigx-common/pigx-common-swagger/pom.xml b/pigx-common/pigx-common-swagger/pom.xml new file mode 100644 index 000000000..898226da2 --- /dev/null +++ b/pigx-common/pigx-common-swagger/pom.xml @@ -0,0 +1,58 @@ + + + + + 4.0.0 + + com.pig4cloud + pigx-common + ${pigx.version} + + + pigx-common-swagger + ${pigx.version} + jar + pigx-common-log + pigx 接口文档 + + + + + + com.pig4cloud + pigx-common-security + ${pigx.version} + + + + javax.servlet + javax.servlet-api + ${servlet-api.version} + provided + + + + io.springfox + springfox-swagger2 + ${swagger.version} + + + diff --git a/pigx-common/pigx-common-swagger/src/main/java/com/pig4cloud/pigx/common/swagger/annotation/EnablePigxSwagger2.java b/pigx-common/pigx-common-swagger/src/main/java/com/pig4cloud/pigx/common/swagger/annotation/EnablePigxSwagger2.java new file mode 100644 index 000000000..9285ad651 --- /dev/null +++ b/pigx-common/pigx-common-swagger/src/main/java/com/pig4cloud/pigx/common/swagger/annotation/EnablePigxSwagger2.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.common.swagger.annotation; + +import com.pig4cloud.pigx.common.swagger.config.SwaggerAutoConfiguration; +import org.springframework.context.annotation.Import; + +import java.lang.annotation.*; + +/** + * @author lengleng + * @date 2018/7/21 + * 开启pigx swagger + */ +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@Import({SwaggerAutoConfiguration.class}) +public @interface EnablePigxSwagger2 { +} diff --git a/pigx-common/pigx-common-swagger/src/main/java/com/pig4cloud/pigx/common/swagger/config/SwaggerAutoConfiguration.java b/pigx-common/pigx-common-swagger/src/main/java/com/pig4cloud/pigx/common/swagger/config/SwaggerAutoConfiguration.java new file mode 100644 index 000000000..023318331 --- /dev/null +++ b/pigx-common/pigx-common-swagger/src/main/java/com/pig4cloud/pigx/common/swagger/config/SwaggerAutoConfiguration.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ +package com.pig4cloud.pigx.common.swagger.config; + + +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.*; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spi.service.contexts.SecurityContext; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * @author Sywd + * swagger配置 + */ +@Configuration +@EnableSwagger2 +@EnableAutoConfiguration +public class SwaggerAutoConfiguration { + + @Bean + public Docket api() { + return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select() + .apis(RequestHandlerSelectors.any()).paths(PathSelectors.any()) + .build().securitySchemes(Collections.singletonList(securitySchema())) + .securityContexts(Collections.singletonList(securityContext())).pathMapping("/"); + } + + private SecurityContext securityContext() { + return SecurityContext.builder().securityReferences(defaultAuth()) + .forPaths(PathSelectors.ant("/**")) + .build(); + } + + private List defaultAuth() { + + final AuthorizationScope[] authorizationScopes = new AuthorizationScope[3]; + authorizationScopes[0] = new AuthorizationScope("read", "read all"); + authorizationScopes[1] = new AuthorizationScope("trust", "trust all"); + authorizationScopes[2] = new AuthorizationScope("write", "write all"); + + return Collections.singletonList(new SecurityReference("pigX OAuth", authorizationScopes)); + } + + + private OAuth securitySchema() { + ArrayList authorizationScopeList = new ArrayList(); + authorizationScopeList.add(new AuthorizationScope("server", "server all")); + authorizationScopeList.add(new AuthorizationScope("read", "read all")); + authorizationScopeList.add(new AuthorizationScope("write", "access all")); + + ArrayList grantTypes = new ArrayList(); + GrantType creGrant = new ResourceOwnerPasswordCredentialsGrant("http://localhost:9999/auth/oauth/token"); + + grantTypes.add(creGrant); + return new OAuth("pigX OAuth", authorizationScopeList, grantTypes); + } + + private ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("PigX Swagger API ") + .description("https://gitee.com/log4j/pig/wikis") + .termsOfServiceUrl("https://gitee.wang/pig/pigx") + .contact(new Contact("冷冷", "https://gitee.wang/pig/pigx", "wangiegie@gmail.com")) + .version("2.0") + .build(); + } + +} diff --git a/pigx-common/pom.xml b/pigx-common/pom.xml new file mode 100644 index 000000000..441f743c3 --- /dev/null +++ b/pigx-common/pom.xml @@ -0,0 +1,42 @@ + + + + + 4.0.0 + + com.pig4cloud + pigx + ${pigx.version} + + + pigx-common + ${pigx.version} + pom + pigx-common + pigx 公共聚合模块 + + + pigx-common-core + pigx-common-log + pigx-common-security + pigx-common-swagger + + diff --git a/pigx-config/Dockerfile b/pigx-config/Dockerfile new file mode 100644 index 000000000..fa772aea8 --- /dev/null +++ b/pigx-config/Dockerfile @@ -0,0 +1,13 @@ +FROM anapsix/alpine-java:8_server-jre_unlimited + +MAINTAINER wangiegie@gmail.com + +RUN mkdir -p /pigx/bin/com.pig4cloud/pigx-config + +WORKDIR /pigx/bin/com.pig4cloud/pigx-config + +EXPOSE 1025 + +ADD ./pigx-config/target/pigx-config.jar ./ + +CMD java -Djava.security.egd=file:/dev/./urandom -jar pigx-config.jar diff --git a/pigx-config/pom.xml b/pigx-config/pom.xml new file mode 100644 index 000000000..93c74f180 --- /dev/null +++ b/pigx-config/pom.xml @@ -0,0 +1,75 @@ + + + + + 4.0.0 + + com.pig4cloud + pigx + ${pigx.version} + + + pigx-config + ${pigx.version} + jar + + pigx-config + pigx 配置中心,基于spring cloud config + + + + + org.springframework.cloud + spring-cloud-config-server + + + + org.springframework.boot + spring-boot-starter-web + + + + spring-boot-starter-tomcat + org.springframework.boot + + + + + + org.springframework.boot + spring-boot-starter-undertow + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + ${project.name} + + + + + + diff --git a/pigx-config/src/main/java/com/pig4cloud/pigx/config/PigxConfigApplication.java b/pigx-config/src/main/java/com/pig4cloud/pigx/config/PigxConfigApplication.java new file mode 100644 index 000000000..23e6f4790 --- /dev/null +++ b/pigx-config/src/main/java/com/pig4cloud/pigx/config/PigxConfigApplication.java @@ -0,0 +1,38 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.config; + +import org.springframework.boot.SpringApplication; +import org.springframework.cloud.client.SpringCloudApplication; +import org.springframework.cloud.config.server.EnableConfigServer; + +/** + * @author lengleng + * @date 2018年06月22日 + * 配置中心 + */ +@EnableConfigServer +@SpringCloudApplication +public class PigxConfigApplication { + + public static void main(String[] args) { + SpringApplication.run(PigxConfigApplication.class, args); + } +} diff --git a/pigx-config/src/main/resources/bootstrap.yml b/pigx-config/src/main/resources/bootstrap.yml new file mode 100644 index 000000000..5564b817f --- /dev/null +++ b/pigx-config/src/main/resources/bootstrap.yml @@ -0,0 +1,29 @@ +server: + port: 4001 + +spring: + application: + name: pigx-config + profiles: + active: native + # 配置中心 + cloud: + config: + server: + native: + search-locations: classpath:/config/ + +# 注册中心配置 +eureka: + instance: + prefer-ip-address: true + client: + service-url: + defaultZone: http://pig:pig@localhost:1025/eureka/ + +# 暴露监控端点 +management: + endpoints: + web: + exposure: + include: '*' diff --git a/pigx-config/src/main/resources/config/application-dev.yml b/pigx-config/src/main/resources/config/application-dev.yml new file mode 100644 index 000000000..5e8f77d89 --- /dev/null +++ b/pigx-config/src/main/resources/config/application-dev.yml @@ -0,0 +1,48 @@ +# redis 相关 +spring: + redis: + password: + host: localhost +# 暴露监控端点 +management: + endpoints: + web: + exposure: + include: '*' + +# feign 配置 +feign: + hystrix: + enabled: true + okhttp: + enabled: true + httpclient: + enabled: false + client: + config: + feignName: + connectTimeout: 10000 + readTimeout: 10000 + compression: + request: + enabled: true + response: + enabled: true +# hystrix If you need to use ThreadLocal bound variables in your RequestInterceptor`s +# you will need to either set the thread isolation strategy for Hystrix to `SEMAPHORE or disable Hystrix in Feign. +hystrix: + command: + default: + execution: + isolation: + strategy: SEMAPHORE + thread: + timeoutInMilliseconds: 60000 + shareSecurityContext: true + +#请求处理的超时时间 +ribbon: + ReadTimeout: 10000 + ConnectTimeout: 10000 + + diff --git a/pigx-config/src/main/resources/config/pigx-auth-dev.yml b/pigx-config/src/main/resources/config/pigx-auth-dev.yml new file mode 100644 index 000000000..0c0a5346a --- /dev/null +++ b/pigx-config/src/main/resources/config/pigx-auth-dev.yml @@ -0,0 +1,8 @@ +# 数据源 +spring: + datasource: + type: com.zaxxer.hikari.HikariDataSource + driver-class-name: com.mysql.jdbc.Driver + username: root + password: root + url: jdbc:mysql://114.116.45.246:13306/pigx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false diff --git a/pigx-config/src/main/resources/config/pigx-gateway-dev.yml b/pigx-config/src/main/resources/config/pigx-gateway-dev.yml new file mode 100644 index 000000000..30b6e0db8 --- /dev/null +++ b/pigx-config/src/main/resources/config/pigx-gateway-dev.yml @@ -0,0 +1,49 @@ +spring: + cloud: + gateway: + locator: + enabled: true + routes: + - id: pigx-auth + uri: lb://pigx-auth + predicates: + - Path=/auth/** + filters: + # 验证码处理 + - ImageCodeGatewayFilter + # 前端密码解密 + - PasswordDecoderFilter + - StripPrefix=1 + - id: pigx-upms + uri: lb://pigx-upms + predicates: + - Path=/admin/** + filters: + # Swagger请求头处理 + - SwaggerHeaderFilter + # 请求头清理避免不合法请求头 + - name: RemoveRequestHeader + args: + name: from + # 限流配置 + - name: RequestRateLimiter + args: + key-resolver: '#{@remoteAddrKeyResolver}' + redis-rate-limiter.replenishRate: 10 + redis-rate-limiter.burstCapacity: 20 + - StripPrefix=1 + # 降级配置 + - name: Hystrix + args: + name: default + fallbackUri: 'forward:/fallback' + +security: + encode: + # 前端密码密钥,必须16位 + key: 'pigxpigxpigxpigx' + +# 不校验验证码终端 +ignore: + clients: + - test diff --git a/pigx-config/src/main/resources/config/pigx-upms-dev.yml b/pigx-config/src/main/resources/config/pigx-upms-dev.yml new file mode 100644 index 000000000..690527469 --- /dev/null +++ b/pigx-config/src/main/resources/config/pigx-upms-dev.yml @@ -0,0 +1,40 @@ +## spring security 配置 +security: + oauth2: + client: + client-id: pig + client-secret: pig + scope: server + resource: + token-info-uri: http://localhost:9999/auth/oauth/check_token + +# 数据源 +spring: + datasource: + type: com.zaxxer.hikari.HikariDataSource + driver-class-name: com.mysql.jdbc.Driver + username: root + password: root + url: jdbc:mysql://114.116.45.246:13306/pigx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false + +#mybaits-plus配置,修改主键类型,mapper.xml、type 别名等 +mybatis-plus: + mapper-locations: classpath:/mapper/*Mapper.xml + typeAliasesPackage: com.pig4cloud.pigx.admin.api.entity + global-config: + #主键类型 0:"数据库ID自增", 1:"用户输入ID",2:"全局唯一ID (数字类型唯一ID)", 3:"全局唯一ID UUID"; + id-type: 0 + #字段策略 0:"忽略判断",1:"非 NULL 判断"),2:"非空判断" + field-strategy: 1 + #驼峰下划线转换 + db-column-underline: true + #刷新mapper 调试神器 + refresh-mapper: true + # 逻辑删除字段 + logic-delete-value: 1 + logic-not-delete-value: 0 + #自定义SQL注入器 + sql-injector: com.baomidou.mybatisplus.mapper.LogicSqlInjector + configuration: + map-underscore-to-camel-case: true + cache-enabled: true diff --git a/pigx-eureka/Dockerfile b/pigx-eureka/Dockerfile new file mode 100644 index 000000000..e05fb249b --- /dev/null +++ b/pigx-eureka/Dockerfile @@ -0,0 +1,13 @@ +FROM anapsix/alpine-java:8_server-jre_unlimited + +MAINTAINER wangiegie@gmail.com + +RUN mkdir -p /pigx/bin/com.pig4cloud/pigx-eureka + +WORKDIR /pigx/bin/com.pig4cloud/pigx-eureka + +EXPOSE 1025 + +ADD ./pigx-eureka/target/pigx-eureka.jar ./ + +CMD java -Djava.security.egd=file:/dev/./urandom -jar pigx-eureka.jar diff --git a/pigx-eureka/pom.xml b/pigx-eureka/pom.xml new file mode 100644 index 000000000..963a5f786 --- /dev/null +++ b/pigx-eureka/pom.xml @@ -0,0 +1,80 @@ + + + + + 4.0.0 + + com.pig4cloud + pigx + ${pigx.version} + + + com.pig4cloud.pigx + pigx-eureka + ${pigx.version} + jar + + pigx-eureka + pigx 服务中心,基于eureka + + + + + org.springframework.cloud + spring-cloud-starter-netflix-eureka-server + + + + org.springframework.cloud + spring-cloud-starter-security + + + + org.springframework.boot + spring-boot-starter-web + + + + spring-boot-starter-tomcat + org.springframework.boot + + + + + + org.springframework.boot + spring-boot-starter-undertow + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + ${project.name} + + + + + + diff --git a/pigx-eureka/src/main/java/com/pig4cloud/pigx/eureka/PigxEurekaApplication.java b/pigx-eureka/src/main/java/com/pig4cloud/pigx/eureka/PigxEurekaApplication.java new file mode 100644 index 000000000..c95bdb2c3 --- /dev/null +++ b/pigx-eureka/src/main/java/com/pig4cloud/pigx/eureka/PigxEurekaApplication.java @@ -0,0 +1,39 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.eureka; + + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; + +/** + * @author lengleng + * @date 2018年06月21日 + * 服务中心 + */ +@EnableEurekaServer +@SpringBootApplication +public class PigxEurekaApplication { + + public static void main(String[] args) { + SpringApplication.run(PigxEurekaApplication.class, args); + } +} diff --git a/pigx-eureka/src/main/java/com/pig4cloud/pigx/eureka/security/WebSecurityConfig.java b/pigx-eureka/src/main/java/com/pig4cloud/pigx/eureka/security/WebSecurityConfig.java new file mode 100644 index 000000000..3faacc7d4 --- /dev/null +++ b/pigx-eureka/src/main/java/com/pig4cloud/pigx/eureka/security/WebSecurityConfig.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.eureka.security; + +/** + * @author lengleng + * @date 2018/7/12 + */ + +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; + +@EnableWebSecurity +public class WebSecurityConfig extends WebSecurityConfigurerAdapter { + @Override + protected void configure(HttpSecurity http) throws Exception { + http.csrf().disable() + .authorizeRequests() + .antMatchers("actuator/**").permitAll() + .anyRequest() + .authenticated().and().httpBasic(); + } +} diff --git a/pigx-eureka/src/main/resources/bootstrap.yml b/pigx-eureka/src/main/resources/bootstrap.yml new file mode 100644 index 000000000..2c36ec856 --- /dev/null +++ b/pigx-eureka/src/main/resources/bootstrap.yml @@ -0,0 +1,32 @@ +server: + port: 1025 + +spring: + security: + user: + name: pig + password: pig + application: + name: pigx-eureka + +# docker-compose部署时候 hostname 换成pigx-eureka +# 类似的 redis 使用pigx-redis ,gateway 换成 pigx-gateway +eureka: + instance: + hostname: localhost + prefer-ip-address: true + client: + register-with-eureka: false + fetch-registry: false + service-url: + defaultZone: http://pig:pig@${eureka.instance.hostname}:${server.port}/eureka/ + server: + eviction-interval-timer-in-ms: 4000 + enable-self-preservation: false + renewal-percent-threshold: 0.9 + +management: + endpoints: + web: + exposure: + include: '*' diff --git a/pigx-gateway/Dockerfile b/pigx-gateway/Dockerfile new file mode 100644 index 000000000..40afbbe0a --- /dev/null +++ b/pigx-gateway/Dockerfile @@ -0,0 +1,13 @@ +FROM anapsix/alpine-java:8_server-jre_unlimited + +MAINTAINER wangiegie@gmail.com + +RUN mkdir -p /pigx/bin/com.pig4cloud/pigx-gateway + +WORKDIR /pigx/bin/com.pig4cloud/pigx-gateway + +EXPOSE 1025 + +ADD ./pigx-gateway/target/pigx-gateway.jar ./ + +CMD java -Djava.security.egd=file:/dev/./urandom -jar pigx-gateway.jar diff --git a/pigx-gateway/pom.xml b/pigx-gateway/pom.xml new file mode 100644 index 000000000..437e7e34d --- /dev/null +++ b/pigx-gateway/pom.xml @@ -0,0 +1,88 @@ + + + + + 4.0.0 + + com.pig4cloud + pigx + ${pigx.version} + + + pigx-gateway + ${pigx.version} + jar + pigx-gateway + pigx 服务网关,基于 spring cloud gateway + + + + + org.springframework.cloud + spring-cloud-starter-gateway + + + org.springframework.boot + spring-boot-starter-data-redis-reactive + + + + org.springframework.cloud + spring-cloud-starter-config + + + + com.github.axet + kaptcha + ${kaptcha.version} + + + + cn.hutool + hutool-all + ${hutool.version} + + + + io.springfox + springfox-swagger-ui + ${swagger.version} + + + io.springfox + springfox-swagger2 + ${swagger.version} + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + ${project.name} + + + + + + diff --git a/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/PigxGatewayApplication.java b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/PigxGatewayApplication.java new file mode 100644 index 000000000..387740c2d --- /dev/null +++ b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/PigxGatewayApplication.java @@ -0,0 +1,37 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.gateway; + + +import org.springframework.boot.SpringApplication; +import org.springframework.cloud.client.SpringCloudApplication; + +/** + * @author lengleng + * @date 2018年06月21日 + * 网关应用 + */ +@SpringCloudApplication +public class PigxGatewayApplication { + + public static void main(String[] args) { + SpringApplication.run(PigxGatewayApplication.class, args); + } +} diff --git a/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/config/FilterIgnorePropertiesConfig.java b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/config/FilterIgnorePropertiesConfig.java new file mode 100644 index 000000000..3aba34a94 --- /dev/null +++ b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/config/FilterIgnorePropertiesConfig.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.gateway.config; + +import lombok.Data; +import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.cloud.context.config.annotation.RefreshScope; +import org.springframework.context.annotation.Configuration; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author lengleng + * @date 2018/7/22 + * 网关不简要终端配置 + */ +@Data +@Configuration +@RefreshScope +@ConditionalOnExpression("!'${ignore}'.isEmpty()") +@ConfigurationProperties(prefix = "ignore") +public class FilterIgnorePropertiesConfig { + private List clients = new ArrayList<>(); +} diff --git a/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/config/KaptchaConfiguration.java b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/config/KaptchaConfiguration.java new file mode 100644 index 000000000..2d7db075a --- /dev/null +++ b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/config/KaptchaConfiguration.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.gateway.config; + +import com.google.code.kaptcha.impl.DefaultKaptcha; +import com.google.code.kaptcha.util.Config; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.util.Properties; + +/** + * @author lengleng + * @date 2017-12-21 21:12:18 + */ +@Configuration +public class KaptchaConfiguration { + + private static final String KAPTCHA_BORDER = "kaptcha.border"; + private static final String KAPTCHA_TEXTPRODUCER_FONT_COLOR = "kaptcha.textproducer.font.color"; + private static final String KAPTCHA_TEXTPRODUCER_CHAR_SPACE = "kaptcha.textproducer.char.space"; + private static final String KAPTCHA_IMAGE_WIDTH = "kaptcha.image.width"; + private static final String KAPTCHA_IMAGE_HEIGHT = "kaptcha.image.height"; + private static final String KAPTCHA_TEXTPRODUCER_CHAR_LENGTH = "kaptcha.textproducer.char.length"; + private static final Object KAPTCHA_IMAGE_FONT_SIZE = "kaptcha.textproducer.font.size"; + + /** + * 默认生成图形验证码宽度 + */ + private static final String DEFAULT_IMAGE_WIDTH = "100"; + + /** + * 默认生成图像验证码高度 + */ + private static final String DEFAULT_IMAGE_HEIGHT = "40"; + + /** + * 默认生成图形验证码长度 + */ + private static final String DEFAULT_IMAGE_LENGTH = "4"; + /** + * 边框颜色,合法值: r,g,b (and optional alpha) 或者 white,black,blue. + */ + private static final String DEFAULT_COLOR_FONT = "black"; + + /** + * 图片边框 + */ + private static final String DEFAULT_IMAGE_BORDER = "no"; + /** + * 默认图片间隔 + */ + private static final String DEFAULT_CHAR_SPACE = "5"; + /** + * 验证码文字大小 + */ + private static final String DEFAULT_IMAGE_FONT_SIZE = "30"; + + @Bean + public DefaultKaptcha producer() { + Properties properties = new Properties(); + properties.put(KAPTCHA_BORDER, DEFAULT_IMAGE_BORDER); + properties.put(KAPTCHA_TEXTPRODUCER_FONT_COLOR, DEFAULT_COLOR_FONT); + properties.put(KAPTCHA_TEXTPRODUCER_CHAR_SPACE, DEFAULT_CHAR_SPACE); + properties.put(KAPTCHA_IMAGE_WIDTH, DEFAULT_IMAGE_WIDTH); + properties.put(KAPTCHA_IMAGE_HEIGHT, DEFAULT_IMAGE_HEIGHT); + properties.put(KAPTCHA_IMAGE_FONT_SIZE, DEFAULT_IMAGE_FONT_SIZE); + properties.put(KAPTCHA_TEXTPRODUCER_CHAR_LENGTH, DEFAULT_IMAGE_LENGTH); + Config config = new Config(properties); + DefaultKaptcha defaultKaptcha = new DefaultKaptcha(); + defaultKaptcha.setConfig(config); + return defaultKaptcha; + } +} diff --git a/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/config/RateLimiterConfiguration.java b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/config/RateLimiterConfiguration.java new file mode 100644 index 000000000..e5d1c2af3 --- /dev/null +++ b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/config/RateLimiterConfiguration.java @@ -0,0 +1,38 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.gateway.config; + +import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import reactor.core.publisher.Mono; + +/** + * @author lengleng + * @date 2018/7/1 + * 路由限流配置 + */ +@Configuration +public class RateLimiterConfiguration { + @Bean(value = "remoteAddrKeyResolver") + public KeyResolver remoteAddrKeyResolver() { + return exchange -> Mono.just(exchange.getRequest().getRemoteAddress().getAddress().getHostAddress()); + } +} diff --git a/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/config/RouterFunctionConfiguration.java b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/config/RouterFunctionConfiguration.java new file mode 100644 index 000000000..c52f00318 --- /dev/null +++ b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/config/RouterFunctionConfiguration.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.gateway.config; + +import com.pig4cloud.pigx.gateway.handle.*; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.web.reactive.function.server.RequestPredicates; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.RouterFunctions; + +/** + * @author lengleng + * @date 2018/7/5 + * 路由配置信息 + */ +@Slf4j +@Configuration +@AllArgsConstructor +public class RouterFunctionConfiguration { + private final HystrixFallbackHandler hystrixFallbackHandler; + private final SwaggerResourceHandler swaggerResourceHandler; + private final SwaggerSecurityHandler swaggerSecurityHandler; + private final SwaggerUiHandler swaggerUiHandler; + private final ImageCodeHandler imageCodeHandler; + + @Bean + public RouterFunction routerFunction() { + return RouterFunctions.route( + RequestPredicates.GET("/fallback") + .and(RequestPredicates.accept(MediaType.TEXT_PLAIN)), hystrixFallbackHandler) + .andRoute(RequestPredicates.GET("/code") + .and(RequestPredicates.accept(MediaType.TEXT_PLAIN)), imageCodeHandler) + .andRoute(RequestPredicates.GET("/swagger-resources") + .and(RequestPredicates.accept(MediaType.ALL)), swaggerResourceHandler) + .andRoute(RequestPredicates.GET("/swagger-resources/configuration/ui") + .and(RequestPredicates.accept(MediaType.ALL)), swaggerUiHandler) + .andRoute(RequestPredicates.GET("/swagger-resources/configuration/security") + .and(RequestPredicates.accept(MediaType.ALL)), swaggerSecurityHandler); + + } + +} diff --git a/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/config/SwaggerProvider.java b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/config/SwaggerProvider.java new file mode 100644 index 000000000..d8b8a02f0 --- /dev/null +++ b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/config/SwaggerProvider.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.gateway.config; + +import lombok.AllArgsConstructor; +import org.springframework.cloud.gateway.config.GatewayProperties; +import org.springframework.cloud.gateway.route.RouteLocator; +import org.springframework.cloud.gateway.support.NameUtils; +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Component; +import springfox.documentation.swagger.web.SwaggerResource; +import springfox.documentation.swagger.web.SwaggerResourcesProvider; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Sywd + * 聚合接口文档注册,和zuul实现类似 + */ +@Component +@Primary +@AllArgsConstructor +public class SwaggerProvider implements SwaggerResourcesProvider { + public static final String API_URI = "/v2/api-docs"; + private final RouteLocator routeLocator; + private final GatewayProperties gatewayProperties; + + + @Override + public List get() { + List resources = new ArrayList<>(); + List routes = new ArrayList<>(); + routeLocator.getRoutes().subscribe(route -> routes.add(route.getId())); + gatewayProperties.getRoutes().stream().filter(routeDefinition -> routes.contains(routeDefinition.getId())) + .forEach(routeDefinition -> routeDefinition.getPredicates().stream() + .filter(predicateDefinition -> "Path".equalsIgnoreCase(predicateDefinition.getName())) + .filter(predicateDefinition -> !"pigx-auth".equalsIgnoreCase(routeDefinition.getId())) + .forEach(predicateDefinition -> resources.add(swaggerResource(routeDefinition.getId(), + predicateDefinition.getArgs().get(NameUtils.GENERATED_NAME_PREFIX + "0") + .replace("/**", API_URI))))); + return resources; + } + + private SwaggerResource swaggerResource(String name, String location) { + SwaggerResource swaggerResource = new SwaggerResource(); + swaggerResource.setName(name); + swaggerResource.setLocation(location); + swaggerResource.setSwaggerVersion("2.0"); + return swaggerResource; + } +} diff --git a/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/exception/CheckedException.java b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/exception/CheckedException.java new file mode 100644 index 000000000..214174dc2 --- /dev/null +++ b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/exception/CheckedException.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.gateway.exception; + +/** + * @author lengleng + * @date 2018年07月22日 + * 异常包装类 + */ +public class CheckedException extends Exception { + + private static final long serialVersionUID = 1L; + + public CheckedException() { + } + + public CheckedException(String message) { + super(message); + } + + public CheckedException(Throwable cause) { + super(cause); + } + + public CheckedException(String message, Throwable cause) { + super(message, cause); + } + + public CheckedException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } +} diff --git a/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/exception/ValidateCodeException.java b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/exception/ValidateCodeException.java new file mode 100644 index 000000000..a86375ac3 --- /dev/null +++ b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/exception/ValidateCodeException.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.gateway.exception; + +/** + * @author lengleng + */ +public class ValidateCodeException extends Exception { + +} diff --git a/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/filter/ImageCodeGatewayFilter.java b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/filter/ImageCodeGatewayFilter.java new file mode 100644 index 000000000..33f798076 --- /dev/null +++ b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/filter/ImageCodeGatewayFilter.java @@ -0,0 +1,186 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.gateway.filter; + +import cn.hutool.core.codec.Base64; +import cn.hutool.core.util.CharsetUtil; +import cn.hutool.core.util.StrUtil; +import com.pig4cloud.pigx.gateway.config.FilterIgnorePropertiesConfig; +import com.pig4cloud.pigx.gateway.exception.CheckedException; +import com.pig4cloud.pigx.gateway.exception.ValidateCodeException; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cloud.gateway.filter.GatewayFilter; +import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.http.HttpStatus; +import org.springframework.http.server.reactive.ServerHttpRequest; +import org.springframework.http.server.reactive.ServerHttpResponse; +import org.springframework.stereotype.Component; + +import java.io.IOException; + +/** + * @author lengleng + * @date 2018/7/4 + * 验证码处理 + */ +@Slf4j +@Component +public class ImageCodeGatewayFilter extends AbstractGatewayFilterFactory { + public static final String DEFAULT_CODE_KEY = "DEFAULT_CODE_KEY"; + public static final String OAUTH_TOKEN_URL = "/oauth/token"; + @Autowired + private RedisTemplate redisTemplate; + @Autowired + private FilterIgnorePropertiesConfig filterIgnorePropertiesConfig; + + @Override + public GatewayFilter apply(Object config) { + return (exchange, chain) -> { + ServerHttpRequest request = exchange.getRequest(); + + // 不是登录请求,直接向下执行 + if (!StrUtil.containsAnyIgnoreCase(request.getURI().getPath(), OAUTH_TOKEN_URL)) { + return chain.filter(exchange); + } + + // 终端设置不校验, 直接向下执行(1. 从请求参数中获取 2.从header取) + String clientId = request.getQueryParams().getFirst("client_id"); + if (StrUtil.isNotBlank(clientId)) { + if (filterIgnorePropertiesConfig.getClients().contains(clientId)) { + return chain.filter(exchange); + } + } + try { + String[] clientInfos = extractAndDecodeHeader(request); + if (filterIgnorePropertiesConfig.getClients().contains(clientInfos[0])) { + return chain.filter(exchange); + } + } catch (Exception e) { + ServerHttpResponse response = exchange.getResponse(); + response.setStatusCode(HttpStatus.PRECONDITION_REQUIRED); + return response.setComplete(); + } + + //校验验证码合法性 + try { + checkCode(request); + } catch (ValidateCodeException e) { + ServerHttpResponse response = exchange.getResponse(); + response.setStatusCode(HttpStatus.PRECONDITION_REQUIRED); + return response.setComplete(); + } + + return chain.filter(exchange); + }; + } + + + /** + * 检查code + * + * @param request + * @throws ValidateCodeException 校验异常 + */ + private void checkCode(ServerHttpRequest request) throws ValidateCodeException { + String code = request.getQueryParams().getFirst("code"); + + if (StrUtil.isBlank(code)) { + throw new ValidateCodeException(); + } + + String randomStr = request.getQueryParams().getFirst("randomStr"); + if (StrUtil.isBlank(randomStr)) { + throw new ValidateCodeException(); + } + + String key = DEFAULT_CODE_KEY + randomStr; + if (!redisTemplate.hasKey(key)) { + throw new ValidateCodeException(); + } + + Object codeObj = redisTemplate.opsForValue().get(key); + + if (codeObj == null) { + throw new ValidateCodeException(); + } + + String saveCode = codeObj.toString(); + if (StrUtil.isBlank(saveCode)) { + redisTemplate.delete(key); + throw new ValidateCodeException(); + } + + if (!StrUtil.equals(saveCode, code)) { + redisTemplate.delete(key); + throw new ValidateCodeException(); + } + + redisTemplate.delete(key); + } + + private static final String BASIC_ = "Basic "; + + /** + * 从header 请求中的clientId/clientsecect + * + * @param header header中的参数 + * @throws CheckedException if the Basic header is not present or is not valid + * Base64 + */ + public static String[] extractAndDecodeHeader(String header) + throws IOException, CheckedException { + + byte[] base64Token = header.substring(6).getBytes("UTF-8"); + byte[] decoded; + try { + decoded = Base64.decode(base64Token); + } catch (IllegalArgumentException e) { + throw new CheckedException( + "Failed to decode basic authentication token"); + } + + String token = new String(decoded, CharsetUtil.UTF_8); + + int delim = token.indexOf(":"); + + if (delim == -1) { + throw new CheckedException("Invalid basic authentication token"); + } + return new String[]{token.substring(0, delim), token.substring(delim + 1)}; + } + + /** + * *从header 请求中的clientId/clientsecect + * + * @param request + * @return + * @throws IOException + */ + public static String[] extractAndDecodeHeader(ServerHttpRequest request) + throws IOException, CheckedException { + String header = request.getHeaders().getFirst("Authorization"); + + if (header == null || !header.startsWith(BASIC_)) { + throw new CheckedException("请求头中client信息为空"); + } + + return extractAndDecodeHeader(header); + } +} diff --git a/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/filter/PasswordDecoderFilter.java b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/filter/PasswordDecoderFilter.java new file mode 100644 index 000000000..025869e90 --- /dev/null +++ b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/filter/PasswordDecoderFilter.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.gateway.filter; + +import cn.hutool.core.codec.Base64; +import cn.hutool.core.util.CharsetUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.http.HttpUtil; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.cloud.gateway.filter.GatewayFilter; +import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory; +import org.springframework.http.server.reactive.ServerHttpRequest; +import org.springframework.stereotype.Component; +import org.springframework.web.util.UriComponentsBuilder; +import reactor.core.publisher.Mono; + +import javax.crypto.Cipher; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; +import java.net.URI; +import java.util.Map; + +/** + * @author lengleng + * @date 2018/7/15 + * 密码解密工具类 + */ +@Slf4j +@Component +public class PasswordDecoderFilter extends AbstractGatewayFilterFactory { + private static final String PASSWORD = "password"; + private static final String KEY_ALGORITHM = "AES"; + private static final String DEFAULT_CIPHER_ALGORITHM = "AES/CBC/NOPadding"; + @Value("${security.encode.key:1234567812345678}") + private String encodeKey; + + @Override + public GatewayFilter apply(Object config) { + return (exchange, chain) -> { + ServerHttpRequest request = exchange.getRequest(); + + // 不是登录请求,直接向下执行 + if (!StrUtil.containsAnyIgnoreCase(request.getURI().getPath(), ImageCodeGatewayFilter.OAUTH_TOKEN_URL)) { + return chain.filter(exchange); + } + + URI uri = exchange.getRequest().getURI(); + String queryParam = uri.getRawQuery(); + Map paramMap = HttpUtil.decodeParamMap(queryParam, CharsetUtil.UTF_8); + + String password = paramMap.get(PASSWORD); + if (StrUtil.isNotBlank(password)) { + try { + password = decryptAES(password, encodeKey); + } catch (Exception e) { + log.error("密码解密失败:{}", password); + return Mono.error(e); + } + paramMap.put(PASSWORD, password.trim()); + } + + URI newUri = UriComponentsBuilder.fromUri(uri) + .replaceQuery(HttpUtil.toParams(paramMap)) + .build(true) + .toUri(); + + ServerHttpRequest newRequest = exchange.getRequest().mutate().uri(newUri).build(); + return chain.filter(exchange.mutate().request(newRequest).build()); + }; + } + + + private static String decryptAES(String data, String pass) throws Exception { + Cipher cipher = Cipher.getInstance(DEFAULT_CIPHER_ALGORITHM); + SecretKeySpec keyspec = new SecretKeySpec(pass.getBytes(), KEY_ALGORITHM); + IvParameterSpec ivspec = new IvParameterSpec(pass.getBytes()); + cipher.init(Cipher.DECRYPT_MODE, keyspec, ivspec); + byte[] result = cipher.doFinal(Base64.decode(data.getBytes(CharsetUtil.UTF_8))); + return new String(result, CharsetUtil.UTF_8); + } +} diff --git a/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/filter/SwaggerHeaderFilter.java b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/filter/SwaggerHeaderFilter.java new file mode 100644 index 000000000..964ac0d65 --- /dev/null +++ b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/filter/SwaggerHeaderFilter.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.gateway.filter; + +import com.pig4cloud.pigx.gateway.config.SwaggerProvider; +import org.springframework.cloud.gateway.filter.GatewayFilter; +import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory; +import org.springframework.http.server.reactive.ServerHttpRequest; +import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; +import org.springframework.web.server.ServerWebExchange; + +/** + * @author Sywd + * 添加X-Forwarded-Prefix header + */ +@Component +public class SwaggerHeaderFilter extends AbstractGatewayFilterFactory { + private static final String HEADER_NAME = "X-Forwarded-Prefix"; + + @Override + public GatewayFilter apply(Object config) { + return (exchange, chain) -> { + ServerHttpRequest request = exchange.getRequest(); + String path = request.getURI().getPath(); + if (!StringUtils.endsWithIgnoreCase(path, SwaggerProvider.API_URI)) { + return chain.filter(exchange); + } + + String basePath = path.substring(0, path.lastIndexOf(SwaggerProvider.API_URI)); + + + ServerHttpRequest newRequest = request.mutate().header(HEADER_NAME, basePath).build(); + ServerWebExchange newExchange = exchange.mutate().request(newRequest).build(); + return chain.filter(newExchange); + }; + } +} diff --git a/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/handle/HystrixFallbackHandler.java b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/handle/HystrixFallbackHandler.java new file mode 100644 index 000000000..794f1080a --- /dev/null +++ b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/handle/HystrixFallbackHandler.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.gateway.handle; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.function.BodyInserters; +import org.springframework.web.reactive.function.server.HandlerFunction; +import org.springframework.web.reactive.function.server.ServerRequest; +import org.springframework.web.reactive.function.server.ServerResponse; +import reactor.core.publisher.Mono; + +/** + * @author lengleng + * @date 2018/7/5 + * Hystrix 降级处理 + */ +@Slf4j +@Component +public class HystrixFallbackHandler implements HandlerFunction { + @Override + public Mono handle(ServerRequest serverRequest) { + log.error("网关执行请求:{}失败,hystrix服务降级处理", serverRequest.uri()); + return ServerResponse.status(HttpStatus.INTERNAL_SERVER_ERROR.value()) + .contentType(MediaType.TEXT_PLAIN).body(BodyInserters.fromObject("服务异常")); + } +} diff --git a/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/handle/ImageCodeHandler.java b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/handle/ImageCodeHandler.java new file mode 100644 index 000000000..98e9ddb8e --- /dev/null +++ b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/handle/ImageCodeHandler.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.gateway.handle; + +import com.google.code.kaptcha.Producer; +import com.pig4cloud.pigx.gateway.filter.ImageCodeGatewayFilter; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.core.io.ByteArrayResource; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.stereotype.Component; +import org.springframework.util.FastByteArrayOutputStream; +import org.springframework.web.reactive.function.BodyInserters; +import org.springframework.web.reactive.function.server.HandlerFunction; +import org.springframework.web.reactive.function.server.ServerRequest; +import org.springframework.web.reactive.function.server.ServerResponse; +import reactor.core.publisher.Mono; + +import javax.imageio.ImageIO; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.util.concurrent.TimeUnit; + +/** + * @author lengleng + * @date 2018/7/5 + * 验证码生成逻辑处理类 + */ +@Slf4j +@Component +@AllArgsConstructor +public class ImageCodeHandler implements HandlerFunction { + private final Producer producer; + private final RedisTemplate redisTemplate; + + @Override + public Mono handle(ServerRequest serverRequest) { + //生成验证码 + String text = producer.createText(); + BufferedImage image = producer.createImage(text); + + //保存验证码信息 + String randomStr = serverRequest.queryParam("randomStr").get(); + redisTemplate.opsForValue().set(ImageCodeGatewayFilter.DEFAULT_CODE_KEY + randomStr, text, 60, TimeUnit.SECONDS); + + // 转换流信息写出 + FastByteArrayOutputStream os = new FastByteArrayOutputStream(); + try { + ImageIO.write(image, "jpeg", os); + } catch (IOException e) { + log.error("ImageIO write err", e); + return Mono.error(e); + } + + return ServerResponse + .status(HttpStatus.OK) + .contentType(MediaType.IMAGE_JPEG) + .body(BodyInserters.fromResource(new ByteArrayResource(os.toByteArray()))); + } +} diff --git a/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/handle/SwaggerResourceHandler.java b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/handle/SwaggerResourceHandler.java new file mode 100644 index 000000000..e443149b7 --- /dev/null +++ b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/handle/SwaggerResourceHandler.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.gateway.handle; + +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.function.BodyInserters; +import org.springframework.web.reactive.function.server.HandlerFunction; +import org.springframework.web.reactive.function.server.ServerRequest; +import org.springframework.web.reactive.function.server.ServerResponse; +import reactor.core.publisher.Mono; +import springfox.documentation.swagger.web.SwaggerResourcesProvider; + +/** + * @author lengleng + * @date 2018-07-19 + * SwaggerResourceHandler + */ +@Slf4j +@Component +@AllArgsConstructor +public class SwaggerResourceHandler implements HandlerFunction { + private final SwaggerResourcesProvider swaggerResources; + + /** + * Handle the given request. + * + * @param request the request to handle + * @return the response + */ + @Override + public Mono handle(ServerRequest request) { + return ServerResponse.status(HttpStatus.OK) + .contentType(MediaType.APPLICATION_JSON_UTF8) + .body(BodyInserters.fromObject(swaggerResources.get())); + } +} diff --git a/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/handle/SwaggerSecurityHandler.java b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/handle/SwaggerSecurityHandler.java new file mode 100644 index 000000000..b6a8b0b77 --- /dev/null +++ b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/handle/SwaggerSecurityHandler.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.gateway.handle; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.function.BodyInserters; +import org.springframework.web.reactive.function.server.HandlerFunction; +import org.springframework.web.reactive.function.server.ServerRequest; +import org.springframework.web.reactive.function.server.ServerResponse; +import reactor.core.publisher.Mono; +import springfox.documentation.swagger.web.SecurityConfiguration; +import springfox.documentation.swagger.web.SecurityConfigurationBuilder; + +import java.util.Optional; + +/** + * @author lengleng + * @date 2018-07-19 + * SwaggerSecurityHandler + */ +@Slf4j +@Component +public class SwaggerSecurityHandler implements HandlerFunction { + @Autowired(required = false) + private SecurityConfiguration securityConfiguration; + + /** + * Handle the given request. + * + * @param request the request to handle + * @return the response + */ + @Override + public Mono handle(ServerRequest request) { + return ServerResponse.status(HttpStatus.OK) + .contentType(MediaType.APPLICATION_JSON_UTF8) + .body(BodyInserters.fromObject( + Optional.ofNullable(securityConfiguration) + .orElse(SecurityConfigurationBuilder.builder().build()))); + } +} diff --git a/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/handle/SwaggerUiHandler.java b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/handle/SwaggerUiHandler.java new file mode 100644 index 000000000..a0f98630a --- /dev/null +++ b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/handle/SwaggerUiHandler.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.gateway.handle; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.function.BodyInserters; +import org.springframework.web.reactive.function.server.HandlerFunction; +import org.springframework.web.reactive.function.server.ServerRequest; +import org.springframework.web.reactive.function.server.ServerResponse; +import reactor.core.publisher.Mono; +import springfox.documentation.swagger.web.UiConfiguration; +import springfox.documentation.swagger.web.UiConfigurationBuilder; + +import java.util.Optional; + +/** + * @author lengleng + * @date 2018-07-19 + * SwaggerUiHandler + */ +@Slf4j +@Component +public class SwaggerUiHandler implements HandlerFunction { + @Autowired(required = false) + private UiConfiguration uiConfiguration; + + /** + * Handle the given request. + * + * @param request the request to handle + * @return the response + */ + @Override + public Mono handle(ServerRequest request) { + return ServerResponse.status(HttpStatus.OK) + .contentType(MediaType.APPLICATION_JSON_UTF8) + .body(BodyInserters.fromObject( + Optional.ofNullable(uiConfiguration) + .orElse(UiConfigurationBuilder.builder().build()))); + } +} diff --git a/pigx-gateway/src/main/resources/bootstrap.yml b/pigx-gateway/src/main/resources/bootstrap.yml new file mode 100644 index 000000000..aeb0ffd87 --- /dev/null +++ b/pigx-gateway/src/main/resources/bootstrap.yml @@ -0,0 +1,27 @@ +server: + port: 9999 + +spring: + application: + name: pigx-gateway + # 配置中心 + cloud: + config: + fail-fast: true + name: ${spring.application.name} + profile: ${spring.profiles.active} + discovery: + enabled: true + service-id: pigx-config + profiles: + active: dev + +# 注册中心 +eureka: + instance: + prefer-ip-address: true + client: + service-url: + defaultZone: http://pig:pig@localhost:1025/eureka/ + + diff --git a/pigx-monitor/Dockerfile b/pigx-monitor/Dockerfile new file mode 100644 index 000000000..b48ea7e08 --- /dev/null +++ b/pigx-monitor/Dockerfile @@ -0,0 +1,13 @@ +FROM anapsix/alpine-java:8_server-jre_unlimited + +MAINTAINER wangiegie@gmail.com + +RUN mkdir -p /pigx/bin/com.pig4cloud/pigx-monitor + +WORKDIR /pigx/bin/com.pig4cloud/pigx-monitor + +EXPOSE 1025 + +ADD ./pigx-monitor/target/pigx-monitor.jar ./ + +CMD java -Djava.security.egd=file:/dev/./urandom -jar pigx-monitor.jar diff --git a/pigx-monitor/pom.xml b/pigx-monitor/pom.xml new file mode 100644 index 000000000..467dbcc54 --- /dev/null +++ b/pigx-monitor/pom.xml @@ -0,0 +1,80 @@ + + + + + 4.0.0 + + com.pig4cloud + pigx + ${pigx.version} + + + pigx-monitor + ${pigx.version} + jar + + pigx-monitor + pigx 监控模块,基于 spring boot admin + + + + + de.codecentric + spring-boot-admin-starter-server + ${monitor.version} + + + + org.springframework.cloud + spring-cloud-starter-config + + + + org.springframework.boot + spring-boot-starter-web + + + + spring-boot-starter-tomcat + org.springframework.boot + + + + + + org.springframework.boot + spring-boot-starter-undertow + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + ${project.name} + + + + + + diff --git a/pigx-monitor/src/main/java/com/pig4cloud/pigx/monitor/PigxMonitorApplication.java b/pigx-monitor/src/main/java/com/pig4cloud/pigx/monitor/PigxMonitorApplication.java new file mode 100644 index 000000000..8ac0e57da --- /dev/null +++ b/pigx-monitor/src/main/java/com/pig4cloud/pigx/monitor/PigxMonitorApplication.java @@ -0,0 +1,39 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.monitor; + + +import de.codecentric.boot.admin.server.config.EnableAdminServer; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * @author lengleng + * @date 2018年06月21日 + * 监控中心 + */ +@EnableAdminServer +@SpringBootApplication +public class PigxMonitorApplication { + + public static void main(String[] args) { + SpringApplication.run(PigxMonitorApplication.class, args); + } +} diff --git a/pigx-monitor/src/main/resources/bootstrap.yml b/pigx-monitor/src/main/resources/bootstrap.yml new file mode 100644 index 000000000..1e29612c9 --- /dev/null +++ b/pigx-monitor/src/main/resources/bootstrap.yml @@ -0,0 +1,23 @@ +server: + port: 5001 + +spring: + application: + name: pigx-monitor + #配置中心 + cloud: + config: + fail-fast: true + name: ${spring.application.name} + profile: dev + discovery: + enabled: true + service-id: pigx-config + +# 注册中心配置 +eureka: + instance: + prefer-ip-address: true + client: + service-url: + defaultZone: http://pig:pig@localhost:1025/eureka/ diff --git a/pigx-upms/pigx-upms-api/pom.xml b/pigx-upms/pigx-upms-api/pom.xml new file mode 100644 index 000000000..b2d2dface --- /dev/null +++ b/pigx-upms/pigx-upms-api/pom.xml @@ -0,0 +1,51 @@ + + + + + 4.0.0 + + com.pig4cloud + pigx-upms + ${pigx.version} + + + pigx-upms-api + ${pigx.version} + jar + pigx-upms-api + pigx 通用用户权限管理系统公共api模块 + + + + + + com.baomidou + mybatis-plus-boot-starter + ${mbp.boot.version} + + + + com.pig4cloud + pigx-common-security + ${pigx.version} + + + diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/dto/DeptTree.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/dto/DeptTree.java new file mode 100644 index 000000000..078014de0 --- /dev/null +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/dto/DeptTree.java @@ -0,0 +1,32 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.api.dto; + +import lombok.Data; + +/** + * @author lengleng + * @date 2018/1/20 + * 部门树 + */ +@Data +public class DeptTree extends TreeNode { + private String name; +} diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/dto/MenuTree.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/dto/MenuTree.java new file mode 100644 index 000000000..1ccf1dc1a --- /dev/null +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/dto/MenuTree.java @@ -0,0 +1,71 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.api.dto; + +import com.pig4cloud.pigx.admin.api.vo.MenuVO; +import lombok.Data; + +/** + * @author lengleng + * @date 2017年11月9日23:33:27 + */ +@Data +public class MenuTree extends TreeNode { + private String icon; + private String name; + private boolean spread = false; + private String path; + private String component; + private String authority; + private String redirect; + private String code; + private String type; + private String label; + private Integer sort; + + public MenuTree() { + } + + public MenuTree(int id, String name, int parentId) { + this.id = id; + this.parentId = parentId; + this.name = name; + this.label = name; + } + + public MenuTree(int id, String name, MenuTree parent) { + this.id = id; + this.parentId = parent.getId(); + this.name = name; + this.label = name; + } + + public MenuTree(MenuVO menuVo) { + this.id = menuVo.getMenuId(); + this.parentId = menuVo.getParentId(); + this.icon = menuVo.getIcon(); + this.name = menuVo.getName(); + this.path = menuVo.getPath(); + this.component = menuVo.getComponent(); + this.type = menuVo.getType(); + this.label = menuVo.getName(); + this.sort = menuVo.getSort(); + } +} diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/dto/Query.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/dto/Query.java new file mode 100644 index 000000000..8b4a53802 --- /dev/null +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/dto/Query.java @@ -0,0 +1,55 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.api.dto; + +import com.baomidou.mybatisplus.plugins.Page; +import org.apache.commons.lang.StringUtils; + +import java.util.Map; + +/** + * @author lengleng + * @date 2017/12/10 + */ +public class Query extends Page { + private static final String PAGE = "page"; + private static final String LIMIT = "limit"; + private static final String ORDER_BY_FIELD = "orderByField"; + private static final String IS_ASC = "isAsc"; + + public Query(Map params) { + super(Integer.parseInt(params.getOrDefault(PAGE, 1).toString()) + , Integer.parseInt(params.getOrDefault(LIMIT, 10).toString())); + + String orderByField = params.getOrDefault(ORDER_BY_FIELD, "").toString(); + if (StringUtils.isNotEmpty(orderByField)) { + this.setOrderByField(orderByField); + } + + Boolean isAsc = Boolean.parseBoolean(params.getOrDefault(IS_ASC, Boolean.TRUE).toString()); + this.setAsc(isAsc); + + params.remove(PAGE); + params.remove(LIMIT); + params.remove(ORDER_BY_FIELD); + params.remove(IS_ASC); + this.setCondition(params); + } +} diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/dto/RoleDTO.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/dto/RoleDTO.java new file mode 100644 index 000000000..85918aebd --- /dev/null +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/dto/RoleDTO.java @@ -0,0 +1,41 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.api.dto; + +import com.pig4cloud.pigx.admin.api.entity.SysRole; +import lombok.Data; + +/** + * @author lengleng + * @date 2018/1/20 + * 角色Dto + */ +@Data +public class RoleDTO extends SysRole { + /** + * 角色部门Id + */ + private Integer roleDeptId; + + /** + * 部门名称 + */ + private String deptName; +} diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/dto/RouteConfig.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/dto/RouteConfig.java new file mode 100644 index 000000000..67d7bc0bf --- /dev/null +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/dto/RouteConfig.java @@ -0,0 +1,58 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.api.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Map; + +/** + * @author lengleng + * @date 2017/11/7 + */ +@Data +public class RouteConfig implements Serializable { + + @com.alibaba.fastjson.annotation.JSONField(name = "path") + private String path; + @com.alibaba.fastjson.annotation.JSONField(name = "component") + private String component; + @com.alibaba.fastjson.annotation.JSONField(name = "name") + private String name; + @com.alibaba.fastjson.annotation.JSONField(name = "components") + private String components; + @com.alibaba.fastjson.annotation.JSONField(name = "redirect") + private String redirect; + @com.alibaba.fastjson.annotation.JSONField(name = "props") + private String props; + @com.alibaba.fastjson.annotation.JSONField(name = "alias") + private String alias; + @com.alibaba.fastjson.annotation.JSONField(name = "children") + private String children; + @com.alibaba.fastjson.annotation.JSONField(name = "beforeEnter") + private String beforeEnter; + @com.alibaba.fastjson.annotation.JSONField(name = "meta") + private Map meta; + @com.alibaba.fastjson.annotation.JSONField(name = "caseSensitive") + private Boolean caseSensitive; + @com.alibaba.fastjson.annotation.JSONField(name = "pathToRegexpOptions") + private String pathToRegexpOptions; +} diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/dto/TreeNode.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/dto/TreeNode.java new file mode 100644 index 000000000..d578da2f8 --- /dev/null +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/dto/TreeNode.java @@ -0,0 +1,40 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.api.dto; + +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author lengleng + * @date 2017年11月9日23:33:45 + */ +@Data +public class TreeNode { + protected int id; + protected int parentId; + protected List children = new ArrayList(); + + public void add(TreeNode node) { + children.add(node); + } +} diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/dto/UserDTO.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/dto/UserDTO.java new file mode 100644 index 000000000..955da69aa --- /dev/null +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/dto/UserDTO.java @@ -0,0 +1,44 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.api.dto; + +import com.pig4cloud.pigx.admin.api.entity.SysUser; +import lombok.Data; + +import java.util.List; + +/** + * @author lengleng + * @date 2017/11/5 + */ +@Data +public class UserDTO extends SysUser { + /** + * 角色ID + */ + private List role; + + private Integer deptId; + + /** + * 新密码 + */ + private String newpassword1; +} diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/dto/UserInfo.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/dto/UserInfo.java new file mode 100644 index 000000000..448ef2ac8 --- /dev/null +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/dto/UserInfo.java @@ -0,0 +1,74 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.api.dto; + +import com.pig4cloud.pigx.admin.api.entity.SysUser; + +import java.io.Serializable; + +/** + * @author lengleng + * @date 2017/11/11 + *

+ * commit('SET_ROLES', data) + * commit('SET_NAME', data) + * commit('SET_AVATAR', data) + * commit('SET_INTRODUCTION', data) + * commit('SET_PERMISSIONS', data) + */ +public class UserInfo implements Serializable { + /** + * 用户基本信息 + */ + private SysUser sysUser; + /** + * 权限标识集合 + */ + private String[] permissions; + + /** + * 角色集合 + */ + private String[] roles; + + public SysUser getSysUser() { + return sysUser; + } + + public void setSysUser(SysUser sysUser) { + this.sysUser = sysUser; + } + + public String[] getPermissions() { + return permissions; + } + + public void setPermissions(String[] permissions) { + this.permissions = permissions; + } + + public String[] getRoles() { + return roles; + } + + public void setRoles(String[] roles) { + this.roles = roles; + } +} diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysDept.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysDept.java new file mode 100644 index 000000000..19cc3137f --- /dev/null +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysDept.java @@ -0,0 +1,95 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.api.entity; + +import com.baomidou.mybatisplus.activerecord.Model; +import com.baomidou.mybatisplus.annotations.TableField; +import com.baomidou.mybatisplus.annotations.TableId; +import com.baomidou.mybatisplus.annotations.TableLogic; +import com.baomidou.mybatisplus.annotations.TableName; +import com.baomidou.mybatisplus.enums.IdType; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + *

+ * 部门管理 + *

+ * + * @author lengleng + * @since 2018-01-22 + */ +@Data +@TableName("sys_dept") +public class SysDept extends Model { + + private static final long serialVersionUID = 1L; + + @TableId(value = "dept_id", type = IdType.AUTO) + private Integer deptId; + /** + * 部门名称 + */ + private String name; + /** + * 排序 + */ + @TableField("order_num") + private Integer orderNum; + /** + * 创建时间 + */ + @TableField("create_time") + private Date createTime; + /** + * 修改时间 + */ + @TableField("update_time") + private Date updateTime; + /** + * 是否删除 -1:已删除 0:正常 + */ + @TableField("del_flag") + @TableLogic + private String delFlag; + + @TableField("parent_id") + private Integer parentId; + + + @Override + protected Serializable pkVal() { + return this.deptId; + } + + @Override + public String toString() { + return "SysDept{" + + ", deptId=" + deptId + + ", name=" + name + + ", orderNum=" + orderNum + + ", createTime=" + createTime + + ", updateTime=" + updateTime + + ", delFlag=" + delFlag + + "}"; + } +} diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysDeptRelation.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysDeptRelation.java new file mode 100644 index 000000000..7a6e1f72e --- /dev/null +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysDeptRelation.java @@ -0,0 +1,64 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.api.entity; + +import com.baomidou.mybatisplus.activerecord.Model; +import com.baomidou.mybatisplus.annotations.TableName; +import lombok.Data; + +import java.io.Serializable; + +/** + *

+ * + *

+ * + * @author lengleng + * @since 2018-01-22 + */ +@Data +@TableName("sys_dept_relation") +public class SysDeptRelation extends Model { + + private static final long serialVersionUID = 1L; + + /** + * 祖先节点 + */ + private Integer ancestor; + /** + * 后代节点 + */ + private Integer descendant; + + + @Override + protected Serializable pkVal() { + return this.ancestor; + } + + @Override + public String toString() { + return "SysDeptRelation{" + + ", ancestor=" + ancestor + + ", descendant=" + descendant + + "}"; + } +} diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysDict.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysDict.java new file mode 100644 index 000000000..9c4d5f648 --- /dev/null +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysDict.java @@ -0,0 +1,115 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.api.entity; + +import com.baomidou.mybatisplus.activerecord.Model; +import com.baomidou.mybatisplus.annotations.TableField; +import com.baomidou.mybatisplus.annotations.TableId; +import com.baomidou.mybatisplus.annotations.TableLogic; +import com.baomidou.mybatisplus.annotations.TableName; +import com.baomidou.mybatisplus.enums.IdType; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + *

+ * 字典表 + *

+ * + * @author lengleng + * @since 2017-11-19 + */ +@Data +@TableName("sys_dict") +public class SysDict extends Model { + + private static final long serialVersionUID = 1L; + + /** + * 编号 + */ + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + /** + * 数据值 + */ + private String value; + /** + * 标签名 + */ + private String label; + /** + * 类型 + */ + private String type; + /** + * 描述 + */ + private String description; + /** + * 排序(升序) + */ + private BigDecimal sort; + /** + * 创建时间 + */ + @TableField("create_time") + private Date createTime; + /** + * 更新时间 + */ + @TableField("update_time") + private Date updateTime; + /** + * 备注信息 + */ + private String remarks; + /** + * 删除标记 + */ + @TableField("del_flag") + @TableLogic + private String delFlag; + + + @Override + protected Serializable pkVal() { + return this.id; + } + + @Override + public String toString() { + return "SysDict{" + + ", id=" + id + + ", value=" + value + + ", label=" + label + + ", type=" + type + + ", description=" + description + + ", sort=" + sort + + ", createTime=" + createTime + + ", updateTime=" + updateTime + + ", remarks=" + remarks + + ", delFlag=" + delFlag + + "}"; + } +} diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysLog.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysLog.java new file mode 100644 index 000000000..17834b76f --- /dev/null +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysLog.java @@ -0,0 +1,129 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.api.entity; + +import com.baomidou.mybatisplus.annotations.TableId; +import com.baomidou.mybatisplus.annotations.TableLogic; +import com.baomidou.mybatisplus.enums.IdType; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + *

+ * 日志表 + *

+ * + * @author lengleng + * @since 2017-11-20 + */ +@Data +public class SysLog implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 编号 + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + /** + * 日志类型 + */ + private String type; + /** + * 日志标题 + */ + private String title; + /** + * 创建者 + */ + private String createBy; + /** + * 创建时间 + */ + private Date createTime; + /** + * 更新时间 + */ + private Date updateTime; + /** + * 操作IP地址 + */ + private String remoteAddr; + /** + * 用户代理 + */ + private String userAgent; + /** + * 请求URI + */ + private String requestUri; + /** + * 操作方式 + */ + private String method; + /** + * 操作提交的数据 + */ + private String params; + /** + * 执行时间 + */ + private Long time; + + /** + * 删除标记 + */ + @TableLogic + private String delFlag; + + /** + * 异常信息 + */ + private String exception; + + /** + * 服务ID + */ + private String serviceId; + + + @Override + public String toString() { + return "SysLog{" + + "id=" + id + + ", type='" + type + '\'' + + ", title='" + title + '\'' + + ", createBy='" + createBy + '\'' + + ", createTime=" + createTime + + ", updateTime=" + updateTime + + ", remoteAddr='" + remoteAddr + '\'' + + ", userAgent='" + userAgent + '\'' + + ", requestUri='" + requestUri + '\'' + + ", method='" + method + '\'' + + ", params='" + params + '\'' + + ", time=" + time + + ", delFlag='" + delFlag + '\'' + + ", exception='" + exception + '\'' + + '}'; + } +} diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysMenu.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysMenu.java new file mode 100644 index 000000000..5ececf527 --- /dev/null +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysMenu.java @@ -0,0 +1,124 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.api.entity; + +import com.baomidou.mybatisplus.activerecord.Model; +import com.baomidou.mybatisplus.annotations.TableField; +import com.baomidou.mybatisplus.annotations.TableId; +import com.baomidou.mybatisplus.annotations.TableLogic; +import com.baomidou.mybatisplus.annotations.TableName; +import com.baomidou.mybatisplus.enums.IdType; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + *

+ * 菜单权限表 + *

+ * + * @author lengleng + * @since 2017-11-08 + */ +@Data +@TableName("sys_menu") +public class SysMenu extends Model { + + private static final long serialVersionUID = 1L; + + /** + * 菜单ID + */ + @TableId(value = "menu_id", type = IdType.INPUT) + private Integer menuId; + /** + * 菜单名称 + */ + private String name; + /** + * 菜单权限标识 + */ + private String permission; + /** + * 父菜单ID + */ + @TableField("parent_id") + private Integer parentId; + /** + * 图标 + */ + private String icon; + /** + * VUE页面 + */ + private String component; + /** + * 排序值 + */ + private Integer sort; + /** + * 菜单类型 (0菜单 1按钮) + */ + private String type; + /** + * 创建时间 + */ + @TableField("create_time") + private Date createTime; + /** + * 更新时间 + */ + @TableField("update_time") + private Date updateTime; + /** + * 0--正常 1--删除 + */ + @TableLogic + @TableField("del_flag") + private String delFlag; + /** + * 前端URL + */ + private String path; + + + @Override + protected Serializable pkVal() { + return this.menuId; + } + + @Override + public String toString() { + return "SysMenu{" + + ", menuId=" + menuId + + ", name=" + name + + ", permission=" + permission + + ", parentId=" + parentId + + ", icon=" + icon + + ", component=" + component + + ", sort=" + sort + + ", type=" + type + + ", createTime=" + createTime + + ", updateTime=" + updateTime + + ", delFlag=" + delFlag + + "}"; + } +} diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysOauthClientDetails.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysOauthClientDetails.java new file mode 100644 index 000000000..ef385aea8 --- /dev/null +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysOauthClientDetails.java @@ -0,0 +1,173 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.api.entity; + +import com.baomidou.mybatisplus.activerecord.Model; +import com.baomidou.mybatisplus.annotations.TableField; +import com.baomidou.mybatisplus.annotations.TableId; +import com.baomidou.mybatisplus.annotations.TableName; +import com.baomidou.mybatisplus.enums.IdType; + +import java.io.Serializable; + +/** + *

+ * + *

+ * + * @author lengleng + * @since 2018-05-15 + */ +@TableName("sys_oauth_client_details") +public class SysOauthClientDetails extends Model { + + private static final long serialVersionUID = 1L; + + @TableId(value = "client_id", type = IdType.INPUT) + private String clientId; + @TableField("resource_ids") + private String resourceIds; + @TableField("client_secret") + private String clientSecret; + private String scope; + @TableField("authorized_grant_types") + private String authorizedGrantTypes; + @TableField("web_server_redirect_uri") + private String webServerRedirectUri; + private String authorities; + @TableField("access_token_validity") + private Integer accessTokenValidity; + @TableField("refresh_token_validity") + private Integer refreshTokenValidity; + @TableField("additional_information") + private String additionalInformation; + private String autoapprove; + + + public String getClientId() { + return clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getResourceIds() { + return resourceIds; + } + + public void setResourceIds(String resourceIds) { + this.resourceIds = resourceIds; + } + + public String getClientSecret() { + return clientSecret; + } + + public void setClientSecret(String clientSecret) { + this.clientSecret = clientSecret; + } + + public String getScope() { + return scope; + } + + public void setScope(String scope) { + this.scope = scope; + } + + public String getAuthorizedGrantTypes() { + return authorizedGrantTypes; + } + + public void setAuthorizedGrantTypes(String authorizedGrantTypes) { + this.authorizedGrantTypes = authorizedGrantTypes; + } + + public String getWebServerRedirectUri() { + return webServerRedirectUri; + } + + public void setWebServerRedirectUri(String webServerRedirectUri) { + this.webServerRedirectUri = webServerRedirectUri; + } + + public String getAuthorities() { + return authorities; + } + + public void setAuthorities(String authorities) { + this.authorities = authorities; + } + + public Integer getAccessTokenValidity() { + return accessTokenValidity; + } + + public void setAccessTokenValidity(Integer accessTokenValidity) { + this.accessTokenValidity = accessTokenValidity; + } + + public Integer getRefreshTokenValidity() { + return refreshTokenValidity; + } + + public void setRefreshTokenValidity(Integer refreshTokenValidity) { + this.refreshTokenValidity = refreshTokenValidity; + } + + public String getAdditionalInformation() { + return additionalInformation; + } + + public void setAdditionalInformation(String additionalInformation) { + this.additionalInformation = additionalInformation; + } + + public String getAutoapprove() { + return autoapprove; + } + + public void setAutoapprove(String autoapprove) { + this.autoapprove = autoapprove; + } + + @Override + protected Serializable pkVal() { + return this.clientId; + } + + @Override + public String toString() { + return "SysOauthClientDetails{" + + ", clientId=" + clientId + + ", resourceIds=" + resourceIds + + ", clientSecret=" + clientSecret + + ", scope=" + scope + + ", authorizedGrantTypes=" + authorizedGrantTypes + + ", webServerRedirectUri=" + webServerRedirectUri + + ", authorities=" + authorities + + ", accessTokenValidity=" + accessTokenValidity + + ", refreshTokenValidity=" + refreshTokenValidity + + ", additionalInformation=" + additionalInformation + + ", autoapprove=" + autoapprove + + "}"; + } +} diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysRole.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysRole.java new file mode 100644 index 000000000..42726a62f --- /dev/null +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysRole.java @@ -0,0 +1,83 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.api.entity; + +import com.baomidou.mybatisplus.activerecord.Model; +import com.baomidou.mybatisplus.annotations.TableField; +import com.baomidou.mybatisplus.annotations.TableId; +import com.baomidou.mybatisplus.annotations.TableLogic; +import com.baomidou.mybatisplus.annotations.TableName; +import com.baomidou.mybatisplus.enums.IdType; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + *

+ *

+ *

+ * + * @author lengleng + * @since 2017-10-29 + */ +@Data +@TableName("sys_role") +public class SysRole extends Model { + + private static final long serialVersionUID = 1L; + + @TableId(value = "role_id", type = IdType.AUTO) + private Integer roleId; + @TableField("role_name") + private String roleName; + @TableField("role_code") + private String roleCode; + @TableField("role_desc") + private String roleDesc; + @TableField("create_time") + private Date createTime; + @TableField("update_time") + private Date updateTime; + /** + * 删除标识(0-正常,1-删除) + */ + @TableLogic + @TableField("del_flag") + private String delFlag; + + @Override + protected Serializable pkVal() { + return this.roleId; + } + + @Override + public String toString() { + return "SysRole{" + + ", roleId=" + roleId + + ", roleName=" + roleName + + ", roleCode=" + roleCode + + ", roleDesc=" + roleDesc + + ", createTime=" + createTime + + ", updateTime=" + updateTime + + ", delFlag=" + delFlag + + "}"; + } +} diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysRoleDept.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysRoleDept.java new file mode 100644 index 000000000..1333d79e7 --- /dev/null +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysRoleDept.java @@ -0,0 +1,72 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.api.entity; + +import com.baomidou.mybatisplus.activerecord.Model; +import com.baomidou.mybatisplus.annotations.TableField; +import com.baomidou.mybatisplus.annotations.TableId; +import com.baomidou.mybatisplus.annotations.TableName; +import com.baomidou.mybatisplus.enums.IdType; +import lombok.Data; + +import java.io.Serializable; + +/** + *

+ * 角色与部门对应关系 + *

+ * + * @author lengleng + * @since 2018-01-20 + */ +@Data +@TableName("sys_role_dept") +public class SysRoleDept extends Model { + + private static final long serialVersionUID = 1L; + + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + /** + * 角色ID + */ + @TableField("role_id") + private Integer roleId; + /** + * 部门ID + */ + @TableField("dept_id") + private Integer deptId; + + + @Override + protected Serializable pkVal() { + return this.id; + } + + @Override + public String toString() { + return "SysRoleDept{" + + ", id=" + id + + ", roleId=" + roleId + + ", deptId=" + deptId + + "}"; + } +} diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysRoleMenu.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysRoleMenu.java new file mode 100644 index 000000000..39b63750e --- /dev/null +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysRoleMenu.java @@ -0,0 +1,67 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.api.entity; + +import com.baomidou.mybatisplus.activerecord.Model; +import com.baomidou.mybatisplus.annotations.TableId; +import com.baomidou.mybatisplus.annotations.TableName; +import com.baomidou.mybatisplus.enums.IdType; +import lombok.Data; + +import java.io.Serializable; + +/** + *

+ * 角色菜单表 + *

+ * + * @author lengleng + * @since 2017-10-29 + */ +@Data +@TableName("sys_role_menu") +public class SysRoleMenu extends Model { + + private static final long serialVersionUID = 1L; + + /** + * 角色ID + */ + @TableId(type = IdType.INPUT) + private Integer roleId; + /** + * 菜单ID + */ + @TableId(type = IdType.INPUT) + private Integer menuId; + + @Override + protected Serializable pkVal() { + return this.roleId; + } + + @Override + public String toString() { + return "SysRoleMenu{" + + ", roleId=" + roleId + + ", menuId=" + menuId + + "}"; + } +} diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysUser.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysUser.java new file mode 100644 index 000000000..783c56dd1 --- /dev/null +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysUser.java @@ -0,0 +1,110 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.api.entity; + +import com.baomidou.mybatisplus.annotations.TableField; +import com.baomidou.mybatisplus.annotations.TableId; +import com.baomidou.mybatisplus.annotations.TableLogic; +import com.baomidou.mybatisplus.annotations.TableName; +import com.baomidou.mybatisplus.enums.IdType; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + *

+ * 用户表 + *

+ * + * @author lengleng + * @since 2017-10-29 + */ +@Data +@TableName("sys_user") +public class SysUser implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键ID + */ + @TableId(value = "user_id", type = IdType.AUTO) + private Integer userId; + /** + * 用户名 + */ + private String username; + + private String password; + /** + * 随机盐 + */ + @JsonIgnore + private String salt; + /** + * 创建时间 + */ + @TableField("create_time") + private Date createTime; + /** + * 修改时间 + */ + @TableField("update_time") + private Date updateTime; + /** + * 0-正常,1-删除 + */ + @TableLogic + @TableField("del_flag") + private String delFlag; + + /** + * 简介 + */ + private String phone; + /** + * 头像 + */ + private String avatar; + + /** + * 部门ID + */ + @TableField("dept_id") + private Integer deptId; + + @Override + public String toString() { + return "SysUser{" + + "userId=" + userId + + ", username='" + username + '\'' + + ", password='" + password + '\'' + + ", salt='" + salt + '\'' + + ", createTime=" + createTime + + ", updateTime=" + updateTime + + ", delFlag='" + delFlag + '\'' + + ", phone='" + phone + '\'' + + ", avatar='" + avatar + '\'' + + ", deptId=" + deptId + + '}'; + } +} diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysUserRole.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysUserRole.java new file mode 100644 index 000000000..2bd15f5f5 --- /dev/null +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysUserRole.java @@ -0,0 +1,68 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.api.entity; + +import com.baomidou.mybatisplus.activerecord.Model; +import com.baomidou.mybatisplus.annotations.TableId; +import com.baomidou.mybatisplus.annotations.TableName; +import com.baomidou.mybatisplus.enums.IdType; +import lombok.Data; + +import java.io.Serializable; + +/** + *

+ * 用户角色表 + *

+ * + * @author lengleng + * @since 2017-10-29 + */ +@Data +@TableName("sys_user_role") +public class SysUserRole extends Model { + + private static final long serialVersionUID = 1L; + + /** + * 用户ID + */ + @TableId(type = IdType.INPUT) + private Integer userId; + /** + * 角色ID + */ + @TableId(type = IdType.INPUT) + private Integer roleId; + + + @Override + protected Serializable pkVal() { + return this.userId; + } + + @Override + public String toString() { + return "SysUserRole{" + + ", userId=" + userId + + ", roleId=" + roleId + + "}"; + } +} diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysZuulRoute.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysZuulRoute.java new file mode 100644 index 000000000..5fec78581 --- /dev/null +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysZuulRoute.java @@ -0,0 +1,106 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.api.entity; + +import com.baomidou.mybatisplus.activerecord.Model; +import com.baomidou.mybatisplus.annotations.TableField; +import com.baomidou.mybatisplus.annotations.TableId; +import com.baomidou.mybatisplus.annotations.TableLogic; +import com.baomidou.mybatisplus.annotations.TableName; +import com.baomidou.mybatisplus.enums.IdType; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + *

+ * 动态路由配置表 + *

+ * + * @author lengleng + * @since 2018-05-15 + */ +@Data +@TableName("sys_zuul_route") +public class SysZuulRoute extends Model { + + private static final long serialVersionUID = 1L; + + /** + * router Id + */ + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + /** + * 路由路径 + */ + private String path; + /** + * 服务名称 + */ + @TableField("service_id") + private String serviceId; + /** + * url代理 + */ + private String url; + /** + * 转发去掉前缀 + */ + @TableField("strip_prefix") + private String stripPrefix; + /** + * 是否重试 + */ + private String retryable; + /** + * 是否启用 + */ + private String enabled; + /** + * 敏感请求头 + */ + @TableField("sensitiveHeaders_list") + private String sensitiveheadersList; + /** + * 创建时间 + */ + @TableField("create_time") + private Date createTime; + /** + * 更新时间 + */ + @TableField("update_time") + private Date updateTime; + /** + * 删除标识(0-正常,1-删除) + */ + @TableLogic + @TableField("del_flag") + private String delFlag; + + @Override + protected Serializable pkVal() { + return this.id; + } + + +} diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/RemoteLogService.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/RemoteLogService.java new file mode 100644 index 000000000..8ab824b01 --- /dev/null +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/RemoteLogService.java @@ -0,0 +1,44 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.api.feign; + +import com.pig4cloud.pigx.admin.api.entity.SysLog; +import com.pig4cloud.pigx.admin.api.feign.fallback.RemoteLogServiceFallbackImpl; +import com.pig4cloud.pigx.common.core.constant.ServiceNameConstant; +import com.pig4cloud.pigx.common.core.util.R; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +/** + * @author lengleng + * @date 2018/6/28 + */ +@FeignClient(value = ServiceNameConstant.UMPS_SERVICE, fallback = RemoteLogServiceFallbackImpl.class) +public interface RemoteLogService { + /** + * 保存日志 + * + * @param sysLog 日志实体 + * @return succes、false + */ + @PostMapping("/log") + R saveLog(@RequestBody SysLog sysLog); +} diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/RemoteUserService.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/RemoteUserService.java new file mode 100644 index 000000000..319dc394f --- /dev/null +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/RemoteUserService.java @@ -0,0 +1,47 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.api.feign; + +import com.pig4cloud.pigx.admin.api.dto.UserInfo; +import com.pig4cloud.pigx.admin.api.feign.fallback.RemoteUserServiceFallbackImpl; +import com.pig4cloud.pigx.common.core.constant.ServiceNameConstant; +import com.pig4cloud.pigx.common.core.util.R; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestHeader; + +/** + * @author lengleng + * @date 2018/6/22 + */ + @FeignClient(value = ServiceNameConstant.UMPS_SERVICE, fallback = RemoteUserServiceFallbackImpl.class) + public interface RemoteUserService { + /** + * 通过用户名查询用户、角色信息 + * + * @param username 用户名 + * @param from 调用标志 + * @return R + */ + @GetMapping("/user/info/{username}") + R info(@PathVariable("username") String username + , @RequestHeader("from") String from); + } diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/fallback/RemoteLogServiceFallbackImpl.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/fallback/RemoteLogServiceFallbackImpl.java new file mode 100644 index 000000000..722e0435d --- /dev/null +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/fallback/RemoteLogServiceFallbackImpl.java @@ -0,0 +1,47 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.api.feign.fallback; + +import com.pig4cloud.pigx.admin.api.entity.SysLog; +import com.pig4cloud.pigx.admin.api.feign.RemoteLogService; +import com.pig4cloud.pigx.common.core.util.R; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * @author lengleng + * @date 2018/6/26 + */ +@Slf4j +@Component +public class RemoteLogServiceFallbackImpl implements RemoteLogService { + + /** + * 保存日志 + * + * @param sysLog + * @return R + */ + @Override + public R saveLog(SysLog sysLog) { + log.error("feign 插入日志失败:{}"); + return null; + } +} diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/fallback/RemoteUserServiceFallbackImpl.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/fallback/RemoteUserServiceFallbackImpl.java new file mode 100644 index 000000000..900b354d0 --- /dev/null +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/fallback/RemoteUserServiceFallbackImpl.java @@ -0,0 +1,47 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.api.feign.fallback; + +import com.pig4cloud.pigx.admin.api.dto.UserInfo; +import com.pig4cloud.pigx.admin.api.feign.RemoteUserService; +import com.pig4cloud.pigx.common.core.util.R; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * @author lengleng + * @date 2018/6/26 + */ +@Slf4j +@Component +public class RemoteUserServiceFallbackImpl implements RemoteUserService { + /** + * 通过用户名查询用户、角色信息 + * + * @param username 用户名 + * @param from 内外标志 + * @return R + */ + @Override + public R info(String username, String from) { + log.error("feign 查询用户信息失败:{}", username); + return null; + } +} diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/ErrorPojo.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/ErrorPojo.java new file mode 100644 index 000000000..d26624f27 --- /dev/null +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/ErrorPojo.java @@ -0,0 +1,47 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.api.vo; + +import com.alibaba.fastjson.annotation.JSONField; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author lengleng + * @date 2017/12/25 + * spring boot 的异常对象 + */ +@Data +public class ErrorPojo implements Serializable { + + @JSONField(name = "timestamp") + private long timestamp; + @JSONField(name = "status") + private int status; + @JSONField(name = "error") + private String error; + @JSONField(name = "exception") + private String exception; + @JSONField(name = "message") + private String message; + @JSONField(name = "path") + private String path; +} diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/ImageCode.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/ImageCode.java new file mode 100644 index 000000000..433057729 --- /dev/null +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/ImageCode.java @@ -0,0 +1,46 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.api.vo; + +import lombok.Data; + +import java.awt.image.BufferedImage; +import java.io.Serializable; +import java.time.LocalDateTime; + + +/** + * @author lengleng + * @date 2017-12-18 + */ +@Data +public class ImageCode implements Serializable { + private String code; + + private LocalDateTime expireTime; + + private BufferedImage image; + + public ImageCode(BufferedImage image, String sRand, int defaultImageExpire) { + this.image = image; + this.code = sRand; + this.expireTime = LocalDateTime.now().plusSeconds(defaultImageExpire); + } +} diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/LogVO.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/LogVO.java new file mode 100644 index 000000000..fa49802c2 --- /dev/null +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/LogVO.java @@ -0,0 +1,37 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.api.vo; + +import com.pig4cloud.pigx.admin.api.entity.SysLog; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author lengleng + * @date 2017/11/20 + */ +@Data +public class LogVO implements Serializable { + private static final long serialVersionUID = 1L; + + private SysLog sysLog; + private String username; +} diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/MenuVO.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/MenuVO.java new file mode 100644 index 000000000..0a64a8da5 --- /dev/null +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/MenuVO.java @@ -0,0 +1,109 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.api.vo; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + *

+ * 菜单权限表 + *

+ * + * @author lengleng + * @since 2017-11-08 + */ +@Data +public class MenuVO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 菜单ID + */ + private Integer menuId; + /** + * 菜单名称 + */ + private String name; + /** + * 菜单权限标识 + */ + private String permission; + /** + * 父菜单ID + */ + private Integer parentId; + /** + * 图标 + */ + private String icon; + /** + * 一个路径 + */ + private String path; + /** + * VUE页面 + */ + private String component; + /** + * 排序值 + */ + private Integer sort; + /** + * 菜单类型 (0菜单 1按钮) + */ + private String type; + /** + * 创建时间 + */ + private Date createTime; + /** + * 更新时间 + */ + private Date updateTime; + /** + * 0--正常 1--删除 + */ + private String delFlag; + + + @Override + public int hashCode() { + return menuId.hashCode(); + } + + /** + * menuId 相同则相同 + * + * @param obj + * @return + */ + @Override + public boolean equals(Object obj) { + if (obj instanceof MenuVO) { + Integer targetMenuId = ((MenuVO) obj).getMenuId(); + return menuId.equals(targetMenuId); + } + return super.equals(obj); + } +} diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/TreeUtil.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/TreeUtil.java new file mode 100644 index 000000000..a695f5c27 --- /dev/null +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/TreeUtil.java @@ -0,0 +1,121 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.api.vo; + + +import com.pig4cloud.pigx.admin.api.dto.MenuTree; +import com.pig4cloud.pigx.admin.api.dto.TreeNode; +import com.pig4cloud.pigx.admin.api.entity.SysMenu; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author lengleng + * @date 2017年11月9日23:34:11 + */ +public class TreeUtil { + /** + * 两层循环实现建树 + * + * @param treeNodes 传入的树节点列表 + * @return + */ + public static List bulid(List treeNodes, Object root) { + + List trees = new ArrayList(); + + for (T treeNode : treeNodes) { + + if (root.equals(treeNode.getParentId())) { + trees.add(treeNode); + } + + for (T it : treeNodes) { + if (it.getParentId() == treeNode.getId()) { + if (treeNode.getChildren() == null) { + treeNode.setChildren(new ArrayList()); + } + treeNode.add(it); + } + } + } + return trees; + } + + /** + * 使用递归方法建树 + * + * @param treeNodes + * @return + */ + public static List buildByRecursive(List treeNodes, Object root) { + List trees = new ArrayList(); + for (T treeNode : treeNodes) { + if (root.equals(treeNode.getParentId())) { + trees.add(findChildren(treeNode, treeNodes)); + } + } + return trees; + } + + /** + * 递归查找子节点 + * + * @param treeNodes + * @return + */ + public static T findChildren(T treeNode, List treeNodes) { + for (T it : treeNodes) { + if (treeNode.getId() == it.getParentId()) { + if (treeNode.getChildren() == null) { + treeNode.setChildren(new ArrayList()); + } + treeNode.add(findChildren(it, treeNodes)); + } + } + return treeNode; + } + + /** + * 通过sysMenu创建树形节点 + * + * @param menus + * @param root + * @return + */ + public static List bulidTree(List menus, int root) { + List trees = new ArrayList(); + MenuTree node; + for (SysMenu menu : menus) { + node = new MenuTree(); + node.setId(menu.getMenuId()); + node.setParentId(menu.getParentId()); + node.setName(menu.getName()); + node.setPath(menu.getPath()); + node.setCode(menu.getPermission()); + node.setLabel(menu.getName()); + node.setComponent(menu.getComponent()); + node.setIcon(menu.getIcon()); + trees.add(node); + } + return TreeUtil.bulid(trees, root); + } +} diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/UserVO.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/UserVO.java new file mode 100644 index 000000000..fc1a82c3f --- /dev/null +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/UserVO.java @@ -0,0 +1,87 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.api.vo; + +import com.pig4cloud.pigx.admin.api.entity.SysRole; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +/** + * @author lengleng + * @date 2017/10/29 + */ +@Data +public class UserVO implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 主键ID + */ + private Integer userId; + /** + * 用户名 + */ + private String username; + /** + * 密码 + */ + private String password; + /** + * 随机盐 + */ + private String salt; + /** + * 创建时间 + */ + private Date createTime; + /** + * 修改时间 + */ + private Date updateTime; + /** + * 0-正常,1-删除 + */ + private String delFlag; + /** + * 简介 + */ + private String phone; + /** + * 头像 + */ + private String avatar; + + /** + * 部门ID + */ + private Integer deptId; + /** + * 部门名称 + */ + private String deptName; + + /** + * 角色列表 + */ + private List roleList; +} diff --git a/pigx-upms/pigx-upms-api/src/main/resources/META-INF/spring-devtools.properties b/pigx-upms/pigx-upms-api/src/main/resources/META-INF/spring-devtools.properties new file mode 100644 index 000000000..6ba6501f2 --- /dev/null +++ b/pigx-upms/pigx-upms-api/src/main/resources/META-INF/spring-devtools.properties @@ -0,0 +1 @@ +restart.include.pigx-upms-api=/pigx-upms-api[\\w-]+\.jar diff --git a/pigx-upms/pigx-upms-api/src/main/resources/META-INF/spring.factories b/pigx-upms/pigx-upms-api/src/main/resources/META-INF/spring.factories new file mode 100644 index 000000000..d11d4b57c --- /dev/null +++ b/pigx-upms/pigx-upms-api/src/main/resources/META-INF/spring.factories @@ -0,0 +1,3 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ + com.pig4cloud.pigx.admin.api.feign.fallback.RemoteUserServiceFallbackImpl,\ + com.pig4cloud.pigx.admin.api.feign.fallback.RemoteLogServiceFallbackImpl\ diff --git a/pigx-upms/pigx-upms-api/src/main/resources/META-INF/spring.provides b/pigx-upms/pigx-upms-api/src/main/resources/META-INF/spring.provides new file mode 100644 index 000000000..709c4b9bc --- /dev/null +++ b/pigx-upms/pigx-upms-api/src/main/resources/META-INF/spring.provides @@ -0,0 +1 @@ +provides: mybatis-plus-boot-starter, pigx-common-security diff --git a/pigx-upms/pigx-upms-biz/Dockerfile b/pigx-upms/pigx-upms-biz/Dockerfile new file mode 100644 index 000000000..7709e058f --- /dev/null +++ b/pigx-upms/pigx-upms-biz/Dockerfile @@ -0,0 +1,13 @@ +FROM anapsix/alpine-java:8_server-jre_unlimited + +MAINTAINER wangiegie@gmail.com + +RUN mkdir -p /pigx/bin/com.pig4cloud/pigx-upms + +WORKDIR /pigx/bin/com.pig4cloud/pigx-upms + +EXPOSE 1025 + +ADD ./pigx-upms/pigx-upms-biz/target/pigx-upms-biz.jar ./ + +CMD java -Djava.security.egd=file:/dev/./urandom -jar pigx-upms-biz.jar diff --git a/pigx-upms/pigx-upms-biz/pom.xml b/pigx-upms/pigx-upms-biz/pom.xml new file mode 100644 index 000000000..0f754dba0 --- /dev/null +++ b/pigx-upms/pigx-upms-biz/pom.xml @@ -0,0 +1,113 @@ + + + + + 4.0.0 + + com.pig4cloud + pigx-upms + ${pigx.version} + + + pigx-upms-biz + ${pigx.version} + jar + + pigx-upms-biz + pigx 通用用户权限管理系统业务处理模块 + + + + + com.pig4cloud + pigx-upms-api + ${pigx.version} + + + + com.pig4cloud + pigx-common-log + ${pigx.version} + + + + com.pig4cloud + pigx-common-swagger + ${pigx.version} + + + + org.springframework.cloud + spring-cloud-starter-netflix-eureka-client + + + + org.springframework.cloud + spring-cloud-starter-config + + + + org.springframework.cloud + spring-cloud-starter-security + + + + de.codecentric + spring-boot-admin-starter-client + ${monitor.version} + + + + mysql + mysql-connector-java + + + + org.springframework.boot + spring-boot-starter-web + + + + spring-boot-starter-tomcat + org.springframework.boot + + + + + + org.springframework.boot + spring-boot-starter-undertow + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + ${project.name} + + + + + + diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/PigxAdminApplication.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/PigxAdminApplication.java new file mode 100644 index 000000000..6fe57204f --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/PigxAdminApplication.java @@ -0,0 +1,40 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin; + + +import com.pig4cloud.pigx.common.swagger.annotation.EnablePigxSwagger2; +import org.springframework.boot.SpringApplication; +import org.springframework.cloud.client.SpringCloudApplication; +import org.springframework.cloud.openfeign.EnableFeignClients; + +/** + * @author lengleng + * @date 2018年06月21日 + * 用户统一管理系统 + */ +@EnablePigxSwagger2 +@EnableFeignClients +@SpringCloudApplication +public class PigxAdminApplication { + public static void main(String[] args) { + SpringApplication.run(PigxAdminApplication.class, args); + } +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/config/MybatisPlusConfigurer.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/config/MybatisPlusConfigurer.java new file mode 100644 index 000000000..9fd5436b4 --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/config/MybatisPlusConfigurer.java @@ -0,0 +1,43 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.config; + +import com.baomidou.mybatisplus.plugins.PaginationInterceptor; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * @author lengleng + * @date 2017/10/29 + */ +@Configuration +@MapperScan("com.pig4cloud.pigx.admin.mapper") +public class MybatisPlusConfigurer { + /** + * 分页插件 + * + * @return PaginationInterceptor + */ + @Bean + public PaginationInterceptor paginationInterceptor() { + return new PaginationInterceptor(); + } +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/config/ResourceServerConfigurer.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/config/ResourceServerConfigurer.java new file mode 100644 index 000000000..eaa1d9aad --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/config/ResourceServerConfigurer.java @@ -0,0 +1,64 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.config; + +import com.pig4cloud.pigx.common.security.compoent.PigAccessDeniedHandler; +import com.pig4cloud.pigx.common.security.compoent.ResourceAuthExceptionEntryPoint; +import lombok.AllArgsConstructor; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer; +import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter; +import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer; + +/** + * @author lengleng + * @date 2018/6/22 + */ +@Configuration +@EnableResourceServer +@AllArgsConstructor +@EnableGlobalMethodSecurity(prePostEnabled = true) +public class ResourceServerConfigurer extends ResourceServerConfigurerAdapter { + private final PigAccessDeniedHandler pigAccessDeniedHandler; + private final ResourceAuthExceptionEntryPoint resourceAuthExceptionEntryPoint; + + @Override + public void configure(HttpSecurity http) throws Exception { + http.authorizeRequests() + .antMatchers("/actuator/**", "/user/info/*", "/log/**","/v2/api-docs").permitAll() + .anyRequest().authenticated() + .and().csrf().disable(); + } + + /** + * why add resourceId + * https://stackoverflow.com/questions/28703847/how-do-you-set-a-resource-id-for-a-token + * + * @param resources + * @throws Exception + */ + @Override + public void configure(ResourceServerSecurityConfigurer resources) throws Exception { + resources.authenticationEntryPoint(resourceAuthExceptionEntryPoint) + .accessDeniedHandler(pigAccessDeniedHandler); + } +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/DeptController.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/DeptController.java new file mode 100644 index 000000000..115266c1d --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/DeptController.java @@ -0,0 +1,109 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.controller; + +import com.baomidou.mybatisplus.mapper.EntityWrapper; +import com.pig4cloud.pigx.admin.api.dto.DeptTree; +import com.pig4cloud.pigx.admin.api.entity.SysDept; +import com.pig4cloud.pigx.admin.service.SysDeptService; +import com.pig4cloud.pigx.common.core.constant.CommonConstant; +import com.pig4cloud.pigx.common.core.util.R; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.Date; +import java.util.List; + +/** + *

+ * 部门管理 前端控制器 + *

+ * + * @author lengleng + * @since 2018-01-20 + */ +@RestController +@RequestMapping("/dept") +public class DeptController { + @Autowired + private SysDeptService sysDeptService; + + /** + * 通过ID查询 + * + * @param id ID + * @return SysDept + */ + @GetMapping("/{id}") + public SysDept get(@PathVariable Integer id) { + return sysDeptService.selectById(id); + } + + + /** + * 返回树形菜单集合 + * + * @return 树形菜单 + */ + @GetMapping(value = "/tree") + public List getTree() { + SysDept condition = new SysDept(); + condition.setDelFlag(CommonConstant.STATUS_NORMAL); + return sysDeptService.selectListTree(new EntityWrapper<>(condition)); + } + + /** + * 添加 + * + * @param sysDept 实体 + * @return success/false + */ + @PostMapping + @PreAuthorize("@pms.hasPermission('sys_dept_add')") + public R add(@RequestBody SysDept sysDept) { + return new R<>(sysDeptService.insertDept(sysDept)); + } + + /** + * 删除 + * + * @param id ID + * @return success/false + */ + @DeleteMapping("/{id}") + @PreAuthorize("@pms.hasPermission('sys_dept_del')") + public R delete(@PathVariable Integer id) { + return new R<>(sysDeptService.deleteDeptById(id)); + } + + /** + * 编辑 + * + * @param sysDept 实体 + * @return success/false + */ + @PutMapping + @PreAuthorize("@pms.hasPermission('sys_dept_edit')") + public Boolean edit(@RequestBody SysDept sysDept) { + sysDept.setUpdateTime(new Date()); + return sysDeptService.updateDeptById(sysDept); + } +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/DictController.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/DictController.java new file mode 100644 index 000000000..4d0d1d93d --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/DictController.java @@ -0,0 +1,134 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.controller; + + +import com.baomidou.mybatisplus.mapper.EntityWrapper; +import com.baomidou.mybatisplus.plugins.Page; +import com.pig4cloud.pigx.admin.api.dto.Query; +import com.pig4cloud.pigx.admin.api.entity.SysDict; +import com.pig4cloud.pigx.admin.service.SysDictService; +import com.pig4cloud.pigx.common.core.constant.CommonConstant; +import com.pig4cloud.pigx.common.core.util.R; +import com.pig4cloud.pigx.common.log.annotation.SysLog; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.cache.annotation.Cacheable; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Map; + +/** + *

+ * 字典表 前端控制器 + *

+ * + * @author lengleng + * @since 2017-11-19 + */ +@RestController +@RequestMapping("/dict") +public class DictController { + @Autowired + private SysDictService sysDictService; + + /** + * 通过ID查询字典信息 + * + * @param id ID + * @return 字典信息 + */ + @GetMapping("/{id}") + public SysDict dict(@PathVariable Integer id) { + return sysDictService.selectById(id); + } + + /** + * 分页查询字典信息 + * + * @param params 分页对象 + * @return 分页对象 + */ + @RequestMapping("/dictPage") + public Page dictPage(@RequestParam Map params) { + params.put(CommonConstant.DEL_FLAG, CommonConstant.STATUS_NORMAL); + return sysDictService.selectPage(new Query<>(params), new EntityWrapper<>()); + } + + /** + * 通过字典类型查找字典 + * + * @param type 类型 + * @return 同类型字典 + */ + @GetMapping("/type/{type}") + @Cacheable(value = "dict_details", key = "#type") + public List findDictByType(@PathVariable String type) { + SysDict condition = new SysDict(); + condition.setDelFlag(CommonConstant.STATUS_NORMAL); + condition.setType(type); + return sysDictService.selectList(new EntityWrapper<>(condition)); + } + + /** + * 添加字典 + * + * @param sysDict 字典信息 + * @return success、false + */ + @SysLog("添加字典") + @PostMapping + @CacheEvict(value = "dict_details", key = "#sysDict.type") + @PreAuthorize("@pms.hasPermission('sys_dict_add')") + public R dict(@RequestBody SysDict sysDict) { + return new R<>(sysDictService.insert(sysDict)); + } + + /** + * 删除字典,并且清除字典缓存 + * + * @param id ID + * @param type 类型 + * @return R + */ + @SysLog("删除字典") + @DeleteMapping("/{id}/{type}") + @CacheEvict(value = "dict_details", key = "#type") + @PreAuthorize("@pms.hasPermission('sys_dict_del')") + public R deleteDict(@PathVariable Integer id, @PathVariable String type) { + return new R<>(sysDictService.deleteById(id)); + } + + /** + * 修改字典 + * + * @param sysDict 字典信息 + * @return success/false + */ + @PutMapping + @SysLog("修改字典") + @CacheEvict(value = "dict_details", key = "#sysDict.type") + @PreAuthorize("@pms.hasPermission('sys_dict_edit')") + public R editDict(@RequestBody SysDict sysDict) { + return new R<>(sysDictService.updateById(sysDict)); + } +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/LogController.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/LogController.java new file mode 100644 index 000000000..cbb0efd37 --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/LogController.java @@ -0,0 +1,84 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.controller; + + +import com.baomidou.mybatisplus.mapper.EntityWrapper; +import com.baomidou.mybatisplus.plugins.Page; +import com.pig4cloud.pigx.admin.api.dto.Query; +import com.pig4cloud.pigx.admin.api.entity.SysLog; +import com.pig4cloud.pigx.admin.service.SysLogService; +import com.pig4cloud.pigx.common.core.constant.CommonConstant; +import com.pig4cloud.pigx.common.core.util.R; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + +/** + *

+ * 日志表 前端控制器 + *

+ * + * @author lengleng + * @since 2017-11-20 + */ +@RestController +@RequestMapping("/log") +public class LogController { + @Autowired + private SysLogService sysLogService; + + /** + * 分页查询日志信息 + * + * @param params 分页对象 + * @return 分页对象 + */ + @RequestMapping("/logPage") + public Page logPage(@RequestParam Map params) { + params.put(CommonConstant.DEL_FLAG, CommonConstant.STATUS_NORMAL); + return sysLogService.selectPage(new Query<>(params), new EntityWrapper<>()); + } + + /** + * 根据ID + * + * @param id ID + * @return success/false + */ + @DeleteMapping("/{id}") + @PreAuthorize("@pms.hasPermission('sys_log_del')") + public R delete(@PathVariable Long id) { + return new R<>(sysLogService.updateByLogId(id)); + } + + /** + * 插入日志 + * + * @param sysLog 日志实体 + * @return success/false + */ + @PostMapping + public R save(@RequestBody SysLog sysLog) { + return new R<>(sysLogService.insert(sysLog)); + } +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/MenuController.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/MenuController.java new file mode 100644 index 000000000..6799a3d5e --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/MenuController.java @@ -0,0 +1,149 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.controller; + +import cn.hutool.core.collection.CollUtil; +import com.baomidou.mybatisplus.mapper.EntityWrapper; +import com.pig4cloud.pigx.admin.api.dto.MenuTree; +import com.pig4cloud.pigx.admin.api.entity.SysMenu; +import com.pig4cloud.pigx.admin.api.vo.MenuVO; +import com.pig4cloud.pigx.admin.api.vo.TreeUtil; +import com.pig4cloud.pigx.admin.service.SysMenuService; +import com.pig4cloud.pigx.common.core.constant.CommonConstant; +import com.pig4cloud.pigx.common.core.util.R; +import com.pig4cloud.pigx.common.security.util.SecurityUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.*; + +/** + * @author lengleng + * @date 2017/10/31 + */ +@RestController +@RequestMapping("/menu") +public class MenuController { + @Autowired + private SysMenuService sysMenuService; + + /** + * 通过角色名称查询用户菜单 + * + * @param role 角色名称 + * @return 菜单列表 + */ + @GetMapping("/findMenuByRole/{role}") + public List findMenuByRole(@PathVariable String role) { + return sysMenuService.findMenuByRoleCode(role); + } + + /** + * 返回当前用户的树形菜单集合 + * + * @return 当前用户的树形菜单 + */ + @GetMapping(value = "/userMenu") + public List userMenu() { + // 获取符合条件得菜单 + Set all = new HashSet<>(); + SecurityUtils.getRoles().forEach(roleName -> all.addAll(sysMenuService.findMenuByRoleCode(roleName))); + List menuTreeList = new ArrayList<>(); + all.forEach(menuVo -> { + if (CommonConstant.MENU.equals(menuVo.getType())) { + menuTreeList.add(new MenuTree(menuVo)); + } + }); + CollUtil.sort(menuTreeList, Comparator.comparingInt(MenuTree::getSort)); + return TreeUtil.bulid(menuTreeList, -1); + } + + /** + * 返回树形菜单集合 + * + * @return 树形菜单 + */ + @GetMapping(value = "/allTree") + public List getTree() { + SysMenu condition = new SysMenu(); + condition.setDelFlag(CommonConstant.STATUS_NORMAL); + return TreeUtil.bulidTree(sysMenuService.selectList(new EntityWrapper<>(condition)), -1); + } + + /** + * 返回角色的菜单集合 + * + * @param roleName 角色名称 + * @return 属性集合 + */ + @GetMapping("/roleTree/{roleName}") + public List roleTree(@PathVariable String roleName) { + List menus = sysMenuService.findMenuByRoleCode(roleName); + List menuList = new ArrayList<>(); + for (MenuVO menuVo : menus) { + menuList.add(menuVo.getMenuId()); + } + return menuList; + } + + /** + * 通过ID查询菜单的详细信息 + * + * @param id 菜单ID + * @return 菜单详细信息 + */ + @GetMapping("/{id}") + public SysMenu menu(@PathVariable Integer id) { + return sysMenuService.selectById(id); + } + + /** + * 新增菜单 + * + * @param sysMenu 菜单信息 + * @return success/false + */ + @PostMapping + @PreAuthorize("@pms.hasPermission('sys_menu_add')") + public R menu(@RequestBody SysMenu sysMenu) { + return new R<>(sysMenuService.insert(sysMenu)); + } + + /** + * 删除菜单 + * + * @param id 菜单ID + * @return success/false + * TODO 级联删除下级节点 + */ + @DeleteMapping("/{id}") + @PreAuthorize("@pms.hasPermission('sys_menu_del')") + public R menuDel(@PathVariable Integer id) { + return new R<>(sysMenuService.deleteMenu(id)); + } + + @PutMapping + @PreAuthorize("@pms.hasPermission('sys_menu_edit')") + public R menuUpdate(@RequestBody SysMenu sysMenu) { + return new R<>(sysMenuService.updateMenuById(sysMenu)); + } + +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/OauthClientDetailsController.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/OauthClientDetailsController.java new file mode 100644 index 000000000..ffc040c00 --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/OauthClientDetailsController.java @@ -0,0 +1,108 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.controller; + +import com.baomidou.mybatisplus.mapper.EntityWrapper; +import com.baomidou.mybatisplus.plugins.Page; +import com.pig4cloud.pigx.admin.api.dto.Query; +import com.pig4cloud.pigx.admin.api.entity.SysOauthClientDetails; +import com.pig4cloud.pigx.admin.service.SysOauthClientDetailsService; +import com.pig4cloud.pigx.common.core.util.R; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + +/** + *

+ * 前端控制器 + *

+ * + * @author lengleng + * @since 2018-05-15 + */ +@RestController +@RequestMapping("/client") +public class OauthClientDetailsController { + @Autowired + private SysOauthClientDetailsService sysOauthClientDetailsService; + + /** + * 通过ID查询 + * + * @param id ID + * @return SysOauthClientDetails + */ + @GetMapping("/{id}") + public SysOauthClientDetails get(@PathVariable Integer id) { + return sysOauthClientDetailsService.selectById(id); + } + + + /** + * 分页查询信息 + * + * @param params 分页对象 + * @return 分页对象 + */ + @RequestMapping("/page") + public Page page(@RequestParam Map params) { + return sysOauthClientDetailsService.selectPage(new Query<>(params), new EntityWrapper<>()); + } + + /** + * 添加 + * + * @param sysOauthClientDetails 实体 + * @return success/false + */ + @PostMapping + @PreAuthorize("@pms.hasPermission('sys_client_add')") + public R add(@RequestBody SysOauthClientDetails sysOauthClientDetails) { + return new R<>(sysOauthClientDetailsService.insert(sysOauthClientDetails)); + } + + /** + * 删除 + * + * @param id ID + * @return success/false + */ + @DeleteMapping("/{id}") + @PreAuthorize("@pms.hasPermission('sys_client_del')") + public R delete(@PathVariable String id) { + SysOauthClientDetails sysOauthClientDetails = new SysOauthClientDetails(); + sysOauthClientDetails.setClientId(id); + return new R<>(sysOauthClientDetailsService.deleteById(sysOauthClientDetails)); + } + + /** + * 编辑 + * + * @param sysOauthClientDetails 实体 + * @return success/false + */ + @PutMapping + @PreAuthorize("@pms.hasPermission('sys_client_edit')") + public R edit(@RequestBody SysOauthClientDetails sysOauthClientDetails) { + return new R<>(sysOauthClientDetailsService.updateById(sysOauthClientDetails)); + } +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/RoleController.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/RoleController.java new file mode 100644 index 000000000..f0d49681c --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/RoleController.java @@ -0,0 +1,130 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.controller; + +import com.baomidou.mybatisplus.mapper.EntityWrapper; +import com.baomidou.mybatisplus.plugins.Page; +import com.pig4cloud.pigx.admin.api.dto.Query; +import com.pig4cloud.pigx.admin.api.dto.RoleDTO; +import com.pig4cloud.pigx.admin.api.entity.SysRole; +import com.pig4cloud.pigx.admin.service.SysRoleMenuService; +import com.pig4cloud.pigx.admin.service.SysRoleService; +import com.pig4cloud.pigx.common.core.constant.CommonConstant; +import com.pig4cloud.pigx.common.core.util.R; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Map; + +/** + * @author lengleng + * @date 2017/11/5 + */ +@RestController +@RequestMapping("/role") +public class RoleController { + @Autowired + private SysRoleService sysRoleService; + @Autowired + private SysRoleMenuService sysRoleMenuService; + + /** + * 通过ID查询角色信息 + * + * @param id ID + * @return 角色信息 + */ + @GetMapping("/{id}") + public SysRole role(@PathVariable Integer id) { + return sysRoleService.selectById(id); + } + + /** + * 添加角色 + * + * @param roleDto 角色信息 + * @return success、false + */ + @PostMapping + @PreAuthorize("@pms.hasPermission('sys_role_add')") + public R role(@RequestBody RoleDTO roleDto) { + return new R<>(sysRoleService.insertRole(roleDto)); + } + + /** + * 修改角色 + * + * @param roleDto 角色信息 + * @return success/false + */ + @PutMapping + @PreAuthorize("@pms.hasPermission('sys_role_edit')") + public R roleUpdate(@RequestBody RoleDTO roleDto) { + return new R<>(sysRoleService.updateRoleById(roleDto)); + } + + @DeleteMapping("/{id}") + @PreAuthorize("@pms.hasPermission('sys_role_del')") + public R roleDel(@PathVariable Integer id) { + SysRole sysRole = sysRoleService.selectById(id); + sysRole.setDelFlag(CommonConstant.STATUS_DEL); + return new R<>(sysRoleService.updateById(sysRole)); + } + + /** + * 获取角色列表 + * + * @param deptId 部门ID + * @return 角色列表 + */ + @GetMapping("/roleList/{deptId}") + public List roleList(@PathVariable Integer deptId) { + return sysRoleService.selectListByDeptId(deptId); + + } + + /** + * 分页查询角色信息 + * + * @param params 分页对象 + * @return 分页对象 + */ + @RequestMapping("/rolePage") + public Page rolePage(@RequestParam Map params) { + params.put(CommonConstant.DEL_FLAG, CommonConstant.STATUS_NORMAL); + return sysRoleService.selectwithDeptPage(new Query<>(params), new EntityWrapper<>()); + } + + /** + * 更新角色菜单 + * + * @param roleId 角色ID + * @param menuIds 菜单结合 + * @return success、false + */ + @PutMapping("/roleMenuUpd") + @PreAuthorize("@pms.hasPermission('sys_role_perm')") + public R roleMenuUpd(Integer roleId, @RequestParam("menuIds[]") Integer[] menuIds) { + SysRole sysRole = sysRoleService.selectById(roleId); + return new R<>(sysRoleMenuService.insertRoleMenus(sysRole.getRoleCode(), roleId, menuIds)); + } +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/UserController.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/UserController.java new file mode 100644 index 000000000..52883b095 --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/UserController.java @@ -0,0 +1,167 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.controller; + +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.plugins.Page; +import com.pig4cloud.pigx.admin.api.dto.Query; +import com.pig4cloud.pigx.admin.api.dto.UserDTO; +import com.pig4cloud.pigx.admin.api.dto.UserInfo; +import com.pig4cloud.pigx.admin.api.entity.SysUser; +import com.pig4cloud.pigx.admin.api.entity.SysUserRole; +import com.pig4cloud.pigx.admin.api.vo.UserVO; +import com.pig4cloud.pigx.admin.service.SysUserService; +import com.pig4cloud.pigx.common.core.constant.CommonConstant; +import com.pig4cloud.pigx.common.core.constant.SecurityConstants; +import com.pig4cloud.pigx.common.core.util.R; +import com.pig4cloud.pigx.common.log.annotation.SysLog; +import com.pig4cloud.pigx.common.security.util.SecurityUtils; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.security.crypto.password.PasswordEncoder; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + +/** + * @author lengleng + * @date 2017/10/28 + */ +@RestController +@RequestMapping("/user") +public class UserController { + private static final PasswordEncoder ENCODER = new BCryptPasswordEncoder(); + @Autowired + private SysUserService userService; + + /** + * 获取当前用户信息(角色、权限) + * 并且异步初始化用户部门信息 + * + * @param from 请求标志,该接口会被 auth、 前端调用 + * @param username 用户名 + * @return 用户名 + */ + @GetMapping(value = {"/info", "/info/{username}"}) + public R user(@PathVariable(required = false) String username, + @RequestHeader(required = false) String from) { + // 查询用户不为空时判断是不是内部请求 + if (StrUtil.isNotBlank(username) && !StrUtil.equals(SecurityConstants.FROM_IN, from)) { + return new R<>(null, "error"); + } + //为空时查询当前用户 + if (StrUtil.isBlank(username)) { + username = SecurityUtils.getUser(); + } + + return new R<>(userService.findUserInfo(username)); + } + + /** + * 通过ID查询当前用户信息 + * + * @param id ID + * @return 用户信息 + */ + @GetMapping("/{id}") + public UserVO user(@PathVariable Integer id) { + return userService.selectUserVoById(id); + } + + /** + * 删除用户信息 + * + * @param id ID + * @return R + */ + @SysLog("删除用户信息") + @DeleteMapping("/{id}") + @PreAuthorize("@pms.hasPermission('sys_user_del')") + @ApiOperation(value = "删除用户", notes = "根据ID删除用户") + @ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "int", paramType = "path",example = "1000") + public R userDel(@PathVariable Integer id) { + SysUser sysUser = userService.selectById(id); + return new R<>(userService.deleteUserById(sysUser)); + } + + /** + * 添加用户 + * + * @param userDto 用户信息 + * @return success/false + */ + @SysLog("添加用户") + @PostMapping + @PreAuthorize("@pms.hasPermission('sys_user_add')") + public R user(@RequestBody UserDTO userDto) { + SysUser sysUser = new SysUser(); + BeanUtils.copyProperties(userDto, sysUser); + sysUser.setDelFlag(CommonConstant.STATUS_NORMAL); + sysUser.setPassword(ENCODER.encode(userDto.getNewpassword1())); + userService.insert(sysUser); + + userDto.getRole().forEach(roleId -> { + SysUserRole userRole = new SysUserRole(); + userRole.setUserId(sysUser.getUserId()); + userRole.setRoleId(roleId); + userRole.insert(); + }); + return new R<>(Boolean.TRUE); + } + + /** + * 更新用户信息 + * + * @param userDto 用户信息 + * @return R + */ + @PutMapping + @PreAuthorize("@pms.hasPermission('sys_user_edit')") + public R userUpdate(@RequestBody UserDTO userDto) { + SysUser user = userService.selectById(userDto.getUserId()); + return new R<>(userService.updateUser(userDto, user.getUsername())); + } + + /** + * 分页查询用户 + * + * @param params 参数集 + * @return 用户集合 + */ + @RequestMapping("/userPage") + public Page userPage(@RequestParam Map params) { + return userService.selectWithRolePage(new Query(params)); + } + + /** + * 修改个人信息 + * + * @param userDto userDto + * @return success/false + */ + @PutMapping("/editInfo") + public R editInfo(@RequestBody UserDTO userDto) { + return userService.updateUserInfo(userDto, SecurityUtils.getUser()); + } +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDeptMapper.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDeptMapper.java new file mode 100644 index 000000000..9f7b12ff4 --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDeptMapper.java @@ -0,0 +1,51 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.mapper; + +import com.baomidou.mybatisplus.mapper.BaseMapper; +import com.pig4cloud.pigx.admin.api.entity.SysDept; + +import java.util.List; + +/** + *

+ * 部门管理 Mapper 接口 + *

+ * + * @author lengleng + * @since 2018-01-20 + */ +public interface SysDeptMapper extends BaseMapper { + + /** + * 关联dept——relation + * + * @param delFlag 删除标记 + * @return 数据列表 + */ + List selectDeptDtoList(String delFlag); + + /** + * 删除部门关系表数据 + * + * @param id 部门ID + */ + void deleteDeptRealtion(Integer id); +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDeptRelationMapper.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDeptRelationMapper.java new file mode 100644 index 000000000..069c66bc4 --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDeptRelationMapper.java @@ -0,0 +1,35 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.mapper; + +import com.baomidou.mybatisplus.mapper.BaseMapper; +import com.pig4cloud.pigx.admin.api.entity.SysDeptRelation; + +/** + *

+ * Mapper 接口 + *

+ * + * @author lengleng + * @since 2018-02-12 + */ +public interface SysDeptRelationMapper extends BaseMapper { + +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDictMapper.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDictMapper.java new file mode 100644 index 000000000..20c9c9c82 --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysDictMapper.java @@ -0,0 +1,35 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.mapper; + +import com.baomidou.mybatisplus.mapper.BaseMapper; +import com.pig4cloud.pigx.admin.api.entity.SysDict; + +/** + *

+ * 字典表 Mapper 接口 + *

+ * + * @author lengleng + * @since 2017-11-19 + */ +public interface SysDictMapper extends BaseMapper { + +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysLogMapper.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysLogMapper.java new file mode 100644 index 000000000..c248310a4 --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysLogMapper.java @@ -0,0 +1,35 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.mapper; + +import com.baomidou.mybatisplus.mapper.BaseMapper; +import com.pig4cloud.pigx.admin.api.entity.SysLog; + +/** + *

+ * 日志表 Mapper 接口 + *

+ * + * @author lengleng + * @since 2017-11-20 + */ +public interface SysLogMapper extends BaseMapper { + +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysMenuMapper.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysMenuMapper.java new file mode 100644 index 000000000..5304ebca7 --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysMenuMapper.java @@ -0,0 +1,53 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.mapper; + +import com.baomidou.mybatisplus.mapper.BaseMapper; +import com.pig4cloud.pigx.admin.api.entity.SysMenu; +import com.pig4cloud.pigx.admin.api.vo.MenuVO; + +import java.util.List; + +/** + *

+ * 菜单权限表 Mapper 接口 + *

+ * + * @author lengleng + * @since 2017-10-29 + */ +public interface SysMenuMapper extends BaseMapper { + + /** + * 通过角色编号查询菜单 + * + * @param role 角色编号 + * @return + */ + List findMenuByRoleCode(String role); + + /** + * 通过角色ID查询权限 + * + * @param roleIds Ids + * @return + */ + List findPermissionsByRoleIds(String roleIds); +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysOauthClientDetailsMapper.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysOauthClientDetailsMapper.java new file mode 100644 index 000000000..0baffe4b3 --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysOauthClientDetailsMapper.java @@ -0,0 +1,36 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.mapper; + + +import com.baomidou.mybatisplus.mapper.BaseMapper; +import com.pig4cloud.pigx.admin.api.entity.SysOauthClientDetails; + +/** + *

+ * Mapper 接口 + *

+ * + * @author lengleng + * @since 2018-05-15 + */ +public interface SysOauthClientDetailsMapper extends BaseMapper { + +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysRoleDeptMapper.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysRoleDeptMapper.java new file mode 100644 index 000000000..3ed3d6892 --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysRoleDeptMapper.java @@ -0,0 +1,35 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.mapper; + +import com.baomidou.mybatisplus.mapper.BaseMapper; +import com.pig4cloud.pigx.admin.api.entity.SysRoleDept; + +/** + *

+ * 角色与部门对应关系 Mapper 接口 + *

+ * + * @author lengleng + * @since 2018-01-20 + */ +public interface SysRoleDeptMapper extends BaseMapper { + +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysRoleMapper.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysRoleMapper.java new file mode 100644 index 000000000..36ed59c7c --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysRoleMapper.java @@ -0,0 +1,63 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.mapper; + +import com.baomidou.mybatisplus.mapper.BaseMapper; +import com.pig4cloud.pigx.admin.api.dto.Query; +import com.pig4cloud.pigx.admin.api.entity.SysRole; + +import java.util.List; +import java.util.Map; + +/** + *

+ * Mapper 接口 + *

+ * + * @author lengleng + * @since 2017-10-29 + */ +public interface SysRoleMapper extends BaseMapper { + + /** + * 查询角色列表含有部门信息 + * + * @param query 查询对象 + * @param condition 条件 + * @return List + */ + List selectRolePage(Query query, Map condition); + + /** + * 通过部门ID查询角色列表 + * + * @param deptId 部门ID + * @return 角色列表 + */ + List selectListByDeptId(Integer deptId); + + /** + * 通过用户ID,查询角色信息 + * + * @param userId + * @return + */ + List findRolesByUserId(Integer userId); +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysRoleMenuMapper.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysRoleMenuMapper.java new file mode 100644 index 000000000..0843d7b08 --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysRoleMenuMapper.java @@ -0,0 +1,36 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.mapper; + + +import com.baomidou.mybatisplus.mapper.BaseMapper; +import com.pig4cloud.pigx.admin.api.entity.SysRoleMenu; + +/** + *

+ * 角色菜单表 Mapper 接口 + *

+ * + * @author lengleng + * @since 2017-10-29 + */ +public interface SysRoleMenuMapper extends BaseMapper { + +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysUserMapper.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysUserMapper.java new file mode 100644 index 000000000..72a477535 --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysUserMapper.java @@ -0,0 +1,64 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.mapper; + +import com.baomidou.mybatisplus.mapper.BaseMapper; +import com.pig4cloud.pigx.admin.api.dto.Query; +import com.pig4cloud.pigx.admin.api.entity.SysUser; +import com.pig4cloud.pigx.admin.api.vo.UserVO; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + *

+ * 用户表 Mapper 接口 + *

+ * + * @author lengleng + * @since 2017-10-29 + */ +public interface SysUserMapper extends BaseMapper { + /** + * 通过用户名查询用户信息(含有角色信息) + * + * @param username 用户名 + * @return userVo + */ + UserVO selectUserVoByUsername(String username); + + /** + * 分页查询用户信息(含角色) + * + * @param query 查询条件 + * @param username 用户名 + * @return list + */ + List selectUserVoPage(Query query, @Param("username") Object username); + + /** + * 通过ID查询用户信息 + * + * @param id 用户ID + * @return userVo + */ + UserVO selectUserVoById(Integer id); + +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysUserRoleMapper.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysUserRoleMapper.java new file mode 100644 index 000000000..71d9ec14e --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysUserRoleMapper.java @@ -0,0 +1,45 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.mapper; + + +import com.baomidou.mybatisplus.mapper.BaseMapper; +import com.pig4cloud.pigx.admin.api.entity.SysUserRole; +import org.apache.ibatis.annotations.Param; + +/** + *

+ * 用户角色表 Mapper 接口 + *

+ * + * @author lengleng + * @since 2017-10-29 + */ +public interface SysUserRoleMapper extends BaseMapper { + /** + * 根据用户Id删除该用户的角色关系 + * + * @param userId 用户ID + * @return boolean + * @author 寻欢·李 + * @date 2017年12月7日 16:31:38 + */ + Boolean deleteByUserId(@Param("userId") Integer userId); +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysDeptRelationService.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysDeptRelationService.java new file mode 100644 index 000000000..4c839b76b --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysDeptRelationService.java @@ -0,0 +1,35 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.service; + +import com.baomidou.mybatisplus.service.IService; +import com.pig4cloud.pigx.admin.api.entity.SysDeptRelation; + +/** + *

+ * 服务类 + *

+ * + * @author lengleng + * @since 2018-02-12 + */ +public interface SysDeptRelationService extends IService { + +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysDeptService.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysDeptService.java new file mode 100644 index 000000000..2be8923e1 --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysDeptService.java @@ -0,0 +1,70 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.service; + +import com.baomidou.mybatisplus.mapper.EntityWrapper; +import com.baomidou.mybatisplus.service.IService; +import com.pig4cloud.pigx.admin.api.dto.DeptTree; +import com.pig4cloud.pigx.admin.api.entity.SysDept; + +import java.util.List; + +/** + *

+ * 部门管理 服务类 + *

+ * + * @author lengleng + * @since 2018-01-20 + */ +public interface SysDeptService extends IService { + + /** + * 查询部门树菜单 + * + * @param sysDeptEntityWrapper + * @return 树 + */ + List selectListTree(EntityWrapper sysDeptEntityWrapper); + + /** + * 添加信息部门 + * + * @param sysDept + * @return + */ + Boolean insertDept(SysDept sysDept); + + /** + * 删除部门 + * + * @param id 部门 ID + * @return 成功、失败 + */ + Boolean deleteDeptById(Integer id); + + /** + * 更新部门 + * + * @param sysDept 部门信息 + * @return 成功、失败 + */ + Boolean updateDeptById(SysDept sysDept); +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysDictService.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysDictService.java new file mode 100644 index 000000000..e5a5b3ff5 --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysDictService.java @@ -0,0 +1,35 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.service; + +import com.baomidou.mybatisplus.service.IService; +import com.pig4cloud.pigx.admin.api.entity.SysDict; + +/** + *

+ * 字典表 服务类 + *

+ * + * @author lengleng + * @since 2017-11-19 + */ +public interface SysDictService extends IService { + +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysLogService.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysLogService.java new file mode 100644 index 000000000..8e0e88f3c --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysLogService.java @@ -0,0 +1,42 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.service; + +import com.baomidou.mybatisplus.service.IService; +import com.pig4cloud.pigx.admin.api.entity.SysLog; + +/** + *

+ * 日志表 服务类 + *

+ * + * @author lengleng + * @since 2017-11-20 + */ +public interface SysLogService extends IService { + + /** + * 通过ID删除日志(逻辑删除) + * + * @param id 日志ID + * @return true/false + */ + Boolean updateByLogId(Long id); +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysMenuService.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysMenuService.java new file mode 100644 index 000000000..3800947a7 --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysMenuService.java @@ -0,0 +1,61 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.service; + + +import com.baomidou.mybatisplus.service.IService; +import com.pig4cloud.pigx.admin.api.entity.SysMenu; +import com.pig4cloud.pigx.admin.api.vo.MenuVO; + +import java.util.List; + +/** + *

+ * 菜单权限表 服务类 + *

+ * + * @author lengleng + * @since 2017-10-29 + */ +public interface SysMenuService extends IService { + /** + * 通过角色编号查询URL 权限 + * + * @param role 角色编号 + * @return 菜单列表 + */ + List findMenuByRoleCode(String role); + + /** + * 级联删除菜单 + * + * @param id 菜单ID + * @return 成功、失败 + */ + Boolean deleteMenu(Integer id); + + /** + * 更新菜单信息 + * + * @param sysMenu 菜单信息 + * @return 成功、失败 + */ + Boolean updateMenuById(SysMenu sysMenu); +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysOauthClientDetailsService.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysOauthClientDetailsService.java new file mode 100644 index 000000000..0e1aaf999 --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysOauthClientDetailsService.java @@ -0,0 +1,35 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.service; + +import com.baomidou.mybatisplus.service.IService; +import com.pig4cloud.pigx.admin.api.entity.SysOauthClientDetails; + +/** + *

+ * 服务类 + *

+ * + * @author lengleng + * @since 2018-05-15 + */ +public interface SysOauthClientDetailsService extends IService { + +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysRoleDeptService.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysRoleDeptService.java new file mode 100644 index 000000000..9c0a1eb62 --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysRoleDeptService.java @@ -0,0 +1,35 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.service; + +import com.baomidou.mybatisplus.service.IService; +import com.pig4cloud.pigx.admin.api.entity.SysRoleDept; + +/** + *

+ * 角色与部门对应关系 服务类 + *

+ * + * @author lengleng + * @since 2018-01-20 + */ +public interface SysRoleDeptService extends IService { + +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysRoleMenuService.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysRoleMenuService.java new file mode 100644 index 000000000..acf41d0fa --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysRoleMenuService.java @@ -0,0 +1,45 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.service; + + +import com.baomidou.mybatisplus.service.IService; +import com.pig4cloud.pigx.admin.api.entity.SysRoleMenu; + +/** + *

+ * 角色菜单表 服务类 + *

+ * + * @author lengleng + * @since 2017-10-29 + */ +public interface SysRoleMenuService extends IService { + + /** + * 更新角色菜单 + * + * @param role + * @param roleId 角色 + * @param menuIds 菜单列表 + * @return + */ + Boolean insertRoleMenus(String role, Integer roleId, Integer[] menuIds); +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysRoleService.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysRoleService.java new file mode 100644 index 000000000..95e320467 --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysRoleService.java @@ -0,0 +1,81 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.service; + +import com.baomidou.mybatisplus.mapper.EntityWrapper; +import com.baomidou.mybatisplus.plugins.Page; +import com.baomidou.mybatisplus.service.IService; +import com.pig4cloud.pigx.admin.api.dto.Query; +import com.pig4cloud.pigx.admin.api.dto.RoleDTO; +import com.pig4cloud.pigx.admin.api.entity.SysRole; + +import java.util.List; + +/** + *

+ * 服务类 + *

+ * + * @author lengleng + * @since 2017-10-29 + */ +public interface SysRoleService extends IService { + + /** + * 添加角色 + * + * @param roleDto 角色信息 + * @return 成功、失败 + */ + Boolean insertRole(RoleDTO roleDto); + + /** + * 分页查角色列表 + * + * @param objectQuery 查询条件 + * @param objectEntityWrapper wapper + * @return page + */ + Page selectwithDeptPage(Query objectQuery, EntityWrapper objectEntityWrapper); + + /** + * 更新角色 + * + * @param roleDto 含有部门信息 + * @return 成功、失败 + */ + Boolean updateRoleById(RoleDTO roleDto); + + /** + * 通过部门ID查询角色列表 + * + * @param deptId 部门ID + * @return 角色列表 + */ + List selectListByDeptId(Integer deptId); + + /** + * 通过用户ID,查询角色信息 + * + * @param userId + * @return + */ + List findRolesByUserId(Integer userId); +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysUserRoleService.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysUserRoleService.java new file mode 100644 index 000000000..5bba86ee0 --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysUserRoleService.java @@ -0,0 +1,45 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.service; + + +import com.baomidou.mybatisplus.service.IService; +import com.pig4cloud.pigx.admin.api.entity.SysUserRole; + +/** + *

+ * 用户角色表 服务类 + *

+ * + * @author lengleng + * @since 2017-10-29 + */ +public interface SysUserRoleService extends IService { + + /** + * 根据用户Id删除该用户的角色关系 + * + * @param userId 用户ID + * @return boolean + * @author 寻欢·李 + * @date 2017年12月7日 16:31:38 + */ + Boolean deleteByUserId(Integer userId); +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysUserService.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysUserService.java new file mode 100644 index 000000000..435ed7a69 --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysUserService.java @@ -0,0 +1,85 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.service; + +import com.baomidou.mybatisplus.plugins.Page; +import com.baomidou.mybatisplus.service.IService; +import com.pig4cloud.pigx.admin.api.dto.Query; +import com.pig4cloud.pigx.admin.api.dto.UserDTO; +import com.pig4cloud.pigx.admin.api.dto.UserInfo; +import com.pig4cloud.pigx.admin.api.entity.SysUser; +import com.pig4cloud.pigx.admin.api.vo.UserVO; +import com.pig4cloud.pigx.common.core.util.R; + +/** + * @author lengleng + * @date 2017/10/31 + */ +public interface SysUserService extends IService { + /** + * 查询用户信息 + * + * @param username 用户名 + * @return userInfo + */ + UserInfo findUserInfo(String username); + + /** + * 分页查询用户信息(含有角色信息) + * + * @param query 查询条件 + * @return + */ + Page selectWithRolePage(Query query); + + /** + * 删除用户 + * + * @param sysUser 用户 + * @return boolean + */ + Boolean deleteUserById(SysUser sysUser); + + /** + * 更新当前用户基本信息 + * + * @param userDto 用户信息 + * @param username 用户名 + * @return Boolean + */ + R updateUserInfo(UserDTO userDto, String username); + + /** + * 更新指定用户信息 + * + * @param userDto 用户信息 + * @param username 用户信息 + * @return + */ + Boolean updateUser(UserDTO userDto, String username); + + /** + * 通过ID查询用户信息 + * + * @param id 用户ID + * @return 用户信息 + */ + UserVO selectUserVoById(Integer id); +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysDeptRelationServiceImpl.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysDeptRelationServiceImpl.java new file mode 100644 index 000000000..0390c698e --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysDeptRelationServiceImpl.java @@ -0,0 +1,39 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.service.impl; + +import com.baomidou.mybatisplus.service.impl.ServiceImpl; +import com.pig4cloud.pigx.admin.api.entity.SysDeptRelation; +import com.pig4cloud.pigx.admin.mapper.SysDeptRelationMapper; +import com.pig4cloud.pigx.admin.service.SysDeptRelationService; +import org.springframework.stereotype.Service; + +/** + *

+ * 服务实现类 + *

+ * + * @author lengleng + * @since 2018-02-12 + */ +@Service +public class SysDeptRelationServiceImpl extends ServiceImpl implements SysDeptRelationService { + +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysDeptServiceImpl.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysDeptServiceImpl.java new file mode 100644 index 000000000..e42c229ae --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysDeptServiceImpl.java @@ -0,0 +1,160 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.service.impl; + +import com.baomidou.mybatisplus.mapper.EntityWrapper; +import com.baomidou.mybatisplus.service.impl.ServiceImpl; +import com.pig4cloud.pigx.admin.api.dto.DeptTree; +import com.pig4cloud.pigx.admin.api.entity.SysDept; +import com.pig4cloud.pigx.admin.api.entity.SysDeptRelation; +import com.pig4cloud.pigx.admin.api.vo.TreeUtil; +import com.pig4cloud.pigx.admin.mapper.SysDeptMapper; +import com.pig4cloud.pigx.admin.mapper.SysDeptRelationMapper; +import com.pig4cloud.pigx.admin.service.SysDeptService; +import com.pig4cloud.pigx.common.core.constant.CommonConstant; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + *

+ * 部门管理 服务实现类 + *

+ * + * @author lengleng + * @since 2018-01-20 + */ +@Service +public class SysDeptServiceImpl extends ServiceImpl implements SysDeptService { + @Autowired + private SysDeptMapper sysDeptMapper; + @Autowired + private SysDeptRelationMapper sysDeptRelationMapper; + + /** + * 添加信息部门 + * + * @param dept 部门 + * @return + */ + @Override + public Boolean insertDept(SysDept dept) { + SysDept sysDept = new SysDept(); + BeanUtils.copyProperties(dept, sysDept); + this.insert(sysDept); + this.insertDeptRelation(sysDept); + return Boolean.TRUE; + } + + /** + * 维护部门关系 + * + * @param sysDept 部门 + */ + private void insertDeptRelation(SysDept sysDept) { + //增加部门关系表 + SysDeptRelation deptRelation = new SysDeptRelation(); + deptRelation.setDescendant(sysDept.getParentId()); + List deptRelationList = sysDeptRelationMapper.selectList(new EntityWrapper<>(deptRelation)); + for (SysDeptRelation sysDeptRelation : deptRelationList) { + sysDeptRelation.setDescendant(sysDept.getDeptId()); + sysDeptRelationMapper.insert(sysDeptRelation); + } + //自己也要维护到关系表中 + SysDeptRelation own = new SysDeptRelation(); + own.setDescendant(sysDept.getDeptId()); + own.setAncestor(sysDept.getDeptId()); + sysDeptRelationMapper.insert(own); + } + + /** + * 删除部门 + * + * @param id 部门 ID + * @return 成功、失败 + */ + @Override + public Boolean deleteDeptById(Integer id) { + SysDept sysDept = new SysDept(); + sysDept.setDeptId(id); + sysDept.setUpdateTime(new Date()); + sysDept.setDelFlag(CommonConstant.STATUS_DEL); + this.deleteById(sysDept); + sysDeptMapper.deleteDeptRealtion(id); + return Boolean.TRUE; + } + + /** + * 更新部门 + * + * @param sysDept 部门信息 + * @return 成功、失败 + */ + @Override + public Boolean updateDeptById(SysDept sysDept) { + //更新部门状态 + this.updateById(sysDept); + //删除部门关系 + sysDeptMapper.deleteDeptRealtion(sysDept.getDeptId()); + //新建部门关系 + this.insertDeptRelation(sysDept); + return Boolean.TRUE; + } + + /** + * 查询部门树 + * + * @param sysDeptEntityWrapper + * @return 树 + */ + @Override + public List selectListTree(EntityWrapper sysDeptEntityWrapper) { + sysDeptEntityWrapper.orderBy("order_num", false); + return getDeptTree(this.selectList(sysDeptEntityWrapper), 0); + } + + + /** + * 构建部门树 + * + * @param depts 部门 + * @param root 根节点 + * @return + */ + private List getDeptTree(List depts, int root) { + List trees = new ArrayList<>(); + DeptTree node; + for (SysDept dept : depts) { + if (dept.getParentId().equals(dept.getDeptId())) { + continue; + } + node = new DeptTree(); + node.setId(dept.getDeptId()); + node.setParentId(dept.getParentId()); + node.setName(dept.getName()); + trees.add(node); + } + return TreeUtil.bulid(trees, root); + } +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysDictServiceImpl.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysDictServiceImpl.java new file mode 100644 index 000000000..39519cbad --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysDictServiceImpl.java @@ -0,0 +1,39 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.service.impl; + +import com.baomidou.mybatisplus.service.impl.ServiceImpl; +import com.pig4cloud.pigx.admin.api.entity.SysDict; +import com.pig4cloud.pigx.admin.mapper.SysDictMapper; +import com.pig4cloud.pigx.admin.service.SysDictService; +import org.springframework.stereotype.Service; + +/** + *

+ * 字典表 服务实现类 + *

+ * + * @author lengleng + * @since 2017-11-19 + */ +@Service +public class SysDictServiceImpl extends ServiceImpl implements SysDictService { + +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysLogServiceImpl.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysLogServiceImpl.java new file mode 100644 index 000000000..d3b126a57 --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysLogServiceImpl.java @@ -0,0 +1,51 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.service.impl; + +import com.baomidou.mybatisplus.service.impl.ServiceImpl; +import com.pig4cloud.pigx.admin.api.entity.SysLog; +import com.pig4cloud.pigx.admin.mapper.SysLogMapper; +import com.pig4cloud.pigx.admin.service.SysLogService; +import com.pig4cloud.pigx.common.core.constant.CommonConstant; +import org.springframework.stereotype.Service; + +import java.util.Date; + +/** + *

+ * 日志表 服务实现类 + *

+ * + * @author lengleng + * @since 2017-11-20 + */ +@Service +public class SysLogServiceImpl extends ServiceImpl implements SysLogService { + + @Override + public Boolean updateByLogId(Long id) { + + SysLog sysLog = new SysLog(); + sysLog.setId(id); + sysLog.setDelFlag(CommonConstant.STATUS_DEL); + sysLog.setUpdateTime(new Date()); + return updateById(sysLog); + } +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysMenuServiceImpl.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysMenuServiceImpl.java new file mode 100644 index 000000000..1f8c322d5 --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysMenuServiceImpl.java @@ -0,0 +1,78 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.service.impl; + +import cn.hutool.core.collection.CollUtil; +import com.baomidou.mybatisplus.mapper.EntityWrapper; +import com.baomidou.mybatisplus.service.impl.ServiceImpl; +import com.pig4cloud.pigx.admin.api.entity.SysMenu; +import com.pig4cloud.pigx.admin.api.vo.MenuVO; +import com.pig4cloud.pigx.admin.mapper.SysMenuMapper; +import com.pig4cloud.pigx.admin.service.SysMenuService; +import com.pig4cloud.pigx.common.core.constant.CommonConstant; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.cache.annotation.Cacheable; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + *

+ * 菜单权限表 服务实现类 + *

+ * + * @author lengleng + * @since 2017-10-29 + */ +@Service +public class SysMenuServiceImpl extends ServiceImpl implements SysMenuService { + @Autowired + private SysMenuMapper sysMenuMapper; + + @Override + @Cacheable(value = "menu_details", key = "#role + '_menu'") + public List findMenuByRoleCode(String role) { + return sysMenuMapper.findMenuByRoleCode(role); + } + + @Override + @CacheEvict(value = "menu_details", allEntries = true) + public Boolean deleteMenu(Integer id) { + // 删除当前节点 + SysMenu condition1 = new SysMenu(); + condition1.setMenuId(id); + condition1.setDelFlag(CommonConstant.STATUS_DEL); + this.updateById(condition1); + + // 删除父节点为当前节点的节点 + SysMenu conditon2 = new SysMenu(); + conditon2.setParentId(id); + SysMenu sysMenu = new SysMenu(); + sysMenu.setDelFlag(CommonConstant.STATUS_DEL); + return this.update(sysMenu, new EntityWrapper<>(conditon2)); + } + + @Override + @CacheEvict(value = "menu_details", allEntries = true) + public Boolean updateMenuById(SysMenu sysMenu) { + return this.updateById(sysMenu); + } +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysOauthClientDetailsServiceImpl.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysOauthClientDetailsServiceImpl.java new file mode 100644 index 000000000..7ed8a5280 --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysOauthClientDetailsServiceImpl.java @@ -0,0 +1,39 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.service.impl; + +import com.baomidou.mybatisplus.service.impl.ServiceImpl; +import com.pig4cloud.pigx.admin.api.entity.SysOauthClientDetails; +import com.pig4cloud.pigx.admin.mapper.SysOauthClientDetailsMapper; +import com.pig4cloud.pigx.admin.service.SysOauthClientDetailsService; +import org.springframework.stereotype.Service; + +/** + *

+ * 服务实现类 + *

+ * + * @author lengleng + * @since 2018-05-15 + */ +@Service +public class SysOauthClientDetailsServiceImpl extends ServiceImpl implements SysOauthClientDetailsService { + +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysRoleDeptServiceImpl.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysRoleDeptServiceImpl.java new file mode 100644 index 000000000..82620024e --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysRoleDeptServiceImpl.java @@ -0,0 +1,39 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.service.impl; + +import com.baomidou.mybatisplus.service.impl.ServiceImpl; +import com.pig4cloud.pigx.admin.api.entity.SysRoleDept; +import com.pig4cloud.pigx.admin.mapper.SysRoleDeptMapper; +import com.pig4cloud.pigx.admin.service.SysRoleDeptService; +import org.springframework.stereotype.Service; + +/** + *

+ * 角色与部门对应关系 服务实现类 + *

+ * + * @author lengleng + * @since 2018-01-20 + */ +@Service +public class SysRoleDeptServiceImpl extends ServiceImpl implements SysRoleDeptService { + +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysRoleMenuServiceImpl.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysRoleMenuServiceImpl.java new file mode 100644 index 000000000..0363aadda --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysRoleMenuServiceImpl.java @@ -0,0 +1,59 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.service.impl; + +import com.baomidou.mybatisplus.mapper.EntityWrapper; +import com.baomidou.mybatisplus.service.impl.ServiceImpl; +import com.pig4cloud.pigx.admin.api.entity.SysRoleMenu; +import com.pig4cloud.pigx.admin.mapper.SysRoleMenuMapper; +import com.pig4cloud.pigx.admin.service.SysRoleMenuService; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +/** + *

+ * 角色菜单表 服务实现类 + *

+ * + * @author lengleng + * @since 2017-10-29 + */ +@Service +public class SysRoleMenuServiceImpl extends ServiceImpl implements SysRoleMenuService { + @Override + @CacheEvict(value = "menu_details", key = "#role + '_menu'") + public Boolean insertRoleMenus(String role, Integer roleId, Integer[] menuIds) { + SysRoleMenu condition = new SysRoleMenu(); + condition.setRoleId(roleId); + this.delete(new EntityWrapper<>(condition)); + + List roleMenuList = new ArrayList<>(); + for (Integer menuId : menuIds) { + SysRoleMenu roleMenu = new SysRoleMenu(); + roleMenu.setRoleId(roleId); + roleMenu.setMenuId(menuId); + roleMenuList.add(roleMenu); + } + return this.insertBatch(roleMenuList); + } +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysRoleServiceImpl.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysRoleServiceImpl.java new file mode 100644 index 000000000..dd82ea0da --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysRoleServiceImpl.java @@ -0,0 +1,133 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.service.impl; + +import com.baomidou.mybatisplus.mapper.EntityWrapper; +import com.baomidou.mybatisplus.plugins.Page; +import com.baomidou.mybatisplus.service.impl.ServiceImpl; +import com.pig4cloud.pigx.admin.api.dto.Query; +import com.pig4cloud.pigx.admin.api.dto.RoleDTO; +import com.pig4cloud.pigx.admin.api.entity.SysRole; +import com.pig4cloud.pigx.admin.api.entity.SysRoleDept; +import com.pig4cloud.pigx.admin.mapper.SysRoleDeptMapper; +import com.pig4cloud.pigx.admin.mapper.SysRoleMapper; +import com.pig4cloud.pigx.admin.service.SysRoleService; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +/** + *

+ * 服务实现类 + *

+ * + * @author lengleng + * @since 2017-10-29 + */ +@Service +public class SysRoleServiceImpl extends ServiceImpl implements SysRoleService { + @Autowired + private SysRoleDeptMapper sysRoleDeptMapper; + @Autowired + private SysRoleMapper sysRoleMapper; + + /** + * 添加角色 + * + * @param roleDto 角色信息 + * @return 成功、失败 + */ + @Override + public Boolean insertRole(RoleDTO roleDto) { + SysRole sysRole = new SysRole(); + BeanUtils.copyProperties(roleDto, sysRole); + sysRoleMapper.insert(sysRole); + SysRoleDept roleDept = new SysRoleDept(); + roleDept.setRoleId(sysRole.getRoleId()); + roleDept.setDeptId(roleDto.getRoleDeptId()); + sysRoleDeptMapper.insert(roleDept); + return true; + } + + /** + * 分页查角色列表 + * + * @param query 查询条件 + * @param wrapper wapper + * @return page + */ + @Override + public Page selectwithDeptPage(Query query, EntityWrapper wrapper) { + query.setRecords(sysRoleMapper.selectRolePage(query, query.getCondition())); + return query; + } + + /** + * 更新角色 + * + * @param roleDto 含有部门信息 + * @return 成功、失败 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public Boolean updateRoleById(RoleDTO roleDto) { + //删除原有的角色部门关系 + SysRoleDept condition = new SysRoleDept(); + condition.setRoleId(roleDto.getRoleId()); + sysRoleDeptMapper.delete(new EntityWrapper<>(condition)); + + //更新角色信息 + SysRole sysRole = new SysRole(); + BeanUtils.copyProperties(roleDto, sysRole); + sysRoleMapper.updateById(sysRole); + + //维护角色部门关系 + SysRoleDept roleDept = new SysRoleDept(); + roleDept.setRoleId(sysRole.getRoleId()); + roleDept.setDeptId(roleDto.getRoleDeptId()); + sysRoleDeptMapper.insert(roleDept); + return true; + } + + /** + * 通过部门ID查询角色列表 + * + * @param deptId 部门ID + * @return 角色列表 + */ + @Override + public List selectListByDeptId(Integer deptId) { + return sysRoleMapper.selectListByDeptId(deptId); + } + + /** + * 通过用户ID,查询角色信息 + * + * @param userId + * @return + */ + @Override + public List findRolesByUserId(Integer userId) { + return sysRoleMapper.findRolesByUserId(userId); + } +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysUserRoleServiceImpl.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysUserRoleServiceImpl.java new file mode 100644 index 000000000..648d3e66e --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysUserRoleServiceImpl.java @@ -0,0 +1,51 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.service.impl; + +import com.baomidou.mybatisplus.service.impl.ServiceImpl; +import com.pig4cloud.pigx.admin.api.entity.SysUserRole; +import com.pig4cloud.pigx.admin.mapper.SysUserRoleMapper; +import com.pig4cloud.pigx.admin.service.SysUserRoleService; +import org.springframework.stereotype.Service; + +/** + *

+ * 用户角色表 服务实现类 + *

+ * + * @author lengleng + * @since 2017-10-29 + */ +@Service +public class SysUserRoleServiceImpl extends ServiceImpl implements SysUserRoleService { + + /** + * 根据用户Id删除该用户的角色关系 + * + * @param userId 用户ID + * @return boolean + * @author 寻欢·李 + * @date 2017年12月7日 16:31:38 + */ + @Override + public Boolean deleteByUserId(Integer userId) { + return baseMapper.deleteByUserId(userId); + } +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysUserServiceImpl.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysUserServiceImpl.java new file mode 100644 index 000000000..4751f98b5 --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysUserServiceImpl.java @@ -0,0 +1,185 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.admin.service.impl; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ArrayUtil; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.mapper.EntityWrapper; +import com.baomidou.mybatisplus.plugins.Page; +import com.baomidou.mybatisplus.service.impl.ServiceImpl; +import com.pig4cloud.pigx.admin.api.dto.Query; +import com.pig4cloud.pigx.admin.api.dto.UserDTO; +import com.pig4cloud.pigx.admin.api.dto.UserInfo; +import com.pig4cloud.pigx.admin.api.entity.SysRole; +import com.pig4cloud.pigx.admin.api.entity.SysUser; +import com.pig4cloud.pigx.admin.api.entity.SysUserRole; +import com.pig4cloud.pigx.admin.api.vo.MenuVO; +import com.pig4cloud.pigx.admin.api.vo.UserVO; +import com.pig4cloud.pigx.admin.mapper.SysUserMapper; +import com.pig4cloud.pigx.admin.service.SysMenuService; +import com.pig4cloud.pigx.admin.service.SysRoleService; +import com.pig4cloud.pigx.admin.service.SysUserRoleService; +import com.pig4cloud.pigx.admin.service.SysUserService; +import com.pig4cloud.pigx.common.core.util.R; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.cache.annotation.Cacheable; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.security.crypto.password.PasswordEncoder; +import org.springframework.stereotype.Service; + +import java.util.*; + +/** + * @author lengleng + * @date 2017/10/31 + */ +@Slf4j +@Service +public class SysUserServiceImpl extends ServiceImpl implements SysUserService { + private static final PasswordEncoder ENCODER = new BCryptPasswordEncoder(); + @Autowired + private SysMenuService sysMenuService; + @Autowired + private SysUserMapper sysUserMapper; + @Autowired + private SysRoleService sysRoleService; + @Autowired + private SysUserRoleService sysUserRoleService; + + /** + * 通过用户名查用户的全部信息 + * + * @param username 用户名 + * @return + */ + @Override + @Cacheable(value = "user_details", key = "#username") + public UserInfo findUserInfo(String username) { + SysUser condition = new SysUser(); + condition.setUsername(username); + SysUser sysUser = this.selectOne(new EntityWrapper<>(condition)); + if (sysUser == null) { + return null; + } + + UserInfo userInfo = new UserInfo(); + userInfo.setSysUser(sysUser); + //设置角色列表 + List roleList = sysRoleService.findRolesByUserId(sysUser.getUserId()); + List roleCodes = new ArrayList<>(); + if (CollUtil.isNotEmpty(roleList)) { + roleList.forEach(sysRole -> roleCodes.add(sysRole.getRoleCode())); + } + userInfo.setRoles(ArrayUtil.toArray(roleCodes, String.class)); + + //设置权限列表(menu.permission) + Set menuVoSet = new HashSet<>(); + for (String role : roleCodes) { + List menuVos = sysMenuService.findMenuByRoleCode(role); + menuVoSet.addAll(menuVos); + } + Set permissions = new HashSet<>(); + for (MenuVO menuVo : menuVoSet) { + if (StringUtils.isNotEmpty(menuVo.getPermission())) { + String permission = menuVo.getPermission(); + permissions.add(permission); + } + } + userInfo.setPermissions(ArrayUtil.toArray(permissions, String.class)); + return userInfo; + } + + @Override + public Page selectWithRolePage(Query query) { + Object username = query.getCondition().get("username"); + query.setRecords(sysUserMapper.selectUserVoPage(query, username)); + return query; + } + + /** + * 通过ID查询用户信息 + * + * @param id 用户ID + * @return 用户信息 + */ + @Override + public UserVO selectUserVoById(Integer id) { + return sysUserMapper.selectUserVoById(id); + } + + /** + * 删除用户 + * + * @param sysUser 用户 + * @return Boolean + */ + @Override + @CacheEvict(value = "user_details", key = "#sysUser.username") + public Boolean deleteUserById(SysUser sysUser) { + sysUserRoleService.deleteByUserId(sysUser.getUserId()); + this.deleteById(sysUser.getUserId()); + return Boolean.TRUE; + } + + @Override + @CacheEvict(value = "user_details", key = "#username") + public R updateUserInfo(UserDTO userDto, String username) { + UserVO userVO = sysUserMapper.selectUserVoByUsername(username); + SysUser sysUser = new SysUser(); + if (StrUtil.isNotBlank(userDto.getPassword()) + && StrUtil.isNotBlank(userDto.getNewpassword1())) { + if (ENCODER.matches(userDto.getPassword(), userVO.getPassword())) { + sysUser.setPassword(ENCODER.encode(userDto.getNewpassword1())); + } else { + log.warn("原密码错误,修改密码失败:{}", username); + return new R<>(Boolean.FALSE, "原密码错误,修改失败"); + } + } + sysUser.setPhone(userDto.getPhone()); + sysUser.setUserId(userVO.getUserId()); + sysUser.setAvatar(userDto.getAvatar()); + return new R<>(this.updateById(sysUser)); + } + + @Override + @CacheEvict(value = "user_details", key = "#username") + public Boolean updateUser(UserDTO userDto, String username) { + SysUser sysUser = new SysUser(); + BeanUtils.copyProperties(userDto, sysUser); + sysUser.setUpdateTime(new Date()); + this.updateById(sysUser); + + SysUserRole condition = new SysUserRole(); + condition.setUserId(userDto.getUserId()); + sysUserRoleService.delete(new EntityWrapper<>(condition)); + userDto.getRole().forEach(roleId -> { + SysUserRole userRole = new SysUserRole(); + userRole.setUserId(sysUser.getUserId()); + userRole.setRoleId(roleId); + userRole.insert(); + }); + return Boolean.TRUE; + } +} diff --git a/pigx-upms/pigx-upms-biz/src/main/resources/bootstrap.yml b/pigx-upms/pigx-upms-biz/src/main/resources/bootstrap.yml new file mode 100644 index 000000000..1dbe02882 --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/resources/bootstrap.yml @@ -0,0 +1,26 @@ +server: + port: 4000 + +spring: + application: + name: pigx-upms + # dev环境 + profiles: + active: dev + # 配置中心 + cloud: + config: + fail-fast: true + name: ${spring.application.name} + profile: ${spring.profiles.active} + discovery: + enabled: true + service-id: pigx-config + +# 注册中心配置 +eureka: + instance: + prefer-ip-address: true + client: + service-url: + defaultZone: http://pig:pig@localhost:1025/eureka/ diff --git a/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysDeptMapper.xml b/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysDeptMapper.xml new file mode 100644 index 000000000..fdd683274 --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysDeptMapper.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + dept_id AS deptId, parent_id AS parentId, name, order_num AS orderNum, create_time AS createTime, update_time AS updateTime, del_flag AS delFlag + + + DELETE + FROM + sys_dept_relation + WHERE + descendant IN ( + SELECT + temp.descendant + FROM + ( + SELECT + descendant + FROM + sys_dept_relation + WHERE + ancestor = #{id} + ) temp + ) + + + + + diff --git a/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysDeptRelationMapper.xml b/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysDeptRelationMapper.xml new file mode 100644 index 000000000..d18d3d1e6 --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysDeptRelationMapper.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + ancestor, descendant + + + diff --git a/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysDictMapper.xml b/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysDictMapper.xml new file mode 100644 index 000000000..99029776c --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysDictMapper.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + id, value, label, type, description, sort, create_time AS createTime, update_time AS updateTime, remarks, del_flag AS delFlag + + + diff --git a/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysLogMapper.xml b/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysLogMapper.xml new file mode 100644 index 000000000..01c09d98e --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysLogMapper.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + id, type, title, create_by AS createBy, create_time AS createTime, update_time AS updateTime, remote_addr AS remoteAddr, user_agent AS userAgent, request_uri AS requestUri, method, params, `time`, del_flag AS delFlag + + + diff --git a/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysMenuMapper.xml b/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysMenuMapper.xml new file mode 100644 index 000000000..9eb4f10d3 --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysMenuMapper.xml @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysOauthClientDetailsMapper.xml b/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysOauthClientDetailsMapper.xml new file mode 100644 index 000000000..54fd10e9d --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysOauthClientDetailsMapper.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + client_id AS clientId, resource_ids AS resourceIds, client_secret AS clientSecret, scope, authorized_grant_types AS authorizedGrantTypes, web_server_redirect_uri AS webServerRedirectUri, authorities, access_token_validity AS accessTokenValidity, refresh_token_validity AS refreshTokenValidity, additional_information AS additionalInformation, autoapprove + + + diff --git a/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysRoleDeptMapper.xml b/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysRoleDeptMapper.xml new file mode 100644 index 000000000..a93f88536 --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysRoleDeptMapper.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + id, role_id AS roleId, dept_id AS deptId + + + diff --git a/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysRoleMapper.xml b/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysRoleMapper.xml new file mode 100644 index 000000000..7c61430b7 --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysRoleMapper.xml @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysRoleMenuMapper.xml b/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysRoleMenuMapper.xml new file mode 100644 index 000000000..9e3589622 --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysRoleMenuMapper.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + diff --git a/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysUserMapper.xml b/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysUserMapper.xml new file mode 100644 index 000000000..c5e43b771 --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysUserMapper.xml @@ -0,0 +1,150 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SELECT + `user`.user_id, + `user`.username, + `user`.`password`, + `user`.salt, + `user`.phone, + `user`.avatar, + `user`.dept_id, + `user`.create_time AS ucreate_time, + `user`.update_time AS uupdate_time, + `user`.del_flag AS udel_flag, + `user`.dept_id AS deptId, + r.role_id, + r.role_name, + r.role_code, + r.role_desc, + r.create_time AS rcreate_time, + r.update_time AS rupdate_time + FROM + sys_user AS `user` + LEFT JOIN sys_user_role AS ur ON ur.user_id = `user`.user_id + LEFT JOIN sys_role AS r ON r.role_id = ur.role_id + + + + + + + + + diff --git a/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysUserRoleMapper.xml b/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysUserRoleMapper.xml new file mode 100644 index 000000000..1777eeeac --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysUserRoleMapper.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + DELETE FROM sys_user_role WHERE user_id = #{userId} + + + diff --git a/pigx-upms/pom.xml b/pigx-upms/pom.xml new file mode 100644 index 000000000..2c0504f54 --- /dev/null +++ b/pigx-upms/pom.xml @@ -0,0 +1,40 @@ + + + + + 4.0.0 + + com.pig4cloud + pigx + ${pigx.version} + + + pigx-upms + ${pigx.version} + pigx-upms + pigx 通用用户权限管理聚合模块 + pom + + + pigx-upms-api + pigx-upms-biz + + diff --git a/pom.xml b/pom.xml new file mode 100644 index 000000000..468452106 --- /dev/null +++ b/pom.xml @@ -0,0 +1,174 @@ + + + + + 4.0.0 + + com.pig4cloud + pigx + ${pigx.version} + pigx + pom + https://www.pig4cloud.com + + + org.springframework.boot + spring-boot-starter-parent + 2.0.3.RELEASE + + + + + 1.2.3 + 2.0.3.RELEASE + Finchley.RELEASE + UTF-8 + 1.8 + 1.8 + 1.16.20 + 2.0.1 + 4.0.4 + 2.3 + 1.2.47 + 0.0.9 + 2.9.2 + 2.3.3.RELEASE + + + + + + org.springframework.cloud + spring-cloud-starter-netflix-eureka-client + + + + org.springframework.boot + spring-boot-configuration-processor + true + + + + org.springframework.boot + spring-boot-starter-actuator + + + + de.codecentric + spring-boot-admin-starter-client + ${monitor.version} + + + + org.springframework.cloud + spring-cloud-starter-netflix-hystrix + + + + org.projectlombok + lombok + ${lombok.version} + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + pigx-eureka + pigx-config + pigx-gateway + pigx-auth + pigx-upms + pigx-common + pigx-monitor + + + + + + io.spring.platform + platform-bom + Cairo-SR2 + pom + import + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring-boot.version} + + + + build-info + + + + + + maven-compiler-plugin + + ${java.version} + ${java.version} + UTF-8 + + + + + + + pl.project13.maven + git-commit-id-plugin + + + + + + + + spring-milestones + Spring Milestones + https://repo.spring.io/libs-milestone + + + aliyun + aliyun + http://maven.aliyun.com/nexus/content/groups/public/ + + +