Skip to content

Commit

Permalink
chore : delete unused files
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeCP17 committed Sep 3, 2024
1 parent 90f03c4 commit 9ded1c8
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 682 deletions.
71 changes: 63 additions & 8 deletions cmd/server/handler/chat_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,35 @@ import (

"github.com/labstack/echo/v4"
pnd "github.com/pet-sitter/pets-next-door-api/api"
"github.com/pet-sitter/pets-next-door-api/internal/chat"
domain "github.com/pet-sitter/pets-next-door-api/internal/domain/chat"
"github.com/pet-sitter/pets-next-door-api/internal/service"
)

type ChatHandler struct {
stateManager *chat.StateManager
authService service.AuthService
chatService service.ChatService
authService service.AuthService
chatService service.ChatService
}

func NewChatHandler(
stateManager chat.StateManager,
authService service.AuthService,
chatService service.ChatService,
) *ChatHandler {
return &ChatHandler{
stateManager: &stateManager,
authService: authService,
chatService: chatService,
authService: authService,
chatService: chatService,
}
}

// FindRoomByID godoc
// @Summary 채팅방을 조회합니다.
// @Description
// @Tags chat
// @Accept json
// @Produce json
// @Param roomID path int true "채팅방 ID"
// @Security FirebaseAuth
// @Success 200 {object} domain.Room
// @Router /chat/rooms/{roomID} [get]
func (h ChatHandler) FindRoomByID(c echo.Context) error {
roomID, err := pnd.ParseIDFromPath(c, "roomID")
if err != nil {
Expand All @@ -42,6 +48,16 @@ func (h ChatHandler) FindRoomByID(c echo.Context) error {
return c.JSON(http.StatusOK, res)
}

// CreateRoom godoc
// @Summary 채팅방을 생성합니다.
// @Description
// @Tags chat
// @Accept json
// @Produce json
// @Param request body domain.CreateRoomRequest true "채팅방 생성 요청"
// @Security FirebaseAuth
// @Success 201 {object} domain.Room
// @Router /chat/rooms [post]
func (h ChatHandler) CreateRoom(c echo.Context) error {
var createRoomRequest domain.CreateRoomRequest
if err := pnd.ParseBody(c, &createRoomRequest); err != nil {
Expand All @@ -56,6 +72,16 @@ func (h ChatHandler) CreateRoom(c echo.Context) error {
return c.JSON(http.StatusCreated, res)
}

// JoinChatRoom godoc
// @Summary 채팅방에 참가합니다.
// @Description 채팅방에 참가합니다.
// @Tags chat
// @Accept json
// @Produce json
// @Param roomID path int true "채팅방 ID"
// @Security FirebaseAuth
// @Success 200 {object} domain.JoinRoomView
// @Router /chat/rooms/{roomID}/join [post]
func (h ChatHandler) JoinChatRoom(c echo.Context) error {
foundUser, err := h.authService.VerifyAuthAndGetUser(c.Request().Context(), c.Request().Header.Get("Authorization"))
if err != nil {
Expand All @@ -75,6 +101,16 @@ func (h ChatHandler) JoinChatRoom(c echo.Context) error {
return c.JSON(http.StatusOK, res)
}

// LeaveChatRoom godoc
// @Summary 채팅방을 나갑니다.
// @Description 채팅방을 나갑니다.
// @Tags chat
// @Accept json
// @Produce json
// @Param roomID path int true "채팅방 ID"
// @Security FirebaseAuth
// @Success 200
// @Router /chat/rooms/{roomID}/leave [post]
func (h ChatHandler) LeaveChatRoom(c echo.Context) error {
foundUser, err := h.authService.VerifyAuthAndGetUser(c.Request().Context(), c.Request().Header.Get("Authorization"))
if err != nil {
Expand All @@ -90,6 +126,15 @@ func (h ChatHandler) LeaveChatRoom(c echo.Context) error {
return c.JSON(http.StatusOK, res)
}

// FindAllRooms godoc
// @Summary 모든 채팅방을 조회합니다.
// @Description 모든 채팅방을 조회합니다. ( 현재는 Mock 데이터로 응답합니다 )
// @Tags chat
// @Accept json
// @Produce json
// @Security FirebaseAuth
// @Success 200 {object} []domain.Room
// @Router /chat/rooms [get]
func (h ChatHandler) FindAllRooms(c echo.Context) error {
rooms, err := h.chatService.MockFindAllChatRooms()
if err != nil {
Expand All @@ -98,6 +143,16 @@ func (h ChatHandler) FindAllRooms(c echo.Context) error {
return c.JSON(http.StatusOK, rooms)
}

// FindMessagesByRoomID godoc
// @Summary 채팅방의 메시지를 조회합니다.
// @Description 채팅방의 메시지를 조회합니다. ( 현재는 Mock 데이터로 응답합니다 )
// @Tags chat
// @Accept json
// @Produce json
// @Param roomID path int true "채팅방 ID"
// @Security FirebaseAuth
// @Success 200 {object} []domain.Message
// @Router /chat/rooms/{roomID}/messages [get]
func (h ChatHandler) FindMessagesByRoomID(c echo.Context) error {
roomID, err := pnd.ParseIDFromPath(c, "roomID")
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions cmd/server/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"github.com/pet-sitter/pets-next-door-api/cmd/server/handler"
"github.com/pet-sitter/pets-next-door-api/internal/chat"
"github.com/pet-sitter/pets-next-door-api/internal/configs"
"github.com/pet-sitter/pets-next-door-api/internal/domain/auth"
s3infra "github.com/pet-sitter/pets-next-door-api/internal/infra/bucket"
Expand Down Expand Up @@ -57,7 +56,6 @@ func NewRouter(app *firebaseinfra.FirebaseApp) (*echo.Echo, error) {
sosPostService := service.NewSOSPostService(db)
conditionService := service.NewSOSConditionService(db)
chatService := service.NewChatService(db)
stateManager := chat.NewInMemoryStateManager()

// Initialize handlers
authHandler := handler.NewAuthHandler(authService, kakaoinfra.NewKakaoDefaultClient())
Expand All @@ -66,7 +64,7 @@ func NewRouter(app *firebaseinfra.FirebaseApp) (*echo.Echo, error) {
breedHandler := handler.NewBreedHandler(*breedService)
sosPostHandler := handler.NewSOSPostHandler(*sosPostService, authService)
conditionHandler := handler.NewConditionHandler(*conditionService)
chatHandler := handler.NewChatHandler(stateManager, authService, *chatService)
chatHandler := handler.NewChatHandler(authService, *chatService)

// // InMemoryStateManager는 클라이언트와 채팅방의 상태를 메모리에 저장하고 관리합니다.
// // 이 메서드는 단순하고 빠르며 테스트 목적으로 적합합니다.
Expand Down Expand Up @@ -156,8 +154,10 @@ func NewRouter(app *firebaseinfra.FirebaseApp) (*echo.Echo, error) {
chatAPIGroup.POST("/rooms", chatHandler.CreateRoom)
chatAPIGroup.PUT("/rooms/:roomID/join", chatHandler.JoinChatRoom)
chatAPIGroup.PUT("/rooms/:roomID/leave", chatHandler.LeaveChatRoom)
chatAPIGroup.GET("/rooms", chatHandler.FindAllRooms)
chatAPIGroup.GET("/rooms/:roomID", chatHandler.FindRoomByID)

// Mock
chatAPIGroup.GET("/rooms", chatHandler.FindAllRooms)
chatAPIGroup.GET("/rooms/:roomID/messages", chatHandler.FindMessagesByRoomID)
}

Expand Down
Loading

0 comments on commit 9ded1c8

Please sign in to comment.