├── .gitignore ├── LICENSE ├── README.md ├── maozi-cloud-common ├── maozi-cloud-common-generate-code │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── maozi │ │ └── generate │ │ └── code │ │ ├── GenerateCodeRun.java │ │ ├── datasource │ │ ├── C3P0.java │ │ ├── DataBaseDao.java │ │ └── TheReflectionClasses.java │ │ ├── entity │ │ ├── DataSourceConfig.java │ │ ├── EntityData.java │ │ └── TableData.java │ │ ├── parent │ │ ├── GenerateParentPom.java │ │ ├── dto │ │ │ └── GenerateDtoPom.java │ │ ├── enums │ │ │ └── GenerateEnumPom.java │ │ ├── rest │ │ │ └── GenerateRestPom.java │ │ ├── rpc │ │ │ └── GenerateRpcPom.java │ │ ├── service │ │ │ ├── GenerateEntity.java │ │ │ ├── GenerateMapper.java │ │ │ ├── GenerateMapperXML.java │ │ │ ├── GenerateProperties.java │ │ │ ├── GenerateRun.java │ │ │ ├── GenerateService.java │ │ │ ├── GenerateServiceImpl.java │ │ │ └── GenerateServicePom.java │ │ └── vo │ │ │ └── GenerateVoPom.java │ │ └── tool │ │ └── SQLType.java ├── maozi-cloud-common-result │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── maozi │ │ └── common │ │ ├── BaseCommon.java │ │ └── result │ │ ├── AbstractBaseResult.java │ │ ├── error │ │ ├── ErrorResult.java │ │ └── exception │ │ │ └── BusinessResultException.java │ │ └── success │ │ └── SuccessResult.java ├── maozi-cloud-common-utils │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── maozi │ │ └── utils │ │ ├── MapperUtils.java │ │ ├── SpringUtil.java │ │ ├── WeightedRandomSelector.java │ │ └── context │ │ ├── ApplicationEnvironmentContext.java │ │ └── ApplicationLinkContext.java └── pom.xml ├── maozi-cloud-config ├── maozi-cloud-config-db │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── maozi │ │ └── db │ │ ├── config │ │ ├── CustomMetaObjectHandler.java │ │ ├── EasySqlInjector.java │ │ ├── MybatisPlusConfig.java │ │ ├── MybatisPlusLog.java │ │ └── RedisCache.java │ │ └── handler │ │ ├── CustomJsonTypeHandler.java │ │ └── ListTypeHandler.java ├── maozi-cloud-config-discovery │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── maozi │ │ └── discovery │ │ └── balancer │ │ ├── GrayLoadBalancerAutoConfiguration.java │ │ ├── GrayLoadBalancerClientConfiguration.java │ │ └── GrayRoundRobinLoadBalancer.java ├── maozi-cloud-config-dubbo │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── maozi │ │ │ └── dubbo │ │ │ ├── filter │ │ │ ├── ApplicationLinkContextSetFilter.java │ │ │ └── ApplicationLinkContextTransmitFilter.java │ │ │ ├── provider │ │ │ └── ProviderFirstParams.java │ │ │ └── router │ │ │ ├── GrayRouter.java │ │ │ └── RouterFactory.java │ │ └── resources │ │ └── META-INF │ │ └── dubbo │ │ ├── org.apache.dubbo.registry.ProviderFirstParams │ │ ├── org.apache.dubbo.rpc.Filter │ │ └── org.apache.dubbo.rpc.cluster.RouterFactory ├── maozi-cloud-config-feign │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── maozi │ │ └── feign │ │ └── config │ │ ├── ErrorDecoder.java │ │ ├── ResultDecoder.java │ │ └── TokenRequestInterceptor.java ├── maozi-cloud-config-job │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── maozi │ │ └── job │ │ ├── XxlJobConfig.java │ │ └── config │ │ └── JobEntranceLogAop.java ├── maozi-cloud-config-lock │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── maozi │ │ └── lock │ │ ├── annotation │ │ ├── Lock.java │ │ └── LockKey.java │ │ ├── config │ │ ├── LockAop.java │ │ └── RedissonConfig.java │ │ ├── error │ │ └── strategy │ │ │ ├── LockTimeoutHandler.java │ │ │ ├── UnLockTimeoutHandler.java │ │ │ └── impl │ │ │ ├── LockTimeoutStrategy.java │ │ │ └── UnLockTimeoutStrategy.java │ │ ├── lock │ │ ├── Lock.java │ │ ├── LockType.java │ │ └── impl │ │ │ ├── FairLock.java │ │ │ ├── ReadLock.java │ │ │ ├── ReentrantLock.java │ │ │ └── WriteLock.java │ │ └── properties │ │ └── LockProperties.java ├── maozi-cloud-config-log │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ ├── com │ │ └── maozi │ │ │ └── log │ │ │ ├── config │ │ │ ├── RemoteInvokeErrorToleranceAop.java │ │ │ ├── RestEntranceLogAop.java │ │ │ └── TtlMDCAdapterInitializer.java │ │ │ ├── convert │ │ │ ├── ApplicationNameMessageConverter.java │ │ │ └── EnvironmentMessageConverter.java │ │ │ └── utils │ │ │ └── RestEntranceLogUtils.java │ │ └── org │ │ └── slf4j │ │ └── TtlMDCAdapter.java ├── maozi-cloud-config-monitor │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── maozi │ │ └── health │ │ ├── api │ │ └── impl │ │ │ └── rest │ │ │ └── RestErrorLog.java │ │ └── config │ │ └── ApplicationHealthIndicator.java ├── maozi-cloud-config-oauth │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── maozi │ │ └── oauth │ │ ├── config │ │ ├── IAccessDeniedHandler.java │ │ ├── IAuthenticationEntryPoint.java │ │ ├── IRequestRejectedHandler.java │ │ └── ResourceServerConfig.java │ │ ├── properties │ │ └── ApiWhitelistProperties.java │ │ └── service │ │ └── IRemoteTokenServices.java ├── maozi-cloud-config-redis │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── maozi │ │ └── redis │ │ └── RedisTemplateConf.java ├── maozi-cloud-config-seata │ └── pom.xml ├── maozi-cloud-config-sentinel │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ ├── alibaba │ │ ├── cloud │ │ │ └── sentinel │ │ │ │ ├── custom │ │ │ │ └── SentinelAutoConfiguration.java │ │ │ │ └── datasource │ │ │ │ └── converter │ │ │ │ └── AuthorityRuleJsonConverter.java │ │ └── csp │ │ │ └── sentinel │ │ │ ├── dashboard │ │ │ └── datasource │ │ │ │ └── entity │ │ │ │ └── rule │ │ │ │ ├── AbstractRuleEntity.java │ │ │ │ ├── AuthorityRuleEntity.java │ │ │ │ └── RuleEntity.java │ │ │ ├── log │ │ │ └── LogBase.java │ │ │ └── slots │ │ │ └── statistic │ │ │ └── StatisticSlot.java │ │ └── maozi │ │ └── monitor │ │ └── config │ │ └── sentinel │ │ ├── CustomUrlBlockHandler.java │ │ ├── DubboFallback.java │ │ └── IpLimiter.java ├── maozi-cloud-config-stream │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── maozi │ │ └── stream │ │ ├── config │ │ ├── MessageSendStream.java │ │ └── StreamEntranceLogAop.java │ │ └── enums │ │ └── DelayMessageLevel.java ├── maozi-cloud-config-swagger │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── maozi │ │ └── swagger │ │ └── config │ │ └── Knife4jConfig.java ├── maozi-cloud-config-web │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── maozi │ │ └── mvc │ │ ├── config │ │ ├── async │ │ │ └── AsyncConfig.java │ │ ├── cache │ │ │ └── CacheConfig.java │ │ ├── code │ │ │ └── CodeConfig.java │ │ ├── enums │ │ │ └── EnumConfig.java │ │ ├── error │ │ │ └── ErrorParamTranslation.java │ │ ├── json │ │ │ ├── JacksonConfig.java │ │ │ └── ReadOnlyMultipartFormDataEndpointConverter.java │ │ └── rest │ │ │ ├── ErrorRestHandler.java │ │ │ ├── RestTemplate.java │ │ │ ├── RestTemplateConfig.java │ │ │ └── WebConfig.java │ │ └── filter │ │ └── ApplicationLinkContextFilter.java └── pom.xml ├── maozi-cloud-entity ├── maozi-cloud-base-entity │ ├── maozi-cloud-base-do │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── maozi │ │ │ └── base │ │ │ ├── AbstractBaseDomain.java │ │ │ └── AbstractBaseNameDomain.java │ ├── maozi-cloud-base-dto │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── maozi │ │ │ └── base │ │ │ ├── AbstractBaseDtomain.java │ │ │ ├── param │ │ │ ├── PageParam.java │ │ │ ├── SaveUpdateBatch.java │ │ │ ├── SearchParam.java │ │ │ ├── ValidCollectionParam.java │ │ │ └── plugin │ │ │ │ ├── OrderParam.java │ │ │ │ └── TimeParam.java │ │ │ ├── plugin │ │ │ ├── StoreClass.java │ │ │ ├── join │ │ │ │ ├── JoinBaseType.java │ │ │ │ ├── JoinPlugin.java │ │ │ │ └── JoinPlugins.java │ │ │ ├── mapping │ │ │ │ └── QueryMapping.java │ │ │ └── query │ │ │ │ ├── QueryBaseType.java │ │ │ │ └── QueryPlugin.java │ │ │ ├── result │ │ │ ├── DropDownResult.java │ │ │ ├── EnumResult.java │ │ │ └── ListStringResult.java │ │ │ └── validator │ │ │ ├── excel │ │ │ ├── ExcelFile.java │ │ │ └── ExcelFileValidator.java │ │ │ ├── image │ │ │ ├── ImageFile.java │ │ │ └── ImageFileValidator.java │ │ │ └── video │ │ │ ├── VideoFile.java │ │ │ └── VideoFileValidator.java │ ├── maozi-cloud-base-enum │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── maozi │ │ │ └── base │ │ │ ├── AbstractBaseCode.java │ │ │ ├── BaseEnum.java │ │ │ ├── CodeData.java │ │ │ ├── enums │ │ │ ├── Deleted.java │ │ │ ├── EnvironmentType.java │ │ │ ├── Status.java │ │ │ └── StoreClassType.java │ │ │ └── error │ │ │ └── code │ │ │ └── SystemErrorCode.java │ ├── maozi-cloud-base-vo │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── maozi │ │ │ └── base │ │ │ ├── AbstractBaseVomain.java │ │ │ └── result │ │ │ └── PageResult.java │ └── pom.xml ├── maozi-cloud-business-entity │ ├── maozi-cloud-do │ │ ├── maozi-cloud-seata-do │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ └── main │ │ │ │ └── resources │ │ │ │ └── db │ │ │ │ └── V1.0.0.20240825000000__init.sql │ │ └── pom.xml │ ├── maozi-cloud-dto │ │ ├── maozi-cloud-oauth-token-dto │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── maozi │ │ │ │ └── oauth │ │ │ │ └── token │ │ │ │ └── dto │ │ │ │ └── platform │ │ │ │ ├── dto │ │ │ │ └── OauthToken.java │ │ │ │ └── param │ │ │ │ ├── ClientParam.java │ │ │ │ ├── ClientUserParam.java │ │ │ │ └── TokenInfoParam.java │ │ ├── maozi-cloud-system-user-dto │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── maozi │ │ │ │ └── system │ │ │ │ └── user │ │ │ │ └── dto │ │ │ │ └── global │ │ │ │ └── dto │ │ │ │ └── SystemUser.java │ │ └── pom.xml │ ├── maozi-cloud-enum │ │ └── pom.xml │ ├── maozi-cloud-vo │ │ └── pom.xml │ └── pom.xml └── pom.xml ├── maozi-cloud-service ├── maozi-cloud-service-base │ ├── maozi-cloud-service-base-impl │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── maozi │ │ │ └── base │ │ │ └── api │ │ │ └── impl │ │ │ └── rest │ │ │ └── RestApplicationCode.java │ ├── maozi-cloud-service-base-rest-api │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── maozi │ │ │ └── base │ │ │ └── annotation │ │ │ ├── Get.java │ │ │ ├── Post.java │ │ │ └── RestService.java │ ├── maozi-cloud-service-base-rpc-api │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── maozi │ │ │ └── base │ │ │ └── api │ │ │ └── rpc │ │ │ └── BaseServiceResult.java │ ├── maozi-cloud-service-base-run │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ ├── com │ │ │ └── maozi │ │ │ │ └── BaseApplication.java │ │ │ └── org │ │ │ ├── apache │ │ │ └── dubbo │ │ │ │ └── spring │ │ │ │ └── boot │ │ │ │ └── context │ │ │ │ └── event │ │ │ │ └── WelcomeLogoApplicationListener.java │ │ │ └── springframework │ │ │ └── boot │ │ │ ├── SpringApplication.java │ │ │ └── StartupInfoLogger.java │ └── pom.xml ├── maozi-cloud-service-business │ ├── maozi-cloud-service-impl │ │ ├── maozi-cloud-service-bd │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── maozi │ │ │ │ └── bd │ │ │ │ ├── api │ │ │ │ ├── BDService.java │ │ │ │ └── impl │ │ │ │ │ └── BDServiceImpl.java │ │ │ │ └── properties │ │ │ │ └── BDProperties.java │ │ ├── maozi-cloud-service-company-wechat │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── maozi │ │ │ │ └── wx │ │ │ │ ├── api │ │ │ │ ├── WxService.java │ │ │ │ └── impl │ │ │ │ │ └── WxServiceImpl.java │ │ │ │ ├── config │ │ │ │ ├── AesException.java │ │ │ │ ├── ByteGroup.java │ │ │ │ ├── PKCS7Encoder.java │ │ │ │ ├── SHA1.java │ │ │ │ ├── WXBizMsgCrypt.java │ │ │ │ └── XMLParse.java │ │ │ │ └── properties │ │ │ │ └── WxProperties.java │ │ ├── maozi-cloud-service-qny │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── maozi │ │ │ │ └── qny │ │ │ │ ├── api │ │ │ │ ├── QNYService.java │ │ │ │ └── impl │ │ │ │ │ ├── QNYServiceImpl.java │ │ │ │ │ └── rest │ │ │ │ │ └── OssServiceRestImpl.java │ │ │ │ └── properties │ │ │ │ └── QNYProperties.java │ │ ├── maozi-cloud-service-ss │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── maozi │ │ │ │ └── ss │ │ │ │ ├── api │ │ │ │ ├── SSService.java │ │ │ │ └── impl │ │ │ │ │ └── SSServiceImpl.java │ │ │ │ ├── config │ │ │ │ └── SSConfig.java │ │ │ │ └── properties │ │ │ │ └── SSProperties.java │ │ └── pom.xml │ ├── maozi-cloud-service-rest-api │ │ ├── maozi-cloud-service-rest-api-oauth-token │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── maozi │ │ │ │ └── oauth │ │ │ │ └── token │ │ │ │ └── api │ │ │ │ └── rest │ │ │ │ └── v1 │ │ │ │ ├── RestOauthTokenServiceV1.java │ │ │ │ └── fallback │ │ │ │ └── OauthTokenServiceRestFallBackFactory.java │ │ └── pom.xml │ ├── maozi-cloud-service-rpc-api │ │ ├── maozi-cloud-service-rpc-api-oauth-token │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── maozi │ │ │ │ └── oauth │ │ │ │ └── token │ │ │ │ └── api │ │ │ │ └── rpc │ │ │ │ └── v1 │ │ │ │ └── RpcOauthTokenServiceV1.java │ │ ├── maozi-cloud-service-rpc-api-system-config │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── maozi │ │ │ │ └── system │ │ │ │ └── config │ │ │ │ └── api │ │ │ │ └── rpc │ │ │ │ └── v1 │ │ │ │ └── RpcRegionServiceV1.java │ │ ├── maozi-cloud-service-rpc-api-system-user │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── maozi │ │ │ │ └── system │ │ │ │ └── user │ │ │ │ └── api │ │ │ │ └── rpc │ │ │ │ └── v1 │ │ │ │ └── RpcUserInfoServiceV1.java │ │ └── pom.xml │ └── pom.xml ├── maozi-cloud-service-plugin │ ├── maozi-cloud-service-db-impl │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ ├── baomidou │ │ │ └── mybatisplus │ │ │ │ └── extension │ │ │ │ └── service │ │ │ │ └── impl │ │ │ │ └── ServiceImpl.java │ │ │ ├── github │ │ │ └── yulichang │ │ │ │ └── base │ │ │ │ └── MPJBaseServiceImpl.java │ │ │ └── maozi │ │ │ ├── BaseApplicationDB.java │ │ │ └── base │ │ │ ├── api │ │ │ ├── IBaseMapper.java │ │ │ └── impl │ │ │ │ └── BaseServiceImpl.java │ │ │ └── plugin │ │ │ ├── JoinBasePlugin.java │ │ │ ├── QueryBasePlugin.java │ │ │ ├── StoreClassDBScan.java │ │ │ ├── impl │ │ │ ├── join │ │ │ │ ├── QueryInnerJoinPlugin.java │ │ │ │ ├── QueryLeftJoinPlugin.java │ │ │ │ └── QueryRightJoinPlugin.java │ │ │ └── query │ │ │ │ ├── QueryEqPlugin.java │ │ │ │ ├── QueryGePlugin.java │ │ │ │ ├── QueryInPlugin.java │ │ │ │ ├── QueryLePlugin.java │ │ │ │ ├── QueryLikePlugin.java │ │ │ │ └── QueryNePlugin.java │ │ │ └── type │ │ │ ├── JoinType.java │ │ │ └── QueryType.java │ └── pom.xml └── pom.xml └── pom.xml /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.jar 15 | *.war 16 | *.nar 17 | *.ear 18 | *.zip 19 | *.tar.gz 20 | *.rar 21 | 22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 23 | hs_err_pid* 24 | 25 | # IDEA project environment # 26 | *.iml 27 | .idea 28 | 29 | # Eclipse project environment # 30 | .settings 31 | .project 32 | .classpath 33 | .factorypath 34 | .springBeans 35 | target 36 | 37 | # Spring Tool Suits project environment # 38 | .sts4-cache 39 | 40 | .flattened-pom.xml -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # maozi-cloud-parent 2 | 3 |
4 | 5 | 基于 Spring-Cloud-Alibaba-Dubbo 开源封装一站式分布式解决方案,它包含开发分布式应用程序所需的所有组件,为开发团队代码风格一致,提升代码质量,专注高效快速开发业务 6 | 7 |
8 | 9 | 亮点组件:全链路灰度( Web Job Mq Dubbo Gateway ) 、全链路完整日志 、结合WSL2自动化部署开发环境 、DTO VO TO CRUD 、重写Klock分布式锁 、服务监控 、领域模型 、结构设计 10 | 11 |
12 | 13 | 为什么选择 maozi-cloud-parent 而不选择 Pigx 、Ruoyi 、Guns 、JeeSite 等开源框架,他们的底层代码我都读完 ,结构非常不清晰 、父模块子模块依赖耦合度极高 没有聚合层 依赖超级乱 、收费 、领域模型非常神奇 、全链路日志不完善 、没有灰度模式 、很多人用了到最后十个有九个成屎山 动也不是 不动也不是 14 | 15 |
16 | 17 | 官方文档:[快速开始](https://www.yuque.com/pengjinlong/maozi-cloud-parent) 18 | 19 |
20 | 21 | null 22 | 23 |
24 | 25 |
26 | 27 | 微信联系方式:x_mao_zi 28 | 29 | QQ联系方式:1095071913 30 | -------------------------------------------------------------------------------- /maozi-cloud-common/maozi-cloud-common-generate-code/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | com.maozi 7 | maozi-cloud-common 8 | ${parent-revision} 9 | 10 | maozi-cloud-common-generate-code 11 | 12 | 13 | 14 | 15 | 16 | com.mchange 17 | c3p0 18 | 0.9.5.4 19 | 20 | 21 | 22 | org.dom4j 23 | dom4j 24 | 2.1.3 25 | 26 | 27 | 28 | com.maozi 29 | maozi-cloud-base-do 30 | ${maozi-cloud-base-do.version} 31 | 32 | 33 | 34 | com.maozi 35 | maozi-cloud-config-db 36 | ${maozi-cloud-config-db.version} 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /maozi-cloud-common/maozi-cloud-common-generate-code/src/main/java/com/maozi/generate/code/datasource/C3P0.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2012-2018 the original author or authors. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * 17 | */ 18 | 19 | package com.maozi.generate.code.datasource; 20 | 21 | import com.maozi.generate.code.entity.DataSourceConfig; 22 | import com.mchange.v2.c3p0.ComboPooledDataSource; 23 | import java.sql.Connection; 24 | import java.sql.SQLException; 25 | 26 | public class C3P0 { 27 | ComboPooledDataSource c = null; 28 | private C3P0() { 29 | try { 30 | c = new ComboPooledDataSource(); 31 | c.setDriverClass("com.mysql.cj.jdbc.Driver");//FinancingProduct 32 | c.setJdbcUrl("jdbc:mysql://"+DataSourceConfig.JDBCURL+"?useSSL=false&serverTimezone=UTC&characterEncoding=utf8&nullCatalogMeansCurrent=true"); 33 | c.setUser(DataSourceConfig.USER); 34 | c.setPassword(DataSourceConfig.PASSWORD); 35 | c.setMaxPoolSize(1); 36 | } catch (Exception e) { 37 | 38 | } 39 | } 40 | private static C3P0 c3p0=new C3P0(); 41 | 42 | public static C3P0 getDBManager(){ 43 | return c3p0; 44 | } 45 | public Connection createDBManager() throws Exception{ 46 | return c.getConnection(); 47 | } 48 | public static void releaseConnection(Connection connection){ 49 | try { 50 | connection.close(); 51 | } catch (SQLException e) { 52 | e.printStackTrace(); 53 | } 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /maozi-cloud-common/maozi-cloud-common-generate-code/src/main/java/com/maozi/generate/code/entity/DataSourceConfig.java: -------------------------------------------------------------------------------- 1 | package com.maozi.generate.code.entity; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class DataSourceConfig { 7 | 8 | public static String JDBCURL; 9 | 10 | public static String USER; 11 | 12 | public static String PASSWORD; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /maozi-cloud-common/maozi-cloud-common-generate-code/src/main/java/com/maozi/generate/code/entity/EntityData.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2012-2018 the original author or authors. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * 17 | */ 18 | 19 | package com.maozi.generate.code.entity; 20 | 21 | import java.util.List; 22 | import lombok.AllArgsConstructor; 23 | import lombok.Data; 24 | import lombok.NoArgsConstructor; 25 | 26 | @Data 27 | @AllArgsConstructor 28 | @NoArgsConstructor 29 | public class EntityData { 30 | 31 | private String tableName; 32 | 33 | private String className; 34 | 35 | private List field; 36 | 37 | private String moduleName; 38 | 39 | private String packageName; 40 | 41 | // private List foreignEntityOne; 42 | // 43 | // private List foreignEntityMany; 44 | 45 | } 46 | -------------------------------------------------------------------------------- /maozi-cloud-common/maozi-cloud-common-generate-code/src/main/java/com/maozi/generate/code/entity/TableData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package com.maozi.generate.code.entity; 19 | 20 | import lombok.AllArgsConstructor; 21 | import lombok.Data; 22 | import lombok.NoArgsConstructor; 23 | 24 | 25 | 26 | @Data 27 | @AllArgsConstructor 28 | @NoArgsConstructor 29 | public class TableData { 30 | 31 | private String tableName; 32 | 33 | private String prefixFilter; 34 | 35 | } 36 | -------------------------------------------------------------------------------- /maozi-cloud-common/maozi-cloud-common-generate-code/src/main/java/com/maozi/generate/code/parent/service/GenerateProperties.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2012-2018 the original author or authors. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * 17 | */ 18 | 19 | package com.maozi.generate.code.parent.service; 20 | 21 | import com.maozi.generate.code.tool.SQLType; 22 | 23 | public class GenerateProperties { 24 | 25 | public static void generate(String mobule,String pash,Boolean db) throws Exception { 26 | 27 | StringBuilder properties = new StringBuilder(); 28 | 29 | if(db) { 30 | properties.append("spring.cloud.nacos.config.shared-dataids=${application-nacos-config},boot-datasource.yml,boot-db.yml\r\n"); 31 | }else { 32 | properties.append("spring.cloud.nacos.config.shared-dataids=${application-nacos-config}\r\n"); 33 | } 34 | 35 | /* 创建文件 Begin */ 36 | SQLType.fileCreate(pash, "bootstrap", properties,"properties"); 37 | /* 创建文件 End */ 38 | 39 | 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /maozi-cloud-common/maozi-cloud-common-generate-code/src/main/java/com/maozi/generate/code/parent/service/GenerateRun.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package com.maozi.generate.code.parent.service; 19 | 20 | import com.maozi.generate.code.tool.SQLType; 21 | 22 | public class GenerateRun { 23 | 24 | public static void generate(String module,String packageName, String pash,Boolean db) throws Exception { 25 | 26 | StringBuilder service = new StringBuilder(); 27 | 28 | service.append("package " + packageName + ";\r\n\r\n"); 29 | 30 | service.append("public class " + SQLType.initial(module) + "Application extends BaseApplication"+(db?"DB":"")+" {\r\n\r\n"); 31 | 32 | service.append(" public static void main(String[] args) {\r\n"); 33 | service.append(" ApplicationRun();\r\n"); 34 | service.append(" }\r\n"); 35 | 36 | service.append("\r\n}"); 37 | 38 | /* 创建文件 Begin */ 39 | SQLType.fileCreate(pash+"\\"+packageName.replace(".", "\\"), SQLType.initial(module) + "Application", service); 40 | /* 创建文件 End */ 41 | 42 | 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /maozi-cloud-common/maozi-cloud-common-result/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 4.0.0 6 | 7 | com.maozi 8 | maozi-cloud-common 9 | ${parent-revision} 10 | 11 | maozi-cloud-common-result 12 | 13 | 14 | 15 | 16 | 17 | 18 | com.maozi 19 | maozi-cloud-base-enum 20 | ${maozi-cloud-base-enum.version} 21 | 22 | 23 | 24 | com.maozi 25 | maozi-cloud-oauth-token-dto 26 | ${maozi-cloud-oauth-token-dto.version} 27 | 28 | 29 | 30 | com.maozi 31 | maozi-cloud-common-utils 32 | ${maozi-cloud-common-utils.version} 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | org.apache.skywalking 41 | apm-toolkit-trace 42 | ${skywalking.version} 43 | 44 | 45 | 46 | org.apache.skywalking 47 | apm-toolkit-logback-1.x 48 | ${skywalking.version} 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | org.springframework.security 57 | spring-security-core 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /maozi-cloud-common/maozi-cloud-common-result/src/main/java/com/maozi/common/result/success/SuccessResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package com.maozi.common.result.success; 19 | 20 | import com.maozi.common.result.AbstractBaseResult; 21 | import io.swagger.v3.oas.annotations.media.Schema; 22 | import java.io.Serializable; 23 | import lombok.Data; 24 | import lombok.EqualsAndHashCode; 25 | import lombok.NoArgsConstructor; 26 | import lombok.ToString; 27 | 28 | @Data 29 | @NoArgsConstructor 30 | @ToString(callSuper = true) 31 | @EqualsAndHashCode(callSuper=true) 32 | @Schema(description = "接口成功结果集") 33 | public class SuccessResult extends AbstractBaseResult implements Serializable { 34 | 35 | private D data; 36 | 37 | public SuccessResult(D data) { 38 | this.data=data; 39 | } 40 | 41 | @Override 42 | public Integer getCode() { 43 | return 200; 44 | } 45 | 46 | } -------------------------------------------------------------------------------- /maozi-cloud-common/maozi-cloud-common-utils/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | com.maozi 6 | maozi-cloud-common 7 | ${parent-revision} 8 | 9 | maozi-cloud-common-utils 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | cglib 19 | cglib 20 | ${cglib.version} 21 | 22 | 23 | 24 | org.apache.commons 25 | commons-lang3 26 | 27 | 28 | 29 | com.google.guava 30 | guava 31 | 33.2.1-jre 32 | 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-json 37 | 38 | 39 | 40 | com.alibaba 41 | transmittable-thread-local 42 | ${transmittable.version} 43 | 44 | 45 | 46 | org.springframework.boot 47 | spring-boot-starter-validation 48 | 49 | 50 | 51 | org.springframework.cloud 52 | spring-cloud-context 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | maven_central 61 | Maven Central 62 | https://repo.maven.apache.org/maven2/ 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /maozi-cloud-common/maozi-cloud-common-utils/src/main/java/com/maozi/utils/WeightedRandomSelector.java: -------------------------------------------------------------------------------- 1 | package com.maozi.utils; 2 | 3 | import java.util.NavigableMap; 4 | import java.util.Random; 5 | import java.util.TreeMap; 6 | 7 | /** 8 | * 概率随机执行函数 9 | * @param 10 | */ 11 | public class WeightedRandomSelector { 12 | 13 | //ConcurrentSkipListMap保证线程安全 14 | private final NavigableMap map = new TreeMap<>(); 15 | 16 | private final Random random; 17 | 18 | private double total = 0; 19 | 20 | public WeightedRandomSelector() { 21 | this(new Random()); 22 | } 23 | 24 | public WeightedRandomSelector(Random random) { 25 | this.random = random; 26 | } 27 | 28 | public void add(double weight, T result) { 29 | if (weight <= 0) { 30 | return; 31 | } 32 | total += weight; 33 | map.put(total, result); 34 | } 35 | 36 | public T next() { 37 | double value = random.nextDouble() * total; 38 | return map.higherEntry(value).getValue(); 39 | } 40 | 41 | } -------------------------------------------------------------------------------- /maozi-cloud-common/maozi-cloud-common-utils/src/main/java/com/maozi/utils/context/ApplicationLinkContext.java: -------------------------------------------------------------------------------- 1 | package com.maozi.utils.context; 2 | 3 | import com.alibaba.ttl.TransmittableThreadLocal; 4 | import lombok.Data; 5 | 6 | @Data 7 | public class ApplicationLinkContext { 8 | 9 | public static TransmittableThreadLocal VERSIONS = new TransmittableThreadLocal<>(); 10 | 11 | public static TransmittableThreadLocal USERNAMES = new TransmittableThreadLocal<>(); 12 | 13 | public static void set(String version,String username){ 14 | 15 | VERSIONS.set(version); 16 | 17 | USERNAMES.set(username); 18 | 19 | } 20 | 21 | public static void clear(){ 22 | 23 | VERSIONS.remove(); 24 | 25 | USERNAMES.remove(); 26 | 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /maozi-cloud-common/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 4.0.0 6 | 7 | com.maozi 8 | maozi-cloud-parent 9 | ${parent-revision} 10 | 11 | maozi-cloud-common 12 | pom 13 | 14 | 15 | 16 | 17 | cn.hutool 18 | hutool-all 19 | ${hutool.version} 20 | 21 | 22 | 23 | 24 | 25 | maozi-cloud-common-utils 26 | maozi-cloud-common-result 27 | maozi-cloud-common-generate-code 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-db/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | com.maozi 7 | maozi-cloud-config 8 | ${parent-revision} 9 | 10 | maozi-cloud-config-db 11 | 12 | 13 | 14 | 15 | 16 | 17 | com.maozi 18 | maozi-cloud-service-base-run 19 | ${maozi-cloud-service-base-run.version} 20 | 21 | 22 | 23 | com.baomidou 24 | mybatis-plus-boot-starter 25 | ${mybatis-plus.version} 26 | 27 | 28 | 29 | mysql 30 | mysql-connector-java 31 | 32 | 33 | 34 | org.jetbrains.kotlin 35 | kotlin-stdlib-jdk8 36 | 37 | 38 | 39 | org.flywaydb 40 | flyway-core 41 | 42 | 43 | 44 | com.github.yulichang 45 | mybatis-plus-join 46 | ${mybatis-plus-join.version} 47 | 48 | 49 | 50 | 51 | 52 | 53 | com.maozi 54 | maozi-cloud-base-enum 55 | ${maozi-cloud-base-enum.version} 56 | 57 | 58 | 59 | com.maozi 60 | maozi-cloud-config-redis 61 | ${maozi-cloud-config-redis.version} 62 | 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-db/src/main/java/com/maozi/db/config/EasySqlInjector.java: -------------------------------------------------------------------------------- 1 | package com.maozi.db.config; 2 | 3 | import com.baomidou.mybatisplus.annotation.FieldFill; 4 | import com.baomidou.mybatisplus.core.injector.AbstractMethod; 5 | import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector; 6 | import com.baomidou.mybatisplus.core.metadata.TableInfo; 7 | import com.baomidou.mybatisplus.extension.injector.methods.InsertBatchSomeColumn; 8 | import java.util.List; 9 | import org.springframework.context.annotation.Configuration; 10 | 11 | @Configuration 12 | public class EasySqlInjector extends DefaultSqlInjector { 13 | 14 | @Override 15 | public List getMethodList(Class mapperClass, TableInfo tableInfo) { 16 | 17 | List methodList = super.getMethodList(mapperClass, tableInfo); 18 | 19 | methodList.add(new InsertBatchSomeColumn(i -> i.getFieldFill() != FieldFill.UPDATE)); 20 | 21 | return methodList; 22 | 23 | } 24 | 25 | } -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-db/src/main/java/com/maozi/db/config/MybatisPlusLog.java: -------------------------------------------------------------------------------- 1 | package com.maozi.db.config; 2 | 3 | import com.maozi.common.BaseCommon; 4 | import com.maozi.utils.context.ApplicationEnvironmentContext; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.apache.ibatis.logging.Log; 7 | 8 | @Slf4j 9 | public class MybatisPlusLog implements Log { 10 | 11 | public MybatisPlusLog(String clazz) {} 12 | 13 | public boolean isDebugEnabled() {return true;} 14 | 15 | public boolean isTraceEnabled() {return true;} 16 | 17 | public void error(String s, Throwable e) {log.error(s);} 18 | 19 | public void error(String s) {log.error(s); } 20 | 21 | public void debug(String s) { 22 | 23 | if(!ApplicationEnvironmentContext.IS_RUNNING){ 24 | return; 25 | } 26 | 27 | StringBuilder sql = BaseCommon.sql.get(); 28 | 29 | if(BaseCommon.isNull(sql)) { 30 | 31 | sql = new StringBuilder(); 32 | 33 | BaseCommon.sql.set(sql); 34 | 35 | } 36 | 37 | if(s.contains("==> Preparing: ")) { 38 | 39 | s=s.replace("==> Preparing: ",""); 40 | 41 | sql.append(s); 42 | 43 | } 44 | 45 | if(s.contains("==> Parameters: ")) { 46 | 47 | s=s.replace("==> Parameters: ",""); 48 | 49 | if(BaseCommon.isNotEmpty(s)) { 50 | 51 | String [] params = s.split("\\),"); 52 | 53 | for(Integer i = 0 ; i < params.length ; i++) { 54 | 55 | String param = params[i]; 56 | 57 | param = "'"+param.substring(0,param.indexOf("("))+"'"; 58 | 59 | int index = sql.indexOf("?"); 60 | 61 | if(index != -1) { 62 | sql.replace(index, index+1, param); 63 | 64 | } 65 | 66 | } 67 | 68 | } 69 | 70 | sql.append(";"); 71 | 72 | } 73 | 74 | } 75 | 76 | public void trace(String s) {} 77 | 78 | public void warn(String s) {} 79 | 80 | } -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-db/src/main/java/com/maozi/db/handler/CustomJsonTypeHandler.java: -------------------------------------------------------------------------------- 1 | package com.maozi.db.handler; 2 | 3 | import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; 4 | import com.fasterxml.jackson.core.JsonProcessingException; 5 | import com.maozi.utils.MapperUtils; 6 | import java.io.IOException; 7 | 8 | public class CustomJsonTypeHandler extends JacksonTypeHandler { 9 | 10 | private final Class type; 11 | 12 | public CustomJsonTypeHandler(Class type) { 13 | 14 | super(type); 15 | 16 | this.type = type; 17 | 18 | } 19 | 20 | protected Object parse(String json) { 21 | 22 | try { 23 | return MapperUtils.getObjectMapper().readValue(json, this.type); 24 | } catch (IOException var3) { 25 | IOException e = var3; 26 | throw new RuntimeException(e); 27 | } 28 | 29 | } 30 | 31 | protected String toJson(Object obj) { 32 | 33 | try { 34 | return MapperUtils.getObjectMapper().writeValueAsString(obj); 35 | } catch (JsonProcessingException var3) { 36 | JsonProcessingException e = var3; 37 | throw new RuntimeException(e); 38 | } 39 | 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-discovery/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | com.maozi 7 | maozi-cloud-config 8 | ${parent-revision} 9 | 10 | maozi-cloud-config-discovery 11 | 12 | 13 | 14 | 15 | 16 | com.alibaba.cloud 17 | spring-cloud-starter-alibaba-nacos-discovery 18 | 19 | 20 | 21 | com.maozi 22 | maozi-cloud-common-result 23 | ${maozi-cloud-common-result.version} 24 | 25 | 26 | 27 | org.springframework.cloud 28 | spring-cloud-starter-loadbalancer 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-discovery/src/main/java/com/maozi/discovery/balancer/GrayLoadBalancerAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.maozi.discovery.balancer; 2 | 3 | import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClients; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | @Configuration 7 | @LoadBalancerClients(defaultConfiguration = GrayLoadBalancerClientConfiguration.class) 8 | public class GrayLoadBalancerAutoConfiguration { 9 | 10 | } -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-discovery/src/main/java/com/maozi/discovery/balancer/GrayLoadBalancerClientConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.maozi.discovery.balancer; 2 | 3 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; 4 | import org.springframework.cloud.client.ServiceInstance; 5 | import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClientConfiguration; 6 | import org.springframework.cloud.loadbalancer.core.ReactorLoadBalancer; 7 | import org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier; 8 | import org.springframework.cloud.loadbalancer.support.LoadBalancerClientFactory; 9 | import org.springframework.context.annotation.Bean; 10 | import org.springframework.core.env.Environment; 11 | 12 | public class GrayLoadBalancerClientConfiguration extends LoadBalancerClientConfiguration { 13 | 14 | @Bean 15 | @Override 16 | @ConditionalOnMissingBean 17 | public ReactorLoadBalancer reactorServiceInstanceLoadBalancer(Environment environment,LoadBalancerClientFactory loadBalancerClientFactory) { 18 | 19 | String name = environment.getProperty(LoadBalancerClientFactory.PROPERTY_NAME); 20 | 21 | return new GrayRoundRobinLoadBalancer(loadBalancerClientFactory.getLazyProvider(name, ServiceInstanceListSupplier.class)); 22 | 23 | } 24 | 25 | } -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-dubbo/src/main/java/com/maozi/dubbo/filter/ApplicationLinkContextSetFilter.java: -------------------------------------------------------------------------------- 1 | package com.maozi.dubbo.filter; 2 | 3 | import com.maozi.common.BaseCommon; 4 | import com.maozi.utils.context.ApplicationLinkContext; 5 | import org.apache.dubbo.rpc.Filter; 6 | import org.apache.dubbo.rpc.Invocation; 7 | import org.apache.dubbo.rpc.Invoker; 8 | import org.apache.dubbo.rpc.Result; 9 | import org.apache.dubbo.rpc.RpcContext; 10 | import org.apache.dubbo.rpc.RpcContextAttachment; 11 | import org.apache.dubbo.rpc.RpcException; 12 | 13 | public class ApplicationLinkContextSetFilter implements Filter { 14 | 15 | @Override 16 | public Result invoke(Invoker invoker, Invocation invocation) throws RpcException { 17 | 18 | RpcContextAttachment serverAttachment = RpcContext.getServerAttachment(); 19 | 20 | ApplicationLinkContext.set(serverAttachment.getAttachment("revision"),serverAttachment.getAttachment("username")); 21 | 22 | try{ return invoker.invoke(invocation); }catch (Throwable e){ throw e; }finally{ 23 | BaseCommon.clearContext(); 24 | } 25 | 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-dubbo/src/main/java/com/maozi/dubbo/filter/ApplicationLinkContextTransmitFilter.java: -------------------------------------------------------------------------------- 1 | package com.maozi.dubbo.filter; 2 | 3 | import com.maozi.utils.context.ApplicationLinkContext; 4 | import org.apache.dubbo.rpc.Filter; 5 | import org.apache.dubbo.rpc.Invocation; 6 | import org.apache.dubbo.rpc.Invoker; 7 | import org.apache.dubbo.rpc.Result; 8 | import org.apache.dubbo.rpc.RpcContext; 9 | import org.apache.dubbo.rpc.RpcContextAttachment; 10 | import org.apache.dubbo.rpc.RpcException; 11 | 12 | public class ApplicationLinkContextTransmitFilter implements Filter { 13 | 14 | @Override 15 | public Result invoke(Invoker invoker, Invocation invocation) throws RpcException { 16 | 17 | RpcContextAttachment clientAttachment = RpcContext.getClientAttachment(); 18 | 19 | clientAttachment.setAttachment("revision",ApplicationLinkContext.VERSIONS.get()); 20 | 21 | clientAttachment.setAttachment("username", ApplicationLinkContext.USERNAMES.get()); 22 | 23 | return invoker.invoke(invocation); 24 | 25 | // return new AsyncRpcResult(CompletableFuture.completedFuture(new AppResponse(BaseCommon.error(new CodeData(6,"服务错误" + "(" + applicationName + ")"),500))), invocation); 26 | 27 | } 28 | 29 | } -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-dubbo/src/main/java/com/maozi/dubbo/provider/ProviderFirstParams.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.maozi.dubbo.provider; 18 | 19 | import static org.apache.dubbo.common.constants.CommonConstants.DUBBO_VERSION_KEY; 20 | import static org.apache.dubbo.common.constants.CommonConstants.METHODS_KEY; 21 | import static org.apache.dubbo.common.constants.CommonConstants.RELEASE_KEY; 22 | import static org.apache.dubbo.common.constants.CommonConstants.TAG_KEY; 23 | import static org.apache.dubbo.common.constants.CommonConstants.TIMESTAMP_KEY; 24 | 25 | import java.util.Arrays; 26 | import java.util.Collections; 27 | import java.util.HashSet; 28 | import java.util.Set; 29 | import org.apache.dubbo.registry.support.DefaultProviderFirstParams; 30 | 31 | public class ProviderFirstParams extends DefaultProviderFirstParams { 32 | private final static Set PARAMS = Collections.unmodifiableSet(new HashSet() {{ 33 | addAll(Arrays.asList(RELEASE_KEY, DUBBO_VERSION_KEY, METHODS_KEY, TIMESTAMP_KEY, TAG_KEY,"application.version")); 34 | }}); 35 | 36 | @Override 37 | public Set params() { 38 | return PARAMS; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-dubbo/src/main/java/com/maozi/dubbo/router/GrayRouter.java: -------------------------------------------------------------------------------- 1 | package com.maozi.dubbo.router; 2 | 3 | import com.google.common.collect.Lists; 4 | import com.maozi.common.BaseCommon; 5 | import com.maozi.utils.context.ApplicationLinkContext; 6 | import java.util.List; 7 | import org.apache.dubbo.common.URL; 8 | import org.apache.dubbo.rpc.Invocation; 9 | import org.apache.dubbo.rpc.Invoker; 10 | import org.apache.dubbo.rpc.RpcException; 11 | import org.apache.dubbo.rpc.cluster.router.AbstractRouter; 12 | import org.apache.dubbo.rpc.cluster.router.RouterResult; 13 | 14 | public class GrayRouter extends AbstractRouter { 15 | 16 | @Override 17 | public RouterResult> route(List> invokers, URL url, Invocation invocation, boolean needToPrintMessage) throws RpcException { 18 | 19 | String version = ApplicationLinkContext.VERSIONS.get(); 20 | 21 | List> mainApplicationClients = Lists.newArrayList(); 22 | 23 | List> grayApplicationClients = Lists.newArrayList(); 24 | 25 | invokers.stream().forEach(invoker ->{ 26 | 27 | String clientApplicationVersion = invoker.getUrl().getParameter("application.version"); 28 | 29 | if(BaseCommon.isNotEmpty(version) && version.equals(clientApplicationVersion)){ 30 | grayApplicationClients.add(invoker); 31 | } 32 | 33 | if("main".equals(clientApplicationVersion)){ 34 | mainApplicationClients.add(invoker); 35 | } 36 | 37 | }); 38 | 39 | return new RouterResult<>(BaseCommon.collectionIsNotEmpty(grayApplicationClients) ? grayApplicationClients : mainApplicationClients); 40 | 41 | } 42 | 43 | } -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-dubbo/src/main/java/com/maozi/dubbo/router/RouterFactory.java: -------------------------------------------------------------------------------- 1 | package com.maozi.dubbo.router; 2 | 3 | import org.apache.dubbo.common.URL; 4 | import org.apache.dubbo.common.constants.CommonConstants; 5 | import org.apache.dubbo.common.extension.Activate; 6 | import org.apache.dubbo.rpc.cluster.CacheableRouterFactory; 7 | import org.apache.dubbo.rpc.cluster.Router; 8 | 9 | @Activate(group = CommonConstants.CONSUMER) 10 | public class RouterFactory extends CacheableRouterFactory { 11 | 12 | @Override 13 | protected Router createRouter(URL url) { 14 | return new GrayRouter(); 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-dubbo/src/main/resources/META-INF/dubbo/org.apache.dubbo.registry.ProviderFirstParams: -------------------------------------------------------------------------------- 1 | providerFirstParams=com.maozi.dubbo.provider.ProviderFirstParams -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-dubbo/src/main/resources/META-INF/dubbo/org.apache.dubbo.rpc.Filter: -------------------------------------------------------------------------------- 1 | applicationLinkContextSetFilter=com.maozi.dubbo.filter.ApplicationLinkContextSetFilter 2 | applicationLinkContextTransmitFilter=com.maozi.dubbo.filter.ApplicationLinkContextTransmitFilter -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-dubbo/src/main/resources/META-INF/dubbo/org.apache.dubbo.rpc.cluster.RouterFactory: -------------------------------------------------------------------------------- 1 | routerFactory=com.maozi.dubbo.router.RouterFactory -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-feign/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | com.maozi 7 | maozi-cloud-config 8 | ${parent-revision} 9 | 10 | maozi-cloud-config-feign 11 | 12 | 13 | 14 | 15 | 16 | 17 | org.springframework.cloud 18 | spring-cloud-starter-openfeign 19 | 20 | 21 | 22 | io.github.openfeign 23 | feign-okhttp 24 | 25 | 26 | 27 | com.maozi 28 | maozi-cloud-common-result 29 | ${maozi-cloud-common-result.version} 30 | 31 | 32 | 33 | javax.ws.rs 34 | javax.ws.rs-api 35 | 2.1 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-feign/src/main/java/com/maozi/feign/config/ErrorDecoder.java: -------------------------------------------------------------------------------- 1 | package com.maozi.feign.config; 2 | 3 | import com.maozi.common.result.error.exception.BusinessResultException; 4 | import feign.Response; 5 | import feign.Util; 6 | import java.io.IOException; 7 | import java.nio.charset.Charset; 8 | import org.springframework.stereotype.Component; 9 | 10 | @Component 11 | public class ErrorDecoder implements feign.codec.ErrorDecoder { 12 | 13 | @Override 14 | public Exception decode(String methodKey, Response response) { 15 | 16 | try {return new BusinessResultException(response.status(),Util.toString(response.body().asReader(Charset.defaultCharset())),response.status());} catch (IOException e) { 17 | return e; 18 | } 19 | 20 | } 21 | 22 | } -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-feign/src/main/java/com/maozi/feign/config/TokenRequestInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.maozi.feign.config; 2 | 3 | import static com.maozi.common.BaseCommon.getRequest; 4 | 5 | import com.maozi.utils.context.ApplicationLinkContext; 6 | import feign.RequestInterceptor; 7 | import feign.RequestTemplate; 8 | import java.util.Enumeration; 9 | import javax.servlet.http.HttpServletRequest; 10 | import org.springframework.stereotype.Component; 11 | 12 | @Component 13 | public class TokenRequestInterceptor implements RequestInterceptor { 14 | 15 | @Override 16 | public void apply(RequestTemplate requestTemplate) { 17 | 18 | HttpServletRequest request = getRequest(); 19 | 20 | Enumeration headerNames = request.getHeaderNames(); 21 | 22 | if (headerNames != null) { 23 | 24 | while (headerNames.hasMoreElements()) { 25 | 26 | String name = headerNames.nextElement(); 27 | 28 | if("authorization".equals(name)) { 29 | requestTemplate.header(name, request.getHeader(name)); 30 | } 31 | 32 | } 33 | 34 | requestTemplate.header("Version", ApplicationLinkContext.VERSIONS.get()); 35 | 36 | } 37 | 38 | } 39 | 40 | } -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-job/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | com.maozi 7 | maozi-cloud-config 8 | ${parent-revision} 9 | 10 | maozi-cloud-config-job 11 | 12 | 13 | 14 | 15 | 16 | com.xuxueli 17 | xxl-job-core 18 | ${xxl-job-core.version} 19 | 20 | 21 | 22 | com.maozi 23 | maozi-cloud-common-result 24 | ${maozi-cloud-common-result.version} 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-aop 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-job/src/main/java/com/maozi/job/XxlJobConfig.java: -------------------------------------------------------------------------------- 1 | package com.maozi.job; 2 | 3 | import com.xxl.job.core.executor.impl.XxlJobSpringExecutor; 4 | import org.springframework.beans.factory.annotation.Value; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | @Configuration 9 | public class XxlJobConfig { 10 | 11 | @Value("${xxl.job.admin.addresses}") 12 | private String adminAddresses; 13 | 14 | @Value("${xxl.job.accessToken}") 15 | private String accessToken; 16 | 17 | @Value("${xxl.job.executor.appname}") 18 | private String appname; 19 | 20 | @Value("${xxl.job.executor.address}") 21 | private String address; 22 | 23 | @Value("${xxl.job.executor.ip}") 24 | private String ip; 25 | 26 | @Value("${xxl.job.executor.port}") 27 | private int port; 28 | 29 | @Value("${xxl.job.executor.logpath}") 30 | private String logPath; 31 | 32 | @Value("${xxl.job.executor.logretentiondays}") 33 | private int logRetentionDays; 34 | 35 | 36 | @Bean 37 | public XxlJobSpringExecutor xxlJobExecutor() { 38 | XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor(); 39 | xxlJobSpringExecutor.setAdminAddresses(adminAddresses); 40 | xxlJobSpringExecutor.setAppname(appname); 41 | xxlJobSpringExecutor.setIp(ip); 42 | xxlJobSpringExecutor.setPort(port); 43 | xxlJobSpringExecutor.setAccessToken(accessToken); 44 | xxlJobSpringExecutor.setLogPath(logPath); 45 | xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays); 46 | return xxlJobSpringExecutor; 47 | } 48 | 49 | 50 | } 51 | -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-lock/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.maozi 8 | maozi-cloud-config 9 | ${parent-revision} 10 | 11 | maozi-cloud-config-lock 12 | 13 | 14 | 15 | 16 | org.redisson 17 | redisson 18 | ${redisson.version} 19 | 20 | 21 | 22 | org.springframework.boot 23 | spring-boot-starter-aop 24 | 25 | 26 | 27 | 28 | com.maozi 29 | maozi-cloud-common-result 30 | ${maozi-cloud-common-result.version} 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-lock/src/main/java/com/maozi/lock/annotation/Lock.java: -------------------------------------------------------------------------------- 1 | package com.maozi.lock.annotation; 2 | 3 | import com.maozi.lock.error.strategy.impl.LockTimeoutStrategy; 4 | import com.maozi.lock.error.strategy.impl.UnLockTimeoutStrategy; 5 | import com.maozi.lock.lock.LockType; 6 | import java.lang.annotation.ElementType; 7 | import java.lang.annotation.Retention; 8 | import java.lang.annotation.RetentionPolicy; 9 | import java.lang.annotation.Target; 10 | 11 | 12 | @Target(value = {ElementType.METHOD}) 13 | @Retention(value = RetentionPolicy.RUNTIME) 14 | public @interface Lock { 15 | 16 | /** 17 | * 锁的名称 18 | * @return name 19 | */ 20 | String name() default ""; 21 | 22 | /** 23 | * 锁类型,默认可重入锁 24 | * @return lockType 25 | */ 26 | LockType type() default LockType.Reentrant; 27 | 28 | /** 29 | * 尝试加锁,最多等待时间 30 | * @return waitTime 31 | */ 32 | long waitTime() default Long.MIN_VALUE; 33 | 34 | /** 35 | *上锁以后xxx秒自动解锁 36 | * @return leaseTime 37 | */ 38 | long leaseTime() default Long.MIN_VALUE; 39 | 40 | /** 41 | * 自定义业务key 42 | * @return keys 43 | */ 44 | String [] keys() default {}; 45 | 46 | /** 47 | * 加锁超时的处理策略 48 | * @return lockTimeoutStrategy 49 | */ 50 | LockTimeoutStrategy lockTimeoutStrategy() default LockTimeoutStrategy.KEEP_ACQUIRE; 51 | 52 | /** 53 | * 释放锁时已超时的处理策略 54 | * @return releaseTimeoutStrategy 55 | */ 56 | UnLockTimeoutStrategy releaseTimeoutStrategy() default UnLockTimeoutStrategy.NO_OPERATION; 57 | 58 | } -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-lock/src/main/java/com/maozi/lock/annotation/LockKey.java: -------------------------------------------------------------------------------- 1 | package com.maozi.lock.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Retention(value = RetentionPolicy.RUNTIME) 9 | @Target(value = {ElementType.PARAMETER, ElementType.TYPE}) 10 | public @interface LockKey { 11 | 12 | String value() default ""; 13 | 14 | } -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-lock/src/main/java/com/maozi/lock/config/RedissonConfig.java: -------------------------------------------------------------------------------- 1 | package com.maozi.lock.config; 2 | 3 | import com.maozi.common.BaseCommon; 4 | import com.maozi.lock.properties.LockProperties; 5 | import io.netty.channel.nio.NioEventLoopGroup; 6 | import javax.annotation.Resource; 7 | import org.redisson.Redisson; 8 | import org.redisson.api.RedissonClient; 9 | import org.redisson.config.Config; 10 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; 11 | import org.springframework.context.annotation.Bean; 12 | import org.springframework.context.annotation.Configuration; 13 | 14 | @Configuration 15 | public class RedissonConfig { 16 | 17 | @Resource 18 | private LockProperties properties; 19 | 20 | @Bean(destroyMethod = "shutdown") 21 | @ConditionalOnMissingBean 22 | public RedissonClient redisson() throws Exception { 23 | 24 | Config config = new Config(); 25 | 26 | if(BaseCommon.isNotNull(properties.getNodeAddresses())){ 27 | config.useClusterServers().setPassword(properties.getPassword()).addNodeAddress(properties.getNodeAddresses()); 28 | }else { 29 | config.useSingleServer().setAddress(properties.getAddress()).setDatabase(properties.getDatabase()).setPassword(properties.getPassword()); 30 | } 31 | 32 | config.setEventLoopGroup(new NioEventLoopGroup()); 33 | 34 | return Redisson.create(config); 35 | 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-lock/src/main/java/com/maozi/lock/error/strategy/LockTimeoutHandler.java: -------------------------------------------------------------------------------- 1 | package com.maozi.lock.error.strategy; 2 | 3 | import com.maozi.lock.lock.Lock; 4 | 5 | public interface LockTimeoutHandler { 6 | 7 | void handle(String key,Long waitTime,Long leaseTime,Lock lock) throws Exception ; 8 | 9 | } -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-lock/src/main/java/com/maozi/lock/error/strategy/UnLockTimeoutHandler.java: -------------------------------------------------------------------------------- 1 | package com.maozi.lock.error.strategy; 2 | 3 | public interface UnLockTimeoutHandler { 4 | 5 | void handle(); 6 | 7 | } -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-lock/src/main/java/com/maozi/lock/error/strategy/impl/LockTimeoutStrategy.java: -------------------------------------------------------------------------------- 1 | package com.maozi.lock.error.strategy.impl; 2 | 3 | import com.maozi.base.error.code.SystemErrorCode; 4 | import com.maozi.common.result.error.exception.BusinessResultException; 5 | import com.maozi.lock.error.strategy.LockTimeoutHandler; 6 | import com.maozi.lock.lock.Lock; 7 | import java.util.concurrent.TimeUnit; 8 | 9 | public enum LockTimeoutStrategy implements LockTimeoutHandler { 10 | 11 | FAIL_FAST() { 12 | @Override 13 | public void handle(String key,Long waitTime,Long leaseTime,Lock lock) throws Exception { 14 | throw new BusinessResultException(SystemErrorCode.CURRENT_LIMITING_ERROR,429); 15 | } 16 | }, 17 | 18 | KEEP_ACQUIRE() { 19 | 20 | private final Long DEFAULT_INTERVAL = 100L; 21 | 22 | private final Long DEFAULT_MAX_INTERVAL = 3L * 60L * 1000L; 23 | 24 | @Override 25 | public void handle(String key,Long waitTime,Long leaseTime,Lock lock) throws Exception { 26 | 27 | Long interval = DEFAULT_INTERVAL; 28 | 29 | while (!lock.lock(key,waitTime,leaseTime)) { 30 | 31 | if (interval > DEFAULT_MAX_INTERVAL) { 32 | throw new BusinessResultException(SystemErrorCode.CURRENT_LIMITING_ERROR,429); 33 | } 34 | 35 | TimeUnit.MILLISECONDS.sleep(interval); 36 | 37 | interval <<= 1; 38 | 39 | } 40 | 41 | } 42 | 43 | } 44 | 45 | } -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-lock/src/main/java/com/maozi/lock/error/strategy/impl/UnLockTimeoutStrategy.java: -------------------------------------------------------------------------------- 1 | package com.maozi.lock.error.strategy.impl; 2 | 3 | import com.maozi.base.error.code.SystemErrorCode; 4 | import com.maozi.common.result.error.exception.BusinessResultException; 5 | import com.maozi.lock.error.strategy.UnLockTimeoutHandler; 6 | 7 | public enum UnLockTimeoutStrategy implements UnLockTimeoutHandler { 8 | 9 | NO_OPERATION() { 10 | 11 | @Override 12 | public void handle() {} 13 | 14 | }, 15 | 16 | FAIL_FAST() { 17 | 18 | @Override 19 | public void handle() { 20 | throw new BusinessResultException(SystemErrorCode.CURRENT_LIMITING_ERROR,429); 21 | } 22 | 23 | } 24 | 25 | } -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-lock/src/main/java/com/maozi/lock/lock/Lock.java: -------------------------------------------------------------------------------- 1 | package com.maozi.lock.lock; 2 | 3 | public interface Lock { 4 | 5 | boolean lock(String key,Long waitTime,Long leaseTime) throws Exception; 6 | 7 | boolean unLock(String key) throws Exception; 8 | 9 | } -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-lock/src/main/java/com/maozi/lock/lock/impl/FairLock.java: -------------------------------------------------------------------------------- 1 | package com.maozi.lock.lock.impl; 2 | 3 | import com.maozi.lock.lock.Lock; 4 | import java.util.concurrent.TimeUnit; 5 | import javax.annotation.Resource; 6 | import org.redisson.api.RLock; 7 | import org.redisson.api.RedissonClient; 8 | import org.springframework.stereotype.Component; 9 | 10 | @Component 11 | public class FairLock implements Lock { 12 | 13 | @Resource 14 | private RedissonClient redissonClient; 15 | 16 | @Override 17 | public boolean lock(String key,Long waitTime,Long leaseTime) throws Exception { 18 | return redissonClient.getFairLock(key).tryLock(waitTime,leaseTime,TimeUnit.SECONDS); 19 | } 20 | 21 | @Override 22 | public boolean unLock(String key) throws Exception { 23 | 24 | RLock lock = redissonClient.getFairLock(key); 25 | 26 | return lock.isHeldByCurrentThread() ? lock.forceUnlockAsync().get() : false; 27 | 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-lock/src/main/java/com/maozi/lock/lock/impl/ReadLock.java: -------------------------------------------------------------------------------- 1 | package com.maozi.lock.lock.impl; 2 | 3 | import com.maozi.lock.lock.Lock; 4 | import java.util.concurrent.TimeUnit; 5 | import javax.annotation.Resource; 6 | import org.redisson.api.RReadWriteLock; 7 | import org.redisson.api.RedissonClient; 8 | import org.springframework.stereotype.Component; 9 | 10 | @Component 11 | public class ReadLock implements Lock { 12 | 13 | @Resource 14 | private RedissonClient redissonClient; 15 | 16 | @Override 17 | public boolean lock(String key,Long waitTime,Long leaseTime) throws Exception { 18 | return redissonClient.getReadWriteLock(key).readLock().tryLock(waitTime,leaseTime,TimeUnit.SECONDS); 19 | } 20 | 21 | @Override 22 | public boolean unLock(String key) throws Exception { 23 | 24 | RReadWriteLock lock = redissonClient.getReadWriteLock(key); 25 | 26 | return lock.readLock().isHeldByCurrentThread() ? lock.readLock().forceUnlockAsync().get() : false; 27 | 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-lock/src/main/java/com/maozi/lock/lock/impl/ReentrantLock.java: -------------------------------------------------------------------------------- 1 | package com.maozi.lock.lock.impl; 2 | 3 | import com.maozi.lock.lock.Lock; 4 | import java.util.concurrent.TimeUnit; 5 | import javax.annotation.Resource; 6 | import org.redisson.api.RLock; 7 | import org.redisson.api.RedissonClient; 8 | import org.springframework.stereotype.Component; 9 | 10 | @Component 11 | public class ReentrantLock implements Lock { 12 | 13 | @Resource 14 | private RedissonClient redissonClient; 15 | 16 | @Override 17 | public boolean lock(String key,Long waitTime,Long leaseTime) throws Exception { 18 | return redissonClient.getLock(key).tryLock(waitTime,leaseTime,TimeUnit.SECONDS); 19 | } 20 | 21 | @Override 22 | public boolean unLock(String key) throws Exception { 23 | 24 | RLock lock = redissonClient.getLock(key); 25 | 26 | return lock.isHeldByCurrentThread() ? lock.forceUnlockAsync().get() : false; 27 | 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-lock/src/main/java/com/maozi/lock/lock/impl/WriteLock.java: -------------------------------------------------------------------------------- 1 | package com.maozi.lock.lock.impl; 2 | 3 | import com.maozi.lock.lock.Lock; 4 | import java.util.concurrent.TimeUnit; 5 | import javax.annotation.Resource; 6 | import org.redisson.api.RReadWriteLock; 7 | import org.redisson.api.RedissonClient; 8 | import org.springframework.stereotype.Component; 9 | 10 | @Component 11 | public class WriteLock implements Lock { 12 | 13 | @Resource 14 | private RedissonClient redissonClient; 15 | 16 | @Override 17 | public boolean lock(String key,Long waitTime,Long leaseTime) throws Exception { 18 | return redissonClient.getReadWriteLock(key).writeLock().tryLock(waitTime,leaseTime,TimeUnit.SECONDS); 19 | } 20 | 21 | @Override 22 | public boolean unLock(String key) throws Exception { 23 | 24 | RReadWriteLock lock = redissonClient.getReadWriteLock(key); 25 | 26 | return lock.writeLock().isHeldByCurrentThread() ? lock.writeLock().forceUnlockAsync().get() : false; 27 | 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-lock/src/main/java/com/maozi/lock/properties/LockProperties.java: -------------------------------------------------------------------------------- 1 | package com.maozi.lock.properties; 2 | 3 | import lombok.Data; 4 | import org.springframework.boot.context.properties.ConfigurationProperties; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | @Data 8 | @Configuration 9 | @ConfigurationProperties(prefix = "spring.lock") 10 | public class LockProperties { 11 | 12 | private String address; 13 | 14 | private String password; 15 | 16 | private int database = 0; 17 | 18 | private String[] nodeAddresses; 19 | 20 | private long waitTime = 60; 21 | 22 | private long leaseTime = 60; 23 | 24 | } -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-log/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | com.maozi 7 | maozi-cloud-config 8 | ${parent-revision} 9 | 10 | maozi-cloud-config-log 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | com.maozi 19 | maozi-cloud-common-result 20 | ${maozi-cloud-common-result.version} 21 | 22 | 23 | 24 | com.maozi 25 | maozi-cloud-config-oauth 26 | ${maozi-cloud-config-oauth.version} 27 | 28 | 29 | 30 | com.maozi 31 | maozi-cloud-config-sentinel 32 | ${maozi-cloud-config-sentinel.version} 33 | 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-starter-aop 38 | 39 | 40 | 41 | org.codehaus.janino 42 | janino 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-log/src/main/java/com/maozi/log/config/TtlMDCAdapterInitializer.java: -------------------------------------------------------------------------------- 1 | package com.maozi.log.config; 2 | 3 | import org.slf4j.TtlMDCAdapter; 4 | import org.springframework.context.ApplicationContextInitializer; 5 | import org.springframework.context.ConfigurableApplicationContext; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | @Configuration 9 | public class TtlMDCAdapterInitializer implements ApplicationContextInitializer { 10 | 11 | @Override 12 | public void initialize(ConfigurableApplicationContext configurableApplicationContext) { 13 | TtlMDCAdapter.getInstance(); 14 | } 15 | 16 | } -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-log/src/main/java/com/maozi/log/convert/ApplicationNameMessageConverter.java: -------------------------------------------------------------------------------- 1 | package com.maozi.log.convert; 2 | 3 | import ch.qos.logback.classic.pattern.MessageConverter; 4 | import ch.qos.logback.classic.spi.ILoggingEvent; 5 | import com.maozi.utils.context.ApplicationEnvironmentContext; 6 | 7 | public class ApplicationNameMessageConverter extends MessageConverter { 8 | @Override 9 | public String convert(ILoggingEvent event) { 10 | return ApplicationEnvironmentContext.APPLICATION_NAME; 11 | } 12 | } -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-log/src/main/java/com/maozi/log/convert/EnvironmentMessageConverter.java: -------------------------------------------------------------------------------- 1 | package com.maozi.log.convert; 2 | 3 | import ch.qos.logback.classic.pattern.MessageConverter; 4 | import ch.qos.logback.classic.spi.ILoggingEvent; 5 | import com.maozi.utils.context.ApplicationEnvironmentContext; 6 | 7 | public class EnvironmentMessageConverter extends MessageConverter { 8 | @Override 9 | public String convert(ILoggingEvent event) { 10 | return ApplicationEnvironmentContext.ENVIRONMENT; 11 | } 12 | } -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-monitor/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | com.maozi 7 | maozi-cloud-config 8 | ${parent-revision} 9 | 10 | maozi-cloud-config-monitor 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | com.maozi 19 | maozi-cloud-common-result 20 | ${maozi-cloud-common-result.version} 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | de.codecentric 29 | spring-boot-admin-starter-client 30 | ${spring-boot-admin-starter.version} 31 | 32 | 33 | 34 | io.micrometer 35 | micrometer-registry-prometheus 36 | 37 | 38 | 39 | com.taobao.arthas 40 | arthas-spring-boot-starter 41 | ${arthas.version} 42 | 43 | 44 | 45 | org.jolokia 46 | jolokia-core 47 | 48 | 49 | 50 | com.maozi 51 | maozi-cloud-service-base-rest-api 52 | ${maozi-cloud-service-base-rest-api.version} 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-monitor/src/main/java/com/maozi/health/api/impl/rest/RestErrorLog.java: -------------------------------------------------------------------------------- 1 | package com.maozi.health.api.impl.rest; 2 | 3 | import com.maozi.base.annotation.Post; 4 | import com.maozi.base.annotation.RestService; 5 | import com.maozi.base.error.code.SystemErrorCode; 6 | import com.maozi.common.BaseCommon; 7 | import com.maozi.common.result.AbstractBaseResult; 8 | import io.swagger.v3.oas.annotations.tags.Tag; 9 | import org.springframework.web.bind.annotation.PathVariable; 10 | 11 | @RestService 12 | @Tag(name = "【全局】告警日志") 13 | public class RestErrorLog extends BaseCommon { 14 | 15 | private static final String PATH = "/application/error/log"; 16 | 17 | @Post(value = PATH + "/{id}/remove",description = "删除") 18 | public AbstractBaseResult remove(@PathVariable String id) { 19 | adminHealthError.remove(id); 20 | return success(null); 21 | } 22 | 23 | @Post(value = PATH + "/removeAll",description = "清空") 24 | public AbstractBaseResult removeAll() { 25 | adminHealthError.clear(); 26 | return success(null); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-oauth/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | com.maozi 7 | maozi-cloud-config 8 | ${parent-revision} 9 | 10 | maozi-cloud-config-oauth 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | org.springframework.cloud 19 | spring-cloud-starter-oauth2 20 | ${spring-cloud-starter-oauth2.version} 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | com.maozi 29 | maozi-cloud-config-dubbo 30 | ${maozi-cloud-config-dubbo.version} 31 | 32 | 33 | 34 | com.maozi 35 | maozi-cloud-service-rpc-api-oauth-token 36 | ${maozi-cloud-service-rpc-api-oauth-token.version} 37 | 38 | 39 | 40 | com.maozi 41 | maozi-cloud-service-rest-api-oauth-token 42 | ${maozi-cloud-service-rest-api-oauth-token.version} 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-oauth/src/main/java/com/maozi/oauth/config/IAccessDeniedHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package com.maozi.oauth.config; 19 | 20 | import com.maozi.base.error.code.SystemErrorCode; 21 | import com.maozi.common.BaseCommon; 22 | import com.maozi.utils.MapperUtils; 23 | import javax.servlet.http.HttpServletRequest; 24 | import javax.servlet.http.HttpServletResponse; 25 | import org.springframework.security.access.AccessDeniedException; 26 | import org.springframework.security.web.access.AccessDeniedHandler; 27 | 28 | public class IAccessDeniedHandler extends BaseCommon implements AccessDeniedHandler { 29 | 30 | //权限错误显示 31 | private Integer errorCode = 403; 32 | 33 | @Override 34 | public void handle(HttpServletRequest request, HttpServletResponse response,AccessDeniedException accessDeniedException){ 35 | MapperUtils.setResponseBody(response, error(getCodes().PERMISSION_ERROR,errorCode).autoIdentifyHttpCode()); 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-oauth/src/main/java/com/maozi/oauth/config/IAuthenticationEntryPoint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package com.maozi.oauth.config; 19 | 20 | import com.maozi.base.CodeData; 21 | import com.maozi.base.error.code.SystemErrorCode; 22 | import com.maozi.common.BaseCommon; 23 | import com.maozi.common.result.AbstractBaseResult; 24 | import com.maozi.utils.MapperUtils; 25 | import javax.servlet.ServletException; 26 | import javax.servlet.http.HttpServletRequest; 27 | import javax.servlet.http.HttpServletResponse; 28 | import org.springframework.security.core.AuthenticationException; 29 | import org.springframework.security.web.AuthenticationEntryPoint; 30 | 31 | public class IAuthenticationEntryPoint extends BaseCommon implements AuthenticationEntryPoint { 32 | 33 | private Integer errorCode = 401; 34 | 35 | @Override 36 | public void commence(HttpServletRequest request,HttpServletResponse response,AuthenticationException authException) throws ServletException { 37 | 38 | try { 39 | 40 | String errorMessage = "Full authentication is required to access this resource".equals(authException.getMessage()) ? "未携带Token" : authException.getMessage(); 41 | 42 | AbstractBaseResult error = error(new CodeData(errorCode,errorMessage),errorCode).autoIdentifyHttpCode(); 43 | 44 | MapperUtils.setResponseBody(response,error); 45 | 46 | } catch (Exception e) { 47 | 48 | BaseCommon.error(e); 49 | 50 | throw new ServletException(); 51 | 52 | } 53 | 54 | } 55 | 56 | } -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-oauth/src/main/java/com/maozi/oauth/config/IRequestRejectedHandler.java: -------------------------------------------------------------------------------- 1 | package com.maozi.oauth.config; 2 | 3 | import com.maozi.base.error.code.SystemErrorCode; 4 | import com.maozi.common.BaseCommon; 5 | import com.maozi.utils.MapperUtils; 6 | import javax.servlet.http.HttpServletRequest; 7 | import javax.servlet.http.HttpServletResponse; 8 | import org.springframework.context.annotation.Configuration; 9 | import org.springframework.security.web.firewall.RequestRejectedException; 10 | import org.springframework.security.web.firewall.RequestRejectedHandler; 11 | 12 | @Configuration 13 | public class IRequestRejectedHandler extends BaseCommon implements RequestRejectedHandler { 14 | 15 | private Integer errorCode = 402; 16 | 17 | @Override 18 | public void handle(HttpServletRequest request, HttpServletResponse response,RequestRejectedException ex){ 19 | MapperUtils.setResponseBody(response,error(getCodes().MALICE_REQUEST_ERROR,errorCode).autoIdentifyHttpCode()); 20 | } 21 | 22 | } -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-oauth/src/main/java/com/maozi/oauth/properties/ApiWhitelistProperties.java: -------------------------------------------------------------------------------- 1 | package com.maozi.oauth.properties; 2 | 3 | import com.google.common.collect.Lists; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | import lombok.Data; 7 | import org.springframework.beans.factory.annotation.Value; 8 | import org.springframework.stereotype.Component; 9 | 10 | 11 | @Data 12 | @Component 13 | public class ApiWhitelistProperties { 14 | 15 | @Value("${application-project-whitelist:#{null}}") 16 | private List whitelist = Lists.newArrayList(); 17 | 18 | private List defaultWitelist = new ArrayList(){ 19 | 20 | { 21 | add("/oauth/check_token"); 22 | add("/webjars/**"); 23 | 24 | add("/actuator/**"); 25 | add("/application/**"); 26 | 27 | add("/v3/api-docs/**"); 28 | 29 | } 30 | 31 | }; 32 | 33 | } -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-redis/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | com.maozi 7 | maozi-cloud-config 8 | ${parent-revision} 9 | 10 | maozi-cloud-config-redis 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | com.maozi 20 | maozi-cloud-common-result 21 | ${maozi-cloud-common-result.version} 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | org.apache.commons 30 | commons-pool2 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-data-redis 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-redis/src/main/java/com/maozi/redis/RedisTemplateConf.java: -------------------------------------------------------------------------------- 1 | package com.maozi.redis; 2 | 3 | import com.fasterxml.jackson.annotation.PropertyAccessor; 4 | import com.fasterxml.jackson.databind.ObjectMapper; 5 | import org.springframework.cache.annotation.CachingConfigurerSupport; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | import org.springframework.data.redis.connection.RedisConnectionFactory; 9 | import org.springframework.data.redis.core.RedisTemplate; 10 | import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; 11 | import org.springframework.data.redis.serializer.RedisSerializer; 12 | import org.springframework.data.redis.serializer.StringRedisSerializer; 13 | 14 | @Configuration 15 | public class RedisTemplateConf extends CachingConfigurerSupport { 16 | @Bean 17 | public RedisTemplate redisTemplate(RedisConnectionFactory connectionFactory) { 18 | 19 | RedisTemplate redisTemplate = new RedisTemplate<>(); 20 | 21 | redisTemplate.setConnectionFactory(connectionFactory); 22 | 23 | Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class); 24 | 25 | ObjectMapper objectMapper = new ObjectMapper(); 26 | 27 | objectMapper.setVisibility(PropertyAccessor.ALL,com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.ANY); 28 | 29 | objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); 30 | 31 | jackson2JsonRedisSerializer.setObjectMapper(objectMapper); 32 | 33 | redisTemplate.setValueSerializer(jackson2JsonRedisSerializer); 34 | redisTemplate.setHashValueSerializer(jackson2JsonRedisSerializer); 35 | 36 | RedisSerializer redisSerializer = new StringRedisSerializer(); 37 | 38 | redisTemplate.setKeySerializer(redisSerializer); 39 | redisTemplate.setHashKeySerializer(redisSerializer); 40 | 41 | redisTemplate.afterPropertiesSet(); 42 | 43 | return redisTemplate; 44 | 45 | } 46 | } -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-seata/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | com.maozi 7 | maozi-cloud-config 8 | ${parent-revision} 9 | 10 | maozi-cloud-config-seata 11 | 12 | 13 | 14 | 15 | 16 | 17 | com.alibaba.cloud 18 | spring-cloud-starter-alibaba-seata 19 | 20 | 21 | 22 | 23 | 24 | com.maozi 25 | maozi-cloud-seata-do 26 | ${maozi-cloud-seata-do.version} 27 | 28 | 29 | 30 | com.maozi 31 | maozi-cloud-config-db 32 | ${maozi-cloud-config-db.version} 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-sentinel/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | com.maozi 7 | maozi-cloud-config 8 | ${parent-revision} 9 | 10 | maozi-cloud-config-sentinel 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | com.alibaba.csp 19 | sentinel-datasource-nacos 20 | 21 | 22 | 24 | 25 | 26 | com.alibaba.csp 27 | sentinel-apache-dubbo-adapter 28 | ${sentinel-apache-dubbo-adapter.version} 29 | 30 | 31 | 32 | com.alibaba.cloud 33 | spring-cloud-starter-alibaba-sentinel 34 | 35 | 36 | 37 | org.springframework 38 | spring-context 39 | 40 | 41 | 42 | com.maozi 43 | maozi-cloud-common-result 44 | ${maozi-cloud-common-result.version} 45 | 46 | 47 | 48 | com.fasterxml.jackson.dataformat 49 | jackson-dataformat-xml 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-sentinel/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/RuleEntity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2018 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.alibaba.csp.sentinel.dashboard.datasource.entity.rule; 17 | 18 | import com.alibaba.csp.sentinel.slots.block.Rule; 19 | import java.util.Date; 20 | 21 | /** 22 | * @author leyou 23 | */ 24 | public interface RuleEntity { 25 | 26 | Long getId(); 27 | 28 | void setId(Long id); 29 | 30 | String getApp(); 31 | 32 | String getIp(); 33 | 34 | Integer getPort(); 35 | 36 | Date getGmtCreate(); 37 | 38 | Rule toRule(); 39 | } 40 | -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-sentinel/src/main/java/com/maozi/monitor/config/sentinel/CustomUrlBlockHandler.java: -------------------------------------------------------------------------------- 1 | package com.maozi.monitor.config.sentinel; 2 | 3 | import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.BlockExceptionHandler; 4 | import com.alibaba.csp.sentinel.slots.block.BlockException; 5 | import com.maozi.base.error.code.SystemErrorCode; 6 | import com.maozi.common.BaseCommon; 7 | import com.maozi.utils.MapperUtils; 8 | import javax.servlet.http.HttpServletRequest; 9 | import javax.servlet.http.HttpServletResponse; 10 | 11 | 12 | public class CustomUrlBlockHandler extends BaseCommon implements BlockExceptionHandler { 13 | 14 | @Override 15 | public void handle(HttpServletRequest request, HttpServletResponse response, BlockException e) { 16 | MapperUtils.setResponseBody(response,error(getCodes().CURRENT_LIMITING_ERROR).autoIdentifyHttpCode()); 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-sentinel/src/main/java/com/maozi/monitor/config/sentinel/DubboFallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package com.maozi.monitor.config.sentinel; 19 | 20 | import com.alibaba.csp.sentinel.annotation.aspectj.SentinelResourceAspect; 21 | import org.springframework.context.annotation.Bean; 22 | import org.springframework.context.annotation.Configuration; 23 | 24 | @Configuration 25 | public class DubboFallback { 26 | 27 | @Bean 28 | public SentinelResourceAspect sentinelResourceAspect() { 29 | return new SentinelResourceAspect(); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-sentinel/src/main/java/com/maozi/monitor/config/sentinel/IpLimiter.java: -------------------------------------------------------------------------------- 1 | package com.maozi.monitor.config.sentinel; 2 | 3 | import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.RequestOriginParser; 4 | import javax.servlet.http.HttpServletRequest; 5 | import org.springframework.stereotype.Component; 6 | 7 | @Component 8 | public class IpLimiter implements RequestOriginParser { 9 | 10 | @Override 11 | public String parseOrigin(HttpServletRequest request) { 12 | return getIpAddress(request); 13 | } 14 | 15 | public static String getIpAddress(HttpServletRequest request) { 16 | 17 | String ip = request.getHeader("x-forwarded-for"); 18 | 19 | if ("0:0:0:0:0:0:0:1".equals(ip)) { 20 | ip = "127.0.0.1"; 21 | } 22 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 23 | ip = request.getHeader("Proxy-Client-IP"); 24 | } 25 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 26 | ip = request.getHeader("WL-Proxy-Client-IP"); 27 | } 28 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 29 | ip = request.getHeader("HTTP_CLIENT_IP"); 30 | } 31 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 32 | ip = request.getHeader("HTTP_X_FORWARDED_FOR"); 33 | } 34 | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 35 | ip = request.getRemoteAddr(); 36 | } 37 | return ip; 38 | } 39 | 40 | } -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-stream/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | com.maozi 7 | maozi-cloud-config 8 | ${parent-revision} 9 | 10 | maozi-cloud-config-stream 11 | 12 | 13 | 14 | 15 | 16 | org.springframework.boot 17 | spring-boot-starter-aop 18 | 19 | 20 | 21 | com.alibaba.cloud 22 | spring-cloud-starter-stream-rocketmq 23 | 24 | 25 | 26 | 27 | com.maozi 28 | maozi-cloud-common-result 29 | ${maozi-cloud-common-result.version} 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-stream/src/main/java/com/maozi/stream/enums/DelayMessageLevel.java: -------------------------------------------------------------------------------- 1 | package com.maozi.stream.enums; 2 | 3 | import com.maozi.base.BaseEnum; 4 | import lombok.Getter; 5 | import lombok.Setter; 6 | 7 | public enum DelayMessageLevel implements BaseEnum { 8 | 9 | One(0,"1s"),Two(1,"5s"),Three(2,"10s"),Four(3,"30s"),Five(4,"1m"),Six(5,"2m"),Seven(6,"3m"),Eight(7,"4m"),Nine(8,"5m"),Ten(9,"6m"),Eleven(10,"7m"),Twelve(11,"8m"),Thirteen(12,"9m"),Fourteen(13,"10m"),Fifteen(14,"20m"),Sixteen(15,"30m"),Seventeen(16,"1h"),Eighteen(17,"2h"); 10 | 11 | DelayMessageLevel(Integer value,String desc) { 12 | 13 | this.value = value; 14 | 15 | this.desc = desc; 16 | 17 | } 18 | 19 | @Getter 20 | @Setter 21 | private Integer value; 22 | 23 | @Getter 24 | @Setter 25 | private String desc; 26 | 27 | @Override 28 | public String toString() { 29 | return value+"."+desc; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-swagger/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | com.maozi 7 | maozi-cloud-config 8 | ${parent-revision} 9 | 10 | maozi-cloud-config-swagger 11 | 12 | 13 | 14 | 15 | org.springdoc 16 | springdoc-openapi-webmvc-core 17 | ${springdoc-openapi.version} 18 | 19 | 20 | 21 | com.maozi 22 | maozi-cloud-common-result 23 | ${maozi-cloud-common-result.version} 24 | 25 | 26 | 27 | com.maozi 28 | maozi-cloud-base-enum 29 | ${maozi-cloud-base-enum.version} 30 | 31 | 32 | 33 | com.maozi 34 | maozi-cloud-config-oauth 35 | ${maozi-cloud-config-oauth.version} 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-web/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | com.maozi 7 | maozi-cloud-config 8 | ${parent-revision} 9 | 10 | maozi-cloud-config-web 11 | 12 | 13 | 14 | 15 | 16 | 17 | org.springframework.boot 18 | spring-boot-starter-web 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter-tomcat 23 | 24 | 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-undertow 30 | 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-starter-cache 35 | 36 | 37 | 38 | com.github.ben-manes.caffeine 39 | caffeine 40 | 41 | 42 | 43 | com.alibaba.cloud 44 | spring-cloud-starter-alibaba-nacos-config 45 | 46 | 47 | 48 | 49 | 50 | 51 | com.maozi 52 | maozi-cloud-common-result 53 | ${maozi-cloud-common-result.version} 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-web/src/main/java/com/maozi/mvc/config/cache/CacheConfig.java: -------------------------------------------------------------------------------- 1 | package com.maozi.mvc.config.cache; 2 | 3 | import com.github.benmanes.caffeine.cache.Caffeine; 4 | import java.util.Arrays; 5 | import java.util.concurrent.TimeUnit; 6 | import org.springframework.cache.CacheManager; 7 | import org.springframework.cache.caffeine.CaffeineCacheManager; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.Configuration; 10 | 11 | @Configuration 12 | public class CacheConfig { 13 | 14 | @Bean 15 | public CacheManager globalCacheManager() { 16 | 17 | Caffeine caffeine = Caffeine.newBuilder().initialCapacity(100).expireAfterWrite(600, TimeUnit.SECONDS).recordStats(); 18 | 19 | CaffeineCacheManager caffeineCacheManager = new CaffeineCacheManager(); 20 | 21 | caffeineCacheManager.setAllowNullValues(true); 22 | 23 | caffeineCacheManager.setCaffeine(caffeine); 24 | 25 | caffeineCacheManager.setCacheNames(Arrays.asList("GlobeCache", "CacheAll")); 26 | 27 | return caffeineCacheManager; 28 | 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-web/src/main/java/com/maozi/mvc/config/code/CodeConfig.java: -------------------------------------------------------------------------------- 1 | package com.maozi.mvc.config.code; 2 | 3 | import com.maozi.base.AbstractBaseCode; 4 | import com.maozi.base.CodeData; 5 | import com.maozi.base.error.code.SystemErrorCode; 6 | import com.maozi.common.BaseCommon; 7 | import com.maozi.utils.SpringUtil; 8 | import java.lang.reflect.Field; 9 | import java.util.HashMap; 10 | import java.util.Map; 11 | import lombok.Data; 12 | import org.springframework.stereotype.Component; 13 | 14 | @Data 15 | @Component 16 | public class CodeConfig { 17 | 18 | public static Map codes = new HashMap(); 19 | 20 | public CodeConfig(){ 21 | initCode(); 22 | } 23 | 24 | private void initCode(){ 25 | 26 | Map codeBeans = SpringUtil.getBeansOfType(AbstractBaseCode.class); 27 | 28 | for(AbstractBaseCode codeBean : codeBeans.values()){ 29 | 30 | try { 31 | 32 | for(Field field : codeBean.getClass().getDeclaredFields()){ 33 | 34 | field.setAccessible(true); 35 | 36 | if(field.get(codeBean) instanceof CodeData codeData){ 37 | codes.put(codeData.getCode(),codeData); 38 | } 39 | 40 | } 41 | 42 | } catch (Exception e) { 43 | BaseCommon.error(e); 44 | } 45 | 46 | } 47 | 48 | } 49 | 50 | public static CodeData getCode(Integer code) { 51 | 52 | CodeData codeData = codes.get(code); 53 | 54 | return BaseCommon.isNull(codeData) ? SystemErrorCode.NOT_EXIST_CODE_ERROR : codeData; 55 | 56 | } 57 | } -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-web/src/main/java/com/maozi/mvc/config/enums/EnumConfig.java: -------------------------------------------------------------------------------- 1 | package com.maozi.mvc.config.enums; 2 | 3 | import cn.hutool.core.util.ClassUtil; 4 | import com.google.common.collect.Lists; 5 | import com.maozi.base.BaseEnum; 6 | import com.maozi.utils.context.ApplicationEnvironmentContext; 7 | import java.util.HashMap; 8 | import java.util.List; 9 | import java.util.Map; 10 | import lombok.Data; 11 | import org.springframework.stereotype.Component; 12 | 13 | @Data 14 | @Component 15 | public class EnumConfig { 16 | 17 | public static Map> enums = new HashMap>(); 18 | 19 | public EnumConfig(){ 20 | 21 | initEnum("com.maozi.base.enums"); 22 | 23 | initEnum("com.maozi."+ ApplicationEnvironmentContext.applicationProjectAbbreviation); 24 | 25 | } 26 | 27 | private void initEnum(String packageName){ 28 | 29 | ClassUtil.scanPackage(packageName).stream() 30 | 31 | .forEach(item -> { 32 | 33 | if (item.isEnum()) { 34 | 35 | BaseEnum[] enumConstants = (BaseEnum[]) item.getEnumConstants(); 36 | 37 | char[] charArray = item.getSimpleName().toCharArray(); 38 | 39 | charArray[0] += 32; 40 | 41 | enums.put(new String(charArray), Lists.newArrayList(enumConstants)); 42 | 43 | } 44 | 45 | }); 46 | 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-web/src/main/java/com/maozi/mvc/config/json/JacksonConfig.java: -------------------------------------------------------------------------------- 1 | package com.maozi.mvc.config.json; 2 | 3 | import cn.hutool.core.util.ClassUtil; 4 | import com.fasterxml.jackson.annotation.JsonFormat; 5 | import com.fasterxml.jackson.databind.ObjectMapper; 6 | import com.maozi.utils.MapperUtils; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; 10 | import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; 11 | 12 | @Configuration 13 | public class JacksonConfig { 14 | 15 | @Bean 16 | public ObjectMapper jacksonObjectMapper(Jackson2ObjectMapperBuilder builder) { 17 | 18 | ObjectMapper objectMapper = builder.createXmlMapper(false).build(); 19 | 20 | MapperUtils.setObjectMapperConfig(objectMapper); 21 | 22 | return objectMapper; 23 | 24 | } 25 | 26 | @Bean 27 | public MappingJackson2HttpMessageConverter httpMessageConverter(ObjectMapper objectMapper) { 28 | 29 | ClassUtil.scanPackage("com.maozi").stream().forEach(item -> { 30 | 31 | if(item.isEnum()) { 32 | objectMapper.configOverride(item).setFormat(JsonFormat.Value.forShape(JsonFormat.Shape.OBJECT)); 33 | } 34 | 35 | }); 36 | 37 | return new MappingJackson2HttpMessageConverter(objectMapper); 38 | 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-web/src/main/java/com/maozi/mvc/config/rest/RestTemplateConfig.java: -------------------------------------------------------------------------------- 1 | package com.maozi.mvc.config.rest; 2 | 3 | import java.io.IOException; 4 | import org.springframework.boot.web.client.RestTemplateBuilder; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.http.client.ClientHttpResponse; 8 | import org.springframework.http.client.OkHttp3ClientHttpRequestFactory; 9 | import org.springframework.web.client.AsyncRestTemplate; 10 | import org.springframework.web.client.DefaultResponseErrorHandler; 11 | import org.springframework.web.client.RestTemplate; 12 | 13 | 14 | @Configuration 15 | public class RestTemplateConfig { 16 | 17 | @Bean 18 | // @SentinelRestTemplate(fallback = "fallback", fallbackClass = 19 | // BaseResultFactory.class, 20 | // blockHandler="handleException",blockHandlerClass=BaseResultFactory.class) 21 | public RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder) { 22 | com.maozi.mvc.config.rest.RestTemplate restTemplate = restTemplateBuilder.build(com.maozi.mvc.config.rest.RestTemplate.class); 23 | restTemplate.setRequestFactory(new OkHttp3ClientHttpRequestFactory()); 24 | restTemplate.setErrorHandler(new DefaultResponseErrorHandler() { 25 | @Override 26 | public void handleError(ClientHttpResponse response) throws IOException { 27 | if (response.getRawStatusCode() != 400) { 28 | super.handleError(response); 29 | } 30 | } 31 | }); 32 | return restTemplate; 33 | } 34 | 35 | @Bean 36 | public AsyncRestTemplate asyncRestTemplate(RestTemplateBuilder restTemplateBuilder) { 37 | return new AsyncRestTemplate(new OkHttp3ClientHttpRequestFactory(), restTemplate(restTemplateBuilder)); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-web/src/main/java/com/maozi/mvc/config/rest/WebConfig.java: -------------------------------------------------------------------------------- 1 | package com.maozi.mvc.config.rest; 2 | 3 | import com.fasterxml.jackson.databind.ObjectMapper; 4 | import com.maozi.mvc.config.json.ReadOnlyMultipartFormDataEndpointConverter; 5 | import com.maozi.mvc.filter.ApplicationLinkContextFilter; 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | import javax.annotation.Resource; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.http.MediaType; 11 | import org.springframework.http.converter.HttpMessageConverter; 12 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; 13 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 14 | 15 | @Configuration 16 | public class WebConfig implements WebMvcConfigurer { 17 | 18 | @Resource 19 | private ObjectMapper objectMapper; 20 | 21 | @Resource 22 | private ApplicationLinkContextFilter applicationLinkContextFilter; 23 | 24 | @Override 25 | public void addInterceptors(InterceptorRegistry registry) { 26 | registry.addInterceptor(applicationLinkContextFilter).addPathPatterns("/**").order(Integer.MIN_VALUE); 27 | } 28 | 29 | @Override 30 | public void extendMessageConverters(List> converters) { 31 | 32 | ReadOnlyMultipartFormDataEndpointConverter converter = new ReadOnlyMultipartFormDataEndpointConverter(objectMapper); 33 | 34 | List supportedMediaTypes = new ArrayList<>(); 35 | 36 | supportedMediaTypes.addAll(converter.getSupportedMediaTypes()); 37 | 38 | supportedMediaTypes.add(MediaType.APPLICATION_OCTET_STREAM); 39 | 40 | converter.setSupportedMediaTypes(supportedMediaTypes); 41 | 42 | converters.add(converter); 43 | 44 | } 45 | 46 | } -------------------------------------------------------------------------------- /maozi-cloud-config/maozi-cloud-config-web/src/main/java/com/maozi/mvc/filter/ApplicationLinkContextFilter.java: -------------------------------------------------------------------------------- 1 | package com.maozi.mvc.filter; 2 | 3 | import com.maozi.common.BaseCommon; 4 | import com.maozi.utils.context.ApplicationLinkContext; 5 | import javax.servlet.http.HttpServletRequest; 6 | import javax.servlet.http.HttpServletResponse; 7 | import org.springframework.context.annotation.Configuration; 8 | import org.springframework.lang.Nullable; 9 | import org.springframework.security.core.Authentication; 10 | import org.springframework.security.core.context.SecurityContextHolder; 11 | import org.springframework.web.servlet.HandlerInterceptor; 12 | 13 | @Configuration 14 | public class ApplicationLinkContextFilter implements HandlerInterceptor { 15 | 16 | @Override 17 | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { 18 | 19 | Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); 20 | 21 | String username = (BaseCommon.isNull(authentication) || !authentication.isAuthenticated()) ? "anonymousUser" : authentication.getName(); 22 | 23 | String version = BaseCommon.getVersionDefault(request.getHeader("Version")); 24 | 25 | ApplicationLinkContext.set(version,username); 26 | 27 | return true; 28 | 29 | } 30 | 31 | @Override 32 | public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler,@Nullable Exception ex) throws Exception { 33 | BaseCommon.clearContext(); 34 | } 35 | 36 | } -------------------------------------------------------------------------------- /maozi-cloud-config/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | com.maozi 5 | maozi-cloud-parent 6 | ${parent-revision} 7 | 8 | maozi-cloud-config 9 | pom 10 | 11 | 12 | maozi-cloud-config-feign 13 | maozi-cloud-config-monitor 14 | maozi-cloud-config-sentinel 15 | maozi-cloud-config-db 16 | maozi-cloud-config-log 17 | maozi-cloud-config-oauth 18 | maozi-cloud-config-web 19 | maozi-cloud-config-seata 20 | maozi-cloud-config-job 21 | maozi-cloud-config-dubbo 22 | maozi-cloud-config-redis 23 | maozi-cloud-config-discovery 24 | maozi-cloud-config-stream 25 | maozi-cloud-config-swagger 26 | maozi-cloud-config-lock 27 | 28 | 29 | -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-base-entity/maozi-cloud-base-do/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 4.0.0 6 | 7 | com.maozi 8 | maozi-cloud-base-entity 9 | ${parent-revision} 10 | 11 | maozi-cloud-base-do 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | com.baomidou 20 | mybatis-plus-annotation 21 | ${mybatis-plus.version} 22 | 23 | 24 | 25 | org.mybatis 26 | mybatis 27 | ${mybatis.version} 28 | 29 | 30 | 31 | 32 | com.maozi 33 | maozi-cloud-base-enum 34 | ${maozi-cloud-base-enum.version} 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-base-entity/maozi-cloud-base-do/src/main/java/com/maozi/base/AbstractBaseNameDomain.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.maozi.base; 18 | 19 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 20 | import lombok.AllArgsConstructor; 21 | import lombok.Data; 22 | import lombok.NoArgsConstructor; 23 | import lombok.experimental.SuperBuilder; 24 | 25 | @Data 26 | @NoArgsConstructor 27 | @AllArgsConstructor 28 | @SuperBuilder(toBuilder = true) 29 | @JsonIgnoreProperties(ignoreUnknown = true) 30 | public abstract class AbstractBaseNameDomain extends AbstractBaseDomain { 31 | 32 | /** 33 | * 名称 34 | */ 35 | private String name; 36 | 37 | } -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-base-entity/maozi-cloud-base-dto/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | com.maozi 6 | maozi-cloud-base-entity 7 | ${parent-revision} 8 | 9 | maozi-cloud-base-dto 10 | 11 | 12 | 13 | 14 | 15 | com.maozi 16 | maozi-cloud-base-enum 17 | ${maozi-cloud-base-enum.version} 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-base-entity/maozi-cloud-base-dto/src/main/java/com/maozi/base/AbstractBaseDtomain.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | import java.io.Serial; 5 | import java.io.Serializable; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import lombok.experimental.SuperBuilder; 9 | 10 | @Data 11 | @NoArgsConstructor 12 | @SuperBuilder(toBuilder = true) 13 | @JsonIgnoreProperties(ignoreUnknown = true) 14 | public abstract class AbstractBaseDtomain implements Serializable { 15 | 16 | @Serial 17 | protected static final long serialVersionUID = 1L; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-base-entity/maozi-cloud-base-dto/src/main/java/com/maozi/base/param/PageParam.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.param; 2 | 3 | import com.maozi.base.AbstractBaseDtomain; 4 | import io.swagger.v3.oas.annotations.media.Schema; 5 | import javax.validation.Valid; 6 | import lombok.AllArgsConstructor; 7 | import lombok.Data; 8 | import lombok.NoArgsConstructor; 9 | 10 | @Data 11 | @NoArgsConstructor 12 | @AllArgsConstructor 13 | public class PageParam extends AbstractBaseDtomain { 14 | 15 | @Schema(description = "页数",defaultValue = "1") 16 | private Long current = 1L; 17 | 18 | @Schema(description = "每页数量",defaultValue = "10") 19 | private Long size = 10L; 20 | 21 | @Valid 22 | @Schema(description = "查询条件") 23 | private D data; 24 | 25 | } 26 | -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-base-entity/maozi-cloud-base-dto/src/main/java/com/maozi/base/param/SaveUpdateBatch.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.param; 2 | 3 | import com.maozi.base.AbstractBaseDtomain; 4 | import io.swagger.v3.oas.annotations.media.Schema; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | 9 | @Data 10 | @NoArgsConstructor 11 | @AllArgsConstructor 12 | public class SaveUpdateBatch extends AbstractBaseDtomain { 13 | 14 | @Schema(description = "标识") 15 | private Long id; 16 | 17 | } -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-base-entity/maozi-cloud-base-dto/src/main/java/com/maozi/base/param/SearchParam.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.param; 2 | 3 | import com.maozi.base.AbstractBaseDtomain; 4 | import io.swagger.v3.oas.annotations.media.Schema; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | 9 | /** 10 | * 查询入参 11 | */ 12 | @Data 13 | @NoArgsConstructor 14 | @AllArgsConstructor 15 | public class SearchParam extends AbstractBaseDtomain{ 16 | 17 | /** 18 | * 查询条件 19 | */ 20 | @Schema(description = "查询条件") 21 | private D search; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-base-entity/maozi-cloud-base-dto/src/main/java/com/maozi/base/param/ValidCollectionParam.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.param; 2 | 3 | import com.maozi.base.AbstractBaseDtomain; 4 | import java.util.Collection; 5 | import javax.validation.Valid; 6 | import lombok.AllArgsConstructor; 7 | import lombok.Builder; 8 | import lombok.Data; 9 | import lombok.NoArgsConstructor; 10 | 11 | @Data 12 | @Builder 13 | @NoArgsConstructor 14 | @AllArgsConstructor 15 | public class ValidCollectionParam extends AbstractBaseDtomain { 16 | 17 | @Valid 18 | private Collection list; 19 | 20 | } -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-base-entity/maozi-cloud-base-dto/src/main/java/com/maozi/base/param/plugin/TimeParam.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.param.plugin; 2 | 3 | import com.maozi.base.AbstractBaseDtomain; 4 | import io.swagger.v3.oas.annotations.media.Schema; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | 9 | @Data 10 | @NoArgsConstructor 11 | @AllArgsConstructor 12 | public class TimeParam extends AbstractBaseDtomain { 13 | 14 | @Schema(description = "开始时间 时间戳") 15 | private Long startTime; 16 | 17 | @Schema(description = "结束时间 时间戳") 18 | private Long endTime; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-base-entity/maozi-cloud-base-dto/src/main/java/com/maozi/base/plugin/StoreClass.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.plugin; 2 | 3 | import com.google.common.collect.Maps; 4 | import com.maozi.base.enums.StoreClassType; 5 | import java.util.Map; 6 | 7 | public class StoreClass { 8 | 9 | public static Map>> storeClassMap = Maps.newHashMap(); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-base-entity/maozi-cloud-base-dto/src/main/java/com/maozi/base/plugin/join/JoinBaseType.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.plugin.join; 2 | 3 | import lombok.Getter; 4 | 5 | @Getter 6 | public enum JoinBaseType { 7 | 8 | innerJoin("innerJoin","内连接"),leftJoin("leftJoin","左连接"),rightJoin("rightJoin","右连接"); 9 | 10 | JoinBaseType(String type,String name) { 11 | 12 | this.type = type; 13 | 14 | this.name = name; 15 | 16 | } 17 | 18 | private String type; 19 | 20 | private String name; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-base-entity/maozi-cloud-base-dto/src/main/java/com/maozi/base/plugin/join/JoinPlugin.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.plugin.join; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target(ElementType.TYPE) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface JoinPlugin { 11 | 12 | JoinBaseType value(); 13 | 14 | String on() default ""; 15 | 16 | String tableName() default ""; 17 | 18 | String tableAlias() default ""; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-base-entity/maozi-cloud-base-dto/src/main/java/com/maozi/base/plugin/join/JoinPlugins.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.plugin.join; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target(ElementType.TYPE) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface JoinPlugins { 11 | 12 | JoinPlugin [] value(); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-base-entity/maozi-cloud-base-dto/src/main/java/com/maozi/base/plugin/mapping/QueryMapping.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.plugin.mapping; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target(ElementType.FIELD) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface QueryMapping { 11 | 12 | boolean isService() default false; 13 | 14 | String serviceName() default ""; 15 | 16 | String relationField() default ""; 17 | 18 | boolean ignore() default false; 19 | 20 | String functionName() default ""; 21 | 22 | String tableName() default ""; 23 | 24 | String field() default ""; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-base-entity/maozi-cloud-base-dto/src/main/java/com/maozi/base/plugin/query/QueryBaseType.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.plugin.query; 2 | 3 | import lombok.Getter; 4 | 5 | @Getter 6 | public enum QueryBaseType { 7 | 8 | eq("eq","等于"),like("like","模糊查询"),in("in","范围等值查询"),ne("ne","不等于"),ge("ge","大于等于"),le("le","小于等于"); 9 | 10 | QueryBaseType(String type,String name) { 11 | 12 | this.type = type; 13 | 14 | this.name = name; 15 | 16 | } 17 | 18 | private String type; 19 | 20 | private String name; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-base-entity/maozi-cloud-base-dto/src/main/java/com/maozi/base/plugin/query/QueryPlugin.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.plugin.query; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target(ElementType.FIELD) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface QueryPlugin { 11 | 12 | String field() default ""; 13 | 14 | QueryBaseType value(); 15 | 16 | boolean nest() default false; 17 | 18 | String tableName() default ""; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-base-entity/maozi-cloud-base-dto/src/main/java/com/maozi/base/result/DropDownResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package com.maozi.base.result; 19 | 20 | import com.maozi.base.AbstractBaseDtomain; 21 | import io.swagger.v3.oas.annotations.media.Schema; 22 | import lombok.AllArgsConstructor; 23 | import lombok.Data; 24 | import lombok.NoArgsConstructor; 25 | 26 | 27 | 28 | 29 | @Data 30 | @NoArgsConstructor 31 | @AllArgsConstructor 32 | public class DropDownResult extends AbstractBaseDtomain{ 33 | 34 | private Long id; 35 | 36 | @Schema(description = "名称") 37 | private String name; 38 | 39 | } -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-base-entity/maozi-cloud-base-dto/src/main/java/com/maozi/base/result/EnumResult.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.result; 2 | 3 | import com.maozi.base.AbstractBaseDtomain; 4 | import io.swagger.v3.oas.annotations.media.Schema; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Builder; 7 | import lombok.Data; 8 | import lombok.NoArgsConstructor; 9 | 10 | @Data 11 | @Builder 12 | @NoArgsConstructor 13 | @AllArgsConstructor 14 | @Schema(name = "EnumResult") 15 | public class EnumResult extends AbstractBaseDtomain { 16 | 17 | @Schema(description = "枚举编码") 18 | private Integer value; 19 | 20 | @Schema(description = "描述") 21 | private String desc; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-base-entity/maozi-cloud-base-dto/src/main/java/com/maozi/base/result/ListStringResult.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.result; 2 | 3 | import java.util.ArrayList; 4 | import lombok.Data; 5 | 6 | @Data 7 | public class ListStringResult extends ArrayList {} 8 | -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-base-entity/maozi-cloud-base-dto/src/main/java/com/maozi/base/validator/excel/ExcelFile.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.validator.excel; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | import javax.validation.Constraint; 8 | import javax.validation.Payload; 9 | 10 | @Target({ ElementType.FIELD }) 11 | @Retention(RetentionPolicy.RUNTIME) 12 | @Constraint(validatedBy = ExcelFileValidator.class) 13 | public @interface ExcelFile { 14 | 15 | String message() default "非表格类型"; 16 | 17 | Class[] groups() default {}; 18 | 19 | Class[] payload() default {}; 20 | 21 | } -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-base-entity/maozi-cloud-base-dto/src/main/java/com/maozi/base/validator/excel/ExcelFileValidator.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.validator.excel; 2 | 3 | import javax.validation.ConstraintValidator; 4 | import javax.validation.ConstraintValidatorContext; 5 | import org.springframework.web.multipart.MultipartFile; 6 | 7 | public class ExcelFileValidator implements ConstraintValidator { 8 | 9 | @Override 10 | public void initialize(ExcelFile constraintAnnotation) {} 11 | 12 | @Override 13 | public boolean isValid(MultipartFile file, ConstraintValidatorContext context) { 14 | 15 | if(file == null || file.isEmpty()) { 16 | return true; 17 | } 18 | 19 | String contentType = file.getContentType(); 20 | return "application/vnd.ms-excel".equals(contentType) || "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet".equals(contentType); 21 | 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-base-entity/maozi-cloud-base-dto/src/main/java/com/maozi/base/validator/image/ImageFile.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.validator.image; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | import javax.validation.Constraint; 9 | import javax.validation.Payload; 10 | 11 | @Target({ElementType.FIELD}) 12 | @Retention(RetentionPolicy.RUNTIME) 13 | @Documented 14 | @Constraint(validatedBy = ImageFileValidator.class) 15 | public @interface ImageFile { 16 | 17 | String message() default "非图片类型"; 18 | 19 | Class[] groups() default {}; 20 | 21 | Class[] payload() default {}; 22 | 23 | } -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-base-entity/maozi-cloud-base-dto/src/main/java/com/maozi/base/validator/image/ImageFileValidator.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.validator.image; 2 | 3 | import java.util.Objects; 4 | import javax.validation.ConstraintValidator; 5 | import javax.validation.ConstraintValidatorContext; 6 | import org.apache.commons.lang3.StringUtils; 7 | import org.springframework.web.multipart.MultipartFile; 8 | 9 | public class ImageFileValidator implements ConstraintValidator { 10 | 11 | @Override 12 | public void initialize(ImageFile constraintAnnotation) {} 13 | 14 | @Override 15 | public boolean isValid(MultipartFile file, ConstraintValidatorContext context) { 16 | 17 | if(Objects.isNull(file) || file.isEmpty()) { 18 | return true; 19 | } 20 | 21 | String contentType = file.getContentType(); 22 | return StringUtils.isNotEmpty(contentType) && contentType.startsWith("image"); 23 | 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-base-entity/maozi-cloud-base-dto/src/main/java/com/maozi/base/validator/video/VideoFile.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.validator.video; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | import javax.validation.Constraint; 8 | import javax.validation.Payload; 9 | 10 | @Target({ElementType.FIELD}) 11 | @Retention(RetentionPolicy.RUNTIME) 12 | @Constraint(validatedBy = VideoFileValidator.class) 13 | public @interface VideoFile { 14 | 15 | String message() default "非视频类型"; 16 | 17 | Class[] groups() default {}; 18 | 19 | Class[] payload() default {}; 20 | 21 | } -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-base-entity/maozi-cloud-base-dto/src/main/java/com/maozi/base/validator/video/VideoFileValidator.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.validator.video; 2 | 3 | import java.util.Objects; 4 | import javax.validation.ConstraintValidator; 5 | import javax.validation.ConstraintValidatorContext; 6 | import org.apache.commons.lang3.StringUtils; 7 | import org.springframework.web.multipart.MultipartFile; 8 | 9 | public class VideoFileValidator implements ConstraintValidator { 10 | 11 | @Override 12 | public void initialize(VideoFile constraintAnnotation) {} 13 | 14 | @Override 15 | public boolean isValid(MultipartFile file, ConstraintValidatorContext context) { 16 | 17 | if(Objects.isNull(file) || file.isEmpty()) { 18 | return true; 19 | } 20 | 21 | String contentType = file.getContentType(); 22 | return StringUtils.isNotEmpty(contentType) && contentType.startsWith("video/"); 23 | 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-base-entity/maozi-cloud-base-enum/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | com.maozi 5 | maozi-cloud-base-entity 6 | ${parent-revision} 7 | 8 | maozi-cloud-base-enum 9 | 10 | 11 | 12 | 13 | com.baomidou 14 | mybatis-plus-annotation 15 | ${mybatis-plus.version} 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-base-entity/maozi-cloud-base-enum/src/main/java/com/maozi/base/AbstractBaseCode.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base; 2 | 3 | import java.io.Serializable; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @NoArgsConstructor 9 | public class AbstractBaseCode implements Serializable { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-base-entity/maozi-cloud-base-enum/src/main/java/com/maozi/base/BaseEnum.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base; 2 | 3 | import com.baomidou.mybatisplus.annotation.IEnum; 4 | 5 | public interface BaseEnum extends IEnum { 6 | 7 | Integer getValue(); 8 | 9 | String getDesc(); 10 | 11 | } -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-base-entity/maozi-cloud-base-enum/src/main/java/com/maozi/base/CodeData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package com.maozi.base; 19 | 20 | import java.io.Serializable; 21 | import lombok.AllArgsConstructor; 22 | import lombok.Data; 23 | import lombok.NoArgsConstructor; 24 | import lombok.experimental.Accessors; 25 | 26 | @Data 27 | @NoArgsConstructor 28 | @AllArgsConstructor 29 | @Accessors(chain = true) 30 | public class CodeData implements Serializable { 31 | 32 | private static final long serialVersionUID = 7953425100947733968L; 33 | 34 | private Integer code; 35 | 36 | private String targetCode; 37 | 38 | private String message; 39 | 40 | private D data; 41 | 42 | public CodeData(String message) { 43 | this.code = 400; 44 | this.message = message; 45 | } 46 | 47 | public CodeData(Integer code, String message) { 48 | this.code = code; 49 | this.message = message; 50 | } 51 | 52 | public CodeData(Integer code, String message,D data) { 53 | this.code = code; 54 | this.message = message; 55 | this.data = data; 56 | } 57 | 58 | } -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-base-entity/maozi-cloud-base-enum/src/main/java/com/maozi/base/enums/Deleted.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.enums; 2 | 3 | import com.maozi.base.BaseEnum; 4 | import lombok.Getter; 5 | import lombok.Setter; 6 | 7 | public enum Deleted implements BaseEnum { 8 | 9 | none(0,"未删除"),del(1,"已删除"); 10 | 11 | Deleted(Integer value,String desc) { 12 | 13 | this.value = value; 14 | 15 | this.desc = desc; 16 | 17 | } 18 | 19 | @Getter 20 | @Setter 21 | private Integer value; 22 | 23 | @Getter 24 | @Setter 25 | private String desc; 26 | 27 | @Override 28 | public String toString() { 29 | return value+"."+desc; 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-base-entity/maozi-cloud-base-enum/src/main/java/com/maozi/base/enums/EnvironmentType.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.enums; 2 | 3 | import com.maozi.base.BaseEnum; 4 | import lombok.Getter; 5 | import lombok.Setter; 6 | 7 | 8 | 9 | public enum EnvironmentType implements BaseEnum { 10 | 11 | localhost(0,"localhost"),test(1,"test"),production(2,"production"); 12 | 13 | EnvironmentType(Integer value,String desc) { 14 | 15 | this.value = value; 16 | 17 | this.desc = desc; 18 | 19 | } 20 | 21 | @Getter 22 | @Setter 23 | private Integer value; 24 | 25 | @Getter 26 | @Setter 27 | private String desc; 28 | 29 | @Override 30 | public String toString() { 31 | return value+"."+desc; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-base-entity/maozi-cloud-base-enum/src/main/java/com/maozi/base/enums/Status.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.enums; 2 | 3 | import com.maozi.base.BaseEnum; 4 | import lombok.Getter; 5 | import lombok.Setter; 6 | 7 | public enum Status implements BaseEnum { 8 | 9 | disable(0,"禁用"),enable(1,"启用"); 10 | 11 | Status(Integer value,String desc) { 12 | 13 | this.value = value; 14 | 15 | this.desc = desc; 16 | 17 | } 18 | 19 | @Getter 20 | @Setter 21 | private Integer value; 22 | 23 | @Getter 24 | @Setter 25 | private String desc; 26 | 27 | @Override 28 | public String toString() { 29 | return value+"."+desc; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-base-entity/maozi-cloud-base-enum/src/main/java/com/maozi/base/enums/StoreClassType.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.enums; 2 | 3 | import com.maozi.base.BaseEnum; 4 | import lombok.Getter; 5 | import lombok.Setter; 6 | 7 | public enum StoreClassType implements BaseEnum { 8 | 9 | db(0,"数据库"); 10 | 11 | StoreClassType(Integer value,String desc) { 12 | 13 | this.value = value; 14 | 15 | this.desc = desc; 16 | 17 | } 18 | 19 | @Getter 20 | @Setter 21 | private Integer value; 22 | 23 | @Getter 24 | @Setter 25 | private String desc; 26 | 27 | @Override 28 | public String toString() { 29 | return value+"."+desc; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-base-entity/maozi-cloud-base-enum/src/main/java/com/maozi/base/error/code/SystemErrorCode.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.error.code; 2 | 3 | import com.maozi.base.AbstractBaseCode; 4 | import com.maozi.base.CodeData; 5 | import org.springframework.stereotype.Component; 6 | 7 | @Component 8 | public class SystemErrorCode extends AbstractBaseCode { 9 | 10 | public final static CodeData NOT_EXIST_CODE_ERROR = new CodeData(0,"没有此编码"); 11 | 12 | public final static CodeData SERVICE_RPC_ERROR = new CodeData(1,"服务调用失败"); 13 | 14 | public final static CodeData FORBIDDEN_ERROR = new CodeData(2,"已被禁用"); 15 | 16 | public final static CodeData SERVICE_NOT_EXIST_ERROR = new CodeData(3,"服务不存在"); 17 | 18 | public final static CodeData DATA_NOT_EXIST_ERROR = new CodeData(4,"数据不存在"); 19 | 20 | public final static CodeData DATA_EXIST_ERROR = new CodeData(5,"数据已存在"); 21 | 22 | public final static CodeData NOT_SET_RESPONSE_ERROR = new CodeData(6,"服务端未设置返回类型"); 23 | 24 | public final static CodeData PARAM_ERROR = new CodeData(400,"参数错误"); 25 | 26 | public final static CodeData USER_AUTH_ERROR = new CodeData(401,"用户认证错误"); 27 | 28 | public final static CodeData MALICE_REQUEST_ERROR = new CodeData(402,"恶意请求"); 29 | 30 | public final static CodeData PERMISSION_ERROR = new CodeData(403,"权限不足"); 31 | 32 | public final static CodeData NOT_RESOURCE_ERROR = new CodeData(404,"资源不存在"); 33 | 34 | public final static CodeData REQUEST_METHOD_ERROR = new CodeData(405,"请求方法错误"); 35 | 36 | public final static CodeData REQUEST_FORMAT_ERROR = new CodeData(415,"请求格式错误"); 37 | 38 | public final static CodeData CURRENT_LIMITING_ERROR = new CodeData(429,"限流中"); 39 | 40 | public final static CodeData SYSTEM_ERROR = new CodeData(500,"内部服务错误"); 41 | 42 | } 43 | -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-base-entity/maozi-cloud-base-vo/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | com.maozi 6 | maozi-cloud-base-entity 7 | ${parent-revision} 8 | 9 | maozi-cloud-base-vo 10 | 11 | 12 | 13 | 14 | 15 | 16 | com.baomidou 17 | mybatis-plus-extension 18 | ${mybatis-plus.version} 19 | 20 | 21 | 22 | com.maozi 23 | maozi-cloud-base-dto 24 | ${maozi-cloud-base-dto.version} 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-base-entity/maozi-cloud-base-vo/src/main/java/com/maozi/base/AbstractBaseVomain.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.maozi.base; 18 | 19 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 20 | import java.io.Serial; 21 | import java.io.Serializable; 22 | import lombok.Data; 23 | import lombok.NoArgsConstructor; 24 | import lombok.experimental.SuperBuilder; 25 | 26 | @Data 27 | @NoArgsConstructor 28 | @SuperBuilder(toBuilder = true) 29 | @JsonIgnoreProperties(ignoreUnknown = true) 30 | public abstract class AbstractBaseVomain implements Serializable { 31 | 32 | @Serial 33 | protected static final long serialVersionUID = 1L; 34 | 35 | } 36 | -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-base-entity/maozi-cloud-base-vo/src/main/java/com/maozi/base/result/PageResult.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.result; 2 | 3 | import com.maozi.base.AbstractBaseVomain; 4 | import io.swagger.v3.oas.annotations.media.Schema; 5 | import java.util.List; 6 | import javax.validation.Valid; 7 | import lombok.AllArgsConstructor; 8 | import lombok.Data; 9 | import lombok.NoArgsConstructor; 10 | 11 | 12 | @Data 13 | @NoArgsConstructor 14 | @AllArgsConstructor 15 | public class PageResult extends AbstractBaseVomain { 16 | 17 | @Schema(description = "页数") 18 | private Long current; 19 | 20 | @Schema(description = "每页数量") 21 | private Long size; 22 | 23 | @Schema(description = "数据总数") 24 | private Long total; 25 | 26 | @Valid 27 | private List data; 28 | 29 | } -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-base-entity/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 4.0.0 5 | 6 | com.maozi 7 | maozi-cloud-entity 8 | ${parent-revision} 9 | 10 | maozi-cloud-base-entity 11 | pom 12 | 13 | 14 | 15 | 16 | 17 | io.swagger.core.v3 18 | swagger-annotations 19 | ${swagger.version} 20 | 21 | 22 | 23 | 24 | com.maozi 25 | maozi-cloud-common-utils 26 | ${maozi-cloud-common-utils.version} 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | maozi-cloud-base-do 35 | maozi-cloud-base-vo 36 | maozi-cloud-base-dto 37 | maozi-cloud-base-enum 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-business-entity/maozi-cloud-do/maozi-cloud-seata-do/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | com.maozi 5 | maozi-cloud-do 6 | ${parent-revision} 7 | 8 | maozi-cloud-seata-do 9 | -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-business-entity/maozi-cloud-do/maozi-cloud-seata-do/src/main/resources/db/V1.0.0.20240825000000__init.sql: -------------------------------------------------------------------------------- 1 | -- seata undolog 2 | CREATE TABLE undo_log ( 3 | id INT AUTO_INCREMENT PRIMARY KEY COMMENT 'Primary key', 4 | branch_id BIGINT NOT NULL COMMENT 'branch transaction id', 5 | xid VARCHAR(255) NOT NULL COMMENT 'global transaction id', 6 | context VARCHAR(255) COMMENT 'undo_log context, such as serialization', 7 | rollback_info LONGBLOB COMMENT 'rollback info', 8 | log_status INT NOT NULL COMMENT '0: normal status, 1: defense status', 9 | log_created TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT 'create datetime', 10 | log_modified TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'modify datetime' 11 | ) COMMENT='seata_undolog'; -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-business-entity/maozi-cloud-do/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | com.maozi 6 | maozi-cloud-business-entity 7 | ${parent-revision} 8 | 9 | maozi-cloud-do 10 | pom 11 | 12 | 13 | 14 | 15 | 16 | 17 | com.maozi 18 | maozi-cloud-base-do 19 | ${maozi-cloud-base-do.version} 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | maozi-cloud-seata-do 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-business-entity/maozi-cloud-dto/maozi-cloud-oauth-token-dto/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | com.maozi 7 | maozi-cloud-dto 8 | ${parent-revision} 9 | 10 | maozi-cloud-oauth-token-dto 11 | 12 | 13 | 14 | 15 | org.springframework.cloud 16 | spring-cloud-starter-oauth2 17 | ${spring-cloud-starter-oauth2.version} 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-business-entity/maozi-cloud-dto/maozi-cloud-oauth-token-dto/src/main/java/com/maozi/oauth/token/dto/platform/dto/OauthToken.java: -------------------------------------------------------------------------------- 1 | package com.maozi.oauth.token.dto.platform.dto; 2 | 3 | import com.maozi.base.AbstractBaseDtomain; 4 | import io.swagger.v3.oas.annotations.media.Schema; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | 9 | @Data 10 | @NoArgsConstructor 11 | @AllArgsConstructor 12 | public class OauthToken extends AbstractBaseDtomain { 13 | 14 | @Schema(description = "通行令牌") 15 | private String accessToken; 16 | 17 | @Schema(description = "刷新令牌") 18 | private String refreshToken; 19 | 20 | @Schema(description = "通行令牌 过期时间") 21 | private Long accessTokenExpiresTime; 22 | 23 | @Schema(description = "刷新令牌 过期时间") 24 | private Long refreshTokenExpiresTime; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-business-entity/maozi-cloud-dto/maozi-cloud-oauth-token-dto/src/main/java/com/maozi/oauth/token/dto/platform/param/ClientParam.java: -------------------------------------------------------------------------------- 1 | package com.maozi.oauth.token.dto.platform.param; 2 | 3 | import com.maozi.base.AbstractBaseDtomain; 4 | import io.swagger.v3.oas.annotations.media.Schema; 5 | import javax.validation.constraints.NotNull; 6 | import lombok.AllArgsConstructor; 7 | import lombok.Data; 8 | import lombok.NoArgsConstructor; 9 | import lombok.experimental.SuperBuilder; 10 | 11 | @Data 12 | @NoArgsConstructor 13 | @AllArgsConstructor 14 | @SuperBuilder(toBuilder = true) 15 | public class ClientParam extends AbstractBaseDtomain { 16 | 17 | @Schema(description = "客户端ID") 18 | @NotNull(message = "客户端ID不能为空") 19 | private String clientId; 20 | 21 | @Schema(description = "客户端密钥") 22 | @NotNull(message = "客户端密钥不能为空") 23 | private String clientSecret; 24 | 25 | } 26 | -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-business-entity/maozi-cloud-dto/maozi-cloud-oauth-token-dto/src/main/java/com/maozi/oauth/token/dto/platform/param/ClientUserParam.java: -------------------------------------------------------------------------------- 1 | package com.maozi.oauth.token.dto.platform.param; 2 | 3 | import com.maozi.base.AbstractBaseDtomain; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | import lombok.experimental.SuperBuilder; 8 | 9 | @Data 10 | @NoArgsConstructor 11 | @AllArgsConstructor 12 | @SuperBuilder(toBuilder = true) 13 | public class ClientUserParam extends AbstractBaseDtomain { 14 | 15 | private Long clientId; 16 | 17 | private String username; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-business-entity/maozi-cloud-dto/maozi-cloud-oauth-token-dto/src/main/java/com/maozi/oauth/token/dto/platform/param/TokenInfoParam.java: -------------------------------------------------------------------------------- 1 | package com.maozi.oauth.token.dto.platform.param; 2 | 3 | import io.swagger.v3.oas.annotations.media.Schema; 4 | import javax.validation.constraints.NotNull; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import lombok.experimental.SuperBuilder; 9 | 10 | @Data 11 | @NoArgsConstructor 12 | @AllArgsConstructor 13 | @SuperBuilder(toBuilder = true) 14 | public class TokenInfoParam extends ClientParam { 15 | 16 | @Schema(description = "用户账号") 17 | @NotNull(message = "用户账号不能为空") 18 | private String username; 19 | 20 | @Schema(description = "用户密码") 21 | @NotNull(message = "用户密码不能为空") 22 | private String password; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-business-entity/maozi-cloud-dto/maozi-cloud-system-user-dto/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | com.maozi 5 | maozi-cloud-dto 6 | ${parent-revision} 7 | 8 | maozi-cloud-system-user-dto 9 | -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-business-entity/maozi-cloud-dto/maozi-cloud-system-user-dto/src/main/java/com/maozi/system/user/dto/global/dto/SystemUser.java: -------------------------------------------------------------------------------- 1 | package com.maozi.system.user.dto.global.dto; 2 | 3 | import com.maozi.base.AbstractBaseDtomain; 4 | import io.swagger.v3.oas.annotations.media.Schema; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | 9 | @Data 10 | @NoArgsConstructor 11 | @AllArgsConstructor 12 | public class SystemUser extends AbstractBaseDtomain{ 13 | 14 | @Schema(description = "标识") 15 | private Long id; 16 | 17 | @Schema(description = "账号") 18 | private String username; 19 | 20 | @Schema(description = "名称") 21 | private String name; 22 | 23 | @Schema(description = "头像") 24 | private String icon; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-business-entity/maozi-cloud-dto/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | com.maozi 6 | maozi-cloud-business-entity 7 | ${parent-revision} 8 | 9 | maozi-cloud-dto 10 | pom 11 | 12 | 13 | 14 | 15 | com.maozi 16 | maozi-cloud-base-dto 17 | ${maozi-cloud-base-dto.version} 18 | 19 | 20 | 21 | 22 | 23 | maozi-cloud-oauth-token-dto 24 | maozi-cloud-system-user-dto 25 | 26 | 27 | -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-business-entity/maozi-cloud-enum/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | com.maozi 7 | maozi-cloud-business-entity 8 | ${parent-revision} 9 | 10 | maozi-cloud-enum 11 | pom 12 | 13 | 14 | 15 | 16 | 17 | 18 | com.maozi 19 | maozi-cloud-base-enum 20 | ${maozi-cloud-base-enum.version} 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-business-entity/maozi-cloud-vo/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | com.maozi 6 | maozi-cloud-business-entity 7 | ${parent-revision} 8 | 9 | maozi-cloud-vo 10 | pom 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | com.maozi 19 | maozi-cloud-base-vo 20 | ${maozi-cloud-base-vo.version} 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /maozi-cloud-entity/maozi-cloud-business-entity/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | com.maozi 5 | maozi-cloud-entity 6 | ${parent-revision} 7 | 8 | maozi-cloud-business-entity 9 | pom 10 | 11 | 12 | maozi-cloud-do 13 | maozi-cloud-vo 14 | maozi-cloud-dto 15 | maozi-cloud-enum 16 | 17 | 18 | -------------------------------------------------------------------------------- /maozi-cloud-entity/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | com.maozi 6 | maozi-cloud-parent 7 | ${parent-revision} 8 | 9 | maozi-cloud-entity 10 | pom 11 | 12 | 13 | maozi-cloud-base-entity 14 | maozi-cloud-business-entity 15 | 16 | 17 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-base/maozi-cloud-service-base-impl/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | com.maozi 7 | maozi-cloud-service-base 8 | ${parent-revision} 9 | 10 | maozi-cloud-service-base-impl 11 | 12 | 13 | 14 | 15 | com.maozi 16 | maozi-cloud-config-web 17 | ${maozi-cloud-config-web.version} 18 | 19 | 20 | 21 | com.maozi 22 | maozi-cloud-service-base-rest-api 23 | ${maozi-cloud-service-base-rest-api.version} 24 | 25 | 26 | 27 | com.alibaba.cloud 28 | spring-cloud-starter-alibaba-nacos-config 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-base/maozi-cloud-service-base-impl/src/main/java/com/maozi/base/api/impl/rest/RestApplicationCode.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.api.impl.rest; 2 | 3 | import com.maozi.base.BaseEnum; 4 | import com.maozi.base.annotation.Get; 5 | import com.maozi.base.annotation.RestService; 6 | import com.maozi.base.error.code.SystemErrorCode; 7 | import com.maozi.base.result.EnumResult; 8 | import com.maozi.common.BaseCommon; 9 | import com.maozi.common.result.AbstractBaseResult; 10 | import com.maozi.common.result.error.ErrorResult; 11 | import com.maozi.mvc.config.enums.EnumConfig; 12 | import io.swagger.v3.oas.annotations.tags.Tag; 13 | import java.util.List; 14 | import java.util.Map; 15 | import org.springframework.web.bind.annotation.PathVariable; 16 | 17 | 18 | @RestService 19 | @Tag(name = "【全局】枚举常量") 20 | public class RestApplicationCode extends BaseCommon { 21 | 22 | private static final String PATH = "/application"; 23 | 24 | @Get(value = PATH + "/enum/list",description = "【服务枚举】列表") 25 | public AbstractBaseResult>> list() { 26 | return success(EnumConfig.enums); 27 | } 28 | 29 | @Get(value = PATH + "/enum/{name}/get",description = "【服务枚举】详情") 30 | public AbstractBaseResult> get(@PathVariable("name") String name) { 31 | return success(EnumConfig.enums.get(name)); 32 | } 33 | 34 | @Get(value = PATH + "/error",description = "【服务测试】测试失败结果") 35 | public ErrorResult error() { 36 | return error(getCodes().SYSTEM_ERROR); 37 | } 38 | 39 | @Get(value = PATH + "/base/enum",description = "【服务测试】模板枚举") 40 | public AbstractBaseResult baseEnum() { 41 | return success(EnumResult.builder().value(0).desc("测试枚举").build()); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-base/maozi-cloud-service-base-rest-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.maozi 8 | maozi-cloud-service-base 9 | ${parent-revision} 10 | 11 | maozi-cloud-service-base-rest-api 12 | 13 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-base/maozi-cloud-service-base-rest-api/src/main/java/com/maozi/base/annotation/Get.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.annotation; 2 | 3 | import io.swagger.v3.oas.annotations.Operation; 4 | import java.lang.annotation.Documented; 5 | import java.lang.annotation.ElementType; 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import java.lang.annotation.Target; 9 | import org.springframework.core.annotation.AliasFor; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RequestMethod; 12 | 13 | 14 | @Documented 15 | @Target({ElementType.METHOD}) 16 | @Retention(RetentionPolicy.RUNTIME) 17 | @Operation 18 | @RequestMapping(method = {RequestMethod.GET}) 19 | public @interface Get { 20 | 21 | @AliasFor(annotation = RequestMapping.class) 22 | String[] value() default {}; 23 | 24 | @AliasFor(value = "summary",annotation = Operation.class) 25 | String description() default ""; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-base/maozi-cloud-service-base-rest-api/src/main/java/com/maozi/base/annotation/Post.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.annotation; 2 | 3 | import io.swagger.v3.oas.annotations.Operation; 4 | import java.lang.annotation.Documented; 5 | import java.lang.annotation.ElementType; 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import java.lang.annotation.Target; 9 | import org.springframework.core.annotation.AliasFor; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RequestMethod; 12 | 13 | 14 | @Documented 15 | @Target({ElementType.METHOD}) 16 | @Retention(RetentionPolicy.RUNTIME) 17 | @Operation 18 | @RequestMapping(method = {RequestMethod.POST}) 19 | public @interface Post { 20 | 21 | @AliasFor(annotation = RequestMapping.class) 22 | String[] value() default {}; 23 | 24 | @AliasFor(value = "summary",annotation = Operation.class) 25 | String description() default ""; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-base/maozi-cloud-service-base-rest-api/src/main/java/com/maozi/base/annotation/RestService.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.annotation; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | import org.springframework.stereotype.Service; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | @Target(ElementType.TYPE) 12 | @Retention(RetentionPolicy.RUNTIME) 13 | @Documented 14 | @Service 15 | @RestController 16 | public @interface RestService {} -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-base/maozi-cloud-service-base-rpc-api/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | com.maozi 7 | maozi-cloud-service-base 8 | ${parent-revision} 9 | 10 | maozi-cloud-service-base-rpc-api 11 | 12 | 13 | 14 | com.maozi 15 | maozi-cloud-base-vo 16 | ${maozi-cloud-base-vo.version} 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-base/maozi-cloud-service-base-rpc-api/src/main/java/com/maozi/base/api/rpc/BaseServiceResult.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.api.rpc; 2 | 3 | import com.maozi.base.AbstractBaseDtomain; 4 | import com.maozi.base.param.SaveUpdateBatch; 5 | import com.maozi.base.result.DropDownResult; 6 | import com.maozi.common.result.AbstractBaseResult; 7 | import java.util.Collection; 8 | import java.util.List; 9 | import java.util.Map; 10 | 11 | public interface BaseServiceResult { 12 | 13 | AbstractBaseResult getByIdResult(Long id,String ... columns); 14 | 15 | AbstractBaseResult> listByIdsResult(Collection ids,String ... columns); 16 | 17 | AbstractBaseResult> listByRelationIdResult(Long id,String relationField,String ... columns); 18 | 19 | AbstractBaseResult>> listByRelationIdsResult(Collection ids,String relationField,String ... columns); 20 | 21 | AbstractBaseResult getCountByParamResult(D dto); 22 | 23 | AbstractBaseResult saveUpdateResult(Long id,D param); 24 | 25 | AbstractBaseResult saveUpdateBatchResult(List dtos); 26 | 27 | AbstractBaseResult removeByIdResult(Long id); 28 | 29 | AbstractBaseResult removeByIdBatchResult(List ids); 30 | 31 | AbstractBaseResult checkAvailableResult(Long id); 32 | 33 | AbstractBaseResult checkAvailableResult(List ids); 34 | 35 | AbstractBaseResult getAvailableByIdResult(Long id,String ... columns); 36 | 37 | AbstractBaseResult dropDownResult(Long id); 38 | 39 | AbstractBaseResult> dropDownListResult(Collection ids); 40 | 41 | } 42 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-base/maozi-cloud-service-base-run/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | com.maozi 5 | maozi-cloud-service-base 6 | ${parent-revision} 7 | 8 | maozi-cloud-service-base-run 9 | 10 | 11 | 12 | 13 | org.springframework.cloud 14 | spring-cloud-starter-bootstrap 15 | 16 | 17 | 18 | org.springframework.cloud 19 | spring-cloud-openfeign-core 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-base/maozi-cloud-service-base-run/src/main/java/org/apache/dubbo/spring/boot/context/event/WelcomeLogoApplicationListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.dubbo.spring.boot.context.event; 18 | 19 | import java.util.concurrent.atomic.AtomicBoolean; 20 | import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent; 21 | import org.springframework.context.ApplicationListener; 22 | import org.springframework.core.Ordered; 23 | import org.springframework.core.annotation.Order; 24 | 25 | /** 26 | * Dubbo Welcome Logo {@link ApplicationListener} 27 | * 28 | * @see ApplicationListener 29 | * @since 2.7.0 30 | */ 31 | @Order(Ordered.HIGHEST_PRECEDENCE + 20 + 1) // After 32 | // LoggingApplicationListener#DEFAULT_ORDER 33 | public class WelcomeLogoApplicationListener implements ApplicationListener { 34 | 35 | private static AtomicBoolean processed = new AtomicBoolean(false); 36 | 37 | @Override 38 | public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) { 39 | 40 | // Skip if processed before, prevent duplicated execution in Hierarchical 41 | // ApplicationContext 42 | if (processed.get()) { 43 | return; 44 | } 45 | 46 | // mark processed to be true 47 | processed.compareAndSet(false, true); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-base/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | com.maozi 6 | maozi-cloud-service 7 | ${parent-revision} 8 | 9 | maozi-cloud-service-base 10 | pom 11 | 12 | 13 | maozi-cloud-service-base-rpc-api 14 | maozi-cloud-service-base-impl 15 | maozi-cloud-service-base-run 16 | maozi-cloud-service-base-rest-api 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-business/maozi-cloud-service-impl/maozi-cloud-service-bd/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | com.maozi 5 | maozi-cloud-service-impl 6 | ${parent-revision} 7 | 8 | maozi-cloud-service-bd 9 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-business/maozi-cloud-service-impl/maozi-cloud-service-bd/src/main/java/com/maozi/bd/api/BDService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package com.maozi.bd.api; 19 | 20 | import com.alibaba.fastjson.JSONObject; 21 | import java.util.Map; 22 | import org.springframework.http.HttpMethod; 23 | 24 | public interface BDService { 25 | 26 | JSONObject bdRest(String uri,Map privateParam,HttpMethod method); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-business/maozi-cloud-service-impl/maozi-cloud-service-bd/src/main/java/com/maozi/bd/properties/BDProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package com.maozi.bd.properties; 19 | 20 | import lombok.Data; 21 | import org.springframework.boot.context.properties.ConfigurationProperties; 22 | import org.springframework.context.annotation.Configuration; 23 | 24 | 25 | 26 | @Data 27 | @Configuration 28 | @ConfigurationProperties("bd.config") 29 | public class BDProperties { 30 | 31 | private String url; 32 | 33 | private String ak; 34 | 35 | } 36 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-business/maozi-cloud-service-impl/maozi-cloud-service-company-wechat/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | com.maozi 5 | maozi-cloud-service-impl 6 | ${parent-revision} 7 | 8 | maozi-cloud-service-company-wechat 9 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-business/maozi-cloud-service-impl/maozi-cloud-service-company-wechat/src/main/java/com/maozi/wx/api/WxService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package com.maozi.wx.api; 19 | 20 | import com.alibaba.fastjson.JSONObject; 21 | import java.util.Map; 22 | import org.springframework.http.HttpMethod; 23 | import org.w3c.dom.Document; 24 | 25 | public interface WxService { 26 | 27 | String getDocumentData(Document document, String tag); 28 | 29 | String getVxAccessToken(); 30 | 31 | JSONObject vxRest(String url, Map body, HttpMethod method); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-business/maozi-cloud-service-impl/maozi-cloud-service-company-wechat/src/main/java/com/maozi/wx/config/AesException.java: -------------------------------------------------------------------------------- 1 | package com.maozi.wx.config; 2 | 3 | @SuppressWarnings("serial") 4 | public class AesException extends Exception { 5 | 6 | public final static int OK = 0; 7 | public final static int ValidateSignatureError = -40001; 8 | public final static int ParseXmlError = -40002; 9 | public final static int ComputeSignatureError = -40003; 10 | public final static int IllegalAesKey = -40004; 11 | public final static int ValidateCorpidError = -40005; 12 | public final static int EncryptAESError = -40006; 13 | public final static int DecryptAESError = -40007; 14 | public final static int IllegalBuffer = -40008; 15 | //public final static int EncodeBase64Error = -40009; 16 | //public final static int DecodeBase64Error = -40010; 17 | //public final static int GenReturnXmlError = -40011; 18 | 19 | private int code; 20 | 21 | private static String getMessage(int code) { 22 | switch (code) { 23 | case ValidateSignatureError: 24 | return "签名验证错误"; 25 | case ParseXmlError: 26 | return "xml解析失败"; 27 | case ComputeSignatureError: 28 | return "sha加密生成签名失败"; 29 | case IllegalAesKey: 30 | return "SymmetricKey非法"; 31 | case ValidateCorpidError: 32 | return "corpid校验失败"; 33 | case EncryptAESError: 34 | return "aes加密失败"; 35 | case DecryptAESError: 36 | return "aes解密失败"; 37 | case IllegalBuffer: 38 | return "解密后得到的buffer非法"; 39 | // case EncodeBase64Error: 40 | // return "base64加密错误"; 41 | // case DecodeBase64Error: 42 | // return "base64解密错误"; 43 | // case GenReturnXmlError: 44 | // return "xml生成失败"; 45 | default: 46 | return null; // cannot be 47 | } 48 | } 49 | 50 | public int getCode() { 51 | return code; 52 | } 53 | 54 | AesException(int code) { 55 | super(getMessage(code)); 56 | this.code = code; 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-business/maozi-cloud-service-impl/maozi-cloud-service-company-wechat/src/main/java/com/maozi/wx/config/ByteGroup.java: -------------------------------------------------------------------------------- 1 | package com.maozi.wx.config; 2 | 3 | import java.util.ArrayList; 4 | 5 | class ByteGroup { 6 | ArrayList byteContainer = new ArrayList(); 7 | 8 | public byte[] toBytes() { 9 | byte[] bytes = new byte[byteContainer.size()]; 10 | for (int i = 0; i < byteContainer.size(); i++) { 11 | bytes[i] = byteContainer.get(i); 12 | } 13 | return bytes; 14 | } 15 | 16 | public ByteGroup addBytes(byte[] bytes) { 17 | for (byte b : bytes) { 18 | byteContainer.add(b); 19 | } 20 | return this; 21 | } 22 | 23 | public int size() { 24 | return byteContainer.size(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-business/maozi-cloud-service-impl/maozi-cloud-service-company-wechat/src/main/java/com/maozi/wx/config/PKCS7Encoder.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 对企业微信发送给企业后台的消息加解密示例代码. 3 | * 4 | * @copyright Copyright (c) 1998-2014 Tencent Inc. 5 | */ 6 | 7 | // ------------------------------------------------------------------------ 8 | 9 | package com.maozi.wx.config; 10 | 11 | import java.nio.charset.Charset; 12 | import java.util.Arrays; 13 | 14 | /** 15 | * 提供基于PKCS7算法的加解密接口. 16 | */ 17 | class PKCS7Encoder { 18 | static Charset CHARSET = Charset.forName("utf-8"); 19 | static int BLOCK_SIZE = 32; 20 | 21 | /** 22 | * 获得对明文进行补位填充的字节. 23 | * 24 | * @param count 需要进行填充补位操作的明文字节个数 25 | * @return 补齐用的字节数组 26 | */ 27 | static byte[] encode(int count) { 28 | // 计算需要填充的位数 29 | int amountToPad = BLOCK_SIZE - (count % BLOCK_SIZE); 30 | if (amountToPad == 0) { 31 | amountToPad = BLOCK_SIZE; 32 | } 33 | // 获得补位所用的字符 34 | char padChr = chr(amountToPad); 35 | String tmp = new String(); 36 | for (int index = 0; index < amountToPad; index++) { 37 | tmp += padChr; 38 | } 39 | return tmp.getBytes(CHARSET); 40 | } 41 | 42 | /** 43 | * 删除解密后明文的补位字符 44 | * 45 | * @param decrypted 解密后的明文 46 | * @return 删除补位字符后的明文 47 | */ 48 | static byte[] decode(byte[] decrypted) { 49 | int pad = (int) decrypted[decrypted.length - 1]; 50 | if (pad < 1 || pad > 32) { 51 | pad = 0; 52 | } 53 | return Arrays.copyOfRange(decrypted, 0, decrypted.length - pad); 54 | } 55 | 56 | /** 57 | * 将数字转化成ASCII码对应的字符,用于对明文进行补码 58 | * 59 | * @param a 需要转化的数字 60 | * @return 转化得到的字符 61 | */ 62 | static char chr(int a) { 63 | byte target = (byte) (a & 0xFF); 64 | return (char) target; 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-business/maozi-cloud-service-impl/maozi-cloud-service-company-wechat/src/main/java/com/maozi/wx/config/SHA1.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 对企业微信发送给企业后台的消息加解密示例代码. 3 | * 4 | * @copyright Copyright (c) 1998-2014 Tencent Inc. 5 | */ 6 | 7 | // ------------------------------------------------------------------------ 8 | 9 | package com.maozi.wx.config; 10 | 11 | import java.security.MessageDigest; 12 | import java.util.Arrays; 13 | 14 | /** 15 | * SHA1 class 16 | * 17 | * 计算消息签名接口. 18 | */ 19 | class SHA1 { 20 | 21 | /** 22 | * 用SHA1算法生成安全签名 23 | * @param token 票据 24 | * @param timestamp 时间戳 25 | * @param nonce 随机字符串 26 | * @param encrypt 密文 27 | * @return 安全签名 28 | * @throws AesException 29 | */ 30 | public static String getSHA1(String token, String timestamp, String nonce, String encrypt) throws AesException 31 | { 32 | try { 33 | String[] array = new String[] { token, timestamp, nonce, encrypt }; 34 | StringBuffer sb = new StringBuffer(); 35 | // 字符串排序 36 | Arrays.sort(array); 37 | for (int i = 0; i < 4; i++) { 38 | sb.append(array[i]); 39 | } 40 | String str = sb.toString(); 41 | // SHA1签名生成 42 | MessageDigest md = MessageDigest.getInstance("SHA-1"); 43 | md.update(str.getBytes()); 44 | byte[] digest = md.digest(); 45 | 46 | StringBuffer hexstr = new StringBuffer(); 47 | String shaHex = ""; 48 | for (int i = 0; i < digest.length; i++) { 49 | shaHex = Integer.toHexString(digest[i] & 0xFF); 50 | if (shaHex.length() < 2) { 51 | hexstr.append(0); 52 | } 53 | hexstr.append(shaHex); 54 | } 55 | return hexstr.toString(); 56 | } catch (Exception e) { 57 | e.printStackTrace(); 58 | throw new AesException(AesException.ComputeSignatureError); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-business/maozi-cloud-service-impl/maozi-cloud-service-company-wechat/src/main/java/com/maozi/wx/properties/WxProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package com.maozi.wx.properties; 19 | 20 | import lombok.Data; 21 | import org.springframework.boot.context.properties.ConfigurationProperties; 22 | import org.springframework.context.annotation.Configuration; 23 | 24 | 25 | 26 | @Data 27 | @Configuration 28 | @ConfigurationProperties("wx.company.config") 29 | public class WxProperties { 30 | 31 | private String corpid; 32 | 33 | private String contactsCorpsecret; 34 | 35 | private String departmentId; 36 | 37 | private String sToken; 38 | 39 | private String sEncodingAESKey; 40 | 41 | } 42 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-business/maozi-cloud-service-impl/maozi-cloud-service-qny/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | com.maozi 7 | maozi-cloud-service-impl 8 | ${parent-revision} 9 | 10 | maozi-cloud-service-qny 11 | 12 | 13 | 14 | com.qiniu 15 | qiniu-java-sdk 16 | 7.7.0 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-business/maozi-cloud-service-impl/maozi-cloud-service-qny/src/main/java/com/maozi/qny/api/QNYService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package com.maozi.qny.api; 19 | 20 | import java.io.File; 21 | import java.util.List; 22 | import org.springframework.web.multipart.MultipartFile; 23 | import org.springframework.web.multipart.MultipartRequest; 24 | 25 | 26 | 27 | public interface QNYService { 28 | 29 | List uploadImages(MultipartFile [] files) throws Exception; 30 | 31 | String uploadImage(MultipartFile file) throws Exception; 32 | 33 | /** 34 | * 上传图片 35 | * @param files 36 | * @return 37 | */ 38 | List uploadImages(MultipartRequest files); 39 | 40 | /** 41 | * 上传文件 42 | * @param bytes 43 | * @return 44 | * @throws Exception 45 | */ 46 | String uploadImage(byte[] bytes) throws Exception; 47 | 48 | /** 49 | * 根据url下载图片 50 | * @param url 51 | * @return 52 | */ 53 | File download(String url); 54 | 55 | } 56 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-business/maozi-cloud-service-impl/maozi-cloud-service-qny/src/main/java/com/maozi/qny/api/impl/rest/OssServiceRestImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package com.maozi.qny.api.impl.rest; 19 | 20 | import com.maozi.base.annotation.Get; 21 | import com.maozi.base.annotation.RestService; 22 | import com.maozi.base.error.code.SystemErrorCode; 23 | import com.maozi.common.BaseCommon; 24 | import com.maozi.common.result.AbstractBaseResult; 25 | import com.maozi.qny.properties.QNYProperties; 26 | import com.qiniu.util.Auth; 27 | import io.swagger.v3.oas.annotations.tags.Tag; 28 | import javax.annotation.Resource; 29 | import org.springframework.web.bind.annotation.RequestParam; 30 | 31 | 32 | 33 | @RestService 34 | @Tag(name = "【全局】图片管理") 35 | public class OssServiceRestImpl extends BaseCommon { 36 | 37 | private static final String PATH = "/oss"; 38 | 39 | @Resource 40 | private QNYProperties qnyProperties; 41 | 42 | @Get(value = PATH + "/getToken",description = "获取七牛云图片访问令牌") 43 | public AbstractBaseResult getToken(@RequestParam String url) throws Exception{ 44 | 45 | Auth auth = Auth.create(qnyProperties.getAccessKey(), qnyProperties.getSecretKey()); 46 | 47 | return success(auth.privateDownloadUrl(url, 86400)); 48 | 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-business/maozi-cloud-service-impl/maozi-cloud-service-qny/src/main/java/com/maozi/qny/properties/QNYProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package com.maozi.qny.properties; 19 | 20 | import lombok.Data; 21 | import org.springframework.boot.context.properties.ConfigurationProperties; 22 | import org.springframework.context.annotation.Configuration; 23 | 24 | 25 | 26 | @Data 27 | @Configuration 28 | @ConfigurationProperties("qny.config") 29 | public class QNYProperties { 30 | 31 | private String accessKey; 32 | 33 | private String secretKey; 34 | 35 | private String bucket; 36 | 37 | private String url; 38 | 39 | } -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-business/maozi-cloud-service-impl/maozi-cloud-service-ss/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | com.maozi 5 | maozi-cloud-service-impl 6 | ${parent-revision} 7 | 8 | maozi-cloud-service-ss 9 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-business/maozi-cloud-service-impl/maozi-cloud-service-ss/src/main/java/com/maozi/ss/api/SSService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package com.maozi.ss.api; 19 | 20 | import com.alibaba.fastjson.JSONObject; 21 | import java.util.Map; 22 | 23 | 24 | 25 | public interface SSService { 26 | 27 | JSONObject ssRefreshRest(String uri,Map privateParam,String refreshToken); 28 | 29 | JSONObject ssRest(String uri,Map privateParam,String refreshToken); 30 | 31 | JSONObject ssRestGetToken(String code); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-business/maozi-cloud-service-impl/maozi-cloud-service-ss/src/main/java/com/maozi/ss/config/SSConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package com.maozi.ss.config; 19 | 20 | import java.security.MessageDigest; 21 | 22 | 23 | 24 | 25 | public class SSConfig { 26 | 27 | //把字节数组转换成大写md5 28 | public static String bytesToMD5(byte[] input) { 29 | String md5str = null; 30 | try { 31 | //创建一个提供信息摘要算法的对象,初始化为md5算法对象 32 | MessageDigest md = MessageDigest.getInstance("MD5"); 33 | //计算后获得字节数组 34 | byte[] buff = md.digest(input); 35 | //把数组每一字节换成16进制连成md5字符串 36 | md5str = bytesToHex(buff); 37 | } catch (Exception e) { 38 | e.printStackTrace(); 39 | } 40 | return md5str.toUpperCase(); 41 | } 42 | 43 | //把字节数组转成16进位制数 44 | public static String bytesToHex(byte[] bytes) { 45 | StringBuffer md5str = new StringBuffer(); 46 | //把数组每一字节换成16进制连成md5字符串 47 | int digital; 48 | for (int i = 0; i < bytes.length; i++) { 49 | digital = bytes[i]; 50 | if(digital < 0) { 51 | digital += 256; 52 | } 53 | if(digital < 16){ 54 | md5str.append("0"); 55 | } 56 | md5str.append(Integer.toHexString(digital)); 57 | } 58 | return md5str.toString(); 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-business/maozi-cloud-service-impl/maozi-cloud-service-ss/src/main/java/com/maozi/ss/properties/SSProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package com.maozi.ss.properties; 19 | 20 | import lombok.Data; 21 | import org.springframework.boot.context.properties.ConfigurationProperties; 22 | import org.springframework.context.annotation.Configuration; 23 | 24 | 25 | 26 | @Data 27 | @Configuration 28 | @ConfigurationProperties("ss.config") 29 | public class SSProperties { 30 | 31 | private String clientId; 32 | 33 | private String appSecret; 34 | 35 | private String url; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-business/maozi-cloud-service-rest-api/maozi-cloud-service-rest-api-oauth-token/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | com.maozi 5 | maozi-cloud-service-rest-api 6 | ${parent-revision} 7 | 8 | maozi-cloud-service-rest-api-oauth-token 9 | 10 | 11 | 12 | 13 | com.maozi 14 | maozi-cloud-oauth-token-dto 15 | ${maozi-cloud-oauth-token-dto.version} 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-business/maozi-cloud-service-rest-api/maozi-cloud-service-rest-api-oauth-token/src/main/java/com/maozi/oauth/token/api/rest/v1/RestOauthTokenServiceV1.java: -------------------------------------------------------------------------------- 1 | package com.maozi.oauth.token.api.rest.v1; 2 | 3 | import com.maozi.base.annotation.Get; 4 | import com.maozi.base.annotation.Post; 5 | import com.maozi.common.result.AbstractBaseResult; 6 | import com.maozi.oauth.token.api.rest.v1.fallback.OauthTokenServiceRestFallBackFactory; 7 | import com.maozi.oauth.token.dto.platform.dto.OauthToken; 8 | import com.maozi.oauth.token.dto.platform.param.ClientParam; 9 | import com.maozi.oauth.token.dto.platform.param.TokenInfoParam; 10 | import io.swagger.v3.oas.annotations.tags.Tag; 11 | import java.util.Map; 12 | import javax.validation.Valid; 13 | import org.springframework.cloud.openfeign.FeignClient; 14 | import org.springframework.web.bind.annotation.PathVariable; 15 | import org.springframework.web.bind.annotation.RequestBody; 16 | 17 | @Tag(name = "【三方】授权令牌") 18 | @FeignClient(value = "maozi-cloud-oauth",fallbackFactory = OauthTokenServiceRestFallBackFactory.class) 19 | public interface RestOauthTokenServiceV1 { 20 | 21 | String PATH = "/oauth/token"; 22 | 23 | @Post(value = PATH + "/get",description = "获取令牌") 24 | AbstractBaseResult restGet(@RequestBody @Valid TokenInfoParam param) throws Exception; 25 | 26 | @Post(value = PATH + "/{token}/refresh",description = "刷新令牌") 27 | AbstractBaseResult restRefresh(@PathVariable("token") String refreshToken,@RequestBody @Valid ClientParam param) throws Exception; 28 | 29 | @Get(value = PATH + "/{token}/check",description = "检查令牌") 30 | AbstractBaseResult restCheck(@PathVariable("token") String token); 31 | 32 | @Get(value = PATH + "/{token}/destroy",description = "删除令牌") 33 | AbstractBaseResult restDestroy(@PathVariable("token") String token); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-business/maozi-cloud-service-rest-api/maozi-cloud-service-rest-api-oauth-token/src/main/java/com/maozi/oauth/token/api/rest/v1/fallback/OauthTokenServiceRestFallBackFactory.java: -------------------------------------------------------------------------------- 1 | package com.maozi.oauth.token.api.rest.v1.fallback; 2 | 3 | import com.maozi.base.error.code.SystemErrorCode; 4 | import com.maozi.common.BaseCommon; 5 | import com.maozi.common.result.AbstractBaseResult; 6 | import com.maozi.common.result.error.ErrorResult; 7 | import com.maozi.common.result.error.exception.BusinessResultException; 8 | import com.maozi.oauth.token.api.rest.v1.RestOauthTokenServiceV1; 9 | import com.maozi.oauth.token.dto.platform.dto.OauthToken; 10 | import com.maozi.oauth.token.dto.platform.param.ClientParam; 11 | import com.maozi.oauth.token.dto.platform.param.TokenInfoParam; 12 | import com.maozi.utils.MapperUtils; 13 | import java.util.Map; 14 | import org.springframework.cloud.openfeign.FallbackFactory; 15 | import org.springframework.stereotype.Component; 16 | 17 | @Component 18 | public class OauthTokenServiceRestFallBackFactory extends BaseCommon implements FallbackFactory{ 19 | 20 | @Override 21 | public RestOauthTokenServiceV1 create(Throwable e) { 22 | 23 | ErrorResult errorResult = MapperUtils.jsonToPojo(e.getLocalizedMessage(), ErrorResult.class); 24 | 25 | ErrorResult result = BaseCommon.isNull(errorResult) ? ((BusinessResultException)e).getErrorResult() : errorResult; 26 | 27 | return new RestOauthTokenServiceV1() { 28 | 29 | @Override 30 | public AbstractBaseResult restGet(TokenInfoParam param) { 31 | return result; 32 | } 33 | 34 | @Override 35 | public AbstractBaseResult restCheck(String token) { 36 | return result; 37 | } 38 | 39 | @Override 40 | public AbstractBaseResult restRefresh(String refreshToken,ClientParam param) { 41 | return result; 42 | } 43 | 44 | @Override 45 | public AbstractBaseResult restDestroy(String token) { 46 | return result; 47 | } 48 | 49 | }; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-business/maozi-cloud-service-rest-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | com.maozi 6 | maozi-cloud-service-business 7 | ${parent-revision} 8 | 9 | maozi-cloud-service-rest-api 10 | pom 11 | 12 | 13 | 14 | 15 | org.springframework.cloud 16 | spring-cloud-openfeign-core 17 | 18 | 19 | 20 | com.maozi 21 | maozi-cloud-service-base-rest-api 22 | ${maozi-cloud-service-base-rest-api.version} 23 | 24 | 25 | 26 | 27 | 28 | maozi-cloud-service-rest-api-oauth-token 29 | 30 | 31 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-business/maozi-cloud-service-rpc-api/maozi-cloud-service-rpc-api-oauth-token/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | com.maozi 5 | maozi-cloud-service-rpc-api 6 | ${parent-revision} 7 | 8 | maozi-cloud-service-rpc-api-oauth-token 9 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-business/maozi-cloud-service-rpc-api/maozi-cloud-service-rpc-api-oauth-token/src/main/java/com/maozi/oauth/token/api/rpc/v1/RpcOauthTokenServiceV1.java: -------------------------------------------------------------------------------- 1 | package com.maozi.oauth.token.api.rpc.v1; 2 | 3 | import com.maozi.common.result.AbstractBaseResult; 4 | import com.maozi.oauth.token.dto.platform.dto.OauthToken; 5 | import com.maozi.oauth.token.dto.platform.param.ClientParam; 6 | import com.maozi.oauth.token.dto.platform.param.ClientUserParam; 7 | import com.maozi.oauth.token.dto.platform.param.TokenInfoParam; 8 | import java.util.List; 9 | import java.util.Map; 10 | 11 | public interface RpcOauthTokenServiceV1 { 12 | 13 | AbstractBaseResult rpcGet(TokenInfoParam param) throws Exception; 14 | 15 | AbstractBaseResult rpcRefresh(String token,ClientParam param) throws Exception; 16 | 17 | AbstractBaseResult rpcCheck(String token); 18 | 19 | AbstractBaseResult rpcDestroy(String token); 20 | 21 | AbstractBaseResult rpcDestroy(ClientUserParam param); 22 | 23 | AbstractBaseResult rpcDestroys(List params); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-business/maozi-cloud-service-rpc-api/maozi-cloud-service-rpc-api-system-config/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | com.maozi 5 | maozi-cloud-service-rpc-api 6 | ${parent-revision} 7 | 8 | maozi-cloud-service-rpc-api-system-config 9 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-business/maozi-cloud-service-rpc-api/maozi-cloud-service-rpc-api-system-config/src/main/java/com/maozi/system/config/api/rpc/v1/RpcRegionServiceV1.java: -------------------------------------------------------------------------------- 1 | package com.maozi.system.config.api.rpc.v1; 2 | 3 | import com.maozi.base.result.DropDownResult; 4 | import com.maozi.common.result.AbstractBaseResult; 5 | 6 | public interface RpcRegionServiceV1 { 7 | 8 | AbstractBaseResult rpcGet(Long id); 9 | 10 | } -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-business/maozi-cloud-service-rpc-api/maozi-cloud-service-rpc-api-system-user/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | com.maozi 5 | maozi-cloud-service-rpc-api 6 | ${parent-revision} 7 | 8 | maozi-cloud-service-rpc-api-system-user 9 | 10 | 11 | 12 | 13 | com.maozi 14 | maozi-cloud-system-user-dto 15 | ${maozi-cloud-system-user-dto.version} 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-business/maozi-cloud-service-rpc-api/maozi-cloud-service-rpc-api-system-user/src/main/java/com/maozi/system/user/api/rpc/v1/RpcUserInfoServiceV1.java: -------------------------------------------------------------------------------- 1 | package com.maozi.system.user.api.rpc.v1; 2 | 3 | import com.maozi.common.result.AbstractBaseResult; 4 | import com.maozi.system.user.dto.global.dto.SystemUser; 5 | 6 | public interface RpcUserInfoServiceV1 { 7 | 8 | AbstractBaseResult rpcGetByUsername(String username,String ... colums); 9 | 10 | } -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-business/maozi-cloud-service-rpc-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | com.maozi 6 | maozi-cloud-service-business 7 | ${parent-revision} 8 | 9 | maozi-cloud-service-rpc-api 10 | pom 11 | 12 | 13 | 14 | com.maozi 15 | maozi-cloud-service-base-rpc-api 16 | ${maozi-cloud-service-base-rpc-api.version} 17 | 18 | 19 | 20 | 21 | maozi-cloud-service-rpc-api-oauth-token 22 | maozi-cloud-service-rpc-api-system-user 23 | maozi-cloud-service-rpc-api-system-config 24 | 25 | 26 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-business/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | com.maozi 5 | maozi-cloud-service 6 | ${parent-revision} 7 | 8 | maozi-cloud-service-business 9 | pom 10 | 11 | 12 | maozi-cloud-service-impl 13 | maozi-cloud-service-rpc-api 14 | maozi-cloud-service-rest-api 15 | 16 | 17 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-plugin/maozi-cloud-service-db-impl/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | com.maozi 5 | maozi-cloud-service-plugin 6 | ${parent-revision} 7 | 8 | maozi-cloud-service-db-impl 9 | 10 | 11 | 12 | 13 | 14 | 15 | com.maozi 16 | maozi-cloud-config-db 17 | ${maozi-cloud-config-db.version} 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-plugin/maozi-cloud-service-db-impl/src/main/java/com/github/yulichang/base/MPJBaseServiceImpl.java: -------------------------------------------------------------------------------- 1 | // 2 | // Source code recreated from a .class file by IntelliJ IDEA 3 | // (powered by FernFlower decompiler) 4 | // 5 | 6 | package com.github.yulichang.base; 7 | 8 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 9 | import com.maozi.base.AbstractBaseCode; 10 | import com.maozi.base.AbstractBaseDomain; 11 | 12 | public class MPJBaseServiceImpl, T extends AbstractBaseDomain, E extends AbstractBaseCode> extends ServiceImpl implements MPJBaseService { 13 | public MPJBaseServiceImpl() { 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-plugin/maozi-cloud-service-db-impl/src/main/java/com/maozi/BaseApplicationDB.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package com.maozi; 19 | 20 | import java.util.Properties; 21 | import org.mybatis.spring.annotation.MapperScan; 22 | import org.springframework.boot.autoconfigure.SpringBootApplication; 23 | 24 | @SpringBootApplication 25 | @MapperScan("com.maozi.${application-project-abbreviation}.*.mapper") 26 | public class BaseApplicationDB { 27 | 28 | protected static void ApplicationRun() { 29 | 30 | Properties properties = System.getProperties(); 31 | 32 | properties.put("application-nacos-config-service",",boot-datasource.yml,boot-db.yml"); 33 | 34 | BaseApplication.ApplicationRun(); 35 | 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-plugin/maozi-cloud-service-db-impl/src/main/java/com/maozi/base/api/IBaseMapper.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.api; 2 | 3 | import com.github.yulichang.base.MPJBaseMapper; 4 | import java.util.Collection; 5 | 6 | public interface IBaseMapper extends MPJBaseMapper { 7 | 8 | Integer insertBatchSomeColumn(Collection entityList); 9 | 10 | } -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-plugin/maozi-cloud-service-db-impl/src/main/java/com/maozi/base/plugin/JoinBasePlugin.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.plugin; 2 | 3 | import com.github.yulichang.wrapper.MPJLambdaWrapper; 4 | import com.maozi.base.plugin.join.JoinPlugin; 5 | 6 | public abstract class JoinBasePlugin { 7 | 8 | public abstract void apply(String abbreviationModelName,MPJLambdaWrapper wrapper, JoinPlugin joinPlugin); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-plugin/maozi-cloud-service-db-impl/src/main/java/com/maozi/base/plugin/QueryBasePlugin.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.plugin; 2 | 3 | import com.github.yulichang.wrapper.MPJLambdaWrapper; 4 | 5 | public abstract class QueryBasePlugin { 6 | 7 | public abstract void apply(MPJLambdaWrapper wrapper,String field,Object data); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-plugin/maozi-cloud-service-db-impl/src/main/java/com/maozi/base/plugin/StoreClassDBScan.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.plugin; 2 | 3 | import cn.hutool.core.util.ClassUtil; 4 | import com.baomidou.mybatisplus.annotation.TableName; 5 | import com.google.common.collect.Maps; 6 | import com.maozi.base.enums.StoreClassType; 7 | import com.maozi.utils.context.ApplicationEnvironmentContext; 8 | import java.util.HashMap; 9 | import org.springframework.boot.ApplicationArguments; 10 | import org.springframework.boot.ApplicationRunner; 11 | import org.springframework.stereotype.Component; 12 | 13 | @Component 14 | public class StoreClassDBScan implements ApplicationRunner { 15 | 16 | @Override 17 | public void run(ApplicationArguments args) throws Exception { 18 | 19 | HashMap> storeClassDBMap = Maps.newHashMap(); 20 | 21 | ClassUtil.scanPackage("com.maozi."+ ApplicationEnvironmentContext.applicationProjectAbbreviation).stream().forEach(clazz ->{ 22 | 23 | if(clazz.isAnnotationPresent(TableName.class)){ 24 | 25 | TableName annotation = clazz.getAnnotation(TableName.class); 26 | 27 | storeClassDBMap.put(annotation.value(),clazz); 28 | 29 | } 30 | 31 | }); 32 | 33 | StoreClass.storeClassMap.put(StoreClassType.db,storeClassDBMap); 34 | 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-plugin/maozi-cloud-service-db-impl/src/main/java/com/maozi/base/plugin/impl/join/QueryInnerJoinPlugin.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.plugin.impl.join; 2 | 3 | import com.github.yulichang.wrapper.MPJLambdaWrapper; 4 | import com.maozi.base.plugin.JoinBasePlugin; 5 | import com.maozi.base.plugin.join.JoinPlugin; 6 | import com.maozi.common.BaseCommon; 7 | 8 | public class QueryInnerJoinPlugin extends JoinBasePlugin { 9 | 10 | @Override 11 | public void apply(String abbreviationModelName,MPJLambdaWrapper wrapper, JoinPlugin joinPlugin) { 12 | 13 | BaseCommon.isEmptyThrowError(joinPlugin.tableName(),abbreviationModelName+"内联目标"); 14 | 15 | BaseCommon.isEmptyThrowError(joinPlugin.on(),abbreviationModelName+"内联条件"); 16 | 17 | String tableName = joinPlugin.tableName(); 18 | 19 | if(BaseCommon.isNotEmpty(joinPlugin.tableAlias())){ 20 | tableName+=" as "+joinPlugin.tableAlias(); 21 | } 22 | 23 | wrapper.innerJoin(tableName+" on "+joinPlugin.on()); 24 | 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-plugin/maozi-cloud-service-db-impl/src/main/java/com/maozi/base/plugin/impl/join/QueryLeftJoinPlugin.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.plugin.impl.join; 2 | 3 | import com.github.yulichang.wrapper.MPJLambdaWrapper; 4 | import com.maozi.base.plugin.JoinBasePlugin; 5 | import com.maozi.base.plugin.join.JoinPlugin; 6 | import com.maozi.common.BaseCommon; 7 | 8 | public class QueryLeftJoinPlugin extends JoinBasePlugin { 9 | 10 | @Override 11 | public void apply(String abbreviationModelName,MPJLambdaWrapper wrapper, JoinPlugin joinPlugin) { 12 | 13 | BaseCommon.isEmptyThrowError(joinPlugin.tableName(),abbreviationModelName+"内联目标"); 14 | 15 | BaseCommon.isEmptyThrowError(joinPlugin.on(),abbreviationModelName+"内联条件"); 16 | 17 | String tableName = joinPlugin.tableName(); 18 | 19 | if(BaseCommon.isNotEmpty(joinPlugin.tableAlias())){ 20 | tableName+=" as "+joinPlugin.tableAlias(); 21 | } 22 | 23 | wrapper.leftJoin(tableName+" on "+joinPlugin.on()); 24 | 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-plugin/maozi-cloud-service-db-impl/src/main/java/com/maozi/base/plugin/impl/join/QueryRightJoinPlugin.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.plugin.impl.join; 2 | 3 | import com.github.yulichang.wrapper.MPJLambdaWrapper; 4 | import com.maozi.base.plugin.JoinBasePlugin; 5 | import com.maozi.base.plugin.join.JoinPlugin; 6 | import com.maozi.common.BaseCommon; 7 | 8 | public class QueryRightJoinPlugin extends JoinBasePlugin { 9 | 10 | @Override 11 | public void apply(String abbreviationModelName,MPJLambdaWrapper wrapper, JoinPlugin joinPlugin) { 12 | 13 | BaseCommon.isEmptyThrowError(joinPlugin.tableName(),abbreviationModelName+"内联目标"); 14 | 15 | BaseCommon.isEmptyThrowError(joinPlugin.on(),abbreviationModelName+"内联条件"); 16 | 17 | String tableName = joinPlugin.tableName(); 18 | 19 | if(BaseCommon.isNotEmpty(joinPlugin.tableAlias())){ 20 | tableName+=" as "+joinPlugin.tableAlias(); 21 | } 22 | 23 | wrapper.rightJoin(tableName+" on "+joinPlugin.on()); 24 | 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-plugin/maozi-cloud-service-db-impl/src/main/java/com/maozi/base/plugin/impl/query/QueryEqPlugin.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.plugin.impl.query; 2 | 3 | import com.github.yulichang.wrapper.MPJLambdaWrapper; 4 | import com.maozi.base.plugin.QueryBasePlugin; 5 | 6 | public class QueryEqPlugin extends QueryBasePlugin{ 7 | 8 | @Override 9 | public void apply(MPJLambdaWrapper wrapper,String field,Object data) { 10 | wrapper.eq(field, data); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-plugin/maozi-cloud-service-db-impl/src/main/java/com/maozi/base/plugin/impl/query/QueryGePlugin.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.plugin.impl.query; 2 | 3 | import com.github.yulichang.wrapper.MPJLambdaWrapper; 4 | import com.maozi.base.plugin.QueryBasePlugin; 5 | 6 | public class QueryGePlugin extends QueryBasePlugin{ 7 | 8 | @Override 9 | public void apply(MPJLambdaWrapper wrapper,String field,Object data) { 10 | wrapper.ge(field, data); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-plugin/maozi-cloud-service-db-impl/src/main/java/com/maozi/base/plugin/impl/query/QueryInPlugin.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.plugin.impl.query; 2 | 3 | import com.github.yulichang.wrapper.MPJLambdaWrapper; 4 | import com.maozi.base.plugin.QueryBasePlugin; 5 | 6 | public class QueryInPlugin extends QueryBasePlugin{ 7 | 8 | @Override 9 | public void apply(MPJLambdaWrapper wrapper,String field,Object data) { 10 | wrapper.in(field, data); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-plugin/maozi-cloud-service-db-impl/src/main/java/com/maozi/base/plugin/impl/query/QueryLePlugin.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.plugin.impl.query; 2 | 3 | import com.github.yulichang.wrapper.MPJLambdaWrapper; 4 | import com.maozi.base.plugin.QueryBasePlugin; 5 | 6 | public class QueryLePlugin extends QueryBasePlugin{ 7 | 8 | @Override 9 | public void apply(MPJLambdaWrapper wrapper,String field,Object data) { 10 | wrapper.le(field, data); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-plugin/maozi-cloud-service-db-impl/src/main/java/com/maozi/base/plugin/impl/query/QueryLikePlugin.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.plugin.impl.query; 2 | 3 | import com.github.yulichang.wrapper.MPJLambdaWrapper; 4 | import com.maozi.base.plugin.QueryBasePlugin; 5 | 6 | public class QueryLikePlugin extends QueryBasePlugin{ 7 | 8 | @Override 9 | public void apply(MPJLambdaWrapper wrapper,String field,Object data) { 10 | wrapper.likeRight(field, data); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-plugin/maozi-cloud-service-db-impl/src/main/java/com/maozi/base/plugin/impl/query/QueryNePlugin.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.plugin.impl.query; 2 | 3 | import com.github.yulichang.wrapper.MPJLambdaWrapper; 4 | import com.maozi.base.plugin.QueryBasePlugin; 5 | 6 | public class QueryNePlugin extends QueryBasePlugin{ 7 | 8 | @Override 9 | public void apply(MPJLambdaWrapper wrapper,String field,Object data) { 10 | wrapper.ne(field, data); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-plugin/maozi-cloud-service-db-impl/src/main/java/com/maozi/base/plugin/type/JoinType.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.plugin.type; 2 | 3 | import com.maozi.base.plugin.JoinBasePlugin; 4 | import com.maozi.base.plugin.impl.join.QueryInnerJoinPlugin; 5 | import com.maozi.base.plugin.impl.join.QueryLeftJoinPlugin; 6 | import com.maozi.base.plugin.impl.join.QueryRightJoinPlugin; 7 | import com.maozi.base.plugin.join.JoinBaseType; 8 | import lombok.Getter; 9 | 10 | @Getter 11 | public enum JoinType { 12 | 13 | innerJoin(JoinBaseType.innerJoin,new QueryInnerJoinPlugin()),leftJoin(JoinBaseType.leftJoin,new QueryLeftJoinPlugin()),rightJoin(JoinBaseType.rightJoin,new QueryRightJoinPlugin()); 14 | 15 | JoinType(JoinBaseType type, JoinBasePlugin joinPlugin) { 16 | 17 | this.type = type; 18 | 19 | this.joinPlugin = joinPlugin; 20 | 21 | } 22 | 23 | private JoinBaseType type; 24 | 25 | private JoinBasePlugin joinPlugin; 26 | 27 | 28 | public static JoinType get(String type) { 29 | 30 | JoinType[] joinTypes = JoinType.values(); 31 | 32 | for(JoinType joinType : joinTypes) { 33 | 34 | if(joinType.getType().getType().equals(type)) { 35 | return joinType; 36 | } 37 | 38 | } 39 | 40 | return null; 41 | 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-plugin/maozi-cloud-service-db-impl/src/main/java/com/maozi/base/plugin/type/QueryType.java: -------------------------------------------------------------------------------- 1 | package com.maozi.base.plugin.type; 2 | 3 | import com.maozi.base.plugin.QueryBasePlugin; 4 | import com.maozi.base.plugin.impl.query.QueryEqPlugin; 5 | import com.maozi.base.plugin.impl.query.QueryGePlugin; 6 | import com.maozi.base.plugin.impl.query.QueryInPlugin; 7 | import com.maozi.base.plugin.impl.query.QueryLePlugin; 8 | import com.maozi.base.plugin.impl.query.QueryLikePlugin; 9 | import com.maozi.base.plugin.impl.query.QueryNePlugin; 10 | import com.maozi.base.plugin.query.QueryBaseType; 11 | import lombok.Getter; 12 | 13 | @Getter 14 | public enum QueryType { 15 | 16 | eq(QueryBaseType.eq,new QueryEqPlugin()),like(QueryBaseType.like,new QueryLikePlugin()),in(QueryBaseType.in,new QueryInPlugin()),ne(QueryBaseType.ne,new QueryNePlugin()),ge(QueryBaseType.ge,new QueryGePlugin()),le(QueryBaseType.le,new QueryLePlugin()); 17 | 18 | QueryType(QueryBaseType type,QueryBasePlugin queryPlugin) { 19 | 20 | this.type = type; 21 | 22 | this.queryPlugin = queryPlugin; 23 | 24 | } 25 | 26 | private QueryBaseType type; 27 | 28 | private QueryBasePlugin queryPlugin; 29 | 30 | 31 | public static QueryType get(String type) { 32 | 33 | QueryType[] queryTypes = QueryType.values(); 34 | 35 | for(QueryType queryType : queryTypes) { 36 | 37 | if(queryType.getType().getType().equals(type)) { 38 | return queryType; 39 | } 40 | 41 | } 42 | 43 | return null; 44 | 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /maozi-cloud-service/maozi-cloud-service-plugin/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | com.maozi 5 | maozi-cloud-service 6 | ${parent-revision} 7 | 8 | maozi-cloud-service-plugin 9 | pom 10 | 11 | 12 | 13 | 14 | com.maozi 15 | maozi-cloud-service-impl 16 | ${maozi-cloud-service-impl.version} 17 | pom 18 | 19 | 20 | 21 | com.maozi 22 | maozi-cloud-do 23 | ${maozi-cloud-do.version} 24 | pom 25 | 26 | 27 | 28 | com.maozi 29 | maozi-cloud-vo 30 | ${maozi-cloud-vo.version} 31 | pom 32 | 33 | 34 | 35 | com.maozi 36 | maozi-cloud-service-base-rpc-api 37 | ${maozi-cloud-service-base-rpc-api.version} 38 | 39 | 40 | 41 | 42 | 43 | maozi-cloud-service-db-impl 44 | 45 | 46 | -------------------------------------------------------------------------------- /maozi-cloud-service/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | com.maozi 7 | maozi-cloud-parent 8 | ${parent-revision} 9 | 10 | maozi-cloud-service 11 | pom 12 | 13 | 14 | 15 | 16 | 17 | 18 | com.maozi 19 | maozi-cloud-common-result 20 | ${maozi-cloud-common-result.version} 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | maozi-cloud-service-base 31 | maozi-cloud-service-business 32 | maozi-cloud-service-plugin 33 | 34 | 35 | 36 | 37 | 38 | --------------------------------------------------------------------------------