1. 定义Detail接口
2. 实现ListPlans接口
This commit is contained in:
32
internal/storage/repository/feed.go
Normal file
32
internal/storage/repository/feed.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user