Skip to content

Commit

Permalink
fix: fix cmd template
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkgos committed Sep 26, 2024
1 parent ed767fd commit ea6bfee
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions cmd/dyngen/command/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ var Static embed.FS

var TemplateFuncs = template.FuncMap{
"add": func(a, b int) int { return a + b },
"snakecase": utils.SnakeCase,
"kebabcase": utils.Kebab,
"pascalcase": utils.PascalCase,
"smallcamelcase": utils.SmallCamelCase,
"stylename": utils.StyleName,
"snakeCase": utils.SnakeCase,
"kebabCase": utils.Kebab,
"pascalCase": utils.PascalCase,
"smallCamelCase": utils.SmallCamelCase,
"styleName": utils.StyleName,
}
var (
tpl = template.Must(template.New("components").
Expand Down
2 changes: 1 addition & 1 deletion cmd/dyngen/command/template/dal_gorm.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

{{- $e := .Entity}}
{{- $stName := pascalcase $e.Name}}
{{- $stName := pascalCase $e.Name}}
{{- $mdPrefix := .ModelPrefix}}
{{- $queryPrefix := .QueryPrefix}}
{{- $mdName := printf "%s%s" $mdPrefix $stName}}
Expand Down
12 changes: 6 additions & 6 deletions cmd/dyngen/command/template/dal_query.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,36 @@ package {{.Package}}

{{- $style := .Style}}
{{- $e := .Entity}}
{{- $stName := pascalcase $e.Name}}
{{- $stName := pascalCase $e.Name}}

type Update{{$stName}}ByPartial struct {
{{- range $f := $e.Fields}}
{{if or (eq $f.GoName "CreatedAt") (eq $f.GoName "UpdatedAt") (eq $f.GoName "DeletedAt")}}// {{end}}{{$f.GoName}} {{if ne $f.GoName "Id"}}*{{- end}}{{$f.Type.Ident}} `json:"{{stylename $style $f.ColumnName}}"`
{{if or (eq $f.GoName "CreatedAt") (eq $f.GoName "UpdatedAt") (eq $f.GoName "DeletedAt")}}// {{end}}{{$f.GoName}} {{if ne $f.GoName "Id"}}*{{- end}}{{$f.Type.Ident}} `json:"{{styleName $style $f.ColumnName}}"`
{{- end}}
}

type Get{{$stName}}ByFilter struct {
{{- range $f := $e.Fields}}
{{if or (eq $f.GoName "CreatedAt") (eq $f.GoName "UpdatedAt") (eq $f.GoName "DeletedAt")}}// {{end}}{{$f.GoName}} {{if eq $f.Type.Type 1 }}*{{- end}}{{$f.Type.Ident}} `json:"{{stylename $style $f.ColumnName}}"`
{{if or (eq $f.GoName "CreatedAt") (eq $f.GoName "UpdatedAt") (eq $f.GoName "DeletedAt")}}// {{end}}{{$f.GoName}} {{if eq $f.Type.Type 1 }}*{{- end}}{{$f.Type.Ident}} `json:"{{styleName $style $f.ColumnName}}"`
{{- end}}
}

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

type List{{$stName}}ByFilter struct {
{{- range $f := $e.Fields}}
{{if or (eq $f.GoName "CreatedAt") (eq $f.GoName "UpdatedAt") (eq $f.GoName "DeletedAt")}}// {{end}}{{$f.GoName}} {{if eq $f.Type.Type 1 }}*{{- end}}{{$f.Type.Ident}} `json:"{{stylename $style $f.ColumnName}}"`
{{if or (eq $f.GoName "CreatedAt") (eq $f.GoName "UpdatedAt") (eq $f.GoName "DeletedAt")}}// {{end}}{{$f.GoName}} {{if eq $f.Type.Type 1 }}*{{- end}}{{$f.Type.Ident}} `json:"{{styleName $style $f.ColumnName}}"`
{{- end}}
Page int64 `json:"page"`
PerPage int64 `json:"perPage"`
}

type PluckId{{$stName}}ByFilter struct {
{{- range $f := $e.Fields}}
{{if or (eq $f.GoName "CreatedAt") (eq $f.GoName "UpdatedAt") (eq $f.GoName "DeletedAt")}}// {{end}}{{$f.GoName}} {{if eq $f.Type.Type 1 }}*{{- end}}{{$f.Type.Ident}} `json:"{{stylename $style $f.ColumnName}}"`
{{if or (eq $f.GoName "CreatedAt") (eq $f.GoName "UpdatedAt") (eq $f.GoName "DeletedAt")}}// {{end}}{{$f.GoName}} {{if eq $f.Type.Type 1 }}*{{- end}}{{$f.Type.Ident}} `json:"{{styleName $style $f.ColumnName}}"`
{{- end}}
}
2 changes: 1 addition & 1 deletion cmd/dyngen/command/template/dal_rapier.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

{{- $e := .Entity}}
{{- $stName := pascalcase $e.Name}}
{{- $stName := pascalCase $e.Name}}
{{- $mdPrefix := .ModelPrefix}}
{{- $queryPrefix := .QueryPrefix}}
{{- $repoPrefix := .RepoPrefix}}
Expand Down

0 comments on commit ea6bfee

Please sign in to comment.