1. 定义Detail接口

2. 实现ListPlans接口
This commit is contained in:
2025-09-10 13:41:24 +08:00
parent 2b4dd3e74d
commit 008677467b
4 changed files with 208 additions and 6 deletions

View File

@@ -0,0 +1,32 @@
package repository
import (
"git.huangwc.com/pig/pig-farm-controller/internal/model"
"gorm.io/gorm"
)
// FeedPlanRepo 饲喂管理接口
type FeedPlanRepo interface {
// ListAllPlanIntroduction 获取所有计划简介
ListAllPlanIntroduction() ([]model.FeedingPlan, error)
}
type feedPlanRepo struct {
db *gorm.DB
}
func NewFeedPlanRepo(db *gorm.DB) FeedPlanRepo {
return &feedPlanRepo{
db: db,
}
}
// ListAllPlanIntroduction 获取所有计划简介
func (f *feedPlanRepo) ListAllPlanIntroduction() ([]model.FeedingPlan, error) {
var plans []model.FeedingPlan
err := f.db.Model(&model.FeedingPlan{}).
Select("id, name, description, type, enabled, schedule_cron").
Find(&plans).Error
return plans, err
}