diff --git a/src/apis/rooms/dto/myRoomInfo.res.dto.ts b/src/apis/rooms/dto/myRoomInfo.res.dto.ts index 6e3e451..2111bc1 100644 --- a/src/apis/rooms/dto/myRoomInfo.res.dto.ts +++ b/src/apis/rooms/dto/myRoomInfo.res.dto.ts @@ -1,9 +1,10 @@ import { ApiProperty } from '@nestjs/swagger'; -import { Expose, Transform } from 'class-transformer'; +import { Exclude, Expose, Transform, Type } from 'class-transformer'; import { CATEGORY_TYPE } from 'src/common/consts/enum'; import { TransformObjectIdToString } from 'src/common/decorators/Expose.decorator'; import { toKRTimeZone } from 'src/common/funcs/toKRTimezone'; +import { Geometry } from 'src/models/room.model'; export class MyRoomInfoDto { @ApiProperty({ @@ -59,4 +60,21 @@ export class MyRoomInfoDto { ) @Expose() lastChatTime: Date | null; + + @Type(() => Geometry) + @Expose({ toClassOnly: true }) + @Exclude({ toPlainOnly: true }) + geometry: Geometry; + + @ApiProperty({ description: '위도 가로선', type: Number }) + @Expose() + get lat(): number { + return this.geometry.coordinates[0]; + } + + @ApiProperty({ description: '경도 세로선', type: Number }) + @Expose() + get lng(): number { + return this.geometry.coordinates[1]; + } } diff --git a/src/common/dtos/shortCutRoomInfo.res.dto.ts b/src/common/dtos/shortCutRoomInfo.res.dto.ts index 38ba775..dbb974a 100644 --- a/src/common/dtos/shortCutRoomInfo.res.dto.ts +++ b/src/common/dtos/shortCutRoomInfo.res.dto.ts @@ -1,8 +1,8 @@ import { ApiProperty } from '@nestjs/swagger'; -import { Expose, Transform } from 'class-transformer'; +import { Exclude, Expose, Transform, Type } from 'class-transformer'; import { Types } from 'mongoose'; import { CATEGORY_TYPE } from 'src/common/consts/enum'; -import { Room } from 'src/models/room.model'; +import { Geometry, Room } from 'src/models/room.model'; import { TransformObjectIdToString } from '../decorators/Expose.decorator'; export class ResShortCutRoomDto { @@ -26,4 +26,21 @@ export class ResShortCutRoomDto { @ApiProperty({ description: '채팅방내 유저숫자' }) @Expose() userCount: number; + + @Type(() => Geometry) + @Expose({ toClassOnly: true }) + @Exclude({ toPlainOnly: true }) + geometry: Geometry; + + @ApiProperty({ description: '위도 가로선', type: Number }) + @Expose() + get lat(): number { + return this.geometry.coordinates[0]; + } + + @ApiProperty({ description: '경도 세로선', type: Number }) + @Expose() + get lng(): number { + return this.geometry.coordinates[1]; + } } diff --git a/src/repositories/room.repository.ts b/src/repositories/room.repository.ts index 4546d47..befd6c2 100644 --- a/src/repositories/room.repository.ts +++ b/src/repositories/room.repository.ts @@ -233,6 +233,7 @@ export class RoomRepository { _id: 1, name: 1, category: 1, + geometry: 1, userCount: { $size: '$userList' }, }, }, diff --git a/src/repositories/user.repository.ts b/src/repositories/user.repository.ts index 2236b1d..0889318 100644 --- a/src/repositories/user.repository.ts +++ b/src/repositories/user.repository.ts @@ -323,6 +323,7 @@ export class UserRepository { _id: 1, name: 1, category: 1, + geometry: 1, userCount: { $size: '$userList' }, }, }, @@ -382,6 +383,7 @@ export class UserRepository { _id: 1, name: 1, category: 1, + geometry: 1, userCount: { $size: '$userList' }, }, },