fix: 全面修复项目问题
后端修复: - 验证码存储与校验机制 - 订单创建事务+库存扣减 - GetStats字段名错误 - VerifyEmail改为POST - 供应商更新字段白名单 - 文件删除安全检查 - 抽奖安全随机数 - 用户管理CRUD - 订单取消/确认收货 - 工单回复 - Toggle返回新数据 - 移除死代码 前端修复: - 404兜底路由 - 401软跳转 - API层统一 - 面包屑补充banners - 国际化完善 - 购物车并行删除 - 退出清理购物车 - 供应商Dashboard数据 - 工单详情页 - 订单取消/确认收货
This commit is contained in:
@@ -164,3 +164,36 @@ func (h *TicketHandler) Assign(c *gin.Context) {
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"message": "Ticket assigned successfully"})
|
||||
}
|
||||
|
||||
func (h *TicketHandler) Reply(c *gin.Context) {
|
||||
userID := c.GetUint("user_id")
|
||||
id, _ := strconv.Atoi(c.Param("id"))
|
||||
|
||||
var ticket models.Ticket
|
||||
if err := utils.DB.Where("id = ? AND user_id = ?", id, userID).First(&ticket).Error; err != nil {
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "Ticket not found"})
|
||||
return
|
||||
}
|
||||
|
||||
var req struct {
|
||||
Content string `json:"content" binding:"required"`
|
||||
}
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
reply := ticket.Reply
|
||||
if reply != "" {
|
||||
reply += "\n\n---\n\n"
|
||||
}
|
||||
reply += req.Content
|
||||
|
||||
utils.DB.Model(&ticket).Updates(map[string]interface{}{
|
||||
"reply": reply,
|
||||
"status": models.TicketStatusPending,
|
||||
})
|
||||
|
||||
utils.DB.First(&ticket, id)
|
||||
c.JSON(http.StatusOK, gin.H{"data": ticket})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user