Skip to content

Commit

Permalink
[v1.0.9] 방정보에 subtitle 추가
Browse files Browse the repository at this point in the history
[v1.0.9] 방정보에 subtitle 추가
  • Loading branch information
ImNM authored Jul 31, 2022
2 parents 645d774 + 3ed0d61 commit 46725bb
Show file tree
Hide file tree
Showing 8 changed files with 161 additions and 140 deletions.
1 change: 1 addition & 0 deletions src/apis/rooms/dto/find-room.res.dto copy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export class ResFindRoomDto extends PickType(Room, [
'userList',
'geometry',
'userCount',
'subtitle'
] as const) {
@Expose({ toClassOnly: true })
@Exclude({ toPlainOnly: true })
Expand Down
3 changes: 2 additions & 1 deletion src/apis/rooms/dto/findOne-room.res.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export class ResFindOneRoomDto extends PickType(Room, [
'userList',
'geometry',
'userCount',
'subtitle'
] as const) {
@ApiProperty({ description: '내가 즐겨찾기 했는지', type: Boolean })
@Expose()
Expand All @@ -36,7 +37,7 @@ export class ResFindOneRoomDto extends PickType(Room, [
iAlarm: boolean;

@ApiProperty({ description: '유저명수' })
@Transform((value) => value.obj.userList.length, { toPlainOnly: true })
@Transform(value => value.obj.userList.length, { toPlainOnly: true })
@Expose()
userCount: number;
// get userCount(): number {
Expand Down
17 changes: 13 additions & 4 deletions src/apis/rooms/dto/myRoomInfo.res.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import { Geometry } from 'src/models/room.model';
export class MyRoomInfoDto {
@ApiProperty({
description: '방의 고유 아이디',
type: String,
type: String
})
@Transform((value) => value.obj._id, { toClassOnly: true })
@Transform(value => value.obj._id, { toClassOnly: true })
@TransformObjectIdToString({ toClassOnly: true })
@Expose()
_id: string;
Expand All @@ -29,10 +29,19 @@ export class MyRoomInfoDto {
@Expose()
userCount: number;

@ApiProperty({
description: '채팅방 부제목',
type: String,
nullable: true,
default: null
})
@Expose()
subtitle: string;

//추가됨
@ApiProperty({
description: '아직 읽지 않은 채팅 숫자 0이면 표시안하시면 됩니다.',
default: 0,
default: 0
})
@Expose()
notReadChatCount: number;
Expand All @@ -41,7 +50,7 @@ export class MyRoomInfoDto {
description: '최신 채팅 정보 채팅 dto로 하나 또는 null',
type: Chat,
nullable: true,
default: null,
default: null
})
@Type(() => Chat)
@Expose()
Expand Down
49 changes: 19 additions & 30 deletions src/apis/utils/utils.controller.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
import {
Body,
Controller,
Delete,
Get,
Post,
UseGuards,
} from '@nestjs/common';
import {
ApiBearerAuth,
ApiOperation,
ApiTags,
} from '@nestjs/swagger';
import { Body, Controller, Delete, Get, Post, UseGuards } from '@nestjs/common';
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
import { JwtAuthGuard } from 'src/auth/guards/jwt.guard';
import { CategoryDto } from 'src/common/dtos/Category.dto';
import { CategoryIdDto } from 'src/common/dtos/CategoryId.dto';
Expand All @@ -21,29 +10,29 @@ import { UtilsService } from './utils.service';
@ApiBearerAuth('accessToken')
@UseGuards(JwtAuthGuard)
export class UtilsController {
constructor(private readonly utilsService: UtilsService) { }
constructor(private readonly utilsService: UtilsService) {}

@ApiOperation({
summary: '카테고리 정보',
summary: '카테고리 정보'
})
@Get('category')
async getCategory() {
return await this.utilsService.findAllCategory()
return await this.utilsService.findAllCategory();
}

@ApiOperation({
summary: '카테고리 추가',
})
@Post('category')
async createCategory(@Body() categoryDto: CategoryDto): Promise<void> {
return await this.utilsService.createCategory(categoryDto)
}
// @ApiOperation({
// summary: '카테고리 추가',
// })
// @Post('category')
// async createCategory(@Body() categoryDto: CategoryDto): Promise<void> {
// return await this.utilsService.createCategory(categoryDto)
// }

@ApiOperation({
summary: '카테고리 삭제',
})
@Delete('category')
async deleteCategory(@Body() categoryIdDto: CategoryIdDto) {
return await this.utilsService.deleteCategory(categoryIdDto)
}
// @ApiOperation({
// summary: '카테고리 삭제',
// })
// @Delete('category')
// async deleteCategory(@Body() categoryIdDto: CategoryIdDto) {
// return await this.utilsService.deleteCategory(categoryIdDto)
// }
}
13 changes: 11 additions & 2 deletions src/common/dtos/shortCutRoomInfo.res.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { TransformObjectIdToString } from '../decorators/Expose.decorator';
export class ResShortCutRoomDto {
@ApiProperty({
description: '방의 고유 아이디',
type: String,
type: String
})
@Transform((value) => value.obj._id, { toClassOnly: true })
@Transform(value => value.obj._id, { toClassOnly: true })
@TransformObjectIdToString({ toClassOnly: true })
@Expose()
_id: string;
Expand All @@ -32,6 +32,15 @@ export class ResShortCutRoomDto {
@Exclude({ toPlainOnly: true })
geometry: Geometry;

@ApiProperty({
description: '채팅방 부제목',
type: String,
nullable: true,
default: null
})
@Expose()
subtitle: string;

@ApiProperty({ description: '위도 가로선', type: Number })
@Expose()
get lat(): number {
Expand Down
39 changes: 21 additions & 18 deletions src/models/room.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
IsNotEmpty,
IsNumber,
IsObject,
IsString,
IsString
} from 'class-validator';
import { Prop, Schema, SchemaFactory, SchemaOptions } from '@nestjs/mongoose';
import { CATEGORY_TYPE } from 'src/common/consts/enum';
Expand All @@ -18,7 +18,7 @@ import { UserProfileDto } from 'src/common/dtos/UserProfile.dto';
const options: SchemaOptions = {
// rooms default 로 s 붙여지는데 디폴트로가는게 좋을것 같아요! (이찬진)
collection: 'room',
timestamps: true,
timestamps: true
};

@Schema({ _id: false })
Expand All @@ -40,24 +40,24 @@ export class Geometry {
export class Room {
@ApiProperty({
description: '유저의 고유아이디',
type: String,
type: String
})
// 시리얼 라이제이션 할때 사용
@TransformObjectIdToString({ toPlainOnly: true })
@Transform((value) => value.obj._id, { toClassOnly: true })
@Transform(value => value.obj._id, { toClassOnly: true })
@Type(() => Types.ObjectId)
@Expose()
_id: Types.ObjectId;

@Prop({
required: true,
type: String,
type: String
})
@ApiProperty({
type: String,
title: '채팅방 이름',
description: '채팅방의 이름입니다',
example: '홍익대학교',
example: '홍익대학교'
})
@IsNotEmpty()
@IsString()
Expand All @@ -66,14 +66,14 @@ export class Room {

@Prop({
required: true,
enum: CATEGORY_TYPE,
enum: CATEGORY_TYPE
})
@ApiProperty({
enum: CATEGORY_TYPE,
title: '카테고리',
description:
'카테고리를 나타내는 상태입니다. 기획안 따라 지속적으로 추가할 예정입니다.',
example: 'UNIVERCITY',
example: 'UNIVERCITY'
})
@IsNotEmpty()
@IsEnum(CATEGORY_TYPE)
Expand All @@ -85,7 +85,7 @@ export class Room {
type: Number,
title: '반경정보',
description: '미터 단위의 반경정보입니다',
example: 2000,
example: 2000
})
@IsNotEmpty()
@IsNumber()
Expand All @@ -94,15 +94,15 @@ export class Room {

@Prop({
required: true,
type: [{ type: Types.ObjectId, ref: 'User' }],
type: [{ type: Types.ObjectId, ref: 'User' }]
})
@ApiProperty({
type: [UserProfileDto],
title: '방에들어간 유저 리스트 정보',
title: '방에들어간 유저 리스트 정보'
})
@IsNotEmpty()
@IsArray()
@Transform((value) => value.obj.userList, { toClassOnly: true })
@Transform(value => value.obj.userList, { toClassOnly: true })
@Type(() => UserProfileDto)
@Expose()
userList: UserProfileDto[];
Expand All @@ -115,7 +115,7 @@ export class Room {
@IsObject()
@Prop({
type: Geometry,
index: '2dsphere',
index: '2dsphere'
})
@Type(() => Geometry)
@Expose({ toClassOnly: true })
Expand All @@ -130,12 +130,15 @@ export class Room {
@Expose()
userCount: number;

@ApiProperty({ description: '채팅방 부제목' })
@Prop({ required: false, type: String, default: "" })
@IsNotEmpty()
@IsString()
@ApiProperty({
description: '채팅방 부제목',
type: String,
nullable: true,
default: null
})
@Prop({ required: false, type: String, default: null })
@Expose()
subtitle: string
subtitle: string;
}

const _RoomSchema = SchemaFactory.createForClass(Room);
Expand Down
10 changes: 7 additions & 3 deletions src/repositories/room.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ export class RoomRepository {
userCount: { $size: '$userList' },
radius: 1,
distance: 1,
geometry: 1
geometry: 1,
subtitle: 1
}
}
// 몽고디비 디폴트 100개임 최대 100개를 뽑아올수있는데 여기서 조정을 해야함
Expand Down Expand Up @@ -102,7 +103,8 @@ export class RoomRepository {
userCount: { $size: '$userList' },
radius: 1,
distance: 1,
geometry: 1
geometry: 1,
subtitle: 1
}
}
// 몽고디비 디폴트 100개임 최대 100개를 뽑아올수있는데 여기서 조정을 해야함
Expand Down Expand Up @@ -143,7 +145,8 @@ export class RoomRepository {
userCount: { $size: '$userList' },
radius: 1,
distance: 1,
geometry: 1
geometry: 1,
subtitle: 1
}
}
// 몽고디비 디폴트 100개임 최대 100개를 뽑아올수있는데 여기서 조정을 해야함
Expand Down Expand Up @@ -234,6 +237,7 @@ export class RoomRepository {
name: 1,
category: 1,
geometry: 1,
subtitle: 1,
userCount: { $size: '$userList' }
}
},
Expand Down
Loading

0 comments on commit 46725bb

Please sign in to comment.