✨ 初始化项目
This commit is contained in:
104
operation/api.go
Normal file
104
operation/api.go
Normal file
@@ -0,0 +1,104 @@
|
||||
/**
|
||||
* @Author: Echo
|
||||
* @Author:1711788888@qq.com
|
||||
* @Date: 2021/5/29 18:38
|
||||
* @Desc: 运营管理
|
||||
*/
|
||||
|
||||
package operation
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"git.echol.cn/loser/tencent-im/internal/core"
|
||||
)
|
||||
|
||||
const (
|
||||
serviceOperation = "openconfigsvr"
|
||||
serviceOpenMessage = "open_msg_svc"
|
||||
serviceConfig = "ConfigSvc"
|
||||
commandGetAppInfo = "getappinfo"
|
||||
commandGetHistory = "get_history"
|
||||
commandGetIPList = "GetIPList"
|
||||
)
|
||||
|
||||
type API interface {
|
||||
// GetOperationData 拉取运营数据
|
||||
// App 管理员可以通过该接口拉取最近30天的运营数据,可拉取的字段见下文可拉取的运营字段。
|
||||
// 点击查看详细文档:
|
||||
// https://cloud.tencent.com/document/product/269/4193
|
||||
GetOperationData(fields ...FieldType) (data []*OperationData, err error)
|
||||
|
||||
// GetHistoryData 下载最近消息记录
|
||||
// App 管理员可以通过该接口获取 App 中最近7天中某天某小时的所有单发或群组消息记录的下载地址
|
||||
// 点击查看详细文档:
|
||||
// https://cloud.tencent.com/document/product/269/1650
|
||||
GetHistoryData(chatType ChatType, msgTime time.Time) (files []*HistoryFile, err error)
|
||||
|
||||
// GetIPList 获取服务器IP地址
|
||||
// 基于安全等考虑,您可能需要获知服务器的 IP 地址列表,以便进行相关限制。
|
||||
// App 管理员可以通过该接口获得 SDK、第三方回调所使用到的服务器 IP 地址列表或 IP 网段信息。
|
||||
// 点击查看详细文档:
|
||||
// https://cloud.tencent.com/document/product/269/45438
|
||||
GetIPList() (ips []string, err error)
|
||||
}
|
||||
|
||||
type api struct {
|
||||
client core.Client
|
||||
}
|
||||
|
||||
func NewAPI(client core.Client) API {
|
||||
return &api{client: client}
|
||||
}
|
||||
|
||||
// GetOperationData 拉取运营数据
|
||||
// App 管理员可以通过该接口拉取最近30天的运营数据,可拉取的字段见下文可拉取的运营字段。
|
||||
// 点击查看详细文档:
|
||||
// https://cloud.tencent.com/document/product/269/4193
|
||||
func (a *api) GetOperationData(fields ...FieldType) (data []*OperationData, err error) {
|
||||
req := &getOperationDataReq{Fields: fields}
|
||||
resp := &getOperationDataResp{}
|
||||
|
||||
if err = a.client.Post(serviceOperation, commandGetAppInfo, req, resp); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
data = resp.Data
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetHistoryData 下载最近消息记录
|
||||
// App 管理员可以通过该接口获取 App 中最近7天中某天某小时的所有单发或群组消息记录的下载地址
|
||||
// 点击查看详细文档:
|
||||
// https://cloud.tencent.com/document/product/269/1650
|
||||
func (a *api) GetHistoryData(chatType ChatType, msgTime time.Time) (files []*HistoryFile, err error) {
|
||||
req := &getHistoryDataReq{ChatType: chatType, MsgTime: msgTime.Format("2006010215")}
|
||||
resp := &getHistoryDataResp{}
|
||||
|
||||
if err = a.client.Post(serviceOpenMessage, commandGetHistory, req, resp); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
files = resp.Files
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetIPList 获取服务器IP地址
|
||||
// 基于安全等考虑,您可能需要获知服务器的 IP 地址列表,以便进行相关限制。
|
||||
// App 管理员可以通过该接口获得 SDK、第三方回调所使用到的服务器 IP 地址列表或 IP 网段信息。
|
||||
// 点击查看详细文档:
|
||||
// https://cloud.tencent.com/document/product/269/45438
|
||||
func (a *api) GetIPList() (ips []string, err error) {
|
||||
req := &getIPListReq{}
|
||||
resp := &getIPListResp{}
|
||||
|
||||
if err = a.client.Post(serviceConfig, commandGetIPList, req, resp); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
ips = resp.IPList
|
||||
|
||||
return
|
||||
}
|
51
operation/enum.go
Normal file
51
operation/enum.go
Normal file
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* @Author: Echo
|
||||
* @Author:1711788888@qq.com
|
||||
* @Date: 2021/9/7 10:28
|
||||
* @Desc: 运营管理枚举参数
|
||||
*/
|
||||
|
||||
package operation
|
||||
|
||||
type (
|
||||
// ChatType 聊天类型
|
||||
ChatType string
|
||||
|
||||
// FieldType 运营数据字段类型
|
||||
FieldType string
|
||||
)
|
||||
|
||||
const (
|
||||
ChatTypeC2C ChatType = "C2C" // 单聊消息
|
||||
ChatTypeGroup ChatType = "Group" // 群聊消息
|
||||
|
||||
FieldTypeAppName FieldType = "AppName" // 应用名称
|
||||
FieldTypeAppId FieldType = "AppId" // 应用 SDKAppID
|
||||
FieldTypeCompany FieldType = "Company" // 所属客户名称
|
||||
FieldTypeActiveUserNum FieldType = "ActiveUserNum" // 活跃用户数
|
||||
FieldTypeRegisterUserNumOneDay FieldType = "RegistUserNumOneDay" // 新增注册人数
|
||||
FieldTypeRegisterUserNumTotal FieldType = "RegistUserNumTotal" // 累计注册人数
|
||||
FieldTypeLoginTimes FieldType = "LoginTimes" // 登录次数
|
||||
FieldTypeLoginUserNum FieldType = "LoginUserNum" // 登录人数
|
||||
FieldTypeUpMsgNum FieldType = "UpMsgNum" // 上行消息数
|
||||
FieldTypeSendMsgUserNum FieldType = "SendMsgUserNum" // 发消息人数
|
||||
FieldTypeAPNSMsgNum FieldType = "APNSMsgNum" // APNs 推送数
|
||||
FieldTypeC2CUpMsgNum FieldType = "C2CUpMsgNum" // 上行消息数(C2C)
|
||||
FieldTypeC2CSendMsgUserNum FieldType = "C2CSendMsgUserNum" // 发消息人数(C2C)
|
||||
FieldTypeC2CAPNSMsgNum FieldType = "C2CAPNSMsgNum" // APNs 推送数(C2C)
|
||||
FieldTypeMaxOnlineNum FieldType = "MaxOnlineNum" // 最高在线人数
|
||||
FieldTypeChainIncrease FieldType = "ChainIncrease" // 关系链对数增加量
|
||||
FieldTypeChainDecrease FieldType = "ChainDecrease" // 关系链对数删除量
|
||||
FieldTypeGroupUpMsgNum FieldType = "GroupUpMsgNum" // 上行消息数(群)
|
||||
FieldTypeGroupSendMsgUserNum FieldType = "GroupSendMsgUserNum" // 发消息人数(群)
|
||||
FieldTypeGroupAPNSMsgNum FieldType = "GroupAPNSMsgNum" // APNs 推送数(群)
|
||||
FieldTypeGroupSendMsgGroupNum FieldType = "GroupSendMsgGroupNum" // 发消息群组数
|
||||
FieldTypeGroupJoinGroupTimes FieldType = "GroupJoinGroupTimes" // 入群总数
|
||||
FieldTypeGroupQuitGroupTimes FieldType = "GroupQuitGroupTimes" // 退群总数
|
||||
FieldTypeGroupNewGroupNum FieldType = "GroupNewGroupNum" // 新增群组数
|
||||
FieldTypeGroupAllGroupNum FieldType = "GroupAllGroupNum" // 累计群组数
|
||||
FieldTypeGroupDestroyGroupNum FieldType = "GroupDestroyGroupNum" // 解散群个数
|
||||
FieldTypeCallBackReq FieldType = "CallBackReq" // 回调请求数
|
||||
FieldTypeCallBackRsp FieldType = "CallBackRsp" // 回调应答数
|
||||
FieldTypeDate FieldType = "Date" // 日期
|
||||
)
|
91
operation/types.go
Normal file
91
operation/types.go
Normal file
@@ -0,0 +1,91 @@
|
||||
/**
|
||||
* @Author: Echo
|
||||
* @Author:1711788888@qq.com
|
||||
* @Date: 2021/5/29 18:39
|
||||
* @Desc: 运营管理数据类型
|
||||
*/
|
||||
|
||||
package operation
|
||||
|
||||
import "git.echol.cn/loser/tencent-im/internal/types"
|
||||
|
||||
type (
|
||||
// 拉取运营数据(请求)
|
||||
getOperationDataReq struct {
|
||||
Fields []FieldType `json:"RequestField,omitempty"` // 该字段用来指定需要拉取的运营数据,不填默认拉取所有字段。
|
||||
}
|
||||
|
||||
// 拉取运营数据(响应)
|
||||
getOperationDataResp struct {
|
||||
types.BaseResp
|
||||
Data []*OperationData `json:"Result"`
|
||||
}
|
||||
|
||||
// OperationData 运营数据
|
||||
OperationData struct {
|
||||
AppId string `json:"AppId"` // 应用AppID
|
||||
AppName string `json:"AppName"` // 应用名称
|
||||
Company string `json:"Company"` // 所属客户名称
|
||||
ActiveUserNum string `json:"ActiveUserNum"` // 活跃用户数
|
||||
RegistUserNumOneDay string `json:"RegistUserNumOneDay"` // 新增注册人数
|
||||
RegistUserNumTotal string `json:"RegistUserNumTotal"` // 累计注册人数
|
||||
LoginTimes string `json:"LoginTimes"` // 登录次数
|
||||
LoginUserNum string `json:"LoginUserNum"` // 登录人数
|
||||
UpMsgNum string `json:"UpMsgNum"` // 上行消息数
|
||||
DownMsgNum string `json:"DownMsgNum"` // 下行消息数
|
||||
SendMsgUserNum string `json:"SendMsgUserNum"` // 发消息人数
|
||||
APNSMsgNum string `json:"APNSMsgNum"` // APNs推送数
|
||||
C2CUpMsgNum string `json:"C2CUpMsgNum"` // 上行消息数(C2C)
|
||||
C2CSendMsgUserNum string `json:"C2CSendMsgUserNum"` // 发消息人数(C2C)
|
||||
C2CAPNSMsgNum string `json:"C2CAPNSMsgNum"` // APNs推送数(C2C)
|
||||
C2CDownMsgNum string `json:"C2CDownMsgNum"` // 下行消息数(C2C)
|
||||
MaxOnlineNum string `json:"MaxOnlineNum"` // 最高在线人数
|
||||
ChainDecrease string `json:"ChainDecrease"` // 关系链对数删除量
|
||||
ChainIncrease string `json:"ChainIncrease"` // 关系链对数增加量
|
||||
GroupUpMsgNum string `json:"GroupUpMsgNum"` // 上行消息数(群)
|
||||
GroupDownMsgNum string `json:"GroupDownMsgNum"` // 下行消息数(群)
|
||||
GroupSendMsgUserNum string `json:"GroupSendMsgUserNum"` // 发消息人数(群)
|
||||
GroupAPNSMsgNum string `json:"GroupAPNSMsgNum"` // APNs推送数(群)
|
||||
GroupSendMsgGroupNum string `json:"GroupSendMsgGroupNum"` // 发消息群组数
|
||||
GroupJoinGroupTimes string `json:"GroupJoinGroupTimes"` // 入群总数
|
||||
GroupQuitGroupTimes string `json:"GroupQuitGroupTimes"` // 退群总数
|
||||
GroupNewGroupNum string `json:"GroupNewGroupNum"` // 新增群组数
|
||||
GroupAllGroupNum string `json:"GroupAllGroupNum"` // 累计群组数
|
||||
GroupDestroyGroupNum string `json:"GroupDestroyGroupNum"` // 解散群个数
|
||||
CallBackReq string `json:"CallBackReq"` // 回调请求数
|
||||
CallBackRsp string `json:"CallBackRsp"` // 回调应答数
|
||||
Date string `json:"Date"` // 日期
|
||||
}
|
||||
|
||||
// 获取历史数据(请求)
|
||||
getHistoryDataReq struct {
|
||||
ChatType ChatType `json:"ChatType"` // (必填)消息类型,C2C 表示单发消息 Group 表示群组消息
|
||||
MsgTime string `json:"MsgTime"` // (必填)需要下载的消息记录的时间段,2015120121表示获取2015年12月1日21:00 - 21:59的消息的下载地址。该字段需精确到小时。每次请求只能获取某天某小时的所有单发或群组消息记录
|
||||
}
|
||||
|
||||
// 获取历史数据(响应)
|
||||
getHistoryDataResp struct {
|
||||
types.BaseResp
|
||||
Files []*HistoryFile `json:"File"` // 消息记录文件下载信息
|
||||
}
|
||||
|
||||
// HistoryFile 历史数据文件
|
||||
HistoryFile struct {
|
||||
URL string `json:"URL"` // 消息记录文件下载地址
|
||||
ExpireTime string `json:"ExpireTime"` // 下载地址过期时间,请在过期前进行下载,若地址失效,请通过该接口重新获取
|
||||
FileSize int `json:"FileSize"` // GZip 压缩前的文件大小(单位 Byte)
|
||||
FileMD5 string `json:"FileMD5"` // GZip 压缩前的文件 MD5
|
||||
GzipSize int `json:"GzipSize"` // GZip 压缩后的文件大小(单位 Byte)
|
||||
GzipMD5 string `json:"GzipMD5"` // GZip 压缩后的文件 MD5
|
||||
}
|
||||
|
||||
// 获取服务器IP地址(请求)
|
||||
getIPListReq struct {
|
||||
}
|
||||
|
||||
// 获取服务器IP地址(响应)
|
||||
getIPListResp struct {
|
||||
types.BaseResp
|
||||
IPList []string `json:"IPList"` // 服务器IP列表
|
||||
}
|
||||
)
|
Reference in New Issue
Block a user