1- import { Restaurant , FollowerStatus , Tag , $Enums , SavedRestaurant } from '@prisma/client' ;
1+ import {
2+ Restaurant ,
3+ FollowerStatus ,
4+ Tag ,
5+ $Enums ,
6+ SavedRestaurant ,
7+ } from '@prisma/client' ;
28import { Type } from 'class-transformer' ;
39import {
410 IsArray ,
@@ -13,6 +19,7 @@ import {
1319 IsOptional ,
1420} from 'class-validator' ;
1521import { ApiProperty } from '@nestjs/swagger' ;
22+ import { RestaurantEntity } from '@/restaurant/entity' ;
1623
1724export class RestaurantResponse {
1825 @ApiProperty ( {
@@ -82,6 +89,18 @@ export class RestaurantResponse {
8289 response . createdAt = restaurant . createdAt ;
8390 return response ;
8491 }
92+
93+ static fromEntity ( restaurant : RestaurantEntity ) : RestaurantResponse {
94+ return {
95+ id : restaurant . id ,
96+ placeId : restaurant . placeId ,
97+ name : restaurant . name ,
98+ address : restaurant . address ,
99+ latitude : restaurant . latitude ,
100+ longitude : restaurant . longitude ,
101+ createdAt : restaurant . createdAt ,
102+ } ;
103+ }
85104}
86105
87106export class RestaurantListResponse {
@@ -353,7 +372,7 @@ export class MypageTreeResponse {
353372
354373 @ApiProperty ( {
355374 description : '나무 높이' ,
356- example : 38
375+ example : 38 ,
357376 } )
358377 @IsNumber ( )
359378 @IsNotEmpty ( )
@@ -367,18 +386,34 @@ export class MypageTreeResponse {
367386 @IsNotEmpty ( )
368387 location : string ;
369388
370- constructor ( savedRestaurant : ( SavedRestaurant & { restaurant : Restaurant } ) ) {
371- this . restaurantId = savedRestaurant . restaurant . id
372- this . restaurantName = savedRestaurant . restaurant . name
373- this . recommendationCount = savedRestaurant . recommendedByUsers . length
374- this . location = savedRestaurant . restaurant . address
389+ @ApiProperty ( {
390+ description : '사용자가 보유한 전체 나무 개수에 따른 종합 요약 메시지' ,
391+ example : '뒷산이 부럽지 않을 만큼 풍성해졌어요' ,
392+ } )
393+ @IsString ( )
394+ @IsNotEmpty ( )
395+ recapMessage : string ;
396+
397+ @ApiProperty ( {
398+ description : '사용자가 보유한 전체 트리 개수에 따른 종합 요약 이미지 URL' ,
399+ example : 'https://example.com/images/level_2.png' ,
400+ } )
401+ @IsString ( )
402+ @IsNotEmpty ( )
403+ recapImageUrl : string | null ;
404+
405+ constructor ( savedRestaurant : SavedRestaurant & { restaurant : Restaurant } ) {
406+ this . restaurantId = savedRestaurant . restaurant . id ;
407+ this . restaurantName = savedRestaurant . restaurant . name ;
408+ this . recommendationCount = savedRestaurant . recommendedByUsers . length ;
409+ this . location = savedRestaurant . restaurant . address ;
375410 }
376411}
377412
378413export class MypageResponse {
379414 @ApiProperty ( {
380415 description : '유저 고유 ID' ,
381- example : 'user-uuid-1234'
416+ example : 'user-uuid-1234' ,
382417 } )
383418 @IsString ( )
384419 @IsNotEmpty ( )
@@ -406,23 +441,23 @@ export class MypageResponse {
406441 } )
407442 @IsNumber ( )
408443 @IsNotEmpty ( )
409- followerCount : number
444+ followerCount : number ;
410445
411446 @ApiProperty ( {
412447 description : '팔로잉 수' ,
413448 example : 100 ,
414449 } )
415450 @IsNumber ( )
416451 @IsNotEmpty ( )
417- followingCount : number
452+ followingCount : number ;
418453
419454 @ApiProperty ( {
420455 description : '내가 심은 나무 수' ,
421- example : 30
456+ example : 30 ,
422457 } )
423458 @IsNumber ( )
424459 @IsNotEmpty ( )
425- treeCount : number
460+ treeCount : number ;
426461
427462 @ApiProperty ( {
428463 description : '프로필 이미지' ,
@@ -440,7 +475,7 @@ export class MypageResponse {
440475 @IsOptional ( )
441476 @ValidateNested ( { each : true } )
442477 tags : Tag [ ] ;
443-
478+
444479 @ApiProperty ( {
445480 description : 'MBTI' ,
446481 example : 'ENFP' ,
@@ -469,7 +504,7 @@ export class MypageResponse {
469504 } )
470505 @IsNotEmpty ( )
471506 biggestTrees : MypageTreeResponse [ ] ;
472-
507+
473508 @ApiProperty ( {
474509 description : '내 트리 목록' ,
475510 type : [ MypageTreeResponse ] ,
@@ -504,4 +539,4 @@ export class CheckFollowingStatusDto {
504539 example : FollowerStatus . PENDING ,
505540 } )
506541 followRequestStatus : FollowerStatus ;
507- }
542+ }
0 commit comments