|
|
|
|
@@ -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());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|