service

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2026 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Audit = &AuditService{}
View Source
var LogCleaner = &LogCleanerService{}
View Source
var Notification = &NotificationService{}

Functions

func InitAlertChecker added in v0.7.0

func InitAlertChecker(db *gorm.DB, interval time.Duration)

func SendAlertToChannels added in v0.7.0

func SendAlertToChannels(rule *models.AlertRule, value float64, message string)

func StopAlertChecker added in v0.7.0

func StopAlertChecker()

Types

type AlertChecker added in v0.7.0

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

func (*AlertChecker) Run added in v0.7.0

func (a *AlertChecker) Run()

type AppConfig

type AppConfig struct{}

func (*AppConfig) CreateOrUpdate

func (e *AppConfig) CreateOrUpdate(ctx *gin.Context, group string, data map[string]any) error

func (*AppConfig) Group

func (e *AppConfig) Group(ctx *gin.Context, group string) (map[string]any, error)

func (*AppConfig) Profile

func (e *AppConfig) Profile(ctx *gin.Context, auth bool) (map[string]gin.H, error)

type AuditService added in v0.7.0

type AuditService struct{}

func (*AuditService) CleanOldLogs added in v0.7.0

func (s *AuditService) CleanOldLogs(db *gorm.DB, days int) error

func (*AuditService) GetAuditLogs added in v0.7.0

func (s *AuditService) GetAuditLogs(db *gorm.DB, userID string, logType models.AuditLogType, page, pageSize int) ([]*models.AuditLog, int64, error)

func (*AuditService) GetLoginLogs added in v0.7.0

func (s *AuditService) GetLoginLogs(db *gorm.DB, userID string, page, pageSize int) ([]*models.LoginLog, int64, error)

func (*AuditService) Log added in v0.7.0

func (s *AuditService) Log(db *gorm.DB, log *models.AuditLog) error

func (*AuditService) LogLogin added in v0.7.0

func (s *AuditService) LogLogin(db *gorm.DB, userID, username, ip, userAgent, message string, success bool) error

func (*AuditService) LogLogout added in v0.7.0

func (s *AuditService) LogLogout(db *gorm.DB, userID string) error

func (*AuditService) LogWithContext added in v0.7.0

func (s *AuditService) LogWithContext(db *gorm.DB, logType string, userID, username, action, resource, method, path, ip, userAgent string, status enum.Status, message string, duration int64) error

type DingTalkChannel added in v0.7.0

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

func (*DingTalkChannel) Name added in v0.7.0

func (c *DingTalkChannel) Name() string

func (*DingTalkChannel) Send added in v0.7.0

func (c *DingTalkChannel) Send(rule *models.AlertRule, value float64, message string) error

type EmailChannel added in v0.7.0

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

func (*EmailChannel) Name added in v0.7.0

func (c *EmailChannel) Name() string

func (*EmailChannel) Send added in v0.7.0

func (c *EmailChannel) Send(rule *models.AlertRule, value float64, message string) error

type LogCleanerService added in v0.7.0

type LogCleanerService struct{}

func (*LogCleanerService) CleanOldLogs added in v0.7.0

func (s *LogCleanerService) CleanOldLogs(db *gorm.DB, retentionDays int) error

func (*LogCleanerService) CleanOldRuntimeLogs added in v0.7.0

func (s *LogCleanerService) CleanOldRuntimeLogs(logDir string, retentionDays int) error

type LogFileInfo added in v0.7.0

type LogFileInfo struct {
	Path    string
	ModTime time.Time
}

type Monitor

type Monitor struct{}

func (*Monitor) Monitor

func (e *Monitor) Monitor(ctx *gin.Context) (*dto.MonitorResponse, error)

type NotificationChannel added in v0.7.0

type NotificationChannel interface {
	Send(rule *models.AlertRule, value float64, message string) error
	Name() string
}

func GetEnabledChannels added in v0.7.0

func GetEnabledChannels() []NotificationChannel

type NotificationService added in v0.7.0

type NotificationService struct{}

func (*NotificationService) Broadcast added in v0.7.0

func (s *NotificationService) Broadcast(notice *models.Notice)

func (*NotificationService) GetOnlineInfo added in v0.7.0

func (s *NotificationService) GetOnlineInfo() map[string]interface{}

func (*NotificationService) IsUserOnline added in v0.7.0

func (s *NotificationService) IsUserOnline(userID string) bool

func (*NotificationService) KickUser added in v0.7.0

func (s *NotificationService) KickUser(userID string, reason string)

func (*NotificationService) SendToUser added in v0.7.0

func (s *NotificationService) SendToUser(userID string, notice *models.Notice) bool

type Option added in v0.7.0

type Option struct{}

func NewOption added in v0.7.0

func NewOption() *Option

func (*Option) GetOption added in v0.7.0

func (e *Option) GetOption(ctx context.Context, category, name string) (*models.Option, error)

func (*Option) GetOptions added in v0.7.0

func (e *Option) GetOptions(ctx context.Context, queries []struct{ Category, Name string }) ([]*models.Option, error)

func (*Option) InvalidateCache added in v0.7.0

func (e *Option) InvalidateCache(ctx context.Context, category, name string) error

func (*Option) UpdateOption added in v0.7.0

func (e *Option) UpdateOption(ctx context.Context, id string, items *models.OptionItems, changedBy, changeNote string) error

type Statistics

type Statistics struct{}

func (*Statistics) Get

type Storage

type Storage struct{}

func (*Storage) Upload

func (s *Storage) Upload(c *gin.Context, f *multipart.FileHeader, userID string) (*UploadResult, error)

type UploadResult added in v0.7.0

type UploadResult struct {
	URL      string `json:"url"`
	Filename string `json:"filename"`
	Size     int64  `json:"size"`
	MimeType string `json:"mimeType"`
}

type UserConfig

type UserConfig struct{}

func (*UserConfig) CreateOrUpdate

func (e *UserConfig) CreateOrUpdate(ctx *gin.Context, userID, group string, data map[string]any) error

func (*UserConfig) Group

func (e *UserConfig) Group(ctx *gin.Context, userID, group string) (map[string]string, error)

func (*UserConfig) Profile

func (e *UserConfig) Profile(ctx *gin.Context, userID string) (map[string]gin.H, error)

type WeChatChannel added in v0.7.0

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

func (*WeChatChannel) Name added in v0.7.0

func (c *WeChatChannel) Name() string

func (*WeChatChannel) Send added in v0.7.0

func (c *WeChatChannel) Send(rule *models.AlertRule, value float64, message string) error