diff --git a/src/apis/reviews/reviews.resolver.ts b/src/apis/reviews/reviews.resolver.ts index 56619ff..5e5a2b0 100644 --- a/src/apis/reviews/reviews.resolver.ts +++ b/src/apis/reviews/reviews.resolver.ts @@ -12,18 +12,20 @@ export class ReviewsResolver { private readonly reviewsService: ReviewsService, // ) {} - @Query(() => Review, { - description: 'Return: 리뷰ID 기준으로 1개 불러오기', - }) + @Query( + () => Review, // + { description: 'Return: 리뷰ID 기준으로 1개 불러오기' }, + ) fetchReview( @Args('reviewId') reviewId: string, // ): Promise { return this.reviewsService.find({ reviewId }); } - @Query(() => [Review], { - description: 'Return: 가게ID 기준으로 모든 리뷰 불러오기', - }) + @Query( + () => [Review], // + { description: 'Return: 가게ID 기준으로 모든 리뷰 불러오기' }, + ) async fetchReviewsByShopId( @Args({ name: 'page', defaultValue: 1, nullable: true }) page: number, // @@ -40,9 +42,10 @@ export class ReviewsResolver { } @UseGuards(GqlAuthGuard('access')) - @Mutation(() => Review, { - description: 'Return: 신규 생성된 리뷰 데이터', - }) + @Mutation( + () => Review, // + { description: 'Return: 신규 생성된 리뷰 데이터' }, + ) createReview( @Args('createReviewInput') createReviewInput: CreateReviewInput, // @Context() context: IContext, @@ -54,9 +57,10 @@ export class ReviewsResolver { }); } - @Mutation(() => Boolean, { - description: 'Return: 리뷰 삭제 후 true 반환', - }) + @Mutation( + () => Boolean, // + { description: 'Return: 리뷰 삭제 후 true 반환' }, + ) deleteReview( @Args('reviewId') id: string, // ): Promise { diff --git a/src/apis/reviews/reviews.service.ts b/src/apis/reviews/reviews.service.ts index ca96de7..5e57d8b 100644 --- a/src/apis/reviews/reviews.service.ts +++ b/src/apis/reviews/reviews.service.ts @@ -23,7 +23,6 @@ export class ReviewsService { private readonly shopsService: ShopsService, ) {} - // 리뷰 가져오기 async find({ reviewId }: IReviewServiceFindById): Promise { const result = await this.reviewsRepository.findOne({ where: { id: reviewId }, @@ -37,7 +36,6 @@ export class ReviewsService { return result; } - // 가게의 모든 리뷰 가져오기 async findByShopIdWithPage({ page, count, // diff --git a/src/apis/shopImages/shopImage.resolver.ts b/src/apis/shopImages/shopImage.resolver.ts index aa5bc39..e41cce5 100644 --- a/src/apis/shopImages/shopImage.resolver.ts +++ b/src/apis/shopImages/shopImage.resolver.ts @@ -9,47 +9,56 @@ export class ShopImagesResolver { private readonly shopImagesService: ShopImagesService, // ) {} - @Query(() => ShopImage, { - description: 'Return: 입력한 가게의 썸네일 가게이미지(1개)', - }) + @Query( + () => ShopImage, // + { description: 'Return: 입력한 가게의 썸네일 가게이미지(1개)' }, + ) fetchThumbnailByShop( @Args('shopId') shopId: string, // ): Promise { return this.shopImagesService.findThumbnailByShopId({ shopId }); } - @Query(() => [ShopImage], { - description: 'Return: 입력한 가게의 모든 가게이미지', - }) + @Query( + () => [ShopImage], // + { description: 'Return: 입력한 가게의 모든 가게이미지' }, + ) fetchShopImagesByShop( @Args('shopId') shopId: string, // ): Promise { return this.shopImagesService.findByShopId({ shopId }); } - @Mutation(() => ShopImage, { - description: 'Return: 신규 생성된 가게이미지 데이터', - }) + @Mutation( + () => ShopImage, // + { description: 'Return: 신규 생성된 가게이미지 데이터' }, + ) async createShopImage( @Args('imageUrl') imageUrl: string, @Args('isThumbnail') isThumbnail: boolean, @Args('shopId') shopId: string, ): Promise { - return await this.shopImagesService.save({ imageUrl, isThumbnail, shopId }); + return await this.shopImagesService.create({ + imageUrl, + isThumbnail, + shopId, + }); } - @Mutation(() => ShopImage, { - description: 'Return: 업데이트된 가게이미지 데이터', - }) + @Mutation( + () => ShopImage, // + { description: 'Return: 업데이트된 가게이미지 데이터' }, + ) async updateShopImage( @Args('updateShopImageInput') updateShopImageInput: UpdateShopImageInput, ): Promise { return await this.shopImagesService.update({ updateShopImageInput }); } - @Mutation(() => Boolean, { - description: 'Return: 가게 이미지 삭제 완료 시, true', - }) + @Mutation( + () => Boolean, // + { description: 'Return: 가게 이미지 삭제 완료 시, true' }, + ) deleteShopImage( @Args('shopImageId') shopImageId: string, // ): Promise { diff --git a/src/apis/shopImages/shopImage.service.ts b/src/apis/shopImages/shopImage.service.ts index cff94d0..67c9508 100644 --- a/src/apis/shopImages/shopImage.service.ts +++ b/src/apis/shopImages/shopImage.service.ts @@ -1,7 +1,6 @@ import { ConflictException, Injectable, - NotFoundException, UnprocessableEntityException, } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; @@ -24,7 +23,6 @@ export class ShopImagesService { private readonly shopsService: ShopsService, ) {} - // 가게ID로 썸네일 찾기 async findThumbnailByShopId({ shopId, }: IShopImagesServiceFindThumbnail): Promise { @@ -44,7 +42,6 @@ export class ShopImagesService { }); } - // 가게ID로 해당 이미지 찾기 async findByShopId({ shopId, }: IShopImagesServiceFindByShopId): Promise { @@ -61,8 +58,7 @@ export class ShopImagesService { }); } - // DB테이블에 신규 이미지 저장 - async save({ + async create({ imageUrl, isThumbnail, shopId, @@ -81,7 +77,6 @@ export class ShopImagesService { }); } - // DB테이블에서 이미지 업데이트 async update({ updateShopImageInput, }: IShopImagesServiceUpdate): Promise { @@ -90,14 +85,10 @@ export class ShopImagesService { imageUrl: updateShopImageInput.imageUrl, }); return await this.shopImageRepository.save({ - id: updateShopImageInput.id, - imageUrl: updateShopImageInput.imageUrl, - isThumbnail: updateShopImageInput.isThumbnail, - shop: { id: updateShopImageInput.shopId }, + ...updateShopImageInput, }); } - // DB테이블에서 이미지 삭제 async delete({ shopImageId }: IShopImagesServiceDelete): Promise { const checkImage = await this.shopImageRepository.findOne({ where: { id: shopImageId }, @@ -108,12 +99,10 @@ export class ShopImagesService { `가게이미지ID가 ${shopImageId}인 이미지를 찾을 수 없습니다`, ); } - console.log('찾았음'); const result = await this.shopImageRepository.delete({ id: shopImageId, }); - console.log('✨✨✨ 삭제 완료 ✨✨✨'); return result.affected ? true : false; }