-
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
1 parent
72cf6fb
commit 7853bc5
Showing
29 changed files
with
386 additions
and
73 deletions.
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
src/main/java/com/modernfarmer/farmusspring/domain/farmclub/entity/FarmClub.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,69 @@ | ||
package com.modernfarmer.farmusspring.domain.farmclub.entity; | ||
|
||
import com.modernfarmer.farmusspring.domain.myveggiegarden.entity.Diary; | ||
import com.modernfarmer.farmusspring.global.common.BaseEntity; | ||
import jakarta.persistence.*; | ||
import lombok.*; | ||
import lombok.experimental.SuperBuilder; | ||
import org.joda.time.LocalDate; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
@Getter | ||
@SuperBuilder | ||
@Entity(name = "farm_club") | ||
public class FarmClub extends BaseEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "farm_club_id") | ||
private Long id; | ||
|
||
@Column(nullable = false) | ||
private String veggieInfoId; | ||
|
||
@Column(nullable = false) | ||
private String name; | ||
|
||
@Column(nullable = false) | ||
private String description; | ||
|
||
@Column(nullable = false) | ||
private String difficulty; | ||
|
||
@Column(nullable = false) | ||
private int maxUser; | ||
|
||
@Column(nullable = false) | ||
private LocalDate startedAt; | ||
|
||
@OneToMany(mappedBy = "farmClub") | ||
@Builder.Default | ||
private List<UserFarmClub> userFarmClubs = new ArrayList<>(); | ||
|
||
@OneToMany(mappedBy = "farmClub") | ||
@Builder.Default | ||
private List<Diary> diaries = new ArrayList<>(); | ||
|
||
public static FarmClub createFarmClub(String veggieInfoId, String name, String description, String difficulty, int maxUser, LocalDate startedAt){ | ||
return FarmClub.builder() | ||
.veggieInfoId(veggieInfoId) | ||
.name(name) | ||
.description(description) | ||
.difficulty(difficulty) | ||
.maxUser(maxUser) | ||
.startedAt(startedAt) | ||
.build(); | ||
} | ||
|
||
public void addUserFarmClub(UserFarmClub userFarmClub){ | ||
this.userFarmClubs.add(userFarmClub); | ||
} | ||
|
||
public void addDiary(Diary diary){ | ||
this.diaries.add(diary); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
src/main/java/com/modernfarmer/farmusspring/domain/farmclub/entity/MissionPost.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,64 @@ | ||
package com.modernfarmer.farmusspring.domain.farmclub.entity; | ||
|
||
import com.modernfarmer.farmusspring.global.common.BaseEntity; | ||
import jakarta.persistence.*; | ||
import lombok.*; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
@Getter | ||
@SuperBuilder | ||
@Entity(name = "mission_post") | ||
public class MissionPost extends BaseEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "mission_post_id") | ||
private Long id; | ||
|
||
@Column(nullable = false) | ||
private String content; | ||
|
||
@Column(nullable = false) | ||
private Long step_num; | ||
|
||
@Column(nullable = false) | ||
private String image; | ||
|
||
@OneToMany(mappedBy = "missionPost", cascade = CascadeType.REMOVE) | ||
@Builder.Default | ||
private List<MissionPostLike> missionPostLikes = new ArrayList<>(); | ||
|
||
@OneToMany(mappedBy = "missionPost", cascade = CascadeType.REMOVE) | ||
@Builder.Default | ||
private List<MissionPostComment> missionPostComments = new ArrayList<>(); | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "user_farm_club_id") | ||
private UserFarmClub userFarmClub; | ||
|
||
public static MissionPost createMissionPost(String content, Long step_num, String image, UserFarmClub userFarmClub){ | ||
MissionPost newMissionPost = MissionPost.builder() | ||
.content(content) | ||
.step_num(step_num) | ||
.image(image) | ||
.userFarmClub(userFarmClub) | ||
.build(); | ||
|
||
userFarmClub.addMissionPost(newMissionPost); | ||
|
||
return newMissionPost; | ||
} | ||
|
||
public void addLike(MissionPostLike missionPostLike) { | ||
missionPostLikes.add(missionPostLike); | ||
} | ||
|
||
public void addComment(MissionPostComment missionPostComment) { | ||
missionPostComments.add(missionPostComment); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
src/main/java/com/modernfarmer/farmusspring/domain/farmclub/entity/MissionPostComment.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,47 @@ | ||
package com.modernfarmer.farmusspring.domain.farmclub.entity; | ||
|
||
import com.modernfarmer.farmusspring.domain.user.entity.User; | ||
import com.modernfarmer.farmusspring.global.common.BaseEntity; | ||
import jakarta.persistence.*; | ||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
@Getter | ||
@SuperBuilder | ||
@Entity(name = "mission_post_comment") | ||
public class MissionPostComment extends BaseEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "mission_post_comment_id") | ||
private Long id; | ||
|
||
@Column(nullable = false) | ||
private String comment; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "mission_post_id") | ||
private MissionPost missionPost; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "user_id") | ||
private User user; | ||
|
||
public static MissionPostComment createMissionPostComment(String comment, MissionPost missionPost, User user){ | ||
MissionPostComment newMissionPostComment = MissionPostComment.builder() | ||
.comment(comment) | ||
.missionPost(missionPost) | ||
.user(user) | ||
.build(); | ||
|
||
missionPost.addComment(newMissionPostComment); | ||
user.addMissionPostComment(newMissionPostComment); | ||
|
||
return newMissionPostComment; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/main/java/com/modernfarmer/farmusspring/domain/farmclub/entity/MissionPostLike.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,43 @@ | ||
package com.modernfarmer.farmusspring.domain.farmclub.entity; | ||
|
||
import com.modernfarmer.farmusspring.domain.user.entity.User; | ||
import com.modernfarmer.farmusspring.global.common.BaseEntity; | ||
import jakarta.persistence.*; | ||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
@Getter | ||
@SuperBuilder | ||
@Entity(name = "mission_post_like") | ||
public class MissionPostLike extends BaseEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "mission_post_like_id") | ||
private Long id; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "mission_post_id") | ||
private MissionPost missionPost; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "user_id") | ||
private User user; | ||
|
||
public static MissionPostLike createMissionPostLike(MissionPost missionPost, User user){ | ||
MissionPostLike newMissionPostLike = MissionPostLike.builder() | ||
.missionPost(missionPost) | ||
.user(user) | ||
.build(); | ||
|
||
missionPost.addLike(newMissionPostLike); | ||
user.addMissionPostLike(newMissionPostLike); | ||
|
||
return newMissionPostLike; | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
src/main/java/com/modernfarmer/farmusspring/domain/farmclub/entity/UserFarmClub.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,68 @@ | ||
package com.modernfarmer.farmusspring.domain.farmclub.entity; | ||
|
||
import com.modernfarmer.farmusspring.domain.myveggiegarden.entity.MyVeggie; | ||
import com.modernfarmer.farmusspring.global.common.BaseEntity; | ||
import jakarta.persistence.*; | ||
import lombok.*; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
@Getter | ||
@SuperBuilder | ||
@Entity(name = "user_farm_club") | ||
public class UserFarmClub extends BaseEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "user_farm_club_id") | ||
private Long id; | ||
|
||
@Column(name = "user_id", nullable = false) | ||
private Long userId; | ||
|
||
@Column(nullable = false) | ||
private int currentStep; | ||
|
||
@Column(nullable = false) | ||
private String currentStepName; | ||
|
||
@OneToMany(mappedBy = "userFarmClub", cascade = CascadeType.REMOVE) | ||
@Builder.Default | ||
private List<MissionPost> missionPosts = new ArrayList<>(); | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "farm_club_id") | ||
private FarmClub farmClub; | ||
|
||
@OneToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "my_veggie_id") | ||
private MyVeggie myVeggie; | ||
|
||
public static UserFarmClub createUserFarmClub(Long userId, int currentStep, String currentStepName, FarmClub farmClub, MyVeggie myVeggie){ | ||
UserFarmClub newUserFarmClub = UserFarmClub.builder() | ||
.userId(userId) | ||
.currentStep(currentStep) | ||
.currentStepName(currentStepName) | ||
.farmClub(farmClub) | ||
.myVeggie(myVeggie) | ||
.build(); | ||
|
||
farmClub.addUserFarmClub(newUserFarmClub); | ||
myVeggie.setUserFarmClub(newUserFarmClub); | ||
|
||
return newUserFarmClub; | ||
} | ||
|
||
public void updateCurrentStep(int currentStep, String currentStepName){ | ||
this.currentStep = currentStep; | ||
this.currentStepName = currentStepName; | ||
} | ||
|
||
public void addMissionPost(MissionPost missionPost){ | ||
this.missionPosts.add(missionPost); | ||
} | ||
} |
4 changes: 0 additions & 4 deletions
4
...ava/com/modernfarmer/farmusspring/domain/myvegetablegarden/controller/TestController.java
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
src/main/java/com/modernfarmer/farmusspring/domain/myvegetablegarden/dto/TestDto.java
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
...ava/com/modernfarmer/farmusspring/domain/myvegetablegarden/repository/TestRepository.java
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
...main/java/com/modernfarmer/farmusspring/domain/myvegetablegarden/service/TestService.java
This file was deleted.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
...n/java/com/modernfarmer/farmusspring/domain/myveggiegarden/controller/TestController.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,4 @@ | ||
package com.modernfarmer.farmusspring.domain.myveggiegarden.controller; | ||
|
||
public class TestController { | ||
} |
4 changes: 4 additions & 0 deletions
4
src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/dto/TestDto.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,4 @@ | ||
package com.modernfarmer.farmusspring.domain.myveggiegarden.dto; | ||
|
||
public class TestDto { | ||
} |
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
2 changes: 1 addition & 1 deletion
2
...yvegetablegarden/entity/DiaryComment.java → ...n/myveggiegarden/entity/DiaryComment.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
2 changes: 1 addition & 1 deletion
2
...n/myvegetablegarden/entity/DiaryLike.java → ...main/myveggiegarden/entity/DiaryLike.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
Oops, something went wrong.