Skip to content

Commit

Permalink
chore : fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeCP17 committed Sep 12, 2024
1 parent 2a27700 commit 47e9818
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cmd/server/handler/chat_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (h ChatHandler) CreateRoom(c echo.Context) error {
c.Request().Context(),
createRoomRequest.RoomName,
createRoomRequest.RoomType,
createRoomRequest.JoinUserIds,
createRoomRequest.JoinUserIDs,
)
if err != nil {
return c.JSON(err.StatusCode, err)
Expand Down
2 changes: 1 addition & 1 deletion internal/domain/chat/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ package chat
type CreateRoomRequest struct {
RoomName string `json:"roomName" validate:"required"`
RoomType string `json:"roomType" validate:"required"`
JoinUserIds *[]int64 `json:"joinUsers"`
JoinUserIDs *[]int64 `json:"joinUserIds"`
}
18 changes: 12 additions & 6 deletions internal/service/chat_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ func NewChatService(conn *database.DB) *ChatService {
}
}

func (s *ChatService) CreateRoom(ctx context.Context, name, roomType string, joinUserIds *[]int64) (*chat.RoomSimpleInfo, *pnd.AppError) {
func (s *ChatService) CreateRoom(ctx context.Context, name, roomType string, joinUserIDs *[]int64) (
*chat.RoomSimpleInfo, *pnd.AppError,
) {
// 채팅방 생성
tx, err := s.conn.BeginTx(ctx)
defer tx.Rollback()
Expand All @@ -40,22 +42,22 @@ func (s *ChatService) CreateRoom(ctx context.Context, name, roomType string, joi
}

// 채팅방에 참여하는 인원이 없을 경우 방만 생성
if joinUserIds == nil || len(*joinUserIds) == 0 {
if joinUserIDs == nil || len(*joinUserIDs) == 0 {
return chat.ToCreateRoom(row, nil), nil
}

// 채팅방에 참여하는 인원이 있을 경우 참여자 추가
err3 := q.JoinRooms(ctx, databasegen.JoinRoomsParams{
RoomID: int64(row.ID),
UserIDs: *joinUserIds,
UserIDs: *joinUserIDs,
})
if err3 != nil {
return nil, pnd.FromPostgresError(err3)
}

tx.Commit()

joinUsers, err4 := databasegen.New(s.conn).FindUsersByIds(ctx, *joinUserIds)
joinUsers, err4 := databasegen.New(s.conn).FindUsersByIds(ctx, *joinUserIDs)

if err4 != nil {
return nil, pnd.FromPostgresError(err4)
Expand Down Expand Up @@ -126,7 +128,9 @@ func (s *ChatService) FindAllByUserUID(ctx context.Context, fbUID string) (*chat
return chat.ToUserChatRoomsView(rows), nil
}

func (s *ChatService) FindChatRoomByUIDAndRoomID(ctx context.Context, fbUID string, roomID int64) (*chat.RoomSimpleInfo, *pnd.AppError) {
func (s *ChatService) FindChatRoomByUIDAndRoomID(ctx context.Context, fbUID string, roomID int64) (
*chat.RoomSimpleInfo, *pnd.AppError,
) {
userData, err := databasegen.New(s.conn).FindUser(ctx, databasegen.FindUserParams{
FbUid: utils.StrToNullStr(fbUID),
})
Expand All @@ -142,7 +146,9 @@ func (s *ChatService) FindChatRoomByUIDAndRoomID(ctx context.Context, fbUID stri
return chat.ToUserChatRoomView(row), nil
}

func (s *ChatService) FindChatRoomMessagesByRoomID(ctx context.Context, roomID, prev, next, limit int64) (*chat.MessageCursorView, *pnd.AppError) {
func (s *ChatService) FindChatRoomMessagesByRoomID(ctx context.Context, roomID, prev, next, limit int64) (
*chat.MessageCursorView, *pnd.AppError,
) {
hasNext, hasPrev, rows, err := databasegen.New(s.conn).FindMessageByRoomID(ctx, databasegen.FindMessageByRoomIDParams{
Prev: prev,
Next: next,
Expand Down

0 comments on commit 47e9818

Please sign in to comment.