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

View File

@@ -5,7 +5,7 @@ import com.example.demo.app.presentation.form.UserForm;
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);

View File

@@ -25,7 +25,7 @@ public class UserServiceImpl implements UserService {
private final CourseRepository courseRepository;
@Override
public void register(UserForm userForm, Long courseId) {
public void register(UserForm userForm, Long courseId, Long userId) {
UserEntity userEntity = new UserEntity();
@@ -44,12 +44,11 @@ public class UserServiceImpl implements UserService {
GoalEntity goalEntity = new GoalEntity();
goalEntity.setTargetAmount(Integer.parseInt(String.valueOf(userForm.getGoalId())));
goalEntity.setUserEntity(userRepository.findById(userId).get());
CourseEntity courseEntity = courseRepository.findById(courseId).orElse(null);
userEntity.setQuestionEntity(questionEntity);
userEntity.setGoalEntity(goalRepository.save(
goalEntity));
userEntity.setCourseEntity(courseEntity);
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.RequestParam;
import com.example.demo.app.domain.model.LoginModel;
import com.example.demo.app.domain.service.CourseService;
import com.example.demo.app.domain.service.QuestionService;
import com.example.demo.app.domain.service.UserService;
@@ -83,9 +84,11 @@ public class UserController {
Model model,
HttpSession session) {
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
Long courseId = courseService.findByName((String) session.getAttribute("selectedCourseName"));
userService.register(userForm, courseId);
userService.register(userForm, courseId, loginUser.getUserId());
return "redirect:/login";
}

View File

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