-
Notifications
You must be signed in to change notification settings - Fork 16
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: improve logic in the starbook #135
Conversation
|
||
import ( | ||
"star/api/users" | ||
usersL "star/internal/logic/users" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在API中,接口包名应该是v1/v2
这样的形式,而在logic
中,应该是users
这样的形式,因此并不需要设置别名。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
users
被"star/api/users"
占用了,那个是gen ctrl
生成的
|
||
func NewV1() users.IUsersV1 { | ||
return &ControllerV1{ | ||
users: &usersL.Users{}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
最好通过New
的创建方法来初始化业务逻辑封装对象,因为外部调用时并不知道一个逻辑对象需要做什么初始化逻辑。直接使用&usersL.Users{}
的方式就无法进行初始化逻辑封装了。
func NewV1() words.IWordsV1 { | ||
return &ControllerV1{ | ||
users: &usersL.Users{}, | ||
words: &wordsL.Words{}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上。
@@ -56,13 +56,13 @@ import ( | |||
"star/utility" | |||
) | |||
|
|||
type UserClaims struct { | |||
type userClaims struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个结构体为什么不公开呢?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个结构体users
内部用的,想着也没必要公开
No description provided.