Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkgos committed May 30, 2024
1 parent 211fd31 commit 69c4212
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions cmd/dyngen/command/template/dal_gorm.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (b {{$stName}}) ExistByFilter(ctx context.Context, q *{{$queryPrefix}}Exist
{{- else }}
if q.{{$f.GoName}} != 0 {
{{- end}}
db = db.Where("{{$f.ColumnName}} = ?", q.{{$f.GoName}})
db = db.Where("{{$f.ColumnName}} = ?", {{if eq $f.Type.Type 1 }}*{{- end}}q.{{$f.GoName}})
}
{{- end}}
{{- end}}
Expand Down Expand Up @@ -198,7 +198,7 @@ func (b {{$stName}}) PluckIdByFilter(ctx context.Context, q *{{$queryPrefix}}Plu
{{- else }}
if q.{{$f.GoName}} != 0 {
{{- end}}
db = db.Where("{{$f.ColumnName}} = ?", q.{{$f.GoName}})
db = db.Where("{{$f.ColumnName}} = ?", {{if eq $f.Type.Type 1 }}*{{- end}}q.{{$f.GoName}})
}
{{- end}}
{{- end}}
Expand All @@ -221,7 +221,7 @@ func get{{$stName}}Filter(q *{{$queryPrefix}}Get{{$stName}}ByFilter) func(db *go
{{- else }}
if q.{{$f.GoName}} != 0 {
{{- end}}
db = db.Where("{{$f.ColumnName}} = ?", q.{{$f.GoName}})
db = db.Where("{{$f.ColumnName}} = ?", {{if eq $f.Type.Type 1 }}*{{- end}}q.{{$f.GoName}})
}
{{- end}}
{{- end}}
Expand All @@ -242,7 +242,7 @@ func list{{$stName}}Filter(q *{{$queryPrefix}}List{{$stName}}ByFilter) func(db *
{{- else }}
if q.{{$f.GoName}} != 0 {
{{- end}}
db = db.Where("{{$f.ColumnName}} = ?", q.{{$f.GoName}})
db = db.Where("{{$f.ColumnName}} = ?", {{if eq $f.Type.Type 1 }}*{{- end}}q.{{$f.GoName}})
}
{{- end}}
{{- end}}
Expand Down
8 changes: 4 additions & 4 deletions cmd/dyngen/command/template/dal_query.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@ type Update{{$stName}}ByPartial struct {
type Get{{$stName}}ByFilter struct {
{{- range $f := $e.Fields}}
{{- if and (ne $f.GoName "CreatedAt") (ne $f.GoName "UpdatedAt") (ne $f.GoName "DeletedAt")}}
{{$f.GoName}} {{$f.Type.Ident}} `json:"{{smallcamelcase $f.ColumnName}}"`
{{$f.GoName}} {{if eq $f.Type.Type 1 }}*{{- end}}{{$f.Type.Ident}} `json:"{{smallcamelcase $f.ColumnName}}"`
{{- end}}
{{- end}}
}

type Exist{{$stName}}ByFilter struct {
{{- range $f := $e.Fields}}
{{- if and (ne $f.GoName "CreatedAt") (ne $f.GoName "UpdatedAt") (ne $f.GoName "DeletedAt")}}
{{$f.GoName}} {{$f.Type.Ident}} `json:"{{smallcamelcase $f.ColumnName}}"`
{{$f.GoName}} {{if eq $f.Type.Type 1 }}*{{- end}}{{$f.Type.Ident}} `json:"{{smallcamelcase $f.ColumnName}}"`
{{- end}}
{{- end}}
}

type List{{$stName}}ByFilter struct {
{{- range $f := $e.Fields}}
{{- if and (ne $f.GoName "CreatedAt") (ne $f.GoName "UpdatedAt") (ne $f.GoName "DeletedAt")}}
{{$f.GoName}} {{$f.Type.Ident}} `json:"{{smallcamelcase $f.ColumnName}}"`
{{$f.GoName}} {{if eq $f.Type.Type 1 }}*{{- end}}{{$f.Type.Ident}} `json:"{{smallcamelcase $f.ColumnName}}"`
{{- end}}
{{- end}}
Page int64 `json:"page"`
Expand All @@ -40,7 +40,7 @@ type List{{$stName}}ByFilter struct {
type PluckId{{$stName}}ByFilter struct {
{{- range $f := $e.Fields}}
{{- if and (ne $f.GoName "CreatedAt") (ne $f.GoName "UpdatedAt") (ne $f.GoName "DeletedAt")}}
{{$f.GoName}} {{$f.Type.Ident}} `json:"{{smallcamelcase $f.ColumnName}}"`
{{$f.GoName}} {{if eq $f.Type.Type 1 }}*{{- end}}{{$f.Type.Ident}} `json:"{{smallcamelcase $f.ColumnName}}"`
{{- end}}
{{- end}}
}
16 changes: 8 additions & 8 deletions cmd/dyngen/command/template/dal_rapier.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ func (b {{$stName}}) ExistByFilter(ctx context.Context, q *{{$queryPrefix}}Exist
{{- else if eq $f.Type.Type 18 }}
if !q.{{$f.GoName}}.IsZero() {
{{- else if eq $f.Type.Type 1 }}
{
if q.{{$f.GoName}} != nil {
{{- else }}
if q.{{$f.GoName}} != 0 {
{{- end}}
db = db.Where(ref.{{$f.GoName}}.Eq(q.{{$f.GoName}}))
db = db.Where(ref.{{$f.GoName}}.Eq({{if eq $f.Type.Type 1 }}*{{- end}}q.{{$f.GoName}}))
}
{{- end}}
{{- end}}
Expand Down Expand Up @@ -167,11 +167,11 @@ func (b {{$stName}}) PluckIdByFilter(ctx context.Context, q *{{$queryPrefix}}Plu
{{- else if eq $f.Type.Type 18 }}
if !q.{{$f.GoName}}.IsZero() {
{{- else if eq $f.Type.Type 1 }}
{
if q.{{$f.GoName}} != nil {
{{- else }}
if q.{{$f.GoName}} != 0 {
{{- end}}
db = db.Where(ref.{{$f.GoName}}.Eq(q.{{$f.GoName}}))
db = db.Where(ref.{{$f.GoName}}.Eq({{if eq $f.Type.Type 1 }}*{{- end}}q.{{$f.GoName}}))
}
{{- end}}
{{- end}}
Expand All @@ -189,11 +189,11 @@ func get{{$stName}}Filter(ref *{{$repoPrefix}}{{$stName}}_Native, q *{{$queryPre
{{- else if eq $f.Type.Type 18 }}
if !q.{{$f.GoName}}.IsZero() {
{{- else if eq $f.Type.Type 1 }}
{
if q.{{$f.GoName}} != nil {
{{- else }}
if q.{{$f.GoName}} != 0 {
{{- end}}
db = db.Where(ref.{{$f.GoName}}.Eq(q.{{$f.GoName}}))
db = db.Where(ref.{{$f.GoName}}.Eq({{if eq $f.Type.Type 1 }}*{{- end}}q.{{$f.GoName}}))
}
{{- end}}
{{- end}}
Expand All @@ -210,11 +210,11 @@ func list{{$stName}}Filter(ref *{{$repoPrefix}}{{$stName}}_Native, q *{{$queryPr
{{- else if eq $f.Type.Type 18 }}
if !q.{{$f.GoName}}.IsZero() {
{{- else if eq $f.Type.Type 1 }}
{
if q.{{$f.GoName}} != nil {
{{- else }}
if q.{{$f.GoName}} != 0 {
{{- end}}
db = db.Where(ref.{{$f.GoName}}.Eq(q.{{$f.GoName}}))
db = db.Where(ref.{{$f.GoName}}.Eq({{if eq $f.Type.Type 1 }}*{{- end}}q.{{$f.GoName}}))
}
{{- end}}
{{- end}}
Expand Down

0 comments on commit 69c4212

Please sign in to comment.