chore: 并入 iotlcm-app 历史到 app/(原提交 f40bda9)

This commit is contained in:
MiFaZhan
2026-11-02 13:28:00 +08:00
1107 changed files with 147143 additions and 0 deletions
@@ -0,0 +1,146 @@
// package genmodel
// @Link https://github.com/xiujiecn/xiu-admin
// @Copyright Copyright (c) 2025 LiXiujie
// @Author Lxj <li@example.com>
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
package genmodel
import "github.com/gogf/gf/v2/encoding/gjson"
type SelectItemModel struct {
Value interface{} `json:"value"` // 选择项值
Label string `json:"label"` // 选择项标签
Name string `json:"name"` // 选择项名称
Disabled bool `json:"disabled"` // 是否禁用
}
// 生成类型选择项
type SelectGenTypeModel struct {
SelectItemModel
Templates []*SelectGenTemplateModel `json:"templates"` // 选择项模板
}
// 生成模板选择项
type SelectGenTemplateModel struct {
SelectItemModel
IsAddon bool `json:"isAddon"` // 是否为插件
}
type SelectsModel struct {
GenType []*SelectGenTypeModel `json:"genType"` // 生成类型 0:增删改查列表 1:关系树列表
Db []*SelectItemModel `json:"db"` // 数据库选择项
Status []*SelectItemModel `json:"status"` // 状态选择项 0:生成成功 1:未生产 2:生成失败
LinkMode []*SelectItemModel `json:"linkMode"` // 链接模式选择项 1左关联 2右关联 3内关联
BuildMethod []*SelectItemModel `json:"buildMethod"` // 构建标志选择项 1:创建文件 2强制覆盖 3已存在跳过 4不生成
FormMode []*SelectItemModel `json:"formMode"` // 表单项类型选择项
FormRole []*SelectItemModel `json:"formRole"` // 表单项校验规则选择项
DictMode []*SelectItemModel `json:"dictMode"` // 字典模式选择项
WhereMode []*SelectItemModel `json:"whereMode"` // 查询条件选择项
Addons []*SelectItemModel `json:"addons"` // 插件选择项
TableAlign []*SelectItemModel `json:"tableAlign"` // 表格对齐方式选择项
TreeStyleType []*SelectItemModel `json:"treeStyleType"` // 树形结构选择项
}
// GenCodesColumn 生成表字段属性
type GenCodesColumn struct {
// 表属性
Id int64 `json:"id" dc:"序号"`
Name string `json:"name" dc:"字段列名"`
Dc string `json:"dc" dc:"字段描述"`
DataType string `json:"dataType" dc:"字段类型"`
SqlType string `json:"sqlType" dc:"物理类型"`
Length int64 `json:"length" dc:"字段长度"`
IsAllowNull string `json:"isAllowNull" dc:"是否允许为空"`
DefaultValue interface{} `json:"defaultValue" dc:"默认值"`
Index string `json:"index" dc:"索引"`
Extra string `json:"extra" dc:"额外选项"`
// 自定义生成属性
// Alias string `json:"alias" dc:"字段别名"`
GoName string `json:"goName" dc:"Go属性"`
GoType string `json:"goType" dc:"Go类型"`
TsName string `json:"tsName" dc:"Ts属性"`
TsType string `json:"tsType" dc:"Ts类型"`
IsList bool `json:"isList" dc:"列表"`
IsExport bool `json:"isExport" dc:"导出"`
IsSort bool `json:"isSort" dc:"排序"`
IsQuery bool `json:"isQuery" dc:"查询"`
QueryWhere string `json:"queryWhere" dc:"查询条件"`
IsEdit bool `json:"isEdit" dc:"编辑"`
Required bool `json:"required" dc:"必填"`
Unique bool `json:"unique" dc:"唯一性"`
FormMode string `json:"formMode" dc:"表单组件"`
FormRole string `json:"formRole" dc:"表单验证"`
FormGridSpan int `json:"formGridSpan" dc:"栅格占位数量"`
DictType string `json:"dictType" dc:"字典类型ID"`
Align string `json:"align" dc:"排列方式"`
Width int64 `json:"width" dc:"列宽"`
}
type GenCodesTableSelectParam struct {
DbGroup string `json:"dbGroup"`
}
type GenCodesTableSelectModel struct {
Value string `json:"value"`
Label string `json:"label"`
Name string `json:"name"`
DaoName string `json:"daoName" dc:"orm模型名称"`
DefVarName string `json:"defVarName" dc:"默认实体名称"`
DefAlias string `json:"defAlias" dc:"默认关联表别名"`
DefTableComment string `json:"defTableComment" dc:"默认菜单名称"`
}
type GenCodesColumnSelectParam struct {
DbGroup string `json:"dbGroup"`
TableName string `json:"tableName"`
}
type GenCodesColumnSelectModel struct {
Value string `json:"value"`
Label string `json:"label"`
Name string `json:"name"`
}
type GenCodesColumnListParam struct {
DbGroup string `json:"dbGroup" dc:"数据库配置名称"`
TableName string `json:"tableName" dc:"表名称"`
IsLink int64 `json:"isLink" dc:"是否是关联表"`
Alias string `json:"alias" dc:"关联表别名"`
}
type GenCodesColumnListModel struct {
GenCodesColumn
}
type GenCodesPreviewParam struct {
TableId int64 `json:"tableId" orm:"table_id" description:"生成ID"`
GenType uint `json:"genType" orm:"gen_type" description:"生成类型"`
GenTemplate int `json:"genTemplate" orm:"gen_template" description:"生成模板"`
VarName string `json:"varName" orm:"var_name" description:"实体命名"`
Options *gjson.Json `json:"options" orm:"options" description:"配置选项"`
DbName string `json:"dbName" orm:"db_name" description:"数据库名称"`
TableName string `json:"tableName" orm:"table_name" description:"主表名称"`
TableComment string `json:"tableComment" orm:"table_comment" description:"主表注释"`
DaoName string `json:"daoName" orm:"dao_name" description:"主表dao模型"`
MasterColumns *gjson.Json `json:"masterColumns" orm:"master_columns" description:"主表字段"`
AddonName string `json:"addonName" orm:"addon_name" description:"插件名称"`
Status int `json:"status" orm:"status" description:"生成状态"`
}
// GenFile 生成文件配置
type GenFile struct {
Content string `json:"content" dc:"页面内容"`
Path string `json:"path" dc:"生成路径"`
Meth int `json:"meth" dc:"生成方式"`
Required bool `json:"required" dc:"是否是必要构建文件"`
}
type GenCodesPreviewModel struct {
Config *GenCodesConfig `json:"config"`
Views map[string]*GenFile `json:"views" dc:"页面"`
}
type GenCodesBuildParam = GenCodesPreviewParam
type GenCodesBuildModel struct {
}
@@ -0,0 +1,126 @@
// package genmodel
// @Link https://github.com/xiujiecn/xiu-admin
// @Copyright Copyright (c) 2025 LiXiujie
// @Author Lxj <li@example.com>
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
package genmodel
import (
genconsts "git.5iot.com/iotlcm-public/iotlcm-app/internal/library/xgen/gen_consts"
"github.com/gogf/gf/v2/util/gconv"
)
// 模板配置 config/config.yaml xgen.application.crud.templates
type GenCodesConfigCrudTemplate struct {
Group string `name:"group" json:"group"`
IsAddon bool `name:"isAddon" json:"isAddon"`
MasterPackage string `name:"masterPackage" json:"masterPackage"`
TemplatePath string `name:"templatePath" json:"templatePath"`
ApiPath string `name:"apiPath" json:"apiPath"`
InputPath string `name:"inputPath" json:"inputPath"`
ControllerPath string `name:"controllerPath" json:"controllerPath"`
LogicPath string `name:"logicPath" json:"logicPath"`
RouterPath string `name:"routerPath" json:"routerPath"`
SqlPath string `name:"sqlPath" json:"sqlPath"`
WebApiPath string `name:"webApiPath" json:"webApiPath"`
WebViewsPath string `name:"webViewsPath" json:"webViewsPath"`
}
type GenCodesConfigTreeTemplate struct {
Group string `json:"group"`
TemplatePath string `json:"templatePath"`
}
type GenCodesConfigBuildAddon struct {
SrcPath string `json:"srcPath"`
WebApiPath string `json:"webApiPath"`
WebViewsPath string `json:"webViewsPath"`
}
// 工具生成配置 hack/config.yaml gfcli.gen.dao
type GenDaoConfig struct {
Group string `name:"group" json:"group"`
Link string `name:"link" json:"link"`
DbName string `name:"dbName" json:"dbName"`
TableName string `name:"tableName" json:"tableName"`
JsonCase string `name:"jsonCase" json:"jsonCase"`
StdTime bool `name:"stdTime" json:"stdTime"`
GJsonSupport bool `name:"gJsonSupport" json:"gJsonSupport"`
}
// 工具生成配置 hack/config.yaml gfcli.gen.service
type GenServiceConfig struct {
SrcFolder string `name:"srcFolder"`
DstFolder string `name:"dstFolder"`
DstFileNameCase string `name:"dstFileNameCase"`
WatchFile string `name:"watchFile" `
StPattern string `name:"stPattern" `
Packages []string `name:"packages" `
ImportPrefix string `name:"importPrefix" `
Clear bool `name:"clear" `
}
// 模板配置 config/config.yaml xgen
type GenCodesConfig struct {
AllowedIPs []string `json:"allowedIPs"`
Application struct {
Crud struct {
Templates []*GenCodesConfigCrudTemplate `json:"templates"`
} `json:"crud"`
Tree struct {
Templates []*GenCodesConfigTreeTemplate `json:"templates"`
} `json:"tree"`
} `json:"application"`
Delimiters []string `json:"delimiters"`
DevPath string `json:"devPath"`
DisableTables []string `json:"disableTables"`
SelectDbs []string `json:"selectDbs"`
Addon *GenCodesConfigBuildAddon `json:"addon"`
}
// ConvType 类型转换
func ConvType(val interface{}, t string) interface{} {
switch t {
case genconsts.ConfigTypeString:
val = gconv.String(val)
case genconsts.ConfigTypeInt:
val = gconv.Int(val)
case genconsts.ConfigTypeInt8:
val = gconv.Int8(val)
case genconsts.ConfigTypeInt16:
val = gconv.Int16(val)
case genconsts.ConfigTypeInt32:
val = gconv.Int32(val)
case genconsts.ConfigTypeInt64:
val = gconv.Int64(val)
case genconsts.ConfigTypeUint:
val = gconv.Uint(val)
case genconsts.ConfigTypeUint8:
val = gconv.Uint8(val)
case genconsts.ConfigTypeUint16:
val = gconv.Uint16(val)
case genconsts.ConfigTypeUint32:
val = gconv.Uint32(val)
case genconsts.ConfigTypeUint64:
val = gconv.Uint64(val)
case genconsts.ConfigTypeFloat32:
val = gconv.Float32(val)
case genconsts.ConfigTypeFloat64:
val = gconv.Float64(val)
case genconsts.ConfigTypeBool:
val = gconv.Bool(val)
case genconsts.ConfigTypeDate:
val = gconv.Time(val, "Y-m-d")
case genconsts.ConfigTypeDateTime:
val = gconv.Time(val, "Y-m-d H:i:s")
case genconsts.ConfigTypeSliceInt:
val = gconv.SliceInt(val)
case genconsts.ConfigTypeSliceInt64:
val = gconv.SliceInt64(val)
case genconsts.ConfigTypeSliceString:
val = gconv.SliceStr(val)
default:
val = gconv.String(val)
}
return val
}
@@ -0,0 +1,145 @@
// package genmodel
// @Link https://github.com/xiujiecn/xiu-admin
// @Copyright Copyright (c) 2025 LiXiujie
// @Author Lxj <li@example.com>
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
package genmodel
import (
"context"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gview"
)
// ImportModel 导包 - model.ts
type ImportModel struct {
NaiveUI []string
UtilsIs []string
UtilsUrl []string
UtilsDate []string
UtilsValidate []string
UtilsIndex []string
}
// CurdStep 生成选项
type CurdStep struct {
HasMaxSort bool // 最大排序
HasAdd bool // 表单添加
HasBatchDel bool // 批量删除
HasExport bool // 表格导出
HasNotFilterAuth bool // 不过滤认证权限
HasEdit bool // 表单编辑
HasDel bool // 删除
HasView bool // 查看详情
HasStatus bool // 修改状态
HasSwitch bool // 数值开关
HasCheck bool // 勾选列
HasMenu bool // 菜单权限
IsTreeTable bool // 树型列表
IsOptionTreeTable bool // 选项式树型列表
HasRules bool // 表单验证规则
HasRulesValidator bool // 表单验证器
HasSearchForm bool // 列表搜索
HasDict bool // 字典
HasFuncDict bool // 注册方法字典
HasQueryMemberSummary bool // 查询用户摘要
HasHookMemberSummary bool // hook用户摘要
ImportModel ImportModel // 公用导包 - model.ts
ActionColumnWidth int64 // 列表操作栏宽度
IsAddon bool // 是否是插件
IsEditModal bool // 新增修改模态框模式
}
type FuncDict struct {
ValueColumn string // 选项值
LabelColumn string // 选项名称
Value *GenCodesColumnListModel
Label *GenCodesColumnListModel
}
// PresetStep 预设生成流程参数
type PresetStep struct {
FormGridCols int `json:"formGridCols" dc:"表单显示的栅格数量"`
}
// OptionsTree 树形结构选项
type OptionsTree struct {
TitleColumn string `json:"titleColumn"`
PidColumn string `json:"pidColumn"`
LevelColumn string `json:"levelColumn"`
TreeColumn string `json:"treeColumn"`
StyleType int `json:"styleType"`
TitleField *GenCodesColumnListModel
PidField *GenCodesColumnListModel
LevelField *GenCodesColumnListModel
TreeField *GenCodesColumnListModel
HasTreePath bool
}
// CurdOptionsMenu 菜单选项
type CurdOptionsMenu struct {
Icon string `json:"icon"`
Pid int `json:"pid"`
Sort int `json:"sort"`
}
// CurdOptionsJoin 关联表选项
type CurdOptionsJoin struct {
Uuid string `json:"uuid"`
LinkTable string `json:"linkTable"`
Alias string `json:"alias"`
LinkMode int `json:"linkMode"`
Field string `json:"field"`
MasterField string `json:"masterField"`
DaoName string `json:"daoName"`
Columns []*GenCodesColumnListModel `json:"columns"`
}
type OptionsSchemasField struct {
Field string
Type string
}
type CurdOptionsDict struct {
Has bool
Types []string
Schemas []*OptionsSchemasField
}
// CurdOptions 生成选项
type CurdOptions struct {
AutoOps []string `json:"autoOps"`
ColumnOps []string `json:"columnOps"`
HeadOps []string `json:"headOps"`
Join []*CurdOptionsJoin `json:"join"`
Menu *CurdOptionsMenu `json:"menu"`
Tree *OptionsTree `json:"tree"`
TemplateGroup string `json:"templateGroup"`
ApiPrefix string `json:"apiPrefix"`
ImportWebApi string `json:"importWebApi"`
FuncDict *FuncDict `json:"funcDict"`
PresetStep *PresetStep `json:"presetStep"`
Step *CurdStep // 转换后的流程控制条件
DictOps CurdOptionsDict // 字典选项
DictMap g.Map // 字典选项 -> 字段映射关系
}
type CurdPreviewParam struct {
In *GenCodesPreviewParam // 提交参数
DaoConfig *GenDaoConfig // 生成dao配置
Config *GenCodesConfig // 生成配置
View *gview.View // 视图模板
Content *GenCodesPreviewModel // 页面代码
MasterFields []*GenCodesColumnListModel // 主表字段属性
Pk *GenCodesColumnListModel // 主键属性
Options *CurdOptions // 生成选项
}
type CurdBuildEvent map[string]func(ctx context.Context) (err error)
type CurdBuildParam struct {
PreviewIn *CurdPreviewParam // 预览参数
BeforeEvent CurdBuildEvent // 前置事件
AfterEvent CurdBuildEvent // 后置事件
}