-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 스터디로그 임시저장 GET, PUT 요청 응답에 역량을 추가한다. (#1053)
* feat: 임시저장 로직 response에 ability 필드 추가 * feat: 플라이웨이에 crate studylog_temp_ability 추가 * test: 문서화 테스트 추가 * refactor: 역량 관련해서 적절한 에러로 수정 * fix: 임시저장 관련 테스트 추가 및 에러 해결 * fix: StudylogTempAbility OnDelete 속성 추가
- Loading branch information
Showing
7 changed files
with
342 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
backend/src/main/java/wooteco/prolog/ability/domain/StudylogTempAbility.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package wooteco.prolog.ability.domain; | ||
|
||
import javax.persistence.Entity; | ||
import javax.persistence.FetchType; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import javax.persistence.JoinColumn; | ||
import javax.persistence.ManyToOne; | ||
import lombok.AccessLevel; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import org.hibernate.annotations.OnDelete; | ||
import org.hibernate.annotations.OnDeleteAction; | ||
import wooteco.prolog.studylog.domain.StudylogTemp; | ||
|
||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Entity | ||
public class StudylogTempAbility { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
private Long memberId; | ||
|
||
@ManyToOne(fetch = FetchType.EAGER) | ||
@JoinColumn(name = "ability_id", nullable = false) | ||
@OnDelete(action = OnDeleteAction.CASCADE) | ||
private Ability ability; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "studylog_temp_id", nullable = false) | ||
@OnDelete(action = OnDeleteAction.CASCADE) | ||
private StudylogTemp studylogTemp; | ||
|
||
public StudylogTempAbility(Long memberId, Ability ability, StudylogTemp studylogTemp) { | ||
this.memberId = memberId; | ||
this.ability = ability; | ||
this.studylogTemp = studylogTemp; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...src/main/java/wooteco/prolog/ability/domain/repository/StudylogTempAbilityRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package wooteco.prolog.ability.domain.repository; | ||
|
||
import java.util.List; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import wooteco.prolog.ability.domain.StudylogTempAbility; | ||
|
||
public interface StudylogTempAbilityRepository extends JpaRepository<StudylogTempAbility, Long> { | ||
|
||
void deleteByStudylogTempId(Long studylogTempId); | ||
|
||
List<StudylogTempAbility> findByStudylogTempId(Long studylogTempId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
backend/src/main/resources/db/migration/prod/V31__create_studylogtempAbility_table.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
CREATE TABLE studylog_temp_ability( | ||
id BIGINT NOT NULL AUTO_INCREMENT, | ||
member_id BIGINT NOT NULL, | ||
ability_id BIGINT NOT NULL, | ||
studylog_temp_id BIGINT NOT NULL, | ||
PRIMARY KEY (id) | ||
) ENGINE=InnoDB; | ||
|
||
alter table studylog_temp_ability | ||
add constraint FK_STUDYLOG_TEMP_ABILITY_ABILITY | ||
foreign key (ability_id) | ||
references ability (id) on delete cascade; | ||
|
||
alter table studylog_temp_ability | ||
add constraint FK_STUDYLOG_TEMP_ABILITY_STUDYLOG_TEMP | ||
foreign key (studylog_temp_id) | ||
references studylog_temp (id) on delete cascade; |
Oops, something went wrong.