|
|
|
@ -126,7 +126,12 @@ func (g *defaultGenerator) genModel(in parser.Table, withCache bool) (string, er
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
importsCode := genImports(withCache)
|
|
|
|
|
|
|
|
|
|
importsCode, err := genImports(withCache, in.ContainsTime())
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var table Table
|
|
|
|
|
table.Table = in
|
|
|
|
|
table.CacheKey = m
|
|
|
|
@ -135,36 +140,44 @@ func (g *defaultGenerator) genModel(in parser.Table, withCache bool) (string, er
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
typesCode, err := genTypes(table, withCache)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
newCode, err := genNew(table, withCache)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
insertCode, err := genInsert(table, withCache)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var findCode = make([]string, 0)
|
|
|
|
|
findOneCode, err := genFindOne(table, withCache)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
findOneByFieldCode, err := genFineOneByField(table, withCache)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
findCode = append(findCode, findOneCode, findOneByFieldCode)
|
|
|
|
|
updateCode, err := genUpdate(table, withCache)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
deleteCode, err := genDelete(table, withCache)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
output, err := t.Execute(map[string]interface{}{
|
|
|
|
|
"imports": importsCode,
|
|
|
|
|
"vars": varsCode,
|
|
|
|
@ -178,5 +191,6 @@ func (g *defaultGenerator) genModel(in parser.Table, withCache bool) (string, er
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return output.String(), nil
|
|
|
|
|
}
|
|
|
|
|