-
Notifications
You must be signed in to change notification settings - Fork 0
[CMAT-42] feat: 채용 공고 조회 시 더미 데이터 -> 사용자 답변 데이터를 사용하도록 수정 #25
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b5c0a6b
[CMAT-42] feat: 답변의 가장 첫번째 데이터는 답변 수정 api 호출마다 항상 updateAt을 갱신하도록한다
momuzzi 779d1b3
[CMAT-42] feat: 채용 공고 조회 시 사용자의 인턴, 프로젝트 템플릿 답변 데이터를 기반으로 gpt에게 요청하도록…
momuzzi 1d94e48
[CMAT-42] fix: 주석을 수정한다
momuzzi b7106f7
[CMAT-42] fix: 코드 위치를 수정한다
momuzzi 69a21b4
[CMAT-42] fix: 주석을 수정한다
momuzzi 625c117
[CMAT-42] fix: GptAnswer과 Member의 연관관계를 수정한다
momuzzi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
52 changes: 52 additions & 0 deletions
52
src/main/java/UMC/career_mate/domain/chatgpt/GptAnswer.java
This file contains hidden or 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,52 @@ | ||
| package UMC.career_mate.domain.chatgpt; | ||
|
|
||
| import UMC.career_mate.domain.member.Member; | ||
| import UMC.career_mate.domain.recruit.enums.RecruitKeyword; | ||
| import UMC.career_mate.global.entity.BaseEntity; | ||
| import jakarta.persistence.Column; | ||
| import jakarta.persistence.Entity; | ||
| import jakarta.persistence.EnumType; | ||
| import jakarta.persistence.Enumerated; | ||
| import jakarta.persistence.FetchType; | ||
| import jakarta.persistence.GeneratedValue; | ||
| import jakarta.persistence.GenerationType; | ||
| import jakarta.persistence.Id; | ||
| import jakarta.persistence.JoinColumn; | ||
| import jakarta.persistence.OneToOne; | ||
| import jakarta.persistence.Table; | ||
| import lombok.AccessLevel; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
| import org.hibernate.annotations.SQLRestriction; | ||
|
|
||
| @Entity | ||
| @Table(name = "gpt_answers") | ||
| @SQLRestriction("deleted_at is NULL") | ||
| @Getter | ||
| @Builder | ||
| @NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
| @AllArgsConstructor | ||
| public class GptAnswer extends BaseEntity { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| @Column(name = "gpt_answer_id") | ||
| private Long id; | ||
|
|
||
| @OneToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "member_id") | ||
| private Member member; | ||
|
|
||
| @Enumerated(EnumType.STRING) | ||
| private RecruitKeyword recruitKeyword; | ||
|
|
||
| private int careerYear; | ||
|
|
||
| public void updateData(RecruitKeyword recruitKeyword, int careerYear) { | ||
| this.recruitKeyword = recruitKeyword; | ||
| this.careerYear = careerYear; | ||
| super.setUpdatedAt(); | ||
| } | ||
| } |
16 changes: 16 additions & 0 deletions
16
src/main/java/UMC/career_mate/domain/chatgpt/converter/GptAnswerConverter.java
This file contains hidden or 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,16 @@ | ||
| package UMC.career_mate.domain.chatgpt.converter; | ||
|
|
||
| import UMC.career_mate.domain.chatgpt.GptAnswer; | ||
| import UMC.career_mate.domain.member.Member; | ||
| import UMC.career_mate.domain.recruit.enums.RecruitKeyword; | ||
|
|
||
| public class GptAnswerConverter { | ||
|
|
||
| public static GptAnswer toEntity(Member member, RecruitKeyword recruitKeyword, int careerYear) { | ||
| return GptAnswer.builder() | ||
| .member(member) | ||
| .recruitKeyword(recruitKeyword) | ||
| .careerYear(careerYear) | ||
| .build(); | ||
| } | ||
| } |
11 changes: 11 additions & 0 deletions
11
src/main/java/UMC/career_mate/domain/chatgpt/repository/GptAnswerRepository.java
This file contains hidden or 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,11 @@ | ||
| package UMC.career_mate.domain.chatgpt.repository; | ||
|
|
||
| import UMC.career_mate.domain.chatgpt.GptAnswer; | ||
| import UMC.career_mate.domain.member.Member; | ||
| import java.util.Optional; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| public interface GptAnswerRepository extends JpaRepository<GptAnswer, Long> { | ||
|
|
||
| Optional<GptAnswer> findByMember(Member member); | ||
| } |
This file contains hidden or 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
29 changes: 29 additions & 0 deletions
29
src/main/java/UMC/career_mate/domain/chatgpt/service/GptAnswerCommandService.java
This file contains hidden or 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,29 @@ | ||
| package UMC.career_mate.domain.chatgpt.service; | ||
|
|
||
| import UMC.career_mate.domain.chatgpt.GptAnswer; | ||
| import UMC.career_mate.domain.chatgpt.converter.GptAnswerConverter; | ||
| import UMC.career_mate.domain.chatgpt.repository.GptAnswerRepository; | ||
| import UMC.career_mate.domain.member.Member; | ||
| import UMC.career_mate.domain.recruit.enums.RecruitKeyword; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Propagation; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| @Transactional(propagation = Propagation.REQUIRES_NEW) | ||
| public class GptAnswerCommandService { | ||
|
|
||
| private final GptAnswerRepository gptAnswerRepository; | ||
|
|
||
| public void saveGptAnswer(Member member, RecruitKeyword recruitKeyword, int careerYear) { | ||
| GptAnswer gptAnswer = GptAnswerConverter.toEntity(member, recruitKeyword, careerYear); | ||
| gptAnswerRepository.save(gptAnswer); | ||
| } | ||
|
|
||
| public void updateGptAnswer(GptAnswer gptAnswer, RecruitKeyword recruitKeyword, int careerYear) { | ||
| gptAnswer.updateData(recruitKeyword, careerYear); | ||
| gptAnswerRepository.save(gptAnswer); | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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
2 changes: 1 addition & 1 deletion
2
...tgpt/dto/response/FilterConditionDTO.java → ...omain/recruit/dto/FilterConditionDTO.java
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이건 무슨 어노테이션인가요??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
트랜잭션 전파 설정을 정해주는 옵션입니다! GptAnswerCommandService의 메서드들(save, update)을 호출하는 쪽(RecruitQueryService)이 readOnly 상태라서 해당 트랜잭션이 이어지면 db 변경이 불가능해서, 전파 옵션으로 트랜잭션을 분리했습니다