From c4dacad7732e423cb1ddfdee64f0eb133c984340 Mon Sep 17 00:00:00 2001 From: Lee Haewon Date: Fri, 12 Jan 2024 18:23:54 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20goal=20=EB=93=B1=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20#9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/tenten/blooming/domain/goal/dto/GoalDto.java | 1 + .../java/tenten/blooming/domain/goal/entity/Goal.java | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/tenten/blooming/domain/goal/dto/GoalDto.java b/src/main/java/tenten/blooming/domain/goal/dto/GoalDto.java index a21af44..d7229e7 100644 --- a/src/main/java/tenten/blooming/domain/goal/dto/GoalDto.java +++ b/src/main/java/tenten/blooming/domain/goal/dto/GoalDto.java @@ -21,6 +21,7 @@ public Goal toEntity() { goal.setGoalName(goalName); goal.setCreatedAt(LocalDate.now()); goal.setIsActivate(true); + goal.setUserId(userId); return goal; } diff --git a/src/main/java/tenten/blooming/domain/goal/entity/Goal.java b/src/main/java/tenten/blooming/domain/goal/entity/Goal.java index 903c046..240b8e0 100644 --- a/src/main/java/tenten/blooming/domain/goal/entity/Goal.java +++ b/src/main/java/tenten/blooming/domain/goal/entity/Goal.java @@ -36,11 +36,15 @@ public class Goal { @Column(name = "is_activate") private Boolean isActivate; - @ManyToOne - @JoinColumn(name = "user_id") + @ManyToOne(targetEntity = User.class) + @JoinColumn(name = "user_id", insertable = false, updatable = false) private User user; + @Column(name = "user_id") + private Long userId; + @OneToMany(mappedBy = "goal") private List subgoals = new ArrayList<>(); + }