当前位置:网站首页>Implementation of API short message gateway based on golang
Implementation of API short message gateway based on golang
2022-07-27 03:47:00 【Julywhj】
The overall design of SMS Gateway
In the message system , The connection between SMS gateway and SMS channel is the core function . SMS gateway is the interface to provide services , All operations that need to send text messages need to be distributed to the corresponding channels through the SMS Gateway . Once shaped , There are few follow-up , It's also hard to adjust . The short message channel is to receive the request of the gateway , Call the channel interface to perform the real operation of sending SMS . The interface of each channel , The transmission modes are different , So here , The function of SMS Gateway relative to SMS channel module , Similar to... In design patterns wrapper, Encapsulate the differences of various channels , Present a unified interface to the gateway . The function of gateway is to provide general interface for business , Some public operations that interact with channels , It will also be placed in the gateway .
One 、 Function Overview
The services provided by the message system to other systems include channel management 、 Signature management 、 SMS template management 、 Application management 、 Business type management 、 SMS record management .
- Channel management : The short message gateway maintains multiple channel providers , Configure the identity of the channel provider ID、 identity key Other information , Supported channel providers : Tencent cloud 、 Alicloud, etc
- Signature management : Configure different SMS signatures under channel providers , Provide data basis for subsequent SMS sending .
- SMS template management : Configure different SMS template information , You can also select different template information in the business configuration , notes : Different channel templates are slightly different , For details, please refer to the instruction document .
- Application management : Configure the application information of SMS Gateway docking , You can configure the number of SMS messages available in the application management 、 Limit the number of messages per minute , Control the number of SMS messages used by different applications through the number of available applications .
- The business management : Configure the business scenario of sending SMS , Such as registered business 、 Log in to business 、 Order notice 、 Payment success notification and other different business information . After adding business information , Generate business number , The business system sends the SMS template according to the business number .
Two 、 The overall architecture

smsGolang
3、 ... and 、 Management platform

Jiezi learning programming - Channel configuration

Jiezi learning programming - Add channel providers

Jiezi learning programming - SMS signature template

Jiezi learning programming - Add SMS signature

Jiezi learning programming - Template list

Jiezi learning programming - Add SMS template

Jiezi learning programming - Application management

Jiezi learning programming - Add application

Jiezi learning programming - Business template configuration

Jiezi learning programming - Add a business template

Jiezi learning programming - Send records

