Skip to content

Commit

Permalink
Merge pull request #10 from GDSC-Hongik/feature/deploy
Browse files Browse the repository at this point in the history
Feature/deploy
  • Loading branch information
cmj7271 authored Jan 15, 2025
2 parents 97dcf64 + 9709f31 commit dec0f1f
Show file tree
Hide file tree
Showing 11 changed files with 181 additions and 11 deletions.
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -38,6 +39,9 @@ dependencies {
tasks.named('test') {
useJUnitPlatform()
}
tasks.named("jar") {
enabled = false
}

spotless {
java {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/gdgoc/study_group/day/domain/Day.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
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<Member, Long> {
/**
* 해당 멤버가 해당 상태를 가진 스터디 목록들을 반환합니다.
*
* @param memberId 검색할 대상이 되는 멤버의 PK
* @param memberStatus 검색할 대상이 되는 멤버가 스터디에서 가지길 기대하는 상태
* @return 해당 멤버가 포함되고, 해당 상태를 상태로 가지는 스터디들을 반환합니다.
*/
@Query(
"SELECT sm.study FROM StudyMember sm WHERE"
+ " sm.member.id = :id AND"
+ " sm.studyMemberStatus = :memberStatus")
List<Study> 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<StudyMemberStatus> findMemberStatus(
@Param("memberId") Long memberId, @Param("studyId") Long studyId);

/**
* 특정 멤버의 특정 스터디에 대한 상태 조회
*
* @param memberId 멤버 아이디
* @param studyId 스터디 아이디
* @return 스터디 지원 상태, 지원한 이력이 없다면 {@code Optional.empty()}
*/
@Query(
"SELECT sm FROM StudyMember sm WHERE"
+ " sm.member.id = :memberId AND"
+ " sm.study.id = :studyId")
Optional<StudyMemberStatus> findStudyMemberStatus(
@Param("memberId") Long memberId, @Param("studyId") Long studyId);

Member findByGithub(String github);
}
27 changes: 27 additions & 0 deletions src/main/java/com/gdgoc/study_group/round/dao/RoundRepository.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.gdgoc.study_group.round.dao;

import com.gdgoc.study_group.comment.domain.Comment;
import com.gdgoc.study_group.round.domain.Round;
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 RoundRepository extends JpaRepository<Round, Long> {
// ================ COMMENT ================ //
/**
* 회차의 모든 댓글 조회
*
* @param roundId 라운드 아이디
* @return 해당 라운드의 모든 댓글 리스트
*/
@Query("SELECT c FROM Comment c WHERE c.round.id = :roundId")
List<Comment> findComments(@Param("roundId") Long roundId);

@Query("SELECT c FROM Comment c WHERE c.round.id = :roundId AND" + " c.member.id = :memberId")
Optional<Comment> findCommentByMemberId(
@Param("roundId") Long roundId, @Param("memberId") Long memberId);
}
72 changes: 72 additions & 0 deletions src/main/java/com/gdgoc/study_group/study/dao/StudyRepository.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package com.gdgoc.study_group.study.dao;

import com.gdgoc.study_group.answer.domain.Answer;
import com.gdgoc.study_group.curriculum.domain.Curriculum;
import com.gdgoc.study_group.day.domain.Day;
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.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

@Repository
public interface StudyRepository extends JpaRepository<Study, Long> {
// ================ STUDY ================ //
/**
* 해당하는 스터디 상태를 가진 모든 스터디를 조회합니다
*
* @param studyStatus 조회를 원하는 스터디의 상태
* @return 해당 상태를 가진 스터디 List
*/
List<Study> findByStudyStatus(StudyStatus studyStatus);

/**
* 모집 중인 스터디 목록 조회
*
* @return 모집 중인 스터디 List
*/
@Query("SELECT s FROM Study s WHERE s.isApplicationClosed = false")
List<Study> findRecruitingStudy();

// ================ CURRICULUM ================ //
/**
* 스터디의 모든 커리큘럼을 조회합니다
*
* @param studyId 스터디 아이디
* @return 커리큘럼 List
*/
@Query(value = "SELECT c FROM Curriculum c WHERE c.study.id = :studyId")
List<Curriculum> findCurriculums(@Param("studyId") Long studyId);

/**
* 스터디의 특정 회차의 Curriculum 을 조회합니다
*
* @param studyId 스터디 아이디
* @param week 조회할 회차
* @return 해당 회차의 Curriculum
*/
@Query("SELECT c FROM Curriculum c WHERE" + " c.study.id = :studyId AND" + " c.week = :week")
Curriculum findCurriculumByWeek(@Param("studyId") Long studyId, @Param("week") Integer week);

// ================ DAY ================ //
/**
* 해당 스터디의 날짜 정보를 조회합니다
*
* @param studyId 조회할 스터디의 Id
* @return 해당 스터디의 주간 일정을 {@code List<Day> } 형식으로 반환
*/
@Query(value = "SELECT d FROM Day d WHERE d.study.id = :studyId")
List<Day> getStudyDay(@Param("studyId") Long studyId);

// ================ ANSWER ================ //
/**
* 해당 스터디의 모든 답변을 조회합니다
*
* @param studyId 검색할 스터디의 id
* @return 해당 스터디의 답변들을 반환
*/
@Query("SELECT a FROM Answer a WHERE a.study.id = :studyId")
List<Answer> findAnswers(@Param("studyId") Long studyId);
}
11 changes: 3 additions & 8 deletions src/main/java/com/gdgoc/study_group/study/domain/Study.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -37,11 +31,12 @@ public class Study {
private List<Answer> 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; // 멤버 지원 종료 여부(기본값은 지원 가능)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.gdgoc.study_group.study.domain;

public enum StudyStatus {
OFFLINE,
ONLINE,
FINISHED
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ public class StudyMember {
private Study study;

@Enumerated(EnumType.STRING)
private Status status;
private StudyMemberStatus studyMemberStatus;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.gdgoc.study_group.studyMember.domain;

public enum Status {
public enum StudyMemberStatus {
LEADER,
PARTICIPANT,
WAITING,
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
server:
port: ${SERVER_PORT}
address: ${SERVER_ADDRESS}

spring:
datasource:
Expand Down

0 comments on commit dec0f1f

Please sign in to comment.