This commit is contained in:
2026-09-24 13:39:17 +09:00
5 changed files with 8 additions and 8 deletions

View File

@@ -20,7 +20,6 @@ public class UserModel {
private Integer saving; private Integer saving;
private Integer annualIncome; private Integer annualIncome;
private Integer monthlyBudget; private Integer monthlyBudget;
private Long goalId;
private Long courseId; private Long courseId;
private Integer deleteFlag; private Integer deleteFlag;
@@ -36,7 +35,6 @@ public class UserModel {
userEntity.getSaving(), userEntity.getSaving(),
userEntity.getAnnualIncome(), userEntity.getAnnualIncome(),
userEntity.getMonthlyBudget(), userEntity.getMonthlyBudget(),
userEntity.getGoalEntity().getGoalId(),
userEntity.getCourseEntity().getCourseId(), userEntity.getCourseEntity().getCourseId(),
userEntity.getDeleteFlag() userEntity.getDeleteFlag()
); );

View File

@@ -5,7 +5,7 @@ import com.example.demo.app.presentation.form.UserForm;
public interface UserService { public interface UserService {
void register(UserForm userForm, Long courseId); public void register(UserForm userForm, Long courseId, Long userId);
public void updateCourse(Long userId, Long courseId); public void updateCourse(Long userId, Long courseId);

View File

@@ -25,7 +25,7 @@ public class UserServiceImpl implements UserService {
private final CourseRepository courseRepository; private final CourseRepository courseRepository;
@Override @Override
public void register(UserForm userForm, Long courseId) { public void register(UserForm userForm, Long courseId, Long userId) {
UserEntity userEntity = new UserEntity(); UserEntity userEntity = new UserEntity();
@@ -44,12 +44,11 @@ public class UserServiceImpl implements UserService {
GoalEntity goalEntity = new GoalEntity(); GoalEntity goalEntity = new GoalEntity();
goalEntity.setTargetAmount(Integer.parseInt(String.valueOf(userForm.getGoalId()))); goalEntity.setTargetAmount(Integer.parseInt(String.valueOf(userForm.getGoalId())));
goalEntity.setUserEntity(userRepository.findById(userId).get());
CourseEntity courseEntity = courseRepository.findById(courseId).orElse(null); CourseEntity courseEntity = courseRepository.findById(courseId).orElse(null);
userEntity.setQuestionEntity(questionEntity); userEntity.setQuestionEntity(questionEntity);
userEntity.setGoalEntity(goalRepository.save(
goalEntity));
userEntity.setCourseEntity(courseEntity); userEntity.setCourseEntity(courseEntity);
userEntity.setDeleteFlag(0); userEntity.setDeleteFlag(0);

View File

@@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import com.example.demo.app.domain.model.LoginModel;
import com.example.demo.app.domain.service.CourseService; import com.example.demo.app.domain.service.CourseService;
import com.example.demo.app.domain.service.QuestionService; import com.example.demo.app.domain.service.QuestionService;
import com.example.demo.app.domain.service.UserService; import com.example.demo.app.domain.service.UserService;
@@ -83,9 +84,11 @@ public class UserController {
Model model, Model model,
HttpSession session) { HttpSession session) {
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
Long courseId = courseService.findByName((String) session.getAttribute("selectedCourseName")); Long courseId = courseService.findByName((String) session.getAttribute("selectedCourseName"));
userService.register(userForm, courseId); userService.register(userForm, courseId, loginUser.getUserId());
return "redirect:/login"; return "redirect:/login";
} }

View File

@@ -36,7 +36,7 @@ public class UserForm {
userModel.getSaving(), userModel.getSaving(),
userModel.getAnnualIncome(), userModel.getAnnualIncome(),
userModel.getMonthlyBudget(), userModel.getMonthlyBudget(),
userModel.getGoalId(), 0L,
userModel.getCourseId() userModel.getCourseId()
); );
} }