From 2e748dc1cb153c8397ac7a40be988b1b5b80f982 Mon Sep 17 00:00:00 2001 From: s-choi Date: Thu, 10 Sep 2026 15:49:34 +0900 Subject: [PATCH] =?UTF-8?q?[STYLE]=20controller=E3=81=AE=E7=84=A1=E9=A7=84?= =?UTF-8?q?=E3=81=AA=E6=94=B9=E8=A1=8C=E3=82=84=E3=82=B9=E3=83=9A=E3=83=BC?= =?UTF-8?q?=E3=82=B9=E3=81=AA=E3=81=A9=E3=81=AE=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DeleteEmployeeController.java | 144 ++++------ .../controller/IndexController.java | 56 ++-- .../InsertEmployeeConfirmController.java | 164 +++++------ .../controller/InsertEmployeeController.java | 256 +++++++----------- .../InsertEmployeeInputController.java | 110 ++++---- .../controller/LoginController.java | 178 +++++------- .../controller/LogoutController.java | 86 +++--- .../controller/MenuController.java | 34 +-- 8 files changed, 411 insertions(+), 617 deletions(-) diff --git a/src/main/java/com/example/rhizome/app/presentation/controller/DeleteEmployeeController.java b/src/main/java/com/example/rhizome/app/presentation/controller/DeleteEmployeeController.java index 07982f7..e4e0457 100644 --- a/src/main/java/com/example/rhizome/app/presentation/controller/DeleteEmployeeController.java +++ b/src/main/java/com/example/rhizome/app/presentation/controller/DeleteEmployeeController.java @@ -1,5 +1,19 @@ package com.example.rhizome.app.presentation.controller; +import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.*; + +import java.util.Objects; +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.servlet.http.HttpSession; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; import com.example.rhizome.aop.aspect.PermissionCheck; import com.example.rhizome.aop.aspect.SessionCheck; @@ -12,110 +26,66 @@ import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTa import com.example.rhizome.app.presentation.form.DepartmentForm; import com.example.rhizome.app.presentation.form.LoginUserForm; import com.example.rhizome.app.presentation.form.MessageForm; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import javax.servlet.http.HttpSession; -import java.util.Objects; -import java.util.logging.Level; -import java.util.logging.Logger; - -import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.DELETE_EMPLOYEE; - -/** - * 削除処理のコントロータ - */ @Controller public class DeleteEmployeeController { - // ログ出力用インスタンス - private final static Logger LOGGER = Logger.getLogger(DeleteEmployeeController.class.getName()); + private final static Logger LOGGER = Logger.getLogger(DeleteEmployeeController.class.getName()); - // エラーメッセージ用の定数フィールド - private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!"; + private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!"; - HttpSession httpSession; - DeleteEmployee deleteEmployee; - SearchDepartment searchDepartment; + HttpSession httpSession; + DeleteEmployee deleteEmployee; + SearchDepartment searchDepartment; - @Autowired - public DeleteEmployeeController(DeleteEmployee deleteEmployee, SearchDepartment searchDepartment, HttpSession httpSession) { - this.httpSession = httpSession; - this.deleteEmployee = deleteEmployee; - this.searchDepartment = searchDepartment; - } + @Autowired + public DeleteEmployeeController(DeleteEmployee deleteEmployee, SearchDepartment searchDepartment, + HttpSession httpSession) { + this.httpSession = httpSession; + this.deleteEmployee = deleteEmployee; + this.searchDepartment = searchDepartment; + } - /** - * 削除処理のコントローラ - * - * @param idEmployee 削除対象のemployeeId - * @param model ビューにデータを渡すためのコンテナ - * @return 遷移先の画面 - */ - @PermissionCheck - @SessionCheck - @RequestMapping(value = DELETE_EMPLOYEE, method = RequestMethod.POST) - public String deleteEmployee(@RequestParam("idEmployee") Integer idEmployee, Model model) { + @PermissionCheck + @SessionCheck + @RequestMapping(value = DELETE_EMPLOYEE, method = RequestMethod.POST) + public String deleteEmployee(@RequestParam("idEmployee") Integer idEmployee, Model model) { - try { - // 部署一覧を取得し、画面に返す用のクラスに詰め替える - // 作成した部署一覧をセット - model.addAttribute( - PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, - DepartmentForm.convertFrom(searchDepartment.selectAll()) - ); + try { + model.addAttribute( + PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, + DepartmentForm.convertFrom(searchDepartment.selectAll())); - // 削除処理実施 - deleteExec( - model, - idEmployee, - LoginUserForm.convertTo((LoginUserForm) httpSession.getAttribute(SessionKeyword.LOGIN_USER))); + deleteExec( + model, + idEmployee, + LoginUserForm.convertTo((LoginUserForm) httpSession.getAttribute(SessionKeyword.LOGIN_USER))); - // 検索画面に遷移 - return "forward:" + TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_INFO_FORM_EMPTY; + return "forward:" + TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_INFO_FORM_EMPTY; - } catch (Exception e) { - // ログイン情報の破棄 - httpSession.invalidate(); + } catch (Exception e) { + httpSession.invalidate(); - e.printStackTrace(); - // エラーログ出力 - LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); - // エラー画面遷移 - return TransitionTargetPageNameKeyword.ERROR_HTML; - } - } + e.printStackTrace(); + LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); + return TransitionTargetPageNameKeyword.ERROR_HTML; + } + } - /** - * 削除処理実施 - * - * @param model ビューにデータを渡すためのコンテナ - * @param idEmployee 削除対象のemployeeId - * @param loginUser ログインユーザー情報 - */ - private void deleteExec(Model model, Integer idEmployee, LoginUser loginUser) { + private void deleteExec(Model model, Integer idEmployee, LoginUser loginUser) { - final String DELETE_TARGET_ID_CAN_NOT_DELETE = "ログイン者自身は削除出来ません。"; - final String DELETE_COMPLETE = "削除しました。"; + final String DELETE_TARGET_ID_CAN_NOT_DELETE = "ログイン者自身は削除出来ません。"; + final String DELETE_COMPLETE = "削除しました。"; - // ログインしている人が、削除対象かチェック - if (Objects.equals(loginUser.getIdEmployee(), idEmployee)) { - // 削除対象だった場合 - // エラーメッセージをセット - model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DELETE_TARGET_ID_CAN_NOT_DELETE)); - // 検索画面に遷移 - return; - } + if (Objects.equals(loginUser.getIdEmployee(), idEmployee)) { + model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, + new MessageForm(DELETE_TARGET_ID_CAN_NOT_DELETE)); + return; + } - // 削除を実施 - deleteEmployee.deleteEmployee(idEmployee); + deleteEmployee.deleteEmployee(idEmployee); - // 削除完了したメッセージをセット - model.addAttribute(PageReturnAttributeKeyword.MESSAGE_INFO, new MessageForm(DELETE_COMPLETE)); + model.addAttribute(PageReturnAttributeKeyword.MESSAGE_INFO, new MessageForm(DELETE_COMPLETE)); - } + } } diff --git a/src/main/java/com/example/rhizome/app/presentation/controller/IndexController.java b/src/main/java/com/example/rhizome/app/presentation/controller/IndexController.java index 93da70a..7ffb7f6 100644 --- a/src/main/java/com/example/rhizome/app/presentation/controller/IndexController.java +++ b/src/main/java/com/example/rhizome/app/presentation/controller/IndexController.java @@ -1,50 +1,42 @@ package com.example.rhizome.app.presentation.controller; -import com.example.rhizome.app.domain.service.impl.LoginImpl; -import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword; -import com.example.rhizome.app.presentation.form.LoginUserForm; +import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.*; + +import javax.servlet.http.HttpSession; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; -import javax.servlet.http.HttpSession; - -import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.*; +import com.example.rhizome.app.domain.service.impl.LoginImpl; +import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword; +import com.example.rhizome.app.presentation.form.LoginUserForm; @Controller public class IndexController { - HttpSession httpSession; + HttpSession httpSession; - @Autowired - public IndexController(HttpSession httpSession, LoginImpl loginImpl) { - this.httpSession = httpSession; - } + @Autowired + public IndexController(HttpSession httpSession, LoginImpl loginImpl) { + this.httpSession = httpSession; + } - @ModelAttribute - public LoginUserForm loginUserForm() { - return new LoginUserForm(); - } + @ModelAttribute + public LoginUserForm loginUserForm() { + return new LoginUserForm(); + } - /** - * ログイン画面表示処理 - * - * @param model ビューにデータを渡すためのコンテナ - * @return 遷移先の画面 - */ - @RequestMapping(value = {INDEX_BLANK, INDEX_SLASH, INDEX_LOGIN}) - public String index(Model model) { - // セッション情報を破棄 - if (httpSession != null) { - httpSession.invalidate(); - } + @RequestMapping(value = { INDEX_BLANK, INDEX_SLASH, INDEX_LOGIN }) + public String index(Model model) { + if (httpSession != null) { + httpSession.invalidate(); + } - // 空のFormをSessionに用意 - model.addAttribute(PageReturnAttributeKeyword.LOGIN_INFO_FORM, loginUserForm()); + model.addAttribute(PageReturnAttributeKeyword.LOGIN_INFO_FORM, loginUserForm()); - // ログイン画面に遷移 - return LOGIN_HTML; - } + return LOGIN_HTML; + } } diff --git a/src/main/java/com/example/rhizome/app/presentation/controller/InsertEmployeeConfirmController.java b/src/main/java/com/example/rhizome/app/presentation/controller/InsertEmployeeConfirmController.java index 4cdf8d1..a7734f2 100644 --- a/src/main/java/com/example/rhizome/app/presentation/controller/InsertEmployeeConfirmController.java +++ b/src/main/java/com/example/rhizome/app/presentation/controller/InsertEmployeeConfirmController.java @@ -1,5 +1,20 @@ package com.example.rhizome.app.presentation.controller; +import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.*; + +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.servlet.http.HttpSession; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + import com.example.rhizome.aop.aspect.PermissionCheck; import com.example.rhizome.aop.aspect.SessionCheck; import com.example.rhizome.app.domain.model.Employee; @@ -12,122 +27,73 @@ import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTa import com.example.rhizome.app.presentation.form.DepartmentForm; import com.example.rhizome.app.presentation.form.InsertEmployeeForm; import com.example.rhizome.app.presentation.form.MessageForm; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import javax.servlet.http.HttpSession; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; - -import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_CONFIRM; - -/** - * 新規登録者情報チェック用のコントローラ - */ @Controller public class InsertEmployeeConfirmController { - // ログ出力用インスタンス - private final static Logger LOGGER = Logger.getLogger(InsertEmployeeConfirmController.class.getName()); + private final static Logger LOGGER = Logger.getLogger(InsertEmployeeConfirmController.class.getName()); - // エラーメッセージ用の定数フィールド - private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!"; + private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!"; - HttpSession httpSession; - SearchDepartment searchDepartment; - SearchEmployee searchEmployee; + HttpSession httpSession; + SearchDepartment searchDepartment; + SearchEmployee searchEmployee; - @Autowired - public InsertEmployeeConfirmController( - HttpSession httpSession, - SearchDepartmentImpl searchDepartment, - SearchEmployeeImpl searchEmployee - ) { - this.httpSession = httpSession; - this.searchDepartment = searchDepartment; - this.searchEmployee = searchEmployee; - } + @Autowired + public InsertEmployeeConfirmController( + HttpSession httpSession, + SearchDepartmentImpl searchDepartment, + SearchEmployeeImpl searchEmployee) { + this.httpSession = httpSession; + this.searchDepartment = searchDepartment; + this.searchEmployee = searchEmployee; + } - @ModelAttribute - public InsertEmployeeForm insertEmployeeForm() { - return new InsertEmployeeForm(); - } + @ModelAttribute + public InsertEmployeeForm insertEmployeeForm() { + return new InsertEmployeeForm(); + } - /** - * 登録情報のチェックを行う - * - * @param insertEmployeeForm 登録情報 - * @param model ビューにデータを渡すためのコンテナ - * @return 遷移先の画面 - */ - @PermissionCheck - @SessionCheck - @RequestMapping(value = INSERT_EMPLOYEE_CONFIRM, method = RequestMethod.POST) - public String insertEmployeeConfirm(InsertEmployeeForm insertEmployeeForm, Model model) { + @PermissionCheck + @SessionCheck + @RequestMapping(value = INSERT_EMPLOYEE_CONFIRM, method = RequestMethod.POST) + public String insertEmployeeConfirm(InsertEmployeeForm insertEmployeeForm, Model model) { - try { - // 部署一覧を取得し、画面に返す用のクラスに詰め替える - // 作成した部署一覧をセット - model.addAttribute( - PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, - DepartmentForm.convertFrom( - searchDepartment.selectAll() - )); + try { + model.addAttribute( + PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, + DepartmentForm.convertFrom( + searchDepartment.selectAll())); - // 登録用パラメータチェック - List error = insertEmployeeForm.validateParameter(); + List error = insertEmployeeForm.validateParameter(); - // 入力内容に誤りがあるか - if (!error.isEmpty()) { - // 誤りがあった場合 - // 誤りがあった箇所のエラーメッセージを表示 - model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(String.join(", ", error) + "が不正です。")); - // 画面に返す為の登録情報をセット - model.addAttribute(PageReturnAttributeKeyword.INSERT_EMPLOYEE_FORM, insertEmployeeForm); - // 登録画面に遷移 - return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML; - } + if (!error.isEmpty()) { + model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, + new MessageForm(String.join(", ", error) + "が不正です。")); + model.addAttribute(PageReturnAttributeKeyword.INSERT_EMPLOYEE_FORM, insertEmployeeForm); + return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML; + } - final String DUPLICATION = "既に登録済みのメールアドレスです。"; + final String DUPLICATION = "既に登録済みのメールアドレスです。"; - // 登録対象のメールアドレスを元に検索 - List employeeList = searchEmployee.searchEmployee(insertEmployeeForm.getMailAddress()); + List employeeList = searchEmployee.searchEmployee(insertEmployeeForm.getMailAddress()); - // 検索結果があるか - if (!employeeList.isEmpty()) { - // 検索した結果0件ではない場合 - // 重複を許さないため、エラー処理 - model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DUPLICATION)); - // 画面に返す為の登録情報をセット - model.addAttribute(PageReturnAttributeKeyword.INSERT_EMPLOYEE_FORM, insertEmployeeForm); - // 登録画面に遷移 - return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML; - } + if (!employeeList.isEmpty()) { + model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DUPLICATION)); + model.addAttribute(PageReturnAttributeKeyword.INSERT_EMPLOYEE_FORM, insertEmployeeForm); + return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML; + } - // 登録確認ページに遷移 - model.addAttribute(PageReturnAttributeKeyword.INSERT_EMPLOYEE_FORM, insertEmployeeForm); - // 登録確認画面に遷移 - return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_CONFIRM_HTML; + model.addAttribute(PageReturnAttributeKeyword.INSERT_EMPLOYEE_FORM, insertEmployeeForm); + return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_CONFIRM_HTML; + } catch (Exception e) { + httpSession.invalidate(); - } catch (Exception e) { - // ログイン情報の破棄 - httpSession.invalidate(); + e.printStackTrace(); - e.printStackTrace(); - - // エラーログ出力 - LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); - // エラー画面遷移 - return TransitionTargetPageNameKeyword.ERROR_HTML; - } - } + LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); + return TransitionTargetPageNameKeyword.ERROR_HTML; + } + } } - - - diff --git a/src/main/java/com/example/rhizome/app/presentation/controller/InsertEmployeeController.java b/src/main/java/com/example/rhizome/app/presentation/controller/InsertEmployeeController.java index a532295..4445753 100644 --- a/src/main/java/com/example/rhizome/app/presentation/controller/InsertEmployeeController.java +++ b/src/main/java/com/example/rhizome/app/presentation/controller/InsertEmployeeController.java @@ -1,5 +1,21 @@ package com.example.rhizome.app.presentation.controller; +import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.*; + +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.servlet.http.HttpSession; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + import com.example.rhizome.aop.aspect.PermissionCheck; import com.example.rhizome.aop.aspect.SessionCheck; import com.example.rhizome.app.domain.service.RegisterEmployee; @@ -11,188 +27,120 @@ import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTa import com.example.rhizome.app.presentation.form.DepartmentForm; import com.example.rhizome.app.presentation.form.InsertEmployeeForm; import com.example.rhizome.app.presentation.form.MessageForm; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import javax.servlet.http.HttpSession; -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; - -import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.INSERT_EMPLOYEE; - -/** - * 新規登録用のコントローラ - */ @Controller public class InsertEmployeeController { - // ログ出力用インスタンス - private final static Logger LOGGER = Logger.getLogger(InsertEmployeeController.class.getName()); + private final static Logger LOGGER = Logger.getLogger(InsertEmployeeController.class.getName()); - // エラーメッセージ用の定数フィールド - private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!"; + private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!"; - HttpSession httpSession; - RegisterEmployee registerEmployee; - SearchDepartment searchDepartment; + HttpSession httpSession; + RegisterEmployee registerEmployee; + SearchDepartment searchDepartment; - @Autowired - public InsertEmployeeController(HttpSession httpSession, RegisterEmployeeImpl registerEmployee, SearchDepartmentImpl searchDepartment) { - this.httpSession = httpSession; - this.registerEmployee = registerEmployee; - this.searchDepartment = searchDepartment; - } + @Autowired + public InsertEmployeeController(HttpSession httpSession, RegisterEmployeeImpl registerEmployee, + SearchDepartmentImpl searchDepartment) { + this.httpSession = httpSession; + this.registerEmployee = registerEmployee; + this.searchDepartment = searchDepartment; + } - @ModelAttribute - public InsertEmployeeForm insertEmployeeForm() { - return new InsertEmployeeForm(); - } + @ModelAttribute + public InsertEmployeeForm insertEmployeeForm() { + return new InsertEmployeeForm(); + } - /** - * 新規登録画面表示処理 - * - * @param insertEmployeeForm 登録情報 - * @param model ビューにデータを渡すためのコンテナ - * @return 遷移先の画面 - */ - @PermissionCheck - @SessionCheck - @RequestMapping(value = INSERT_EMPLOYEE, method = RequestMethod.POST) - public String insertEmployee(InsertEmployeeForm insertEmployeeForm, Model model) { + @PermissionCheck + @SessionCheck + @RequestMapping(value = INSERT_EMPLOYEE, method = RequestMethod.POST) + public String insertEmployee(InsertEmployeeForm insertEmployeeForm, Model model) { - try { - // 部署一覧を取得し、画面に返す用のクラスに詰め替える - // 作成した部署一覧をセット - model.addAttribute( - PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, - DepartmentForm.convertFrom( - searchDepartment.selectAll() - )); + try { + model.addAttribute( + PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, + DepartmentForm.convertFrom( + searchDepartment.selectAll())); - // Confirm画面から渡ってきた値をチェック - List error = validateParameter( - insertEmployeeForm.getNmEmployee(), - insertEmployeeForm.getKnEmployee(), - insertEmployeeForm.getMailAddress(), - insertEmployeeForm.getPassword(), - insertEmployeeForm.getAdminAuth(), - insertEmployeeForm.getIdDepartment() - ); + List error = validateParameter( + insertEmployeeForm.getNmEmployee(), + insertEmployeeForm.getKnEmployee(), + insertEmployeeForm.getMailAddress(), + insertEmployeeForm.getPassword(), + insertEmployeeForm.getAdminAuth(), + insertEmployeeForm.getIdDepartment()); - // エラーが1件以上有る場合 - if (!error.isEmpty()) { - // エラー内容を画面に表示 - model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(String.join(", ", error) + "が不正です。")); - // 登録画面に遷移 - return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML; - } + if (!error.isEmpty()) { + model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, + new MessageForm(String.join(", ", error) + "が不正です。")); + return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML; + } - // 登録処理 - registerEmployee.registerEmployee(InsertEmployeeForm.convertTo(insertEmployeeForm)); - // 登録結果画面に遷移 - return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_RESULT_HTML; + registerEmployee.registerEmployee(InsertEmployeeForm.convertTo(insertEmployeeForm)); + return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_RESULT_HTML; - } catch (Exception e) { - // ログイン情報の破棄 - httpSession.invalidate(); + } catch (Exception e) { + httpSession.invalidate(); - e.printStackTrace(); + e.printStackTrace(); - // エラーログ出力 - LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); - // エラー画面遷移 - return TransitionTargetPageNameKeyword.ERROR_HTML; - } - } + LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); + return TransitionTargetPageNameKeyword.ERROR_HTML; + } + } - /** - * @param employeeName 登録対象の名前 - * @param employeeKana 登録対象のカナ - * @param mailAddress 登録対象のメールアドレス - * @param password 登録対象のパスワード - * @param management システム権限 - * @param departmentId 部署ID - * @return エラーが有った場合はエラー文言、無ければ空のリストが返る - */ - private List validateParameter( - String employeeName, - String employeeKana, - String mailAddress, - String password, - Integer management, - Integer departmentId - ) { + private List validateParameter( + String employeeName, + String employeeKana, + String mailAddress, + String password, + Integer management, + Integer departmentId) { - final String EMPLOYEE_NAME_NULL_BLANK = "社員名"; - final String EMPLOYEE_KANA_NULL_BLANK = "社員名フリガナ"; - final String MAIL_ADDRESS_NULL_BLANK = "メールアドレス"; - final String PASSWORD_NULL_BLANK = "パスワード"; - final String MANAGEMENT_ERROR = "管理者権限指定"; - final String DEPARTMENT_ID_NULL_BLANK = "所属部署"; + final String EMPLOYEE_NAME_NULL_BLANK = "社員名"; + final String EMPLOYEE_KANA_NULL_BLANK = "社員名フリガナ"; + final String MAIL_ADDRESS_NULL_BLANK = "メールアドレス"; + final String PASSWORD_NULL_BLANK = "パスワード"; + final String MANAGEMENT_ERROR = "管理者権限指定"; + final String DEPARTMENT_ID_NULL_BLANK = "所属部署"; - List error = new ArrayList<>(); + List error = new ArrayList<>(); - // null or 空文字判定 - if (isNullOrBlank(employeeName)) { - // エラー内容を追加 - error.add(EMPLOYEE_NAME_NULL_BLANK); - } + if (isNullOrBlank(employeeName)) { + error.add(EMPLOYEE_NAME_NULL_BLANK); + } - // null or 空文字判定 - if (isNullOrBlank(employeeKana)) { - // エラー内容を追加 - error.add(EMPLOYEE_KANA_NULL_BLANK); - } + if (isNullOrBlank(employeeKana)) { + error.add(EMPLOYEE_KANA_NULL_BLANK); + } - // null or 空文字判定 - if (isNullOrBlank(mailAddress)) { - // エラー内容を追加 - error.add(MAIL_ADDRESS_NULL_BLANK); - } + if (isNullOrBlank(mailAddress)) { + error.add(MAIL_ADDRESS_NULL_BLANK); + } - // null or 空文字判定 - if (isNullOrBlank(password)) { - // エラー内容を追加 - error.add(PASSWORD_NULL_BLANK); - } + if (isNullOrBlank(password)) { + error.add(PASSWORD_NULL_BLANK); + } - // 管理者権限の値が不正か - if (management == null) { - // エラー内容を追加 - error.add(MANAGEMENT_ERROR); - } + if (management == null) { + error.add(MANAGEMENT_ERROR); + } - // 所属部署の値が不正か - if (departmentId == null) { - // エラー内容を追加 - error.add(DEPARTMENT_ID_NULL_BLANK); - } + if (departmentId == null) { + error.add(DEPARTMENT_ID_NULL_BLANK); + } - return error; + return error; - } + } - /** - * 仮引数を null or 空 判定する - * - * @param str 判定対象の文字列 - * @return true:null or 空 false:null or 空 では無い - */ - private static boolean isNullOrBlank(String str) { - if (null == str) { - return true; - } + private static boolean isNullOrBlank(String str) { + if (null == str) { + return true; + } - return str.isBlank(); - } + return str.isBlank(); + } } - - - diff --git a/src/main/java/com/example/rhizome/app/presentation/controller/InsertEmployeeInputController.java b/src/main/java/com/example/rhizome/app/presentation/controller/InsertEmployeeInputController.java index fab6082..a51b90a 100644 --- a/src/main/java/com/example/rhizome/app/presentation/controller/InsertEmployeeInputController.java +++ b/src/main/java/com/example/rhizome/app/presentation/controller/InsertEmployeeInputController.java @@ -1,5 +1,19 @@ package com.example.rhizome.app.presentation.controller; +import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.*; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.servlet.http.HttpSession; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + import com.example.rhizome.aop.aspect.PermissionCheck; import com.example.rhizome.aop.aspect.SessionCheck; import com.example.rhizome.app.domain.service.RegisterEmployee; @@ -8,83 +22,51 @@ import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAt import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword; import com.example.rhizome.app.presentation.form.DepartmentForm; import com.example.rhizome.app.presentation.form.InsertEmployeeForm; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import javax.servlet.http.HttpSession; -import java.util.logging.Level; -import java.util.logging.Logger; - -import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT; - -/** - * 登録画面表示用コントローラ - */ @Controller public class InsertEmployeeInputController { - // ログ出力用インスタンス - private final static Logger LOGGER = Logger.getLogger(InsertEmployeeInputController.class.getName()); + private final static Logger LOGGER = Logger.getLogger(InsertEmployeeInputController.class.getName()); - // エラーメッセージ用の定数フィールド - private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!"; + private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!"; - HttpSession httpSession; - RegisterEmployee registerEmployee; - SearchDepartment searchDepartment; + HttpSession httpSession; + RegisterEmployee registerEmployee; + SearchDepartment searchDepartment; - @Autowired - public InsertEmployeeInputController(HttpSession httpSession, RegisterEmployee registerEmployee, SearchDepartment searchDepartment) { - this.httpSession = httpSession; - this.registerEmployee = registerEmployee; - this.searchDepartment = searchDepartment; - } + @Autowired + public InsertEmployeeInputController(HttpSession httpSession, RegisterEmployee registerEmployee, + SearchDepartment searchDepartment) { + this.httpSession = httpSession; + this.registerEmployee = registerEmployee; + this.searchDepartment = searchDepartment; + } - @ModelAttribute - public InsertEmployeeForm insertEmployeeForm() { - return new InsertEmployeeForm(); - } + @ModelAttribute + public InsertEmployeeForm insertEmployeeForm() { + return new InsertEmployeeForm(); + } + @SessionCheck + @PermissionCheck + @RequestMapping(value = INSERT_EMPLOYEE_INPUT, method = RequestMethod.POST) + public String insertInput(InsertEmployeeForm insertEmployeeForm, Model model) { - /** - * 登録画面表示処理 - * - * @param insertEmployeeForm 登録画面のフォーム - * @param model ビューにデータを渡すためのコンテナ - * @return 遷移先の画面 - */ - @SessionCheck - @PermissionCheck - @RequestMapping(value = INSERT_EMPLOYEE_INPUT, method = RequestMethod.POST) - public String insertInput(InsertEmployeeForm insertEmployeeForm, Model model) { + try { + model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, + DepartmentForm.convertFrom(searchDepartment.selectAll())); - try { - // 部署コードリストを作成し、画面に返す値としてセット - model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, DepartmentForm.convertFrom(searchDepartment.selectAll())); + model.addAttribute(PageReturnAttributeKeyword.INSERT_EMPLOYEE_FORM, insertEmployeeForm); - // パラメータをセット - model.addAttribute(PageReturnAttributeKeyword.INSERT_EMPLOYEE_FORM, insertEmployeeForm); + return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML; - // 登録画面に遷移 - return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML; + } catch (Exception e) { + httpSession.invalidate(); - } catch (Exception e) { - // ログイン情報の破棄 - httpSession.invalidate(); + e.printStackTrace(); - e.printStackTrace(); - - // エラーログ出力 - LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); - // エラー画面遷移 - return TransitionTargetPageNameKeyword.ERROR_HTML; - } - } + LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); + return TransitionTargetPageNameKeyword.ERROR_HTML; + } + } } - - - diff --git a/src/main/java/com/example/rhizome/app/presentation/controller/LoginController.java b/src/main/java/com/example/rhizome/app/presentation/controller/LoginController.java index 036bee3..1327f28 100644 --- a/src/main/java/com/example/rhizome/app/presentation/controller/LoginController.java +++ b/src/main/java/com/example/rhizome/app/presentation/controller/LoginController.java @@ -1,5 +1,18 @@ package com.example.rhizome.app.presentation.controller; +import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.*; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.servlet.http.HttpSession; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; import com.example.rhizome.app.domain.model.LoginInfo; import com.example.rhizome.app.domain.model.LoginUser; @@ -11,138 +24,81 @@ import com.example.rhizome.app.presentation.form.LoginInfoForm; import com.example.rhizome.app.presentation.form.LoginUserForm; import com.example.rhizome.app.presentation.form.MessageForm; import com.example.rhizome.app.presentation.form.UpdatePersonalUserForm; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import javax.servlet.http.HttpSession; -import java.util.logging.Level; -import java.util.logging.Logger; - -import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.DO_LOGIN; - -/** - * ログイン関連のコントローラ - */ @Controller public class LoginController { - // ログ出力用インスタンス - private final static Logger LOGGER = Logger.getLogger(LoginController.class.getName()); + private final static Logger LOGGER = Logger.getLogger(LoginController.class.getName()); - // エラーメッセージ用の定数フィールド - private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!"; + private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!"; - HttpSession httpSession; - Login login; + HttpSession httpSession; + Login login; - @Autowired - public LoginController(HttpSession httpSession, Login login) { - this.httpSession = httpSession; - this.login = login; - } + @Autowired + public LoginController(HttpSession httpSession, Login login) { + this.httpSession = httpSession; + this.login = login; + } - @ModelAttribute - public LoginUserForm loginUserForm() { - return new LoginUserForm(); - } + @ModelAttribute + public LoginUserForm loginUserForm() { + return new LoginUserForm(); + } - /** - * 画面から渡ってきたパラメータのチェックを行う - * - * @param loginInfoForm mailAddress, password を保持したインスタンス - * @param model ビューにデータを渡すためのコンテナ - * @return 遷移先の画面 - */ - @RequestMapping(value = DO_LOGIN, method = RequestMethod.POST) - public String doLogin(LoginInfoForm loginInfoForm, Model model) { + @RequestMapping(value = DO_LOGIN, method = RequestMethod.POST) + public String doLogin(LoginInfoForm loginInfoForm, Model model) { - // ログに出力する - final String MAIL_ADDRESS_PASSWORD_ERROR = "メールアドレス、パスワードの入力内容に誤りがあります"; - // 発生しうるErrorに対するメッセージ - final String LOGIN_ERROR = "IDまたはパスワードが間違っています"; + final String MAIL_ADDRESS_PASSWORD_ERROR = "メールアドレス、パスワードの入力内容に誤りがあります"; + final String LOGIN_ERROR = "IDまたはパスワードが間違っています"; - try { - // mailAddress, password の入力に誤りがあるかチェック - if (!LoginUserForm.checkParameter(loginInfoForm)) { + try { + if (!LoginUserForm.checkParameter(loginInfoForm)) { - // mail,passwordが仕様を満たしていない場合 - model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(MAIL_ADDRESS_PASSWORD_ERROR)); + model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, + new MessageForm(MAIL_ADDRESS_PASSWORD_ERROR)); - // エラーだった場合に login.html に処理を戻す。mailAddress, password を login.htmlに表示するために - // ここで addAttribute する - model.addAttribute(PageReturnAttributeKeyword.LOGIN_INFO_FORM, loginInfoForm); - // login.html に遷移する様に設定 - return TransitionTargetPageNameKeyword.LOGIN_HTML; - } + model.addAttribute(PageReturnAttributeKeyword.LOGIN_INFO_FORM, loginInfoForm); + return TransitionTargetPageNameKeyword.LOGIN_HTML; + } - // Login者情報インスタンスを作成 - LoginInfo loginInfo = createLoginInfo(httpSession, loginInfoForm); + LoginInfo loginInfo = createLoginInfo(httpSession, loginInfoForm); - // login 可能かチェック - if (!login.canLogin(loginInfo)) { - // ログイン不可の場合、エラーメッセージをセットして入力された値とともに login.html を再表示 - // 画面に表示するエラーメッセージをセット - model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(LOGIN_ERROR)); - // 画面に表示する mailAddress, password をセット - model.addAttribute(PageReturnAttributeKeyword.LOGIN_INFO_FORM, loginInfoForm); - // login.html に遷移 - return TransitionTargetPageNameKeyword.LOGIN_HTML; - } + if (!login.canLogin(loginInfo)) { + model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(LOGIN_ERROR)); + model.addAttribute(PageReturnAttributeKeyword.LOGIN_INFO_FORM, loginInfoForm); + return TransitionTargetPageNameKeyword.LOGIN_HTML; + } - // ログイン(インスタンス作成) - LoginUser loginUser = login.doLogin(loginInfo); + LoginUser loginUser = login.doLogin(loginInfo); - // ログイン者の情報をセッション情報に格納 - // セッションに loginUser 情報を保持し続ける = ログイン中として扱う - httpSession.setAttribute(SessionKeyword.LOGIN_USER, LoginUserForm.convertFrom(loginUser)); + httpSession.setAttribute(SessionKeyword.LOGIN_USER, LoginUserForm.convertFrom(loginUser)); - // 管理者かチェック - if (!loginUser.isAdminUser()) { - // 管理者ではない場合直で自分の情報を更新するページに遷移する - // 編集対象のログイン者の情報を画面に渡す値にセット - model.addAttribute(PageReturnAttributeKeyword.UPDATE_PERSONAL_EMPLOYEE_USER_FORM, UpdatePersonalUserForm.convertFrom(loginUser)); - // 個人の情報更新ページに遷移 - return TransitionTargetPageNameKeyword.UPDATE_PERSONAL_EMPLOYEE_INPUT_HTML; - } + if (!loginUser.isAdminUser()) { + model.addAttribute(PageReturnAttributeKeyword.UPDATE_PERSONAL_EMPLOYEE_USER_FORM, + UpdatePersonalUserForm.convertFrom(loginUser)); + return TransitionTargetPageNameKeyword.UPDATE_PERSONAL_EMPLOYEE_INPUT_HTML; + } - // メニュー画面に遷移 - return TransitionTargetPageNameKeyword.MENU_HTML; + return TransitionTargetPageNameKeyword.MENU_HTML; - } catch (Exception e) { - // ログイン情報の破棄 - httpSession.invalidate(); - e.printStackTrace(); - // エラーログ出力 - LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); - // エラー画面に遷移 - return TransitionTargetPageNameKeyword.ERROR_HTML; - } - } + } catch (Exception e) { + httpSession.invalidate(); + e.printStackTrace(); + LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); + return TransitionTargetPageNameKeyword.ERROR_HTML; + } + } - /** - * ログイン者情報のインスタンスを作成 - * - * @param httpSession セッション情報 - * @param loginInfoForm mailAddress, password を保持したインスタンス - */ - private static LoginInfo createLoginInfo(HttpSession httpSession, LoginInfoForm loginInfoForm) { - // セッションからログイン者情報を取得 - LoginUserForm loginUserForm = (LoginUserForm) httpSession.getAttribute(SessionKeyword.LOGIN_USER); + private static LoginInfo createLoginInfo(HttpSession httpSession, LoginInfoForm loginInfoForm) { + LoginUserForm loginUserForm = (LoginUserForm) httpSession.getAttribute(SessionKeyword.LOGIN_USER); - // セッションにログイン者情報があるか - if (loginUserForm != null) { - // セッションにログイン者情報がある場合 - return new LoginInfo(loginUserForm.getMailAddress(), loginUserForm.getPassword()); - } + if (loginUserForm != null) { + return new LoginInfo(loginUserForm.getMailAddress(), loginUserForm.getPassword()); + } - // セッションにない場合は画面からの input 値 を取得 - return new LoginInfo( - loginInfoForm.getMailAddress(), - loginInfoForm.getPassword() - ); - } + return new LoginInfo( + loginInfoForm.getMailAddress(), + loginInfoForm.getPassword()); + } } diff --git a/src/main/java/com/example/rhizome/app/presentation/controller/LogoutController.java b/src/main/java/com/example/rhizome/app/presentation/controller/LogoutController.java index dbc94fc..e03f51e 100644 --- a/src/main/java/com/example/rhizome/app/presentation/controller/LogoutController.java +++ b/src/main/java/com/example/rhizome/app/presentation/controller/LogoutController.java @@ -1,10 +1,12 @@ package com.example.rhizome.app.presentation.controller; -import com.example.rhizome.aop.aspect.PermissionCheck; -import com.example.rhizome.aop.aspect.SessionCheck; -import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword; -import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword; -import com.example.rhizome.app.presentation.form.LoginUserForm; +import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.*; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.servlet.http.HttpSession; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; @@ -12,62 +14,46 @@ import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; -import javax.servlet.http.HttpSession; -import java.util.logging.Level; -import java.util.logging.Logger; +import com.example.rhizome.aop.aspect.PermissionCheck; +import com.example.rhizome.aop.aspect.SessionCheck; +import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword; +import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword; +import com.example.rhizome.app.presentation.form.LoginUserForm; -import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.LOGOUT; - -/** - * ログアウト処理のコントローラ - */ @Controller public class LogoutController { - // ログ出力用インスタンス - private final static Logger LOGGER = Logger.getLogger(LogoutController.class.getName()); - // エラーメッセージ用の定数フィールド - private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!"; + private final static Logger LOGGER = Logger.getLogger(LogoutController.class.getName()); + private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!"; - HttpSession httpSession; + HttpSession httpSession; - @Autowired - public LogoutController(HttpSession httpSession) { - this.httpSession = httpSession; - } + @Autowired + public LogoutController(HttpSession httpSession) { + this.httpSession = httpSession; + } - @ModelAttribute - public LoginUserForm loginUserForm() { - return new LoginUserForm(); - } + @ModelAttribute + public LoginUserForm loginUserForm() { + return new LoginUserForm(); + } - /** - * ログアウト処理 - * - * @param model ビューにデータを渡すためのコンテナ - * @return 遷移先の画面 - */ - @PermissionCheck - @SessionCheck - @RequestMapping(value = LOGOUT, method = RequestMethod.POST) - public String doLogout(Model model) { - try { - // セッション情報の破棄 - httpSession.invalidate(); + @PermissionCheck + @SessionCheck + @RequestMapping(value = LOGOUT, method = RequestMethod.POST) + public String doLogout(Model model) { + try { + httpSession.invalidate(); - // ログイン画面に遷移するための情報を設定 - model.addAttribute(PageReturnAttributeKeyword.LOGIN_INFO_FORM, loginUserForm()); - // login.html に遷移 - return TransitionTargetPageNameKeyword.LOGIN_HTML; + model.addAttribute(PageReturnAttributeKeyword.LOGIN_INFO_FORM, loginUserForm()); + return TransitionTargetPageNameKeyword.LOGIN_HTML; - } catch (Exception e) { + } catch (Exception e) { - // エラーログ出力 - LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); - // エラーページに遷移 - return TransitionTargetPageNameKeyword.ERROR_HTML; - } + LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); + return TransitionTargetPageNameKeyword.ERROR_HTML; + } - } + } } diff --git a/src/main/java/com/example/rhizome/app/presentation/controller/MenuController.java b/src/main/java/com/example/rhizome/app/presentation/controller/MenuController.java index 7ba1e9f..91505f7 100644 --- a/src/main/java/com/example/rhizome/app/presentation/controller/MenuController.java +++ b/src/main/java/com/example/rhizome/app/presentation/controller/MenuController.java @@ -1,33 +1,27 @@ package com.example.rhizome.app.presentation.controller; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; + import com.example.rhizome.aop.aspect.PermissionCheck; import com.example.rhizome.aop.aspect.SessionCheck; import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword; import com.example.rhizome.app.presentation.form.MessageForm; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.RequestMapping; -/** - * メニュー画面表示用コントローラ - */ @Controller public class MenuController { - @ModelAttribute - public MessageForm messageForm() { - return new MessageForm(); - } + @ModelAttribute + public MessageForm messageForm() { + return new MessageForm(); + } - /** - * メニュー画面に遷移 - */ - @PermissionCheck - @SessionCheck - @RequestMapping(value = TransitionTargetPageNameKeyword.SHOW_MENU) - public String showMenu() { - // メニュー画面遷移 - return TransitionTargetPageNameKeyword.MENU_HTML; - } + @PermissionCheck + @SessionCheck + @RequestMapping(value = TransitionTargetPageNameKeyword.SHOW_MENU) + public String showMenu() { + return TransitionTargetPageNameKeyword.MENU_HTML; + } }