Jiezi learning programming - Send SMS test page
Four 、 service API
Request address :/api/v1/send-message
Request mode :POST
Request parameters :
| Field name | Field description | Field type | If required | remarks |
|---|---|---|---|---|
| businessNo | Business number | String | yes | |
| phones | Mobile number collection | List | yes | Multiple cell phone numbers "," Division |
| params | Template filling parameters | List | no | Multiple parameters "," Division |
Sample request parameters :
{
"businessNo": "B-000003",
"phones": [
"+86182XXXXXX68"
],
"params": ["123456"]
}
Response parameter :
| Field name | Field description | Field type | If required | remarks |
|---|---|---|---|---|
| requestId | requestId | String | yes | |
| code | Status code | Int | yes | |
| msg | The channel returns a message | String | yes | |
| data | The response data | Int | no |
Examples of response parameters :
{
"requestId": "b9c0fd5e-3a43-4039-a224-2a5ae99385e1",
"code": 200,
"msg": "{\"sms_send_status\":[{\"fee\":1,\"message\":\"OK\",\"code\":\"OK\",\"phone\":\"+8618232533068\"}],\"request_id\":\"771D1C9C-74AD-582E-B5EB-5FB12C038497\"}",
"data": 200
}
nothing 、 Database design
5.1 SMS channel configuration table
Configure different channel information , Like Tencent cloud 、 Alibaba cloud 、 Qiniuyun and so on
sms_service_provider_config ( Service provider configuration table )
| Field name | Field description | Field type | If required | remarks |
|---|---|---|---|---|
| channel_no | Channel programming | String | yes | Tencent、AliYun |
| provider_name | Service provider name | String | yes | Alibaba cloud 、 Tencent cloud |
| provider_no | Service provider number | String | yes | Aly、txy |
| access_key_id | Identification | String | yes | tencent :SecretId |
| access_key_secret | Authentication key | String | yes | tencent :SecretKey |
| endpoint | Call domain name | String | yes | |
| sdk_app_id | application ID | String | no | Tencent cloud is required |
| region | List of regions | String | no | Tencent cloud is required :ap-beijing、ap-guangzhou、ap-nanjing |
| remark | remarks | String | no | |
| ext_json | Extension field | String | no | |
| status | state | Bool | yes | 1 Enable 0 Ban |
5.2 SMS signature configuration table
sms_sign_config( SMS signature configuration table )
| Field number | Field description | Field type | If required | remarks |
|---|---|---|---|---|
| sign_name | Signature name | String | yes | |
| provider_no | Service provider number | String | yes | Aly、txy |
| provider_name | Service provider name | String | yes | |
| remark | remarks | String | no | |
| ext_json | Extension field | String | no | |
| status | state | Bool | yes | 1 Enable 0 Ban |
5.3 SMS template configuration table
sms_template_config( SMS template configuration table )
| Field number | Field description | Field type | If required | remarks |
|---|---|---|---|---|
| sign_name | Signature name | String | yes | |
| provider_no | Service provider number | String | yes | Aly、txy |
| template_no | Template number | String | yes | |
| template_content | Template content | String | yes | |
| third_party_template_no | Third party template number | String | yes | |
| remark | remarks | String | no | |
| ext_json | Extension field | String | no | |
| status | state | Bool | yes | 1 Enable 0 Ban |
3.4 Application configuration table
sms_app_config ( Application management configuration table )
| Field number | Field description | Field type | If required | remarks |
|---|---|---|---|---|
| app_no | application ID | String | yes | |
| app_name | apply name | String | yes | Aly、txy |
| available_number | Quantity available | Int | yes | Available SMS packages |
| current_limiting | Current limiting quantity | Int | yes | The number of messages allowed to be sent per minute |
| use_number | Used quantity | Int | yes | |
| remark | remarks | String | no | |
| ext_json | Extension field | String | no | |
| status | state | Bool | yes | 1 Enable 0 Ban |
5.5 Business configuration table
sms_business_config( Business configuration table )
| Field number | Field description | Field type | If required | remarks |
|---|---|---|---|---|
| app_no | application ID | String | yes | |
| business_name | Business name | String | yes | Aly、txy |
| business_no | Business number | String | yes | |
| template_no | Template number | String | yes | |
| business_desc | Business description | String | no | |
| remark | remarks | String | no | |
| ext_json | Extension field | String | no | |
| status | state | Bool | yes | 1 Enable 0 Ban |
5.6 Send log table
sms_send_log( Send record sheet )
| Field number | Field description | Field type | If required | remarks |
|---|---|---|---|---|
| app_no | application ID | String | yes | |
| business_no | Business number | String | yes | |
| status | state | Int | yes | |
| fee | Number of pricing items | Int | yes | |
| phone_number | Send mobile number | String | yes | |
| message | Interface response message | String | yes | |
| code | Interface response status code | String | yes | |
| content | send content | String | yes | |
| remark | remarks | String | no | |
| ext_json | Extension field | String | no |
6、 ... and 、 Technology stack
Jiezi learning programming (julywhj.cn)
Mysql、Redis、
7、 ... and 、 Source code
Official account : Jiezi learning programming , reply : " SMS Gateway " obtain .

边栏推荐
- Insert pictures and videos in typera
- Mysql database related operations
- mysql底层数据结构
- 477-82(236、61、47、74、240、93)
- Practical application of digital twins: smart city project construction solution
- What are "full five unique" and "full two unique"? Any difference?
- "Date: write error: no space left on device" solution
- Food chain (day 79)
- How to optimize MySQL
- The function and application of lpci-252 universal PCI interface can card
猜你喜欢

Source code analysis of openfeign

Spark: calculate the average value of the same key in different partitions (entry level - simple implementation)

Briefly sort out the dualpivotquicksort

Introduction to redis

Mysql database related operations

复盘:DFS与BFS的主要区别,在思想上的区别,代码实现上的区别

The application and significance of digital twins are the main role and conceptual value of electric power.
![[untitled] JDBC connection database read timeout](/img/24/726ed8b3419866244a1b69e6485d7c.png)
[untitled] JDBC connection database read timeout

【树链剖分】模板题

Fastboot刷机
随机推荐
Cocos game practice-04-collision detection and NPC rendering
C语言力扣第43题之字符串相乘。优化竖式
PyCharm中Debug模式进行调试详解
数据库概论 - 数据库的介绍
Spark Learning Notes (VI) -- spark core core programming RDD action operator
768. 最多能完成排序的块 II 贪心
架构基本概念和架构本质
Redis源码学习(33),命令执行过程
Code review pyramid
Deeply understand the underlying data structure and algorithm of MySQL index
Safe-arc/warner power supply maintenance xenon lamp power supply maintenance analysis
Penetration test - post penetration - Trace cleaning
Double disk: the main differences between DFS and BFS, the differences in ideology, and the differences in code implementation
typescript ts 基础知识之接口、泛型
Do you really understand code rollback?
redis秒杀案例,跟着b站尚硅谷老师学习
redis入门练习
Characteristics and experimental suggestions of abbkine abfluor 488 cell apoptosis detection kit
Add support for @data add-on in idea
飞腾腾锐 D2000 荣获数字中国“十大硬核科技”奖