mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-11-12 04:03:44 +08:00
修复树表上级关系绑定验证,优化CURD代码生成
This commit is contained in:
@@ -3,12 +3,15 @@
|
||||
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
//
|
||||
package sysin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/model/entity"
|
||||
"hotgo/internal/model/input/form"
|
||||
"hotgo/utility/validate"
|
||||
)
|
||||
|
||||
// CronGroupMaxSortInp 最大排序
|
||||
@@ -24,8 +27,44 @@ type CronGroupMaxSortModel struct {
|
||||
type CronGroupEditInp struct {
|
||||
entity.SysCronGroup
|
||||
}
|
||||
|
||||
func (in *CronGroupEditInp) Filter(ctx context.Context) (err error) {
|
||||
if in.Name == "" {
|
||||
err = gerror.New("名称不能为空")
|
||||
return
|
||||
}
|
||||
|
||||
if in.Id > 0 && in.Id == in.Pid {
|
||||
err = gerror.New("上级分组不能是自己")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
type CronGroupEditModel struct{}
|
||||
|
||||
// CronGroupUpdateFields 修改数据字段过滤
|
||||
type CronGroupUpdateFields struct {
|
||||
Id int64 `json:"id" description:"任务分组ID"`
|
||||
Pid int64 `json:"pid" description:"父类字典类型ID"`
|
||||
Name string `json:"name" description:"字典类型名称"`
|
||||
Type string `json:"type" description:"字典类型"`
|
||||
Sort int `json:"sort" description:"排序"`
|
||||
Remark string `json:"remark" description:"备注"`
|
||||
Status int `json:"status" description:"字典类型状态"`
|
||||
}
|
||||
|
||||
// CronGroupInsertFields 新增数据字段过滤
|
||||
type CronGroupInsertFields struct {
|
||||
Pid int64 `json:"pid" description:"父类任务分组ID"`
|
||||
Name string `json:"name" description:"分组名称"`
|
||||
IsDefault int `json:"isDefault" description:"是否默认"`
|
||||
Sort int `json:"sort" description:"排序"`
|
||||
Remark string `json:"remark" description:"备注"`
|
||||
Status int `json:"status" description:"分组状态"`
|
||||
}
|
||||
|
||||
// CronGroupDeleteInp 删除字典类型
|
||||
type CronGroupDeleteInp struct {
|
||||
Id interface{}
|
||||
@@ -57,6 +96,26 @@ type CronGroupListModel struct {
|
||||
type CronGroupStatusInp struct {
|
||||
entity.SysCronGroup
|
||||
}
|
||||
|
||||
func (in *CronGroupStatusInp) Filter(ctx context.Context) (err error) {
|
||||
if in.Id <= 0 {
|
||||
err = gerror.New("ID不能为空")
|
||||
return
|
||||
}
|
||||
|
||||
if in.Status <= 0 {
|
||||
err = gerror.New("状态不能为空")
|
||||
return
|
||||
}
|
||||
|
||||
if !validate.InSliceInt(consts.StatusSlice, in.Status) {
|
||||
err = gerror.New("状态不正确")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
type CronGroupStatusModel struct{}
|
||||
|
||||
// CronGroupSelectInp 选项
|
||||
|
||||
Reference in New Issue
Block a user