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;
@Service
@RequiredArgsConstructor
public class UserServiceImpl implements UserService {
@@ -28,35 +27,36 @@ public class UserServiceImpl implements UserService {
@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
@@ -70,12 +70,8 @@ public class UserServiceImpl implements UserService {
userRepository.save(userEntity);
}
public UserModel findByUserId(Long userId) {
return UserModel.convertFrom(userRepository.findById(userId).get());
}
}

View File

@@ -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;