定义仓库层对象

This commit is contained in:
2025-11-07 22:26:16 +08:00
parent d3207cc2b8
commit a90b1cc012
3 changed files with 29 additions and 1 deletions

View File

@@ -0,0 +1,25 @@
package repository
import (
"context"
"gorm.io/gorm"
)
// AlarmRepository 定义了对告警模型的数据库操作接口
type AlarmRepository interface {
}
// gormAlarmRepository 是 AlarmRepository 的 GORM 实现。
type gormAlarmRepository struct {
ctx context.Context
db *gorm.DB
}
// NewGormAlarmRepository 创建一个新的 AlarmRepository GORM 实现实例。
func NewGormAlarmRepository(ctx context.Context, db *gorm.DB) AlarmRepository {
return &gormAlarmRepository{
ctx: ctx,
db: db,
}
}