Skip to content

Commit

Permalink
Merge pull request #6 from GDSC-Hongik/feature/domain
Browse files Browse the repository at this point in the history
domain 생성
  • Loading branch information
cmj7271 authored Jan 9, 2025
2 parents 0ecdbc2 + 5efbb97 commit 53385cc
Show file tree
Hide file tree
Showing 13 changed files with 328 additions and 7 deletions.
22 changes: 16 additions & 6 deletions .github/workflows/random_reviewer/reviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ function selectRandomReviewer() {
]
}

async function sendDiscordMsg(reviewer) {
async function sendDiscordMsg(reviewer, title) {
const webhook = process.env.DISCORD_WEBHOOK;

const msg = {
content: createMsg(reviewer)
content: createMsg(reviewer, title)
}

await fetch(webhook, {
Expand All @@ -31,15 +31,25 @@ async function sendDiscordMsg(reviewer) {
})
}

function createMsg(reviewer) {
return "리뷰해주세요\n" + "* PR: " + `https://github.com/${github.context.repo.owner}/${github.context.repo.repo}/pulls/${github.context.payload.pull_request.number}`
+ "\n* 담당자: @" + "<@&" + member[reviewer] + ">"
function createMsg(reviewer, title) {
return title + "\n" + "* PR: " + `https://github.com/${github.context.repo.owner}/${github.context.repo.repo}/pulls/${github.context.payload.pull_request.number}`
+ "\n* 담당자: " + "<@!" + member[reviewer] + ">"
}

async function main() {
const githubClient = github.getOctokit(process.env.REVIEW_TOKEN);
const reviewer = selectRandomReviewer();

const { owner, repo } = github.context.repo;

const pr = await githubClient.rest.pulls.get(
{
owner: owner,
repo: repo,
pull_number: github.context.payload.pull_request.number
}
)

githubClient.rest.pulls.requestReviewers(
{
owner: github.context.repo.owner,
Expand All @@ -51,7 +61,7 @@ async function main() {
.then((res) => console.log("reviewer assign success: ", res))
.catch((err) => console.log("reviewer assign failed:", err));

sendDiscordMsg(reviewer)
sendDiscordMsg(reviewer, pr.data.title)
.then(() => console.log("message send success"))
.catch(() => console.log("message send failed"));
}
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ repositories {
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.postgresql:postgresql'
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'org.postgresql:postgresql'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
Expand Down
27 changes: 27 additions & 0 deletions src/main/java/com/gdgoc/study_group/answer/domain/Answer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.gdgoc.study_group.answer.domain;

import com.gdgoc.study_group.member.domain.Member;
import com.gdgoc.study_group.study.domain.Study;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;

@Entity
public class Answer {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne
@JoinColumn(name = "member_id")
private Member member;

@ManyToOne
@JoinColumn(name = "study_id")
private Study study;

private String answer;
}
27 changes: 27 additions & 0 deletions src/main/java/com/gdgoc/study_group/comment/domain/Comment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.gdgoc.study_group.comment.domain;

import com.gdgoc.study_group.member.domain.Member;
import com.gdgoc.study_group.round.domain.Round;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;

@Entity
public class Comment {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne
@JoinColumn(name = "round_id")
private Round round;

@ManyToOne
@JoinColumn(name = "member_id")
private Member member;

private String comment;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.gdgoc.study_group.curriculum.domain;

import com.gdgoc.study_group.study.domain.Study;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;

@Entity
public class Curriculum {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne
@JoinColumn(name = "study_id", nullable = false)
private Study study;

private Integer week;
private String subject; // 해당 회차의 주제
}
24 changes: 24 additions & 0 deletions src/main/java/com/gdgoc/study_group/day/domain/Day.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.gdgoc.study_group.day.domain;

import com.gdgoc.study_group.study.domain.Study;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import java.time.LocalTime;

@Entity
public class Day {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne
@JoinColumn(name = "study_id", nullable = false)
private Study study;

private String day;
private LocalTime startTime;
}
28 changes: 28 additions & 0 deletions src/main/java/com/gdgoc/study_group/member/domain/Member.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.gdgoc.study_group.member.domain;

import com.gdgoc.study_group.roundMember.domain.RoundMember;
import com.gdgoc.study_group.studyMember.domain.StudyMember;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.OneToMany;
import java.util.ArrayList;
import java.util.List;

@Entity
public class Member {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@OneToMany(mappedBy = "member")
private List<StudyMember> studyMembers = new ArrayList<>();

@OneToMany(mappedBy = "member")
private List<RoundMember> roundMembers = new ArrayList<>();

private String name;
private String github;
private String studentNumber;
}
39 changes: 39 additions & 0 deletions src/main/java/com/gdgoc/study_group/round/domain/Round.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.gdgoc.study_group.round.domain;

import com.gdgoc.study_group.comment.domain.Comment;
import com.gdgoc.study_group.roundMember.domain.RoundMember;
import com.gdgoc.study_group.study.domain.Study;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;

@Entity
public class Round {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne
@JoinColumn(name = "study_id")
private Study study;

@OneToMany(mappedBy = "round")
private List<RoundMember> roundMembers = new ArrayList<>();

@OneToMany(mappedBy = "round")
private List<RoundThumbnail> images = new ArrayList<>();

@OneToMany(mappedBy = "round")
private List<Comment> comments = new ArrayList<>();

private String goal; // 학습 목표
private String studyDetail; // 학습 내용
private LocalDate roundDate; // 회차 진행한 날짜
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.gdgoc.study_group.round.domain;

import com.gdgoc.study_group.member.domain.Member;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;

@Entity
@Table(name = "ROUND_THUMBNAIL")
public class RoundThumbnail {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne
@JoinColumn(name = "round_id")
private Round round;

@OneToOne
@JoinColumn(name = "member_id")
private Member member;

private String fileName;
private String filePath; // 파일의 이름을 제외한 저장 위치
private String type; // jpeg, png...
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.gdgoc.study_group.roundMember.domain;

import com.gdgoc.study_group.member.domain.Member;
import com.gdgoc.study_group.round.domain.Round;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;

@Entity
@Table(name = "ROUND_MEMBER")
public class RoundMember {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne
@JoinColumn(name = "round_id")
private Round round;

@ManyToOne
@JoinColumn(name = "member_id")
private Member member;

private String retrospect; // 후기 내용
}
43 changes: 43 additions & 0 deletions src/main/java/com/gdgoc/study_group/study/domain/Study.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.gdgoc.study_group.study.domain;

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.round.domain.Round;
import com.gdgoc.study_group.studyMember.domain.StudyMember;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.OneToMany;
import java.util.ArrayList;
import java.util.List;

@Entity
public class Study {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@OneToMany(mappedBy = "study")
private List<StudyMember> studyMembers = new ArrayList<>();

@OneToMany(mappedBy = "study")
private List<Round> rounds = new ArrayList<>();

@OneToMany(mappedBy = "study")
private List<Curriculum> curriculums = new ArrayList<>();

@OneToMany(mappedBy = "study")
private List<Day> days = new ArrayList<>();

@OneToMany(mappedBy = "study")
private List<Answer> answers = new ArrayList<>();

private String name;
private String description;
private boolean isOffline;
private boolean isActive;
private Integer participants; // 현재 스터디 참여 인원
private Integer maxParticipants; // null == 인원 제한 X
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.gdgoc.study_group.studyMember.domain;

public enum Status {
LEADER,
PARTICIPANT,
WAITING,
CANCELED;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.gdgoc.study_group.studyMember.domain;

import com.gdgoc.study_group.member.domain.Member;
import com.gdgoc.study_group.study.domain.Study;
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.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;

@Entity
@Table(name = "STUDY_MEMBER")
public class StudyMember {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne
@JoinColumn(name = "member_id")
private Member member;

@ManyToOne
@JoinColumn(name = "study_id")
private Study study;

@Enumerated(EnumType.STRING)
private Status status;
}

0 comments on commit 53385cc

Please sign in to comment.