mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-25 02:08:44 +08:00
81831b60a9
* fix(change model template file type): All model template variables are stored in tpl format files with the same name as the template generated using the template init command * fix(change model template file type): All model template variables are stored in tpl format files with the same name as the template generated using the template init command Co-authored-by: qilvge <qilvge@.qilvge.com> Co-authored-by: Kevin Wan <wanjunfeng@gmail.com>
9 lines
503 B
Smarty
9 lines
503 B
Smarty
func (m *default{{.upperStartCamelObject}}Model) formatPrimary(primary interface{}) string {
|
|
return fmt.Sprintf("%s%v", {{.primaryKeyLeft}}, primary)
|
|
}
|
|
|
|
func (m *default{{.upperStartCamelObject}}Model) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary interface{}) error {
|
|
query := fmt.Sprintf("select %s from %s where {{.originalPrimaryField}} = {{if .postgreSql}}$1{{else}}?{{end}} limit 1", {{.lowerStartCamelObject}}Rows, m.table )
|
|
return conn.QueryRowCtx(ctx, v, query, primary)
|
|
}
|