UpdateSubGroupWeight handles updating the weight of a sub group
(c *gin.Context)
| 477 | |
| 478 | // UpdateSubGroupWeight handles updating the weight of a sub group |
| 479 | func (s *Server) UpdateSubGroupWeight(c *gin.Context) { |
| 480 | id, err := strconv.Atoi(c.Param("id")) |
| 481 | if err != nil { |
| 482 | response.ErrorI18nFromAPIError(c, app_errors.ErrBadRequest, "validation.invalid_group_id") |
| 483 | return |
| 484 | } |
| 485 | |
| 486 | subGroupID, err := strconv.Atoi(c.Param("subGroupId")) |
| 487 | if err != nil { |
| 488 | response.ErrorI18nFromAPIError(c, app_errors.ErrBadRequest, "validation.invalid_sub_group_id") |
| 489 | return |
| 490 | } |
| 491 | |
| 492 | var req UpdateSubGroupWeightRequest |
| 493 | if err := c.ShouldBindJSON(&req); err != nil { |
| 494 | response.Error(c, app_errors.NewAPIError(app_errors.ErrInvalidJSON, err.Error())) |
| 495 | return |
| 496 | } |
| 497 | |
| 498 | if err := s.AggregateGroupService.UpdateSubGroupWeight(c.Request.Context(), uint(id), uint(subGroupID), req.Weight); s.handleGroupError(c, err) { |
| 499 | return |
| 500 | } |
| 501 | |
| 502 | response.SuccessI18n(c, "success.sub_group_weight_updated", nil) |
| 503 | } |
| 504 | |
| 505 | // DeleteSubGroup handles deleting a sub group from an aggregate group |
| 506 | func (s *Server) DeleteSubGroup(c *gin.Context) { |
nothing calls this directly
no test coverage detected