feat: add IM governance admin enhancements

This commit is contained in:
richjohnrambo
2026-08-21 16:06:29 +08:00
parent 543c7b624e
commit 21a5b97ac8
34 changed files with 2621 additions and 135 deletions
+86 -12
View File
@@ -26,9 +26,6 @@ type ImGroupListInp struct {
}
func (in *ImGroupListInp) Filter(ctx context.Context) (err error) {
if in.TenantId <= 0 {
return gerror.New("请选择租户")
}
return
}
@@ -72,9 +69,6 @@ type ImGroupViewInp struct {
}
func (in *ImGroupViewInp) Filter(ctx context.Context) (err error) {
if in.TenantId <= 0 {
return gerror.New("请选择租户")
}
if in.Topic == "" {
return gerror.New("Topic不能为空")
}
@@ -98,9 +92,6 @@ type ImGroupMemberListInp struct {
}
func (in *ImGroupMemberListInp) Filter(ctx context.Context) (err error) {
if in.TenantId <= 0 {
return gerror.New("请选择租户")
}
if in.Topic == "" {
return gerror.New("Topic不能为空")
}
@@ -140,9 +131,6 @@ type ImGroupTopicInp struct {
}
func (in *ImGroupTopicInp) Filter(ctx context.Context) (err error) {
if in.TenantId <= 0 {
return gerror.New("请选择租户")
}
if in.Topic == "" {
return gerror.New("Topic不能为空")
}
@@ -174,6 +162,92 @@ type ImGroupGovernanceModel struct {
UpdatedAt *gtime.Time `json:"updatedAt" dc:"修改时间"`
}
type ImGroupGovernanceUpdateInp struct {
ImGroupTopicInp
JoinApproval int `json:"joinApproval" dc:"入群审批"`
MuteAll int `json:"muteAll" dc:"全员禁言"`
MemberUploadFiles int `json:"memberUploadFiles" dc:"成员上传文件"`
MemberPrivateChat int `json:"memberPrivateChat" dc:"成员私聊"`
MemberInvite int `json:"memberInvite" dc:"成员邀请"`
MaxMemberCount int `json:"maxMemberCount" dc:"最大成员数"`
MaxAdminCount int `json:"maxAdminCount" dc:"最大管理员数"`
}
func (in *ImGroupGovernanceUpdateInp) Filter(ctx context.Context) (err error) {
if err = in.ImGroupTopicInp.Filter(ctx); err != nil {
return
}
if in.JoinApproval != 0 && in.JoinApproval != 1 {
return gerror.New("入群审批值不正确")
}
if in.MuteAll != 0 && in.MuteAll != 1 {
return gerror.New("全员禁言值不正确")
}
if in.MemberUploadFiles != 0 && in.MemberUploadFiles != 1 {
return gerror.New("成员上传文件值不正确")
}
if in.MemberPrivateChat != 0 && in.MemberPrivateChat != 1 {
return gerror.New("成员私聊值不正确")
}
if in.MemberInvite != 0 && in.MemberInvite != 1 {
return gerror.New("成员邀请值不正确")
}
if in.MaxMemberCount < 0 || in.MaxAdminCount < 0 {
return gerror.New("人数上限不能小于0")
}
return
}
type ImGroupDissolveInp struct {
ImGroupTopicInp
Reason string `json:"reason" dc:"解散原因"`
}
func (in *ImGroupDissolveInp) Filter(ctx context.Context) (err error) {
if err = in.ImGroupTopicInp.Filter(ctx); err != nil {
return
}
if len([]rune(in.Reason)) > 200 {
return gerror.New("解散原因不能超过200个字符")
}
return
}
type ImGroupMuteInp struct {
ImGroupTopicInp
UserId int64 `json:"userId" v:"required#用户ID不能为空" dc:"用户ID"`
ExpiresAt *gtime.Time `json:"expiresAt" dc:"过期时间"`
Reason string `json:"reason" dc:"禁言原因"`
}
func (in *ImGroupMuteInp) Filter(ctx context.Context) (err error) {
if err = in.ImGroupTopicInp.Filter(ctx); err != nil {
return
}
if in.UserId <= 0 {
return gerror.New("用户ID不能为空")
}
if len([]rune(in.Reason)) > 200 {
return gerror.New("禁言原因不能超过200个字符")
}
return
}
type ImGroupUnmuteInp struct {
ImGroupTopicInp
UserId int64 `json:"userId" v:"required#用户ID不能为空" dc:"用户ID"`
}
func (in *ImGroupUnmuteInp) Filter(ctx context.Context) (err error) {
if err = in.ImGroupTopicInp.Filter(ctx); err != nil {
return
}
if in.UserId <= 0 {
return gerror.New("用户ID不能为空")
}
return
}
type ImGroupJoinRequestListInp struct {
form.PageReq
ImGroupTopicInp
@@ -0,0 +1,101 @@
// Package sysin
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2026 HotGo
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package sysin
import (
"context"
"hotgo/internal/model/input/form"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/os/gtime"
)
const (
ImOutboxSourceBusiness = "business"
ImOutboxSourceGroup = "group"
ImOutboxStatusPending = "pending"
ImOutboxStatusDelivered = "delivered"
ImOutboxStatusFailed = "failed"
ImOutboxStatusDead = "dead"
)
type ImOutboxListInp struct {
form.PageReq
TenantId int64 `json:"tenantId" dc:"租户ID"`
Source string `json:"source" dc:"事件来源"`
EventId string `json:"eventId" dc:"事件ID"`
EventType string `json:"eventType" dc:"事件类型"`
TargetType string `json:"targetType" dc:"目标类型"`
Target string `json:"target" dc:"目标"`
Status string `json:"status" dc:"状态"`
CreatedAt []*gtime.Time `json:"createdAt" dc:"创建时间"`
}
func (in *ImOutboxListInp) Filter(ctx context.Context) (err error) {
if in.Source == "" {
in.Source = ImOutboxSourceBusiness
}
if in.Source != ImOutboxSourceBusiness && in.Source != ImOutboxSourceGroup {
return gerror.New("Outbox来源不正确")
}
return
}
type ImOutboxListModel struct {
TenantId int64 `json:"tenantId" dc:"租户ID"`
TenantName string `json:"tenantName" dc:"租户名称"`
Source string `json:"source" dc:"事件来源"`
Id int64 `json:"id" dc:"ID"`
EventId string `json:"eventId" dc:"事件ID"`
TargetType string `json:"targetType" dc:"目标类型"`
Target string `json:"target" dc:"目标"`
ActorUserId int64 `json:"actorUserId" dc:"操作用户ID"`
EventType string `json:"eventType" dc:"事件类型"`
Payload string `json:"payload" dc:"事件负载"`
Status string `json:"status" dc:"状态"`
Attempts int `json:"attempts" dc:"尝试次数"`
NextRetryAt *gtime.Time `json:"nextRetryAt" dc:"下次重试时间"`
DeliveredAt *gtime.Time `json:"deliveredAt" dc:"投递时间"`
CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"`
UpdatedAt *gtime.Time `json:"updatedAt" dc:"更新时间"`
}
type ImOutboxViewInp struct {
TenantId int64 `json:"tenantId" dc:"租户ID"`
Source string `json:"source" v:"required#事件来源不能为空" dc:"事件来源"`
Id int64 `json:"id" v:"required#ID不能为空" dc:"ID"`
}
func (in *ImOutboxViewInp) Filter(ctx context.Context) (err error) {
if in.Source != ImOutboxSourceBusiness && in.Source != ImOutboxSourceGroup {
return gerror.New("Outbox来源不正确")
}
if in.Id <= 0 {
return gerror.New("ID不能为空")
}
return
}
type ImOutboxViewModel struct {
ImOutboxListModel
}
type ImOutboxActionInp struct {
TenantId int64 `json:"tenantId" dc:"租户ID"`
Source string `json:"source" v:"required#事件来源不能为空" dc:"事件来源"`
Id int64 `json:"id" v:"required#ID不能为空" dc:"ID"`
}
func (in *ImOutboxActionInp) Filter(ctx context.Context) (err error) {
if in.Source != ImOutboxSourceBusiness && in.Source != ImOutboxSourceGroup {
return gerror.New("Outbox来源不正确")
}
if in.Id <= 0 {
return gerror.New("ID不能为空")
}
return
}
@@ -26,9 +26,6 @@ type ImRealnameListInp struct {
}
func (in *ImRealnameListInp) Filter(ctx context.Context) (err error) {
if in.TenantId <= 0 {
return gerror.New("请选择租户")
}
return
}
@@ -55,9 +52,6 @@ type ImRealnameViewInp struct {
}
func (in *ImRealnameViewInp) Filter(ctx context.Context) (err error) {
if in.TenantId <= 0 {
return gerror.New("请选择租户")
}
if in.Id <= 0 {
return gerror.New("ID不能为空")
}
@@ -78,9 +72,6 @@ type ImRealnameReviewInp struct {
}
func (in *ImRealnameReviewInp) Filter(ctx context.Context) (err error) {
if in.TenantId <= 0 {
return gerror.New("请选择租户")
}
if in.Id <= 0 {
return gerror.New("ID不能为空")
}
@@ -32,9 +32,6 @@ type ImWorkOrderListInp struct {
}
func (in *ImWorkOrderListInp) Filter(ctx context.Context) (err error) {
if in.TenantId <= 0 {
return gerror.New("请选择租户")
}
if in.Type == "" {
return gerror.New("请选择工单类型")
}
@@ -68,9 +65,6 @@ type ImWorkOrderViewInp struct {
}
func (in *ImWorkOrderViewInp) Filter(ctx context.Context) (err error) {
if in.TenantId <= 0 {
return gerror.New("请选择租户")
}
if in.Type != ImWorkOrderTypeAbuse && in.Type != ImWorkOrderTypeFeedback {
return gerror.New("工单类型不正确")
}
@@ -100,9 +94,6 @@ type ImWorkOrderStatusInp struct {
}
func (in *ImWorkOrderStatusInp) Filter(ctx context.Context) (err error) {
if in.TenantId <= 0 {
return gerror.New("请选择租户")
}
if in.Type != ImWorkOrderTypeAbuse && in.Type != ImWorkOrderTypeFeedback {
return gerror.New("工单类型不正确")
}