
* fix(style): 修复 border 额外的 reset 导致 tailwind border 属性生效异常的问题 * feat: 添加错误预览组件并优化请求错误处理逻辑 * optimize: select and update necessary fields in `ChangePassword` method - Simplify `ChangePassword` method signature by removing unnecessary return type. - Use `Select()` to fetch only the necessary fields (`id` and `password`) from the database. - Replace `Save()` with `Update()` for more efficient password update operation. Note: use `Save(&user)` to update the whole user record, which will cover other unchanged fields as well, causing data inconsistency when data race conditions. * feat(menu): 版本更新为2.8.4,给菜单增加按钮和参数的预制打包 * feat(menu): 恢复空白的配置文件 * Remove unused `SideMode` field from `ChangeUserInfo` struct Remove unused and deprecated `SideMode` field from user request model. * feat(automation): 增加可以自动生成CURD和续写方法的MCP * fix(mcp): 确保始终返回目录结构信息 * fix(mcp): 当不需要创建模块时提前返回目录结构信息 * feat(automation): 增加可以自动生成CURD和续写方法的MCP * feat(mcp): 添加GAG工具用户确认流程和自动字典创建功能 实现三步工作流程:分析、确认、执行 新增自动字典创建功能,当字段使用字典类型时自动检查并创建字典 添加用户确认机制,确保创建操作前获得用户明确确认 * feat(version): 新增版本管理功能,支持创建、导入、导出和下载版本数据 新增版本管理模块,包含以下功能: 1. 版本数据的增删改查 2. 版本创建功能,可选择关联菜单和API 3. 版本导入导出功能 4. 版本JSON数据下载 5. 相关前端页面和接口实现 * refactor(version): 简化版本管理删除逻辑并移除无用字段 移除版本管理中的状态、创建者、更新者和删除者字段 简化删除和批量删除方法的实现,去除事务和用户ID参数 更新自动生成配置的默认值说明 * feat(版本管理): 新增版本管理功能模块 * fix(menu): 修复递归创建菜单时关联数据未正确处理的问题 * feat(mcp): 添加预设计模块扫描功能以支持代码自动生成 在自动化模块分析器中添加对预设计模块的扫描功能,包括: - 新增PredesignedModuleInfo结构体存储模块信息 - 实现scanPredesignedModules方法扫描plugin和model目录 - 在分析响应中添加predesignedModules字段 - 更新帮助文档说明预设计模块的使用方式 这些修改使系统能够识别并利用现有的预设计模块,提高代码生成效率并减少重复工作。 * feat(mcp): 新增API、菜单和字典生成工具并优化自动生成模块 * docs(mcp): 更新菜单和API创建工具的描述信息 * feat(mcp): 添加字典查询工具用于AI生成逻辑时了解可用字典选项 * feat: 在创建菜单/API/模块结果中添加权限分配提醒 为菜单创建、API创建和模块创建的结果消息添加权限分配提醒,帮助用户了解后续需要进行的权限配置步骤 * refactor(mcp): 统一使用WithBoolean替换WithBool并优化错误处理 * docs(mcp): 更新API创建工具的说明和错误处理日志 * feat(mcp): 添加插件意图检测功能并增强验证逻辑 --------- Co-authored-by: Azir <2075125282@qq.com> Co-authored-by: Feng.YJ <jxfengyijie@gmail.com> Co-authored-by: piexlMax(奇淼 <qimiaojiangjizhao@gmail.com>
10 KiB
10 KiB
ExecutionPlan 结构体格式说明
概述
ExecutionPlan 是用于自动化模块创建的执行计划结构体,包含了创建包和模块所需的所有信息。
完整结构体定义
type ExecutionPlan struct {
PackageName string `json:"packageName"` // 包名,如:"user", "order", "product"
ModuleName string `json:"moduleName"` // 模块名,通常与结构体名相同
PackageType string `json:"packageType"` // "plugin" 或 "package"
NeedCreatedPackage bool `json:"needCreatedPackage"` // 是否需要创建包
NeedCreatedModules bool `json:"needCreatedModules"` // 是否需要创建模块
PackageInfo *request.SysAutoCodePackageCreate `json:"packageInfo,omitempty"` // 包信息(当NeedCreatedPackage=true时必需)
ModulesInfo *request.AutoCode `json:"modulesInfo,omitempty"` // 模块信息(当NeedCreatedModules=true时必需)
Paths map[string]string `json:"paths,omitempty"` // 路径信息
}
子结构体详细说明
1. SysAutoCodePackageCreate 结构体
type SysAutoCodePackageCreate struct {
Desc string `json:"desc"` // 描述,如:"用户管理模块"
Label string `json:"label"` // 展示名,如:"用户管理"
Template string `json:"template"` // 模板类型:"plugin" 或 "package"
PackageName string `json:"packageName"` // 包名,如:"user"
Module string `json:"-"` // 模块名(自动填充,无需设置)
}
2. AutoCode 结构体(核心字段)
type AutoCode struct {
Package string `json:"package"` // 包名
TableName string `json:"tableName"` // 数据库表名
BusinessDB string `json:"businessDB"` // 业务数据库名
StructName string `json:"structName"` // 结构体名称
PackageName string `json:"packageName"` // 文件名称
Description string `json:"description"` // 结构体中文名称
Abbreviation string `json:"abbreviation"` // 结构体简称
HumpPackageName string `json:"humpPackageName"` // 驼峰命名的包名
GvaModel bool `json:"gvaModel"` // 是否使用GVA默认Model
AutoMigrate bool `json:"autoMigrate"` // 是否自动迁移表结构
AutoCreateResource bool `json:"autoCreateResource"` // 是否自动创建资源标识
AutoCreateApiToSql bool `json:"autoCreateApiToSql"` // 是否自动创建API
AutoCreateMenuToSql bool `json:"autoCreateMenuToSql"` // 是否自动创建菜单
AutoCreateBtnAuth bool `json:"autoCreateBtnAuth"` // 是否自动创建按钮权限
OnlyTemplate bool `json:"onlyTemplate"` // 是否只生成模板
IsTree bool `json:"isTree"` // 是否树形结构
TreeJson string `json:"treeJson"` // 树形结构JSON字段
IsAdd bool `json:"isAdd"` // 是否新增
Fields []*AutoCodeField `json:"fields"` // 字段列表
GenerateWeb bool `json:"generateWeb"` // 是否生成前端代码
GenerateServer bool `json:"generateServer"` // 是否生成后端代码
Module string `json:"-"` // 模块(自动填充)
DictTypes []string `json:"-"` // 字典类型(自动填充)
}
3. AutoCodeField 结构体(字段定义)
type AutoCodeField struct {
FieldName string `json:"fieldName"` // 字段名
FieldDesc string `json:"fieldDesc"` // 字段中文描述
FieldType string `json:"fieldType"` // 字段类型:string, int, bool, time.Time等
FieldJson string `json:"fieldJson"` // JSON标签名
DataTypeLong string `json:"dataTypeLong"` // 数据库字段长度
Comment string `json:"comment"` // 数据库字段注释
ColumnName string `json:"columnName"` // 数据库列名
FieldSearchType string `json:"fieldSearchType"` // 搜索类型:EQ, LIKE, BETWEEN等
FieldSearchHide bool `json:"fieldSearchHide"` // 是否隐藏查询条件
DictType string `json:"dictType"` // 字典类型
Form bool `json:"form"` // 是否在表单中显示
Table bool `json:"table"` // 是否在表格中显示
Desc bool `json:"desc"` // 是否在详情中显示
Excel bool `json:"excel"` // 是否支持导入导出
Require bool `json:"require"` // 是否必填
DefaultValue string `json:"defaultValue"` // 默认值
ErrorText string `json:"errorText"` // 校验失败提示
Clearable bool `json:"clearable"` // 是否可清空
Sort bool `json:"sort"` // 是否支持排序
PrimaryKey bool `json:"primaryKey"` // 是否主键
DataSource *DataSource `json:"dataSource"` // 数据源
CheckDataSource bool `json:"checkDataSource"` // 是否检查数据源
FieldIndexType string `json:"fieldIndexType"` // 索引类型
}
使用示例
示例1:创建新包和模块
{
"packageName": "user",
"moduleName": "User",
"packageType": "package",
"needCreatedPackage": true,
"needCreatedModules": true,
"packageInfo": {
"desc": "用户管理模块",
"label": "用户管理",
"template": "package",
"packageName": "user"
},
"modulesInfo": {
"package": "user",
"tableName": "sys_users",
"businessDB": "",
"structName": "User",
"packageName": "user",
"description": "用户",
"abbreviation": "user",
"humpPackageName": "user",
"gvaModel": true,
"autoMigrate": true,
"autoCreateResource": true,
"autoCreateApiToSql": true,
"autoCreateMenuToSql": true,
"autoCreateBtnAuth": true,
"onlyTemplate": false,
"isTree": false,
"treeJson": "",
"isAdd": true,
"generateWeb": true,
"generateServer": true,
"fields": [
{
"fieldName": "Username",
"fieldDesc": "用户名",
"fieldType": "string",
"fieldJson": "username",
"dataTypeLong": "50",
"comment": "用户名",
"columnName": "username",
"fieldSearchType": "LIKE",
"fieldSearchHide": false,
"dictType": "",
"form": true,
"table": true,
"desc": true,
"excel": true,
"require": true,
"defaultValue": "",
"errorText": "请输入用户名",
"clearable": true,
"sort": false,
"primaryKey": false,
"dataSource": null,
"checkDataSource": false,
"fieldIndexType": ""
},
{
"fieldName": "Email",
"fieldDesc": "邮箱",
"fieldType": "string",
"fieldJson": "email",
"dataTypeLong": "100",
"comment": "邮箱地址",
"columnName": "email",
"fieldSearchType": "EQ",
"fieldSearchHide": false,
"dictType": "",
"form": true,
"table": true,
"desc": true,
"excel": true,
"require": true,
"defaultValue": "",
"errorText": "请输入邮箱",
"clearable": true,
"sort": false,
"primaryKey": false,
"dataSource": null,
"checkDataSource": false,
"fieldIndexType": "index"
}
]
}
}
示例2:仅在现有包中创建模块
{
"packageName": "system",
"moduleName": "Role",
"packageType": "package",
"needCreatedPackage": false,
"needCreatedModules": true,
"packageInfo": null,
"modulesInfo": {
"package": "system",
"tableName": "sys_roles",
"businessDB": "",
"structName": "Role",
"packageName": "system",
"description": "角色",
"abbreviation": "role",
"humpPackageName": "system",
"gvaModel": true,
"autoMigrate": true,
"autoCreateResource": true,
"autoCreateApiToSql": true,
"autoCreateMenuToSql": true,
"autoCreateBtnAuth": true,
"onlyTemplate": false,
"isTree": false,
"generateWeb": true,
"generateServer": true,
"fields": [
{
"fieldName": "RoleName",
"fieldDesc": "角色名称",
"fieldType": "string",
"fieldJson": "roleName",
"dataTypeLong": "50",
"comment": "角色名称",
"columnName": "role_name",
"fieldSearchType": "LIKE",
"form": true,
"table": true,
"desc": true,
"require": true
}
]
}
}
重要注意事项
- PackageType: 只能是 "plugin" 或 "package"
- NeedCreatedPackage: 当为true时,PackageInfo必须提供
- NeedCreatedModules: 当为true时,ModulesInfo必须提供
- 字段类型: FieldType支持的类型包括:string, int, int64, float64, bool, time.Time, enum, picture, video, file, pictures, array, richtext, json等
- 搜索类型: FieldSearchType支持:EQ, NE, GT, GE, LT, LE, LIKE, BETWEEN等
- 索引类型: FieldIndexType支持:index, unique等
- GvaModel: 设置为true时会自动包含ID、CreatedAt、UpdatedAt、DeletedAt字段
常见错误避免
- 确保PackageName和ModuleName符合Go语言命名规范
- 字段名使用大写开头的驼峰命名
- JSON标签使用小写开头的驼峰命名
- 数据库列名使用下划线分隔的小写命名
- 必填字段不要遗漏
- 字段类型要与实际需求匹配