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 }