84 lines
2.7 KiB
Go
84 lines
2.7 KiB
Go
package chat
|
||
|
||
import (
|
||
"strconv"
|
||
|
||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||
)
|
||
|
||
// QueryChatRecordsParams 查询聊天记录入参。均为可选,建议至少给一个身份或时间范围,避免全量扫描。
|
||
type QueryChatRecordsParams struct {
|
||
GrUid string // 高热 uid(精确匹配,多个用英文逗号分隔)
|
||
Uid string // CP uid(精确匹配,多个用英文逗号分隔)
|
||
Gkey string // 游戏 key
|
||
Type string // 频道类型 1私聊 2喇叭 3邮件 4世界 5国家 6工会 7队伍 8附近 9其他
|
||
Sid string // 区服 ID(多个用英文逗号分隔)
|
||
Keyword string // 内容关键词(分词匹配)
|
||
DateStart string // 起始时间 Y-m-d H:i:s(按 ctime 过滤)
|
||
DateEnd string // 截止时间 Y-m-d H:i:s
|
||
Page int // 页码,默认 1
|
||
PageSize int // 每页条数,默认 100,上限 500
|
||
}
|
||
|
||
type QueryChatRecordsRequest struct {
|
||
*requests.RpcRequest
|
||
}
|
||
|
||
// QueryChatRecordsResponse 聊天记录查询响应。
|
||
// Items 为 ES child 文档原样字段(map),字段随 ES mapping 变化,调用方按需取用。
|
||
type QueryChatRecordsResponse struct {
|
||
*responses.BaseResponse
|
||
Code int `json:"code"`
|
||
Msg string `json:"msg"`
|
||
Data QueryChatRecordsData `json:"data"`
|
||
}
|
||
|
||
type QueryChatRecordsData struct {
|
||
Total int `json:"total"`
|
||
Page int `json:"page"`
|
||
PageSize int `json:"page_size"`
|
||
Items []map[string]interface{} `json:"items"`
|
||
}
|
||
|
||
// CreateQueryChatRecordsRequest 组装请求:仅写入非空参数为 FormParams。
|
||
func CreateQueryChatRecordsRequest(params QueryChatRecordsParams) (req *QueryChatRecordsRequest) {
|
||
req = &QueryChatRecordsRequest{
|
||
RpcRequest: &requests.RpcRequest{},
|
||
}
|
||
req.InitWithApiInfo(HOST, VERSION, "/api/internal/chatRecords")
|
||
|
||
form := map[string]string{}
|
||
putNonEmpty(form, "gr_uid", params.GrUid)
|
||
putNonEmpty(form, "uid", params.Uid)
|
||
putNonEmpty(form, "gkey", params.Gkey)
|
||
putNonEmpty(form, "type", params.Type)
|
||
putNonEmpty(form, "sid", params.Sid)
|
||
putNonEmpty(form, "keyword", params.Keyword)
|
||
putNonEmpty(form, "date_start", params.DateStart)
|
||
putNonEmpty(form, "date_end", params.DateEnd)
|
||
if params.Page > 0 {
|
||
form["page"] = strconv.Itoa(params.Page)
|
||
}
|
||
if params.PageSize > 0 {
|
||
form["page_size"] = strconv.Itoa(params.PageSize)
|
||
}
|
||
|
||
req.FormParams = form
|
||
req.Method = requests.POST
|
||
return
|
||
}
|
||
|
||
func CreateQueryChatRecordsResponse() (resp *QueryChatRecordsResponse) {
|
||
resp = &QueryChatRecordsResponse{
|
||
BaseResponse: &responses.BaseResponse{},
|
||
}
|
||
return
|
||
}
|
||
|
||
func putNonEmpty(m map[string]string, key, val string) {
|
||
if val != "" {
|
||
m[key] = val
|
||
}
|
||
}
|