diff --git a/build.gradle b/build.gradle index f16a19e..e7bccc9 100644 --- a/build.gradle +++ b/build.gradle @@ -28,6 +28,7 @@ repositories { dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springframework.boot:spring-boot-starter-data-jpa' + implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.5.0' implementation 'org.postgresql:postgresql' compileOnly 'org.projectlombok:lombok' annotationProcessor 'org.projectlombok:lombok' diff --git a/src/main/java/com/gdgoc/study_group/answer/dao/AnswerRepository.java b/src/main/java/com/gdgoc/study_group/answer/dao/AnswerRepository.java new file mode 100644 index 0000000..ac5a52a --- /dev/null +++ b/src/main/java/com/gdgoc/study_group/answer/dao/AnswerRepository.java @@ -0,0 +1,15 @@ +package com.gdgoc.study_group.answer.dao; + +import com.gdgoc.study_group.answer.domain.Answer; +import java.util.List; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface AnswerRepository extends JpaRepository { + + boolean existsByMemberIdAndStudyId(Long memberId, Long studyId); + + // 스터디 신청 답변 조회 + List findByStudyId(Long studyId); +} diff --git a/src/main/java/com/gdgoc/study_group/comment/dao/CommentRepository.java b/src/main/java/com/gdgoc/study_group/comment/dao/CommentRepository.java new file mode 100644 index 0000000..21e9ab7 --- /dev/null +++ b/src/main/java/com/gdgoc/study_group/comment/dao/CommentRepository.java @@ -0,0 +1,8 @@ +package com.gdgoc.study_group.comment.dao; + +import com.gdgoc.study_group.comment.domain.Comment; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface CommentRepository extends JpaRepository {} diff --git a/src/main/java/com/gdgoc/study_group/curriculum/dao/CurriculumRepository.java b/src/main/java/com/gdgoc/study_group/curriculum/dao/CurriculumRepository.java new file mode 100644 index 0000000..cb6199b --- /dev/null +++ b/src/main/java/com/gdgoc/study_group/curriculum/dao/CurriculumRepository.java @@ -0,0 +1,8 @@ +package com.gdgoc.study_group.curriculum.dao; + +import com.gdgoc.study_group.curriculum.domain.Curriculum; +import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface CurriculumRepository extends CrudRepository {} diff --git a/src/main/java/com/gdgoc/study_group/curriculum/domain/Curriculum.java b/src/main/java/com/gdgoc/study_group/curriculum/domain/Curriculum.java index ba8fdae..5fc3795 100644 --- a/src/main/java/com/gdgoc/study_group/curriculum/domain/Curriculum.java +++ b/src/main/java/com/gdgoc/study_group/curriculum/domain/Curriculum.java @@ -7,8 +7,12 @@ import jakarta.persistence.Id; import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; +import lombok.Getter; +import lombok.Setter; @Entity +@Getter +@Setter public class Curriculum { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) diff --git a/src/main/java/com/gdgoc/study_group/day/dao/DayRepository.java b/src/main/java/com/gdgoc/study_group/day/dao/DayRepository.java new file mode 100644 index 0000000..1a8829c --- /dev/null +++ b/src/main/java/com/gdgoc/study_group/day/dao/DayRepository.java @@ -0,0 +1,8 @@ +package com.gdgoc.study_group.day.dao; + +import com.gdgoc.study_group.day.domain.Day; +import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface DayRepository extends CrudRepository {} diff --git a/src/main/java/com/gdgoc/study_group/day/domain/Day.java b/src/main/java/com/gdgoc/study_group/day/domain/Day.java index 876fbe2..4c299b7 100644 --- a/src/main/java/com/gdgoc/study_group/day/domain/Day.java +++ b/src/main/java/com/gdgoc/study_group/day/domain/Day.java @@ -8,8 +8,12 @@ import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; import java.time.LocalTime; +import lombok.Getter; +import lombok.Setter; @Entity +@Getter +@Setter public class Day { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) diff --git a/src/main/java/com/gdgoc/study_group/member/dao/MemberRepository.java b/src/main/java/com/gdgoc/study_group/member/dao/MemberRepository.java new file mode 100644 index 0000000..e5d322e --- /dev/null +++ b/src/main/java/com/gdgoc/study_group/member/dao/MemberRepository.java @@ -0,0 +1,43 @@ +package com.gdgoc.study_group.member.dao; + +import com.gdgoc.study_group.member.domain.Member; +import com.gdgoc.study_group.study.domain.Study; +import com.gdgoc.study_group.studyMember.domain.StudyMemberStatus; +import java.util.List; +import java.util.Optional; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +@Repository +public interface MemberRepository extends JpaRepository { + /** + * 해당 멤버가 해당 상태를 가진 스터디 목록들을 반환합니다. + * + * @param memberId 검색할 대상이 되는 멤버의 PK + * @param memberStatus 검색할 대상이 되는 멤버가 스터디에서 가지길 기대하는 상태 + * @return 해당 멤버가 포함되고, 해당 상태를 상태로 가지는 스터디들을 반환합니다. + */ + @Query( + "SELECT sm.study FROM StudyMember sm WHERE" + + " sm.member.id = :id AND" + + " sm.studyMemberStatus = :memberStatus") + List findByMemberIdAndStatus( + @Param("id") Long memberId, @Param("memberStatus") StudyMemberStatus memberStatus); + + /** + * 해당 멤버의 스터디에서의 상태를 조회합니다. + * + * @param memberId 검색할 멤버의 id + * @param studyId 검색할 스터디의 id + * @return 해당 스터디에서 멤버의 상태(Optional) + */ + @Query( + "SELECT sm.studyMemberStatus FROM StudyMember sm WHERE sm.member.id = :memberId AND" + + " sm.study.id = :studyId") + Optional findMemberStatus( + @Param("memberId") Long memberId, @Param("studyId") Long studyId); + + Member findByGithub(String github); +} diff --git a/src/main/java/com/gdgoc/study_group/round/dao/RoundRepository.java b/src/main/java/com/gdgoc/study_group/round/dao/RoundRepository.java new file mode 100644 index 0000000..45e1917 --- /dev/null +++ b/src/main/java/com/gdgoc/study_group/round/dao/RoundRepository.java @@ -0,0 +1,8 @@ +package com.gdgoc.study_group.round.dao; + +import com.gdgoc.study_group.round.domain.Round; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface RoundRepository extends JpaRepository {} diff --git a/src/main/java/com/gdgoc/study_group/roundMember/dao/RoundMemberRepository.java b/src/main/java/com/gdgoc/study_group/roundMember/dao/RoundMemberRepository.java new file mode 100644 index 0000000..67a25f5 --- /dev/null +++ b/src/main/java/com/gdgoc/study_group/roundMember/dao/RoundMemberRepository.java @@ -0,0 +1,8 @@ +package com.gdgoc.study_group.roundMember.dao; + +import com.gdgoc.study_group.roundMember.domain.RoundMember; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface RoundMemberRepository extends JpaRepository {} diff --git a/src/main/java/com/gdgoc/study_group/study/dao/StudyRepository.java b/src/main/java/com/gdgoc/study_group/study/dao/StudyRepository.java new file mode 100644 index 0000000..a977a8a --- /dev/null +++ b/src/main/java/com/gdgoc/study_group/study/dao/StudyRepository.java @@ -0,0 +1,17 @@ +package com.gdgoc.study_group.study.dao; + +import com.gdgoc.study_group.study.domain.Study; +import com.gdgoc.study_group.study.domain.StudyStatus; +import java.util.List; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface StudyRepository extends JpaRepository { + + // 특정 Status인 스터디 목록 조회 + List findByStatus(StudyStatus studyStatus); + + // 모집 중인 스터디 목록 조회(status != FINISHED) + List findByStatusNot(StudyStatus studyStatus); +} diff --git a/src/main/java/com/gdgoc/study_group/study/domain/Study.java b/src/main/java/com/gdgoc/study_group/study/domain/Study.java index 5ad7f86..5ed44a7 100644 --- a/src/main/java/com/gdgoc/study_group/study/domain/Study.java +++ b/src/main/java/com/gdgoc/study_group/study/domain/Study.java @@ -5,13 +5,7 @@ import com.gdgoc.study_group.day.domain.Day; import com.gdgoc.study_group.round.domain.Round; import com.gdgoc.study_group.studyMember.domain.StudyMember; -import jakarta.persistence.Entity; -import jakarta.persistence.EnumType; -import jakarta.persistence.Enumerated; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; -import jakarta.persistence.OneToMany; +import jakarta.persistence.*; import java.util.ArrayList; import java.util.List; @@ -37,11 +31,12 @@ public class Study { private List answers = new ArrayList<>(); @Enumerated(EnumType.STRING) - private Status status; + private StudyStatus studyStatus; private String name; private String description; private String requirement; // 지원 자격, nullable: 별도 요구 자격 없음 private String question; // 지원 질문, nullable: 지원 답변 없이 바로 신청 가능 private Integer maxParticipants; // null == 인원 제한 X + private Boolean isApplicationClosed = false; // 멤버 지원 종료 여부(기본값은 지원 가능) } diff --git a/src/main/java/com/gdgoc/study_group/study/domain/StudyStatus.java b/src/main/java/com/gdgoc/study_group/study/domain/StudyStatus.java new file mode 100644 index 0000000..3497750 --- /dev/null +++ b/src/main/java/com/gdgoc/study_group/study/domain/StudyStatus.java @@ -0,0 +1,7 @@ +package com.gdgoc.study_group.study.domain; + +public enum StudyStatus { + OFFLINE, + ONLINE, + FINISHED +} diff --git a/src/main/java/com/gdgoc/study_group/studyMember/domain/StudyMember.java b/src/main/java/com/gdgoc/study_group/studyMember/domain/StudyMember.java index b2ae7c5..9733efb 100644 --- a/src/main/java/com/gdgoc/study_group/studyMember/domain/StudyMember.java +++ b/src/main/java/com/gdgoc/study_group/studyMember/domain/StudyMember.java @@ -28,5 +28,5 @@ public class StudyMember { private Study study; @Enumerated(EnumType.STRING) - private Status status; + private StudyMemberStatus studyMemberStatus; } diff --git a/src/main/java/com/gdgoc/study_group/studyMember/domain/Status.java b/src/main/java/com/gdgoc/study_group/studyMember/domain/StudyMemberStatus.java similarity index 75% rename from src/main/java/com/gdgoc/study_group/studyMember/domain/Status.java rename to src/main/java/com/gdgoc/study_group/studyMember/domain/StudyMemberStatus.java index 2eea43b..31fb9a6 100644 --- a/src/main/java/com/gdgoc/study_group/studyMember/domain/Status.java +++ b/src/main/java/com/gdgoc/study_group/studyMember/domain/StudyMemberStatus.java @@ -1,6 +1,6 @@ package com.gdgoc.study_group.studyMember.domain; -public enum Status { +public enum StudyMemberStatus { LEADER, PARTICIPANT, WAITING,