60 lines
2.5 KiB
Go
60 lines
2.5 KiB
Go
package sysin
|
|
|
|
import (
|
|
"context"
|
|
"hotgo/internal/consts"
|
|
"hotgo/internal/library/dict"
|
|
|
|
"github.com/gogf/gf/v2/encoding/gjson"
|
|
"github.com/gogf/gf/v2/errors/gerror"
|
|
"github.com/gogf/gf/v2/os/gtime"
|
|
)
|
|
|
|
type ImMailboxConfigGetInp struct {
|
|
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
|
}
|
|
|
|
func (in *ImMailboxConfigGetInp) Filter(ctx context.Context) (err error) { return }
|
|
|
|
type ImMailboxConfigModel struct {
|
|
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
|
TenantName string `json:"tenantName" dc:"租户名称"`
|
|
Id int64 `json:"id" dc:"ID"`
|
|
Enabled int `json:"enabled" dc:"启用状态"`
|
|
AllowAnonymous int `json:"allowAnonymous" dc:"允许匿名"`
|
|
RequiredFields string `json:"requiredFields" dc:"必填字段JSON"`
|
|
MaxLength int `json:"maxLength" dc:"最大字数"`
|
|
AttachmentPolicy string `json:"attachmentPolicy" dc:"附件策略JSON"`
|
|
NoticeTitle string `json:"noticeTitle" dc:"告知标题"`
|
|
NoticeContent string `json:"noticeContent" dc:"告知内容"`
|
|
NoticeUpdatedAt *gtime.Time `json:"noticeUpdatedAt" dc:"告知更新时间"`
|
|
UpdatedAt *gtime.Time `json:"updatedAt" dc:"更新时间"`
|
|
}
|
|
|
|
type ImMailboxConfigUpdateInp struct {
|
|
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
|
Enabled int `json:"enabled" dc:"启用状态"`
|
|
AllowAnonymous int `json:"allowAnonymous" dc:"允许匿名"`
|
|
RequiredFields *gjson.Json `json:"requiredFields" dc:"必填字段JSON"`
|
|
MaxLength int `json:"maxLength" dc:"最大字数"`
|
|
AttachmentPolicy *gjson.Json `json:"attachmentPolicy" dc:"附件策略JSON"`
|
|
NoticeTitle string `json:"noticeTitle" v:"required#告知标题不能为空" dc:"告知标题"`
|
|
NoticeContent string `json:"noticeContent" v:"required#告知内容不能为空" dc:"告知内容"`
|
|
}
|
|
|
|
func (in *ImMailboxConfigUpdateInp) Filter(ctx context.Context) (err error) {
|
|
if !dict.HasOptionKey(consts.ImFilePolicySwitchOptions, in.Enabled) {
|
|
return gerror.New("启用状态不合法")
|
|
}
|
|
if !dict.HasOptionKey(consts.ImFilePolicySwitchOptions, in.AllowAnonymous) {
|
|
return gerror.New("匿名开关不合法")
|
|
}
|
|
if in.MaxLength <= 0 {
|
|
return gerror.New("最大字数必须大于0")
|
|
}
|
|
if len([]rune(in.NoticeTitle)) > 128 {
|
|
return gerror.New("告知标题不能超过128个字符")
|
|
}
|
|
return nil
|
|
}
|