[EDIT] セッションチェック機能をつけました。

This commit is contained in:
s-choi
2026-09-18 16:08:07 +09:00
parent d308f14df4
commit af3e171006
7 changed files with 28 additions and 2 deletions

View File

@@ -6,6 +6,7 @@ import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import com.example.demo.aop.aspect.SessionCheck;
import com.example.demo.app.domain.model.AnalysisModel;
import com.example.demo.app.domain.model.LoginModel;
import com.example.demo.app.domain.service.AnalysisService;
@@ -20,6 +21,7 @@ public class AnalysisController {
private final AnalysisService analysisService;
@SessionCheck
@GetMapping("/analysis")
public String showAnalysis(Model model, HttpSession session) {

View File

@@ -7,6 +7,7 @@ import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import com.example.demo.aop.aspect.SessionCheck;
import com.example.demo.app.domain.model.AuthenticationModel;
import com.example.demo.app.domain.service.AuthenticationService;
import com.example.demo.app.infra.repository.QuestionRepository;
@@ -21,6 +22,7 @@ public class AuthenticationController {
private final AuthenticationService authenticationService;
private final QuestionRepository questionRepository;
@SessionCheck
@GetMapping("/authentication")
public String showAuthentication(Model model) {
@@ -30,6 +32,7 @@ public class AuthenticationController {
return "authentication";
}
@SessionCheck
@PostMapping("/authentication")
public String authenticate(
AuthenticationForm authenticationForm,

View File

@@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import com.example.demo.aop.aspect.SessionCheck;
import com.example.demo.app.domain.model.LoginModel;
import com.example.demo.app.domain.model.UserModel;
import com.example.demo.app.domain.service.CourseInfoService;
@@ -38,7 +39,7 @@ public class CourseController {
private final UserService userService;
@SessionCheck
@PostMapping("/select/register")
public String showSelectCourse(@ModelAttribute UserModel userModel, Model model) {
@@ -63,6 +64,7 @@ public class CourseController {
}
}
@SessionCheck
@PostMapping("/select/change")
public String showChangeCourse(Model model) {
@@ -87,6 +89,7 @@ public class CourseController {
}
}
@SessionCheck
@PostMapping("/change")
public String changeCourse(@RequestParam Long courseId) {

View File

@@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import com.example.demo.aop.aspect.SessionCheck;
import com.example.demo.app.domain.model.GoalModel;
import com.example.demo.app.domain.model.LoginModel;
import com.example.demo.app.domain.service.GoalService;
@@ -23,6 +24,7 @@ public class GoalController {
private final GoalService goalService;
@SessionCheck
@GetMapping("")
public String getGoal(Model model, HttpSession session) {
@@ -37,6 +39,7 @@ public class GoalController {
return "goal_view";
}
@SessionCheck
@GetMapping("/edit")
public String editGoal(Model model, HttpSession session) {
@@ -50,6 +53,7 @@ public class GoalController {
return "goal_edit";
}
@SessionCheck
@PostMapping("/update")
public String updateGoal(@ModelAttribute GoalForm goalForm, HttpSession session) {

View File

@@ -7,6 +7,7 @@ import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import com.example.demo.aop.aspect.SessionCheck;
import com.example.demo.app.domain.model.LoginModel;
import com.example.demo.app.domain.model.ProfileModel;
import com.example.demo.app.domain.service.ProfileService;
@@ -19,6 +20,7 @@ import lombok.RequiredArgsConstructor;
public class ProfileController {
private final ProfileService profileService;
@SessionCheck
@GetMapping("/profile")
public String profile(Model model, HttpSession session) {
LoginModel loginUser = (LoginModel) session.getAttribute("loginUser");
@@ -31,6 +33,7 @@ public class ProfileController {
return "profile";
}
@SessionCheck
@GetMapping("/profile/edit")
public String showEditProfile() {
return "profile_edit";
@@ -49,6 +52,7 @@ public class ProfileController {
return "redirect:/login";
}
@PostMapping("/logout")
public String logout(HttpSession session) {
session.invalidate();

View File

@@ -17,6 +17,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.aop.aspect.SessionCheck;
import com.example.demo.app.domain.model.LoginModel;
import com.example.demo.app.domain.service.CategoryService;
import com.example.demo.app.domain.service.GoalService;
@@ -41,6 +42,7 @@ public class TransactionController {
private final UserService userService;
// 一覧画面
@SessionCheck
@GetMapping("/transaction/list")
public String transactionList(
@RequestParam(required = false, defaultValue = "0") String years,
@@ -124,6 +126,7 @@ public class TransactionController {
}
// 詳細画面
@SessionCheck
@GetMapping("/transaction/detail")
public String findOne(@RequestParam(required = false) LocalDate todayDates, Model model, HttpSession session) {
@@ -176,6 +179,7 @@ public class TransactionController {
return "transaction_detail";
}
@SessionCheck
@GetMapping("/transaction/create")
public String createOneGet(@RequestParam(defaultValue = "") LocalDate today,
Model model) {
@@ -200,6 +204,7 @@ public class TransactionController {
return "transaction_create";
}
@SessionCheck
@PostMapping("/transaction/create")
public String createOnePost(@ModelAttribute TransactionForm transactionForm, @RequestParam LocalDate today,
Model model,
@@ -215,6 +220,7 @@ public class TransactionController {
}
@SessionCheck
@GetMapping("/transaction/update")
public String updateOneGet(@RequestParam Long transactionId, @RequestParam(defaultValue = "") LocalDate today,
Model model) {
@@ -246,6 +252,7 @@ public class TransactionController {
}
@SessionCheck
@PostMapping("/transaction/update")
public String updateOnePost(@RequestParam Long transactionId, @ModelAttribute TransactionForm transactionForm,
@RequestParam LocalDate today, Model model,
@@ -264,6 +271,7 @@ public class TransactionController {
}
@SessionCheck
@PostMapping("/transaction/delete")
public String deleteOne(@RequestParam Long transactionId, @RequestParam LocalDate today) {
@@ -271,6 +279,7 @@ public class TransactionController {
return "redirect:/transaction/detail?todayDates=" + today;
}
@SessionCheck
@GetMapping("/menu")
public String menu(HttpSession session, Model model,
@RequestParam(required = false, defaultValue = "0") String years,

View File

@@ -12,6 +12,7 @@ import com.example.demo.app.presentation.form.UserForm;
import lombok.RequiredArgsConstructor;
@Controller
@RequiredArgsConstructor
public class UserController {