source integration 배달 주문 도메인, statics domain 작업 - #9
Conversation
Delog 15 be 배달정보 저장 user auth init
chore: username 추가로 인한 mapper 및 context.set 추가
chore : globalExceptionHandler와 swagger 간 ex catch 및 버전 문제 해결
qlido
left a comment
There was a problem hiding this comment.
일단 회사에서 보이는 대로 적어봤는데 큰건 아니라 확ㄷ인만 해주시고 배포 ㄱㄱ
| WHERE o.username = :username | ||
| AND o.orderDateTime BETWEEN :startDate AND :endDate | ||
| """, | ||
| ) |
There was a problem hiding this comment.
따로 query annotation 사용하신 이유가 있나요?
There was a problem hiding this comment.
ㅋㅋㅋ 따로 쿼리 작성하는게 익숙해서 쓴거라 큰 이유는 없습니다.
| val entity = | ||
| deliveryOrderRepository | ||
| .findById(id) | ||
| .orElseThrow { EntityNotFoundException("해당 ID의 주문을 찾을 수 없습니다: $id") } | ||
| return deliveryOrderMapper.toResponse(entity) |
There was a problem hiding this comment.
이거 그럼 command 랑 query 제가 분리하겠습니다.
| val gaps = calculateWeeklyOrderGapsInDays(deliveryOrderList, startDate, endDate) | ||
|
|
||
| return Stats( | ||
| 0L, |
There was a problem hiding this comment.
null이나 기본값을 사용해주시고 명시적인 매직 넘버는 지양 부탁드립니다
| @ElementCollection | ||
| @CollectionTable( | ||
| name = "delivery_orderId_list", | ||
| joinColumns = [JoinColumn(name = "statsId")], | ||
| uniqueConstraints = [UniqueConstraint(columnNames = ["statsId", "deliveryOrderIdList"])], | ||
| ) | ||
| val deliveryOrderIdList: List<Long> = listOf(), |
There was a problem hiding this comment.
이것도 저희가 관리하게 테이블로 분리해주시면 좋겠습니다
| uniqueConstraints = [UniqueConstraint(columnNames = ["statsId", "deliveryOrderIdList"])], | ||
| ) | ||
| val deliveryOrderIdList: List<Long> = listOf(), | ||
| @CreatedDate |
There was a problem hiding this comment.
hibernate CreationTimestamp 쓰면 jpaaudit이 필요없어요 (TMI)
| ItemProcessor { usernames -> | ||
| val results = mutableListOf<Stats>() | ||
| val currentDate = LocalDate.now() | ||
|
|
There was a problem hiding this comment.
비동기 Future를 쓴다는게 Thread 단위로 작성하는 패턴이 고런게 있는건가요
| 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, |
There was a problem hiding this comment.
data class 얕은 복사 관련해서 방어적으로 작성하는 방법중에 하나라고 해서 작성했는데
과한가요?
| } | ||
|
|
||
| fun getAllUsernames(currentDate: LocalDate): List<String> { | ||
| val endDate = currentDate.minusDays(1).atTime(23, 59, 59) |
There was a problem hiding this comment.
LocalTime.MAX 이런거 사용하시는거 어떨까요?
There was a problem hiding this comment.
아 LocalTime.MAX의 존재를 몰랐습니다. 감사합니다.
|
|
||
| private fun getYearMonth(month: Int): YearMonth { | ||
| val currentYear = LocalDate.now().year | ||
| val yearMonth = YearMonth.of(currentYear, month) |
There was a problem hiding this comment.
조금 고민되던 부분이었는데 년-월 formatting 해서 작성하겠습니다.
주요 feature