Skip to content

Feat: 백오피스 개발#165

Merged
MoonMinHyuk1 merged 63 commits intodevfrom
feat/back-office
May 23, 2023
Merged

Feat: 백오피스 개발#165
MoonMinHyuk1 merged 63 commits intodevfrom
feat/back-office

Conversation

@MoonMinHyuk1
Copy link
Contributor

주요 작업 내용

백오피스 api 개발

작업 내용

  • Autority 타입 추가(SERVER, WEB)
  • 게시글 api 개발
  • 템플릿 api 개발
  • 리뷰 api 개발
  • 댓글 api 개발

CheckList

  • CI를 통과했나요?
  • 리뷰어를 등록했나요?
  • 참고 레퍼런스가 있을 경우, PR 혹은 댓글로 남겼나요?

전달 사항

  • 간단한 시나리오는 노션 테크블로그 파트에 적어두었습니다.
  • 개발 후에 바로 pr을 날리고 싶었지만 테스트때문에 ci jacoco 오류가 떠서 날릴 수 없었습니다..
  • 모호한 부분이 있을 수 있어서 계속 수정할 계획입니다!
  • 태민님께서 의견주신 웹소켓도 적용 고려해보겠습니다^^

@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 22 Code Smells

72.6% 72.6% Coverage
0.0% 0.0% Duplication

fun getRecord(
@PathVariable("record_id") recordId: Long,
request: HttpServletRequest,
@PageableDefault(size = 10) pageable: Pageable
Copy link
Member

Choose a reason for hiding this comment

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

페이징 처리에서 디폴드 값이 10인 이유가 있나요..? 위에 API는 4로 지정되어 있어서 여쭤봅니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

레코드 단건 조회에서의 페이징은 댓글에 대한 페이징이어서 제가 임의로 10개로 설정해두었습니다!


interface RecordRepository: JpaRepository<Record, Long>, RecordRepositoryCustom {

@Query("select dtype from record where id = :recordId", nativeQuery = true)
Copy link
Member

Choose a reason for hiding this comment

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

컬럼을 하나만 추출하고 싶을 때에는 정적 쿼리로 사용해야 하는 군요..!

Copy link
Contributor Author

@MoonMinHyuk1 MoonMinHyuk1 May 23, 2023

Choose a reason for hiding this comment

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

이건 사실 슈퍼-서브 클래스 사용 시 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"])
Copy link
Member

Choose a reason for hiding this comment

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

해당 어노테이션의 사용은 처음 접하는 것 같아요.!
Record 객체 조회 시, user 객체를 한 번에 fetch join으로 불러오면 성능에서 이점으로 작용할 것 같아요 👍🏻

}

override fun getHotRecords(): RecordHotResDto {
val weekAgo = LocalDateTime.now().minusWeeks(7)
Copy link
Member

Choose a reason for hiding this comment

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

LocalDateTime 라이브러리에 minusWeeks() 함수가 있는지는 몰랐어요. 유용한 함수들이 많군요

Comment on lines +84 to +101
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)
Copy link
Member

Choose a reason for hiding this comment

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

when에서 case에 해당하는 부분을 문자열 값으로 사용하기 보다는 명시적으로 enum 변수를 사용하는 건 어떨까요? 유지보수에도 용이할 것 같습니다!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

오! 바로 적용 가겠습니다~~


return when (recordRepository.findDType(recordId)) {
"O" -> {
val odori = record as Odori
Copy link
Member

Choose a reason for hiding this comment

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

타입스크립트가 생각나는 문법이군요 .. 👍🏻

Comment on lines +132 to +133
val record = recordRepository.findByIdWithUser(recordId)
.orElseThrow { ApplicationException(NOT_FOUND_EXCEPTION) }
Copy link
Member

Choose a reason for hiding this comment

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

record의 pk 값인 id로 조회 후, exception 처리를 하는 것이라면 findByIdOrThrow() 함수를 사용해도 되지 않을까 합니다!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

레코드의 유저 정보를 사용하기 때문에 페치 조인으로 한번에 불러오기 위해 사용했습니다!

Comment on lines +22 to +26
var ref: Long,

var step: Long,

var level: Long,
Copy link
Member

Choose a reason for hiding this comment

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

LinkedList가 생각나는 구조인데, 맞을까요..?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

무한 대댓글 머리 빠지는 줄 알았어요...

Copy link
Member

Choose a reason for hiding this comment

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

ㅋㅋㅋㅋ앗!! 코드 상의 구조는 굉장히 이쁜데요?!! 역시 갓민혁😎

Comment on lines +26 to +46
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
Copy link
Member

Choose a reason for hiding this comment

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

미녁씨... 눈에 확 들어오는 코드 ... 너무 멋있는 거 아닌가요 ? 😊👍🏻⭐️

Copy link
Contributor Author

Choose a reason for hiding this comment

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

😎

Comment on lines +31 to +33
@JsonFormat(pattern = "MM.dd.yyyy")
@JsonProperty("create_at")
val createAt: LocalDateTime
Copy link
Member

Choose a reason for hiding this comment

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

포맷팅까지 해주는 센스 ... 🥺

Copy link
Contributor

@YoonTaeMinnnn YoonTaeMinnnn left a comment

Choose a reason for hiding this comment

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

혼자서 이렇게 많은 api 뚝딱뚝딱 만들어줘서 감사합니다! 고생하셨어요!
우릉비씨가 제 마음을 대변하는 리뷰를 해주셔서 저는 딱히 코멘트 안달었어요!! ㅎ..ㅎ🤗

YoonTaeMinnnn

This comment was marked as duplicate.

@MoonMinHyuk1 MoonMinHyuk1 merged commit 0ec7738 into dev May 23, 2023
@dldmsql
Copy link
Member

dldmsql commented May 23, 2023

ㅋㅋㅋ 저의 리뷰가 좀 야무지긴 했죠?? 😎 @YoonTaeMinnnn

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.

3 participants

Comments