diff --git a/src/main/java/com/example/demo/app/domain/service/ProfileService.java b/src/main/java/com/example/demo/app/domain/service/ProfileService.java index 6dd2b8c..19441ab 100644 --- a/src/main/java/com/example/demo/app/domain/service/ProfileService.java +++ b/src/main/java/com/example/demo/app/domain/service/ProfileService.java @@ -3,5 +3,6 @@ package com.example.demo.app.domain.service; import com.example.demo.app.domain.model.ProfileModel; public interface ProfileService { - ProfileModel findOne(Long userId); + ProfileModel findOne(Long userId); + void withdraw(Long userId); } diff --git a/src/main/java/com/example/demo/app/domain/service/impl/ProfileServiceImpl.java b/src/main/java/com/example/demo/app/domain/service/impl/ProfileServiceImpl.java index 7df882c..f9fdbd7 100644 --- a/src/main/java/com/example/demo/app/domain/service/impl/ProfileServiceImpl.java +++ b/src/main/java/com/example/demo/app/domain/service/impl/ProfileServiceImpl.java @@ -31,4 +31,16 @@ public class ProfileServiceImpl implements ProfileService{ userEntity.getAnnualIncome(), userEntity.getMonthlyBudget()); } + + @Override + public void withdraw(Long userId) { + UserEntity userEntity =userRepository.findById(userId).orElse(null); + + if (userEntity == null) { + return; + } + + userEntity.setDeleteFlag(1); + userRepository.save(userEntity); + } } diff --git a/src/main/java/com/example/demo/app/presentation/controller/ProfileController.java b/src/main/java/com/example/demo/app/presentation/controller/ProfileController.java index f9a3f81..3829d49 100644 --- a/src/main/java/com/example/demo/app/presentation/controller/ProfileController.java +++ b/src/main/java/com/example/demo/app/presentation/controller/ProfileController.java @@ -5,6 +5,7 @@ import jakarta.servlet.http.HttpSession; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import com.example.demo.app.domain.model.LoginModel; import com.example.demo.app.domain.model.ProfileModel; @@ -29,4 +30,28 @@ public class ProfileController { model.addAttribute("profileForm", profileForm); return "profile"; } + + @GetMapping("/profile/edit") + public String showEditProfile() { + return "profile_edit"; + } + + @PostMapping("/withdraw") + public String withdraw(HttpSession session) { + + LoginModel loginUser = + (LoginModel) session.getAttribute("loginUser"); + + profileService.withdraw(loginUser.getUserId()); + + session.invalidate(); + + return "redirect:/login"; + } + + @PostMapping("/logout") + public String logout(HttpSession session) { + session.invalidate(); + return "redirect:/login"; + } } diff --git a/src/main/resources/templates/profile.html b/src/main/resources/templates/profile.html index 0853058..63cca4c 100644 --- a/src/main/resources/templates/profile.html +++ b/src/main/resources/templates/profile.html @@ -51,12 +51,13 @@ -
-