完善文案的状态流转

This commit is contained in:
sjk
2025-12-20 01:05:46 +08:00
parent 6802624e59
commit 15b579d64a
13 changed files with 547 additions and 181 deletions

View File

@@ -7,6 +7,7 @@ import (
"github.com/gin-gonic/gin"
)
type EmployeeController struct {
service *service.EmployeeService
}
@@ -255,3 +256,41 @@ func (ctrl *EmployeeController) GetProducts(c *gin.Context) {
"list": data,
})
}
// UpdateArticleStatus 更新文案状态(通过/拒绝)
func (ctrl *EmployeeController) UpdateArticleStatus(c *gin.Context) {
employeeID := c.GetInt("employee_id")
articleID, err := strconv.Atoi(c.Param("id"))
if err != nil {
common.Error(c, common.CodeInvalidParams, "文案ID参数错误")
return
}
var req struct {
Status string `json:"status" binding:"required"`
}
if err := c.ShouldBindJSON(&req); err != nil {
common.Error(c, common.CodeInvalidParams, "参数错误")
return
}
// 验证status值
if req.Status != "approved" && req.Status != "rejected" {
common.Error(c, common.CodeInvalidParams, "status只能为approved或rejected")
return
}
err = ctrl.service.UpdateArticleStatus(employeeID, articleID, req.Status)
if err != nil {
common.Error(c, common.CodeInternalError, err.Error())
return
}
message := "已通过"
if req.Status == "rejected" {
message = "已拒绝"
}
common.SuccessWithMessage(c, message, nil)
}