第三方API(third-party-api)
第三方API集成(Third party api integration)!
报告Bug(Report Bug)
·
请求功能(Request Feature)
目录(Table of Contents)
关于该项目 About The Project
GitHub上有很多很棒的第三方接口集成,但是我找不到真正适合我需要的,因此我创建了这个我认为比较优雅的实现。 我想创建一个第三方接口集成,如此出色,以至于它将成为您需要的最后一个-我想就是这样。
设计理念
- 尽量领域驱动设计
- 尽量代码规范
- 尽量单元测试
- 尽量使用官方sdk或者声明式HTTP(feign)
- 尽量事件驱动
特点
- 高度抽象,统一接口,模块化设计,方法使用更优雅
- 支持多种可插拔机制,扩展性好,可按需使用
- 支持纯java使用,也支持多种框架内使用(一般会自动配置)
- 支持多配置参数,支持多配置参数方式
- 支持发布事件
- 详细可参考用法(Usage)
当然,由于您的需求可能不同,因此没有一个项目可以为所有项目提供服务。 因此,我将在不久的将来添加更多内容。 您也可以通过分叉此存储库并创建请求请求或打开问题来提出更改建议。 感谢所有为该项目的扩展做出贡献的人们!
致谢中列出了一些我认为有用的常用资源。
用什么构建 Built With
本节列出在构建项目时使用的所有主要框架。在致谢(Acknowledgements)部分留下任何附加组件/插件。
入门指南 Getting Started
安装 Installation
-
Maven
<dependency> <groupId>cn.shishuihao</groupId> <artifactId>third-party-api</artifactId> <version>latest</version> </dependency>
-
Gradle
compile 'cn.shishuihao:third-party-api:latest'
用法 Usage
- 可插拔方式
- SPI机制
如:AliYunSmsApiChannel的spi机制实现
cn.shishuihao.thirdparty.api.sms.aliyun.AliYunSmsApiChannel
- 通过注入容器,再从容器获取
-
springboot 如注入容器
@Bean @ConditionalOnMissingBean protected ApiPropertiesRepository propertiesRepository(ApiPropertiesEntityJpaRepository jpaRepository) { return new ApiPropertiesJpaRepository(jpaRepository); }
-
- SPI机制
如:AliYunSmsApiChannel的spi机制实现
- 配置属性配置方式
- 代码 如:
AliYunSmsApiProperties properties = new AliYunSmsApiProperties(); properties.setAccessKeyId("AccessKeyId"); properties.setAccessSecret("AccessSecret"); ApiRegistry.PROPERTIES_REPOSITORY.add(properties);
- 容器
- springboot
- 代码
@Bean @ConditionalOnMissingBean protected AliYunSmsApiProperties defaultAliYunSmsApiProperties() { AliYunSmsApiProperties properties = new AliYunSmsApiProperties(); properties.setAccessKeyId("AccessKeyId"); properties.setAccessSecret("AccessSecret"); return properties; }
- yml(自定义)
sms: aliyun: - access-key-id: AccessKeyId1 access-secret: AccessSecret1 - access-key-id: AccessKeyId2 access-secret: AccessSecret2
- 代码
- springboot
- 数据库配置方式
- spring-boot-jpa
@Bean @ConditionalOnMissingBean protected ApiPropertiesRepository propertiesRepository(ApiPropertiesEntityJpaRepository jpaRepository) { return new ApiPropertiesJpaRepository(jpaRepository); }
- spring-boot-mybatis-plus
@Bean @ConditionalOnMissingBean protected ApiPropertiesRepository propertiesRepository(ApiPropertiesEntityMybatisPlusMapper mybatisPlusMapper) { return new ApiPropertiesMybatisPlusRepository(mybatisPlusMapper); }
- spring-boot-redis
@Bean @ConditionalOnMissingBean protected ApiPropertiesRepository propertiesRepository(RedisTemplate<String, ApiProperties> redisTemplate) { return new ApiPropertiesRedisRepository(redisTemplate); }
- spring-boot-mongodb
@Bean @ConditionalOnMissingBean protected ApiPropertiesRepository propertiesRepository(ApiPropertiesDocumentMongoRepository mongoRepository) { return new ApiPropertiesMongodbRepository(mongoRepository); }
- spring-boot-jpa
- 代码 如:
- 发布事件
- SMS集成(sms integration)
- 推送集成(push integration)
- 小米(xiaomi)
- 发送消息
- 华为(huawei)
- VIVO
- 推送消息
- OPPO
- 推送消息
- 魅族(flyme)
- 推送消息
- 苹果(apple)
- 谷歌(fcm)
- 极光推送(jiguang)
- 小米(xiaomi)
- 支付集成(pay integration)
- 登录集成
- 分享集成
- 有关更多示例,请参考文档
- For more examples, please refer to the Documentation
路线图 Roadmap
- 请参阅未解决的问题,以获取提出了功能(和已知问题)的列表。
- See the open issues for a list of proposed features (and known issues).
贡献 Contributing
- 复刻该项目(Fork the Project)
- 创建您的功能分支(Create your Feature Branch) (
git checkout -b feature/AmazingFeature
) - 提交您的更改(Commit your Changes) (
git commit -m 'Add some AmazingFeature'
) - 推到分支(Push to the Branch) (
git push origin feature/AmazingFeature
) - 提交拉取请求(Open a Pull Request)
许可证 License
- 根据Apache 2.0许可证分发。有关更多信息,请参见Apache License 2.0
- Distributed under the Apache 2.0 License. See Apache License 2.0 for more information.
联系方式 Contact
shishuihao - - [email protected]
下面链接(Project Link): https://github.com/shishuihao/third-party-api
致谢 Acknowledgements
捐助 Donate
如果您觉得我的项目对您有帮助,并且您愿意给予我一点小小的支持,您可以通过以下方式向我捐助,这样可以维持项目持续地发展,灰常感谢!(/ω\)
支付宝(Alipay) | 微信(Wechat) |
---|---|
❤❤❤
捐助者名单 Donor list
(如果这里还没有你的名字?请发邮件至 [email protected] 告诉我)
捐助日期 | 捐助者 | 捐助金额 |
---|