GithubHelp home page GithubHelp logo

sms-gateway's Introduction

短信网关总体设计

在消息系统中,短信网关和短信渠道的对接是最核心的功能。其中短信网关是对外提供服务的接口,所有需要发送短信的操作都需要通过短信网关分发到对应的渠道上。一旦定型,后续就很少,也很难调整。而短信渠道是接收网关的请求,调用渠道接口执行真正的发送短信操作。每个渠道的接口,传输方式都不尽相同,所以在这里,短信网关相对短信渠道模块的作用,类似设计模式模式中的wrapper,封装各个渠道的差异,对网关呈现统一的接口。而网关的功能就是为业务提供通用接口,一些和渠道交互的公共操作,也会放置到网关中。

一、功能概述

消息系统对其他系统提供的服务包括渠道商管理、签名管理、短信模版管理、应用管理、业务类型管理、短信记录管理等。

  • 渠道商管理:短息网关维护多个渠道商,配置渠道商的身份ID、身份key等其他信息,支持的渠道商:腾讯云、阿里云等
  • 签名管理:配置渠道商下不同的短信签名,为后续发送短信提供数据基础。
  • 短信模版管理:配置不同短信模版信息,可在也业务配置中选择不同的模版信息,注:不同渠道模版略有不同,详情参见说明文档。
  • 应用管理:配置短信网关对接的应用信息,可在应用管理中配置应用可用短信条数、每分钟限制短信条数等信息,通过应用可用条数控制不同应用使用短信数量。
  • 业务管理:配置发送短信业务场景,如注册业务、登录业务、下单通知、支付成功通知等不同的业务信息。添加业务信息后,生成业务编号,业务系统根据业务编号发送短信模版。

二、整体架构

smsGolang

三、管理平台

杰子学编程-渠道商配置

杰子学编程-添加渠道商

杰子学编程-短信签名模版

杰子学编程-添加短信签名

杰子学编程-模版列表

杰子学编程-添加短信模版

杰子学编程-应用管理

杰子学编程-添加应用

杰子学编程-业务模版配置

杰子学编程-添加业务模版

杰子学编程-发送记录

杰子学编程-发送短信测试页面

四、服务API

请求地址:/api/v1/send-message

请求方式:POST

请求参数:

字段名称 字段说明 字段类型 是否必填 备注
businessNo 业务编号 String
phones 手机号集合 List 多个手机号","分割
params 模版填充参数 List 多个参数","分割

请求参数示例:

{
    "businessNo": "B-000003",
    "phones": [
        "+86182XXXXXX68"
    ],
    "params": ["123456"]
}

响应参数:

字段名称 字段说明 字段类型 是否必填 备注
requestId requestId String
code 状态码 Int
msg 渠道返回消息 String
data 响应数据 Int

响应参数示例:

{
  "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
}

无、数据库设计

5.1 短信渠道配置表

配置不同渠道商信息,如腾讯云、阿里云、七牛云等

sms_service_provider_config (服务商配置表)

字段名称 字段说明 字段类型 是否必填 备注
channel_no 渠道商编程 String Tencent、AliYun
provider_name 服务商名称 String 阿里云、腾讯云
provider_no 服务商编号 String Aly、txy
access_key_id 身份标识 String 腾讯:SecretId
access_key_secret 身份认证密钥 String 腾讯:SecretKey
endpoint 调用域名 String
sdk_app_id 应用ID String 腾讯云必填
region 地域列表 String 腾讯云必填:ap-beijing、ap-guangzhou、ap-nanjing
remark 备注 String
ext_json 扩展字段 String
status 状态 Bool 1启用 0 禁用

5.2 短信签名配置表

sms_sign_config(短信签名配置表)

字段编号 字段说明 字段类型 是否必填 备注
sign_name 签名名称 String
provider_no 服务商编号 String Aly、txy
provider_name 服务商名称 String
remark 备注 String
ext_json 扩展字段 String
status 状态 Bool 1启用 0 禁用

5.3 短信模版配置表

sms_template_config(短信模版配置表)

字段编号 字段说明 字段类型 是否必填 备注
sign_name 签名名称 String
provider_no 服务商编号 String Aly、txy
template_no 模版编号 String
template_content 模版内容 String
third_party_template_no 第三方模版编号 String
remark 备注 String
ext_json 扩展字段 String
status 状态 Bool 1启用 0 禁用

5.4 应用配置表

sms_app_config (应用管理配置表)

字段编号 字段说明 字段类型 是否必填 备注
app_no 应用ID String
app_name 应用名称 String Aly、txy
available_number 可用数量 Int 可用短信包
current_limiting 限流数量 Int 每分钟允许发送短信数量
use_number 已用数量 Int
remark 备注 String
ext_json 扩展字段 String
status 状态 Bool 1启用 0 禁用

5.5 业务配置表

sms_business_config(业务配置表)

字段编号 字段说明 字段类型 是否必填 备注
app_no 应用ID String
business_name 业务名称 String Aly、txy
business_no 业务编号 String
template_no 模版编号 String
business_desc 业务说明 String
remark 备注 String
ext_json 扩展字段 String
status 状态 Bool 1启用 0 禁用

5.6 发送日志表

sms_send_log(发送记录表)

字段编号 字段说明 字段类型 是否必填 备注
app_no 应用ID String
business_no 业务编号 String
status 状态 Int
fee 计价条数 Int
phone_number 发送手机号 String
message 接口响应消息 String
code 接口响应状态码 String
content 发送内容 String
remark 备注 String
ext_json 扩展字段 String

六、技术栈

go-admin

杰子学编程 (julywhj.cn)

Mysql、Redis、

七、源码

关注公众号:杰子学编程,回复: "短信网关" 获取。

qrcode_for_gh_5d871c6cb930_258

sms-gateway's People

Contributors

hongjiewang avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.