Skip to content

Commit

Permalink
Merge pull request #41 from depromeet/refactor/rooms
Browse files Browse the repository at this point in the history
Refactor/rooms
  • Loading branch information
ImNM authored May 6, 2022
2 parents a0ccf3a + dc2f14d commit c191722
Show file tree
Hide file tree
Showing 20 changed files with 261 additions and 335 deletions.
Binary file removed public/.DS_Store
Binary file not shown.
7 changes: 0 additions & 7 deletions public/css/styles.css

This file was deleted.

64 changes: 0 additions & 64 deletions public/js/scripts.js

This file was deleted.

2 changes: 0 additions & 2 deletions src/apis/letter/letter.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ import { SuccessInterceptor } from 'src/common/interceptors/sucess.interceptor';
@Controller('letters')
@ApiBearerAuth('accessToken')
@UseGuards(JwtAuthGuard)
@UseInterceptors(ClassSerializerInterceptor)
@UseInterceptors(SuccessInterceptor)
export class LetterController {
constructor(private readonly letterService: LetterService) {}

Expand Down
2 changes: 0 additions & 2 deletions src/apis/questions/questions.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ import { QuestionsService } from './questions.service';
@ApiTags('questions')
@Controller('questions')
@ApiBearerAuth('accessToken')
@UseInterceptors(ClassSerializerInterceptor)
@UseInterceptors(SuccessInterceptor)
@UseGuards(JwtAuthGuard)
export class QuestionsController {
constructor(private readonly questionService: QuestionsService) {}
Expand Down
74 changes: 32 additions & 42 deletions src/apis/rooms/dto/find-room.res.dto copy.ts
Original file line number Diff line number Diff line change
@@ -1,50 +1,40 @@
import { ApiProperty } from '@nestjs/swagger';
import { Types } from 'mongoose';
import { CATEGORY_TYPE } from 'src/common/consts/enum';
import { ApiProperty, PickType } from '@nestjs/swagger';
import { Exclude, Expose } from 'class-transformer';
import { UserProfileDto } from 'src/common/dtos/UserProfile.dto';
import { Room } from 'src/models/room.model';

export class ResFindRoomDto {
constructor(room: Room, iFavorite: boolean, iJoin: boolean) {
this._id = room._id;
this.category = room.category;
this.name = room.name;
this.radius = room.radius;
this.lat = room.geometry.coordinates[0];
this.lng = room.geometry.coordinates[1];
this.userCount = room.userCount;
this.distance = room.distance;
this.iFavorite = iFavorite;
this.iJoin = iJoin;
}
@ApiProperty()
_id: string;

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

@ApiProperty({ description: '반경정보' })
radius: number;

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

@ApiProperty()
lat: number;

@ApiProperty()
lng: number;

@ApiProperty({ description: '채팅방내 유저숫자' })
userCount: number;

@ApiProperty({ description: '거리정보' })
distance: number;

@ApiProperty({ description: '내가 즐겨찾기 했는지' })
export class ResFindRoomDto extends PickType(Room, [
'_id',
'name',
'category',
'radius',
'userList',
'geometry',
'userCount',
] as const) {
@Expose({ toClassOnly: true })
@Exclude({ toPlainOnly: true })
userList: UserProfileDto[];

@ApiProperty({ description: '내가 즐겨찾기 했는지', type: Boolean })
@Expose()
iFavorite: boolean;

@ApiProperty({ description: '내가 들어가 있는지' })
@ApiProperty({ description: '내가 들어가 있는지', type: Boolean })
@Expose()
iJoin: boolean;

@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];
}
}
// console.log(plainToClass(User, fromPlainUser, { excludeExtraneousValues: true }));
// '_id',
Expand Down
159 changes: 76 additions & 83 deletions src/apis/rooms/dto/findOne-room.res.dto.ts
Original file line number Diff line number Diff line change
@@ -1,98 +1,91 @@
import { Room } from 'src/models/room.model';
import { ApiProperty, PickType } from '@nestjs/swagger';
import { Expose, plainToClass, plainToInstance } from 'class-transformer';
import { Types } from 'mongoose';
import { CATEGORY_TYPE } from 'src/common/consts/enum';
import { Expose, Transform } from 'class-transformer';

export class ResFindOneRoomDto extends PickType(Room, [
'_id',
'name',
'category',
'radius',
'userList',
'geometry',
'userCount',
] as const) {
@ApiProperty({ description: '내가 즐겨찾기 했는지', type: Boolean })
@Expose()
iFavorite: boolean;

@ApiProperty({ description: '내가 들어가 있는지', type: Boolean })
@Expose()
iJoin: boolean;

import { UserProfileDto } from 'src/common/dtos/UserProfile.dto';
import { Room } from 'src/models/room.model';
@ApiProperty({ description: '위도 가로선', type: Number })
@Expose()
get lat(): number {
return this.geometry.coordinates[0];
}

export class ResFindOneRoomDto {
constructor(room: Room, iFavoriteRoom: boolean, iAlarm: boolean) {
this._id = room._id;
this.category = room.category;
this.name = room.name;
this.radius = room.radius;
this.lat = room.geometry.coordinates[0];
this.lng = room.geometry.coordinates[1];
this.iFavoriteRoom = iFavoriteRoom;
this.iAlarm = iAlarm;
this.userCount = room.userList.length;
this.userList = room.userList;
@ApiProperty({ description: '경도 세로선', type: Number })
@Expose()
get lng(): number {
return this.geometry.coordinates[1];
}
@ApiProperty()
_id: string;

@ApiProperty()
name: string;
@ApiProperty({ description: '내가 채팅방 알림 켰는지여부' })
@Expose()
iAlarm: boolean;

@ApiProperty({ description: '유저명수' })
@Transform((value) => value.obj.userList.length, { toPlainOnly: true })
@Expose()
userCount: number;
// get userCount(): number {
// return 0;
// }
}
// export class ResFindOneRoomDto {
// constructor(room: Room, iFavoriteRoom: boolean, iAlarm: boolean) {
// this._id = room._id;
// this.category = room.category;
// this.name = room.name;
// this.radius = room.radius;
// this.lat = room.geometry.coordinates[0];
// this.lng = room.geometry.coordinates[1];
// this.iFavoriteRoom = iFavoriteRoom;
// this.iAlarm = iAlarm;
// this.userCount = room.userList.length;
// this.userList = room.userList;
// }
// @ApiProperty()
// _id: string;

@ApiProperty()
radius: number;
// @ApiProperty()
// name: string;

@ApiProperty({ enum: CATEGORY_TYPE })
category: CATEGORY_TYPE;
// @ApiProperty()
// radius: number;

@ApiProperty()
lat: number;
// @ApiProperty({ enum: CATEGORY_TYPE })
// category: CATEGORY_TYPE;

@ApiProperty()
lng: number;
// @ApiProperty()
// lat: number;

@ApiProperty({ type: [UserProfileDto], required: false })
userList: UserProfileDto[];
// @ApiProperty()
// lng: number;

@ApiProperty({ description: '유저 숫자' })
userCount: number;
// @ApiProperty({ type: [UserProfileDto], required: false })
// userList: UserProfileDto[];

@ApiProperty({ description: '내가 즐겨찾기 했는지' })
iFavoriteRoom: boolean;
// @ApiProperty({ description: '유저 숫자' })
// userCount: number;

@ApiProperty({ description: '내가 들어가 있는지' })
iJoin: boolean;
// @ApiProperty({ description: '내가 즐겨찾기 했는지' })
// iFavoriteRoom: boolean;

@ApiProperty({ description: '내가 채팅방 알림 켰는지여부' })
iAlarm: boolean;
}
// @ApiProperty({ description: '내가 들어가 있는지' })
// iJoin: boolean;

// '_id',
// 'name',
// 'radius',
// 'category',

// export class UserShowDto {
// // (1)
// @Exclude() private readonly _id: number;
// @Exclude() private readonly _firstName: string;
// @Exclude() private readonly _lastName: string;
// @Exclude() private readonly _orderDateTime: LocalDateTime;

// constructor(user: User) {
// this._id = user.id;
// this._firstName = user.firstName;
// this._lastName = user.lastName;
// this._orderDateTime = user.orderDateTime.plusDays(1); // (2)
// }

// @ApiProperty()
// @Expose() // (3)
// get id(): number {
// return this._id;
// }

// @ApiProperty()
// @Expose()
// get firstName(): string {
// return this._firstName;
// }

// @ApiProperty()
// @Expose()
// get lastName(): string {
// return this._lastName;
// }

// @ApiProperty()
// @Expose()
// get orderDateTime(): string {
// return DateTimeUtil.toString(this._orderDateTime); // (4)
// }
// }
// @ApiProperty({ description: '내가 채팅방 알림 켰는지여부' })
// iAlarm: boolean;
// }
11 changes: 11 additions & 0 deletions src/apis/rooms/dto/leftRoomResult.res.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { ApiProperty } from '@nestjs/swagger';
import { Expose } from 'class-transformer';

export class LeftRoomResultResDto {
@ApiProperty({
example: true,
description: '방떠난거 성공여부',
})
@Expose()
leftSuccess: boolean;
}
2 changes: 1 addition & 1 deletion src/apis/rooms/rooms.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
SerializeOptions,
UseGuards,
UseInterceptors,
ClassSerializerInterceptor,
} from '@nestjs/common';
import { RoomsService } from './rooms.service';
import { CreateRoomDto } from './dto/create-room.dto';
Expand Down Expand Up @@ -46,7 +47,6 @@ import { ResShortCutRoomDto } from 'src/common/dtos/shortCutRoomInfo.res.dto';
@Controller('rooms')
@ApiBearerAuth('accessToken')
@UseGuards(JwtAuthGuard)
@UseInterceptors(SuccessInterceptor)
export class RoomsController {
constructor(private readonly roomsService: RoomsService) {}

Expand Down
Loading

0 comments on commit c191722

Please sign in to comment.