-
Notifications
You must be signed in to change notification settings - Fork 10
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
refactor: modern project structure in launch_screen #76
Conversation
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.
把全部修改文件的 import 检查一遍,遵循下面规范
- golang 内置包
- 外部包
- 隶属于本 org(west2-online)的包
除此之外,注意一下 cache、db 的一些通用函数,前面一些函数写重复了
cmd/launch_screen/main.go
Outdated
@@ -23,21 +23,28 @@ import ( | |||
"github.com/cloudwego/netpoll" | |||
etcd "github.com/kitex-contrib/registry-etcd" | |||
|
|||
"github.com/west2-online/fzuhelper-server/pkg/base" |
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.
import 遵循规范
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.
svr.Run()
前注册退出函数,e.g.
server.RegisterShutdownHook(clientSet.Close)
@@ -19,18 +19,22 @@ package service | |||
import ( | |||
"context" | |||
|
|||
"github.com/west2-online/fzuhelper-server/pkg/utils" | |||
|
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.
遵循 import 规范
internal/launch_screen/pack/image.go
Outdated
"github.com/west2-online/fzuhelper-server/kitex_gen/model" | ||
model2 "github.com/west2-online/fzuhelper-server/pkg/db/model" |
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.
import 规范修正
@@ -20,25 +20,26 @@ import ( | |||
"fmt" | |||
"time" | |||
|
|||
"github.com/west2-online/fzuhelper-server/pkg/db/model" | |||
|
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.
import 规范修正
"github.com/west2-online/fzuhelper-server/pkg/cache" | ||
"github.com/west2-online/fzuhelper-server/pkg/db" | ||
"github.com/west2-online/fzuhelper-server/pkg/db/model" | ||
|
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.
import 规范修正
"github.com/west2-online/fzuhelper-server/pkg/db" | ||
"github.com/west2-online/fzuhelper-server/pkg/db/model" | ||
"github.com/west2-online/fzuhelper-server/pkg/utils" | ||
|
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.
import 规范修正
todo:use cache.go | ||
*/ | ||
|
||
func (c *CacheLaunchScreen) IsLaunchScreenCacheExist(ctx context.Context, key string) bool { |
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.
删掉这个玩意,已经有通用函数了
} | ||
|
||
func IsLastLaunchScreenIdCacheExist(ctx context.Context) bool { | ||
return RedisClient.Exists(ctx, constants.LastLaunchScreenIdKey).Val() == 1 | ||
func (c *CacheLaunchScreen) IsLastLaunchScreenIdCacheExist(ctx context.Context) bool { |
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.
这个删掉,用通用函数
@jiuxia211 @SchwarzSail 快来review然后合了 |
@@ -52,7 +60,7 @@ func (s *LaunchScreenServiceImpl) CreateImage(stream launch_screen.LaunchScreenS | |||
req.Image = bytes.Join([][]byte{req.Image, fileReq.Image}, []byte("")) | |||
} | |||
|
|||
pic, err := service.NewLaunchScreenService(stream.Context()).CreateImage(req) | |||
pic, err := service.NewLaunchScreenService(stream.Context(), s.ClientSet).CreateImage(req) |
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.
这边在注入依赖的时候是把 ClientSet 全部注入进去吗,还是注入 service 所需要的 client?
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.
我偏向于后者,需要你在 service 定义出你所需要的 client 吧(
@FantasyRL 修一下 ci,帮你解决冲突了,后面应该也由你自己来解决冲突,基本功了属于是 |
@jiuxia211 cc |
Signed-off-by: FanR <[email protected]>
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.
LGTM
refer to #71