1.注册饲喂计划相关路由
2. 实现create接口
This commit is contained in:
@@ -69,7 +69,16 @@ type API struct {
|
||||
|
||||
// NewAPI 创建并返回一个新的API实例
|
||||
// 初始化Gin引擎和相关配置
|
||||
func NewAPI(cfg *config.Config, userRepo repository.UserRepo, operationHistoryRepo repository.OperationHistoryRepo, deviceControlRepo repository.DeviceControlRepo, deviceRepo repository.DeviceRepo, websocketManager *websocket.Manager, heartbeatService *service.HeartbeatService, deviceStatusPool *service.DeviceStatusPool) *API {
|
||||
func NewAPI(cfg *config.Config,
|
||||
userRepo repository.UserRepo,
|
||||
operationHistoryRepo repository.OperationHistoryRepo,
|
||||
deviceControlRepo repository.DeviceControlRepo,
|
||||
deviceRepo repository.DeviceRepo,
|
||||
feedRepo repository.FeedPlanRepo,
|
||||
websocketManager *websocket.Manager,
|
||||
heartbeatService *service.HeartbeatService,
|
||||
deviceStatusPool *service.DeviceStatusPool,
|
||||
) *API {
|
||||
// 设置Gin为发布模式
|
||||
gin.SetMode(gin.DebugMode)
|
||||
|
||||
@@ -103,7 +112,7 @@ func NewAPI(cfg *config.Config, userRepo repository.UserRepo, operationHistoryRe
|
||||
deviceController := device.NewController(deviceControlRepo, deviceRepo, websocketManager, heartbeatService, deviceStatusPool)
|
||||
|
||||
// 创建饲喂管理控制器
|
||||
feedController := feed.NewController()
|
||||
feedController := feed.NewController(feedRepo)
|
||||
|
||||
// 创建远程控制控制器
|
||||
remoteController := remote.NewController(websocketManager)
|
||||
@@ -235,6 +244,9 @@ func (a *API) setupRoutes() {
|
||||
{
|
||||
feedGroup.GET("/plan/list", a.feedController.ListPlans)
|
||||
feedGroup.GET("/plan/detail", a.feedController.Detail)
|
||||
feedGroup.POST("/plan/create", a.feedController.Create)
|
||||
feedGroup.POST("/plan/update", a.feedController.Update)
|
||||
feedGroup.POST("/plan/delete", a.feedController.Delete)
|
||||
}
|
||||
|
||||
// 远程控制相关路由
|
||||
|
||||
Reference in New Issue
Block a user