模块化上传驱动,使用泛型优化工具库降低冗余

This commit is contained in:
孟帅
2023-06-02 20:29:08 +08:00
parent fdc48b9335
commit 62ecbb7f26
96 changed files with 1276 additions and 1483 deletions

View File

@@ -189,7 +189,7 @@ func (s *sSysTable) Status(ctx context.Context, in sysin.TableStatusInp) (err er
return
}
if !validate.InSliceInt(consts.StatusSlice, in.Status) {
if !validate.InSlice(consts.StatusSlice, in.Status) {
err = gerror.New("状态不正确")
return
}
@@ -209,7 +209,7 @@ func (s *sSysTable) Switch(ctx context.Context, in sysin.TableSwitchInp) (err er
// ...
}
if !validate.InSliceString(fields, in.Key) {
if !validate.InSlice(fields, in.Key) {
err = gerror.New("开关键名不在白名单")
return
}

View File

@@ -3,7 +3,6 @@
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
//
package sysin
import (
@@ -53,7 +52,6 @@ func (in *TableEditInp) Filter(ctx context.Context) (err error) {
if err := g.Validator().Rules("float|between:0,5").Messages("请输入一个浮点数|推荐星只能是0~5星").Data(in.Star).Run(ctx); err != nil {
return err.Current()
}
return
}

View File

@@ -15,7 +15,7 @@ import (
)
var (
NoLogin []interface{} // 无需登录
NoLoginRouter []interface{} // 无需登录
LoginRequiredRouter []interface{} // 需要登录
)
@@ -23,8 +23,8 @@ var (
func Register(ctx context.Context, group *ghttp.RouterGroup) {
prefix := addons.RouterPrefix(ctx, consts.AppAdmin, global.GetSkeleton().Name)
group.Group(prefix, func(group *ghttp.RouterGroup) {
if len(NoLogin) > 0 {
group.Bind(NoLogin...)
if len(NoLoginRouter) > 0 {
group.Bind(NoLoginRouter...)
}
group.Middleware(service.Middleware().AdminAuth)
if len(LoginRequiredRouter) > 0 {