Conversation
|
SonarCloud Quality Gate failed. |
| fun getRecord( | ||
| @PathVariable("record_id") recordId: Long, | ||
| request: HttpServletRequest, | ||
| @PageableDefault(size = 10) pageable: Pageable |
There was a problem hiding this comment.
페이징 처리에서 디폴드 값이 10인 이유가 있나요..? 위에 API는 4로 지정되어 있어서 여쭤봅니다.
There was a problem hiding this comment.
레코드 단건 조회에서의 페이징은 댓글에 대한 페이징이어서 제가 임의로 10개로 설정해두었습니다!
|
|
||
| interface RecordRepository: JpaRepository<Record, Long>, RecordRepositoryCustom { | ||
|
|
||
| @Query("select dtype from record where id = :recordId", nativeQuery = true) |
There was a problem hiding this comment.
컬럼을 하나만 추출하고 싶을 때에는 정적 쿼리로 사용해야 하는 군요..!
There was a problem hiding this comment.
이건 사실 슈퍼-서브 클래스 사용 시 dtype을 알 방도가 없어서 사용했습니다😅
| @Query("select r from Record r where r.createdAt >= :weekAgo and r.status = 'WAIT'") | ||
| fun findWeekAgo(@Param("weekAgo") weekAgo: LocalDateTime): List<Record> | ||
|
|
||
| @EntityGraph(attributePaths = ["user"]) |
There was a problem hiding this comment.
해당 어노테이션의 사용은 처음 접하는 것 같아요.!
Record 객체 조회 시, user 객체를 한 번에 fetch join으로 불러오면 성능에서 이점으로 작용할 것 같아요 👍🏻
| } | ||
|
|
||
| override fun getHotRecords(): RecordHotResDto { | ||
| val weekAgo = LocalDateTime.now().minusWeeks(7) |
There was a problem hiding this comment.
LocalDateTime 라이브러리에 minusWeeks() 함수가 있는지는 몰랐어요. 유용한 함수들이 많군요
| return when (condition.type) { | ||
| "all" -> { | ||
| val records = recordRepository.findRecords(condition, pageable) | ||
| RecordPageResDto(records) | ||
| } | ||
| "odori" -> { | ||
| val records = odoriRepository.findOdoris(condition, pageable) | ||
| RecordPageResDto(records) | ||
| } | ||
| "retro" -> { | ||
| val records = retrospectionRepository.findRetrospections(condition, pageable) | ||
| RecordPageResDto(records) | ||
| } | ||
| "tech" -> { | ||
| val records = technologyRepository.findTechnologies(condition, pageable) | ||
| RecordPageResDto(records) | ||
| } | ||
| else -> throw ApplicationException(NOT_FOUND_EXCEPTION) |
There was a problem hiding this comment.
when에서 case에 해당하는 부분을 문자열 값으로 사용하기 보다는 명시적으로 enum 변수를 사용하는 건 어떨까요? 유지보수에도 용이할 것 같습니다!
There was a problem hiding this comment.
오! 바로 적용 가겠습니다~~
|
|
||
| return when (recordRepository.findDType(recordId)) { | ||
| "O" -> { | ||
| val odori = record as Odori |
| val record = recordRepository.findByIdWithUser(recordId) | ||
| .orElseThrow { ApplicationException(NOT_FOUND_EXCEPTION) } |
There was a problem hiding this comment.
record의 pk 값인 id로 조회 후, exception 처리를 하는 것이라면 findByIdOrThrow() 함수를 사용해도 되지 않을까 합니다!
There was a problem hiding this comment.
레코드의 유저 정보를 사용하기 때문에 페치 조인으로 한번에 불러오기 위해 사용했습니다!
| var ref: Long, | ||
|
|
||
| var step: Long, | ||
|
|
||
| var level: Long, |
There was a problem hiding this comment.
무한 대댓글 머리 빠지는 줄 알았어요...
There was a problem hiding this comment.
ㅋㅋㅋㅋ앗!! 코드 상의 구조는 굉장히 이쁜데요?!! 역시 갓민혁😎
| val record = recordRepository.findByIdOrThrow(recordCommentReqDto.recordId) | ||
| var parent: RecordComment? = null | ||
| val refCount = recordCommentRepository.findNextRef(record) | ||
| var ref: Long = if(refCount == null) 1 else (refCount + 1).toLong() | ||
| var step: Long = 1 | ||
| var level: Long = 1 | ||
| var allChildrenSize: Long = 0 | ||
| if(recordCommentReqDto.parentId != null) { | ||
| parent = recordCommentRepository.findByIdOrThrow(recordCommentReqDto.parentId) | ||
|
|
||
| val parentStep: Long = parent.step | ||
| val parentAllChildrenSize: Long = parent.allChildrenSize | ||
| step = parentStep + parentAllChildrenSize + 1 | ||
| ref = parent.ref | ||
| level = parent.level + 1 | ||
|
|
||
| val comments = recordCommentRepository.findSameRef(record, ref) | ||
| updateAllChildrenSize(parent) | ||
| updateStep(comments, step) | ||
| } | ||
| return recordCommentRepository.save(RecordComment(recordCommentReqDto.content, record, user, ref, step, level, allChildrenSize, parent)).id |
There was a problem hiding this comment.
미녁씨... 눈에 확 들어오는 코드 ... 너무 멋있는 거 아닌가요 ? 😊👍🏻⭐️
| @JsonFormat(pattern = "MM.dd.yyyy") | ||
| @JsonProperty("create_at") | ||
| val createAt: LocalDateTime |
YoonTaeMinnnn
left a comment
There was a problem hiding this comment.
혼자서 이렇게 많은 api 뚝딱뚝딱 만들어줘서 감사합니다! 고생하셨어요!
우릉비씨가 제 마음을 대변하는 리뷰를 해주셔서 저는 딱히 코멘트 안달었어요!! ㅎ..ㅎ🤗
|
ㅋㅋㅋ 저의 리뷰가 좀 야무지긴 했죠?? 😎 @YoonTaeMinnnn |








주요 작업 내용
작업 내용
CheckList
전달 사항