feat: add IM admin P2 configuration modules
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
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 ImAbuseReasonListInp struct {
|
||||
form.PageReq
|
||||
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
||||
TargetType string `json:"targetType" dc:"对象类型"`
|
||||
ReasonCode string `json:"reasonCode" dc:"原因编码"`
|
||||
Enabled *int `json:"enabled" dc:"启用状态"`
|
||||
}
|
||||
|
||||
func (in *ImAbuseReasonListInp) Filter(ctx context.Context) (err error) {
|
||||
in.TargetType = strings.TrimSpace(in.TargetType)
|
||||
in.ReasonCode = strings.TrimSpace(in.ReasonCode)
|
||||
if in.TargetType != "" && !dict.HasOptionKey(consts.ImAbuseTargetTypeOptions, in.TargetType) {
|
||||
return gerror.New("举报对象类型不合法")
|
||||
}
|
||||
if in.Enabled != nil && !dict.HasOptionKey(consts.ImAbuseReasonEnabledOptions, *in.Enabled) {
|
||||
return gerror.New("启用状态不合法")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type ImAbuseReasonModel struct {
|
||||
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
||||
TenantName string `json:"tenantName" dc:"租户名称"`
|
||||
Id int64 `json:"id" dc:"ID"`
|
||||
TargetType string `json:"targetType" dc:"对象类型"`
|
||||
ReasonCode string `json:"reasonCode" dc:"原因编码"`
|
||||
Label string `json:"label" dc:"展示文案"`
|
||||
RequiresDescription int `json:"requiresDescription" dc:"要求描述"`
|
||||
AllowsEvidence int `json:"allowsEvidence" dc:"允许证据"`
|
||||
SortOrder int `json:"sortOrder" dc:"排序"`
|
||||
Enabled int `json:"enabled" dc:"启用状态"`
|
||||
CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"`
|
||||
UpdatedAt *gtime.Time `json:"updatedAt" dc:"更新时间"`
|
||||
}
|
||||
|
||||
type ImAbuseReasonEditInp struct {
|
||||
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
||||
Id int64 `json:"id" dc:"ID"`
|
||||
TargetType string `json:"targetType" v:"required#对象类型不能为空" dc:"对象类型"`
|
||||
ReasonCode string `json:"reasonCode" v:"required#原因编码不能为空" dc:"原因编码"`
|
||||
Label string `json:"label" v:"required#展示文案不能为空" dc:"展示文案"`
|
||||
RequiresDescription int `json:"requiresDescription" dc:"要求描述"`
|
||||
AllowsEvidence int `json:"allowsEvidence" dc:"允许证据"`
|
||||
SortOrder int `json:"sortOrder" dc:"排序"`
|
||||
Enabled int `json:"enabled" dc:"启用状态"`
|
||||
}
|
||||
|
||||
func (in *ImAbuseReasonEditInp) Filter(ctx context.Context) (err error) {
|
||||
in.TargetType = strings.TrimSpace(in.TargetType)
|
||||
in.ReasonCode = strings.TrimSpace(in.ReasonCode)
|
||||
in.Label = strings.TrimSpace(in.Label)
|
||||
if !dict.HasOptionKey(consts.ImAbuseTargetTypeOptions, in.TargetType) {
|
||||
return gerror.New("举报对象类型不合法")
|
||||
}
|
||||
if in.ReasonCode == "" || strings.ContainsAny(in.ReasonCode, " \t\r\n/") || len([]rune(in.ReasonCode)) > 64 {
|
||||
return gerror.New("原因编码不能为空,且不能包含空格或斜杠")
|
||||
}
|
||||
if in.Label == "" || len([]rune(in.Label)) > 128 {
|
||||
return gerror.New("展示文案不能为空且不能超过128个字符")
|
||||
}
|
||||
if !dict.HasOptionKey(consts.ImAbuseReasonEnabledOptions, in.RequiresDescription) {
|
||||
return gerror.New("要求描述开关不合法")
|
||||
}
|
||||
if !dict.HasOptionKey(consts.ImAbuseReasonEnabledOptions, in.AllowsEvidence) {
|
||||
return gerror.New("允许证据开关不合法")
|
||||
}
|
||||
if !dict.HasOptionKey(consts.ImAbuseReasonEnabledOptions, in.Enabled) {
|
||||
return gerror.New("启用状态不合法")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type ImAbuseReasonDeleteInp struct {
|
||||
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
||||
Id int64 `json:"id" v:"required|min:1#请选择要禁用的举报原因|请选择要禁用的举报原因" dc:"ID"`
|
||||
}
|
||||
|
||||
func (in *ImAbuseReasonDeleteInp) Filter(ctx context.Context) (err error) {
|
||||
if in.Id <= 0 {
|
||||
return gerror.New("请选择要禁用的举报原因")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
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 ImAppReleaseListInp struct {
|
||||
form.PageReq
|
||||
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
||||
Platform string `json:"platform" dc:"平台"`
|
||||
Channel string `json:"channel" dc:"渠道"`
|
||||
}
|
||||
|
||||
func (in *ImAppReleaseListInp) Filter(ctx context.Context) (err error) {
|
||||
in.Platform = strings.TrimSpace(in.Platform)
|
||||
in.Channel = strings.TrimSpace(in.Channel)
|
||||
if in.Platform != "" && !dict.HasOptionKey(consts.ImAppPlatformOptions, in.Platform) {
|
||||
return gerror.New("客户端平台不合法")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type ImAppReleaseModel struct {
|
||||
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
||||
TenantName string `json:"tenantName" dc:"租户名称"`
|
||||
Id int64 `json:"id" dc:"ID"`
|
||||
Platform string `json:"platform" dc:"平台"`
|
||||
Channel string `json:"channel" dc:"渠道"`
|
||||
LatestVersion string `json:"latestVersion" dc:"最新版本"`
|
||||
MinSupportedVersion string `json:"minSupportedVersion" dc:"最低支持版本"`
|
||||
UpdateType string `json:"updateType" dc:"更新类型"`
|
||||
ReleaseNotes string `json:"releaseNotes" dc:"更新说明"`
|
||||
StoreUrl string `json:"storeUrl" dc:"商店地址"`
|
||||
PackageUrl string `json:"packageUrl" dc:"安装包地址"`
|
||||
Checksum string `json:"checksum" dc:"校验值"`
|
||||
RemindAfterSeconds int `json:"remindAfterSeconds" dc:"再次提醒秒数"`
|
||||
PublishedAt *gtime.Time `json:"publishedAt" dc:"发布时间"`
|
||||
CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"`
|
||||
UpdatedAt *gtime.Time `json:"updatedAt" dc:"更新时间"`
|
||||
}
|
||||
|
||||
type ImAppReleaseEditInp struct {
|
||||
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
||||
Id int64 `json:"id" dc:"ID"`
|
||||
Platform string `json:"platform" v:"required#平台不能为空" dc:"平台"`
|
||||
Channel string `json:"channel" v:"required#渠道不能为空" dc:"渠道"`
|
||||
LatestVersion string `json:"latestVersion" v:"required#最新版本不能为空" dc:"最新版本"`
|
||||
MinSupportedVersion string `json:"minSupportedVersion" v:"required#最低支持版本不能为空" dc:"最低支持版本"`
|
||||
UpdateType string `json:"updateType" v:"required#更新类型不能为空" dc:"更新类型"`
|
||||
ReleaseNotes string `json:"releaseNotes" dc:"更新说明"`
|
||||
StoreUrl string `json:"storeUrl" dc:"商店地址"`
|
||||
PackageUrl string `json:"packageUrl" dc:"安装包地址"`
|
||||
Checksum string `json:"checksum" dc:"校验值"`
|
||||
RemindAfterSeconds int `json:"remindAfterSeconds" dc:"再次提醒秒数"`
|
||||
}
|
||||
|
||||
func (in *ImAppReleaseEditInp) Filter(ctx context.Context) (err error) {
|
||||
in.Platform = strings.TrimSpace(in.Platform)
|
||||
in.Channel = strings.TrimSpace(in.Channel)
|
||||
in.LatestVersion = strings.TrimSpace(in.LatestVersion)
|
||||
in.MinSupportedVersion = strings.TrimSpace(in.MinSupportedVersion)
|
||||
in.UpdateType = strings.TrimSpace(in.UpdateType)
|
||||
in.StoreUrl = strings.TrimSpace(in.StoreUrl)
|
||||
in.PackageUrl = strings.TrimSpace(in.PackageUrl)
|
||||
in.Checksum = strings.TrimSpace(in.Checksum)
|
||||
if !dict.HasOptionKey(consts.ImAppPlatformOptions, in.Platform) {
|
||||
return gerror.New("客户端平台不合法")
|
||||
}
|
||||
if in.Channel == "" || strings.ContainsAny(in.Channel, " \t\r\n/") || len([]rune(in.Channel)) > 32 {
|
||||
return gerror.New("渠道不能为空,且不能包含空格或斜杠")
|
||||
}
|
||||
if in.LatestVersion == "" || len([]rune(in.LatestVersion)) > 64 {
|
||||
return gerror.New("最新版本不能为空且不能超过64个字符")
|
||||
}
|
||||
if in.MinSupportedVersion == "" || len([]rune(in.MinSupportedVersion)) > 64 {
|
||||
return gerror.New("最低支持版本不能为空且不能超过64个字符")
|
||||
}
|
||||
if !dict.HasOptionKey(consts.ImAppUpdateTypeOptions, in.UpdateType) {
|
||||
return gerror.New("更新类型不合法")
|
||||
}
|
||||
if in.RemindAfterSeconds < 0 {
|
||||
return gerror.New("再次提醒时间不能小于0")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
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 ImFeedbackConfigGetInp struct {
|
||||
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
||||
}
|
||||
|
||||
func (in *ImFeedbackConfigGetInp) Filter(ctx context.Context) (err error) { return }
|
||||
|
||||
type ImFeedbackConfigModel struct {
|
||||
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
||||
TenantName string `json:"tenantName" dc:"租户名称"`
|
||||
Id int64 `json:"id" dc:"ID"`
|
||||
Categories string `json:"categories" dc:"分类JSON"`
|
||||
MaxLength int `json:"maxLength" dc:"最大字数"`
|
||||
AttachmentPolicy string `json:"attachmentPolicy" dc:"附件策略JSON"`
|
||||
AllowContact int `json:"allowContact" dc:"允许联系方式"`
|
||||
DiagnosticsNotice string `json:"diagnosticsNotice" dc:"诊断信息提示"`
|
||||
UpdatedAt *gtime.Time `json:"updatedAt" dc:"更新时间"`
|
||||
}
|
||||
|
||||
type ImFeedbackConfigUpdateInp struct {
|
||||
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
||||
Categories *gjson.Json `json:"categories" dc:"分类JSON"`
|
||||
MaxLength int `json:"maxLength" dc:"最大字数"`
|
||||
AttachmentPolicy *gjson.Json `json:"attachmentPolicy" dc:"附件策略JSON"`
|
||||
AllowContact int `json:"allowContact" dc:"允许联系方式"`
|
||||
DiagnosticsNotice string `json:"diagnosticsNotice" v:"required#诊断提示不能为空" dc:"诊断信息提示"`
|
||||
}
|
||||
|
||||
func (in *ImFeedbackConfigUpdateInp) Filter(ctx context.Context) (err error) {
|
||||
if in.MaxLength <= 0 {
|
||||
return gerror.New("最大字数必须大于0")
|
||||
}
|
||||
if !dict.HasOptionKey(consts.ImFilePolicySwitchOptions, in.AllowContact) {
|
||||
return gerror.New("联系方式开关不合法")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
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
|
||||
}
|
||||
@@ -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