定义仓库层对象
This commit is contained in:
@@ -127,3 +127,4 @@
|
||||
|
||||
1. 定义告警表和告警历史表
|
||||
2. 重构部分枚举, 让models包不依赖其他项目中的包
|
||||
3. 创建仓库层对象(不包含方法)
|
||||
@@ -86,6 +86,7 @@ type Repositories struct {
|
||||
medicationLogRepo repository.MedicationLogRepository
|
||||
rawMaterialRepo repository.RawMaterialRepository
|
||||
notificationRepo repository.NotificationRepository
|
||||
alarmRepo repository.AlarmRepository
|
||||
unitOfWork repository.UnitOfWork
|
||||
}
|
||||
|
||||
@@ -114,6 +115,7 @@ func initRepositories(ctx context.Context, db *gorm.DB) *Repositories {
|
||||
medicationLogRepo: repository.NewGormMedicationLogRepository(logs.AddCompName(baseCtx, "MedicationLogRepo"), db),
|
||||
rawMaterialRepo: repository.NewGormRawMaterialRepository(logs.AddCompName(baseCtx, "RawMaterialRepo"), db),
|
||||
notificationRepo: repository.NewGormNotificationRepository(logs.AddCompName(baseCtx, "NotificationRepo"), db),
|
||||
alarmRepo: repository.NewGormAlarmRepository(logs.AddCompName(baseCtx, "AlarmRepo"), db),
|
||||
unitOfWork: repository.NewGormUnitOfWork(logs.AddCompName(baseCtx, "UnitOfWork"), db),
|
||||
}
|
||||
}
|
||||
|
||||
25
internal/infra/repository/alarm_repository.go
Normal file
25
internal/infra/repository/alarm_repository.go
Normal 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,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user