feat: 完成鸽达达后台安全与审计改造
This commit is contained in:
@@ -0,0 +1,147 @@
|
||||
package sysin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/library/dict"
|
||||
"hotgo/internal/model/input/form"
|
||||
"strings"
|
||||
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
type ImPrivateMessageListInp struct {
|
||||
form.PageReq
|
||||
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
||||
Topic string `json:"topic" dc:"会话Topic"`
|
||||
FromUserId string `json:"fromUserId" dc:"发送用户ID"`
|
||||
ToUserId string `json:"toUserId" dc:"接收用户ID"`
|
||||
ContentType string `json:"contentType" dc:"内容类型"`
|
||||
Status string `json:"status" dc:"状态"`
|
||||
Keyword string `json:"keyword" dc:"内容关键词"`
|
||||
CreatedAt []*gtime.Time `json:"createdAt" dc:"发送时间"`
|
||||
}
|
||||
|
||||
func (in *ImPrivateMessageListInp) Filter(ctx context.Context) error {
|
||||
return filterImMessageList(&in.PageReq, &in.Topic, &in.Keyword, in.ContentType, in.Status)
|
||||
}
|
||||
|
||||
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:"发送时间"`
|
||||
}
|
||||
|
||||
func (in *ImGroupMessageListInp) Filter(ctx context.Context) error {
|
||||
return filterImMessageList(&in.PageReq, &in.Topic, &in.Keyword, in.ContentType, in.Status)
|
||||
}
|
||||
|
||||
func filterImMessageList(page *form.PageReq, topic *string, keyword *string, contentType string, status string) error {
|
||||
*topic = strings.TrimSpace(*topic)
|
||||
*keyword = strings.TrimSpace(*keyword)
|
||||
if page.Page <= 0 {
|
||||
page.Page = 1
|
||||
}
|
||||
if page.PerPage <= 0 {
|
||||
page.PerPage = 20
|
||||
}
|
||||
if page.PerPage > 200 {
|
||||
return gerror.New("每页数量不能超过200")
|
||||
}
|
||||
if contentType != "" && !dict.HasOptionKey(consts.ImMessageContentTypeOptions, contentType) {
|
||||
return gerror.New("消息类型不合法")
|
||||
}
|
||||
if status != "" && !dict.HasOptionKey(consts.ImMessageStatusOptions, status) {
|
||||
return gerror.New("消息状态不合法")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type ImMessageListModel struct {
|
||||
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
||||
TenantName string `json:"tenantName" dc:"租户名称"`
|
||||
Topic string `json:"topic" dc:"会话Topic"`
|
||||
SeqId int64 `json:"seqId" dc:"消息序号"`
|
||||
FromUserId string `json:"fromUserId" dc:"发送用户ID"`
|
||||
SenderUsername string `json:"senderUsername" dc:"发送人用户名"`
|
||||
SenderNickname string `json:"senderNickname" dc:"发送人昵称"`
|
||||
ToUserId string `json:"toUserId" dc:"接收用户ID"`
|
||||
ReceiverUsername string `json:"receiverUsername" dc:"接收人用户名"`
|
||||
ReceiverNickname string `json:"receiverNickname" dc:"接收人昵称"`
|
||||
GroupName string `json:"groupName" dc:"群名称"`
|
||||
GroupNo string `json:"groupNo" dc:"群号"`
|
||||
ContentType string `json:"contentType" dc:"消息类型"`
|
||||
ContentExcerpt string `json:"contentExcerpt" dc:"内容摘要"`
|
||||
Status string `json:"status" dc:"状态"`
|
||||
ReplyToSeq int64 `json:"replyToSeq" dc:"回复消息序号"`
|
||||
AtUsers string `json:"atUsers" dc:"@用户"`
|
||||
CreatedAt *gtime.Time `json:"createdAt" dc:"发送时间"`
|
||||
UpdatedAt *gtime.Time `json:"updatedAt" dc:"更新时间"`
|
||||
}
|
||||
|
||||
type ImMessageViewInp struct {
|
||||
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
||||
Topic string `json:"topic" dc:"会话Topic"`
|
||||
SeqId int64 `json:"seqId" dc:"消息序号"`
|
||||
}
|
||||
|
||||
func (in *ImMessageViewInp) Filter(ctx context.Context) error {
|
||||
in.Topic = strings.TrimSpace(in.Topic)
|
||||
if in.Topic == "" || in.SeqId <= 0 {
|
||||
return gerror.New("消息Topic和序号不能为空")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type ImMessageViewModel struct {
|
||||
ImMessageListModel
|
||||
Head string `json:"head" dc:"消息头"`
|
||||
Content string `json:"content" dc:"完整消息内容"`
|
||||
Metadata string `json:"metadata" dc:"扩展数据"`
|
||||
}
|
||||
|
||||
type ImMessageActionInp struct {
|
||||
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
||||
Topic string `json:"topic" dc:"会话Topic"`
|
||||
SeqId int64 `json:"seqId" dc:"消息序号"`
|
||||
Reason string `json:"reason" dc:"处置原因"`
|
||||
}
|
||||
|
||||
func (in *ImMessageActionInp) Filter(ctx context.Context) error {
|
||||
in.Topic = strings.TrimSpace(in.Topic)
|
||||
in.Reason = strings.TrimSpace(in.Reason)
|
||||
if in.Topic == "" || in.SeqId <= 0 {
|
||||
return gerror.New("消息Topic和序号不能为空")
|
||||
}
|
||||
if in.Reason == "" {
|
||||
return gerror.New("处置原因不能为空")
|
||||
}
|
||||
if len([]rune(in.Reason)) > 500 {
|
||||
return gerror.New("处置原因不能超过500个字符")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type ImMessageCommandModel struct {
|
||||
CommandId string `json:"commandId" dc:"命令ID"`
|
||||
EventId string `json:"eventId" dc:"事件ID"`
|
||||
Status string `json:"status" dc:"命令状态"`
|
||||
}
|
||||
|
||||
type ImMessageExportModel struct {
|
||||
Topic string `json:"topic" dc:"Topic"`
|
||||
SeqId int64 `json:"seqId" dc:"消息序号"`
|
||||
FromUserId string `json:"fromUserId" dc:"发送用户ID"`
|
||||
ToUserId string `json:"toUserId" dc:"接收用户ID"`
|
||||
GroupName string `json:"groupName" dc:"群名称"`
|
||||
ContentType string `json:"contentType" dc:"消息类型"`
|
||||
ContentExcerpt string `json:"contentExcerpt" dc:"内容摘要"`
|
||||
Status string `json:"status" dc:"状态"`
|
||||
CreatedAt *gtime.Time `json:"createdAt" dc:"发送时间"`
|
||||
}
|
||||
Reference in New Issue
Block a user