增加生成dao的模版
This commit is contained in:
@ -9,8 +9,6 @@ package sql2go
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"git.zhangdeman.cn/zhangdeman/util"
|
||||
)
|
||||
|
||||
// GenerateDao 根据sql自动生成dao
|
||||
@ -26,9 +24,6 @@ func GenerateDao(sql string, packageName string) (string, error) {
|
||||
if nil != err {
|
||||
return "", err
|
||||
}
|
||||
// 读入模板
|
||||
tplByte, _ := util.File.ReadFileContent("dao_tpl.tpl")
|
||||
tpl := string(tplByte)
|
||||
replaceTable := map[string]string{
|
||||
"{PACKAGE}": packageName,
|
||||
"{DATA_STRUCT_DAO}": basic.ModelStruct + "Dao",
|
||||
@ -40,6 +35,7 @@ func GenerateDao(sql string, packageName string) (string, error) {
|
||||
"{PRIMARY_KEY_TYPE}": basic.PrimaryFieldType,
|
||||
}
|
||||
|
||||
tpl := DaoTpl
|
||||
for oldVal, newVal := range replaceTable {
|
||||
tpl = strings.ReplaceAll(tpl, oldVal, newVal)
|
||||
}
|
||||
|
Reference in New Issue
Block a user