mirror of
https://github.com/serty2005/rmser.git
synced 2026-02-04 19:02:33 -06:00
2701-есть адекватный порядок для строк черновика и фикс пустого поиска
This commit is contained in:
@@ -302,3 +302,31 @@ func (h *DraftsHandler) DeleteDraft(c *gin.Context) {
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"status": newStatus, "id": id.String()})
|
||||
}
|
||||
|
||||
// ReorderItems изменяет порядок позиции в черновике
|
||||
func (h *DraftsHandler) ReorderItems(c *gin.Context) {
|
||||
type ReorderRequest struct {
|
||||
ItemID uuid.UUID `json:"item_id" binding:"required"`
|
||||
NewOrder int `json:"new_order" binding:"required"`
|
||||
}
|
||||
|
||||
var req ReorderRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
// Получаем draftID из параметров пути
|
||||
draftID, err := uuid.Parse(c.Param("id"))
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "invalid draft id"})
|
||||
return
|
||||
}
|
||||
|
||||
if err := h.service.ReorderItem(draftID, req.ItemID, req.NewOrder); err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"success": true})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user