mirror of
https://github.com/zeromicro/go-zero.git
synced 2026-05-10 08:29:58 +08:00
add customized.tpl for model template (#4086)
Co-authored-by: sudaoxyz <sudaoxyz@gmail.com>
This commit is contained in:
@@ -36,16 +36,17 @@ type (
|
||||
Option func(generator *defaultGenerator)
|
||||
|
||||
code struct {
|
||||
importsCode string
|
||||
varsCode string
|
||||
typesCode string
|
||||
newCode string
|
||||
insertCode string
|
||||
findCode []string
|
||||
updateCode string
|
||||
deleteCode string
|
||||
cacheExtra string
|
||||
tableName string
|
||||
importsCode string
|
||||
varsCode string
|
||||
typesCode string
|
||||
newCode string
|
||||
insertCode string
|
||||
findCode []string
|
||||
updateCode string
|
||||
deleteCode string
|
||||
cacheExtra string
|
||||
tableName string
|
||||
customizedCode string
|
||||
}
|
||||
|
||||
codeTuple struct {
|
||||
@@ -323,17 +324,23 @@ func (g *defaultGenerator) genModel(in parser.Table, withCache bool) (string, er
|
||||
return "", err
|
||||
}
|
||||
|
||||
customizedCode, err := genCustomized(table, withCache, g.isPostgreSql)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
code := &code{
|
||||
importsCode: importsCode,
|
||||
varsCode: varsCode,
|
||||
typesCode: typesCode,
|
||||
newCode: newCode,
|
||||
insertCode: insertCode,
|
||||
findCode: findCode,
|
||||
updateCode: updateCode,
|
||||
deleteCode: deleteCode,
|
||||
cacheExtra: ret.cacheExtra,
|
||||
tableName: tableName,
|
||||
importsCode: importsCode,
|
||||
varsCode: varsCode,
|
||||
typesCode: typesCode,
|
||||
newCode: newCode,
|
||||
insertCode: insertCode,
|
||||
findCode: findCode,
|
||||
updateCode: updateCode,
|
||||
deleteCode: deleteCode,
|
||||
cacheExtra: ret.cacheExtra,
|
||||
tableName: tableName,
|
||||
customizedCode: customizedCode,
|
||||
}
|
||||
|
||||
output, err := g.executeModel(table, code)
|
||||
@@ -387,6 +394,7 @@ func (g *defaultGenerator) executeModel(table Table, code *code) (*bytes.Buffer,
|
||||
"extraMethod": code.cacheExtra,
|
||||
"tableName": code.tableName,
|
||||
"data": table,
|
||||
"customized": code.customizedCode,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user