Skip to content

Commit 9ffb46b

Browse files
committed
fix
1 parent 0587c46 commit 9ffb46b

File tree

4 files changed

+24
-23
lines changed

4 files changed

+24
-23
lines changed

backend/biz/git/usecase/gitbot.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ import (
1717

1818
// GitBotUsecase GitBot 业务逻辑
1919
type GitBotUsecase struct {
20-
cfg *config.Config
21-
repo domain.GitBotRepo
20+
cfg *config.Config
21+
repo domain.GitBotRepo
2222
logger *slog.Logger
2323
}
2424

@@ -40,9 +40,9 @@ func (u *GitBotUsecase) GetByID(ctx context.Context, id uuid.UUID) (*domain.GitB
4040
}
4141
return nil, err
4242
}
43-
return (&domain.GitBot{
43+
return cvt.From(bot, &domain.GitBot{
4444
WebhookURL: u.webhookURL(bot),
45-
}).From(bot), nil
45+
}), nil
4646
}
4747

4848
// GetInstallationID 获取 installation_id
@@ -78,9 +78,9 @@ func (u *GitBotUsecase) List(ctx context.Context, uid uuid.UUID) (*domain.ListGi
7878
}
7979
return &domain.ListGitBotResp{
8080
Bots: cvt.Iter(bots, func(_ int, bot *db.GitBot) *domain.GitBot {
81-
return (&domain.GitBot{
81+
return cvt.From(bot, &domain.GitBot{
8282
WebhookURL: u.webhookURL(bot),
83-
}).From(bot)
83+
})
8484
}),
8585
}, nil
8686
}
@@ -91,9 +91,9 @@ func (u *GitBotUsecase) Create(ctx context.Context, uid uuid.UUID, req domain.Cr
9191
if err != nil {
9292
return nil, err
9393
}
94-
return (&domain.GitBot{
94+
return cvt.From(bot, &domain.GitBot{
9595
WebhookURL: u.webhookURL(bot),
96-
}).From(bot), nil
96+
}), nil
9797
}
9898

9999
// Update 更新 GitBot
@@ -102,9 +102,9 @@ func (u *GitBotUsecase) Update(ctx context.Context, uid uuid.UUID, req domain.Up
102102
if err != nil {
103103
return nil, err
104104
}
105-
return (&domain.GitBot{
105+
return cvt.From(bot, &domain.GitBot{
106106
WebhookURL: u.webhookURL(bot),
107-
}).From(bot), nil
107+
}), nil
108108
}
109109

110110
// Delete 删除 GitBot
@@ -120,7 +120,7 @@ func (u *GitBotUsecase) ListTask(ctx context.Context, uid uuid.UUID, req domain.
120120
}
121121
return &domain.ListGitBotTaskResp{
122122
Tasks: cvt.Iter(tasks, func(_ int, t *db.GitBotTask) *domain.GitBotTask {
123-
return (&domain.GitBotTask{}).From(t)
123+
return cvt.From(t, &domain.GitBotTask{})
124124
}),
125125
Page: pageInfo.TotalCount,
126126
Size: int64(req.Size),

backend/biz/host/usecase/host.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ func (h *HostUsecase) vmSleepConsumer() {
242242
if err := h.taskflow.VirtualMachiner().Hibernate(ctx, &taskflow.HibernateVirtualMachineReq{
243243
HostID: vm.HostID,
244244
UserID: vm.UserID.String(),
245-
ID: vm.ID,
245+
ID: vm.EnvironmentID,
246246
}); err != nil {
247247
return fmt.Errorf("hibernate vm %s: %w", vm.ID, err)
248248
}

backend/biz/project/repo/project.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ func (r *ProjectRepo) Get(ctx context.Context, uid, id uuid.UUID) (*db.Project,
6262
WithIssues(func(piq *db.ProjectIssueQuery) {
6363
piq.WithUser()
6464
}).
65+
WithGitBots().
6566
First(ctx)
6667
}
6768

backend/domain/gitbot.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ func (g *GitBot) From(src *db.GitBot) *GitBot {
5959
g.Name = src.Name
6060
g.Token = src.Token
6161
g.SecretToken = src.SecretToken
62-
g.Host = g.Host.From(src.Edges.Host)
62+
g.Host = cvt.From(src.Edges.Host, &Host{})
6363
g.Users = cvt.Iter(src.Edges.Users, func(_ int, u *db.User) *User {
64-
return (&User{}).From(u)
64+
return cvt.From(u, &User{})
6565
})
6666
g.CreatedAt = src.CreatedAt.Unix()
6767
return g
@@ -97,9 +97,9 @@ type ListGitBotResp struct {
9797

9898
// ListGitBotTaskReq Git Bot 任务列表请求
9999
type ListGitBotTaskReq struct {
100-
ID uuid.UUID `json:"id" query:"id" validate:"omitempty"`
101-
Page int `json:"page" query:"page"`
102-
Size int `json:"size" query:"size"`
100+
ID uuid.UUID `json:"id" query:"id" validate:"omitempty"`
101+
Page int `json:"page" query:"page"`
102+
Size int `json:"size" query:"size"`
103103
}
104104

105105
// ListGitBotTaskResp Git Bot 任务列表响应
@@ -112,12 +112,12 @@ type ListGitBotTaskResp struct {
112112

113113
// GitBotTask Git Bot 任务实体
114114
type GitBotTask struct {
115-
ID uuid.UUID `json:"id"`
116-
PullRequest PullRequest `json:"pull_request"`
117-
Repo GitRepository `json:"repo"`
115+
ID uuid.UUID `json:"id"`
116+
PullRequest PullRequest `json:"pull_request"`
117+
Repo GitRepository `json:"repo"`
118118
Status consts.TaskStatus `json:"status"`
119-
Bot *GitBot `json:"bot"`
120-
CreatedAt int64 `json:"created_at"`
119+
Bot *GitBot `json:"bot"`
120+
CreatedAt int64 `json:"created_at"`
121121
}
122122

123123
// From 从 ent 实体转换
@@ -128,7 +128,7 @@ func (g *GitBotTask) From(src *db.GitBotTask) *GitBotTask {
128128
g.ID = src.ID
129129
g.CreatedAt = src.CreatedAt.Unix()
130130
if bot := src.Edges.GitBot; bot != nil {
131-
g.Bot = (&GitBot{}).From(bot)
131+
g.Bot = cvt.From(bot, &GitBot{})
132132
}
133133
if task := src.Edges.Task; task != nil {
134134
g.Status = task.Status

0 commit comments

Comments
 (0)