diff --git a/src/main/java/com/example/demo/aop/aspect/SessionCheckAspect.java b/src/main/java/com/example/demo/aop/aspect/SessionCheckAspect.java index 3043c98..37faa6d 100644 --- a/src/main/java/com/example/demo/aop/aspect/SessionCheckAspect.java +++ b/src/main/java/com/example/demo/aop/aspect/SessionCheckAspect.java @@ -10,6 +10,7 @@ import org.aspectj.lang.annotation.Pointcut; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import com.example.demo.app.presentation.controller.pageproperty.SessionKeyword; import com.example.demo.exception.NoSessionException; @@ -32,7 +33,7 @@ public class SessionCheckAspect { public void checkSession() { HttpSession session = request.getSession(false); - if (session == null || session.getAttribute("loginUser") == null) { + if (session == null || session.getAttribute(SessionKeyword.LOGIN_USER) == null) { throw new NoSessionException("不正なログインです"); } diff --git a/src/main/java/com/example/demo/aop/handler/GlobalExceptionHandler.java b/src/main/java/com/example/demo/aop/handler/GlobalExceptionHandler.java index 2814100..83554ed 100644 --- a/src/main/java/com/example/demo/aop/handler/GlobalExceptionHandler.java +++ b/src/main/java/com/example/demo/aop/handler/GlobalExceptionHandler.java @@ -12,6 +12,8 @@ import org.springframework.web.HttpRequestMethodNotSupportedException; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; +import com.example.demo.app.presentation.controller.pageproperty.PageReturnAttributeKeyword; +import com.example.demo.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword; import com.example.demo.exception.NoSessionException; @ControllerAdvice @@ -30,18 +32,18 @@ public class GlobalExceptionHandler { LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE_ILLEGAL_TRANSITION, e); model.addAttribute( - "errorMessage", + PageReturnAttributeKeyword.ERROR_MESSAGE, "システムエラーが発生しました。" + "初めからやり直してください。"); - return "redirect:/login"; + return TransitionTargetPageNameKeyword.REDIRECT + TransitionTargetPageNameKeyword.LOGIN; } @ExceptionHandler(HttpRequestMethodNotSupportedException.class) public String handleBadRequestException(Model model, Exception e, HttpSession session) { - model.addAttribute("error", SEVERE_ERROR_MESSAGE_BAD_REQUEST); - model.addAttribute("status", HttpStatus.BAD_REQUEST.value()); + model.addAttribute(PageReturnAttributeKeyword.ERROR, SEVERE_ERROR_MESSAGE_BAD_REQUEST); + model.addAttribute(PageReturnAttributeKeyword.STATUS, HttpStatus.BAD_REQUEST.value()); e.printStackTrace(); @@ -50,7 +52,7 @@ public class GlobalExceptionHandler { System.out.println("session invalidated"); session.invalidate(); - return "error"; + return TransitionTargetPageNameKeyword.ERROR_HTML; } @ExceptionHandler(Exception.class) @@ -60,6 +62,6 @@ public class GlobalExceptionHandler { System.out.println("session invalidated exception"); session.invalidate(); - return "error"; + return TransitionTargetPageNameKeyword.ERROR_HTML; } } diff --git a/src/main/java/com/example/demo/app/domain/service/impl/LoginServiceImpl.java b/src/main/java/com/example/demo/app/domain/service/impl/LoginServiceImpl.java index 26ef947..d11347e 100644 --- a/src/main/java/com/example/demo/app/domain/service/impl/LoginServiceImpl.java +++ b/src/main/java/com/example/demo/app/domain/service/impl/LoginServiceImpl.java @@ -25,6 +25,8 @@ public class LoginServiceImpl implements LoginService { if (userEntity == null) { return null; + } else if (userEntity.getDeleteFlag() == 1) { + return null; } boolean isValidPassword = false; diff --git a/src/main/java/com/example/demo/app/presentation/controller/GoalController.java b/src/main/java/com/example/demo/app/presentation/controller/GoalController.java index cb7ee49..2ced072 100644 --- a/src/main/java/com/example/demo/app/presentation/controller/GoalController.java +++ b/src/main/java/com/example/demo/app/presentation/controller/GoalController.java @@ -275,7 +275,7 @@ public class GoalController { int currentAmount = goalService.getCurrentAmount(userId); - model.addAttribute("currentAmount", currentAmount); + model.addAttribute(PageReturnAttributeKeyword.CURRENT_AMOUNT, currentAmount); return TransitionTargetPageNameKeyword.GOAL_CREATE_HTML; } diff --git a/src/main/java/com/example/demo/app/presentation/controller/pageproperty/PageReturnAttributeKeyword.java b/src/main/java/com/example/demo/app/presentation/controller/pageproperty/PageReturnAttributeKeyword.java index 3b0a32a..1b89364 100644 --- a/src/main/java/com/example/demo/app/presentation/controller/pageproperty/PageReturnAttributeKeyword.java +++ b/src/main/java/com/example/demo/app/presentation/controller/pageproperty/PageReturnAttributeKeyword.java @@ -4,7 +4,8 @@ public class PageReturnAttributeKeyword { public static final String ERROR_MESSAGE = "errorMessage"; public static final String MESSAGE = "message"; - + public static final String ERROR = "error"; + public static final String STATUS = "status"; public static final String QUESTION_LIST = "questionList"; public static final String USER_FORM = "userForm"; diff --git a/src/main/resources/templates/transaction_create.html b/src/main/resources/templates/transaction_create.html index 31db04f..53e3bd3 100644 --- a/src/main/resources/templates/transaction_create.html +++ b/src/main/resources/templates/transaction_create.html @@ -124,7 +124,7 @@ if (tType == "0") { transactionType.value = 0; - } else { + } else if (tType == "1") { transactionType.value = 1; }