-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/#3 basic entity #7
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
Open
lemonson03
wants to merge
6
commits into
dev
Choose a base branch
from
feat/#3-basic-entity
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+523
−0
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9ba9622
feat#3/basic-entity
lemonson03 f141bee
feat#3/basic-repository
lemonson03 1a4c07a
feat#3/basic-repo2,report
lemonson03 894d6a8
Update src/main/java/org/groomUniv/meet/blinddate/entity/BlindDate.java
lemonson03 5734591
feat: (#3) Accept Comment
lemonson03 1ddd3c9
feat : (#3) resolve conflicts
lemonson03 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
48 changes: 48 additions & 0 deletions
48
src/main/java/org/groomUniv/meet/blinddate/entity/BlindDate.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,48 @@ | ||
| package org.groomUniv.meet.blinddate.entity; | ||
|
|
||
| import jakarta.persistence.*; | ||
| import lombok.Data; | ||
| import lombok.NoArgsConstructor; | ||
| import org.groomUniv.meet.common.entity.BaseEntity; | ||
| import org.groomUniv.meet.oauth.entity.Member; | ||
| import org.springframework.data.annotation.CreatedDate; | ||
| import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
|
|
||
| import java.time.LocalDateTime; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| @Entity | ||
| @NoArgsConstructor | ||
| @Table(name = "blind_date") | ||
|
|
||
|
|
||
| public class BlindDate extends BaseEntity { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private Long blindDateId; | ||
|
|
||
|
|
||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "member1_id") | ||
| private Member member1; | ||
|
|
||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "member2_id") | ||
| private Member member2; | ||
|
|
||
| // 채팅제한 | ||
| private Long chatLimit; | ||
|
|
||
| //챗 엔티티 리스트로 관리하기 | ||
| @OneToMany(mappedBy = "blindDate", cascade = CascadeType.ALL) | ||
| private List<BlindDateChat> chats = new ArrayList<>(); | ||
| } | ||
| // JPA Auditing 설명 | ||
| //@CreatedDate: 엔터티가 처음 생성된 날짜를 자동으로 기록합니다. | ||
| // | ||
| //@LastModifiedDate: 엔터티가 마지막으로 수정된 날짜를 자동으로 기록합니다. | ||
| // | ||
| //@CreatedBy: 엔터티를 처음 생성한 사용자를 자동으로 기록합니다. | ||
| // | ||
| //@LastModifiedBy: 엔터티를 마지막으로 수정한 사용자를 자동으로 기록합니다. |
31 changes: 31 additions & 0 deletions
31
src/main/java/org/groomUniv/meet/blinddate/entity/BlindDateChat.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,31 @@ | ||
| package org.groomUniv.meet.blinddate.entity; | ||
|
|
||
|
|
||
| import jakarta.persistence.*; | ||
| import lombok.Data; | ||
| import org.groomUniv.meet.common.entity.BaseEntity; | ||
| import org.groomUniv.meet.oauth.entity.Member; | ||
| import org.springframework.data.annotation.CreatedDate; | ||
|
|
||
| import java.time.LocalDateTime; | ||
|
|
||
|
|
||
| @Entity | ||
| public class BlindDateChat extends BaseEntity { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private Long blindDataChatId; | ||
|
|
||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "blind_date_id") | ||
| private BlindDate blindDate; | ||
|
|
||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "member_id") | ||
| private Member sender; | ||
|
|
||
| private String message; | ||
|
|
||
| private Boolean readStatus; | ||
| } |
22 changes: 22 additions & 0 deletions
22
src/main/java/org/groomUniv/meet/blinddate/repository/BlindDateChatRepository.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,22 @@ | ||
| package org.groomUniv.meet.blinddate.repository; | ||
|
|
||
| import org.groomUniv.meet.blinddate.entity.BlindDate; | ||
| import org.groomUniv.meet.blinddate.entity.BlindDateChat; | ||
| import org.groomUniv.meet.oauth.entity.Member; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Optional; | ||
|
|
||
| public interface BlindDateChatRepository extends JpaRepository<BlindDateChat, Long> { | ||
|
|
||
| // 채팅 ID로 채팅 검색 | ||
| Optional<BlindDateChat> findById(Long blindDataChatId); | ||
|
|
||
| // 특정 블라인드 채팅에 속한 모든 채팅 시간순으로 | ||
| List<BlindDateChat> findAllByBlindDateOrderByTimestampAsc(BlindDate blindDate); | ||
| // 읽지 않은 메세지들 가져오기 | ||
| List<BlindDateChat> findAllByBlindDateAndReadStatusFalse(BlindDate blindDate); | ||
| // 특정 sender 기반으로 조회하기 | ||
| List<BlindDateChat> findAllBySender(Member sender); | ||
| } |
20 changes: 20 additions & 0 deletions
20
src/main/java/org/groomUniv/meet/blinddate/repository/BlindDateRepository.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,20 @@ | ||
| package org.groomUniv.meet.blinddate.repository; | ||
|
|
||
| import org.groomUniv.meet.blinddate.entity.BlindDate; | ||
| import org.groomUniv.meet.blinddate.entity.BlindDateChat; | ||
| import org.groomUniv.meet.oauth.entity.Member; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
| import org.springframework.data.jpa.repository.Query; | ||
| import org.springframework.data.repository.query.Param; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Optional; | ||
|
|
||
| public interface BlindDateRepository extends JpaRepository<BlindDate,Long> { | ||
| // 특정 두 멤버 기반의 챗 가져오기 | ||
| Optional<BlindDate> findByMember1AndMember2(Member member1, Member member2); | ||
| // 특정 멤버중 하나만 있어도 가져오는 함수 | ||
| @Query("SELECT b FROM BlindDate b WHERE b.member1 = :member OR b.member2 = :member") | ||
| List<BlindDate> findAllByMember(@Param("member") Member member); | ||
|
|
||
| } |
24 changes: 24 additions & 0 deletions
24
src/main/java/org/groomUniv/meet/common/config/JpaAuditingConfig.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,24 @@ | ||
| package org.groomUniv.meet.common.config; | ||
|
|
||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
| import org.springframework.data.domain.AuditorAware; | ||
| import org.springframework.data.jpa.repository.config.EnableJpaAuditing; | ||
|
|
||
| import java.util.Optional; | ||
|
|
||
| @Configuration | ||
| @EnableJpaAuditing | ||
| // Spring이 CreatedBy에서 어떤 사용자를 넣을지 모르기 때문에 그걸 이 부분을 통해 찾아주려고 적는 Config 파일 | ||
| public class JpaAuditingConfig { | ||
|
|
||
| @Bean | ||
| public AuditorAware<String> auditorProvider() { | ||
| // 실제 사용자 인증이 있는 경우엔 SecurityContext에서 꺼내서 여기 부분 변경해야함 basic으로 쓰면 안됨. | ||
| return () -> Optional.of("basic"); // 기본값 | ||
| } | ||
| } | ||
| // Spring Security 사용할 때의 SecurityContextHolder 사용법 | ||
| // return () -> Optional.ofNullable(SecurityContextHolder.getContext().getAuthentication()) | ||
| // .filter(Authentication::isAuthenticated) | ||
| // .map(Authentication::getName); |
29 changes: 29 additions & 0 deletions
29
src/main/java/org/groomUniv/meet/common/entity/BaseEntity.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 org.groomUniv.meet.common.entity; | ||
|
|
||
| import jakarta.persistence.Column; | ||
| import jakarta.persistence.EntityListeners; | ||
| import jakarta.persistence.MappedSuperclass; | ||
| import lombok.Getter; | ||
| import org.springframework.data.annotation.CreatedBy; | ||
| import org.springframework.data.annotation.CreatedDate; | ||
| import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
|
|
||
| import java.time.LocalDateTime; | ||
| @Getter | ||
| @MappedSuperclass | ||
| @EntityListeners(AuditingEntityListener.class) // JPA Auditing 활성화 | ||
| // 생성일자, 수정일자, 시간 관리에 대한 것은 공통적인 부분이라 BaseEntity를 통해 관리하고 상속받아서 사용하기 위한 용도 | ||
| public class BaseEntity { | ||
| // create 날짜 언제인지 | ||
| @CreatedDate | ||
| @Column(updatable = false) | ||
| private LocalDateTime createdAt; | ||
|
|
||
| // 누가 create 했는지 | ||
| @CreatedBy | ||
| @Column(updatable = false) | ||
| private String createdBy; | ||
|
|
||
|
|
||
|
|
||
| } |
32 changes: 32 additions & 0 deletions
32
src/main/java/org/groomUniv/meet/meeting/entity/Meeting.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,32 @@ | ||
| package org.groomUniv.meet.meeting.entity; | ||
|
|
||
| import jakarta.persistence.*; | ||
| import lombok.Data; | ||
| import lombok.NoArgsConstructor; | ||
| import org.groomUniv.meet.blinddate.entity.BlindDateChat; | ||
| import org.groomUniv.meet.common.entity.BaseEntity; | ||
| import org.springframework.data.annotation.CreatedBy; | ||
| import org.springframework.data.annotation.CreatedDate; | ||
| import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
|
|
||
| import java.time.LocalDateTime; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| @Entity | ||
|
|
||
| @NoArgsConstructor | ||
|
|
||
| public class Meeting extends BaseEntity { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private Long meetingId; | ||
|
|
||
|
|
||
| private String meetingDetails; | ||
|
|
||
|
|
||
| @OneToMany(mappedBy = "meeting", cascade = CascadeType.ALL) | ||
| private List<MeetingChat> chats = new ArrayList<>(); | ||
| } | ||
|
|
36 changes: 36 additions & 0 deletions
36
src/main/java/org/groomUniv/meet/meeting/entity/MeetingChat.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,36 @@ | ||
| package org.groomUniv.meet.meeting.entity; | ||
|
|
||
| import jakarta.persistence.*; | ||
| import lombok.Data; | ||
| import lombok.NoArgsConstructor; | ||
| import org.groomUniv.meet.common.entity.BaseEntity; | ||
| import org.groomUniv.meet.oauth.entity.Member; | ||
| import org.springframework.data.annotation.CreatedDate; | ||
| import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
|
|
||
| import java.time.LocalDateTime; | ||
| import java.util.Date; | ||
|
|
||
| @Entity | ||
| @NoArgsConstructor | ||
| public class MeetingChat extends BaseEntity { | ||
|
|
||
| @Id | ||
| @GeneratedValue | ||
| private Long meetingChatId; | ||
|
|
||
| private String message; | ||
|
|
||
| private String senderId; | ||
|
|
||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "meeting_id") | ||
| private Meeting meeting; | ||
|
|
||
| } | ||
| // 생성 가이드라인 | ||
| //MeetingChat chat = new MeetingChat(); | ||
| //chat.setMeeting(meeting); // 여기서 meeting은 기존에 조회한 Meeting 객체 | ||
| //chat.setSenderId(1L); | ||
| //chat.setMessage("안녕하세요!"); | ||
| //chat.setTimestamp(LocalDateTime.now()); |
11 changes: 11 additions & 0 deletions
11
src/main/java/org/groomUniv/meet/meeting/repository/MeetingChatRepository.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 org.groomUniv.meet.meeting.repository; | ||
|
|
||
| import org.groomUniv.meet.meeting.entity.MeetingChat; | ||
| import org.groomUniv.meet.payment.entity.Payment; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| import java.util.Optional; | ||
|
|
||
| public interface MeetingChatRepository extends JpaRepository<MeetingChat, Long> { | ||
| Optional<MeetingChat> findById(Long meetingChatId); | ||
| } |
17 changes: 17 additions & 0 deletions
17
src/main/java/org/groomUniv/meet/meeting/repository/MeetingRepository.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,17 @@ | ||
| package org.groomUniv.meet.meeting.repository; | ||
|
|
||
| import org.groomUniv.meet.meeting.entity.Meeting; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Optional; | ||
|
|
||
| public interface MeetingRepository extends JpaRepository<Meeting, Long> { | ||
|
|
||
| //미팅 Id 기반으로 검색 | ||
| Optional<Meeting> findById(Long meetingId); | ||
| // 생성한 사람 기반으로 검색 | ||
| List<Meeting> findAllByCreatedBy(String createdBy); | ||
| // 미팅 내용으로 검색 , 키워드 기반 욕, 문제되는 발언 필터링 | ||
| List<Meeting> findByMeetingDetailsContaining(String keyword); | ||
| } |
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,41 @@ | ||
| package org.groomUniv.meet.oauth.entity; | ||
|
|
||
| import jakarta.persistence.*; | ||
| import lombok.Data; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @NoArgsConstructor | ||
| @Entity | ||
| @Getter | ||
| @Table(name = "member") | ||
| public class Member { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private Long memberId; | ||
|
|
||
| @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) | ||
| @JoinColumn(name = "preference_id") | ||
| private MemberPreference memberPreference; | ||
|
|
||
|
|
||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "school_id") | ||
| private School school; | ||
|
|
||
|
|
||
| private String email; | ||
| // password는 security로 암홓화해야함 | ||
| private String password; | ||
|
|
||
| private String name; | ||
| private String image; | ||
|
|
||
| private Long height; | ||
| private Long age; | ||
| private String biography; | ||
| private String major; | ||
|
|
||
| private boolean emailVerified; | ||
| } |
34 changes: 34 additions & 0 deletions
34
src/main/java/org/groomUniv/meet/oauth/entity/MemberPreference.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,34 @@ | ||
| package org.groomUniv.meet.oauth.entity; | ||
|
|
||
| import jakarta.persistence.*; | ||
| import lombok.Data; | ||
| import lombok.Getter; | ||
| import org.groomUniv.meet.oauth.enums.*; | ||
|
|
||
| @Getter | ||
| @Entity | ||
| public class MemberPreference { | ||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private Long preference_id; | ||
|
|
||
| @OneToOne(mappedBy = "memberPreference", fetch = FetchType.LAZY) | ||
| private Member member; | ||
|
|
||
| private Long desired_age_min; | ||
| private Long desired_age_max; | ||
| private Long desired_height_min; | ||
| private Long desired_height_max; | ||
| private String desired_school; | ||
| private String desired_major; | ||
| private String additional_criteria; | ||
|
|
||
| // enum타입으로 받아야할 것들 | ||
| private BodyType bodyType; | ||
| private Drinking drinking; | ||
| private Hobby hobby; | ||
| private Mbti mbti; | ||
| private Religion religion; | ||
| private Smoke smoke; | ||
| private Style style; | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
현재 각 도메인마다 필요할 때, 애노테이션을 지정해서 사용하고 있는데,
차라리 공통패키지에 japAuditing을 활용해서 baseEntity를 만들고, 해당 엔티티 안에서 생성일자, 수정일자를 관리하게 하고
이 baseEntity를 상속해서 사용하는건 어떤가요?
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.
아 겹치는 부분에 대해서는 baseEntity 고려해서 올려보겠습니다 감사합니다