feat: add IM file policy and org exports
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
package sysin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/library/dict"
|
||||
"hotgo/internal/model/input/form"
|
||||
"strings"
|
||||
|
||||
"github.com/gogf/gf/v2/encoding/gjson"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
type ImFilePolicyListInp struct {
|
||||
form.PageReq
|
||||
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
||||
Purpose string `json:"purpose" dc:"用途"`
|
||||
AutoCleanup *int `json:"autoCleanup" dc:"自动清理"`
|
||||
ScanEnabled *int `json:"scanEnabled" dc:"病毒扫描"`
|
||||
}
|
||||
|
||||
func (in *ImFilePolicyListInp) Filter(ctx context.Context) (err error) { return }
|
||||
|
||||
type ImFilePolicyListModel struct {
|
||||
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
||||
TenantName string `json:"tenantName" dc:"租户名称"`
|
||||
Id int64 `json:"id" dc:"ID"`
|
||||
Purpose string `json:"purpose" dc:"用途"`
|
||||
MaxSize int64 `json:"maxSize" dc:"单文件大小上限"`
|
||||
RetentionDays int `json:"retentionDays" dc:"保留天数"`
|
||||
AllowedMimes string `json:"allowedMimes" dc:"允许MIME JSON"`
|
||||
AutoCleanup int `json:"autoCleanup" dc:"自动清理"`
|
||||
ScanEnabled int `json:"scanEnabled" dc:"病毒扫描"`
|
||||
Remark string `json:"remark" dc:"备注"`
|
||||
UpdatedAt *gtime.Time `json:"updatedAt" dc:"更新时间"`
|
||||
}
|
||||
|
||||
type ImFilePolicyUpdateInp struct {
|
||||
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
||||
Purpose string `json:"purpose" v:"required#用途不能为空" dc:"用途"`
|
||||
MaxSize int64 `json:"maxSize" dc:"单文件大小上限"`
|
||||
RetentionDays int `json:"retentionDays" dc:"保留天数"`
|
||||
AllowedMimes *gjson.Json `json:"allowedMimes" dc:"允许MIME JSON"`
|
||||
AutoCleanup int `json:"autoCleanup" dc:"自动清理"`
|
||||
ScanEnabled int `json:"scanEnabled" dc:"病毒扫描"`
|
||||
Remark string `json:"remark" dc:"备注"`
|
||||
}
|
||||
|
||||
func (in *ImFilePolicyUpdateInp) Filter(ctx context.Context) (err error) {
|
||||
in.Purpose = strings.TrimSpace(in.Purpose)
|
||||
in.Remark = strings.TrimSpace(in.Remark)
|
||||
if !dict.HasOptionKey(consts.ImFilePurposeOptions, in.Purpose) {
|
||||
return gerror.New("文件用途不合法")
|
||||
}
|
||||
if in.Purpose == consts.ImFilePurposeUnknown || in.Purpose == consts.ImFilePurposeOrphan {
|
||||
return gerror.New("该文件用途不允许配置策略")
|
||||
}
|
||||
if in.MaxSize <= 0 {
|
||||
return gerror.New("单文件大小上限必须大于0")
|
||||
}
|
||||
if in.RetentionDays < 0 {
|
||||
return gerror.New("保留天数不能小于0")
|
||||
}
|
||||
if !dict.HasOptionKey(consts.ImFilePolicySwitchOptions, in.AutoCleanup) {
|
||||
return gerror.New("自动清理开关不合法")
|
||||
}
|
||||
if !dict.HasOptionKey(consts.ImFilePolicySwitchOptions, in.ScanEnabled) {
|
||||
return gerror.New("病毒扫描开关不合法")
|
||||
}
|
||||
if len([]rune(in.Remark)) > 200 {
|
||||
return gerror.New("备注不能超过200个字符")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user