Skip to content

Commit

Permalink
♻️ Rename handler fields
Browse files Browse the repository at this point in the history
  • Loading branch information
H1rono committed Apr 28, 2024
1 parent 4e547ae commit 87a0f60
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
32 changes: 16 additions & 16 deletions interfaces/handler/contest.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
)

type ContestHandler struct {
r repository.ContestRepository
contest repository.ContestRepository
}

// NewContestHandler creates a ContestHandler
Expand All @@ -26,7 +26,7 @@ func NewContestHandler(r repository.ContestRepository) *ContestHandler {
// GetContests GET /contests
func (h *ContestHandler) GetContests(c echo.Context) error {
ctx := c.Request().Context()
contests, err := h.r.GetContests(ctx)
contests, err := h.contest.GetContests(ctx)
if err != nil {
return err
}
Expand All @@ -47,13 +47,13 @@ func (h *ContestHandler) GetContest(c echo.Context) error {
}

ctx := c.Request().Context()
contest, err := h.r.GetContest(ctx, contestID)
contest, err := h.contest.GetContest(ctx, contestID)
if err != nil {
return err
}

{
teams, err := h.r.GetContestTeams(ctx, contestID)
teams, err := h.contest.GetContestTeams(ctx, contestID)
if err != nil && !errors.Is(err, repository.ErrNotFound) {
return err
}
Expand Down Expand Up @@ -95,7 +95,7 @@ func (h *ContestHandler) CreateContest(c echo.Context) error {
}

ctx := c.Request().Context()
contest, err := h.r.CreateContest(ctx, &createReq)
contest, err := h.contest.CreateContest(ctx, &createReq)
if err != nil {
return err
}
Expand Down Expand Up @@ -128,7 +128,7 @@ func (h *ContestHandler) EditContest(c echo.Context) error {
}

ctx := c.Request().Context()
err = h.r.UpdateContest(ctx, contestID, &patchReq)
err = h.contest.UpdateContest(ctx, contestID, &patchReq)
if err != nil {
return err
}
Expand All @@ -144,7 +144,7 @@ func (h *ContestHandler) DeleteContest(c echo.Context) error {
}

ctx := c.Request().Context()
if err := h.r.DeleteContest(ctx, contestID); err != nil {
if err := h.contest.DeleteContest(ctx, contestID); err != nil {
return err
}

Expand All @@ -159,7 +159,7 @@ func (h *ContestHandler) GetContestTeams(c echo.Context) error {
}

ctx := c.Request().Context()
contestTeams, err := h.r.GetContestTeams(ctx, contestID)
contestTeams, err := h.contest.GetContestTeams(ctx, contestID)
if err != nil {
return err
}
Expand Down Expand Up @@ -189,13 +189,13 @@ func (h *ContestHandler) GetContestTeam(c echo.Context) error {
}

ctx := c.Request().Context()
contestTeam, err := h.r.GetContestTeam(ctx, contestID, teamID)
contestTeam, err := h.contest.GetContestTeam(ctx, contestID, teamID)
if err != nil {
return err
}

{
members, err := h.r.GetContestTeamMembers(ctx, contestID, teamID)
members, err := h.contest.GetContestTeamMembers(ctx, contestID, teamID)
if err != nil {
return err
}
Expand Down Expand Up @@ -237,7 +237,7 @@ func (h *ContestHandler) AddContestTeam(c echo.Context) error {
}

ctx := c.Request().Context()
contestTeam, err := h.r.CreateContestTeam(ctx, contestID, &args)
contestTeam, err := h.contest.CreateContestTeam(ctx, contestID, &args)
if err != nil {
return err
}
Expand Down Expand Up @@ -273,7 +273,7 @@ func (h *ContestHandler) EditContestTeam(c echo.Context) error {
}

ctx := c.Request().Context()
if err = h.r.UpdateContestTeam(ctx, teamID, &args); err != nil {
if err = h.contest.UpdateContestTeam(ctx, teamID, &args); err != nil {
return err
}

Expand All @@ -293,7 +293,7 @@ func (h *ContestHandler) DeleteContestTeam(c echo.Context) error {
}

ctx := c.Request().Context()
if err = h.r.DeleteContestTeam(ctx, contestID, teamID); err != nil {
if err = h.contest.DeleteContestTeam(ctx, contestID, teamID); err != nil {
return err
}

Expand All @@ -313,7 +313,7 @@ func (h *ContestHandler) GetContestTeamMembers(c echo.Context) error {
}

ctx := c.Request().Context()
users, err := h.r.GetContestTeamMembers(ctx, contestID, teamID)
users, err := h.contest.GetContestTeamMembers(ctx, contestID, teamID)
if err != nil {
return err
}
Expand Down Expand Up @@ -349,7 +349,7 @@ func (h *ContestHandler) AddContestTeamMembers(c echo.Context) error {
return err
}

err = h.r.AddContestTeamMembers(ctx, teamID, req.Members)
err = h.contest.AddContestTeamMembers(ctx, teamID, req.Members)
if err != nil {
return err
}
Expand All @@ -375,7 +375,7 @@ func (h *ContestHandler) EditContestTeamMembers(c echo.Context) error {
}

ctx := c.Request().Context()
if err = h.r.EditContestTeamMembers(ctx, teamID, req.Members); err != nil {
if err = h.contest.EditContestTeamMembers(ctx, teamID, req.Members); err != nil {
return err
}
return c.NoContent(http.StatusNoContent)
Expand Down
20 changes: 10 additions & 10 deletions interfaces/handler/project.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package handler

import (
"github.com/traPtitech/traPortfolio/domain"
"net/http"

"github.com/gofrs/uuid"
"github.com/labstack/echo/v4"
"github.com/traPtitech/traPortfolio/domain"
"github.com/traPtitech/traPortfolio/interfaces/handler/schema"
"github.com/traPtitech/traPortfolio/usecases/repository"
"github.com/traPtitech/traPortfolio/util/optional"
)

type ProjectHandler struct {
r repository.ProjectRepository
project repository.ProjectRepository
}

func NewProjectHandler(r repository.ProjectRepository) *ProjectHandler {
Expand All @@ -22,7 +22,7 @@ func NewProjectHandler(r repository.ProjectRepository) *ProjectHandler {
// GetProjects GET /projects
func (h *ProjectHandler) GetProjects(c echo.Context) error {
ctx := c.Request().Context()
projects, err := h.r.GetProjects(ctx)
projects, err := h.project.GetProjects(ctx)
if err != nil {
return err
}
Expand All @@ -43,7 +43,7 @@ func (h *ProjectHandler) GetProject(c echo.Context) error {
}

ctx := c.Request().Context()
project, err := h.r.GetProject(ctx, projectID)
project, err := h.project.GetProject(ctx, projectID)
if err != nil {
return err
}
Expand Down Expand Up @@ -89,7 +89,7 @@ func (h *ProjectHandler) CreateProject(c echo.Context) error {
}

ctx := c.Request().Context()
project, err := h.r.CreateProject(ctx, &createReq)
project, err := h.project.CreateProject(ctx, &createReq)
if err != nil {
return err
}
Expand Down Expand Up @@ -135,7 +135,7 @@ func (h *ProjectHandler) EditProject(c echo.Context) error {

ctx := c.Request().Context()
{
old, err := h.r.GetProject(ctx, projectID)
old, err := h.project.GetProject(ctx, projectID)
if err != nil {
return err
}
Expand All @@ -159,7 +159,7 @@ func (h *ProjectHandler) EditProject(c echo.Context) error {
}
}

err = h.r.UpdateProject(ctx, projectID, &patchReq)
err = h.project.UpdateProject(ctx, projectID, &patchReq)
if err != nil {
return err
}
Expand All @@ -175,7 +175,7 @@ func (h *ProjectHandler) GetProjectMembers(c echo.Context) error {
}

ctx := c.Request().Context()
members, err := h.r.GetProjectMembers(ctx, projectID)
members, err := h.project.GetProjectMembers(ctx, projectID)
if err != nil {
return err
}
Expand Down Expand Up @@ -225,7 +225,7 @@ func (h *ProjectHandler) AddProjectMembers(c echo.Context) error {
}

ctx := c.Request().Context()
err = h.r.AddProjectMembers(ctx, projectID, createReq)
err = h.project.AddProjectMembers(ctx, projectID, createReq)
if err != nil {
return err
}
Expand All @@ -246,7 +246,7 @@ func (h *ProjectHandler) DeleteProjectMembers(c echo.Context) error {
}

ctx := c.Request().Context()
err = h.r.DeleteProjectMembers(ctx, projectID, req.Members)
err = h.project.DeleteProjectMembers(ctx, projectID, req.Members)
if err != nil {
return err
}
Expand Down

0 comments on commit 87a0f60

Please sign in to comment.