ManualControl
This commit is contained in:
@@ -24,6 +24,7 @@ import (
|
||||
"git.huangwc.com/pig/pig-farm-controller/internal/app/service"
|
||||
"git.huangwc.com/pig/pig-farm-controller/internal/app/webhook"
|
||||
"git.huangwc.com/pig/pig-farm-controller/internal/domain/audit"
|
||||
domain_device "git.huangwc.com/pig/pig-farm-controller/internal/domain/device"
|
||||
"git.huangwc.com/pig/pig-farm-controller/internal/domain/task"
|
||||
"git.huangwc.com/pig/pig-farm-controller/internal/domain/token"
|
||||
"git.huangwc.com/pig/pig-farm-controller/internal/infra/config"
|
||||
@@ -60,13 +61,14 @@ func NewAPI(cfg config.ServerConfig,
|
||||
userRepo repository.UserRepository,
|
||||
deviceRepository repository.DeviceRepository,
|
||||
areaControllerRepository repository.AreaControllerRepository,
|
||||
deviceTemplateRepository repository.DeviceTemplateRepository, // 添加设备模板仓库
|
||||
deviceTemplateRepository repository.DeviceTemplateRepository,
|
||||
planRepository repository.PlanRepository,
|
||||
pigFarmService service.PigFarmService,
|
||||
pigBatchService service.PigBatchService, // 添加猪群服务
|
||||
pigBatchService service.PigBatchService,
|
||||
userActionLogRepository repository.UserActionLogRepository,
|
||||
tokenService token.TokenService,
|
||||
auditService audit.Service, // 注入审计服务
|
||||
auditService audit.Service,
|
||||
deviceService domain_device.Service,
|
||||
listenHandler webhook.ListenHandler,
|
||||
analysisTaskManager *task.AnalysisPlanTaskManager) *API {
|
||||
// 设置 Gin 模式,例如 gin.ReleaseMode (生产模式) 或 gin.DebugMode (开发模式)
|
||||
@@ -93,7 +95,7 @@ func NewAPI(cfg config.ServerConfig,
|
||||
// 在 NewAPI 中初始化用户控制器,并将其作为 API 结构体的成员
|
||||
userController: user.NewController(userRepo, userActionLogRepository, logger, tokenService),
|
||||
// 在 NewAPI 中初始化设备控制器,并将其作为 API 结构体的成员
|
||||
deviceController: device.NewController(deviceRepository, areaControllerRepository, deviceTemplateRepository, logger),
|
||||
deviceController: device.NewController(deviceRepository, areaControllerRepository, deviceTemplateRepository, deviceService, logger),
|
||||
// 在 NewAPI 中初始化计划控制器,并将其作为 API 结构体的成员
|
||||
planController: plan.NewController(logger, planRepository, analysisTaskManager),
|
||||
// 在 NewAPI 中初始化猪场管理控制器
|
||||
@@ -160,11 +162,12 @@ func (a *API) setupRoutes() {
|
||||
// 设备相关路由组
|
||||
deviceGroup := authGroup.Group("/devices")
|
||||
{
|
||||
deviceGroup.POST("", a.deviceController.CreateDevice) // 创建设备
|
||||
deviceGroup.GET("", a.deviceController.ListDevices) // 获取设备列表
|
||||
deviceGroup.GET("/:id", a.deviceController.GetDevice) // 获取单个设备
|
||||
deviceGroup.PUT("/:id", a.deviceController.UpdateDevice) // 更新设备
|
||||
deviceGroup.DELETE("/:id", a.deviceController.DeleteDevice) // 删除设备
|
||||
deviceGroup.POST("", a.deviceController.CreateDevice) // 创建设备
|
||||
deviceGroup.GET("", a.deviceController.ListDevices) // 获取设备列表
|
||||
deviceGroup.GET("/:id", a.deviceController.GetDevice) // 获取单个设备
|
||||
deviceGroup.PUT("/:id", a.deviceController.UpdateDevice) // 更新设备
|
||||
deviceGroup.DELETE("/:id", a.deviceController.DeleteDevice) // 删除设备
|
||||
deviceGroup.POST("/manual-control/:id", a.deviceController.ManualControl) // 手动控制设备
|
||||
}
|
||||
a.logger.Info("设备相关接口注册成功 (需要认证和审计)")
|
||||
|
||||
@@ -236,7 +239,7 @@ func (a *API) setupRoutes() {
|
||||
pigBatchGroup.DELETE("/:id", a.pigBatchController.DeletePigBatch) // 删除猪群
|
||||
pigBatchGroup.POST("/assign-pens/:id", a.pigBatchController.AssignEmptyPensToBatch) // 为猪群分配空栏
|
||||
pigBatchGroup.POST("/reclassify-pen/:fromBatchID", a.pigBatchController.ReclassifyPenToNewBatch) // 将猪栏划拨到新群
|
||||
pigBatchGroup.DELETE("/remove-pen/:penID/:batchID", a.pigBatchController.RemoveEmptyPenFromBatch) // 从猪群移除空栏
|
||||
penGroup.DELETE("/remove-pen/:penID/:batchID", a.pigBatchController.RemoveEmptyPenFromBatch) // 从猪群移除空栏
|
||||
pigBatchGroup.POST("/move-pigs-into-pen/:id", a.pigBatchController.MovePigsIntoPen) // 将猪只从“虚拟库存”移入指定猪栏
|
||||
pigBatchGroup.POST("/sell-pigs/:id", a.pigBatchController.SellPigs) // 处理卖猪业务
|
||||
pigBatchGroup.POST("/buy-pigs/:id", a.pigBatchController.BuyPigs) // 处理买猪业务
|
||||
|
||||
Reference in New Issue
Block a user