mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-11-11 03:33:53 +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 选项
|
||||
|
||||
@@ -3,24 +3,82 @@
|
||||
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
// @AutoGenerate Version 2.5.3
|
||||
// @AutoGenerate Date 2023-04-28 15:28:40
|
||||
// @AutoGenerate Version 2.7.3
|
||||
package sysin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/model/entity"
|
||||
"hotgo/internal/model/input/form"
|
||||
"hotgo/utility/validate"
|
||||
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
// CurdDemoUpdateFields 修改生成演示字段过滤
|
||||
type CurdDemoUpdateFields struct {
|
||||
CategoryId int64 `json:"categoryId" dc:"分类ID"`
|
||||
Title string `json:"title" dc:"标题"`
|
||||
Description string `json:"description" dc:"描述"`
|
||||
Content string `json:"content" dc:"内容"`
|
||||
Image string `json:"image" dc:"单图"`
|
||||
Attachfile string `json:"attachfile" dc:"附件"`
|
||||
CityId int64 `json:"cityId" dc:"所在城市"`
|
||||
Switch int `json:"switch" dc:"显示开关"`
|
||||
Sort int `json:"sort" dc:"排序"`
|
||||
Status int `json:"status" dc:"状态"`
|
||||
UpdatedBy int64 `json:"updatedBy" dc:"更新者"`
|
||||
}
|
||||
|
||||
// CurdDemoInsertFields 新增生成演示字段过滤
|
||||
type CurdDemoInsertFields struct {
|
||||
CategoryId int64 `json:"categoryId" dc:"分类ID"`
|
||||
Title string `json:"title" dc:"标题"`
|
||||
Description string `json:"description" dc:"描述"`
|
||||
Content string `json:"content" dc:"内容"`
|
||||
Image string `json:"image" dc:"单图"`
|
||||
Attachfile string `json:"attachfile" dc:"附件"`
|
||||
CityId int64 `json:"cityId" dc:"所在城市"`
|
||||
Switch int `json:"switch" dc:"显示开关"`
|
||||
Sort int `json:"sort" dc:"排序"`
|
||||
Status int `json:"status" dc:"状态"`
|
||||
CreatedBy int64 `json:"createdBy" dc:"创建者"`
|
||||
}
|
||||
|
||||
// CurdDemoEditInp 修改/新增生成演示
|
||||
type CurdDemoEditInp struct {
|
||||
entity.SysGenCurdDemo
|
||||
}
|
||||
|
||||
func (in *CurdDemoEditInp) Filter(ctx context.Context) (err error) {
|
||||
// 验证分类ID
|
||||
if err := g.Validator().Rules("required").Data(in.CategoryId).Messages("分类ID不能为空").Run(ctx); err != nil {
|
||||
return err.Current()
|
||||
}
|
||||
|
||||
// 验证标题
|
||||
if err := g.Validator().Rules("required").Data(in.Title).Messages("标题不能为空").Run(ctx); err != nil {
|
||||
return err.Current()
|
||||
}
|
||||
|
||||
// 验证描述
|
||||
if err := g.Validator().Rules("required").Data(in.Description).Messages("描述不能为空").Run(ctx); err != nil {
|
||||
return err.Current()
|
||||
}
|
||||
|
||||
// 验证内容
|
||||
if err := g.Validator().Rules("required").Data(in.Content).Messages("内容不能为空").Run(ctx); err != nil {
|
||||
return err.Current()
|
||||
}
|
||||
|
||||
// 验证排序
|
||||
if err := g.Validator().Rules("required").Data(in.Sort).Messages("排序不能为空").Run(ctx); err != nil {
|
||||
return err.Current()
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -70,9 +128,12 @@ type CurdDemoListModel struct {
|
||||
Description string `json:"description" dc:"描述"`
|
||||
Image string `json:"image" dc:"单图"`
|
||||
Attachfile string `json:"attachfile" dc:"附件"`
|
||||
CityId int64 `json:"cityId" dc:"所在城市"`
|
||||
Switch int `json:"switch" dc:"显示开关"`
|
||||
Sort int `json:"sort" dc:"排序"`
|
||||
Status int `json:"status" dc:"状态"`
|
||||
CreatedBy int64 `json:"createdBy" dc:"创建者"`
|
||||
UpdatedBy int64 `json:"updatedBy" dc:"更新者"`
|
||||
CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"`
|
||||
UpdatedAt *gtime.Time `json:"updatedAt" dc:"修改时间"`
|
||||
TestCategoryName string `json:"testCategoryName" dc:"分类名称"`
|
||||
@@ -86,6 +147,7 @@ type CurdDemoExportModel struct {
|
||||
Description string `json:"description" dc:"描述"`
|
||||
Image string `json:"image" dc:"单图"`
|
||||
Attachfile string `json:"attachfile" dc:"附件"`
|
||||
CityId int64 `json:"cityId" dc:"所在城市"`
|
||||
Switch int `json:"switch" dc:"显示开关"`
|
||||
Sort int `json:"sort" dc:"排序"`
|
||||
Status int `json:"status" dc:"状态"`
|
||||
@@ -114,6 +176,20 @@ type CurdDemoStatusInp struct {
|
||||
}
|
||||
|
||||
func (in *CurdDemoStatusInp) 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
|
||||
}
|
||||
|
||||
|
||||
@@ -3,10 +3,11 @@
|
||||
// @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/model/entity"
|
||||
"hotgo/internal/model/input/form"
|
||||
)
|
||||
@@ -16,8 +17,50 @@ type DictDataEditInp struct {
|
||||
entity.SysDictData
|
||||
TypeID int64
|
||||
}
|
||||
|
||||
func (in *DictDataEditInp) Filter(ctx context.Context) (err error) {
|
||||
if in.Label == "" {
|
||||
err = gerror.New("字典标签不能为空")
|
||||
return
|
||||
}
|
||||
|
||||
if in.Id > 0 && in.TypeID <= 0 {
|
||||
err = gerror.New("字典类型不能为空")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
type DictDataEditModel struct{}
|
||||
|
||||
// DictDataUpdateFields 修改数据字段过滤
|
||||
type DictDataUpdateFields struct {
|
||||
Id int64 `json:"id" description:"字典数据ID"`
|
||||
Label string `json:"label" description:"字典标签"`
|
||||
Value string `json:"value" description:"字典键值"`
|
||||
ValueType string `json:"valueType" description:"键值数据类型:string,int,uint,bool,datetime,date"`
|
||||
Type string `json:"type" description:"字典类型"`
|
||||
ListClass string `json:"listClass" description:"表格回显样式"`
|
||||
IsDefault int `json:"isDefault" description:"是否为系统默认"`
|
||||
Sort int `json:"sort" description:"字典排序"`
|
||||
Remark string `json:"remark" description:"备注"`
|
||||
Status int `json:"status" description:"状态"`
|
||||
}
|
||||
|
||||
// DictDataInsertFields 新增数据字段过滤
|
||||
type DictDataInsertFields struct {
|
||||
Label string `json:"label" description:"字典标签"`
|
||||
Value string `json:"value" description:"字典键值"`
|
||||
ValueType string `json:"valueType" description:"键值数据类型:string,int,uint,bool,datetime,date"`
|
||||
Type string `json:"type" description:"字典类型"`
|
||||
ListClass string `json:"listClass" description:"表格回显样式"`
|
||||
IsDefault int `json:"isDefault" description:"是否为系统默认"`
|
||||
Sort int `json:"sort" description:"字典排序"`
|
||||
Remark string `json:"remark" description:"备注"`
|
||||
Status int `json:"status" description:"状态"`
|
||||
}
|
||||
|
||||
// DictDataDeleteInp 删除字典数据
|
||||
type DictDataDeleteInp struct {
|
||||
Id interface{}
|
||||
|
||||
@@ -3,10 +3,11 @@
|
||||
// @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"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"hotgo/internal/model/entity"
|
||||
)
|
||||
@@ -15,8 +16,44 @@ import (
|
||||
type DictTypeEditInp struct {
|
||||
entity.SysDictType
|
||||
}
|
||||
|
||||
func (in *DictTypeEditInp) 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 DictTypeEditModel struct{}
|
||||
|
||||
// DictTypeUpdateFields 修改数据字段过滤
|
||||
type DictTypeUpdateFields 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:"字典类型状态"`
|
||||
}
|
||||
|
||||
// DictTypeInsertFields 新增数据字段过滤
|
||||
type DictTypeInsertFields struct {
|
||||
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:"字典类型状态"`
|
||||
}
|
||||
|
||||
// DictTypeDeleteInp 删除字典类型
|
||||
type DictTypeDeleteInp struct {
|
||||
Id interface{}
|
||||
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
// ProvincesMaxSortInp 最大排序
|
||||
@@ -23,8 +26,50 @@ type ProvincesMaxSortModel struct {
|
||||
type ProvincesEditInp struct {
|
||||
entity.SysProvinces
|
||||
}
|
||||
|
||||
func (in *ProvincesEditInp) Filter(ctx context.Context) (err error) {
|
||||
if in.Title == "" {
|
||||
err = gerror.New("标题不能为空")
|
||||
return
|
||||
}
|
||||
|
||||
if in.Id <= 0 {
|
||||
err = gerror.New("地区Id必须大于0")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
type ProvincesEditModel struct{}
|
||||
|
||||
// ProvincesUpdateFields 修改数据字段过滤
|
||||
type ProvincesUpdateFields struct {
|
||||
Id int64 `json:"id" description:"省市区ID"`
|
||||
Title string `json:"title" description:"栏目名称"`
|
||||
Pinyin string `json:"pinyin" description:"拼音"`
|
||||
Lng string `json:"lng" description:"经度"`
|
||||
Lat string `json:"lat" description:"纬度"`
|
||||
Pid int64 `json:"pid" description:"父栏目"`
|
||||
Level int `json:"level" description:"关系树等级"`
|
||||
Tree string `json:"tree" description:"关系"`
|
||||
Sort int `json:"sort" description:"排序"`
|
||||
Status int `json:"status" description:"状态"`
|
||||
}
|
||||
|
||||
// ProvincesInsertFields 新增数据字段过滤
|
||||
type ProvincesInsertFields struct {
|
||||
Title string `json:"title" description:"栏目名称"`
|
||||
Pinyin string `json:"pinyin" description:"拼音"`
|
||||
Lng string `json:"lng" description:"经度"`
|
||||
Lat string `json:"lat" description:"纬度"`
|
||||
Pid int64 `json:"pid" description:"父栏目"`
|
||||
Level int `json:"level" description:"关系树等级"`
|
||||
Tree string `json:"tree" description:"关系"`
|
||||
Sort int `json:"sort" description:"排序"`
|
||||
Status int `json:"status" description:"状态"`
|
||||
}
|
||||
|
||||
// ProvincesDeleteInp 删除字典类型
|
||||
type ProvincesDeleteInp struct {
|
||||
Id interface{} `json:"id" v:"required#省市区ID不能为空" dc:"省市区ID"`
|
||||
@@ -57,6 +102,25 @@ type ProvincesListModel struct {
|
||||
type ProvincesStatusInp struct {
|
||||
entity.SysProvinces
|
||||
}
|
||||
|
||||
func (in *ProvincesStatusInp) 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 ProvincesStatusModel struct{}
|
||||
|
||||
// ProvincesChildrenListInp 获取省市区下级列表
|
||||
|
||||
Reference in New Issue
Block a user