dao

package
v1.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 17, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindByID

func FindByID[T any](db *gorm.DB, id uint) (*T, error)

FindByID 根据 ID 查找记录

func FindByKey

func FindByKey[T any](db *gorm.DB, key string) (*T, error)

FindByKey 根据 key 字段查找记录

func Paginate

func Paginate[T any](db *gorm.DB, page Pagination, dest *[]*T) (int64, error)

Paginate 执行分页查询

Types

type OperationLogDAO

type OperationLogDAO struct {
	// contains filtered or unexported fields
}

func NewOperationLogDAO

func NewOperationLogDAO(db *gorm.DB) *OperationLogDAO

func (*OperationLogDAO) CountAll

func (d *OperationLogDAO) CountAll() (int64, error)

CountAll 统计全部审计日志数。

func (*OperationLogDAO) CountSince

func (d *OperationLogDAO) CountSince(t time.Time) (int64, error)

CountSince 统计 created_at >= t 的记录数。

func (*OperationLogDAO) Create

func (d *OperationLogDAO) Create(log *model.OperationLog) error

Create 写入一条审计日志。

func (*OperationLogDAO) List

List 按过滤条件分页查询审计日志,返回列表与总数。

type OperationLogFilter

type OperationLogFilter struct {
	Search    string // LIKE resource / detail
	Action    string // 精确匹配
	Actor     string // 精确匹配
	StartDate string // YYYY-MM-DD(含,按 created_at 起算)
	EndDate   string // YYYY-MM-DD(含,按 created_at 止算)
}

OperationLogFilter 审计日志过滤条件。

type Pagination

type Pagination struct {
	Offset int
	Limit  int
}

func DefaultPagination

func DefaultPagination(offset, limit int) Pagination

type PlatformDAO

type PlatformDAO struct {
	// contains filtered or unexported fields
}

PlatformDAO 平台数据访问对象。 AccessToken 与 repo_dao 一致采用加密存储:写入加密、读取解密; 读取解密失败视为存量明文,原样返回(下次写入时自动转为密文)。

func NewPlatformDAO

func NewPlatformDAO(db *gorm.DB) (*PlatformDAO, error)

NewPlatformDAO 创建 PlatformDAO

func (*PlatformDAO) Count

func (d *PlatformDAO) Count() (int64, error)

Count 统计平台数量

func (*PlatformDAO) Create

func (d *PlatformDAO) Create(platform *model.Platform) error

Create 创建平台

func (*PlatformDAO) Delete

func (d *PlatformDAO) Delete(key string) error

Delete 删除平台(软删除)

func (*PlatformDAO) FindAll

func (d *PlatformDAO) FindAll() ([]*model.Platform, error)

FindAll 查找所有平台

func (*PlatformDAO) FindByID

func (d *PlatformDAO) FindByID(id uint) (*model.Platform, error)

FindByID 根据 ID 查找平台

func (*PlatformDAO) FindByKey

func (d *PlatformDAO) FindByKey(key string) (*model.Platform, error)

FindByKey 根据 Key 查找平台

func (*PlatformDAO) FindByType

func (d *PlatformDAO) FindByType(platformType string) ([]*model.Platform, error)

FindByType 根据类型查找平台

func (*PlatformDAO) FindDefault

func (d *PlatformDAO) FindDefault() (*model.Platform, error)

FindDefault 查找默认平台

func (*PlatformDAO) SetDefault

func (d *PlatformDAO) SetDefault(key string) error

SetDefault 设置默认平台

func (*PlatformDAO) Update

func (d *PlatformDAO) Update(platform *model.Platform) error

Update 更新平台

func (*PlatformDAO) UpdateFields

func (d *PlatformDAO) UpdateFields(key string, fields map[string]interface{}) error

UpdateFields 更新平台指定字段 注意:字段值原样写入;如需更新 access_token 请走 Update 以确保加密。

func (*PlatformDAO) UpdateRepoCount

func (d *PlatformDAO) UpdateRepoCount(platformID uint) error

