Skip to content

Commit

Permalink
Merge pull request #4 from Q-Dang/feature/#3-도메인엔티티모델생성
Browse files Browse the repository at this point in the history
#3 [feat] : 도메인엔티티모델생성
  • Loading branch information
SeorinY authored Jun 4, 2023
2 parents 515ee3a + 46351d9 commit 9dbce4a
Show file tree
Hide file tree
Showing 12 changed files with 162 additions and 28 deletions.
4 changes: 2 additions & 2 deletions was/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ out/
### VS Code ###
.vscode/


### application.yml ###
application.yaml
application.yaml
application.yml
2 changes: 2 additions & 0 deletions was/src/main/java/qdang/group/was/WasApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;

@EnableJpaAuditing
@SpringBootApplication
public class WasApplication {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package qdang.group.was.global.util;

import jakarta.persistence.EntityListeners;
import jakarta.persistence.MappedSuperclass;
import lombok.Getter;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.time.LocalDateTime;

@Getter
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public class AuditingTimeEntity {

@CreatedDate
private LocalDateTime createdAt;

@LastModifiedDate
private LocalDateTime updatedAt;
}
46 changes: 40 additions & 6 deletions was/src/main/java/qdang/group/was/match/domain/Match.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,49 @@
package qdang.group.was.match.domain;


import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.*;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import qdang.group.was.matchProcess.domain.MatchProcess;
import qdang.group.was.userMatch.domain.UserMatch;

import java.time.Duration;
import java.time.LocalDateTime;
import java.util.List;

@Getter
@Entity
public class Match {
@Entity(name = "q_match")
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Match extends AuditingEntityListener {

@Id
@Column(name = "q_match_id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

}
@OneToMany(mappedBy = "match")
private List<UserMatch> userMatchList;

@Column(name = "user_count")
private int userCount;

private int matchTypeCode;

@Enumerated(EnumType.STRING)
private MatchType matchTypeName;

private LocalDateTime endAt;

private Duration duration;

private boolean deletedTf;

private boolean validTf;

@OneToMany(mappedBy = "match")
private List<UserMatch> userMatcheList;

@OneToMany(mappedBy = "match")
private List<MatchProcess> matchProcessList;
}
19 changes: 19 additions & 0 deletions was/src/main/java/qdang/group/was/match/domain/MatchType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package qdang.group.was.match.domain;

import jakarta.persistence.Embeddable;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public enum MatchType {

pool(0, "pool"),
BALL4(1, "ball4"),
BALL3(2, "ball3");

private final int matchTypeCode;
private final String matchTypeName;

}
Original file line number Diff line number Diff line change
@@ -1,13 +1,32 @@
package qdang.group.was.matchProcess.domain;

import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.*;
import lombok.Getter;
import qdang.group.was.match.domain.Match;
import qdang.group.was.user.domain.User;

@Getter
@Entity
@Entity(name = "q_match_process")
public class MatchProcess {

@Id
@Column(name = "q_match_process_id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "q_match_id")
private Match match;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "q_user_id")
private User user;

private int processCount;

private int turnCount;

private int phaseCount;

private boolean validTf;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@


import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import lombok.Getter;

Expand All @@ -10,5 +12,8 @@
public class PhoneAuth {

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


}

This file was deleted.

22 changes: 17 additions & 5 deletions was/src/main/java/qdang/group/was/user/domain/User.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
package qdang.group.was.user.domain;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.*;
import lombok.Getter;
import qdang.group.was.matchProcess.domain.MatchProcess;
import qdang.group.was.userMatch.domain.UserMatch;

import java.util.List;

@Getter
@Entity
@Entity(name = "q_user")
public class User {

@Id
@Column(name = "USER_ID")
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "q_user_id")
private Long id;

@OneToMany(mappedBy = "user")
private List<UserMatch> userMatchList;

@OneToMany(mappedBy = "user")
private List<MatchProcess> matchProcessList;


private String username;
private String phone;
private String password;
Expand All @@ -36,4 +46,6 @@ public class User {
private String agreeUpdateAt;
private String accessAt;
private String accessCount;


}
33 changes: 29 additions & 4 deletions was/src/main/java/qdang/group/was/userMatch/domain/UserMatch.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,39 @@
package qdang.group.was.userMatch.domain;

import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.*;
import lombok.Getter;
import qdang.group.was.global.util.AuditingTimeEntity;
import qdang.group.was.match.domain.Match;
import qdang.group.was.user.domain.User;

@Getter
@Entity
public class UserMatch {
@Entity(name = "q_user_match")
public class UserMatch extends AuditingTimeEntity {

@Id
@Column(name = "q_user_match_id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "q_user_id")
private User user;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "q_match_id")
private Match match;

private int targetScore;
private int finishCushionTargetScore;
private int finishBankShotTargetScore;
private boolean validTf;
private int score;
private int finishCushionScore;
private int finishBankShotScore;
private int ranking;
private int maxHighRun;
private int average;
private int inningCount;
private int succeedInningCount;
private int failedInningCount;
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package qdang.group.was.userMatchProcess.domain;

import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.*;
import lombok.Getter;

@Getter
@Entity
@Entity(name = "q_user_match_process")
public class UserMatchProcess {

@Id
@Column(name = "q_user_match_proccess_id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

}
1 change: 0 additions & 1 deletion was/src/main/resources/application.yaml

This file was deleted.

0 comments on commit 9dbce4a

Please sign in to comment.