generated from Bamdoliro/repository-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 그룹, 멤버 엔티티 추가 - 그룹, 멤버 레포지토리 추가
- Loading branch information
Showing
5 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
src/main/java/com/soogung/simblue/domain/group/domain/Group.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.soogung.simblue.domain.group.domain; | ||
|
||
import com.soogung.simblue.domain.group.domain.type.GroupType; | ||
import com.soogung.simblue.global.entity.BaseTimeEntity; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import javax.persistence.*; | ||
|
||
@Entity | ||
@Table(name = "tbl_group") | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Getter | ||
public class Group extends BaseTimeEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "group_id") | ||
private Long id; | ||
|
||
@Column(nullable = false, length = 20) | ||
private String name; | ||
|
||
@Enumerated(EnumType.STRING) | ||
@Column(nullable = false, length = 10) | ||
private GroupType type; | ||
|
||
@Builder | ||
public Group(String name, GroupType type) { | ||
this.name = name; | ||
this.type = type; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/com/soogung/simblue/domain/group/domain/Member.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.soogung.simblue.domain.group.domain; | ||
|
||
import com.soogung.simblue.domain.user.domain.Student; | ||
import com.soogung.simblue.global.entity.BaseTimeEntity; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import javax.persistence.*; | ||
|
||
@Entity | ||
@Table(name = "tbl_member") | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Getter | ||
public class Member extends BaseTimeEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "group_id") | ||
private Long id; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "student_id", nullable = false) | ||
private Student student; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "group_id", nullable = false) | ||
private Group group; | ||
|
||
@Builder | ||
public Member(Student student, Group group) { | ||
this.student = student; | ||
this.group = group; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/com/soogung/simblue/domain/group/domain/repository/GroupRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.soogung.simblue.domain.group.domain.repository; | ||
|
||
import com.soogung.simblue.domain.group.domain.Group; | ||
import org.springframework.data.repository.CrudRepository; | ||
|
||
public interface GroupRepository extends CrudRepository<Group, Long> { | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/com/soogung/simblue/domain/group/domain/repository/MemberRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.soogung.simblue.domain.group.domain.repository; | ||
|
||
import com.soogung.simblue.domain.group.domain.Member; | ||
import org.springframework.data.repository.CrudRepository; | ||
|
||
public interface MemberRepository extends CrudRepository<Member, Long> { | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/com/soogung/simblue/domain/group/domain/type/GroupType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.soogung.simblue.domain.group.domain.type; | ||
|
||
public enum GroupType { | ||
|
||
CLASS, YEAR, MAJOR, ETC | ||
} |