UpdateRepoCount 更新平台关联的仓库数量

func (*PlatformDAO) UpdateStatus

func (d *PlatformDAO) UpdateStatus(key, status, testResult string) error

UpdateStatus 更新平台状态

type RepoDAO

type RepoDAO struct {
	// contains filtered or unexported fields
}

func NewRepoDAO

func NewRepoDAO(db *gorm.DB) (*RepoDAO, error)

func (*RepoDAO) Count added in v1.5.5

func (d *RepoDAO) Count() (int64, error)

Count 返回仓库总数(走 COUNT 聚合,不加载行)。

func (*RepoDAO) Create

func (d *RepoDAO) Create(repo *model.Repo) error

func (*RepoDAO) Delete

func (d *RepoDAO) Delete(key string) error

func (*RepoDAO) FindAll

func (d *RepoDAO) FindAll(page Pagination) ([]*model.Repo, int64, error)

func (*RepoDAO) FindByCloneURL

func (d *RepoDAO) FindByCloneURL(cloneURL string) (*model.Repo, error)

FindByCloneURL 根据 Clone URL 查找仓库

func (*RepoDAO) FindByKey

func (d *RepoDAO) FindByKey(key string) (*model.Repo, error)

func (*RepoDAO) FindByPlatformID

func (d *RepoDAO) FindByPlatformID(platformID uint) ([]*model.Repo, error)

FindByPlatformID 根据平台 ID 查找仓库

func (*RepoDAO) ListWithFilter

func (d *RepoDAO) ListWithFilter(page Pagination, filter *RepoFilter) ([]*model.Repo, int64, error)

ListWithFilter returns a filtered, sorted, paginated list of repos and the total count.

func (*RepoDAO) Update

func (d *RepoDAO) Update(repo *model.Repo) error

type RepoFilter

type RepoFilter struct {
	Search   string // search by name or clone_url (LIKE)
	Platform string // exact match on platform
	Status   string // exact match on status
	SortBy   string // column to sort by (default: created_at)
	OrderBy  string // sort direction: asc or desc (default: desc)
}

RepoFilter contains optional filters for listing repositories.

type SyncRunDAO

type SyncRunDAO struct {
	// contains filtered or unexported fields
}

func NewSyncRunDAO

func NewSyncRunDAO(db *gorm.DB) *SyncRunDAO

func (*SyncRunDAO) CleanupOlderThan

func (d *SyncRunDAO) CleanupOlderThan(olderThan time.Duration) (int64, error)

func (*SyncRunDAO) CountByTaskKey

func (d *SyncRunDAO) CountByTaskKey(taskKey string) (int64, error)

func (*SyncRunDAO) Create

func (d *SyncRunDAO) Create(run *model.SyncRun) error

func (*SyncRunDAO) Delete

func (d *SyncRunDAO) Delete(id uint) error

func (*SyncRunDAO) FindByTaskKey

func (d *SyncRunDAO) FindByTaskKey(taskKey string, page Pagination) ([]*model.SyncRun, int64, error)

func (*SyncRunDAO) FindRecent

func (d *SyncRunDAO) FindRecent(page Pagination) ([]*model.SyncRun, error)

func (*SyncRunDAO) Update

func (d *SyncRunDAO) Update(run *model.SyncRun) error

type SyncRunStepDAO

type SyncRunStepDAO struct {
	// contains filtered or unexported fields
}

func NewSyncRunStepDAO

func NewSyncRunStepDAO(db *gorm.DB) *SyncRunStepDAO

func (*SyncRunStepDAO) CleanupOlderThan

func (d *SyncRunStepDAO) CleanupOlderThan(olderThan time.Duration) (int64, error)

func (*SyncRunStepDAO) Create

func (d *SyncRunStepDAO) Create(step *model.SyncRunStep) error

func (*SyncRunStepDAO) FindByRunID

func (d *SyncRunStepDAO) FindByRunID(runID uint) ([]*model.SyncRunStep, error)

func (*SyncRunStepDAO) Update

func (d *SyncRunStepDAO) Update(step *model.SyncRunStep) error

