-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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(cmd/gf): add interface functions generating for embedded struct of logic struct in command gen service
#3802
base: master
Are you sure you want to change the base?
Conversation
gen service
gen service
gen service
这个PR @hailaz 和 @oldme-git 一起帮忙review下呢? |
Can @hailaz and @oldme-git help review this PR? |
@gqcn Is this function necessary? What to do if there are multiple levels of nesting? |
Multiple levels of nesting have been handled. Functions with the same name in the inner layer will be overwritten by function definitions with the same name in the outer layer. Some scenarios need to be handled this way. For example, there is an sMember first, and then you need to define an sAdmin to inherit from sMember. sAdmin only overloads some specific methods, and the others follow sMember. |
@joy999 Well, can you make a switch to control it? Usually it is not needed and the user can turn it on by himself. In addition, please add more comments on the key logic to facilitate long-term maintenance. |
The processing logic of determining whether to inline recognition through the beginning of the structure s has now been removed. Instead, we use the method of adding a tag after the embedded structure name, so that no matter it starts with s or other structures, it can be embedded. At the same time, it can also be embedded across packages. If the tag now defines gen:"extend", it will be recognized inline. |
识别 |
The reason for identifying the beginning of |
并没有改动原来的sXXX的生成判定。我去掉的是我用来判定内嵌识别的那部分我自己添加的代码,之前是以sXXX为嵌入结构体,其它的命名的结构体不会被识别为嵌入方法继承,所以只能在本目录下引入。现在这个调整为了通过tag来识别,所以,理论上任意位置的结构体现在都可以嵌入了。 |
The original sXXX generation judgment has not been changed. What I removed is the part of the code I added myself to determine the embedded recognition. Previously, sXXX was used as the embedded structure. Other named structures will not be recognized as embedded method inheritance, so they can only be used in this directory. introduced below. Now this adjustment is to identify it through tags, so in theory, the structure at any position can now be embedded. |
实现logic中内嵌其它logic时,生成service可以合并内嵌logic的接口生成。
比如 type sAdmin struct {
sMember
}
生成的service.IAdmin将存在sMember的接口合并,并不会只有sAdmin的接口。