mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-08-26 16:46:14 +08:00
修复树表上级关系绑定验证,优化CURD代码生成
This commit is contained in:
@@ -6,20 +6,14 @@
|
||||
package adminin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/model/entity"
|
||||
"hotgo/internal/model/input/form"
|
||||
"hotgo/utility/validate"
|
||||
)
|
||||
|
||||
// DeptNameUniqueInp 名称是否唯一
|
||||
type DeptNameUniqueInp struct {
|
||||
Name string
|
||||
Id int64
|
||||
}
|
||||
|
||||
type DeptNameUniqueModel struct {
|
||||
IsUnique bool
|
||||
}
|
||||
|
||||
// DeptMaxSortInp 最大排序
|
||||
type DeptMaxSortInp struct {
|
||||
Id int64
|
||||
@@ -29,13 +23,59 @@ type DeptMaxSortModel struct {
|
||||
Sort int
|
||||
}
|
||||
|
||||
// DeptEditInp 修改/新增字典数据
|
||||
// DeptEditInp 修改/新增部门数据
|
||||
type DeptEditInp struct {
|
||||
entity.AdminDept
|
||||
}
|
||||
|
||||
func (in *DeptEditInp) 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 DeptEditModel struct{}
|
||||
|
||||
// DeptDeleteInp 删除字典类型
|
||||
// DeptUpdateFields 修改数据字段过滤
|
||||
type DeptUpdateFields struct {
|
||||
Id int64 `json:"id" description:"部门ID"`
|
||||
Pid int64 `json:"pid" description:"父部门ID"`
|
||||
Name string `json:"name" description:"部门名称"`
|
||||
Code string `json:"code" description:"部门编码"`
|
||||
Type string `json:"type" description:"部门类型"`
|
||||
Leader string `json:"leader" description:"负责人"`
|
||||
Phone string `json:"phone" description:"联系电话"`
|
||||
Email string `json:"email" description:"邮箱"`
|
||||
Level int `json:"level" description:"关系树等级"`
|
||||
Tree string `json:"tree" description:"关系树"`
|
||||
Sort int `json:"sort" description:"排序"`
|
||||
Status int `json:"status" description:"部门状态"`
|
||||
}
|
||||
|
||||
// DeptInsertFields 新增数据字段过滤
|
||||
type DeptInsertFields struct {
|
||||
Pid int64 `json:"pid" description:"父部门ID"`
|
||||
Name string `json:"name" description:"部门名称"`
|
||||
Code string `json:"code" description:"部门编码"`
|
||||
Type string `json:"type" description:"部门类型"`
|
||||
Leader string `json:"leader" description:"负责人"`
|
||||
Phone string `json:"phone" description:"联系电话"`
|
||||
Email string `json:"email" description:"邮箱"`
|
||||
Level int `json:"level" description:"关系树等级"`
|
||||
Tree string `json:"tree" description:"关系树"`
|
||||
Sort int `json:"sort" description:"排序"`
|
||||
Status int `json:"status" description:"部门状态"`
|
||||
}
|
||||
|
||||
// DeptDeleteInp 删除部门类型
|
||||
type DeptDeleteInp struct {
|
||||
Id interface{}
|
||||
}
|
||||
@@ -72,6 +112,26 @@ type DeptListModel struct {
|
||||
type DeptStatusInp struct {
|
||||
entity.AdminDept
|
||||
}
|
||||
|
||||
func (in *DeptStatusInp) 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 DeptStatusModel struct{}
|
||||
|
||||
type DeptOptionInp struct {
|
||||
|
@@ -15,6 +15,7 @@ import (
|
||||
"hotgo/internal/library/contexts"
|
||||
"hotgo/internal/model/entity"
|
||||
"hotgo/internal/model/input/form"
|
||||
"hotgo/utility/validate"
|
||||
)
|
||||
|
||||
// MemberUpdateCashInp 更新会员提现信息
|
||||
@@ -110,11 +111,11 @@ type LoginMemberInfoModel struct {
|
||||
|
||||
// MemberEditInp 修改/新增管理员
|
||||
type MemberEditInp struct {
|
||||
Id int64 `json:"id" dc:""`
|
||||
RoleId int64 `json:"roleId" v:"required#角色不能为空" dc:"角色ID"`
|
||||
PostIds []int64 `json:"postIds" v:"required#岗位不能为空" dc:"岗位ID"`
|
||||
DeptId int64 `json:"deptId" v:"required#部门不能为空" dc:"部门ID"`
|
||||
Username string `json:"username" v:"required#账号不能为空" dc:"帐号"`
|
||||
Id int64 `json:"id" dc:"管理员ID"`
|
||||
RoleId int64 `json:"roleId" v:"required#角色不能为空" dc:"角色ID"`
|
||||
PostIds []int64 `json:"postIds" v:"required#岗位不能为空" dc:"岗位ID"`
|
||||
DeptId int64 `json:"deptId" v:"required#部门不能为空" dc:"部门ID"`
|
||||
Username string `json:"username" v:"required#账号不能为空" dc:"帐号"`
|
||||
PasswordHash string `json:"passwordHash" dc:"密码hash"`
|
||||
Password string `json:"password" dc:"密码"`
|
||||
RealName string `json:"realName" dc:"真实姓名"`
|
||||
@@ -130,8 +131,6 @@ type MemberEditInp struct {
|
||||
Mobile string `json:"mobile" dc:"手机号码"`
|
||||
Remark string `json:"remark" dc:"备注"`
|
||||
Status int `json:"status" dc:"状态"`
|
||||
CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"`
|
||||
UpdatedAt *gtime.Time `json:"updatedAt" dc:"修改时间"`
|
||||
}
|
||||
|
||||
type MemberAddInp struct {
|
||||
@@ -214,6 +213,25 @@ type MemberCash struct {
|
||||
type MemberStatusInp struct {
|
||||
entity.AdminMember
|
||||
}
|
||||
|
||||
func (in *MemberStatusInp) 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 MemberStatusModel struct{}
|
||||
|
||||
// MemberSelectInp 获取可选的后台用户选项
|
||||
|
@@ -3,16 +3,99 @@
|
||||
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
//
|
||||
package adminin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/encoding/gjson"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"hotgo/internal/model"
|
||||
"hotgo/internal/model/entity"
|
||||
"hotgo/internal/model/input/form"
|
||||
"sort"
|
||||
)
|
||||
|
||||
// GetPermissionsInp 获取指定角色的菜单权限
|
||||
type GetPermissionsInp struct {
|
||||
RoleId int64 `json:"id"`
|
||||
}
|
||||
|
||||
type GetPermissionsModel struct {
|
||||
MenuIds []int64 `json:"menuIds"`
|
||||
}
|
||||
|
||||
// UpdatePermissionsInp 更新指定角色的菜单权限
|
||||
type UpdatePermissionsInp struct {
|
||||
RoleId int64 `json:"id"`
|
||||
MenuIds []int64 `json:"menuIds"`
|
||||
}
|
||||
|
||||
// RoleDeleteInp 删除角色
|
||||
type RoleDeleteInp struct {
|
||||
Id int64 `json:"id" v:"required"`
|
||||
}
|
||||
|
||||
func (in *RoleDeleteInp) Filter(ctx context.Context) (err error) {
|
||||
if in.Id <= 0 {
|
||||
err = gerror.New("ID不能为空")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// RoleEditInp 获取列表
|
||||
type RoleEditInp struct {
|
||||
entity.AdminRole
|
||||
}
|
||||
|
||||
func (in *RoleEditInp) Filter(ctx context.Context) (err error) {
|
||||
if in.Name == "" {
|
||||
err = gerror.New("名称不能为空")
|
||||
return
|
||||
}
|
||||
|
||||
if in.Key == "" {
|
||||
err = gerror.New("编码不能为空")
|
||||
return
|
||||
}
|
||||
|
||||
if in.Id > 0 && in.Id == in.Pid {
|
||||
err = gerror.New("上级角色不能是自己")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// RoleUpdateFields 修改数据字段过滤
|
||||
type RoleUpdateFields struct {
|
||||
Id int64 `json:"id" description:"角色ID"`
|
||||
Name string `json:"name" description:"角色名称"`
|
||||
Key string `json:"key" description:"角色权限字符串"`
|
||||
DataScope int `json:"dataScope" description:"数据范围"`
|
||||
CustomDept *gjson.Json `json:"customDept" description:"自定义部门权限"`
|
||||
Pid int64 `json:"pid" description:"上级角色ID"`
|
||||
Level int `json:"level" description:"关系树等级"`
|
||||
Tree string `json:"tree" description:"关系树"`
|
||||
Remark string `json:"remark" description:"备注"`
|
||||
Sort int `json:"sort" description:"排序"`
|
||||
Status int `json:"status" description:"角色状态"`
|
||||
}
|
||||
|
||||
// RoleInsertFields 新增数据字段过滤
|
||||
type RoleInsertFields struct {
|
||||
Name string `json:"name" description:"角色名称"`
|
||||
Key string `json:"key" description:"角色权限字符串"`
|
||||
DataScope int `json:"dataScope" description:"数据范围"`
|
||||
CustomDept *gjson.Json `json:"customDept" description:"自定义部门权限"`
|
||||
Pid int64 `json:"pid" description:"上级角色ID"`
|
||||
Level int `json:"level" description:"关系树等级"`
|
||||
Tree string `json:"tree" description:"关系树"`
|
||||
Remark string `json:"remark" description:"备注"`
|
||||
Sort int `json:"sort" description:"排序"`
|
||||
Status int `json:"status" description:"角色状态"`
|
||||
}
|
||||
|
||||
// RoleListInp 获取列表
|
||||
type RoleListInp struct {
|
||||
form.PageReq
|
||||
@@ -29,18 +112,6 @@ type RoleListModel struct {
|
||||
List []*RoleTree `json:"list"`
|
||||
}
|
||||
|
||||
func Sort(v []*RoleTree) {
|
||||
sort.SliceStable(v, func(i, j int) bool {
|
||||
if v[i].Sort < v[j].Sort {
|
||||
return true
|
||||
}
|
||||
if v[i].Sort > v[j].Sort {
|
||||
return false
|
||||
}
|
||||
return v[i].Id < v[j].Id
|
||||
})
|
||||
}
|
||||
|
||||
// RoleMemberListInp 查询列表
|
||||
type RoleMemberListInp struct {
|
||||
form.PageReq
|
||||
@@ -68,8 +139,16 @@ type MenuRoleListModel struct {
|
||||
CheckedKeys []int64 `json:"checkedKeys" dc:"选择的菜单ID"`
|
||||
}
|
||||
|
||||
// DataScopeEditInp 获取数据权限选项
|
||||
type DataScopeEditInp struct {
|
||||
Id int64 `json:"id" v:"required" dc:"角色ID"`
|
||||
DataScope int `json:"dataScope" v:"required" dc:"数据范围"`
|
||||
CustomDept []int64 `json:"customDept" dc:"自定义部门权限"`
|
||||
}
|
||||
|
||||
func (in *DataScopeEditInp) Filter(ctx context.Context) (err error) {
|
||||
if in.Id <= 0 {
|
||||
return gerror.New("角色ID不正确!")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@@ -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