type SyncTaskDAO

type SyncTaskDAO struct {
	// contains filtered or unexported fields
}

func NewSyncTaskDAO

func NewSyncTaskDAO(db *gorm.DB) *SyncTaskDAO

func (*SyncTaskDAO) CountByStatus added in v1.5.5

func (d *SyncTaskDAO) CountByStatus() (map[string]int64, error)

CountByStatus 按_last_status 聚合计数,返回 map[status]count; 总数放在 "total" 键。用于面板计数,避免全表加载进内存。

func (*SyncTaskDAO) Create

func (d *SyncTaskDAO) Create(task *model.SyncTask) error

func (*SyncTaskDAO) Delete

func (d *SyncTaskDAO) Delete(key string) error

func (*SyncTaskDAO) FindAll

func (d *SyncTaskDAO) FindAll(page Pagination) ([]*model.SyncTask, int64, error)

func (*SyncTaskDAO) FindAllEnabled

func (d *SyncTaskDAO) FindAllEnabled() ([]*model.SyncTask, error)

func (*SyncTaskDAO) FindByKey

func (d *SyncTaskDAO) FindByKey(key string) (*model.SyncTask, error)

func (*SyncTaskDAO) FindByRepoKey

func (d *SyncTaskDAO) FindByRepoKey(repoKey string, page Pagination) ([]*model.SyncTask, int64, error)

func (*SyncTaskDAO) Update

func (d *SyncTaskDAO) Update(task *model.SyncTask) error

type WebhookEventDAO

type WebhookEventDAO struct {
	// contains filtered or unexported fields
}

func NewWebhookEventDAO

func NewWebhookEventDAO(db *gorm.DB) *WebhookEventDAO

func (*WebhookEventDAO) CleanupOlderThan

func (d *WebhookEventDAO) CleanupOlderThan(olderThan time.Duration) (int64, error)

func (*WebhookEventDAO) CountByRepoKey

func (d *WebhookEventDAO) CountByRepoKey(repoKey string) (int64, error)

func (*WebhookEventDAO) Create

func (d *WebhookEventDAO) Create(event *model.WebhookEvent) error

func (*WebhookEventDAO) FindByEventID

func (d *WebhookEventDAO) FindByEventID(eventID string) (*model.WebhookEvent, error)

func (*WebhookEventDAO) FindByID

func (d *WebhookEventDAO) FindByID(id uint) (*model.WebhookEvent, error)

func (*WebhookEventDAO) FindByRepoKey

func (d *WebhookEventDAO) FindByRepoKey(repoKey string, page Pagination) ([]*model.WebhookEvent, int64, error)

func (*WebhookEventDAO) FindRecent

func (d *WebhookEventDAO) FindRecent(repoKey string, page Pagination) ([]*model.WebhookEvent, error)

func (*WebhookEventDAO) Update

func (d *WebhookEventDAO) Update(event *model.WebhookEvent) error

type WebhookRuleDAO

type WebhookRuleDAO struct {
	// contains filtered or unexported fields
}

func NewWebhookRuleDAO

func NewWebhookRuleDAO(db *gorm.DB) *WebhookRuleDAO

func (*WebhookRuleDAO) Create

func (d *WebhookRuleDAO) Create(rule *model.WebhookRule) error

func (*WebhookRuleDAO) Delete

func (d *WebhookRuleDAO) Delete(id uint) error

func (*WebhookRuleDAO) FindByID

func (d *WebhookRuleDAO) FindByID(id uint) (*model.WebhookRule, error)

func (*WebhookRuleDAO) FindByRepoKey

func (d *WebhookRuleDAO) FindByRepoKey(repoKey string) ([]*model.WebhookRule, error)

func (*WebhookRuleDAO) FindTasksByRuleID

func (d *WebhookRuleDAO) FindTasksByRuleID(ruleID uint) ([]model.WebhookRuleTask, error)

func (*WebhookRuleDAO) Update

func (d *WebhookRuleDAO) Update(rule *model.WebhookRule) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL