This commit is contained in:
2026-09-24 10:39:30 +09:00
2 changed files with 35 additions and 39 deletions

View File

@@ -16,7 +16,6 @@ import com.example.demo.app.presentation.form.UserForm;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class UserServiceImpl implements UserService { public class UserServiceImpl implements UserService {
@@ -41,14 +40,15 @@ public class UserServiceImpl implements UserService {
userEntity.setAnnualIncome(userForm.getAnnualIncome()); userEntity.setAnnualIncome(userForm.getAnnualIncome());
userEntity.setMonthlyBudget(userForm.getMonthlyBudget()); userEntity.setMonthlyBudget(userForm.getMonthlyBudget());
QuestionEntity questionEntity = QuestionEntity questionEntity = questionRepository.findById(userForm.getSecretQuestionId()).orElse(null);
questionRepository.findById(userForm.getSecretQuestionId()).orElse(null);
GoalEntity goalEntity = GoalEntity goalEntity = new GoalEntity();
goalRepository.findById(userForm.getGoalId()).orElse(null); goalEntity.setTargetAmount(Integer.parseInt(String.valueOf(userForm.getGoalId())));
CourseEntity courseEntity = goalRepository.save(
courseRepository.findById(courseId).orElse(null); goalEntity);
CourseEntity courseEntity = courseRepository.findById(courseId).orElse(null);
userEntity.setQuestionEntity(questionEntity); userEntity.setQuestionEntity(questionEntity);
userEntity.setGoalEntity(goalEntity); userEntity.setGoalEntity(goalEntity);
@@ -70,12 +70,8 @@ public class UserServiceImpl implements UserService {
userRepository.save(userEntity); userRepository.save(userEntity);
} }
public UserModel findByUserId(Long userId) { public UserModel findByUserId(Long userId) {
return UserModel.convertFrom(userRepository.findById(userId).get()); return UserModel.convertFrom(userRepository.findById(userId).get());
} }
} }

View File

@@ -32,14 +32,14 @@ public class GoalEntity {
@Column(name = "goal_subtitle", nullable = true) @Column(name = "goal_subtitle", nullable = true)
private String goalSubtitle; private String goalSubtitle;
@Column(name = "target_amount", nullable = false) @Column(name = "target_amount", nullable = true)
private Integer targetAmount; private Integer targetAmount;
@Column(name = "deadline", nullable = false) @Column(name = "deadline", nullable = true)
private LocalDate deadline; private LocalDate deadline = LocalDate.now().plusYears(1L);
@Column(name = "goal_complete", nullable = true) @Column(name = "goal_complete", nullable = false)
private Integer goalComplete; private Integer goalComplete = 0;
@OneToOne(mappedBy = "goalEntity") @OneToOne(mappedBy = "goalEntity")
private UserEntity userEntity; private UserEntity userEntity;