ReorderGroups handles batch reorder updates for groups.
(c *gin.Context)
| 219 | |
| 220 | // ReorderGroups handles batch reorder updates for groups. |
| 221 | func (s *Server) ReorderGroups(c *gin.Context) { |
| 222 | var req GroupReorderRequest |
| 223 | if err := c.ShouldBindJSON(&req); err != nil { |
| 224 | response.Error(c, app_errors.NewAPIError(app_errors.ErrInvalidJSON, err.Error())) |
| 225 | return |
| 226 | } |
| 227 | |
| 228 | if err := validateGroupReorderItems(req.Items); s.handleGroupError(c, err) { |
| 229 | return |
| 230 | } |
| 231 | |
| 232 | items := make([]services.GroupReorderItem, 0, len(req.Items)) |
| 233 | for _, item := range req.Items { |
| 234 | items = append(items, services.GroupReorderItem{ |
| 235 | ID: item.ID, |
| 236 | Sort: item.Sort, |
| 237 | }) |
| 238 | } |
| 239 | |
| 240 | if s.handleGroupError(c, s.GroupService.ReorderGroups(c.Request.Context(), items)) { |
| 241 | return |
| 242 | } |
| 243 | |
| 244 | response.SuccessI18n(c, "success.groups_reordered", nil) |
| 245 | } |
| 246 | |
| 247 | // GroupResponse defines the structure for a group response, excluding sensitive or large fields. |
| 248 | type GroupResponse struct { |
nothing calls this directly
no test coverage detected