Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
5770bd7
chore: review 코드 리팩토링
Jjoobob123 Apr 3, 2023
cf4d179
shopImage 코드 리팩토링
Jjoobob123 Apr 4, 2023
a4682aa
chore: shop 코드 리팩토링
Jjoobob123 Apr 4, 2023
cace6b8
Merge pull request #223 from Jjoobob123/chore-#219
cabbage556 Apr 4, 2023
12cee16
Merge pull request #228 from Jjoobob123/chore-#224
cabbage556 Apr 4, 2023
937dafc
user 코드 리팩토링
Jjoobob123 Apr 4, 2023
f100d77
Merge pull request #230 from Jjoobob123/chore-#229
Jjoobob123 Apr 4, 2023
db545e4
release: logstash schedule 수정
cabbage556 Apr 4, 2023
6c268b2
Merge pull request #1 from cabbage556/release-#232
cabbage556 Apr 4, 2023
f46735a
release: 서버 배포 버전 수정
cabbage556 Apr 4, 2023
e531021
Merge pull request #4 from cabbage556/release-#233
cabbage556 Apr 4, 2023
dc2a1a7
test: updateDog 테스트코드 삭제
cabbage556 Apr 4, 2023
b279420
fix: findOne, findUserDog 서비스 로직 추가
cabbage556 Apr 5, 2023
ef56ea8
Merge pull request #6 from cabbage556/fix-#237
cabbage556 Apr 5, 2023
d467400
release: 유저서비스 findOne, fetchUserDog 서비스 로직 수정 배포
cabbage556 Apr 5, 2023
bb29225
Merge pull request #7 from cabbage556/release-#239
cabbage556 Apr 5, 2023
c0ff26e
Merge pull request #241 from cabbage556/develop
cabbage556 Apr 8, 2023
24027be
Merge pull request #236 from cabbage556/test-#235
cabbage556 Apr 8, 2023
af0b053
readme: readme 수정
cabbage556 Apr 8, 2023
5b3c926
Merge pull request #242 from cabbage556/readme-#240
cabbage556 Apr 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
426 changes: 216 additions & 210 deletions README.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ steps:
- set
- image
- deployment/groomeong-backend
- backend-sha256-1=asia.gcr.io/project-groomeong/backend:2.5
- backend-sha256-1=asia.gcr.io/project-groomeong/backend:2.7
env:
- CLOUDSDK_COMPUTE_ZONE=asia-northeast3
- CLOUDSDK_CONTAINER_CLUSTER=autopilot-cluster-5
Expand All @@ -26,7 +26,7 @@ steps:
- set
- image
- deployment/groomeong-logstash
- logstash-sha256-1=asia.gcr.io/project-groomeong/logstash:1.2
- logstash-sha256-1=asia.gcr.io/project-groomeong/logstash:1.3
env:
- CLOUDSDK_COMPUTE_ZONE=asia-northeast3
- CLOUDSDK_CONTAINER_CLUSTER=autopilot-cluster-5
4 changes: 2 additions & 2 deletions docker-compose.prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ version: '3.7'

services:
my-backend:
image: asia.gcr.io/project-groomeong/backend:2.5
image: asia.gcr.io/project-groomeong/backend:2.7
platform: linux/x86_64
build:
context: .
dockerfile: Dockerfile.prod

