Skip to content

Commit

Permalink
feat: add FindUserByID API
Browse files Browse the repository at this point in the history
  • Loading branch information
litsynp committed May 12, 2024
1 parent 819c1e4 commit d36abe8
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
28 changes: 28 additions & 0 deletions cmd/server/handler/user_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,34 @@ func (h *UserHandler) FindUsers(c echo.Context) error {
return c.JSON(http.StatusOK, res)
}

// FindUserByID godoc
// @Summary 단일 사용자 정보를 조회합니다.
// @Description
// @Tags users
// @Produce json
// @Security FirebaseAuth
// @Param userID path int true "사용자 ID"
// @Success 200 {object} user.WithoutPrivateInfo
// @Router /users/{userID} [get]
func (h *UserHandler) FindUserByID(c echo.Context) error {
// _, err := h.authService.VerifyAuthAndGetUser(c.Request().Context(), c.Request().Header.Get("Authorization"))
// if err != nil {
// return c.JSON(err.StatusCode, err)
// }

userID, err := pnd.ParseIDFromPath(c, "userID")
if err != nil {
return c.JSON(err.StatusCode, err)
}

res, err := h.userService.FindUser(c.Request().Context(), user.FindUserParams{ID: userID})
if err != nil {
return c.JSON(err.StatusCode, err)
}

return c.JSON(http.StatusOK, res)
}

// FindMyProfile godoc
// @Summary 내 프로필 정보를 조회합니다.
// @Description
Expand Down
1 change: 1 addition & 0 deletions cmd/server/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ func NewRouter(app *firebaseinfra.FirebaseApp) (*echo.Echo, error) {
userAPIGroup.POST("/check/nickname", userHandler.CheckUserNickname)
userAPIGroup.POST("/status", userHandler.FindUserStatusByEmail)
userAPIGroup.GET("", userHandler.FindUsers)
userAPIGroup.GET("/:userID", userHandler.FindUserByID)
userAPIGroup.GET("/me", userHandler.FindMyProfile)
userAPIGroup.PUT("/me", userHandler.UpdateMyProfile)
userAPIGroup.DELETE("/me", userHandler.DeleteMyAccount)
Expand Down
8 changes: 8 additions & 0 deletions internal/domain/user/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,11 @@ func (u *WithProfileImage) ToMyProfileView() *MyProfileView {
FirebaseProviderType: u.FirebaseProviderType,
}
}

func (u *WithProfileImage) ToWithoutPrivateInfo() *WithoutPrivateInfo {
return &WithoutPrivateInfo{
ID: u.ID,
Nickname: u.Nickname,
ProfileImageURL: u.ProfileImageURL,
}
}

0 comments on commit d36abe8

Please sign in to comment.