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

[BE] feat: 하이라이트 추가 및 수정 API 구현 #813

Merged
merged 39 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
c62884c
feat: 하이라이트 기능을 위한 도메인, 테이블, 레포지토리 생성
skylar1220 Oct 9, 2024
5979829
refactor: reviewRequestCode도 서비스에 함께 넘기도록 수정
skylar1220 Oct 9, 2024
fa5aa38
feat: 하이라이트 수정을 위한 삭제, 저장 로직 구현
skylar1220 Oct 9, 2024
b55df2f
feat: 하이라이트 수정을 위한 검증 로직 구현
skylar1220 Oct 10, 2024
cbbc950
db: 하이라이트 조회 성능과 동시성을 위한 복합 인덱스 추가
skylar1220 Oct 10, 2024
84898cf
fix: 리뷰 그룹으로 질문 검증하는 로직 수정
skylar1220 Oct 10, 2024
2b74e5e
refactor: 레포지토리에 기존에 있던 메서드 활용하도록 수정
skylar1220 Oct 10, 2024
eb1459e
fix: 테이블명 오류 수정
skylar1220 Oct 10, 2024
f4418cc
refactor: 초기화시 필드 순서 수정
skylar1220 Oct 10, 2024
921cc6e
test: 하이라이트 레포지토리 테스트 추가
skylar1220 Oct 10, 2024
b3a58c3
test: 하이라이트 입력 검증 테스트 추가
skylar1220 Oct 10, 2024
a88d090
test: 하이라이트 수정 기능 서비스 테스트 추가
skylar1220 Oct 10, 2024
b8ce456
refactor: 생성자 파라미터 및 필드 순서 변경
skylar1220 Oct 10, 2024
ad59c37
fix: not null 설정 오타 수정
skylar1220 Oct 10, 2024
f87efad
refactor: 검증 순서 변경
skylar1220 Oct 10, 2024
d3abfd3
refactor: jpa 기본 메서드로 쿼리 여러개 나가는 부분을 @Query로 변경
skylar1220 Oct 10, 2024
95cf051
style: 개행 수정
skylar1220 Oct 10, 2024
bb9ebb1
refactor: 에러 메세지 수정
skylar1220 Oct 10, 2024
c700e45
db: 하이라이트 인덱스 관련 데이터 타입 int로 수정
skylar1220 Oct 10, 2024
834d900
refactor: 하이라이트 표시 위치 관련 속성을 객체로 분리
skylar1220 Oct 10, 2024
16f5d34
refactor: JPQL로 변경
skylar1220 Oct 10, 2024
f71d9de
refactor: 기존 레포지토리 메서드를 사용하도록 변경
skylar1220 Oct 10, 2024
4b28bd4
refactor: 메서드 네이밍 수정
skylar1220 Oct 10, 2024
cd6a16c
refactor: 하이라이트 위치 속성 객체에 추가 설정
skylar1220 Oct 10, 2024
fbd8fc4
refactor: 하이라이트 엔티티에서 reviewGroupId, questionId 필드 제거
skylar1220 Oct 10, 2024
1ce93e6
refactor: 기존 하이라이트 제거를 answerId를 통해 하도록 변경
skylar1220 Oct 10, 2024
ba72762
test: 책임을 이동한 테스트 제거 및 테스트 오류 수정
skylar1220 Oct 10, 2024
1c16507
db: 테이블에 questionId, review_group_id 컬럼 제거 반영
skylar1220 Oct 10, 2024
a7f25b8
refactor: 기존 중복 요청 메서드 제거
skylar1220 Oct 10, 2024
52c350b
refactor: 중복 요청의 경우 하나만 저장하도록 EqualsAndHashCode 재정의
skylar1220 Oct 10, 2024
7e546aa
refactor: 하이라이트 저장시 순서 보장 적용
skylar1220 Oct 10, 2024
55895db
refactor: HighlightPosition 검증, 객체 생성 후 하이라이트 객체 생성하도록 변경
skylar1220 Oct 10, 2024
aaf1c6c
refactor: 엔티티의 equals 조건 id로 복원 및 중복 제거 로직 삭제
skylar1220 Oct 11, 2024
560faec
refactor: HighlightPosition 객체 생성 위치 생성자 내로 이동
skylar1220 Oct 11, 2024
a3a968f
refactor: 예외명 수정
skylar1220 Oct 11, 2024
c226e21
refactor: 하이라이트 인덱스의 검증 추가
skylar1220 Oct 11, 2024
132ff57
refactor: 양수 검증 메서드명 수정
skylar1220 Oct 11, 2024
a9ceb36
test: 필드에 접근 제어자 추가
skylar1220 Oct 11, 2024
24b706b
fix: 하이라이트 줄 번호 계산 로직 및 변수명 수정
skylar1220 Oct 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions backend/src/main/java/reviewme/highlight/domain/HighLight.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package reviewme.highlight.domain;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.AccessLevel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
@Table(name = "highlight")
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@EqualsAndHashCode(of = "id")
@Getter
public class HighLight {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(name = "question_id", nullable = false)
private long questionId;

@Column(name = "review_group_id", nullable = false)
private long reviewGroupId;

Copy link
Contributor

Choose a reason for hiding this comment

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

굳이 questionId와 reviewId를 가지고 있지 않아도 되지 않을까요?
answerId로 소속은 충분히 알 수 있다고 생각해요,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

questionId와 reviewGroupId를 말하는 게 맞겠죠?
새로운 하이라이트가 들어왔을 때 question id = ? and review_group_id = ? 인 조건문으로 기존 데이터 삭제를 진행하기 떄문에 넣었어요~

Copy link
Contributor

Choose a reason for hiding this comment

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

JOIN해서 DELETE하는 게 좋지 않을까요? 데이터 삭제에만 필요한 것이 DB에 속성으로 등록될 필요가 있을지 고민해보아야겠네용,,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

맞네요 answerId로 처리하고 review group id와 question id는 뺐어요!

@Column(name = "answer_id", nullable = false)
private long answerId;

@Column(name = "line_index", nullable = false)
private long lineIndex;

@Column(name = "start_index", nullable = false)
private long startIndex;

@Column(name = "end_index", nullable = false)
private long endIndex;

public HighLight(long answerId, long questionId, long reviewGroupId,
long lineIndex, long startIndex, long endIndex) {
this.answerId = answerId;
this.questionId = questionId;
this.reviewGroupId = reviewGroupId;
this.lineIndex = lineIndex;
this.startIndex = startIndex;
this.endIndex = endIndex;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package reviewme.highlight.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import reviewme.highlight.domain.HighLight;

public interface HighlightRepository extends JpaRepository<HighLight, Long> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-- highlight 테이블을 생성합니다.

CREATE TABLE highlight
(
id BIGINT AUTO_INCREMENT,
questionId BIGINT NOT NULl,
review_group_id BIGINT NOT NULl,
answer_id BIGINT NOT NULl,
line_index BIGINT NOT NULl,
start_index BIGINT NOT NULl,
end_index BIGINT NOT NULl,
Copy link
Contributor

Choose a reason for hiding this comment

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

  • NULl ???
  • index는 몇억 단위로 커질 일이 없는데 BIGINT로 하지 않고 그냥 INT로 해도 되지 않을까요?

Copy link
Contributor

Choose a reason for hiding this comment

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

BIGINT, INT는 DB에서는 반영하되, 어플리케이션에서 longint로 바꾸지는 않아도 될 듯해요.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

db에 차지하는 크기를 줄이는 목적이니 ddl만 바꾸면 된다는 말이죠? 반영완!

Copy link
Contributor

Choose a reason for hiding this comment

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

(어플리케이션이 DB에 종속적일 필요가 없다는 맥락에서 바꾸지 않아도 된다는 이야기를 했슴다)

PRIMARY KEY (id)
);