chore: 初始开源发布

iotlcm-upstream-chan:运营商上游通道适配服务(统一 /sim/* 协议)。

- 内联原私有依赖:yunze-public → internal/pub/(10 包 18 文件),
  yunze-pb/pb → internal/pb/(9 文件);Consul 注册改用官方
  gogf/gf/contrib/registry/consul/v2(API 兼容)
- Go module:yz-svr → git.5iot.com/iotlcm-public/iotlcm-upstream-chan
- 修复 mingqian 包测试:实现重构后 `adapter.operations` 字段已移除,
  测试断言按当前实现语义重写(不改产品行为)
- 凭据与内部标识脱敏:MySQL/Redis/Consul 凭据、私网与生产 IP、
  内网域名、真实手机号、注释里的真实 token/transid
- 移除内部资产:CI 触发器、生产通道种子 SQL、真实凭据测试资源文档
- Dockerfile 改用公共基础镜像,移除写死的 registry 凭据
- 补 Apache-2.0 LICENSE,重写 README,LF 行尾 + .gitattributes
This commit is contained in:
MiFaZhan
2026-10-22 15:42:29 +08:00
commit 96b1edff45
191 changed files with 30805 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
package xjpubmodel
type InfoModel struct {
Type string `json:"type"`
Name string `json:"name"`
Title string `json:"title"`
Description string `json:"description"`
Version string `json:"version"`
Build string `json:"build"`
Commit string `json:"commit"`
Data map[string]interface{} `json:"data"`
}
func NewInfoModel() *InfoModel {
return &InfoModel{
Data: make(map[string]interface{}),
}
}
@@ -0,0 +1,12 @@
// package response
// @Link https://github.com/xiujiecn/xiu-admin
// @Copyright Copyright (c) 2025 LiXiujie
// @Author Lxj <li@xiujie.cn>
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
package response
type PageResult struct {
Page int `json:"page"`
PageSize int `json:"pageSize"`
Total int `json:"total"`
}
@@ -0,0 +1,67 @@
// package response
// @Link https://github.com/xiujiecn/xiu-admin
// @Copyright Copyright (c) 2025 LiXiujie
// @Author Lxj <li@xiujie.cn>
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
package response
import (
"fmt"
"io"
"net/http"
"time"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/net/ghttp"
"github.com/gogf/gf/v2/os/gtime"
)
// 泛型
type ResponseGeneric[T any] struct {
Code int `json:"code"`
Message string `json:"message"`
Data T `json:"data"`
}
type JsonResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data"`
Error interface{} `json:"error"`
}
func Json(r *ghttp.Request, code int, message string, data ...interface{}) {
var responseData interface{}
if len(data) > 0 {
responseData = data[0]
} else {
responseData = g.Map{}
}
// g.Log().Infof(r.GetCtx(), "response.Json: %v", responseData)
r.Response.WriteJson(JsonResponse{
Code: code,
Message: message,
Data: responseData,
})
}
func JsonExit(r *ghttp.Request, code int, message string, data ...interface{}) {
Json(r, code, message, data...)
r.ExitAll()
}
// 向前端返回Excel文件 参数 content 为上面生成的io.ReadSeeker, fileTag 为返回前端的文件名
func Excel(r *ghttp.Request, content io.ReadSeeker, fileTag string) {
fileName := fmt.Sprintf("%s%s%s.xlsx", gtime.Now().Format("Ymdhis"), `_`, fileTag)
r.Response.Header().Set("Content-Type", "application/vnd.ms-excel")
r.Response.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=%s", fileName))
http.ServeContent(r.Response.Writer, r.Request, fileTag, time.Now(), content)
}
// 向前端返回Json文件 参数 content 为上面生成的io.ReadSeeker, fileTag 为返回前端的文件名
func JsonFile(r *ghttp.Request, content io.ReadSeeker, fileTag string) {
fileName := fmt.Sprintf("%s%s%s.json", gtime.Now().Format("Ymdhis"), `_`, fileTag)
r.Response.Header().Set("Content-Type", "application/json")
r.Response.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=%s", fileName))
http.ServeContent(r.Response.Writer, r.Request, fileTag, time.Now(), content)
}
+48
View File
@@ -0,0 +1,48 @@
package xjpubmodel
type SimKey struct {
ChanKey string `json:"chanKey" dc:"通道标识"`
ICCID string `json:"iccid" dc:"联网卡集成电路卡识别码20位"`
}
// 物联网卡在线信息实时查询 请求参数
type SimSessionInput struct {
SimKeys []*SimKey `json:"simKeys" dc:"SIM卡标识列表"`
}
type SimSessionItem struct {
*SimKey
ApnId string `json:"apnId" dc:"APN ID"`
Rat string `json:"rat" dc:"接入方式"`
Ipv4 string `json:"ipv4" dc:"IPV4"`
Ipv6 string `json:"ipv6" dc:"IPV6"`
Ipv6Prefix string `json:"ipv6Prefix" dc:"IPV6前缀"`
Status string `json:"status" dc:"状态(0:用户在线 -1:用户不在线 -2:未查询到会话信息)"`
CreateTime string `json:"createTime" dc:"创建时间"`
ApiStatus int `json:"apiStatus" dc:"API状态"`
ApiMessage string `json:"apiMessage" dc:"API消息"`
}
// 物联网卡在线信息实时查询 响应参数
type SimSessionOutput struct {
Items []*SimSessionItem `json:"items" dc:"SIM卡会话列表"`
}
// 物联网卡卡状态查询 请求参数
type SimCardStatusInput struct {
SimKeys []*SimKey `json:"simKeys" dc:"SIM卡标识列表"`
}
// 物联网卡卡状态查询 响应参数
type SimCardStatusOutput struct {
Items []*SimCardStatusItem `json:"items" dc:"SIM卡状态列表"`
}
// {"cardStatus":"2","lastChangeDate":"2024-05-30 22:05:31"}]
type SimCardStatusItem struct {
*SimKey
CardStatus int `json:"cardStatus" dc:"卡状态"`
LastChangeDate string `json:"lastChangeDate" dc:"最后变更时间"`
ApiStatus int `json:"apiStatus" dc:"API状态"`
ApiMessage string `json:"apiMessage" dc:"API消息"`
}
+91
View File
@@ -0,0 +1,91 @@
package xjpubmodel
import (
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/util/gconv"
)
type MetricItem struct {
Name string `json:"name"`
Value float64 `json:"value"`
Time *gtime.Time `json:"time"`
}
func (m *MetricItem) SetValue(value interface{}) {
m.Value = gconv.Float64(value)
m.Time = gtime.Now()
}
func (m *MetricItem) GetValue() float64 {
return m.Value
}
func (m *MetricItem) GetTime() *gtime.Time {
return m.Time
}
func (m *MetricItem) GetName() string {
return m.Name
}
func (m *MetricItem) SetName(name string) {
m.Name = name
}
func (m *MetricItem) AddValue(value interface{}) {
m.Value += gconv.Float64(value)
m.Time = gtime.Now()
}
func (m *MetricItem) Inc() {
m.Value++
m.Time = gtime.Now()
}
func (m *MetricItem) Dec() {
m.Value--
m.Time = gtime.Now()
}
type MetricData struct {
MetricClientCount MetricItem `json:"clientCount"` // 当前在线数
MetricConnectedCounter MetricItem `json:"connectedCounter"` // 连接数
MetricDisconnectedCounter MetricItem `json:"disconnectedCounter"` // 断开连接数
MetricRecvPkgCount MetricItem `json:"recvPkgCount"` // 接收包数
MetricSendPkgCount MetricItem `json:"sendPkgCount"` // 发送包数
MetricRecvPkgSize MetricItem `json:"recvPkgSize"` // 接收包大小
MetricSendPkgSize MetricItem `json:"sendPkgSize"` // 发送包大小
MetricRecvPkgTime MetricItem `json:"recvPkgTime"` // 接收包时间(毫秒)
MetricSendPkgTime MetricItem `json:"sendPkgTime"` // 发送包时间(毫秒)
MetricSubTopicCount MetricItem `json:"subTopicCount"` // 订阅主题数
MetricAuthSuccessCount MetricItem `json:"authSuccessCount"` // 认证成功数
MetricAuthFailCount MetricItem `json:"authFailCount"` // 认证失败数
MetricAuthCostTime MetricItem `json:"authCostTime"` // 认证耗时
MetricUpMsgConnectCostTime MetricItem `json:"upMsgConnectCostTime"` // 上行消息连接耗时(毫秒)
MetricUpMsgDataCostTime MetricItem `json:"upMsgDataCostTime"` // 上行消息数据耗时(毫秒)
MetricUpMsgDisconnectCostTime MetricItem `json:"upMsgDisconnectCostTime"` // 上行消息断开连接耗时(毫秒)
MetricTopicCount MetricItem `json:"topicCount"` // 累计主题数
MetricProcessMemSize MetricItem `json:"processMemSize"` // 进程内存大小
MetricProcessCpuUsage MetricItem `json:"processCpuUsage"` // 进程CPU使用率
MetricProcessThreads MetricItem `json:"processThreads"` // 进程线程数
MetricProcessGoroutines MetricItem `json:"processGoroutines"` // 进程协程数
MetricSysCpuNum MetricItem `json:"sysCpuNum"` // 系统CPU数量
MetricSysCpuCores MetricItem `json:"sysCpuCores"` // 系统CPU核数
MetricSysCpuUsage MetricItem `json:"sysCpuUsage"` // 系统CPU使用率
MetricSysCpuLoad1 MetricItem `json:"sysCpuLoad1"` // 系统CPU负载1
MetricSysCpuLoad5 MetricItem `json:"sysCpuLoad5"` // 系统CPU负载2
MetricSysCpuLoad15 MetricItem `json:"sysCpuLoad15"` // 系统CPU负载3
MetricSysMemTotal MetricItem `json:"sysMemTotal"` // 系统内存总量
MetricSysMemUsage MetricItem `json:"sysMemUsage"` // 系统内存使用率
MetricSysDiskTotal MetricItem `json:"sysDiskTotal"` // 系统磁盘总量
MetricSysDiskUsage MetricItem `json:"sysDiskUsage"` // 系统磁盘使用率
MetricWaitMsgCount MetricItem `json:"waitMsgCount"` // 等待消息数量
MetricOneDeviceWaitMsgCount MetricItem `json:"oneDeviceWaitMsgCount"` // 同一个设备等待消息数量
MetricRecvMsgFailCount MetricItem `json:"recvMsgFailCount"` // 接收消息处理失败数
MetricRecvMsgWaitCostTime MetricItem `json:"recvMsgWaitCostTime"` // 接收消息等待耗时
}
type XjServerInfo struct {
NodeName string `json:"nodeName"`
SvrType int `json:"svrType"`
SvrCode string `json:"svrCode"` // 服务器编号
ShardId int64 `json:"shardId"` // 分片ID
StartTime *gtime.Time `json:"startTime"` // 启动时间
SysIpLan string `json:"sysIpLan"` // 内网IP
SysIpWan string `json:"sysIpWan"` // 外网IP
AppVersion string `json:"appVersion"` // 程序版本
TenantId string `json:"tenantId"` // 租户ID
ReportInterval int64 `json:"reportInterval"` // 上报间隔
}