[FIX] 目標カラムの条件と読み取れない問題を修正しました。

This commit is contained in:
s-choi
2026-09-24 10:39:03 +09:00
parent 336adf0dec
commit 65d80e6306
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 {
@@ -28,35 +27,36 @@ public class UserServiceImpl implements UserService {
@Override @Override
public void register(UserForm userForm, Long courseId) { public void register(UserForm userForm, Long courseId) {
UserEntity userEntity = new UserEntity(); UserEntity userEntity = new UserEntity();
userEntity.setUserName(userForm.getUserName()); userEntity.setUserName(userForm.getUserName());
userEntity.setMailAddress(userForm.getMailAddress()); userEntity.setMailAddress(userForm.getMailAddress());
userEntity.setPassword(userForm.getPassword()); userEntity.setPassword(userForm.getPassword());
userEntity.setSecretQuestionAnswer(userForm.getSecretAnswer()); userEntity.setSecretQuestionAnswer(userForm.getSecretAnswer());
userEntity.setBirthDate(userForm.getBirthDate()); userEntity.setBirthDate(userForm.getBirthDate());
userEntity.setSaving(userForm.getSaving()); userEntity.setSaving(userForm.getSaving());
userEntity.setBirthDate(userForm. getBirthDate()); userEntity.setBirthDate(userForm.getBirthDate());
userEntity.setSaving(userForm.getSaving()); userEntity.setSaving(userForm.getSaving());
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);
userEntity.setQuestionEntity(questionEntity); CourseEntity courseEntity = courseRepository.findById(courseId).orElse(null);
userEntity.setGoalEntity(goalEntity);
userEntity.setCourseEntity(courseEntity);
userEntity.setDeleteFlag(0); userEntity.setQuestionEntity(questionEntity);
userEntity.setGoalEntity(goalEntity);
userEntity.setCourseEntity(courseEntity);
userRepository.save(userEntity); userEntity.setDeleteFlag(0);
userRepository.save(userEntity);
} }
@Override @Override
@@ -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;