models

package
v0.26.17 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DropDB

func DropDB() error

DropDB 中文函数注释:删除webhook插件相关的表及数据。

func InitDB

func InitDB() error

InitDB 中文函数注释:初始化数据库表(GORM自动迁移)。

func UpgradeDB

func UpgradeDB(fromVersion string, toVersion string) error

UpgradeDB 中文函数注释:升级webhook插件数据库结构与数据。

Types

type WebhookLogRecord

type WebhookLogRecord struct {
	ID           uint      `gorm:"primaryKey;autoIncrement" json:"id,omitempty"`
	WebhookID    uint      `gorm:"index:idx_webhook_log_webhook_id" json:"webhook_id,omitempty"`     // webhook接收器ID
	WebhookName  string    `gorm:"size:255" json:"webhook_name,omitempty"`                           // webhook名称
	ReceiverID   string    `gorm:"size:64" json:"receiver_id,omitempty"`                             // 接收器ID
	Method       string    `gorm:"size:16" json:"method,omitempty"`                                  // HTTP方法
	URL          string    `gorm:"type:text" json:"url,omitempty"`                                   // 请求URL
	StatusCode   int       `json:"status_code,omitempty"`                                            // 响应状态码
	Success      bool      `gorm:"index:idx_webhook_log_success" json:"success,omitempty"`           // 是否成功
	Duration     int64     `json:"duration,omitempty"`                                               // 请求耗时(纳秒)
	ErrorMessage string    `gorm:"type:text" json:"error_message,omitempty"`                         // 错误信息
	Summary      string    `gorm:"type:text" json:"summary,omitempty"`                               // 日志摘要
	Detail       string    `gorm:"type:text" json:"detail,omitempty"`                                // 完整日志详情(JSON格式)
	RequestTime  time.Time `gorm:"index:idx_webhook_log_request_time" json:"request_time,omitempty"` // 请求时间
	CreatedAt    time.Time `json:"created_at,omitempty" gorm:"<-:create"`                            // 创建时间
	UpdatedAt    time.Time `json:"updated_at,omitempty"`                                             // 更新时间
}

WebhookLogRecord webhook发送日志记录

func (*WebhookLogRecord) Delete

func (w *WebhookLogRecord) Delete(params *dao.Params, ids string, queryFuncs ...func(*gorm.DB) *gorm.DB) error

Delete 删除webhook日志

func (*WebhookLogRecord) GetOne

func (w *WebhookLogRecord) GetOne(params *dao.Params, queryFuncs ...func(*gorm.DB) *gorm.DB) (*WebhookLogRecord, error)

GetOne 获取单个webhook日志

func (*WebhookLogRecord) GetStatistics

func (w *WebhookLogRecord) GetStatistics(webhookID uint, startTime, endTime time.Time) (map[string]interface{}, error)

GetStatistics 获取webhook发送统计信息

func (*WebhookLogRecord) List

func (w *WebhookLogRecord) List(params *dao.Params, queryFuncs ...func(*gorm.DB) *gorm.DB) ([]*WebhookLogRecord, int64, error)

List 查询webhook日志列表

func (*WebhookLogRecord) ListBySuccess

func (w *WebhookLogRecord) ListBySuccess(success bool, params *dao.Params) ([]*WebhookLogRecord, int64, error)

ListBySuccess 根据成功状态查询日志

func (*WebhookLogRecord) ListByTimeRange

func (w *WebhookLogRecord) ListByTimeRange(startTime, endTime time.Time, params *dao.Params) ([]*WebhookLogRecord, int64, error)

ListByTimeRange 根据时间范围查询日志

func (*WebhookLogRecord) ListByWebhookID

func (w *WebhookLogRecord) ListByWebhookID(webhookID uint, params *dao.Params) ([]*WebhookLogRecord, int64, error)

ListByWebhookID 根据webhook ID查询日志

func (*WebhookLogRecord) Save

func (w *WebhookLogRecord) Save(params *dao.Params, queryFuncs ...func(*gorm.DB) *gorm.DB) error

Save 保存webhook日志

type WebhookReceiver

type WebhookReceiver struct {
	ID           uint      `gorm:"primaryKey;autoIncrement" json:"id,omitempty"`
	Name         string    `gorm:"size:255;uniqueIndex:idx_webhook_receiver_name" json:"name,omitempty"` // webhook名称
	Platform     string    `gorm:"size:50" json:"platform,omitempty"`                                    // feishu,dingtalk
	TargetURL    string    `gorm:"size:255" json:"target_url,omitempty"`
	BodyTemplate string    `gorm:"type:text" json:"body_template,omitempty"` // 发送到webhook的body模板
	SignSecret   string    `gorm:"size:255" json:"sign_secret,omitempty"`
	CreatedAt    time.Time `json:"created_at,omitempty" gorm:"<-:create"`
	UpdatedAt    time.Time `json:"updated_at,omitempty"` // Automatically managed by GORM for update time
}

func (*WebhookReceiver) Delete

func (c *WebhookReceiver) Delete(params *dao.Params, ids string, queryFuncs ...func(*gorm.DB) *gorm.DB) error

func (*WebhookReceiver) GetNamesByIds

func (c *WebhookReceiver) GetNamesByIds(ids []string) ([]string, error)

GetNamesByIds 根据webhook ID列表获取对应的名称列表

func (*WebhookReceiver) GetOne

func (c *WebhookReceiver) GetOne(params *dao.Params, queryFuncs ...func(*gorm.DB) *gorm.DB) (*WebhookReceiver, error)

func (*WebhookReceiver) GetReceiversByIds

func (c *WebhookReceiver) GetReceiversByIds(ids []string) ([]*WebhookReceiver, error)

GetReceiversByIds 根据逗号分隔的ID字符串查询webhook接收器列表 参数:ids - 逗号分隔的webhook ID字符串,例如 "1,2,3" 返回:webhook接收器列表和错误信息 如果ids为空,返回空列表

func (*WebhookReceiver) List

func (c *WebhookReceiver) List(params *dao.Params, queryFuncs ...func(*gorm.DB) *gorm.DB) ([]*WebhookReceiver, int64, error)

func (*WebhookReceiver) Save

func (c *WebhookReceiver) Save(params *dao.Params, queryFuncs ...func(*gorm.DB) *gorm.DB) error

Jump to

Keyboard shortcuts

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