chore: seed migration objects batch 5
This commit is contained in:
@@ -0,0 +1,141 @@
|
||||
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 ImWorkbenchAppListInp struct {
|
||||
form.PageReq
|
||||
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
||||
Code string `json:"code" dc:"模块编码"`
|
||||
Name string `json:"name" dc:"模块名称"`
|
||||
Enabled *int `json:"enabled" dc:"启用状态"`
|
||||
}
|
||||
|
||||
func (in *ImWorkbenchAppListInp) Filter(ctx context.Context) (err error) {
|
||||
in.Code = strings.TrimSpace(in.Code)
|
||||
in.Name = strings.TrimSpace(in.Name)
|
||||
if in.Enabled != nil && !dict.HasOptionKey(consts.ImWorkbenchAppEnabledOptions, *in.Enabled) {
|
||||
return gerror.New("启用状态不合法")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type ImWorkbenchAppModel struct {
|
||||
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
||||
TenantName string `json:"tenantName" dc:"租户名称"`
|
||||
Id int64 `json:"id" dc:"ID"`
|
||||
Code string `json:"code" dc:"模块编码"`
|
||||
Name string `json:"name" dc:"模块名称"`
|
||||
IconFileId string `json:"iconFileId" dc:"图标文件ID"`
|
||||
Route string `json:"route" dc:"客户端路由"`
|
||||
SortOrder int `json:"sortOrder" dc:"排序"`
|
||||
UnreadKey string `json:"unreadKey" dc:"未读角标Key"`
|
||||
Enabled int `json:"enabled" dc:"启用状态"`
|
||||
Permission string `json:"permission" dc:"权限策略"`
|
||||
CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"`
|
||||
UpdatedAt *gtime.Time `json:"updatedAt" dc:"更新时间"`
|
||||
}
|
||||
|
||||
type ImWorkbenchAppEditInp struct {
|
||||
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
||||
Id int64 `json:"id" dc:"ID"`
|
||||
Code string `json:"code" v:"required#模块编码不能为空" dc:"模块编码"`
|
||||
Name string `json:"name" v:"required#模块名称不能为空" dc:"模块名称"`
|
||||
IconFileId string `json:"iconFileId" dc:"图标文件ID"`
|
||||
Route string `json:"route" v:"required#客户端路由不能为空" dc:"客户端路由"`
|
||||
SortOrder int `json:"sortOrder" dc:"排序"`
|
||||
UnreadKey string `json:"unreadKey" dc:"未读角标Key"`
|
||||
Enabled int `json:"enabled" dc:"启用状态"`
|
||||
Permission string `json:"permission" dc:"权限策略"`
|
||||
}
|
||||
|
||||
func (in *ImWorkbenchAppEditInp) Filter(ctx context.Context) (err error) {
|
||||
in.Code = strings.TrimSpace(in.Code)
|
||||
in.Name = strings.TrimSpace(in.Name)
|
||||
in.IconFileId = strings.TrimSpace(in.IconFileId)
|
||||
in.Route = strings.TrimSpace(in.Route)
|
||||
in.UnreadKey = strings.TrimSpace(in.UnreadKey)
|
||||
in.Permission = strings.TrimSpace(in.Permission)
|
||||
if in.Code == "" {
|
||||
return gerror.New("模块编码不能为空")
|
||||
}
|
||||
if strings.ContainsAny(in.Code, " \t\r\n/") {
|
||||
return gerror.New("模块编码不能包含空格或斜杠")
|
||||
}
|
||||
if len([]rune(in.Code)) > 64 {
|
||||
return gerror.New("模块编码不能超过64个字符")
|
||||
}
|
||||
if in.Name == "" {
|
||||
return gerror.New("模块名称不能为空")
|
||||
}
|
||||
if len([]rune(in.Name)) > 128 {
|
||||
return gerror.New("模块名称不能超过128个字符")
|
||||
}
|
||||
if !dict.HasOptionKey(consts.ImWorkbenchRouteOptions, in.Route) {
|
||||
return gerror.New("客户端路由不在当前IM服务端白名单内")
|
||||
}
|
||||
if !dict.HasOptionKey(consts.ImWorkbenchAppEnabledOptions, in.Enabled) {
|
||||
return gerror.New("启用状态不合法")
|
||||
}
|
||||
if in.Permission == "" {
|
||||
in.Permission = consts.ImWorkbenchPermissionEnabled
|
||||
}
|
||||
if !dict.HasOptionKey(consts.ImWorkbenchPermissionOptions, in.Permission) {
|
||||
return gerror.New("权限策略不合法")
|
||||
}
|
||||
if len([]rune(in.IconFileId)) > 64 {
|
||||
return gerror.New("图标文件ID不能超过64个字符")
|
||||
}
|
||||
if len([]rune(in.UnreadKey)) > 64 {
|
||||
return gerror.New("未读角标Key不能超过64个字符")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type ImWorkbenchAppDeleteInp struct {
|
||||
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
||||
Id int64 `json:"id" dc:"ID"`
|
||||
Code string `json:"code" dc:"模块编码"`
|
||||
}
|
||||
|
||||
func (in *ImWorkbenchAppDeleteInp) Filter(ctx context.Context) (err error) {
|
||||
in.Code = strings.TrimSpace(in.Code)
|
||||
if in.Id <= 0 && in.Code == "" {
|
||||
return gerror.New("请选择要禁用的工作台模块")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type ImWorkbenchAppReorderItem struct {
|
||||
Code string `json:"code" dc:"模块编码"`
|
||||
SortOrder int `json:"sortOrder" dc:"排序"`
|
||||
}
|
||||
|
||||
type ImWorkbenchAppReorderInp struct {
|
||||
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
||||
Items []*ImWorkbenchAppReorderItem `json:"items" dc:"排序列表"`
|
||||
}
|
||||
|
||||
func (in *ImWorkbenchAppReorderInp) Filter(ctx context.Context) (err error) {
|
||||
if len(in.Items) == 0 {
|
||||
return gerror.New("排序列表不能为空")
|
||||
}
|
||||
for _, item := range in.Items {
|
||||
if item == nil {
|
||||
return gerror.New("排序项不能为空")
|
||||
}
|
||||
item.Code = strings.TrimSpace(item.Code)
|
||||
if item.Code == "" {
|
||||
return gerror.New("模块编码不能为空")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user