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: improve logic in the starbook #135

Merged
merged 2 commits into from
Jan 2, 2025
Merged

feat: improve logic in the starbook #135

merged 2 commits into from
Jan 2, 2025

Conversation

oldme-git
Copy link
Member

No description provided.


import (
"star/api/users"
usersL "star/internal/logic/users"
Copy link
Member

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这样的形式,因此并不需要设置别名。

Copy link
Member Author

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{},
Copy link
Member

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{},
Copy link
Member

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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个结构体为什么不公开呢?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个结构体users内部用的,想着也没必要公开

@gqcn gqcn merged commit 6feaf2b into main Jan 2, 2025
1 check passed
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.

2 participants