tpl format

This commit is contained in:
白茶清欢 2024-04-14 21:46:43 +08:00
parent b5766839fa
commit 1e720ff9a3

View File

@ -127,7 +127,7 @@ func generateTable(tableName string, modelStructName string, columnList []*sqlpa
// TableName 获取表名称 // TableName 获取表名称
func ({{TABLE_FIRST}} {{TABLE_STRUCT_NAME}}) TableName() string { func ({{TABLE_FIRST}} {{TABLE_STRUCT_NAME}}) TableName() string {
return "{{TABLE_NAME}}" return "{{TABLE_NAME}}"
}` }`
replaceTable := map[string]string{ replaceTable := map[string]string{
"{{TABLE_FIRST}}": tableFirst, "{{TABLE_FIRST}}": tableFirst,
@ -171,22 +171,22 @@ func generateTableColumnDefined(modelStructName string, columnList []*sqlparser.
structFieldCommentDefine = strings.ReplaceAll(structFieldCommentDefine, k, v) structFieldCommentDefine = strings.ReplaceAll(structFieldCommentDefine, k, v)
} }
structFieldResult += structFieldDefine + "\n" structFieldResult += structFieldDefine + "\n"
structFieldDescInstanceResult += " " + structFieldDescDefine + ",\n" structFieldDescInstanceResult += structFieldDescDefine + ",\n"
structFieldCommentInstanceResult += " " + structFieldCommentDefine + ",\n" structFieldCommentInstanceResult += structFieldCommentDefine + ",\n"
} }
structFieldResult += "}" structFieldResult += "}"
structFieldDescInstanceResult += " }" structFieldDescInstanceResult += "}"
structFieldCommentInstanceResult += " }" structFieldCommentInstanceResult += "}"
tableColumnFunction := ` tableColumnFunction := `
// Columns 获取表字段定义 // Columns 获取表字段定义
func ({TABLE_FIRST} {MODEL_STRUCT_NAME}) Columns() *{COLUMN_DEFINED} { func ({TABLE_FIRST} {MODEL_STRUCT_NAME}) Columns() *{COLUMN_DEFINED} {
return {STRUCT_FIELD_DESC_DEFINED_RESULT} return {STRUCT_FIELD_DESC_DEFINED_RESULT}
} }
// ColumnComment 获取表字段描述 // ColumnComment 获取表字段描述
func ({TABLE_FIRST} {MODEL_STRUCT_NAME}) ColumnComment() map[string]string { func ({TABLE_FIRST} {MODEL_STRUCT_NAME}) ColumnComment() map[string]string {
return {STRUCT_FIELD_COMMENT_DEFINED_RESULT} return {STRUCT_FIELD_COMMENT_DEFINED_RESULT}
} }
` `
dataMap := map[string]string{ dataMap := map[string]string{