Skip to content

Commit

Permalink
Merge pull request #22 from depromeet/feature/letter
Browse files Browse the repository at this point in the history
🔨 fix(rooms): swagger dto 보안
  • Loading branch information
ImNM authored Apr 20, 2022
2 parents f7a7f03 + 25c5c67 commit ca6639c
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 3 deletions.
18 changes: 18 additions & 0 deletions src/apis/rooms/dto/shortCutRoomInfo.res.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { ApiProperty } from '@nestjs/swagger';
import { Types } from 'mongoose';
import { CATEGORY_TYPE } from 'src/common/consts/enum';
import { Room } from 'src/models/room.model';

export class ResShortCutRoomDto {
@ApiProperty()
_id: string;

@ApiProperty({ description: '채팅방 이름' })
name: string;

@ApiProperty({ enum: CATEGORY_TYPE, description: '카테고리정보' })
category: CATEGORY_TYPE;

@ApiProperty({ description: '채팅방내 유저숫자' })
userCount: number;
}
22 changes: 22 additions & 0 deletions src/apis/rooms/rooms.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ import { JwtAuthGuard } from 'src/auth/guards/jwt.guard';
import { SuccessInterceptor } from 'src/common/interceptors/sucess.interceptor';
import { ResChatAlarmToggleDto } from './dto/chatAlarmToggle.res.dto';
import { ResFavoriteToggleDto } from './dto/FavoriteToggle.res.dto';
import { Room } from 'src/models/room.model';
import { ResShortCutRoomDto } from './dto/shortCutRoomInfo.res.dto';

@ApiTags('rooms')
@Controller('rooms')
Expand Down Expand Up @@ -74,6 +76,16 @@ export class RoomsController {
//TODO : 안읽은 채팅 갯수 ?
@ApiOperation({ summary: '(채팅탭용)내 룸 정보 가져옴' })
@Get('/my/room')
@ApiResponse({
status: 200,
description: '요청 성공시',
type: ResShortCutRoomDto,
})
@ApiResponse({
status: 200,
description: '내 방이없으면',
type: null,
})
getMyRoomShortCutInfo(@ReqUser() user: User) {
// console.log(FindRoomDto);
// 경도lng 위도lat
Expand All @@ -82,6 +94,11 @@ export class RoomsController {

@ApiOperation({ summary: '(채팅탭용)내가 즐겨찾기한 채팅방 뽑아옴' })
@Get('/my/favorite')
@ApiResponse({
status: 200,
description: '요청 성공시',
type: [ResShortCutRoomDto],
})
getMyFavorite(@ReqUser() user: User) {
// console.log(FindRoomDto);
// 경도lng 위도lat
Expand All @@ -99,6 +116,11 @@ export class RoomsController {
}
@ApiOperation({ summary: '유저가 채팅방에 입장할 때 ( 모든 경우 사용)' })
@Post(':roomId/join')
@ApiResponse({
status: 200,
description: '요청 성공시',
type: ResFindOneRoomDto,
})
joinRoom(@Param() roomId: RoomIdDto, @ReqUser() user: User) {
// 조인 룸시에 다른 룸에서 자동으로 나가져야함
return this.roomsService.addUserToRoom(roomId, new UserIdDto(user._id));
Expand Down
6 changes: 3 additions & 3 deletions src/apis/rooms/rooms.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,9 @@ export class RoomsService {
async getMyRoomShortCutInfo(userId: UserIdDto) {
const roomInfo = await this.userRepository.getMyRoom(userId);
console.log(roomInfo);
if (!roomInfo) {
throw new BadRequestException('MyRoom does not exist');
}
// if (!roomInfo) {
// throw new BadRequestException('MyRoom does not exist');
// }
return roomInfo;
}
async getMyFavorite(userId: UserIdDto) {
Expand Down

0 comments on commit ca6639c

Please sign in to comment.