Skip to content

Commit 55891d0

Browse files
removed team ban from admin
1 parent 9a031e3 commit 55891d0

3 files changed

Lines changed: 1 addition & 118 deletions

File tree

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,4 @@ require (
4343
golang.org/x/sync v0.19.0 // indirect
4444
golang.org/x/sys v0.39.0 // indirect
4545
golang.org/x/text v0.32.0 // indirect
46-
4746
)

pkg/controllers/admin.go

Lines changed: 0 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -835,121 +835,6 @@ func GetTeamsByTrack(c echo.Context)error{
835835

836836

837837
}
838-
839-
func BanTeam(c echo.Context) error {
840-
var payload dto.BanTeamRequest
841-
842-
if err := c.Bind(&payload); err != nil {
843-
return c.JSON(http.StatusBadRequest, &models.Response{
844-
Status: "fail",
845-
Message: err.Error(),
846-
})
847-
}
848-
849-
if err := utils.Validate.Struct(payload); err != nil {
850-
return c.JSON(http.StatusBadRequest, &models.Response{
851-
Status: "fail",
852-
Data: utils.FormatValidationErrors(err),
853-
})
854-
}
855-
856-
ctx := c.Request().Context()
857-
858-
teamID := pgtype.UUID{Bytes: payload.TeamId, Valid: true}
859-
team, err := db.Queries.GetTeamById(ctx, teamID)
860-
if err != nil {
861-
if errors.Is(err, sql.ErrNoRows) {
862-
return c.JSON(http.StatusNotFound, &models.Response{
863-
Status: "fail",
864-
Message: "Team does not exist",
865-
})
866-
}
867-
return c.JSON(http.StatusInternalServerError, &models.Response{
868-
Status: "fail",
869-
Message: err.Error(),
870-
})
871-
}
872-
873-
err = db.Queries.UpdateTeam(ctx, sqlc.UpdateTeamParams{
874-
ID: teamID,
875-
Name: team.Name,
876-
TeamSize: team.TeamSize,
877-
RoundQualified: team.RoundQualified,
878-
IsBanned: true,
879-
TotalScore: team.TotalScore,
880-
})
881-
882-
if err != nil {
883-
return c.JSON(http.StatusInternalServerError, &models.Response{
884-
Status: "fail",
885-
Message: err.Error(),
886-
})
887-
}
888-
889-
return c.JSON(http.StatusOK, &models.Response{
890-
Status: "success",
891-
Message: "Team banned successfully",
892-
Data: map[string]interface{}{},
893-
})
894-
}
895-
896-
func UnBanTeam(c echo.Context) error {
897-
var payload dto.UnBanTeamRequest
898-
899-
if err := c.Bind(&payload); err != nil {
900-
return c.JSON(http.StatusBadRequest, &models.Response{
901-
Status: "fail",
902-
Message: err.Error(),
903-
})
904-
}
905-
906-
if err := utils.Validate.Struct(payload); err != nil {
907-
return c.JSON(http.StatusBadRequest, &models.Response{
908-
Status: "fail",
909-
Data: utils.FormatValidationErrors(err),
910-
})
911-
}
912-
913-
ctx := c.Request().Context()
914-
915-
teamID := pgtype.UUID{Bytes: payload.TeamId, Valid: true}
916-
team, err := db.Queries.GetTeamById(ctx, teamID)
917-
if err != nil {
918-
if errors.Is(err, sql.ErrNoRows) {
919-
return c.JSON(http.StatusNotFound, &models.Response{
920-
Status: "fail",
921-
Message: "Team does not exist",
922-
})
923-
}
924-
return c.JSON(http.StatusInternalServerError, &models.Response{
925-
Status: "fail",
926-
Message: err.Error(),
927-
})
928-
}
929-
930-
err = db.Queries.UpdateTeam(ctx, sqlc.UpdateTeamParams{
931-
ID: teamID,
932-
Name: team.Name,
933-
TeamSize: team.TeamSize,
934-
RoundQualified: team.RoundQualified,
935-
IsBanned: false,
936-
TotalScore: team.TotalScore,
937-
})
938-
939-
if err != nil {
940-
return c.JSON(http.StatusInternalServerError, &models.Response{
941-
Status: "fail",
942-
Message: err.Error(),
943-
})
944-
}
945-
946-
return c.JSON(http.StatusOK, &models.Response{
947-
Status: "success",
948-
Message: "Team unbanned successfully",
949-
Data: map[string]interface{}{},
950-
})
951-
}
952-
953838
func BanUser(c echo.Context) error {
954839
var payload dto.BanUserRequest
955840

pkg/router/admin_routes.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ func AdminRoutes(api *echo.Group) {
3232
// moderation
3333
admin.POST("/ban", controllers.BanUser)
3434
admin.POST("/unban", controllers.UnbanUser)
35-
admin.POST("/ban/team", controllers.BanTeam)
36-
admin.POST("/unban/team", controllers.UnBanTeam)
35+
3736
}
3837

0 commit comments

Comments
 (0)