logstash:
image: asia.gcr.io/project-groomeong/logstash:1.2
image: asia.gcr.io/project-groomeong/logstash:1.3
platform: linux/x86_64
build:
context: .
Expand Down
2 changes: 1 addition & 1 deletion elk/logstash/logstash.prod.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ input {
jdbc_connection_string => "jdbc:mysql://10.42.208.3:3306/prod" # jdbc:mysql://SQL인스턴스비공개IP주소:포트번호/db이름
jdbc_user => "root"
jdbc_password => "root"
schedule => "*/30 * * * *"
schedule => "*/5 * * * *"
use_column_value => true
tracking_column => "updatedat"
tracking_column_type => "numeric"
Expand Down
14 changes: 0 additions & 14 deletions src/apis/dogs/__test__/dogs.mocking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,3 @@ export const MOCK_DOG = {
deletedAt: null,
userId: 'c84fa63e-7a05-4cd5-b015-d4db9a262b18',
};

export const UPDATED_MOCK_DOG = {
id: '3ce6246c-f37a-426e-b95a-b38ec6d55f4e',
name: '댕댕이',
age: 5,
weight: 10.5,
breed: DOG_TYPE.LARGE,
specifics: '성격이 착해요',
image:
'https://storage.cloud.google.com/groomeong-storage/origin/dog/a6c16f50-2946-4dfb-9785-a782cea6c570/%03b%EF%BF%BD2.jpeg',
createdAt: '2023-03-21 12:13:02.011088',
deletedAt: null,
userId: 'c84fa63e-7a05-4cd5-b015-d4db9a262b18',
};
62 changes: 1 addition & 61 deletions src/apis/dogs/__test__/dogs.resolver.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ import * as httpMocks from 'node-mocks-http';
import { IContext } from 'src/commons/interface/context';
import { User } from 'src/apis/users/entities/user.entity';
import { CreateDogInput } from '../dto/create-dog.input';
import { UpdateDogInput } from '../dto/update-dog.input';
import { MOCK_DOG, MOCK_USER, UPDATED_MOCK_DOG } from './dogs.mocking';
import { MOCK_DOG, MOCK_USER } from './dogs.mocking';
import { getRepositoryToken } from '@nestjs/typeorm';
import { Dog } from '../entities/dog.entity';
import { DOG_TYPE } from '../enum/dog-type.enum';

describe('DogsResolver', () => {
let dogsResolver: DogsResolver;
Expand Down Expand Up @@ -146,64 +144,6 @@ describe('DogsResolver', () => {
});
});

describe('updateDog', () => {
const updateDogInput: UpdateDogInput = {
weight: UPDATED_MOCK_DOG.weight,
breed: UPDATED_MOCK_DOG.breed,
};

it('업데이트한 강아지 정보를 리턴해야 함', async () => {
mockDogsRepository.findOne.mockImplementation(
(where: { id: string }, relations: { user: true }) => MOCK_DOG,
);
mockDogsService.findOneById.mockImplementation((id: string) => MOCK_DOG);
mockDogsRepository.save.mockImplementation(
(
id: string,
name: string,
age: number,
weight: number,
breed: DOG_TYPE,
specifics: string,
image: string,
createdAt: Date,
deleledAt: Date,
userId: string,
) => UPDATED_MOCK_DOG,
);
mockDogsService.updateOneById.mockImplementation(
(id: string, updateDogInput: UpdateDogInput) => UPDATED_MOCK_DOG,
);

const result = await dogsResolver.updateDog(MOCK_DOG.id, updateDogInput);
expect(result).toEqual(UPDATED_MOCK_DOG);
expect(mockDogsService.updateOneById).toHaveBeenCalledWith({
id: MOCK_DOG.id,
updateDogInput,
});
});

it('NotFoundException을 던져야 함', () => {
const invalidMockId = '3ce6246c-f37a-426e-b95a-b38ec6d55f4f';
mockDogsRepository.findOne.mockImplementation(
(where: { id: string }) => null,
);

try {
dogsResolver.updateDog(invalidMockId, updateDogInput);
} catch (error) {
expect(error).toBeInstanceOf(NotFoundException);
expect(error.message).toBe(
`id ${invalidMockId}를 갖는 강아지를 찾을 수 없음`,
);
}
expect(mockDogsService.updateOneById).toHaveBeenCalledWith({
id: invalidMockId,
updateDogInput,
});
});
});

describe('deleteDog', () => {
it('삭제 여부 true를 반환해야 함', async () => {
mockDogsRepository.findOne.mockImplementation(
Expand Down
28 changes: 16 additions & 12 deletions src/apis/reviews/reviews.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Review> {
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, //
Expand All @@ -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,
Expand All @@ -54,9 +57,10 @@ export class ReviewsResolver {
});
}

@Mutation(() => Boolean, {
description: 'Return: 리뷰 삭제 후 true 반환',
})
@Mutation(
() => Boolean, //
{ description: 'Return: 리뷰 삭제 후 true 반환' },
)
deleteReview(
@Args('reviewId') id: string, //
): Promise<boolean> {
Expand Down
2 changes: 0 additions & 2 deletions src/apis/reviews/reviews.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export class ReviewsService {
private readonly shopsService: ShopsService,
) {}

// 리뷰 가져오기
async find({ reviewId }: IReviewServiceFindById): Promise<Review> {
const result = await this.reviewsRepository.findOne({
where: { id: reviewId },
Expand All @@ -37,7 +36,6 @@ export class ReviewsService {
return result;
}

// 가게의 모든 리뷰 가져오기
async findByShopIdWithPage({
page,
count, //
Expand Down
16 changes: 0 additions & 16 deletions src/apis/shopImages/dto/save-shopImage.input.ts

This file was deleted.

41 changes: 25 additions & 16 deletions src/apis/shopImages/shopImage.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ShopImage> {
return this.shopImagesService.findThumbnailByShopId({ shopId });
}

@Query(() => [ShopImage], {
description: 'Return: 입력한 가게의 모든 가게이미지',
})
@Query(
() => [ShopImage], //
{ description: 'Return: 입력한 가게의 모든 가게이미지' },
)
fetchShopImagesByShop(
@Args('shopId') shopId: string, //
): Promise<ShopImage[]> {
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<ShopImage> {
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<ShopImage> {
return await this.shopImagesService.update({ updateShopImageInput });
}

@Mutation(() => Boolean, {
description: 'Return: 가게 이미지 삭제 완료 시, true',
})
@Mutation(
() => Boolean, //
{ description: 'Return: 가게 이미지 삭제 완료 시, true' },
)
deleteShopImage(
@Args('shopImageId') shopImageId: string, //
): Promise<boolean> {
Expand Down
15 changes: 2 additions & 13 deletions src/apis/shopImages/shopImage.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
ConflictException,
Injectable,
NotFoundException,
UnprocessableEntityException,
} from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
Expand All @@ -24,7 +23,6 @@ export class ShopImagesService {
private readonly shopsService: ShopsService,
) {}

// 가게ID로 썸네일 찾기
async findThumbnailByShopId({
shopId,
}: IShopImagesServiceFindThumbnail): Promise<ShopImage> {
Expand All @@ -44,7 +42,6 @@ export class ShopImagesService {
});
}

// 가게ID로 해당 이미지 찾기
async findByShopId({
shopId,
}: IShopImagesServiceFindByShopId): Promise<ShopImage[]> {
Expand All @@ -61,8 +58,7 @@ export class ShopImagesService {
});
}

// DB테이블에 신규 이미지 저장
async save({
async create({
imageUrl,
isThumbnail,
shopId,
Expand All @@ -81,7 +77,6 @@ export class ShopImagesService {
});
}

// DB테이블에서 이미지 업데이트
async update({
updateShopImageInput,
}: IShopImagesServiceUpdate): Promise<ShopImage> {
Expand All @@ -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<boolean> {
const checkImage = await this.shopImageRepository.findOne({
where: { id: shopImageId },
Expand All @@ -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;
}
Expand Down
Loading