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)
|
values := addPageQuery(url.Values{}, in.Page, in.PerPage)
|
||||||
setQuery(values, "topic", in.Topic)
|
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_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, "content_type", in.ContentType)
|
||||||
setQuery(values, "status", in.Status)
|
setQuery(values, "status", in.Status)
|
||||||
setQuery(values, "keyword", in.Keyword)
|
setQuery(values, "keyword", in.Keyword)
|
||||||
|
|||||||
@@ -29,16 +29,23 @@ func (in *ImPrivateMessageListInp) Filter(ctx context.Context) error {
|
|||||||
|
|
||||||
type ImGroupMessageListInp struct {
|
type ImGroupMessageListInp struct {
|
||||||
form.PageReq
|
form.PageReq
|
||||||
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
||||||
Topic string `json:"topic" dc:"群Topic"`
|
Topic string `json:"topic" dc:"群Topic"`
|
||||||
SenderUserId string `json:"senderUserId" dc:"发送用户ID"`
|
SeqId int64 `json:"seqId" dc:"消息序号"`
|
||||||
ContentType string `json:"contentType" dc:"内容类型"`
|
SenderUserId string `json:"senderUserId" dc:"发送用户ID"`
|
||||||
Status string `json:"status" dc:"状态"`
|
SenderUsername string `json:"senderUsername" dc:"发送人用户名"`
|
||||||
Keyword string `json:"keyword" dc:"内容关键词"`
|
SenderNickname string `json:"senderNickname" dc:"发送人昵称"`
|
||||||
CreatedAt []*gtime.Time `json:"createdAt" 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 {
|
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)
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -108,6 +108,7 @@
|
|||||||
const showDetail = ref(false);
|
const showDetail = ref(false);
|
||||||
const showAction = ref(false);
|
const showAction = ref(false);
|
||||||
const submitting = ref(false);
|
const submitting = ref(false);
|
||||||
|
const hasQueried = ref(!props.group);
|
||||||
const current = ref<Recordable>({});
|
const current = ref<Recordable>({});
|
||||||
const reason = ref('');
|
const reason = ref('');
|
||||||
const actionType = ref<'hide' | 'delete'>('hide');
|
const actionType = ref<'hide' | 'delete'>('hide');
|
||||||
@@ -148,21 +149,28 @@
|
|||||||
schemas,
|
schemas,
|
||||||
});
|
});
|
||||||
const loadDataTable = async (res) => {
|
const loadDataTable = async (res) => {
|
||||||
|
if (props.group && !hasQueried.value) return { list: [], page: 1, pageCount: 0, totalCount: 0 };
|
||||||
const params = { ...searchFormRef.value?.formModel, ...res };
|
const params = { ...searchFormRef.value?.formModel, ...res };
|
||||||
if (isPlatformAdmin.value && !params.tenantId)
|
if (isPlatformAdmin.value && !params.tenantId)
|
||||||
return { list: [], page: 1, pageCount: 0, totalCount: 0 };
|
return { list: [], page: 1, pageCount: 0, totalCount: 0 };
|
||||||
return api.List(params);
|
return api.List(params);
|
||||||
};
|
};
|
||||||
function reloadTable() {
|
function reloadTable() {
|
||||||
|
hasQueried.value = true;
|
||||||
actionRef.value?.reload();
|
actionRef.value?.reload();
|
||||||
}
|
}
|
||||||
async function handleReset() {
|
async function handleReset() {
|
||||||
const defaults: Recordable = {};
|
const defaults: Recordable = {};
|
||||||
if (isPlatformAdmin.value) defaults.tenantId = imQueryTenantOptions.value[0]?.value;
|
if (isPlatformAdmin.value) defaults.tenantId = imQueryTenantOptions.value[0]?.value;
|
||||||
await setFieldsValue(defaults);
|
await setFieldsValue(defaults);
|
||||||
reloadTable();
|
if (props.group) hasQueried.value = false;
|
||||||
|
actionRef.value?.reload();
|
||||||
}
|
}
|
||||||
function handleExport() {
|
function handleExport() {
|
||||||
|
if (props.group && !hasQueried.value) {
|
||||||
|
message.warning('请先查询群聊消息');
|
||||||
|
return;
|
||||||
|
}
|
||||||
const params = { ...searchFormRef.value?.formModel };
|
const params = { ...searchFormRef.value?.formModel };
|
||||||
if (isPlatformAdmin.value && !params.tenantId) {
|
if (isPlatformAdmin.value && !params.tenantId) {
|
||||||
message.warning('请选择租户');
|
message.warning('请选择租户');
|
||||||
@@ -213,7 +221,7 @@
|
|||||||
await setFieldsValue({ tenantId: imQueryTenantOptions.value[0].value });
|
await setFieldsValue({ tenantId: imQueryTenantOptions.value[0].value });
|
||||||
else message.warning('暂无可用租户');
|
else message.warning('暂无可用租户');
|
||||||
}
|
}
|
||||||
reloadTable();
|
if (!props.group) reloadTable();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ export function createMessageSchemas(group: boolean) {
|
|||||||
{
|
{
|
||||||
field: 'topic',
|
field: 'topic',
|
||||||
component: 'NInput',
|
component: 'NInput',
|
||||||
label: group ? '群Topic' : '会话Topic',
|
label: group ? '群号/Topic' : '会话Topic',
|
||||||
componentProps: { placeholder: '请输入Topic' },
|
componentProps: { placeholder: group ? '请输入群号或Topic' : '请输入Topic' },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: group ? 'senderUserId' : 'fromUserId',
|
field: group ? 'senderUserId' : 'fromUserId',
|
||||||
@@ -31,6 +31,33 @@ export function createMessageSchemas(group: boolean) {
|
|||||||
componentProps: { placeholder: '请输入用户ID' },
|
componentProps: { placeholder: '请输入用户ID' },
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
if (group)
|
||||||
|
items.push(
|
||||||
|
{
|
||||||
|
field: 'seqId',
|
||||||
|
component: 'NInputNumber',
|
||||||
|
label: '消息序号',
|
||||||
|
componentProps: { min: 1, showButton: false, placeholder: '请输入消息序号' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'senderUsername',
|
||||||
|
component: 'NInput',
|
||||||
|
label: '发送人用户名',
|
||||||
|
componentProps: { placeholder: '请输入发送人用户名' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'senderNickname',
|
||||||
|
component: 'NInput',
|
||||||
|
label: '发送人昵称',
|
||||||
|
componentProps: { placeholder: '请输入发送人昵称' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'groupName',
|
||||||
|
component: 'NInput',
|
||||||
|
label: '群名称',
|
||||||
|
componentProps: { placeholder: '请输入群名称' },
|
||||||
|
}
|
||||||
|
);
|
||||||
if (!group)
|
if (!group)
|
||||||
items.push({
|
items.push({
|
||||||
field: 'toUserId',
|
field: 'toUserId',
|
||||||
|
|||||||
Reference in New Issue
Block a user