feat: 优化群聊消息手动查询
This commit is contained in:
@@ -50,7 +50,13 @@ func (s *sSysImGroupMessage) List(ctx context.Context, in *sysin.ImGroupMessageL
|
||||
}
|
||||
values := addPageQuery(url.Values{}, in.Page, in.PerPage)
|
||||
setQuery(values, "topic", in.Topic)
|
||||
if in.SeqId > 0 {
|
||||
values.Set("seq_id", strconv.FormatInt(in.SeqId, 10))
|
||||
}
|
||||
setQuery(values, "sender_user_id", in.SenderUserId)
|
||||
setQuery(values, "sender_username", in.SenderUsername)
|
||||
setQuery(values, "sender_nickname", in.SenderNickname)
|
||||
setQuery(values, "group_name", in.GroupName)
|
||||
setQuery(values, "content_type", in.ContentType)
|
||||
setQuery(values, "status", in.Status)
|
||||
setQuery(values, "keyword", in.Keyword)
|
||||
|
||||
@@ -29,16 +29,23 @@ func (in *ImPrivateMessageListInp) Filter(ctx context.Context) error {
|
||||
|
||||
type ImGroupMessageListInp struct {
|
||||
form.PageReq
|
||||
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
||||
Topic string `json:"topic" dc:"群Topic"`
|
||||
SenderUserId string `json:"senderUserId" dc:"发送用户ID"`
|
||||
ContentType string `json:"contentType" dc:"内容类型"`
|
||||
Status string `json:"status" dc:"状态"`
|
||||
Keyword string `json:"keyword" dc:"内容关键词"`
|
||||
CreatedAt []*gtime.Time `json:"createdAt" dc:"发送时间"`
|
||||
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
||||
Topic string `json:"topic" dc:"群Topic"`
|
||||
SeqId int64 `json:"seqId" dc:"消息序号"`
|
||||
SenderUserId string `json:"senderUserId" dc:"发送用户ID"`
|
||||
SenderUsername string `json:"senderUsername" dc:"发送人用户名"`
|
||||
SenderNickname string `json:"senderNickname" dc:"发送人昵称"`
|
||||
GroupName string `json:"groupName" dc:"群名称"`
|
||||
ContentType string `json:"contentType" dc:"内容类型"`
|
||||
Status string `json:"status" dc:"状态"`
|
||||
Keyword string `json:"keyword" dc:"内容关键词"`
|
||||
CreatedAt []*gtime.Time `json:"createdAt" dc:"发送时间"`
|
||||
}
|
||||
|
||||
func (in *ImGroupMessageListInp) Filter(ctx context.Context) error {
|
||||
in.SenderUsername = strings.TrimSpace(in.SenderUsername)
|
||||
in.SenderNickname = strings.TrimSpace(in.SenderNickname)
|
||||
in.GroupName = strings.TrimSpace(in.GroupName)
|
||||
return filterImMessageList(&in.PageReq, &in.Topic, &in.Keyword, in.ContentType, in.Status)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package sysin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestImGroupMessageListFilterTrimsTextFilters(t *testing.T) {
|
||||
in := &ImGroupMessageListInp{
|
||||
SenderUsername: " alice ",
|
||||
SenderNickname: " 小明 ",
|
||||
GroupName: " 测试群 ",
|
||||
Keyword: " 关键字 ",
|
||||
Topic: " grpTest ",
|
||||
}
|
||||
if err := in.Filter(context.Background()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if in.SenderUsername != "alice" || in.SenderNickname != "小明" || in.GroupName != "测试群" || in.Keyword != "关键字" || in.Topic != "grpTest" {
|
||||
t.Fatalf("message filters were not normalized: %#v", in)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user