Skip to content

Commit

Permalink
feat: generate with Session method
Browse files Browse the repository at this point in the history
  • Loading branch information
tr1v3r committed Oct 18, 2022
1 parent 6cbdcbe commit 3c1f921
Show file tree
Hide file tree
Showing 31 changed files with 3,313 additions and 3 deletions.
4 changes: 4 additions & 0 deletions internal/template/method.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ func ({{.S}} {{.QueryStructName}}Do) WriteDB() {{.ReturnObject}} {
return {{.S}}.Clauses(dbresolver.Write)
}
func ({{.S}} {{.QueryStructName}}Do) Session(config *gorm.Session) {{.ReturnObject}} {
return {{.S}}.withDO({{.S}}.DO.Session(config))
}
func ({{.S}} {{.QueryStructName}}Do) Clauses(conds ...clause.Expression) {{.ReturnObject}} {
return {{.S}}.withDO({{.S}}.DO.Clauses(conds...))
}
Expand Down
3 changes: 2 additions & 1 deletion internal/template/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const (
{{.QueryStructName}}Do
` + fields + `
}
` + tableMethod + asMethond + updateFieldMethod + getFieldMethod + fillFieldMapMethod + cloneMethod+ replaceMethod + relationship + defineMethodStruct
` + tableMethod + asMethond + updateFieldMethod + getFieldMethod + fillFieldMapMethod + cloneMethod + replaceMethod + relationship + defineMethodStruct

// TableQueryStructWithContext table query struct with context
TableQueryStructWithContext = createMethod + `
Expand Down Expand Up @@ -151,6 +151,7 @@ type I{{.ModelStructName}}Do interface {
ReadDB() I{{.ModelStructName}}Do
WriteDB() I{{.ModelStructName}}Do
As(alias string) gen.Dao
Session(config *gorm.Session) I{{.ModelStructName}}Do
Columns(cols ...field.Expr) gen.Columns
Clauses(conds ...clause.Expression) I{{.ModelStructName}}Do
Not(conds ...gen.Condition) I{{.ModelStructName}}Do
Expand Down
4 changes: 4 additions & 0 deletions tests/.expect/dal_1/query/banks.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions tests/.expect/dal_1/query/credit_cards.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions tests/.expect/dal_1/query/customers.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions tests/.expect/dal_1/query/people.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions tests/.expect/dal_1/query/users.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions tests/.expect/dal_2/query/banks.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions tests/.expect/dal_2/query/credit_cards.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions tests/.expect/dal_2/query/customers.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions tests/.expect/dal_2/query/people.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions tests/.expect/dal_2/query/users.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions tests/.expect/dal_3/model/banks.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions tests/.expect/dal_3/model/credit_cards.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions tests/.expect/dal_3/model/customers.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 43 additions & 0 deletions tests/.expect/dal_3/model/people.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions tests/.expect/dal_3/model/users.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3c1f921

Please sign in to comment.