[STYLE] controllerの無駄な改行やスペースなどの削除
This commit is contained in:
@@ -1,5 +1,17 @@
|
|||||||
package com.example.rhizome.app.presentation.controller;
|
package com.example.rhizome.app.presentation.controller;
|
||||||
|
|
||||||
|
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.PermissionCheck;
|
||||||
import com.example.rhizome.aop.aspect.SessionCheck;
|
import com.example.rhizome.aop.aspect.SessionCheck;
|
||||||
import com.example.rhizome.app.domain.service.SearchDepartment;
|
import com.example.rhizome.app.domain.service.SearchDepartment;
|
||||||
@@ -9,113 +21,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.DepartmentForm;
|
||||||
import com.example.rhizome.app.presentation.form.EmployeeInfoForm;
|
import com.example.rhizome.app.presentation.form.EmployeeInfoForm;
|
||||||
import com.example.rhizome.app.presentation.form.SearchConditionEmployeeForm;
|
import com.example.rhizome.app.presentation.form.SearchConditionEmployeeForm;
|
||||||
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;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 社員検索画面用コントローラ リスト全件表示、検索表示、更新、削除が可能
|
|
||||||
*/
|
|
||||||
@Controller
|
@Controller
|
||||||
public class SelectEmployeeController {
|
public class SelectEmployeeController {
|
||||||
|
|
||||||
// ログ出力用インスタンス
|
private final static Logger LOGGER = Logger.getLogger(SelectEmployeeController.class.getName());
|
||||||
private final static Logger LOGGER = Logger.getLogger(SelectEmployeeController.class.getName());
|
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||||
// エラーメッセージ用の定数フィールド
|
|
||||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
|
||||||
|
|
||||||
HttpSession httpSession;
|
HttpSession httpSession;
|
||||||
SearchDepartment searchDepartment;
|
SearchDepartment searchDepartment;
|
||||||
SearchEmployeeInfo searchEmployeeInfo;
|
SearchEmployeeInfo searchEmployeeInfo;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public SelectEmployeeController(HttpSession httpSession, SearchDepartment searchDepartment, SearchEmployeeInfo searchEmployeeInfo) {
|
public SelectEmployeeController(HttpSession httpSession, SearchDepartment searchDepartment,
|
||||||
this.httpSession = httpSession;
|
SearchEmployeeInfo searchEmployeeInfo) {
|
||||||
this.searchDepartment = searchDepartment;
|
this.httpSession = httpSession;
|
||||||
this.searchEmployeeInfo = searchEmployeeInfo;
|
this.searchDepartment = searchDepartment;
|
||||||
}
|
this.searchEmployeeInfo = searchEmployeeInfo;
|
||||||
|
}
|
||||||
|
|
||||||
@ModelAttribute
|
@ModelAttribute
|
||||||
public SearchConditionEmployeeForm searchConditionEmployeeForm() {
|
public SearchConditionEmployeeForm searchConditionEmployeeForm() {
|
||||||
return new SearchConditionEmployeeForm();
|
return new SearchConditionEmployeeForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@PermissionCheck
|
||||||
* 社員検索画面表示処理コントローラ
|
@SessionCheck
|
||||||
*
|
@RequestMapping(value = TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_INFO, method = RequestMethod.POST)
|
||||||
* @param searchConditionEmployeeForm 検索画面のフォーム
|
public String select(SearchConditionEmployeeForm searchConditionEmployeeForm, Model model) {
|
||||||
* @param model ビューにデータを渡すためのコンテナ
|
try {
|
||||||
* @return 遷移先の画面
|
|
||||||
*/
|
|
||||||
@PermissionCheck
|
|
||||||
@SessionCheck
|
|
||||||
@RequestMapping(value = TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_INFO, method = RequestMethod.POST)
|
|
||||||
public String select(SearchConditionEmployeeForm searchConditionEmployeeForm, Model model) {
|
|
||||||
|
|
||||||
try {
|
model.addAttribute(
|
||||||
|
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||||
|
DepartmentForm.convertFrom(searchDepartment.selectAll()));
|
||||||
|
|
||||||
// 部署一覧を取得し、画面に返す用のクラスに詰め替える
|
model.addAttribute(PageReturnAttributeKeyword.EMPLOYEE_INFO_FORM_LIST, EmployeeInfoForm.convertFrom(
|
||||||
// 作成した部署一覧をセット
|
searchEmployeeInfo.searchBy(SearchConditionEmployeeForm.convertTo(searchConditionEmployeeForm))));
|
||||||
model.addAttribute(
|
return TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_HTML;
|
||||||
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
|
||||||
DepartmentForm.convertFrom(searchDepartment.selectAll())
|
|
||||||
);
|
|
||||||
|
|
||||||
// 検索条件を元に検索を実施
|
} catch (Exception e) {
|
||||||
// 取得した EmployeeInfo( employee + department )の情報を画面に返す用の型に詰め替えてセット
|
httpSession.invalidate();
|
||||||
model.addAttribute(PageReturnAttributeKeyword.EMPLOYEE_INFO_FORM_LIST, EmployeeInfoForm.convertFrom(searchEmployeeInfo.searchBy(SearchConditionEmployeeForm.convertTo(searchConditionEmployeeForm))));
|
|
||||||
// 検索ページに遷移
|
|
||||||
return TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_HTML;
|
|
||||||
|
|
||||||
|
e.printStackTrace();
|
||||||
|
|
||||||
} catch (Exception e) {
|
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||||
// ログイン情報の破棄
|
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||||
httpSession.invalidate();
|
}
|
||||||
|
|
||||||
e.printStackTrace();
|
}
|
||||||
|
|
||||||
// エラーログ出力
|
@RequestMapping(value = TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_INFO_FORM_EMPTY, method = RequestMethod.POST)
|
||||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
public String select(Model model) {
|
||||||
// エラー画面遷移
|
model.addAttribute(
|
||||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||||
}
|
DepartmentForm.convertFrom(searchDepartment.selectAll()));
|
||||||
|
|
||||||
}
|
model.addAttribute(PageReturnAttributeKeyword.EMPLOYEE_INFO_FORM_LIST,
|
||||||
|
EmployeeInfoForm.convertFrom(
|
||||||
|
searchEmployeeInfo.searchBy(
|
||||||
|
SearchConditionEmployeeForm.convertTo(searchConditionEmployeeForm()))));
|
||||||
|
|
||||||
/**
|
return TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_HTML;
|
||||||
* 社員検索画面表示処理コントローラ
|
}
|
||||||
* 検索条件無しの状態を作るため、空の検索条件で検索した結果を画面に返す
|
|
||||||
*
|
|
||||||
* @param model ビューにデータを渡すためのコンテナ
|
|
||||||
* @return 遷移先の画面
|
|
||||||
*/
|
|
||||||
@PermissionCheck
|
|
||||||
@SessionCheck
|
|
||||||
@RequestMapping(value = TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_INFO_FORM_EMPTY, method = RequestMethod.POST)
|
|
||||||
public String select(Model model) {
|
|
||||||
|
|
||||||
// 部署一覧を取得し、画面に返す用のクラスに詰め替える
|
|
||||||
// 作成した部署一覧をセット
|
|
||||||
model.addAttribute(
|
|
||||||
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
|
||||||
DepartmentForm.convertFrom(searchDepartment.selectAll())
|
|
||||||
);
|
|
||||||
|
|
||||||
// 検索条件を元に検索を実施
|
|
||||||
model.addAttribute(PageReturnAttributeKeyword.EMPLOYEE_INFO_FORM_LIST,
|
|
||||||
EmployeeInfoForm.convertFrom(
|
|
||||||
searchEmployeeInfo.searchBy(
|
|
||||||
SearchConditionEmployeeForm.convertTo(searchConditionEmployeeForm())
|
|
||||||
)));
|
|
||||||
|
|
||||||
// 検索ページに遷移
|
|
||||||
return TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_HTML;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,19 @@
|
|||||||
package com.example.rhizome.app.presentation.controller;
|
package com.example.rhizome.app.presentation.controller;
|
||||||
|
|
||||||
|
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 org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
import com.example.rhizome.aop.aspect.PermissionCheck;
|
import com.example.rhizome.aop.aspect.PermissionCheck;
|
||||||
import com.example.rhizome.aop.aspect.SessionCheck;
|
import com.example.rhizome.aop.aspect.SessionCheck;
|
||||||
import com.example.rhizome.app.domain.model.EmployeeInfo;
|
import com.example.rhizome.app.domain.model.EmployeeInfo;
|
||||||
@@ -12,96 +26,66 @@ import com.example.rhizome.app.presentation.form.DepartmentForm;
|
|||||||
import com.example.rhizome.app.presentation.form.MessageForm;
|
import com.example.rhizome.app.presentation.form.MessageForm;
|
||||||
import com.example.rhizome.app.presentation.form.SearchConditionEmployeeForm;
|
import com.example.rhizome.app.presentation.form.SearchConditionEmployeeForm;
|
||||||
import com.example.rhizome.app.presentation.form.UpdateEmployeeInfoForm;
|
import com.example.rhizome.app.presentation.form.UpdateEmployeeInfoForm;
|
||||||
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 org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpSession;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新対象の employee が存在するか確認する為のコントローラ
|
|
||||||
*/
|
|
||||||
@Controller
|
@Controller
|
||||||
public class UpdateEmployeeController {
|
public class UpdateEmployeeController {
|
||||||
|
|
||||||
// ログ出力用インスタンス
|
private final static Logger LOGGER = Logger.getLogger(UpdateEmployeeController.class.getName());
|
||||||
private final static Logger LOGGER = Logger.getLogger(UpdateEmployeeController.class.getName());
|
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||||
// エラーメッセージ用の定数フィールド
|
|
||||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
|
||||||
|
|
||||||
HttpSession httpSession;
|
HttpSession httpSession;
|
||||||
SearchDepartment searchDepartment;
|
SearchDepartment searchDepartment;
|
||||||
SearchEmployeeInfo searchEmployeeInfo;
|
SearchEmployeeInfo searchEmployeeInfo;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public UpdateEmployeeController(HttpSession httpSession, SearchDepartment searchDepartment, SearchEmployeeInfo searchEmployeeInfo) {
|
public UpdateEmployeeController(HttpSession httpSession, SearchDepartment searchDepartment,
|
||||||
this.httpSession = httpSession;
|
SearchEmployeeInfo searchEmployeeInfo) {
|
||||||
this.searchDepartment = searchDepartment;
|
this.httpSession = httpSession;
|
||||||
this.searchEmployeeInfo = searchEmployeeInfo;
|
this.searchDepartment = searchDepartment;
|
||||||
}
|
this.searchEmployeeInfo = searchEmployeeInfo;
|
||||||
|
}
|
||||||
|
|
||||||
@ModelAttribute
|
@ModelAttribute
|
||||||
public SearchConditionEmployeeForm searchConditionEmployeeForm() {
|
public SearchConditionEmployeeForm searchConditionEmployeeForm() {
|
||||||
return new SearchConditionEmployeeForm();
|
return new SearchConditionEmployeeForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@PermissionCheck
|
||||||
* 更新対象の employee が存在するか確認する為のコントローラ
|
@SessionCheck
|
||||||
*
|
@RequestMapping(value = TransitionTargetPageNameKeyword.SHOW_UPDATE_EMPLOYEE, method = RequestMethod.POST)
|
||||||
* @param idEmployee 更新対象の employee の id
|
public String showUpdateEmployee(@RequestParam("idEmployee") Integer idEmployee, Model model) {
|
||||||
* @param model ビューにデータを渡すためのコンテナ
|
final String UPDATE_TARGET_ID_NOT_FOUND = "更新対象のデータが見つかりません。";
|
||||||
* @return 遷移先の画面
|
|
||||||
*/
|
|
||||||
@PermissionCheck
|
|
||||||
@SessionCheck
|
|
||||||
@RequestMapping(value = TransitionTargetPageNameKeyword.SHOW_UPDATE_EMPLOYEE, method = RequestMethod.POST)
|
|
||||||
public String showUpdateEmployee(@RequestParam("idEmployee") Integer idEmployee, Model model) {
|
|
||||||
final String UPDATE_TARGET_ID_NOT_FOUND = "更新対象のデータが見つかりません。";
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 部署一覧を取得し画面に返す値としてセット
|
model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||||
model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, DepartmentForm.convertFrom(searchDepartment.selectAll()));
|
DepartmentForm.convertFrom(searchDepartment.selectAll()));
|
||||||
|
|
||||||
// id を条件に更新対象のレコードを検索、取得する
|
List<EmployeeInfo> employeeInfoList = searchEmployeeInfo.searchBy(
|
||||||
List<EmployeeInfo> employeeInfoList = searchEmployeeInfo.searchBy(
|
new SearchConditionEmployee(idEmployee,
|
||||||
new SearchConditionEmployee(idEmployee,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
null));
|
||||||
null));
|
|
||||||
|
|
||||||
// DBに更新対象のデータがあるか
|
if (employeeInfoList.isEmpty()) {
|
||||||
if (employeeInfoList.isEmpty()) {
|
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR,
|
||||||
// ない場合はエラーメッセージをセットして検索画面に戻る
|
new MessageForm(UPDATE_TARGET_ID_NOT_FOUND));
|
||||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(UPDATE_TARGET_ID_NOT_FOUND));
|
return "forward:" + TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_INFO;
|
||||||
return "forward:" + TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_INFO;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// 更新画面に遷移
|
model.addAttribute(PageReturnAttributeKeyword.UPDATE_EMPLOYEE_INFO_FORM,
|
||||||
model.addAttribute(PageReturnAttributeKeyword.UPDATE_EMPLOYEE_INFO_FORM, UpdateEmployeeInfoForm.convertFrom(employeeInfoList.get(0)));
|
UpdateEmployeeInfoForm.convertFrom(employeeInfoList.get(0)));
|
||||||
|
|
||||||
// Update画面に遷移
|
return TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_INPUT_HTML;
|
||||||
return TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_INPUT_HTML;
|
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
httpSession.invalidate();
|
||||||
|
|
||||||
} catch (Exception e) {
|
e.printStackTrace();
|
||||||
// ログイン情報の破棄
|
|
||||||
httpSession.invalidate();
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,18 @@
|
|||||||
package com.example.rhizome.app.presentation.controller;
|
package com.example.rhizome.app.presentation.controller;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
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.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.PermissionCheck;
|
||||||
import com.example.rhizome.aop.aspect.SessionCheck;
|
import com.example.rhizome.aop.aspect.SessionCheck;
|
||||||
@@ -15,192 +28,126 @@ import com.example.rhizome.app.presentation.form.DepartmentForm;
|
|||||||
import com.example.rhizome.app.presentation.form.LoginUserForm;
|
import com.example.rhizome.app.presentation.form.LoginUserForm;
|
||||||
import com.example.rhizome.app.presentation.form.MessageForm;
|
import com.example.rhizome.app.presentation.form.MessageForm;
|
||||||
import com.example.rhizome.app.presentation.form.UpdateEmployeeInfoForm;
|
import com.example.rhizome.app.presentation.form.UpdateEmployeeInfoForm;
|
||||||
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.Objects;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* employee を更新して結果を返す為のコントローラ
|
|
||||||
*/
|
|
||||||
@Controller
|
@Controller
|
||||||
public class UpdateEmployeeResultController {
|
public class UpdateEmployeeResultController {
|
||||||
|
|
||||||
// ログ出力用インスタンス
|
private final static Logger LOGGER = Logger.getLogger(UpdateEmployeeController.class.getName());
|
||||||
private final static Logger LOGGER = Logger.getLogger(UpdateEmployeeController.class.getName());
|
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||||
// エラーメッセージ用の定数フィールド
|
|
||||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
|
||||||
|
|
||||||
HttpSession httpSession;
|
HttpSession httpSession;
|
||||||
SearchDepartment searchDepartment;
|
SearchDepartment searchDepartment;
|
||||||
SearchEmployee searchEmployee;
|
SearchEmployee searchEmployee;
|
||||||
UpdateEmployee updateEmployee;
|
UpdateEmployee updateEmployee;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public UpdateEmployeeResultController(HttpSession httpSession, SearchDepartment searchDepartment, SearchEmployee searchEmployee, UpdateEmployee updateEmployee) {
|
public UpdateEmployeeResultController(HttpSession httpSession, SearchDepartment searchDepartment,
|
||||||
this.httpSession = httpSession;
|
SearchEmployee searchEmployee, UpdateEmployee updateEmployee) {
|
||||||
this.searchDepartment = searchDepartment;
|
this.httpSession = httpSession;
|
||||||
this.searchEmployee = searchEmployee;
|
this.searchDepartment = searchDepartment;
|
||||||
this.updateEmployee = updateEmployee;
|
this.searchEmployee = searchEmployee;
|
||||||
}
|
this.updateEmployee = updateEmployee;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
private static boolean checkDuplicateMailAddress(List<Employee> employeeList,
|
||||||
* メールアドレスの重複チェック
|
UpdateEmployeeInfoForm updateEmployeeInfoForm) {
|
||||||
*
|
if (!employeeList.isEmpty()) {
|
||||||
* @param employeeList 元の employeeList
|
return Objects.equals(employeeList.get(0).getIdEmployee(), updateEmployeeInfoForm.getIdEmployee());
|
||||||
* @param updateEmployeeInfoForm 更新対象のデータ
|
}
|
||||||
* @return true:重複無し false:重複あり
|
return true;
|
||||||
*/
|
}
|
||||||
private static boolean checkDuplicateMailAddress(List<Employee> employeeList, UpdateEmployeeInfoForm updateEmployeeInfoForm) {
|
|
||||||
// メールアドレスが既に使われていた場合
|
|
||||||
if (!employeeList.isEmpty()) {
|
|
||||||
// 重複が有った場合に、同一人物のものであれば上書きOKとする
|
|
||||||
return Objects.equals(employeeList.get(0).getIdEmployee(), updateEmployeeInfoForm.getIdEmployee());
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
@PermissionCheck
|
||||||
* 更新結果画面表示処理
|
@SessionCheck
|
||||||
*
|
@RequestMapping(value = TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_RESULT, method = RequestMethod.POST)
|
||||||
* @param updateEmployeeInfoForm 更新画面のフォーム
|
public String employeeUpdateResult(@ModelAttribute UpdateEmployeeInfoForm updateEmployeeInfoForm, Model model) {
|
||||||
* @param model ビューにデータを渡すためのコンテナ
|
|
||||||
* @return 遷移先の画面
|
|
||||||
*/
|
|
||||||
@PermissionCheck
|
|
||||||
@SessionCheck
|
|
||||||
@RequestMapping(value = TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_RESULT, method = RequestMethod.POST)
|
|
||||||
public String employeeUpdateResult(@ModelAttribute UpdateEmployeeInfoForm updateEmployeeInfoForm, Model model) {
|
|
||||||
|
|
||||||
final String DUPLICATION = "既に登録済みのメールアドレスです。";
|
final String DUPLICATION = "既に登録済みのメールアドレスです。";
|
||||||
final String NOTHING = "項目が空欄です。";
|
final String NOTHING = "項目が空欄です。";
|
||||||
final String ADMIN_USER = "更新対象者がログイン者のため、管理者権限を変更できません。";
|
final String ADMIN_USER = "更新対象者がログイン者のため、管理者権限を変更できません。";
|
||||||
final String NO_TARGET = "更新対象のデータが見つかりません。";
|
final String NO_TARGET = "更新対象のデータが見つかりません。";
|
||||||
|
|
||||||
final String UPDATE_COMPLETE = "更新が完了しました。";
|
final String UPDATE_COMPLETE = "更新が完了しました。";
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
try {
|
model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||||
|
DepartmentForm.convertFrom(searchDepartment.selectAll()));
|
||||||
|
|
||||||
// 部署一覧取得
|
String error = UpdateEmployeeInfoForm.validatePassword(
|
||||||
model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, DepartmentForm.convertFrom(searchDepartment.selectAll()));
|
updateEmployeeInfoForm.getPassword(),
|
||||||
|
updateEmployeeInfoForm.getPasswordConfirm());
|
||||||
|
|
||||||
// パスワードが仕様を満たしているか確認
|
if (!error.isBlank()) {
|
||||||
String error = UpdateEmployeeInfoForm.validatePassword(
|
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(error));
|
||||||
updateEmployeeInfoForm.getPassword(),
|
model.addAttribute(PageReturnAttributeKeyword.UPDATE_EMPLOYEE_INFO_FORM, updateEmployeeInfoForm);
|
||||||
updateEmployeeInfoForm.getPasswordConfirm()
|
|
||||||
);
|
|
||||||
|
|
||||||
// エラーが存在するか
|
return TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_INPUT_HTML;
|
||||||
if (!error.isBlank()) {
|
}
|
||||||
// エラーが存在する場合、更新画面に遷移
|
|
||||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(error));
|
|
||||||
model.addAttribute(PageReturnAttributeKeyword.UPDATE_EMPLOYEE_INFO_FORM, updateEmployeeInfoForm);
|
|
||||||
|
|
||||||
return TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_INPUT_HTML;
|
List<Employee> employeeList = searchEmployee.searchEmployee(updateEmployeeInfoForm.getMailAddress());
|
||||||
}
|
|
||||||
|
|
||||||
// メールアドレスを元に検索
|
if (!checkDuplicateMailAddress(employeeList, updateEmployeeInfoForm)) {
|
||||||
List<Employee> employeeList = searchEmployee.searchEmployee(updateEmployeeInfoForm.getMailAddress());
|
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DUPLICATION));
|
||||||
|
model.addAttribute(PageReturnAttributeKeyword.UPDATE_EMPLOYEE_INFO_FORM, updateEmployeeInfoForm);
|
||||||
|
|
||||||
// 既に登録済みのメールアドレスが存在するか
|
return TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_INPUT_HTML;
|
||||||
if (!checkDuplicateMailAddress(employeeList, updateEmployeeInfoForm)) {
|
}
|
||||||
// 存在する場合はエラーメッセージを設定して更新入力画面に遷移
|
|
||||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DUPLICATION));
|
|
||||||
model.addAttribute(PageReturnAttributeKeyword.UPDATE_EMPLOYEE_INFO_FORM, updateEmployeeInfoForm);
|
|
||||||
|
|
||||||
return TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_INPUT_HTML;
|
LoginUserForm loginUserForm = (LoginUserForm) httpSession.getAttribute(SessionKeyword.LOGIN_USER);
|
||||||
}
|
|
||||||
|
|
||||||
// session 情報からログイン者の情報を取得
|
if (isUpdateTargetLoginUserAdminToNormal(updateEmployeeInfoForm, loginUserForm)) {
|
||||||
LoginUserForm loginUserForm = (LoginUserForm) httpSession.getAttribute(SessionKeyword.LOGIN_USER);
|
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(ADMIN_USER));
|
||||||
|
model.addAttribute(PageReturnAttributeKeyword.UPDATE_EMPLOYEE_INFO_FORM, updateEmployeeInfoForm);
|
||||||
|
return TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_INPUT_HTML;
|
||||||
|
}
|
||||||
|
|
||||||
// ログイン者が更新対象で、権限を管理者権限から一般権限に変更しようとしているかチェック
|
if (!UpdateEmployeeInfoForm.hasErrorParameter(updateEmployeeInfoForm)) {
|
||||||
if (isUpdateTargetLoginUserAdminToNormal(updateEmployeeInfoForm, loginUserForm)) {
|
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(NOTHING));
|
||||||
// 存在する場合はエラーメッセージを設定して更新入力画面に遷移
|
model.addAttribute(PageReturnAttributeKeyword.UPDATE_EMPLOYEE_INFO_FORM, updateEmployeeInfoForm);
|
||||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(ADMIN_USER));
|
|
||||||
model.addAttribute(PageReturnAttributeKeyword.UPDATE_EMPLOYEE_INFO_FORM, updateEmployeeInfoForm);
|
|
||||||
return TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_INPUT_HTML;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 画面から渡ってきた値が必須を満たしているか
|
return TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_INPUT_HTML;
|
||||||
if (!UpdateEmployeeInfoForm.hasErrorParameter(updateEmployeeInfoForm)) {
|
}
|
||||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(NOTHING));
|
|
||||||
model.addAttribute(PageReturnAttributeKeyword.UPDATE_EMPLOYEE_INFO_FORM, updateEmployeeInfoForm);
|
|
||||||
|
|
||||||
return TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_INPUT_HTML;
|
Employee beforeEmployee = searchEmployee.searchEmployeeByIdEmployee(updateEmployeeInfoForm.getIdEmployee());
|
||||||
}
|
if (beforeEmployee.getIdEmployee() == null) {
|
||||||
|
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(NO_TARGET));
|
||||||
|
model.addAttribute(PageReturnAttributeKeyword.UPDATE_EMPLOYEE_INFO_FORM, updateEmployeeInfoForm);
|
||||||
|
|
||||||
// 更新前のデータを取得
|
return TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_INPUT_HTML;
|
||||||
Employee beforeEmployee = searchEmployee.searchEmployeeByIdEmployee(updateEmployeeInfoForm.getIdEmployee());
|
}
|
||||||
if (beforeEmployee.getIdEmployee() == null) {
|
|
||||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(NO_TARGET));
|
|
||||||
model.addAttribute(PageReturnAttributeKeyword.UPDATE_EMPLOYEE_INFO_FORM, updateEmployeeInfoForm);
|
|
||||||
|
|
||||||
return TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_INPUT_HTML;
|
updateEmployee.updateEmployee(beforeEmployee, UpdateEmployeeInfoForm.convertTo(updateEmployeeInfoForm));
|
||||||
}
|
|
||||||
|
|
||||||
// 画面用の型からビジネスロジック用のモデルに変換し、Updateを実行
|
LoginUser updatedTargetEmployee = searchEmployee.searchLoginUser(updateEmployeeInfoForm.getMailAddress());
|
||||||
updateEmployee.updateEmployee(beforeEmployee, UpdateEmployeeInfoForm.convertTo(updateEmployeeInfoForm));
|
|
||||||
|
|
||||||
// Update後の情報を再取得
|
if (Objects.equals(updatedTargetEmployee.getIdEmployee(), loginUserForm.getIdEmployee())) {
|
||||||
LoginUser updatedTargetEmployee = searchEmployee.searchLoginUser(updateEmployeeInfoForm.getMailAddress());
|
httpSession.setAttribute(SessionKeyword.LOGIN_USER, LoginUserForm.convertFrom(updatedTargetEmployee));
|
||||||
|
}
|
||||||
|
|
||||||
// ログイン者と更新した対象が同じアカウントだった場合、session情報を更新
|
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_INFO, new MessageForm(UPDATE_COMPLETE));
|
||||||
if (Objects.equals(updatedTargetEmployee.getIdEmployee(), loginUserForm.getIdEmployee())) {
|
|
||||||
// ログイン者の情報をセッション情報に格納
|
|
||||||
httpSession.setAttribute(SessionKeyword.LOGIN_USER, LoginUserForm.convertFrom(updatedTargetEmployee));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 更新結果のメッセージを画面にセットし一覧画面に遷移
|
return "forward:" + TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_INFO_FORM_EMPTY;
|
||||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_INFO, new MessageForm(UPDATE_COMPLETE));
|
|
||||||
|
|
||||||
// forward 先で不用意な動作をしないために UpdateEmployeeInfoForm をクリア
|
} catch (Exception e) {
|
||||||
return "forward:" + TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_INFO_FORM_EMPTY;
|
httpSession.invalidate();
|
||||||
|
|
||||||
|
e.printStackTrace();
|
||||||
|
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||||
|
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||||
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
}
|
||||||
// ログイン情報の破棄
|
|
||||||
httpSession.invalidate();
|
|
||||||
|
|
||||||
e.printStackTrace();
|
private boolean isUpdateTargetLoginUserAdminToNormal(UpdateEmployeeInfoForm updateEmployeeInfoForm,
|
||||||
// エラーログ出力
|
LoginUserForm loginUserForm) {
|
||||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
|
||||||
// エラー画面遷移
|
|
||||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
if (!Objects.equals(updateEmployeeInfoForm.getIdEmployee(), loginUserForm.getIdEmployee())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
return updateEmployeeInfoForm.getAdminAuth().equals(0);
|
||||||
* ログイン者がログイン者自身を更新する際
|
|
||||||
* 管理者権限から一般権限に変更する内容も含まれているかチェックする
|
|
||||||
*
|
|
||||||
* @param updateEmployeeInfoForm 更新対象データ
|
|
||||||
* @param loginUserForm ログイン者情報
|
|
||||||
* @return true:ログイン者自身のデータをUpdate管理者→一般に権限変更しようとしている。
|
|
||||||
* false:Update対象者がログイン者自身ではない or 管理者権限 → 一般権限 への更新は含まれていない
|
|
||||||
*/
|
|
||||||
private boolean isUpdateTargetLoginUserAdminToNormal(UpdateEmployeeInfoForm updateEmployeeInfoForm, LoginUserForm loginUserForm) {
|
|
||||||
|
|
||||||
// ログイン者が今回の更新対象か
|
|
||||||
if (!Objects.equals(updateEmployeeInfoForm.getIdEmployee(), loginUserForm.getIdEmployee())) {
|
|
||||||
// 今回の対象者はログイン者ではない
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 管理者から一般権限への変更があるか
|
|
||||||
return updateEmployeeInfoForm.getAdminAuth().equals(0);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,18 @@
|
|||||||
package com.example.rhizome.app.presentation.controller;
|
package com.example.rhizome.app.presentation.controller;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
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.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.PermissionCheck;
|
||||||
import com.example.rhizome.aop.aspect.SessionCheck;
|
import com.example.rhizome.aop.aspect.SessionCheck;
|
||||||
@@ -12,152 +25,103 @@ import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTa
|
|||||||
import com.example.rhizome.app.presentation.form.LoginUserForm;
|
import com.example.rhizome.app.presentation.form.LoginUserForm;
|
||||||
import com.example.rhizome.app.presentation.form.MessageForm;
|
import com.example.rhizome.app.presentation.form.MessageForm;
|
||||||
import com.example.rhizome.app.presentation.form.UpdatePersonalUserForm;
|
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.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 個人情報更新用コントローラ
|
|
||||||
*/
|
|
||||||
@Controller
|
@Controller
|
||||||
public class UpdatePersonalEmployeeResultController {
|
public class UpdatePersonalEmployeeResultController {
|
||||||
|
|
||||||
// ログ出力用インスタンス
|
private final static Logger LOGGER = Logger.getLogger(UpdatePersonalEmployeeResultController.class.getName());
|
||||||
private final static Logger LOGGER = Logger.getLogger(UpdatePersonalEmployeeResultController.class.getName());
|
|
||||||
|
|
||||||
// エラーメッセージ用の定数フィールド
|
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
|
||||||
|
|
||||||
HttpSession httpSession;
|
HttpSession httpSession;
|
||||||
SearchEmployee searchEmployee;
|
SearchEmployee searchEmployee;
|
||||||
UpdateEmployee updateEmployee;
|
UpdateEmployee updateEmployee;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public UpdatePersonalEmployeeResultController(HttpSession httpSession, SearchEmployee searchEmployee, UpdateEmployee updateEmployee) {
|
public UpdatePersonalEmployeeResultController(HttpSession httpSession, SearchEmployee searchEmployee,
|
||||||
this.httpSession = httpSession;
|
UpdateEmployee updateEmployee) {
|
||||||
this.searchEmployee = searchEmployee;
|
this.httpSession = httpSession;
|
||||||
this.updateEmployee = updateEmployee;
|
this.searchEmployee = searchEmployee;
|
||||||
}
|
this.updateEmployee = updateEmployee;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
private static boolean checkDuplicateMailAddress(List<Employee> employeeList,
|
||||||
* メールアドレスの重複チェック
|
UpdatePersonalUserForm updatePersonalUserForm) {
|
||||||
*
|
if (!employeeList.isEmpty()) {
|
||||||
* @param employeeList 元の employeeList
|
return Objects.equals(employeeList.get(0).getIdEmployee(), updatePersonalUserForm.getIdEmployee());
|
||||||
* @param updatePersonalUserForm 更新対象のデータ
|
}
|
||||||
* @return true:重複無し false:重複あり
|
return true;
|
||||||
*/
|
}
|
||||||
private static boolean checkDuplicateMailAddress(List<Employee> employeeList, UpdatePersonalUserForm updatePersonalUserForm) {
|
|
||||||
// メールアドレスが既に使われていた場合
|
|
||||||
if (!employeeList.isEmpty()) {
|
|
||||||
// 更新対象のデータと同じIDの場合は重複していないとみなす
|
|
||||||
return Objects.equals(employeeList.get(0).getIdEmployee(), updatePersonalUserForm.getIdEmployee());
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ModelAttribute
|
@ModelAttribute
|
||||||
public UpdatePersonalUserForm personalUpdateUserForm() {
|
public UpdatePersonalUserForm personalUpdateUserForm() {
|
||||||
return new UpdatePersonalUserForm();
|
return new UpdatePersonalUserForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@PermissionCheck
|
||||||
* 個人情報更新結果画面表示処理
|
@SessionCheck
|
||||||
*
|
@RequestMapping(value = TransitionTargetPageNameKeyword.PERSONAL_UPDATE_RESULT, method = RequestMethod.POST)
|
||||||
* @param updatePersonalUserForm 個人情報更新画面のフォーム
|
public String personalEmployeeUpdateResult(UpdatePersonalUserForm updatePersonalUserForm, Model model) {
|
||||||
* @param model ビューにデータを渡すためのコンテナ
|
|
||||||
* @return 遷移先の画面
|
|
||||||
*/
|
|
||||||
@PermissionCheck
|
|
||||||
@SessionCheck
|
|
||||||
@RequestMapping(value = TransitionTargetPageNameKeyword.PERSONAL_UPDATE_RESULT, method = RequestMethod.POST)
|
|
||||||
public String personalEmployeeUpdateResult(UpdatePersonalUserForm updatePersonalUserForm, Model model) {
|
|
||||||
|
|
||||||
final String NOTHING = "項目が空欄です。";
|
final String NOTHING = "項目が空欄です。";
|
||||||
final String DUPLICATION = "既に登録済みのメールアドレスです。";
|
final String DUPLICATION = "既に登録済みのメールアドレスです。";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// 更新完了画面からの遷移の場合
|
if (updatePersonalUserForm.getIdEmployee() == null) {
|
||||||
if (updatePersonalUserForm.getIdEmployee() == null) {
|
LoginUserForm loginUserForm = (LoginUserForm) httpSession.getAttribute(SessionKeyword.LOGIN_USER);
|
||||||
// ログイン者の情報を取得
|
model.addAttribute(PageReturnAttributeKeyword.UPDATE_PERSONAL_EMPLOYEE_USER_FORM, UpdatePersonalUserForm
|
||||||
LoginUserForm loginUserForm = (LoginUserForm) httpSession.getAttribute(SessionKeyword.LOGIN_USER);
|
.convertFrom(searchEmployee.searchLoginUser(loginUserForm.getMailAddress())));
|
||||||
// ログイン者の情報を元に個人情報更新画面の初期表示用のインスタンスを作成
|
|
||||||
model.addAttribute(PageReturnAttributeKeyword.UPDATE_PERSONAL_EMPLOYEE_USER_FORM, UpdatePersonalUserForm.convertFrom(searchEmployee.searchLoginUser(loginUserForm.getMailAddress())));
|
|
||||||
|
|
||||||
return TransitionTargetPageNameKeyword.UPDATE_PERSONAL_EMPLOYEE_INPUT_HTML;
|
return TransitionTargetPageNameKeyword.UPDATE_PERSONAL_EMPLOYEE_INPUT_HTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
// パスワードが仕様を満たしているかチェック
|
String error = UpdatePersonalUserForm.validatePassword(
|
||||||
String error = UpdatePersonalUserForm.validatePassword(
|
updatePersonalUserForm.getPassword(),
|
||||||
updatePersonalUserForm.getPassword(),
|
updatePersonalUserForm.getPasswordConfirm());
|
||||||
updatePersonalUserForm.getPasswordConfirm()
|
|
||||||
);
|
|
||||||
|
|
||||||
// エラーがあるか
|
if (!error.isBlank()) {
|
||||||
if (!error.isBlank()) {
|
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(error));
|
||||||
// エラーが有る場合メッセージをセットして個人情報更新入力画面に遷移
|
model.addAttribute(PageReturnAttributeKeyword.UPDATE_PERSONAL_EMPLOYEE_USER_FORM,
|
||||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(error));
|
updatePersonalUserForm);
|
||||||
model.addAttribute(PageReturnAttributeKeyword.UPDATE_PERSONAL_EMPLOYEE_USER_FORM, updatePersonalUserForm);
|
|
||||||
|
|
||||||
return TransitionTargetPageNameKeyword.UPDATE_PERSONAL_EMPLOYEE_INPUT_HTML;
|
return TransitionTargetPageNameKeyword.UPDATE_PERSONAL_EMPLOYEE_INPUT_HTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 入力必須を満たしているか
|
if (!UpdatePersonalUserForm.hasErrorParameter(updatePersonalUserForm)) {
|
||||||
if (!UpdatePersonalUserForm.hasErrorParameter(updatePersonalUserForm)) {
|
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(NOTHING));
|
||||||
// 満たしていない場合、メッセージをセットして個人情報更新入力画面に遷移
|
model.addAttribute(PageReturnAttributeKeyword.UPDATE_PERSONAL_EMPLOYEE_USER_FORM,
|
||||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(NOTHING));
|
updatePersonalUserForm);
|
||||||
model.addAttribute(PageReturnAttributeKeyword.UPDATE_PERSONAL_EMPLOYEE_USER_FORM, updatePersonalUserForm);
|
|
||||||
|
|
||||||
return TransitionTargetPageNameKeyword.UPDATE_PERSONAL_EMPLOYEE_INPUT_HTML;
|
return TransitionTargetPageNameKeyword.UPDATE_PERSONAL_EMPLOYEE_INPUT_HTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
// メールアドレス重複チェック
|
if (!checkDuplicateMailAddress(
|
||||||
if (!checkDuplicateMailAddress(
|
searchEmployee.searchEmployee(updatePersonalUserForm.getMailAddress()),
|
||||||
searchEmployee.searchEmployee(updatePersonalUserForm.getMailAddress()),
|
updatePersonalUserForm)) {
|
||||||
updatePersonalUserForm)
|
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DUPLICATION));
|
||||||
) {
|
model.addAttribute(PageReturnAttributeKeyword.UPDATE_PERSONAL_EMPLOYEE_USER_FORM,
|
||||||
// メールアドレスが既に使われていた場合
|
updatePersonalUserForm);
|
||||||
// 個人情報更新ページに遷移
|
|
||||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DUPLICATION));
|
|
||||||
model.addAttribute(PageReturnAttributeKeyword.UPDATE_PERSONAL_EMPLOYEE_USER_FORM, updatePersonalUserForm);
|
|
||||||
|
|
||||||
return TransitionTargetPageNameKeyword.UPDATE_PERSONAL_EMPLOYEE_INPUT_HTML;
|
return TransitionTargetPageNameKeyword.UPDATE_PERSONAL_EMPLOYEE_INPUT_HTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
//更新前のEmployeeの情報を取得
|
updateEmployee.updateEmployee(
|
||||||
// 画面用のインスタンスから更新用のインスタンスに変換し、Update実施
|
searchEmployee.searchEmployeeByIdEmployee(updatePersonalUserForm.getIdEmployee()),
|
||||||
updateEmployee.updateEmployee(
|
UpdatePersonalUserForm.convertTo(updatePersonalUserForm));
|
||||||
searchEmployee.searchEmployeeByIdEmployee(updatePersonalUserForm.getIdEmployee()),
|
|
||||||
UpdatePersonalUserForm.convertTo(updatePersonalUserForm)
|
|
||||||
);
|
|
||||||
|
|
||||||
// ログイン者の情報をセッション情報に格納
|
httpSession.setAttribute(
|
||||||
httpSession.setAttribute(
|
SessionKeyword.LOGIN_USER,
|
||||||
SessionKeyword.LOGIN_USER,
|
LoginUserForm.convertFrom(
|
||||||
LoginUserForm.convertFrom(
|
searchEmployee.searchLoginUser(updatePersonalUserForm.getMailAddress())));
|
||||||
searchEmployee.searchLoginUser(updatePersonalUserForm.getMailAddress()))
|
|
||||||
);
|
|
||||||
|
|
||||||
// 更新結果画面に遷移
|
return TransitionTargetPageNameKeyword.UPDATE_PERSONAL_RESULT_HTML;
|
||||||
return TransitionTargetPageNameKeyword.UPDATE_PERSONAL_RESULT_HTML;
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// ログイン情報の破棄
|
httpSession.invalidate();
|
||||||
httpSession.invalidate();
|
|
||||||
|
|
||||||
// エラーログ出力
|
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||||
// エラー画面遷移
|
}
|
||||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user