-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 146-create-change-password-auth-route
- Loading branch information
Showing
52 changed files
with
2,048 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package controllers | ||
|
||
import ( | ||
"github.com/GenerateNU/sac/backend/src/errors" | ||
"github.com/GenerateNU/sac/backend/src/models" | ||
"github.com/GenerateNU/sac/backend/src/services" | ||
"github.com/gofiber/fiber/v2" | ||
) | ||
|
||
type ClubContactController struct { | ||
clubContactService services.ClubContactServiceInterface | ||
} | ||
|
||
func NewClubContactController(clubContactService services.ClubContactServiceInterface) *ClubContactController { | ||
return &ClubContactController{clubContactService: clubContactService} | ||
} | ||
|
||
func (cc *ClubContactController) GetClubContacts(c *fiber.Ctx) error { | ||
contacts, err := cc.clubContactService.GetClubContacts(c.Params("clubID")) | ||
if err != nil { | ||
return err.FiberError(c) | ||
} | ||
|
||
return c.Status(fiber.StatusOK).JSON(contacts) | ||
} | ||
|
||
func (cc *ClubContactController) PutContact(c *fiber.Ctx) error { | ||
var contactBody models.PutContactRequestBody | ||
|
||
if err := c.BodyParser(&contactBody); err != nil { | ||
return errors.FailedToParseRequestBody.FiberError(c) | ||
} | ||
|
||
contact, err := cc.clubContactService.PutClubContact(c.Params("clubID"), contactBody) | ||
if err != nil { | ||
return err.FiberError(c) | ||
} | ||
|
||
return c.Status(fiber.StatusOK).JSON(contact) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package controllers | ||
|
||
import ( | ||
"strconv" | ||
|
||
"github.com/GenerateNU/sac/backend/src/services" | ||
"github.com/gofiber/fiber/v2" | ||
) | ||
|
||
type ClubFollowerController struct { | ||
clubFollowerService services.ClubFollowerServiceInterface | ||
} | ||
|
||
func NewClubFollowerController(clubFollowerService services.ClubFollowerServiceInterface) *ClubFollowerController { | ||
return &ClubFollowerController{clubFollowerService: clubFollowerService} | ||
} | ||
|
||
func (cf *ClubFollowerController) GetClubFollowers(c *fiber.Ctx) error { | ||
defaultLimit := 10 | ||
defaultPage := 1 | ||
|
||
followers, err := cf.clubFollowerService.GetClubFollowers(c.Params("clubID"), c.Query("limit", strconv.Itoa(defaultLimit)), c.Query("page", strconv.Itoa(defaultPage))) | ||
if err != nil { | ||
return err.FiberError(c) | ||
} | ||
|
||
return c.Status(fiber.StatusOK).JSON(followers) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package controllers | ||
|
||
import ( | ||
"strconv" | ||
|
||
"github.com/GenerateNU/sac/backend/src/services" | ||
"github.com/gofiber/fiber/v2" | ||
) | ||
|
||
type ClubMemberController struct { | ||
clubMemberService services.ClubMemberServiceInterface | ||
} | ||
|
||
func NewClubMemberController(clubMemberService services.ClubMemberServiceInterface) *ClubMemberController { | ||
return &ClubMemberController{clubMemberService: clubMemberService} | ||
} | ||
|
||
func (cm *ClubMemberController) GetClubMembers(c *fiber.Ctx) error { | ||
defaultLimit := 10 | ||
defaultPage := 1 | ||
|
||
followers, err := cm.clubMemberService.GetClubMembers(c.Params("clubID"), c.Query("limit", strconv.Itoa(defaultLimit)), c.Query("page", strconv.Itoa(defaultPage))) | ||
if err != nil { | ||
return err.FiberError(c) | ||
} | ||
|
||
return c.Status(fiber.StatusOK).JSON(followers) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package controllers | ||
|
||
import ( | ||
"strconv" | ||
|
||
"github.com/GenerateNU/sac/backend/src/services" | ||
"github.com/gofiber/fiber/v2" | ||
) | ||
|
||
type ContactController struct { | ||
contactService services.ContactServiceInterface | ||
} | ||
|
||
func NewContactController(contactService services.ContactServiceInterface) *ContactController { | ||
return &ContactController{contactService: contactService} | ||
} | ||
|
||
func (co *ContactController) GetContact(c *fiber.Ctx) error { | ||
contact, err := co.contactService.GetContact(c.Params("contactID")) | ||
if err != nil { | ||
return err.FiberError(c) | ||
} | ||
|
||
return c.Status(fiber.StatusOK).JSON(contact) | ||
} | ||
|
||
func (co *ContactController) GetContacts(c *fiber.Ctx) error { | ||
defaultLimit := 10 | ||
defaultPage := 1 | ||
|
||
contacts, err := co.contactService.GetContacts(c.Query("limit", strconv.Itoa(defaultLimit)), c.Query("page", strconv.Itoa(defaultPage))) | ||
if err != nil { | ||
return err.FiberError(c) | ||
} | ||
|
||
return c.Status(fiber.StatusOK).JSON(contacts) | ||
} | ||
|
||
func (co *ContactController) DeleteContact(c *fiber.Ctx) error { | ||
err := co.contactService.DeleteContact(c.Params("contactID")) | ||
if err != nil { | ||
return err.FiberError(c) | ||
} | ||
|
||
return c.SendStatus(fiber.StatusNoContent) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package controllers | ||
|
||
import ( | ||
"github.com/GenerateNU/sac/backend/src/services" | ||
"github.com/gofiber/fiber/v2" | ||
) | ||
|
||
type UserFollowerController struct { | ||
userFollowerService services.UserFollowerServiceInterface | ||
} | ||
|
||
func NewUserFollowerController(userFollowerService services.UserFollowerServiceInterface) *UserFollowerController { | ||
return &UserFollowerController{userFollowerService: userFollowerService} | ||
} | ||
|
||
func (uf *UserFollowerController) CreateFollowing(c *fiber.Ctx) error { | ||
err := uf.userFollowerService.CreateFollowing(c.Params("userID"), c.Params("clubID")) | ||
if err != nil { | ||
return err.FiberError(c) | ||
} | ||
return c.SendStatus(fiber.StatusCreated) | ||
} | ||
|
||
func (uf *UserFollowerController) DeleteFollowing(c *fiber.Ctx) error { | ||
err := uf.userFollowerService.DeleteFollowing(c.Params("userID"), c.Params("clubID")) | ||
if err != nil { | ||
return err.FiberError(c) | ||
} | ||
return c.SendStatus(fiber.StatusNoContent) | ||
} | ||
|
||
func (uf *UserFollowerController) GetAllFollowing(c *fiber.Ctx) error { | ||
clubs, err := uf.userFollowerService.GetFollowing(c.Params("userID")) | ||
if err != nil { | ||
return err.FiberError(c) | ||
} | ||
return c.Status(fiber.StatusOK).JSON(clubs) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package controllers | ||
|
||
import ( | ||
"github.com/GenerateNU/sac/backend/src/services" | ||
"github.com/gofiber/fiber/v2" | ||
) | ||
|
||
type UserMemberController struct { | ||
clubMemberService services.UserMemberServiceInterface | ||
} | ||
|
||
func NewUserMemberController(clubMemberService services.UserMemberServiceInterface) *UserMemberController { | ||
return &UserMemberController{clubMemberService: clubMemberService} | ||
} | ||
|
||
func (um *UserMemberController) CreateMembership(c *fiber.Ctx) error { | ||
err := um.clubMemberService.CreateMembership(c.Params("userID"), c.Params("clubID")) | ||
if err != nil { | ||
return err.FiberError(c) | ||
} | ||
|
||
return c.SendStatus(fiber.StatusCreated) | ||
} | ||
|
||
func (um *UserMemberController) DeleteMembership(c *fiber.Ctx) error { | ||
err := um.clubMemberService.DeleteMembership(c.Params("userID"), c.Params("clubID")) | ||
if err != nil { | ||
return err.FiberError(c) | ||
} | ||
|
||
return c.SendStatus(fiber.StatusNoContent) | ||
} | ||
|
||
func (um *UserMemberController) GetMembership(c *fiber.Ctx) error { | ||
followers, err := um.clubMemberService.GetMembership(c.Params("clubID")) | ||
if err != nil { | ||
return err.FiberError(c) | ||
} | ||
|
||
return c.Status(fiber.StatusOK).JSON(followers) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package errors | ||
|
||
import "github.com/gofiber/fiber/v2" | ||
|
||
var ( | ||
FailedToGetContacts = Error{ | ||
StatusCode: fiber.StatusInternalServerError, | ||
Message: "failed to get contacts", | ||
} | ||
FailedToGetContact = Error{ | ||
StatusCode: fiber.StatusInternalServerError, | ||
Message: "failed to get contact", | ||
} | ||
ContactNotFound = Error{ | ||
StatusCode: fiber.StatusNotFound, | ||
Message: "contact not found", | ||
} | ||
FailedToPutContact = Error{ | ||
StatusCode: fiber.StatusInternalServerError, | ||
Message: "failed to put contact", | ||
} | ||
FailedToDeleteContact = Error{ | ||
StatusCode: fiber.StatusInternalServerError, | ||
Message: "failed to delete contact", | ||
} | ||
FailedToValidateContact = Error{ | ||
StatusCode: fiber.StatusBadRequest, | ||
Message: "failed to validate contact", | ||
} | ||
) |
Oops, something went wrong.