mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-11-28 15:37:45 +08:00
GitBot 功能: - 用户级 CRUD API (6 条路由) - Bot 共享功能 - 支持 GitHub/GitLab/Gitee/Gitea 四个平台 Webhook 功能: - 4 个平台 Webhook handler - HMAC-SHA256 签名验证 - Redis 防重入检查 GitTask 功能: - 定义 GitTaskUsecase 接口和 CreateGitTaskReq 类型 - Webhook handler 通过 GitTaskUsecase 创建任务 集成: - 整合到 biz/git/ 模块 - 通过 GitIdentity 动态获取 access_token - config.Task 添加 ImageID/Core/Memory 字段
61 lines
1.9 KiB
Go
61 lines
1.9 KiB
Go
package domain
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
|
|
"github.com/chaitin/MonkeyCode/backend/consts"
|
|
"github.com/chaitin/MonkeyCode/backend/db"
|
|
"github.com/chaitin/MonkeyCode/backend/pkg/taskflow"
|
|
)
|
|
|
|
// GitTaskUsecase GitTask 业务逻辑接口
|
|
type GitTaskUsecase interface {
|
|
Create(ctx context.Context, req CreateGitTaskReq) (*GitTask, error)
|
|
}
|
|
|
|
// GitTaskRepoInterface GitTask 数据访问接口
|
|
type GitTaskRepoInterface interface {
|
|
Create(ctx context.Context, req CreateGitTaskReq, fn func(user *db.User, t *db.Task, m *db.Model, i *db.Image) (*taskflow.VirtualMachine, error)) (*db.Task, error)
|
|
}
|
|
|
|
// CreateGitTaskReq 创建 GitTask 请求
|
|
type CreateGitTaskReq struct {
|
|
HostID string `json:"host_id"`
|
|
ImageID uuid.UUID `json:"image_id"`
|
|
Subject Subject `json:"subject"`
|
|
Repo Repo `json:"repo"`
|
|
User User `json:"user"`
|
|
Platform consts.GitPlatform `json:"platform"`
|
|
Body string `json:"body"`
|
|
Time time.Time `json:"time"`
|
|
Prompt string `json:"prompt"`
|
|
PromptID string `json:"prompt_id"`
|
|
GithubInstallationID int64 `json:"github_installation_id"`
|
|
Env map[string]string `json:"env"`
|
|
Git taskflow.Git `json:"git"`
|
|
Bot *GitBot `json:"-"`
|
|
}
|
|
|
|
// Subject 任务主题
|
|
type Subject struct {
|
|
ID string `json:"id"`
|
|
Type string `json:"type"`
|
|
Title string `json:"title"`
|
|
URL string `json:"url"`
|
|
Number int `json:"number"`
|
|
}
|
|
|
|
// Repo 仓库信息
|
|
type Repo struct {
|
|
ID string `json:"id"`
|
|
Name string `json:"name"`
|
|
FullName string `json:"fullname"`
|
|
URL string `json:"url"`
|
|
Desc string `json:"desc"`
|
|
Branch *string `json:"branch"`
|
|
IsPrivate bool `json:"is_private"`
|
|
}
|