From 65d80e6306fe57b188878791768987ab15ec6fdc Mon Sep 17 00:00:00 2001 From: s-choi Date: Thu, 24 Sep 2026 10:39:03 +0900 Subject: [PATCH] =?UTF-8?q?[FIX]=20=E7=9B=AE=E6=A8=99=E3=82=AB=E3=83=A9?= =?UTF-8?q?=E3=83=A0=E3=81=AE=E6=9D=A1=E4=BB=B6=E3=81=A8=E8=AA=AD=E3=81=BF?= =?UTF-8?q?=E5=8F=96=E3=82=8C=E3=81=AA=E3=81=84=E5=95=8F=E9=A1=8C=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E3=81=97=E3=81=BE=E3=81=97=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/service/impl/UserServiceImpl.java | 64 +++++++++---------- .../demo/app/infra/entity/GoalEntity.java | 10 +-- 2 files changed, 35 insertions(+), 39 deletions(-) diff --git a/src/main/java/com/example/demo/app/domain/service/impl/UserServiceImpl.java b/src/main/java/com/example/demo/app/domain/service/impl/UserServiceImpl.java index b4872f7..6aa541c 100644 --- a/src/main/java/com/example/demo/app/domain/service/impl/UserServiceImpl.java +++ b/src/main/java/com/example/demo/app/domain/service/impl/UserServiceImpl.java @@ -16,7 +16,6 @@ import com.example.demo.app.presentation.form.UserForm; import lombok.RequiredArgsConstructor; - @Service @RequiredArgsConstructor public class UserServiceImpl implements UserService { @@ -24,58 +23,55 @@ public class UserServiceImpl implements UserService { private final QuestionRepository questionRepository; private final GoalRepository goalRepository; private final CourseRepository courseRepository; - + @Override public void register(UserForm userForm, Long courseId) { - UserEntity userEntity = new UserEntity(); + UserEntity userEntity = new UserEntity(); - userEntity.setUserName(userForm.getUserName()); - userEntity.setMailAddress(userForm.getMailAddress()); - userEntity.setPassword(userForm.getPassword()); - userEntity.setSecretQuestionAnswer(userForm.getSecretAnswer()); - userEntity.setBirthDate(userForm.getBirthDate()); - userEntity.setSaving(userForm.getSaving()); - userEntity.setBirthDate(userForm. getBirthDate()); - userEntity.setSaving(userForm.getSaving()); - userEntity.setAnnualIncome(userForm.getAnnualIncome()); - userEntity.setMonthlyBudget(userForm.getMonthlyBudget()); + userEntity.setUserName(userForm.getUserName()); + userEntity.setMailAddress(userForm.getMailAddress()); + userEntity.setPassword(userForm.getPassword()); + userEntity.setSecretQuestionAnswer(userForm.getSecretAnswer()); + userEntity.setBirthDate(userForm.getBirthDate()); + userEntity.setSaving(userForm.getSaving()); + userEntity.setBirthDate(userForm.getBirthDate()); + userEntity.setSaving(userForm.getSaving()); + userEntity.setAnnualIncome(userForm.getAnnualIncome()); + userEntity.setMonthlyBudget(userForm.getMonthlyBudget()); - QuestionEntity questionEntity = - questionRepository.findById(userForm.getSecretQuestionId()).orElse(null); + QuestionEntity questionEntity = questionRepository.findById(userForm.getSecretQuestionId()).orElse(null); - GoalEntity goalEntity = - goalRepository.findById(userForm.getGoalId()).orElse(null); + GoalEntity goalEntity = new GoalEntity(); + goalEntity.setTargetAmount(Integer.parseInt(String.valueOf(userForm.getGoalId()))); - CourseEntity courseEntity = - courseRepository.findById(courseId).orElse(null); + goalRepository.save( + goalEntity); - userEntity.setQuestionEntity(questionEntity); - userEntity.setGoalEntity(goalEntity); - userEntity.setCourseEntity(courseEntity); + CourseEntity courseEntity = courseRepository.findById(courseId).orElse(null); - userEntity.setDeleteFlag(0); + userEntity.setQuestionEntity(questionEntity); + userEntity.setGoalEntity(goalEntity); + userEntity.setCourseEntity(courseEntity); - userRepository.save(userEntity); + userEntity.setDeleteFlag(0); + + userRepository.save(userEntity); } - + @Override public void updateCourse(Long userId, Long courseId) { UserEntity userEntity = userRepository.findById(userId).orElseThrow(); - + CourseEntity courseEntity = courseRepository.findById(courseId).orElseThrow(); - + userEntity.setCourseEntity(courseEntity); - + userRepository.save(userEntity); } - - + public UserModel findByUserId(Long userId) { - + return UserModel.convertFrom(userRepository.findById(userId).get()); } } - - - diff --git a/src/main/java/com/example/demo/app/infra/entity/GoalEntity.java b/src/main/java/com/example/demo/app/infra/entity/GoalEntity.java index 2996fe6..e37c562 100644 --- a/src/main/java/com/example/demo/app/infra/entity/GoalEntity.java +++ b/src/main/java/com/example/demo/app/infra/entity/GoalEntity.java @@ -32,14 +32,14 @@ public class GoalEntity { @Column(name = "goal_subtitle", nullable = true) private String goalSubtitle; - @Column(name = "target_amount", nullable = false) + @Column(name = "target_amount", nullable = true) private Integer targetAmount; - @Column(name = "deadline", nullable = false) - private LocalDate deadline; + @Column(name = "deadline", nullable = true) + private LocalDate deadline = LocalDate.now().plusYears(1L); - @Column(name = "goal_complete", nullable = true) - private Integer goalComplete; + @Column(name = "goal_complete", nullable = false) + private Integer goalComplete = 0; @OneToOne(mappedBy = "goalEntity") private UserEntity userEntity;