Skip to content

Commit

Permalink
Merge pull request #75 from depromeet/dev
Browse files Browse the repository at this point in the history
🔨 fix(room) : popular, favorite , myroom info (used in chat Ta…
  • Loading branch information
ImNM authored May 28, 2022
2 parents ec5a9d6 + 8bda45b commit d7e3636
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
20 changes: 19 additions & 1 deletion src/apis/rooms/dto/myRoomInfo.res.dto.ts
Original file line number Diff line number Diff line change
@@ -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({
Expand Down Expand Up @@ -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];
}
}
21 changes: 19 additions & 2 deletions src/common/dtos/shortCutRoomInfo.res.dto.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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];
}
}
1 change: 1 addition & 0 deletions src/repositories/room.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ export class RoomRepository {
_id: 1,
name: 1,
category: 1,
geometry: 1,
userCount: { $size: '$userList' },
},
},
Expand Down
2 changes: 2 additions & 0 deletions src/repositories/user.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ export class UserRepository {
_id: 1,
name: 1,
category: 1,
geometry: 1,
userCount: { $size: '$userList' },
},
},
Expand Down Expand Up @@ -382,6 +383,7 @@ export class UserRepository {
_id: 1,
name: 1,
category: 1,
geometry: 1,
userCount: { $size: '$userList' },
},
},
Expand Down

0 comments on commit d7e3636

Please sign in to comment.