Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PlaceRepository에서 Repository 대신 SoftDeleteRepository로 리팩토링 #59

Merged
merged 6 commits into from
Nov 6, 2024

Conversation

koomchang
Copy link
Collaborator

@koomchang koomchang commented Nov 6, 2024

📄 Summary

  • SoftDeleteRepository에서 where 절을 배열로 받는 경우 처리를 위해 코드 수정
  • Place에서 TypeORM Repository를 상속받은 SoftDeleteRepository로 리팩토링
  • pagination 대비 service에 파라미터 추가
  • 장소 상세 조회 api 에서 장소가 없는 경우 예외 추가
  • Query Param을 이용해서 기존 장소의 이름 검색 기능에다가 장소의 주소 검색 기능 추가

🙋🏻 More

참고 : Find Options | typeorm

where 에서 대괄호 -> OR / 중괄호 -> AND

where - simple conditions by which entity should be queried.


userRepository.find({
    where: {
        firstName: "Timber",
        lastName: "Saw",
    },
})

will execute following query:


SELECT * FROM "user"
WHERE "firstName" = 'Timber' AND "lastName" = 'Saw'
userRepository.find({
    where: [
        { firstName: "Timber", lastName: "Saw" },
        { firstName: "Stan", lastName: "Lee" },
    ],
})
will execute following query:

Copy
SELECT * FROM "user" WHERE ("firstName" = 'Timber' AND "lastName" = 'Saw') OR ("firstName" = 'Stan' AND "lastName" = 'Lee')

🕰️ Actual Time of Completion

2.5

close #52

@koomchang koomchang added BE 백엔드 관련 이슈입니다 🌱 기능추가 새로운 기능 요청입니다 🚑 버그 예기치 않은 문제 또는 의도하지 않은 동작입니다 ⚙️ 리팩터링 코드 퀄리티를 높입니다 labels Nov 6, 2024
@koomchang koomchang added this to the week2 milestone Nov 6, 2024
@koomchang koomchang self-assigned this Nov 6, 2024
@koomchang koomchang linked an issue Nov 6, 2024 that may be closed by this pull request
1 task
Copy link
Collaborator

@Miensoap Miensoap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -5,7 +5,7 @@ export class PlaceNotFoundException extends BaseException {
constructor() {
super({
code: 1002,
message: '검색 결과가 없습니다.',
message: '해당 장소가 존재하지 않습니다.',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p3. id 등을 인자로 받는건 어떨까요?

ex) 1번 장소가 존재하지 않습니다.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

반영했습니다!

});
}

softDelete(id: number) {
return super.update(id, { deletedAt: new Date() } as any);
}

private applyDeletedAtCondition(where: any) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

대괄호 조건은 몰랐는데 좋네요 ㅎㅎ

{ name: ILike(`%${query}%`) },
],
skip: (page - 1) * pageSize,
take: pageSize,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

지도 쪽에도 페이징에 대한 중복 조건이 있는데 나중에 분리할지 고민해 보아요

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵 좋습니다!

Copy link
Collaborator

@hyohyo12 hyohyo12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고 많았습니다!

@koomchang koomchang merged commit e20fb19 into develop Nov 6, 2024
2 checks passed
@koomchang koomchang deleted the feature/#52 branch November 6, 2024 05:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BE 백엔드 관련 이슈입니다 ⚙️ 리팩터링 코드 퀄리티를 높입니다 🌱 기능추가 새로운 기능 요청입니다 🚑 버그 예기치 않은 문제 또는 의도하지 않은 동작입니다
Projects
None yet
Development

Successfully merging this pull request may close these issues.

장소 Repository를 SoftDeleteRepository로 변경한다
3 participants