27 lines
		
	
	
		
			863 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			27 lines
		
	
	
		
			863 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package repository
 | |
| 
 | |
| import (
 | |
| 	"git.huangwc.com/pig/pig-farm-controller/internal/infra/models"
 | |
| 	"gorm.io/gorm"
 | |
| )
 | |
| 
 | |
| // MedicationLogRepository 定义了与群体用药日志模型相关的数据库操作接口。
 | |
| type MedicationLogRepository interface {
 | |
| 	CreateMedicationLog(log *models.MedicationLog) error
 | |
| }
 | |
| 
 | |
| // gormMedicationLogRepository 是 MedicationLogRepository 接口的 GORM 实现。
 | |
| type gormMedicationLogRepository struct {
 | |
| 	db *gorm.DB
 | |
| }
 | |
| 
 | |
| // NewGormMedicationLogRepository 创建一个新的 MedicationLogRepository GORM 实现实例。
 | |
| func NewGormMedicationLogRepository(db *gorm.DB) MedicationLogRepository {
 | |
| 	return &gormMedicationLogRepository{db: db}
 | |
| }
 | |
| 
 | |
| // CreateMedicationLog 创建一条新的群体用药日志记录
 | |
| func (r *gormMedicationLogRepository) CreateMedicationLog(log *models.MedicationLog) error {
 | |
| 	return r.db.Create(log).Error
 | |
| }
 |