diff --git a/install/define/err.go b/install/define/err.go new file mode 100644 index 0000000..7b19785 --- /dev/null +++ b/install/define/err.go @@ -0,0 +1,27 @@ +// Package define ... +// +// Description : define ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 2023-09-17 13:29 +package define + +import "errors" + +var ( + // FieldNameIsEmpty 字段名为空 + FieldNameIsEmpty = errors.New("field name is empty") + // FieldTypeIsEmpty 字段类型为空 + FieldTypeIsEmpty = errors.New("field type is empty") + // IndexNameIsEmpty 索引名为空 + IndexNameIsEmpty = errors.New("index name is empty") + // IndexTypeIsEmpty 索引类型为空 + IndexTypeIsEmpty = errors.New("index type is empty") + // IndexFieldIsEmpty 索引字段为空 + IndexFieldIsEmpty = errors.New("index field is empty") + // TableNameIsEmpty 数据表名称为空 + TableNameIsEmpty = errors.New("table name is empty") + // TableFieldListIsEmpty 表字段列表为空 + TableFieldListIsEmpty = errors.New("table field list is empty") +) diff --git a/install/define/field.go b/install/define/field.go new file mode 100644 index 0000000..ce68546 --- /dev/null +++ b/install/define/field.go @@ -0,0 +1,180 @@ +// Package define ... +// +// Description : define ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 2023-09-17 18:07 +package define + +import "strings" + +// Field 表字段结构 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 11:19 2023/9/17 +type Field struct { + Name string `json:"name"` // 字段名 + Type string `json:"type"` // 字段类型 + Unsigned bool `json:"unsigned"` // 无符号 + NotNull bool `json:"not_null"` // 禁止为空 + DefaultValue *string `json:"default_value"` // 默认值 + PrimaryKey bool `json:"primary_key"` // 是否主键 + IsAutoIncrement bool `json:"is_auto_increment"` // 是否自增 + Comment string `json:"comment"` // 字段注释 + OnUpdate string `json:"on_update"` // 更新时自动更新数据 + isFormat bool `json:"-"` // 是否格式化过 +} + +// Format 格式化 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 15:08 2023/9/17 +func (f *Field) Format() { + if f.isFormat { + return + } + f.isFormat = true + f.Name = strings.TrimSpace(f.Name) + if !strings.HasPrefix(f.Name, "`") { + f.Name = "`" + f.Name + } + if !strings.HasSuffix(f.Name, "`") { + f.Name = f.Name + "`" + } + f.OnUpdate = strings.TrimSpace(f.OnUpdate) + f.Type = strings.ToUpper(strings.TrimSpace(f.Type)) + f.Comment = strings.TrimSpace(f.Comment) +} + +// IsInt 是否是数字类型, 条件 : 类型关键字包含int +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 15:09 2023/9/17 +func (f *Field) IsInt() bool { + f.Format() + return strings.Contains(f.Type, "INT") +} + +// UseAutoIncrement 是否自增 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 15:13 2023/9/17 +func (f *Field) UseAutoIncrement() bool { + return f.IsAutoIncrement && f.IsInt() +} + +// UseDefaultValue 使用默认值, 条件 : 非自增 + 设置了默认值 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 15:15 2023/9/17 +func (f *Field) UseDefaultValue() bool { + return !f.UseAutoIncrement() && !strings.Contains(strings.ToUpper(f.Type), "TEXT") && nil != f.DefaultValue +} + +// UseUnsigned 无符号 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 16:12 2023/9/17 +func (f *Field) UseUnsigned() bool { + return f.Unsigned && f.IsInt() +} + +// Validate 验证 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 16:10 2023/9/17 +func (f *Field) Validate() error { + if len(f.Name) <= 0 { + return FieldNameIsEmpty + } + if len(f.Type) == 0 { + return FieldTypeIsEmpty + } + return nil +} + +// ToString 转字符串 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 16:04 2023/9/17 +func (f *Field) ToString() (string, error) { + f.Format() + if err := f.Validate(); nil != err { + return "", err + } + fieldTpl := MysqlFieldTpl + dataReplaceTable := map[string]string{ + FieldName: f.Name, // 字段名 + FieldType: f.Type, // 字段类型 + FieldUnsigned: "", // 无符号 + FieldNotNull: "", // 不为空 + FieldAutoIncrement: "", // 是否自增 + FieldDefaultValue: "", // 默认值 + FieldOnUpdate: "", // 自动更新 + } + + // 是否有符号, 整数且设置有符号 + if f.UseUnsigned() { + dataReplaceTable[FieldUnsigned] = "UNSIGNED" + } + + // 是否为空 + if f.NotNull { + dataReplaceTable[FieldNotNull] = "NOT NULL" + } + + // 是否自增 + if f.UseAutoIncrement() { + dataReplaceTable[FieldAutoIncrement] = "AUTO_INCREMENT" + } + + // 默认值 + if f.UseDefaultValue() { + defaultVal := *f.DefaultValue + if strings.Contains(defaultVal, "()") { + // 默认值是Mysql函数 + dataReplaceTable[FieldDefaultValue] = "DEFAULT " + defaultVal + } else { + // 默认值是指定的固定值 + if f.IsInt() { + dataReplaceTable[FieldDefaultValue] = "DEFAULT " + defaultVal + } else { + dataReplaceTable[FieldDefaultValue] = "DEFAULT '" + defaultVal + "'" + } + } + } + + if len(f.OnUpdate) > 0 { + dataReplaceTable[FieldOnUpdate] = " ON UPDATE " + f.OnUpdate + } + + // 注释 + f.Comment = strings.TrimSpace(f.Comment) + if len(f.Comment) > 0 { + dataReplaceTable[FieldComment] = "COMMENT '" + f.Comment + "'" + } + + for source, target := range dataReplaceTable { + fieldTpl = strings.ReplaceAll(fieldTpl, source, target) + } + return fieldTpl, nil +} + +// ToStringIgnoreError ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 15:59 2023/9/18 +func (f *Field) ToStringIgnoreError() string { + sql, _ := f.ToString() + return sql +} diff --git a/install/define/index.go b/install/define/index.go new file mode 100644 index 0000000..d35650e --- /dev/null +++ b/install/define/index.go @@ -0,0 +1,107 @@ +// Package define ... +// +// Description : define ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 2023-09-17 18:07 +package define + +import ( + "fmt" + "strings" +) + +// Index 索引数据结构 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 11:39 2023/9/17 +type Index struct { + Type string `json:"type"` // 索引类型 : unique / index / key / primary 等 + Name string `json:"name"` // 索引名称 + FieldList []string `json:"field_list"` // 索引字段列表 + IsFormat bool `json:"-"` // 是否格式化 +} + +// Format 格式化 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 15:35 2023/9/17 +func (i *Index) Format() { + if i.IsFormat { + return + } + i.IsFormat = true + i.Type = strings.ToUpper(strings.TrimSpace(i.Type)) + i.Name = strings.TrimSpace(i.Name) + if !strings.HasPrefix(i.Name, "`") { + i.Name = "`" + i.Name + } + if !strings.HasSuffix(i.Name, "`") { + i.Name = i.Name + "`" + } + for idx := 0; idx < len(i.FieldList); idx++ { + if !strings.HasPrefix(i.FieldList[idx], "`") { + i.FieldList[idx] = "`" + i.FieldList[idx] + } + if !strings.HasSuffix(i.FieldList[idx], "`") { + i.FieldList[idx] = i.FieldList[idx] + "`" + } + } +} + +// Validate 验证数据 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 16:17 2023/9/17 +func (i *Index) Validate() error { + i.Format() + if len(i.Name) <= 2 { + return IndexNameIsEmpty + } + if len(i.Type) == 0 { + return IndexTypeIsEmpty + } + if len(i.FieldList) == 0 { + return IndexFieldIsEmpty + } + return nil +} + +// ToString 生成sql语句 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 17:47 2023/9/17 +func (i *Index) ToString() (string, error) { + if err := i.Validate(); nil != err { + return "", err + } + + // 拼接sql + switch i.Type { + case TableIndexPrimary: + return fmt.Sprintf("PRIMARY KEY (%v)", i.FieldList[0]), nil + case TableIndexUnique: + return fmt.Sprintf("UNIQUE KEY %v (%v)", i.Name, strings.Join(i.FieldList, ",")), nil + case TableIndexKey: + return fmt.Sprintf("KEY %v (%v)", i.Name, strings.Join(i.FieldList, ",")), nil + case TableIndexIndex: + return fmt.Sprintf("INDEX %v (%v)", i.Name, strings.Join(i.FieldList, ",")), nil + default: + return fmt.Sprintf("%v %v (%v)", i.Type, i.Name, strings.Join(i.FieldList, ",")), nil + } +} + +// ToStringIgnoreError ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 15:59 2023/9/18 +func (i *Index) ToStringIgnoreError() string { + sql, _ := i.ToString() + return sql +} diff --git a/install/define/table.go b/install/define/table.go new file mode 100644 index 0000000..86e7e6d --- /dev/null +++ b/install/define/table.go @@ -0,0 +1,153 @@ +// Package define ... +// +// Description : define ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 2023-09-17 11:19 +package define + +import ( + "fmt" + "strings" +) + +// Table 数据表的数据结构 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 11:22 2023/9/17 +type Table struct { + Name string `json:"name"` // 表名称 + Engine string `json:"engine"` // 存储引擎 + DefaultCharset string `json:"default_charset"` // 默认编码 + DefaultCollate string `json:"default_collate"` // 默认集合 + Comment string `json:"comment"` // 表注释 + AutoIncrement int `json:"auto_increment"` // 自增起始值 + FieldList []*Field `json:"field_list"` // 表字段列表 + IndexList []*Index `json:"index_list"` // 表索引列表 + isFormat bool `json:"-"` // 是否格式化过 +} + +// Format 格式化 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 18:14 2023/9/17 +func (t *Table) Format() { + if t.isFormat { + return + } + t.isFormat = true + t.Name = strings.TrimSpace(t.Name) + t.Engine = strings.TrimSpace(t.Engine) + if len(t.Engine) == 0 { + t.Engine = "InnoDB" + } + t.DefaultCharset = strings.TrimSpace(t.DefaultCharset) + if len(t.DefaultCharset) == 0 { + t.DefaultCharset = "utf8mb4" + } + t.DefaultCollate = strings.TrimSpace(t.DefaultCollate) + if len(t.DefaultCollate) == 0 { + t.DefaultCollate = "utf8mb4_general_ci" + } + for _, item := range t.FieldList { + item.Format() + } + for _, item := range t.IndexList { + item.Format() + } +} + +// Validate 数据验证 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 18:23 2023/9/17 +func (t *Table) Validate() error { + t.Format() + if len(t.Name) <= 2 { + return TableNameIsEmpty + } + if len(t.FieldList) == 0 { + return TableFieldListIsEmpty + } + return nil +} + +// ToString 生成sql +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 18:46 2023/9/17 +func (t *Table) ToString() (string, error) { + tableTpl := MysqlTableTpl + replaceTable := map[string]string{ + TableName: t.Name, // 表名 + TableFieldList: "", // 表字段 + TableIndexList: "", // 表索引 + TableEngine: "", // 表引擎 + TableAutoIncrement: "", // 自增起点 + TableDefaultCharset: "", // 默认编码 + TableDefaultCollate: "", // 默认字符集 + TableComment: "", // 表注释 + } + fieldList := make([]string, 0) + for _, item := range t.FieldList { + fieldStr, err := item.ToString() + if nil != err { + return "", err + } + fieldList = append(fieldList, fieldStr) + } + indexList := make([]string, 0) + for _, item := range t.IndexList { + indexStr, err := item.ToString() + if nil != err { + return "", err + } + indexList = append(indexList, indexStr) + } + if len(indexList) == 0 { + replaceTable[TableFieldList] = strings.Join(fieldList, ",") + } else { + replaceTable[TableFieldList] = strings.Join(fieldList, ",") + "," + } + replaceTable[TableIndexList] = strings.Join(indexList, ",") + + if len(t.Engine) > 0 { + replaceTable[TableEngine] = "ENGINE=" + t.Engine + } + if t.AutoIncrement > 0 { + replaceTable[TableAutoIncrement] = fmt.Sprintf("AUTO_INCREMENT=%v", t.AutoIncrement) + } + + if len(t.DefaultCharset) > 0 { + replaceTable[TableDefaultCharset] = "DEFAULT CHARSET=" + t.DefaultCharset + } + if len(t.DefaultCollate) > 0 { + if len(replaceTable[TableDefaultCharset]) == 0 { + replaceTable[TableDefaultCollate] = "DEFAULT COLLATE=" + t.DefaultCollate + } else { + replaceTable[TableDefaultCollate] = "COLLATE=" + t.DefaultCollate + } + } + if len(t.Comment) > 0 { + replaceTable[TableComment] = fmt.Sprintf("COMMENT='%v'", t.Comment) + } + for source, target := range replaceTable { + tableTpl = strings.ReplaceAll(tableTpl, source, target) + } + return tableTpl, nil +} + +// ToStringIgnoreError ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 15:59 2023/9/18 +func (t *Table) ToStringIgnoreError() string { + sql, _ := t.ToString() + return sql +} diff --git a/install/define/tpl.go b/install/define/tpl.go new file mode 100644 index 0000000..23b534a --- /dev/null +++ b/install/define/tpl.go @@ -0,0 +1,82 @@ +// Package define ... +// +// Description : define ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 2023-09-17 11:48 +package define + +import "fmt" + +// 占位符定义 +const ( + // Symbol 引号占位符 + Symbol = "{SYMBOL}" + // FieldName 表字段名称 + FieldName = "{FIELD_NAME}" + // FieldType 字段类型 + FieldType = "{FIELD_TYPE}" + // FieldUnsigned 字段无符号 + FieldUnsigned = "{FIELD_UNSIGNED}" + // FieldNotNull 字段不为空 + FieldNotNull = "{FIELD_NOT_NULL}" + // FieldAutoIncrement 表字段自增 + FieldAutoIncrement = "{FIELD_AUTO_INCREMENT}" + // FieldDefaultValue 默认值 + FieldDefaultValue = "{FIELD_DEFAULT_VALUE}" + // FieldOnUpdate 字段自动更新 + FieldOnUpdate = "{FIELD_ON_UPDATE}" + // FieldComment 字段注释 + FieldComment = "{FIELD_COMMENT}" + // IndexType 索引类型 + IndexType = "{INDEX_TYPE}" + // IndexName 索引名称 + IndexName = "{INDEX_NAME}" + // IndexFieldList 索引字段列表 + IndexFieldList = "{INDEX_FIELD_LIST}" + // TableName 表名称 + TableName = "{TABLE_NAME}" + // TableFieldList 表字段列表 + TableFieldList = "{TABLE_FIELD_LIST}" + // TableIndexList 表索引列表 + TableIndexList = "{TABLE_INDEX_LIST}" + // TableEngine 数据表存储引擎 + TableEngine = "{TABLE_ENGINE}" + // TableAutoIncrement 表自增起始值 + TableAutoIncrement = "{TABLE_AUTO_INCREMENT}" + // TableDefaultCharset 表默认编码 + TableDefaultCharset = "{TABLE_DEFAULT_CHARSET}" + // TableDefaultCollate 表默认编码集 + TableDefaultCollate = "{TABLE_DEFAULT_COLLATE}" + // TableComment 表注释 + TableComment = "{TABLE_COMMENT}" +) + +// mysql 数据库相关模板 +var ( + // MysqlFieldTpl mysql 表字段模板 + MysqlFieldTpl = fmt.Sprintf("%v %v %v %v %v %v %v %v", FieldName, FieldType, FieldUnsigned, FieldNotNull, FieldAutoIncrement, FieldDefaultValue, FieldOnUpdate, FieldComment) + // MysqlTableTpl 创建表sql语句 + MysqlTableTpl = fmt.Sprintf("CREATE TABLE %v (%v %v) %v %v %v %v %v;", TableName, TableFieldList, TableIndexList, TableEngine, TableAutoIncrement, TableDefaultCharset, TableDefaultCollate, TableComment) +) + +const ( + // TableIndexPrimary 主键索引 + TableIndexPrimary = "PRIMARY" + // TableIndexUnique 唯一索引 + TableIndexUnique = "UNIQUE" + // TableIndexKey key + TableIndexKey = "KEY" + // TableIndexIndex index + TableIndexIndex = "INDEX" +) + +const ( + // TableEngineInnoDB InnoDB 存储引擎 + TableEngineInnoDB = "InnoDB" + // TableCharsetUtf8mb4 utf8mb4编码 + TableCharsetUtf8mb4 = "utf8mb4" + // TableCollateUtf8mb4GeneralCi 字符集编码 + TableCollateUtf8mb4GeneralCi = "utf8mb4_general_ci" +) diff --git a/install/helper.go b/install/helper.go new file mode 100644 index 0000000..28023f7 --- /dev/null +++ b/install/helper.go @@ -0,0 +1,251 @@ +// Package install ... +// +// Description : define ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 2023-09-17 19:41 +package install + +import ( + "fmt" + + "git.zhangdeman.cn/zhangdeman/database/install/define" + "git.zhangdeman.cn/zhangdeman/wrapper" +) + +var ( + // Helper ... + Helper *helper +) + +func init() { + Helper = &helper{} +} + +// helper ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 19:42 2023/9/17 +type helper struct { +} + +// NewPrimaryID 主键ID +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 19:52 2023/9/17 +func (h *helper) NewPrimaryID(name string, comment string) *define.Field { + return &define.Field{ + Name: name, + Type: "BIGINT(20)", + Unsigned: true, + NotNull: true, + DefaultValue: wrapper.String("0").ToStringPtr().Value, + PrimaryKey: true, + IsAutoIncrement: true, + Comment: comment, + } +} + +// NewBigintField 生成bigint字段 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 19:43 2023/9/17 +func (h *helper) NewBigintField(name string, unsigned bool, defaultVal string, comment string) *define.Field { + return &define.Field{ + Name: name, + Type: "BIGINT(20)", + Unsigned: unsigned, + NotNull: true, + DefaultValue: wrapper.String(defaultVal).ToStringPtr().Value, + PrimaryKey: false, + IsAutoIncrement: false, + Comment: comment, + } +} + +// NewIntField 生成int类型 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 19:57 2023/9/17 +func (h *helper) NewIntField(name string, unsigned bool, defaultVal string, comment string) *define.Field { + return &define.Field{ + Name: name, + Type: "INT(11)", + Unsigned: unsigned, + NotNull: true, + DefaultValue: wrapper.String(defaultVal).ToStringPtr().Value, + PrimaryKey: false, + IsAutoIncrement: false, + Comment: comment, + } +} + +// NewVarcharField varchar字段 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 19:59 2023/9/17 +func (h *helper) NewVarcharField(name string, length int, defaultVal string, comment string) *define.Field { + return &define.Field{ + Name: name, + Type: fmt.Sprintf("VARCHAR(%v)", length), + Unsigned: false, + NotNull: true, + DefaultValue: wrapper.String(defaultVal).ToStringPtr().Value, + PrimaryKey: false, + IsAutoIncrement: false, + Comment: comment, + } +} + +// NewCharField char字段 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 20:01 2023/9/17 +func (h *helper) NewCharField(name string, length int, comment string, defaultVal string) *define.Field { + return &define.Field{ + Name: name, + Type: fmt.Sprintf("CHAR(%v)", length), + Unsigned: false, + NotNull: true, + DefaultValue: wrapper.String(defaultVal).ToStringPtr().Value, + PrimaryKey: false, + IsAutoIncrement: false, + Comment: comment, + } +} + +// NewTextField text字段 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 14:49 2024/1/11 +func (h *helper) NewTextField(name string, comment string) *define.Field { + return &define.Field{ + Name: name, + Type: "TEXT", + Unsigned: false, + NotNull: false, + DefaultValue: nil, + PrimaryKey: false, + IsAutoIncrement: false, + Comment: comment, + } +} + +// NewTimestampField ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 14:02 2023/9/18 +func (h *helper) NewTimestampField(name string, comment string, defaultVal string) *define.Field { + return &define.Field{ + Name: name, + Type: "TIMESTAMP", + Unsigned: false, + NotNull: true, + DefaultValue: wrapper.String(defaultVal).ToStringPtr().Value, + PrimaryKey: false, + IsAutoIncrement: false, + Comment: comment, + } +} + +// NewTimestampFieldWithUpdate 自动更新字段 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 14:03 2023/9/18 +func (h *helper) NewTimestampFieldWithUpdate(name string, comment string, defaultVal string) *define.Field { + return &define.Field{ + Name: name, + Type: "TIMESTAMP", + Unsigned: false, + NotNull: true, + DefaultValue: wrapper.String(defaultVal).ToStringPtr().Value, + PrimaryKey: false, + IsAutoIncrement: false, + OnUpdate: "current_timestamp()", + Comment: comment, + } +} + +// NewDefaultTable 数据表 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 14:11 2023/9/18 +func (h *helper) NewDefaultTable(name string, comment string, fieldList []*define.Field, indexList []*define.Index) *define.Table { + return &define.Table{ + Name: name, + Engine: define.TableEngineInnoDB, + DefaultCharset: define.TableCharsetUtf8mb4, + DefaultCollate: define.TableCollateUtf8mb4GeneralCi, + Comment: comment, + AutoIncrement: 1, + FieldList: fieldList, + IndexList: indexList, + } +} + +// NewPrimaryIndex ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 16:11 2023/9/18 +func (h *helper) NewPrimaryIndex(fieldName string) *define.Index { + return &define.Index{ + Type: define.TableIndexPrimary, + Name: fieldName, + FieldList: []string{fieldName}, + IsFormat: false, + } +} + +// NewUniqueIndex 生成唯一索引 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 17:05 2023/9/18 +func (h *helper) NewUniqueIndex(idxName string, fieldNameList []string) *define.Index { + return &define.Index{ + Type: define.TableIndexUnique, + Name: idxName, + FieldList: fieldNameList, + IsFormat: false, + } +} + +// NewKeyIndex ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 17:05 2023/9/18 +func (h *helper) NewKeyIndex(idxName string, fieldNameList []string) *define.Index { + return &define.Index{ + Type: define.TableIndexKey, + Name: idxName, + FieldList: fieldNameList, + IsFormat: false, + } +} + +// NewIndexIndex ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 17:05 2023/9/18 +func (h *helper) NewIndexIndex(idxName string, fieldNameList []string) *define.Index { + return &define.Index{ + Type: define.TableIndexIndex, + Name: idxName, + FieldList: fieldNameList, + IsFormat: false, + } +}