Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: extended helper interface to support custom object method and i… #1147

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

eleztian
Copy link

@eleztian eleztian commented May 7, 2024

…nterface definitions.

  • Do only one thing
  • Non breaking API changes
  • Tested

What did this pull request do?

  • Extend the object interface in the helper and add the mehtod method.
  • Added Interface interface in helper for customizing query interface

User Case Description

In some scenarios, I need to dynamically build modules and queries through code instead of relying on the target code to compile and run (such as parsing go code files through ast or other methods). Here are my use cases:

	g := gen.NewGenerator(cfg)
	obj, err := sql.ParseFromStruct("./example/model_user.go", "TblUser")
	if err != nil {
		panic(err)
	}
	g.ApplyInterface(sql.Interface{
		IfName: "query",
		IfMethods: []sql.Method{{
			MethodName: "GetUser",
			Doc:        "SELECT * FROM @@table WHERE xxx=1",
		}}}, g.GenerateModelFrom(obj))

	g.Execute()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant