Skip to content

source integration 배달 주문 도메인, statics domain 작업 - #9

Open
moonlt93 wants to merge 40 commits into
developfrom
integration
Open

source integration 배달 주문 도메인, statics domain 작업#9
moonlt93 wants to merge 40 commits into
developfrom
integration

Conversation

@moonlt93

Copy link
Copy Markdown

주요 feature

  • 배달 주문 CRUD 및 당일 주문 조회
  • interceptor 인증
  • statics batch , 조회API 작성 -> cron 시간 수정 필요

seoyeon-jung and others added 30 commits July 11, 2025 16:24
@qlido
qlido changed the base branch from develop to DELOG-15-BE-배달정보-저장 July 17, 2025 09:08
@qlido
qlido changed the base branch from DELOG-15-BE-배달정보-저장 to develop July 17, 2025 09:09

@qlido qlido left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

일단 회사에서 보이는 대로 적어봤는데 큰건 아니라 확ㄷ인만 해주시고 배포 ㄱㄱ

WHERE o.username = :username
AND o.orderDateTime BETWEEN :startDate AND :endDate
""",
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

따로 query annotation 사용하신 이유가 있나요?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

ㅋㅋㅋ 따로 쿼리 작성하는게 익숙해서 쓴거라 큰 이유는 없습니다.

Comment on lines +29 to +33
val entity =
deliveryOrderRepository
.findById(id)
.orElseThrow { EntityNotFoundException("해당 ID의 주문을 찾을 수 없습니다: $id") }
return deliveryOrderMapper.toResponse(entity)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

이런 부분 find class 에서 관리

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

이거 그럼 command 랑 query 제가 분리하겠습니다.

val gaps = calculateWeeklyOrderGapsInDays(deliveryOrderList, startDate, endDate)

return Stats(
0L,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

null이나 기본값을 사용해주시고 명시적인 매직 넘버는 지양 부탁드립니다

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@qlido
아 이거 기본 값이 0L이라 넣어둔거긴한데 따른 방법이 있을까요?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

생성자에 기본값 주시면 좋을거 같아요

Comment on lines +50 to +56
@ElementCollection
@CollectionTable(
name = "delivery_orderId_list",
joinColumns = [JoinColumn(name = "statsId")],
uniqueConstraints = [UniqueConstraint(columnNames = ["statsId", "deliveryOrderIdList"])],
)
val deliveryOrderIdList: List<Long> = listOf(),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

이것도 저희가 관리하게 테이블로 분리해주시면 좋겠습니다

uniqueConstraints = [UniqueConstraint(columnNames = ["statsId", "deliveryOrderIdList"])],
)
val deliveryOrderIdList: List<Long> = listOf(),
@CreatedDate

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

hibernate CreationTimestamp 쓰면 jpaaudit이 필요없어요 (TMI)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@CreatedDate 요놈이면 충분한 건가요?

ItemProcessor { usernames ->
val results = mutableListOf<Stats>()
val currentDate = LocalDate.now()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

나중에 비동기 Future로 바꾸시죠!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

비동기 Future를 쓴다는게 Thread 단위로 작성하는 패턴이 고런게 있는건가요

Comment on lines +79 to +98
companion object {
private class MonthlyBuilder {
private var deliveryCount = 0
private var orderMenuCount = 0
private var totalSpent = BigInteger.ZERO
private var summaryMonth = 0

fun add(entity: StatisticsEntity) =
apply {
deliveryCount += entity.totalOrderCount
orderMenuCount += entity.totalItemCount
totalSpent += entity.totalSpent
summaryMonth = entity.summaryStartDate.monthValue
}

fun build(): StatisticsMonthlyResponse =
StatisticsMonthlyResponse(
deliveryCount = deliveryCount,
orderMenuCount = orderMenuCount,
totalSpent = totalSpent,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

왜 이렇게 작성해주셨을까요?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

data class 얕은 복사 관련해서 방어적으로 작성하는 방법중에 하나라고 해서 작성했는데
과한가요?

}

fun getAllUsernames(currentDate: LocalDate): List<String> {
val endDate = currentDate.minusDays(1).atTime(23, 59, 59)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

매직넘버 지양 부탁드림니다

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LocalTime.MAX 이런거 사용하시는거 어떨까요?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

아 LocalTime.MAX의 존재를 몰랐습니다. 감사합니다.


private fun getYearMonth(month: Int): YearMonth {
val currentYear = LocalDate.now().year
val yearMonth = YearMonth.of(currentYear, month)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

년 월 모두 입력받는건 어떠신가요?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

조금 고민되던 부분이었는데 년-월 formatting 해서 작성하겠습니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants