kra/cmd/kra-gen/autocode.example.yaml

122 lines
3.9 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# KRA AutoCode 配置文件示例
# 用于 kra-gen 命令行工具
# 基础信息
package: example # 包名
structName: Article # 结构体名称
tableName: articles # 数据库表名
description: 文章管理 # 功能描述
businessDB: "" # 业务数据库(空表示默认数据库)
abbreviation: article # 缩写(用于路由和变量名)
# 生成选项
options:
# 基础配置
gvaModel: true # 使用 KRA_MODEL包含 ID, CreatedAt, UpdatedAt, DeletedAt
autoMigrate: true # 自动迁移数据库表结构
# 生成范围
generateWeb: true # 生成前端代码
generateServer: true # 生成后端代码
# 高级选项
onlyTemplate: false # 仅生成模板(不注入代码到现有文件)
isAdd: false # 追加模式(不覆盖已有文件)
# 自动注册配置(仅在 onlyTemplate=false 时生效)
autoCreateApiToSql: true # 自动创建 API 记录到 sys_apis 表
autoCreateMenuToSql: true # 自动创建菜单记录到 sys_base_menus 表
autoCreateBtnAuth: true # 自动创建按钮权限
autoCreateResource: false # 自动创建资源标识
# 树形结构配置
isTree: false # 是否为树形结构数据
treeJson: "" # 树形结构展示字段(如: name, title
# 字段配置
fields:
- fieldName: Title # Go 字段名
fieldDesc: 标题 # 字段描述
fieldType: string # Go 类型
fieldJson: title # JSON 字段名
columnName: title # 数据库列名
dataTypeLong: varchar(255) # 数据库类型
form: true # 显示在表单中
table: true # 显示在表格中
desc: true # 显示在详情页
excel: true # 支持导入/导出
require: true # 是否必填
errorText: 请输入标题 # 校验失败提示
clearable: true # 是否可清空
sort: false # 是否支持排序
fieldSearchType: LIKE # 搜索类型: LIKE, EQ, BETWEEN, GT, GTE, LT, LTE, NEQ
fieldSearchHide: false # 是否隐藏搜索条件
fieldIndexType: "" # 索引类型: index, unique
- fieldName: Content
fieldDesc: 内容
fieldType: string
fieldJson: content
columnName: content
dataTypeLong: text
form: true
table: false # 内容字段不在表格中显示
desc: true
excel: false
require: false
clearable: true
- fieldName: Status
fieldDesc: 状态
fieldType: int
fieldJson: status
columnName: status
dataTypeLong: tinyint(1)
form: true
table: true
desc: true
excel: true
require: false
defaultValue: "1" # 默认值
clearable: false
sort: true
fieldSearchType: EQ # 精确匹配
dictType: article_status # 字典类型(用于下拉选择)
- fieldName: AuthorID
fieldDesc: 作者ID
fieldType: uint
fieldJson: authorId
columnName: author_id
dataTypeLong: bigint(20)
form: true
table: true
desc: true
excel: true
require: true
fieldSearchType: EQ
fieldIndexType: index # 普通索引
# 数据源配置示例
dataSource:
dbName: "" # 数据库名(空表示当前数据库)
table: sys_users # 关联表名
label: nick_name # 显示字段
value: id # 值字段
association: 1 # 关联关系: 1=一对一, 2=一对多
hasDeletedAt: true # 关联表是否有软删除
- fieldName: PublishTime
fieldDesc: 发布时间
fieldType: time.Time
fieldJson: publishTime
columnName: publish_time
dataTypeLong: datetime
form: true
table: true
desc: true
excel: true
require: false
clearable: true
sort: true
fieldSearchType: BETWEEN # 时间范围搜索