102 lines
3.4 KiB
Go
102 lines
3.4 KiB
Go
// 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
|
|
}
|