将状态码改成自定义码
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
package plan
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.huangwc.com/pig/pig-farm-controller/internal/app/controller"
|
||||
"git.huangwc.com/pig/pig-farm-controller/internal/infra/logs"
|
||||
"git.huangwc.com/pig/pig-farm-controller/internal/infra/repository"
|
||||
@@ -72,7 +70,7 @@ func NewController(logger *logs.Logger, planRepo repository.PlanRepository) *Con
|
||||
func (pc *Controller) CreatePlan(c *gin.Context) {
|
||||
// 占位符:此处应调用服务层或仓库层来创建计划
|
||||
pc.logger.Infof("收到创建计划请求 (占位符)")
|
||||
controller.SendResponse(c, http.StatusCreated, "创建计划接口占位符", PlanResponse{ID: 0, Name: "占位计划"})
|
||||
controller.SendResponse(c, controller.CodeCreated, "创建计划接口占位符", PlanResponse{ID: 0, Name: "占位计划"})
|
||||
}
|
||||
|
||||
// GetPlan godoc
|
||||
@@ -87,7 +85,7 @@ func (pc *Controller) CreatePlan(c *gin.Context) {
|
||||
func (pc *Controller) GetPlan(c *gin.Context) {
|
||||
// 占位符:此处应调用服务层或仓库层来获取计划
|
||||
pc.logger.Infof("收到获取计划 (占位符)")
|
||||
controller.SendResponse(c, http.StatusOK, "获取计划接口占位符", ListPlansResponse{Plans: []PlanResponse{}, Total: 0})
|
||||
controller.SendResponse(c, controller.CodeSuccess, "获取计划接口占位符", ListPlansResponse{Plans: []PlanResponse{}, Total: 0})
|
||||
|
||||
}
|
||||
|
||||
@@ -102,7 +100,7 @@ func (pc *Controller) GetPlan(c *gin.Context) {
|
||||
func (pc *Controller) ListPlans(c *gin.Context) {
|
||||
// 占位符:此处应调用服务层或仓库层来获取计划列表
|
||||
pc.logger.Infof("收到获取计划列表请求 (占位符)")
|
||||
controller.SendResponse(c, http.StatusOK, "获取计划列表接口占位符", ListPlansResponse{Plans: []PlanResponse{}, Total: 0})
|
||||
controller.SendResponse(c, controller.CodeSuccess, "获取计划列表接口占位符", ListPlansResponse{Plans: []PlanResponse{}, Total: 0})
|
||||
}
|
||||
|
||||
// UpdatePlan godoc
|
||||
@@ -119,7 +117,7 @@ func (pc *Controller) ListPlans(c *gin.Context) {
|
||||
func (pc *Controller) UpdatePlan(c *gin.Context) {
|
||||
// 占位符:此处应调用服务层或仓库层来更新计划
|
||||
pc.logger.Infof("收到更新计划请求 (占位符)")
|
||||
controller.SendResponse(c, http.StatusOK, "更新计划接口占位符", PlanResponse{ID: 0, Name: "占位计划"})
|
||||
controller.SendResponse(c, controller.CodeSuccess, "更新计划接口占位符", PlanResponse{ID: 0, Name: "占位计划"})
|
||||
}
|
||||
|
||||
// DeletePlan godoc
|
||||
@@ -134,7 +132,7 @@ func (pc *Controller) UpdatePlan(c *gin.Context) {
|
||||
func (pc *Controller) DeletePlan(c *gin.Context) {
|
||||
// 占位符:此处应调用服务层或仓库层来删除计划
|
||||
pc.logger.Infof("收到删除计划请求 (占位符)")
|
||||
controller.SendResponse(c, http.StatusOK, "删除计划接口占位符", nil)
|
||||
controller.SendResponse(c, controller.CodeSuccess, "删除计划接口占位符", nil)
|
||||
}
|
||||
|
||||
// StartPlan godoc
|
||||
@@ -149,7 +147,7 @@ func (pc *Controller) DeletePlan(c *gin.Context) {
|
||||
func (pc *Controller) StartPlan(c *gin.Context) {
|
||||
// 占位符:此处应调用服务层或仓库层来启动计划
|
||||
pc.logger.Infof("收到启动计划请求 (占位符)")
|
||||
controller.SendResponse(c, http.StatusOK, "启动计划接口占位符", nil)
|
||||
controller.SendResponse(c, controller.CodeSuccess, "启动计划接口占位符", nil)
|
||||
}
|
||||
|
||||
// StopPlan godoc
|
||||
@@ -164,5 +162,5 @@ func (pc *Controller) StartPlan(c *gin.Context) {
|
||||
func (pc *Controller) StopPlan(c *gin.Context) {
|
||||
// 占位符:此处应调用服务层或仓库层来停止计划
|
||||
pc.logger.Infof("收到停止计划请求 (占位符)")
|
||||
controller.SendResponse(c, http.StatusOK, "停止计划接口占位符", nil)
|
||||
controller.SendResponse(c, controller.CodeSuccess, "停止计划接口占位符", nil)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user