Skip to content

Commit

Permalink
[#26]Refactor: User에서 GitHub와 BaekJoon을 다른 도메인으로 분리
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobhboy committed May 9, 2023
1 parent a5bdc6b commit d3226f8
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 98 deletions.
66 changes: 66 additions & 0 deletions src/main/java/bssm/db/bssmgit/domain/baekjoon/domain/BaekJoon.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package bssm.db.bssmgit.domain.baekjoon.domain;

import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

import javax.persistence.*;

@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class BaekJoon {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column
private String bojAuthId;

@Column
private String bojImg;

@Column
private String bojBio;

@Column
private String randomCode;

@Column
private String bojId;

// solvedCount - 사용자가 푼 문제 수
@Column(length = 8)
private Integer solvedCount;

@Column(length = 64)
private Integer rating;

// tier - Bronze V를 1, Bronze IV를 2, ...,
// Ruby I을 30, Master를 31로 표현하는 사용자 티어
@Column(length = 4)
private Integer tier;

// maxStreak - 최대 연속 문제 풀이일 수
@Column(length = 8)
private Integer maxStreak;

public void updateBojAuthId(String bojAuthId) {
this.bojAuthId = bojAuthId;
}

public void updateRandomCode(String randomCode) {
this.randomCode = randomCode;
}

public void updateUserBojInfo(String bojId, Integer solvedCount, Integer tier, Integer rating, Integer maxStreak, String bojImg, String bio) {
this.bojId = bojId;
this.solvedCount = solvedCount;
this.tier = tier;
this.rating = Math.toIntExact(rating);
this.maxStreak = maxStreak;
this.bojImg = bojImg;
this.bojBio = bio;
}
}
67 changes: 67 additions & 0 deletions src/main/java/bssm/db/bssmgit/domain/github/domain/GitHub.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package bssm.db.bssmgit.domain.github.domain;

import bssm.db.bssmgit.domain.user.domain.type.Imaginary;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

import javax.persistence.*;

@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class GitHub {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(length = 64)
private String githubId;

@Column(length = 8)
private Integer commits;

@Column(length = 1024)
private String githubMsg;

@Column
private String githubImg;


@Enumerated(EnumType.STRING)
private Imaginary imaginary;

@Column
private Integer votingCount;

public void updateGitId(String githubId) {
this.githubId = githubId;
}

public void updateGitInfo(int commits, String bio, String githubImg) {
this.commits = commits;
this.githubMsg = bio;
this.githubImg = githubImg;
}

public boolean hasNotGithubId() {
return this.githubId == null;
}

public void initImaginary() {
this.imaginary = Imaginary.REAL_NUMBER;
}

public void initVotingCount() {
this.votingCount = 3;
}

public void updateImaginary() {
this.imaginary = Imaginary.IMAGINARY_NUMBER;
}

public void reductionVotingCount() {
this.votingCount--;
}
}
98 changes: 0 additions & 98 deletions src/main/java/bssm/db/bssmgit/domain/user/domain/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import bssm.db.bssmgit.domain.post.entity.Category;
import bssm.db.bssmgit.domain.post.entity.Post;
import bssm.db.bssmgit.domain.user.domain.type.Imaginary;
import bssm.db.bssmgit.domain.user.domain.type.Role;
import lombok.AllArgsConstructor;
import lombok.Builder;
Expand Down Expand Up @@ -67,54 +66,6 @@ public class User {
@Column(length = 32)
private String bsmToken;

@Column(length = 64)
private String githubId;

@Column(length = 8)
private Integer commits;

@Column(length = 1024)
private String githubMsg;

@Column
private String githubImg;

@Column
private String bojId;
// solvedCount - 사용자가 푼 문제 수
@Column(length = 8)
private Integer solvedCount;

@Column(length = 64)
private Integer rating;

// tier - Bronze V를 1, Bronze IV를 2, ...,
// Ruby I을 30, Master를 31로 표현하는 사용자 티어
@Column(length = 4)
private Integer tier;

// maxStreak - 최대 연속 문제 풀이일 수
@Column(length = 8)
private Integer maxStreak;

@Column
private String bojAuthId;

@Column
private String bojImg;

@Column
private String bojBio;

@Column
private String randomCode;

@Enumerated(EnumType.STRING)
private Imaginary imaginary;

@Column
private Integer votingCount;

public void updateStudentGrade(Integer studentGrade) {
this.studentGrade = studentGrade;
}
Expand All @@ -131,60 +82,11 @@ public void updateName(String name) {
this.name = name;
}

public void updateGitId(String githubId) {
this.githubId = githubId;
}

public void updateGitInfo(int commits, String bio, String githubImg) {
this.commits = commits;
this.githubMsg = bio;
this.githubImg = githubImg;
}

public void updateBojAuthId(String bojAuthId) {
this.bojAuthId = bojAuthId;
}

public void updateRandomCode(String randomCode) {
this.randomCode = randomCode;
}

public void updateUserBojInfo(String bojId, Integer solvedCount, Integer tier, Integer rating, Integer maxStreak, String bojImg, String bio) {
this.bojId = bojId;
this.solvedCount = solvedCount;
this.tier = tier;
this.rating = Math.toIntExact(rating);
this.maxStreak = maxStreak;
this.bojImg = bojImg;
this.bojBio = bio;
}

public void initImaginary() {
this.imaginary = Imaginary.REAL_NUMBER;
}

public void initVotingCount() {
this.votingCount = 3;
}

public void updateImaginary() {
this.imaginary = Imaginary.IMAGINARY_NUMBER;
}

public void addPostCategories(Category category) {
this.categories.add(category);
}

public void addPosts(Post post) {
this.posts.add(post);
}

public void reductionVotingCount() {
this.votingCount--;
}

public boolean hasNotGithubId() {
return this.githubId == null;
}

}

0 comments on commit d3226f8

Please sign in to comment.