init
This commit is contained in:
15
src/main/java/com/example/rhizome/EmSpringApplication.java
Normal file
15
src/main/java/com/example/rhizome/EmSpringApplication.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package com.example.rhizome;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableAspectJAutoProxy(proxyTargetClass = true)
|
||||
public class EmSpringApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(EmSpringApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
13
src/main/java/com/example/rhizome/ServletInitializer.java
Normal file
13
src/main/java/com/example/rhizome/ServletInitializer.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package com.example.rhizome;
|
||||
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||
|
||||
public class ServletInitializer extends SpringBootServletInitializer {
|
||||
|
||||
@Override
|
||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
|
||||
return application.sources(EmSpringApplication.class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package com.example.rhizome.aop.Handler;
|
||||
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
||||
import com.example.rhizome.app.presentation.form.LoginInfoForm;
|
||||
import com.example.rhizome.app.presentation.form.MessageForm;
|
||||
import com.example.rhizome.exception.InsufficientPermissionException;
|
||||
import com.example.rhizome.exception.NoSessionException;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword.LOGIN_INFO_FORM;
|
||||
import static com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword.MESSAGE_ERROR;
|
||||
|
||||
/**
|
||||
* 例外処理用のコントローラ
|
||||
*/
|
||||
@ControllerAdvice
|
||||
public class GlobalExceptionHandler {
|
||||
|
||||
private final static Logger LOGGER = Logger.getLogger(GlobalExceptionHandler.class.getName());
|
||||
|
||||
private final String SEVERE_ERROR_MESSAGE_ILLEGAL_TRANSITION = "不正な遷移です。";
|
||||
private final String SEVERE_ERROR_MESSAGE_BAD_REQUEST = "不正なリクエストです。";
|
||||
|
||||
/**
|
||||
* セッションが切れている場合の例外処理
|
||||
*
|
||||
* @param model ビューにデータを渡すためのコンテナ
|
||||
* @return 遷移先の画面
|
||||
*/
|
||||
@ExceptionHandler(NoSessionException.class)
|
||||
public String handleNoSessionException(Model model, Exception e) {
|
||||
|
||||
model.addAttribute(MESSAGE_ERROR, new MessageForm(SEVERE_ERROR_MESSAGE_ILLEGAL_TRANSITION));
|
||||
model.addAttribute(LOGIN_INFO_FORM, new LoginInfoForm());
|
||||
|
||||
e.printStackTrace();
|
||||
|
||||
// エラーログ出力
|
||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE_ILLEGAL_TRANSITION, e);
|
||||
|
||||
return TransitionTargetPageNameKeyword.LOGIN_HTML;
|
||||
}
|
||||
|
||||
/**
|
||||
* 権限がない場合の例外処理
|
||||
*
|
||||
* @param model ビューにデータを渡すためのコンテナ
|
||||
* @return 遷移先の画面
|
||||
*/
|
||||
@ExceptionHandler(InsufficientPermissionException.class)
|
||||
public String handleInsufficientPermissionException(Model model, Exception e) {
|
||||
|
||||
model.addAttribute(MESSAGE_ERROR, new MessageForm(SEVERE_ERROR_MESSAGE_ILLEGAL_TRANSITION));
|
||||
model.addAttribute(LOGIN_INFO_FORM, new LoginInfoForm());
|
||||
|
||||
e.printStackTrace();
|
||||
|
||||
// エラーログ出力
|
||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE_ILLEGAL_TRANSITION, e);
|
||||
|
||||
return TransitionTargetPageNameKeyword.LOGIN_HTML;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* リクエストメソッドが不正な場合の例外処理
|
||||
*
|
||||
* @param model ビューにデータを渡すためのコンテナ
|
||||
* @return 遷移先の画面
|
||||
*/
|
||||
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
|
||||
public String handleBadRequestException(Model model, Exception e) {
|
||||
// エラーメッセージやその他の情報をモデルに追加する
|
||||
model.addAttribute("error", SEVERE_ERROR_MESSAGE_BAD_REQUEST);
|
||||
model.addAttribute("status", HttpStatus.BAD_REQUEST.value());
|
||||
|
||||
e.printStackTrace();
|
||||
|
||||
// エラーログ出力
|
||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE_ILLEGAL_TRANSITION, e);
|
||||
|
||||
// カスタムエラーページにリダイレクト
|
||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||
}
|
||||
|
||||
/**
|
||||
* その他の例外処理
|
||||
*
|
||||
* @param model ビューにデータを渡すためのコンテナ
|
||||
* @return 遷移先の画面
|
||||
*/
|
||||
@ExceptionHandler(Exception.class)
|
||||
public String AllException(Model model, Exception e) {
|
||||
// エラーメッセージやその他の情報をモデルに追加する
|
||||
model.addAttribute("error", SEVERE_ERROR_MESSAGE_BAD_REQUEST);
|
||||
|
||||
e.printStackTrace();
|
||||
|
||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE_ILLEGAL_TRANSITION, e);
|
||||
|
||||
// カスタムエラーページにリダイレクト
|
||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.example.rhizome.aop.aspect;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* SessionCheckアノテーション
|
||||
* セッションチェックを行うメソッドに付与する
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface PermissionCheck {
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package com.example.rhizome.aop.aspect;
|
||||
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.SessionKeyword;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
||||
import com.example.rhizome.app.presentation.form.LoginUserForm;
|
||||
import com.example.rhizome.exception.InsufficientPermissionException;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Before;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* 権限チェック用のAOP
|
||||
*/
|
||||
@Aspect
|
||||
@Component
|
||||
public class PermissionCheckAspect {
|
||||
|
||||
HttpServletRequest request;
|
||||
|
||||
@Autowired
|
||||
public PermissionCheckAspect(HttpServletRequest request) {
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
// Aspectのフックを定義(今回はPermissionCheckアノテーションが定義されているメソッドが動作するタイミング)
|
||||
@Pointcut("@annotation(com.example.rhizome.aop.aspect.PermissionCheck)")
|
||||
public void permissionCheckMethod() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 権限チェック
|
||||
*/
|
||||
@Before("permissionCheckMethod()")
|
||||
public void checkPermission() {
|
||||
// ログインユーザの取得
|
||||
LoginUserForm loginUserForm = (LoginUserForm) request.getSession().getAttribute(SessionKeyword.LOGIN_USER);
|
||||
|
||||
// ログインユーザが取得できない場合、または権限がない場合はエラー画面に遷移
|
||||
if (loginUserForm == null || !hasRequiredPermission(request.getRequestURI(), loginUserForm)) {
|
||||
throw new InsufficientPermissionException("不正な遷移です");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 遷移先のURLとログインユーザの権限から、遷移可否を判定する
|
||||
*
|
||||
* @param targetURL 遷移したいURL
|
||||
* @param loginUserForm リクエスト元のユーザ
|
||||
* @return true:遷移可 false:遷移不可
|
||||
*/
|
||||
private boolean hasRequiredPermission(String targetURL, LoginUserForm loginUserForm) {
|
||||
|
||||
// 管理者権限
|
||||
if (isAdminTransition(targetURL, loginUserForm)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 一般権限
|
||||
if (isUserTransition(targetURL, loginUserForm)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// アクセス不許可の場合の処理(不正アクセス画面に遷移)
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理者用のアカウントで管理者向けのページアクセスか
|
||||
*
|
||||
* @param targetURL 遷移したいURL
|
||||
* @param loginUserForm リクエスト元のユーザ
|
||||
* @return true:遷移可 false:遷移不可
|
||||
*/
|
||||
private boolean isAdminTransition(String targetURL, LoginUserForm loginUserForm) {
|
||||
|
||||
// 管理者か
|
||||
if (!loginUserForm.isAdminUser()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 管理者向けのページ遷移か
|
||||
if (!TransitionTargetPageNameKeyword.getAdminPageList().contains(targetURL)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 一般ユーザ用のアカウントで一般ユーザ向けのページアクセスか
|
||||
*
|
||||
* @param targetURL 遷移したいURL
|
||||
* @param loginUserForm リクエスト元のユーザ
|
||||
* @return true:遷移可 false:遷移不可
|
||||
*/
|
||||
private boolean isUserTransition(String targetURL, LoginUserForm loginUserForm) {
|
||||
|
||||
// 管理者か
|
||||
if (loginUserForm.isAdminUser()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 一般ユーザ向けのページ遷移か
|
||||
return TransitionTargetPageNameKeyword.getUserPageList().contains(targetURL);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.example.rhizome.aop.aspect;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* SessionCheckアノテーション
|
||||
* セッションチェックを行うメソッドに付与する
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface SessionCheck {
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.example.rhizome.aop.aspect;
|
||||
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.SessionKeyword;
|
||||
import com.example.rhizome.exception.NoSessionException;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Before;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
/**
|
||||
* セッションチェック用のAOP
|
||||
*/
|
||||
@Aspect
|
||||
@Component
|
||||
public class SessionCheckAspect {
|
||||
|
||||
HttpServletRequest request;
|
||||
|
||||
@Autowired
|
||||
public SessionCheckAspect(HttpServletRequest request) {
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
@Pointcut("@annotation(com.example.rhizome.aop.aspect.SessionCheck)")
|
||||
public void sessionCheckMethod() {
|
||||
}
|
||||
|
||||
/**
|
||||
* セッションチェック
|
||||
*/
|
||||
@Before("sessionCheckMethod()")
|
||||
public void checkSession() {
|
||||
// セッションの取得
|
||||
HttpSession session = request.getSession(false);
|
||||
|
||||
// セッションが取得できない場合はエラー画面に遷移
|
||||
if (session == null || session.getAttribute(SessionKeyword.LOGIN_USER) == null) {
|
||||
throw new NoSessionException("不正なログインです");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.example.rhizome.app.domain.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 部署情報の概念を表現するモデルクラスです。
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class Department {
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
private final Integer idDepartment;
|
||||
/**
|
||||
* 部署名
|
||||
*/
|
||||
private final String nmDepartment;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.example.rhizome.app.domain.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 社員を表現するモデルクラスです
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class Employee {
|
||||
/**
|
||||
* 社員ID
|
||||
*/
|
||||
private final Integer idEmployee;
|
||||
/**
|
||||
* 社員名
|
||||
*/
|
||||
private final String nmEmployee;
|
||||
/**
|
||||
* 社員名カナ
|
||||
*/
|
||||
private final String knEmployee;
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
private final String mailAddress;
|
||||
/**
|
||||
* パスワード
|
||||
*/
|
||||
private final String password;
|
||||
/**
|
||||
* 管理者権限
|
||||
*/
|
||||
private final Integer adminAuth;
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
private final Integer idDepartment;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* EmployeeInfo.java
|
||||
* 作成 IT-College 2016
|
||||
*------------------------------------------------------------
|
||||
* Copyright(c) Rhizome Inc. All Rights Reserved.
|
||||
*/
|
||||
package com.example.rhizome.app.domain.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 社員情報の概念を表現するモデルクラスです。
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class EmployeeInfo {
|
||||
|
||||
/**
|
||||
* 社員情報
|
||||
*/
|
||||
private final Employee employee;
|
||||
/**
|
||||
* 部署名
|
||||
*/
|
||||
private final Department department;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.example.rhizome.app.domain.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* ログインを試みる人を表現するモデルクラスです
|
||||
*/
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class LoginInfo {
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
private String mailAddress;
|
||||
/**
|
||||
* パスワード
|
||||
*/
|
||||
private String password;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.example.rhizome.app.domain.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* ログイン者を表現するクラスです
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class LoginUser {
|
||||
/**
|
||||
* 社員ID
|
||||
*/
|
||||
private final Integer idEmployee;
|
||||
/**
|
||||
* 社員名
|
||||
*/
|
||||
private final String nmEmployee;
|
||||
/**
|
||||
* 社員名カナ
|
||||
*/
|
||||
private final String knEmployee;
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
private final String mailAddress;
|
||||
/**
|
||||
* パスワード
|
||||
*/
|
||||
private final String password;
|
||||
|
||||
/**
|
||||
* 管理者権限
|
||||
*/
|
||||
private final Integer adminAuth;
|
||||
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
private final Integer idDepartment;
|
||||
|
||||
/**
|
||||
* ログインユーザが管理者か
|
||||
*
|
||||
* @return true:管理者 false:一般権限
|
||||
*/
|
||||
public boolean isAdminUser() {
|
||||
return getAdminAuth() == 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.example.rhizome.app.domain.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 部署情報の検索要件を表現するモデルクラスです。
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class SearchConditionDepartment {
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
private final Integer idDepartment;
|
||||
/**
|
||||
* 部署名
|
||||
*/
|
||||
private final String nmDepartment;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.example.rhizome.app.domain.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 社員情報の検索条件という概念を表現するモデルクラスです
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class SearchConditionEmployee {
|
||||
/**
|
||||
* 社員ID
|
||||
*/
|
||||
private final Integer idEmployee;
|
||||
/**
|
||||
* 社員名
|
||||
*/
|
||||
private final String nmEmployee;
|
||||
/**
|
||||
* 社員名カナ
|
||||
*/
|
||||
private final String knEmployee;
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
private final String mailAddress;
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
private final Integer idDepartment;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.example.rhizome.app.domain.service;
|
||||
|
||||
public interface DeleteEmployee {
|
||||
void deleteEmployee(Integer idEmployee);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.example.rhizome.app.domain.service;
|
||||
|
||||
import com.example.rhizome.app.domain.model.LoginInfo;
|
||||
import com.example.rhizome.app.domain.model.LoginUser;
|
||||
|
||||
public interface Login {
|
||||
LoginUser doLogin(LoginInfo loginInfo);
|
||||
|
||||
boolean canLogin(LoginInfo loginInfo);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.example.rhizome.app.domain.service;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Department;
|
||||
|
||||
public interface RegisterDepartment {
|
||||
void registerDepartment(Department department);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.example.rhizome.app.domain.service;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Employee;
|
||||
|
||||
public interface RegisterEmployee {
|
||||
void registerEmployee(Employee employee);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.example.rhizome.app.domain.service;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Department;
|
||||
import com.example.rhizome.app.domain.model.SearchConditionDepartment;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SearchDepartment {
|
||||
List<Department> selectAll();
|
||||
|
||||
List<Department> searchBy(SearchConditionDepartment searchConditionDepartment);
|
||||
|
||||
List<Department> searchByWithLike(SearchConditionDepartment searchConditionDepartment);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.example.rhizome.app.domain.service;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Employee;
|
||||
import com.example.rhizome.app.domain.model.LoginUser;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SearchEmployee {
|
||||
List<Employee> searchEmployee(String mailAddress);
|
||||
|
||||
List<Employee> searchEmployeeByIdDepartment(Integer idDepartment);
|
||||
|
||||
LoginUser searchLoginUser(String mailAddress);
|
||||
|
||||
Employee searchEmployeeByIdEmployee(Integer idEmployee);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.example.rhizome.app.domain.service;
|
||||
|
||||
import com.example.rhizome.app.domain.model.EmployeeInfo;
|
||||
import com.example.rhizome.app.domain.model.SearchConditionEmployee;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SearchEmployeeInfo {
|
||||
List<EmployeeInfo> selectAll();
|
||||
|
||||
List<EmployeeInfo> searchBy(SearchConditionEmployee searchConditionEmployee);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.example.rhizome.app.domain.service;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Employee;
|
||||
|
||||
public interface UpdateEmployee {
|
||||
void updateEmployee(Employee beforeEmployee, Employee updateEmployee);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.example.rhizome.app.domain.service.impl;
|
||||
|
||||
import com.example.rhizome.app.domain.service.DeleteEmployee;
|
||||
import com.example.rhizome.app.infra.repository.EmployeeRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* Employee レコード削除関連の機能を持つサービス
|
||||
*/
|
||||
@Service
|
||||
@Transactional
|
||||
public class DeleteEmployeeImpl implements DeleteEmployee {
|
||||
|
||||
EmployeeRepository employeeRepository;
|
||||
|
||||
@Autowired
|
||||
public DeleteEmployeeImpl(EmployeeRepository employeeRepository) {
|
||||
this.employeeRepository = employeeRepository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* idEmployee を元に employee データを削除
|
||||
*
|
||||
* @param idEmployee 削除対象のidEmployee
|
||||
*/
|
||||
public void deleteEmployee(Integer idEmployee) {
|
||||
employeeRepository.deleteById(idEmployee);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.example.rhizome.app.domain.service.impl;
|
||||
|
||||
import com.example.rhizome.app.domain.model.LoginInfo;
|
||||
import com.example.rhizome.app.domain.model.LoginUser;
|
||||
import com.example.rhizome.app.domain.service.Login;
|
||||
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||
import com.example.rhizome.app.infra.repository.EmployeeRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* ログイン系の機能を集約させるサービスクラスです。
|
||||
*/
|
||||
@Service
|
||||
@Transactional
|
||||
public class LoginImpl implements Login {
|
||||
|
||||
EmployeeRepository employeeRepository;
|
||||
|
||||
@Autowired
|
||||
public LoginImpl(EmployeeRepository employeeRepository) {
|
||||
this.employeeRepository = employeeRepository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* メールアドレス、パスワードでログイン判定を行う
|
||||
*
|
||||
* @param loginInfo ログインを試みるアカウント
|
||||
* @return loginUser のインスタンス
|
||||
*/
|
||||
public LoginUser doLogin(LoginInfo loginInfo) {
|
||||
// ログイン情報を元にログインユーザーを取得
|
||||
return employeeRepository
|
||||
.findByMailAddressAndPassword(loginInfo.getMailAddress(), loginInfo.getPassword())
|
||||
.orElse(new EmployeeEntity())
|
||||
.createLoginUser();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* メールアドレス、パスワードでログイン判定を行う
|
||||
*
|
||||
* @param loginInfo ログインを試みるアカウント
|
||||
* @return loginUser のインスタンス
|
||||
*/
|
||||
public boolean canLogin(LoginInfo loginInfo) {
|
||||
// ログイン情報を元にログインユーザーを取得
|
||||
return employeeRepository
|
||||
.findByMailAddressAndPassword(loginInfo.getMailAddress(), loginInfo.getPassword())
|
||||
.isPresent();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.example.rhizome.app.domain.service.impl;
|
||||
|
||||
|
||||
import com.example.rhizome.app.domain.model.Employee;
|
||||
import com.example.rhizome.app.domain.service.RegisterEmployee;
|
||||
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||
import com.example.rhizome.app.infra.repository.EmployeeRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* Employee テーブルの登録系の機能を集約させるサービスクラスです。
|
||||
*/
|
||||
@Service
|
||||
@Transactional
|
||||
public class RegisterEmployeeImpl implements RegisterEmployee {
|
||||
|
||||
EmployeeRepository employeeRepository;
|
||||
|
||||
@Autowired
|
||||
public RegisterEmployeeImpl(EmployeeRepository employeeRepository) {
|
||||
this.employeeRepository = employeeRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* employee インスタンスの内容を登録する
|
||||
*
|
||||
* @param employee 登録対象のデータ
|
||||
*/
|
||||
public void registerEmployee(Employee employee) {
|
||||
employeeRepository.save(EmployeeEntity.convertFrom(employee));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.example.rhizome.app.domain.service.impl;
|
||||
|
||||
|
||||
import com.example.rhizome.app.domain.model.Department;
|
||||
import com.example.rhizome.app.domain.model.SearchConditionDepartment;
|
||||
import com.example.rhizome.app.domain.service.SearchDepartment;
|
||||
import com.example.rhizome.app.infra.entity.DepartmentEntity;
|
||||
import com.example.rhizome.app.infra.repository.DepartmentRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 部署情報検索系の機能を集約させるサービスクラスです。
|
||||
*/
|
||||
@Service
|
||||
@Transactional
|
||||
public class SearchDepartmentImpl implements SearchDepartment {
|
||||
|
||||
DepartmentRepository departmentRepository;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
*
|
||||
* @param departmentRepository DI対象
|
||||
*/
|
||||
@Autowired
|
||||
public SearchDepartmentImpl(DepartmentRepository departmentRepository) {
|
||||
this.departmentRepository = departmentRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* 部署情報を全件取得する
|
||||
*
|
||||
* @return 取得した部署情報レコード全件
|
||||
*/
|
||||
public List<Department> selectAll() {
|
||||
return DepartmentEntity.createDepartmentList(departmentRepository.findAll());
|
||||
}
|
||||
|
||||
/**
|
||||
* searchConditionDepartment の情報を元に Department のレコードを取得
|
||||
*
|
||||
* @param searchConditionDepartment 検索条件
|
||||
* @return 検索結果のレコード
|
||||
*/
|
||||
public List<Department> searchBy(SearchConditionDepartment searchConditionDepartment) {
|
||||
// 動的に検索条件を絞り込む
|
||||
// Specification は Criteria API の Predicate をラップしたもの
|
||||
return DepartmentEntity
|
||||
.createDepartmentList(
|
||||
departmentRepository.findAll(Specification
|
||||
.where(DepartmentRepository.idDepartmentEqual(searchConditionDepartment.getIdDepartment()))
|
||||
.and(DepartmentRepository.nmDepartmentEqual(searchConditionDepartment.getNmDepartment()))
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* searchConditionDepartment の情報を元に Department のレコードを取得
|
||||
* 部分一致検索
|
||||
*
|
||||
* @param searchConditionDepartment 検索条件
|
||||
* @return 検索結果のレコード
|
||||
*/
|
||||
public List<Department> searchByWithLike(SearchConditionDepartment searchConditionDepartment) {
|
||||
// 動的に検索条件を絞り込む
|
||||
// Specification は Criteria API の Predicate をラップしたもの
|
||||
return DepartmentEntity
|
||||
.createDepartmentList(
|
||||
departmentRepository.findAll(Specification
|
||||
.where(DepartmentRepository.idDepartmentEqual(searchConditionDepartment.getIdDepartment()))
|
||||
.and(DepartmentRepository.nmDepartmentLike(searchConditionDepartment.getNmDepartment()))
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.example.rhizome.app.domain.service.impl;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Employee;
|
||||
import com.example.rhizome.app.domain.model.LoginUser;
|
||||
import com.example.rhizome.app.domain.service.SearchEmployee;
|
||||
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||
import com.example.rhizome.app.infra.repository.EmployeeRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Employee テーブル検索系の機能を集約させるサービスクラスです。
|
||||
*/
|
||||
@Service
|
||||
@Transactional
|
||||
public class SearchEmployeeImpl implements SearchEmployee {
|
||||
|
||||
EmployeeRepository employeeRepository;
|
||||
|
||||
@Autowired
|
||||
public SearchEmployeeImpl(EmployeeRepository employeeRepository) {
|
||||
this.employeeRepository = employeeRepository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* mailAddress を元に Employee Table を検索します。
|
||||
*
|
||||
* @param mailAddress 検索対象の mailAddress
|
||||
* @return Table から取得したレコードの情報
|
||||
*/
|
||||
public List<Employee> searchEmployee(String mailAddress) {
|
||||
return EmployeeEntity.createEmployeeList(employeeRepository.findByMailAddress(mailAddress).stream().toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* mailAddress を元に ログイン者の情報 を検索します。
|
||||
*
|
||||
* @param mailAddress 検索対象の mailAddress
|
||||
* @return login者の情報
|
||||
*/
|
||||
public LoginUser searchLoginUser(String mailAddress) {
|
||||
return employeeRepository.findByMailAddress(mailAddress).orElse(new EmployeeEntity()).createLoginUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* idEmployee を元に Employee Table を検索します。
|
||||
*
|
||||
* @param idEmployee 検索対象の idEmployee
|
||||
* @return Table から取得したレコードの情報
|
||||
*/
|
||||
public Employee searchEmployeeByIdEmployee(Integer idEmployee) {
|
||||
return EmployeeEntity.createEmployee(employeeRepository.findByIdEmployee(idEmployee).orElse(new EmployeeEntity()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* idDepartment を元に Employee Table を検索します。
|
||||
*
|
||||
* @param idDepartment 部署ID
|
||||
* @return Table から取得したレコードの情報
|
||||
*/
|
||||
@Override
|
||||
public List<Employee> searchEmployeeByIdDepartment(Integer idDepartment) {
|
||||
return EmployeeEntity.createEmployeeList(employeeRepository.findByIdDepartment(idDepartment));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.example.rhizome.app.domain.service.impl;
|
||||
|
||||
import com.example.rhizome.app.domain.model.EmployeeInfo;
|
||||
import com.example.rhizome.app.domain.model.SearchConditionEmployee;
|
||||
import com.example.rhizome.app.domain.service.SearchEmployeeInfo;
|
||||
import com.example.rhizome.app.infra.entity.EmployeeDepartmentEntity;
|
||||
import com.example.rhizome.app.infra.repository.EmployeeInfoRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* SearchEmployeeInfoImpl (employee join department) 検索系の機能を集約させるサービスクラスです
|
||||
*/
|
||||
@Service
|
||||
@Transactional
|
||||
public class SearchEmployeeInfoImpl implements SearchEmployeeInfo {
|
||||
|
||||
EmployeeInfoRepository employeeInfoRepository;
|
||||
|
||||
@Autowired
|
||||
public SearchEmployeeInfoImpl(EmployeeInfoRepository employeeInfoRepository) {
|
||||
this.employeeInfoRepository = employeeInfoRepository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* EmployeeInfo (employee join department) のレコードを全件取得
|
||||
*
|
||||
* @return 取得したレコード全件
|
||||
*/
|
||||
public List<EmployeeInfo> selectAll() {
|
||||
|
||||
return EmployeeDepartmentEntity.createEmployeeInfoList(employeeInfoRepository.findAll());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* SearchConditionEmployee の情報を元に EmployeeInfo (employee join department) のレコードを取得
|
||||
*
|
||||
* @param searchConditionEmployee 検索条件
|
||||
* @return 検索結果のレコードリスト
|
||||
*/
|
||||
public List<EmployeeInfo> searchBy(SearchConditionEmployee searchConditionEmployee) {
|
||||
// 動的に検索条件を絞り込む
|
||||
// Specification は Criteria API の Predicate をラップしたもの
|
||||
return EmployeeDepartmentEntity
|
||||
.createEmployeeInfoList(
|
||||
employeeInfoRepository.findAll(Specification
|
||||
.where(EmployeeInfoRepository.idEmployeeEqual(searchConditionEmployee.getIdEmployee()))
|
||||
.and(EmployeeInfoRepository.nmEmployeeEqual(searchConditionEmployee.getNmEmployee()))
|
||||
.and(EmployeeInfoRepository.knEmployeeEqual(searchConditionEmployee.getKnEmployee()))
|
||||
.and(EmployeeInfoRepository.mailAddressEqual(searchConditionEmployee.getMailAddress()))
|
||||
.and(EmployeeInfoRepository.idDepartmentEqual(searchConditionEmployee.getIdDepartment()))
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.example.rhizome.app.domain.service.impl;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Employee;
|
||||
import com.example.rhizome.app.domain.service.UpdateEmployee;
|
||||
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||
import com.example.rhizome.app.infra.repository.EmployeeRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* employee の更新系の機能を集約させるサービスクラスです。
|
||||
*/
|
||||
@Service
|
||||
@Transactional
|
||||
public class UpdateEmployeeImpl implements UpdateEmployee {
|
||||
|
||||
EmployeeRepository employeeRepository;
|
||||
|
||||
@Autowired
|
||||
public UpdateEmployeeImpl(EmployeeRepository employeeRepository) {
|
||||
this.employeeRepository = employeeRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* employee の情報を元に employee table のレコードを更新する
|
||||
*
|
||||
* @param beforeEmployee 更新前のデータ
|
||||
* @param updateEmployee 更新後のデータ
|
||||
*/
|
||||
public void updateEmployee(Employee beforeEmployee, Employee updateEmployee) {
|
||||
|
||||
employeeRepository.save(EmployeeEntity.convertFrom(mergeEmployee(beforeEmployee, updateEmployee)));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新前のデータと更新対象のデータをマージする
|
||||
*
|
||||
* @param beforeEmployee 更新前のデータ
|
||||
* @param updateEmployee 更新対象のデータ
|
||||
* @return マージしたデータ
|
||||
*/
|
||||
private Employee mergeEmployee(Employee beforeEmployee, Employee updateEmployee) {
|
||||
// 更新対象のデータのパスワードが空文字の場合は、更新前のパスワードを使用する
|
||||
// 更新対象のデータの管理者権限が null の場合は、更新前の管理者権限を使用する
|
||||
// 更新対象のデータの部署IDが null の場合は、更新前の部署IDを使用する
|
||||
return new Employee(
|
||||
updateEmployee.getIdEmployee(),
|
||||
updateEmployee.getNmEmployee(),
|
||||
updateEmployee.getKnEmployee(),
|
||||
updateEmployee.getMailAddress(),
|
||||
updateEmployee.getPassword().isBlank() ? beforeEmployee.getPassword() : updateEmployee.getPassword(),
|
||||
updateEmployee.getAdminAuth() == null ? beforeEmployee.getAdminAuth() : updateEmployee.getAdminAuth(),
|
||||
updateEmployee.getIdDepartment() == null ? beforeEmployee.getIdDepartment() : updateEmployee.getIdDepartment()
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Department.java
|
||||
* 作成 IT-College 2016
|
||||
*------------------------------------------------------------
|
||||
* Copyright(c) Rhizome Inc. All Rights Reserved.
|
||||
*/
|
||||
package com.example.rhizome.app.infra.entity;
|
||||
|
||||
|
||||
import com.example.rhizome.app.domain.model.Department;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Department テーブルの Entity
|
||||
*
|
||||
* @author IT-College
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "department")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DepartmentEntity {
|
||||
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id_department", nullable = false)
|
||||
private Integer idDepartment;
|
||||
/**
|
||||
* 部署名
|
||||
*/
|
||||
@Column(name = "nm_department", nullable = false)
|
||||
private String nmDepartment;
|
||||
|
||||
/**
|
||||
* DepartmentEntity(DataAccess層依存)から Department(BusinessLogic層依存型)に変換します。
|
||||
*
|
||||
* @param departmentEntityList department Table のリスト
|
||||
* @return List<Department> リスト
|
||||
*/
|
||||
public static List<Department> createDepartmentList(List<DepartmentEntity> departmentEntityList) {
|
||||
|
||||
// Stream API を利用するとこうなります。
|
||||
return departmentEntityList
|
||||
.stream()
|
||||
.map(departmentEntity -> new Department(
|
||||
departmentEntity.getIdDepartment(),
|
||||
departmentEntity.getNmDepartment()
|
||||
)).toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Department(BusinessLogic層依存型) から DepartmentEntity(DataAccess層依存)に変換します。
|
||||
*
|
||||
* @param department department モデルの値
|
||||
* @return DepartmentEntity に変換したインスタンス
|
||||
*/
|
||||
public static DepartmentEntity convertFrom(Department department) {
|
||||
return new DepartmentEntity(
|
||||
department.getIdDepartment(),
|
||||
department.getNmDepartment()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package com.example.rhizome.app.infra.entity;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Department;
|
||||
import com.example.rhizome.app.domain.model.Employee;
|
||||
import com.example.rhizome.app.domain.model.EmployeeInfo;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.hibernate.annotations.Fetch;
|
||||
import org.hibernate.annotations.FetchMode;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Employee + Department の Join 情報を保持するEntity
|
||||
*
|
||||
* @author IT-College
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "employee")
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@NamedEntityGraph(
|
||||
name = "employee_with_department",
|
||||
includeAllAttributes = true
|
||||
)
|
||||
public class EmployeeDepartmentEntity {
|
||||
|
||||
/**
|
||||
* 社員ID
|
||||
*/
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id_employee", nullable = false)
|
||||
private Integer idEmployee;
|
||||
|
||||
/**
|
||||
* 社員名
|
||||
*/
|
||||
@Column(name = "nm_employee", nullable = false)
|
||||
private String nmEmployee;
|
||||
|
||||
/**
|
||||
* 社員名カナ
|
||||
*/
|
||||
@Column(name = "kn_employee", nullable = false)
|
||||
private String knEmployee;
|
||||
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
@Column(name = "mail_address", nullable = false)
|
||||
private String mailAddress;
|
||||
|
||||
/**
|
||||
* パスワード
|
||||
*/
|
||||
@Column(name = "password", nullable = false)
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 管理者権限
|
||||
*/
|
||||
@Column(name = "admin_auth", nullable = false)
|
||||
private Integer adminAuth;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "id_department", referencedColumnName = "id_department", insertable = false, updatable = false)
|
||||
@Fetch(FetchMode.JOIN)
|
||||
private DepartmentEntity department;
|
||||
|
||||
/**
|
||||
* EmployeeDepartmentEntity(DataAccess層依存) を EmployeeInfo(BusinessLogic層依存) に変換します。
|
||||
*
|
||||
* @param employeeDepartmentEntity EmployeeDepartmentEntity のインスタンス
|
||||
* @return EmployeeInfo のインスタンス
|
||||
*/
|
||||
public static EmployeeInfo createEmployeeInfo(EmployeeDepartmentEntity employeeDepartmentEntity) {
|
||||
|
||||
// コンストラクタを使って書くとSetterを使用するより簡略化出来ます。
|
||||
// 混乱してしまう人は落ち着いて EmployeeInfo のフィールドを見に行って、
|
||||
// どうしてこの書き方が出来るのかを理解できる様になりましょう。
|
||||
return new EmployeeInfo(
|
||||
new Employee(
|
||||
employeeDepartmentEntity.getIdEmployee(),
|
||||
employeeDepartmentEntity.getNmEmployee(),
|
||||
employeeDepartmentEntity.getKnEmployee(),
|
||||
employeeDepartmentEntity.getMailAddress(),
|
||||
employeeDepartmentEntity.getPassword(),
|
||||
employeeDepartmentEntity.getAdminAuth(),
|
||||
employeeDepartmentEntity.getDepartment() == null ? null : employeeDepartmentEntity.getDepartment().getIdDepartment()
|
||||
),
|
||||
new Department(
|
||||
employeeDepartmentEntity.getDepartment() == null ? null : employeeDepartmentEntity.getDepartment().getIdDepartment(),
|
||||
employeeDepartmentEntity.getDepartment() == null ? null : employeeDepartmentEntity.getDepartment().getNmDepartment()
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* EmployeeDepartmentEntity(DataAccess層依存) を EmployeeInfo(BusinessLogic層依存) に変換します。
|
||||
* (リスト版)
|
||||
*
|
||||
* @param employeeDepartmentEntityList EmployeeDepartmentEntity インスタンスのリスト
|
||||
* @return EmployeeInfo インスタンスのリスト
|
||||
*/
|
||||
public static List<EmployeeInfo> createEmployeeInfoList(List<EmployeeDepartmentEntity> employeeDepartmentEntityList) {
|
||||
|
||||
// StreamAPI を使うとこうなります。
|
||||
return employeeDepartmentEntityList.stream().map(EmployeeDepartmentEntity::createEmployeeInfo).toList();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
/*
|
||||
* Employee.java
|
||||
* 作成 IT-College 2016
|
||||
*------------------------------------------------------------
|
||||
* Copyright(c) Rhizome Inc. All Rights Reserved.
|
||||
*/
|
||||
package com.example.rhizome.app.infra.entity;
|
||||
|
||||
|
||||
import com.example.rhizome.app.domain.model.Employee;
|
||||
import com.example.rhizome.app.domain.model.LoginUser;
|
||||
import com.example.rhizome.app.domain.model.SearchConditionEmployee;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* EmployeeテーブルのEntity
|
||||
*
|
||||
* @author IT-College
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "employee")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class EmployeeEntity {
|
||||
|
||||
/**
|
||||
* 社員ID
|
||||
*/
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id_employee", nullable = false)
|
||||
private Integer idEmployee;
|
||||
|
||||
/**
|
||||
* 社員名
|
||||
*/
|
||||
@Column(name = "nm_employee", nullable = false)
|
||||
private String nmEmployee;
|
||||
|
||||
/**
|
||||
* 社員名カナ
|
||||
*/
|
||||
@Column(name = "kn_employee", nullable = false)
|
||||
private String knEmployee;
|
||||
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
@Column(name = "mail_address", nullable = false)
|
||||
private String mailAddress;
|
||||
|
||||
/**
|
||||
* パスワード
|
||||
*/
|
||||
@Column(name = "password", nullable = false)
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 管理者権限
|
||||
*/
|
||||
@Column(name = "admin_auth", nullable = false)
|
||||
private Integer adminAuth;
|
||||
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
@Column(name = "id_department", nullable = false)
|
||||
private Integer idDepartment;
|
||||
|
||||
|
||||
/**
|
||||
* Employee(BusinessLogic 依存)を EmployeeEntity(DataAccess層依存)に変換します。
|
||||
*
|
||||
* @param employee Employee Table の中身
|
||||
* @return EmployeeEntity のインスタンス(1レコード分)
|
||||
*/
|
||||
public static EmployeeEntity convertFrom(Employee employee) {
|
||||
// 値を既に持ったインスタンスの生成に、コンストラクタを使用するとこうなります。
|
||||
return new EmployeeEntity(
|
||||
employee.getIdEmployee(),
|
||||
employee.getNmEmployee(),
|
||||
employee.getKnEmployee(),
|
||||
employee.getMailAddress(),
|
||||
employee.getPassword(),
|
||||
employee.getAdminAuth(),
|
||||
employee.getIdDepartment()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* SearchConditionEmployee(BusinessLogic 依存)を EmployeeEntity(DataAccess層依存)に変換します。
|
||||
* (コンストラクタを使用せず、Setterを利用したパターン)
|
||||
*
|
||||
* @param searchConditionEmployee 検索条件
|
||||
* @return EmployeeEntity のインスタンス(1レコード分)
|
||||
*/
|
||||
public static EmployeeEntity convertFrom(SearchConditionEmployee searchConditionEmployee) {
|
||||
EmployeeEntity employeeEntity = new EmployeeEntity();
|
||||
|
||||
employeeEntity.setIdEmployee(searchConditionEmployee.getIdEmployee());
|
||||
employeeEntity.setNmEmployee(searchConditionEmployee.getNmEmployee());
|
||||
employeeEntity.setKnEmployee(searchConditionEmployee.getKnEmployee());
|
||||
employeeEntity.setMailAddress(searchConditionEmployee.getMailAddress());
|
||||
employeeEntity.setIdDepartment(searchConditionEmployee.getIdDepartment());
|
||||
|
||||
|
||||
return employeeEntity;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* EmployeeEntity(DataAccess層依存)から Employee (BusinessLogic層依存型)に変換します。
|
||||
*
|
||||
* @param employeeEntity Employee Table のインスタンス
|
||||
* @return employee インスタンス
|
||||
*/
|
||||
public static Employee createEmployee(EmployeeEntity employeeEntity) {
|
||||
// 値を既に持ったインスタンスの生成に、コンストラクタを使用するとこうなります。
|
||||
return new Employee(
|
||||
employeeEntity.getIdEmployee(),
|
||||
employeeEntity.getNmEmployee(),
|
||||
employeeEntity.getKnEmployee(),
|
||||
employeeEntity.getMailAddress(),
|
||||
employeeEntity.getPassword(),
|
||||
employeeEntity.getAdminAuth(),
|
||||
employeeEntity.getIdDepartment()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* EmployeeEntity(DataAccess層依存) から Employee (BusinessLogic層依存型)に変換します。(リスト版)
|
||||
*
|
||||
* @param employeeEntityList EmployeeEntity インスタンスのリスト
|
||||
* @return Employee インスタンスのリスト
|
||||
*/
|
||||
public static List<Employee> createEmployeeList(List<EmployeeEntity> employeeEntityList) {
|
||||
/* 従来の書き方
|
||||
List<Employee> employeeList = new ArrayList<>();
|
||||
for(EmployeeEntity employeeEntity:employeeEntityList){
|
||||
Employee employee = EmployeeEntity.createEmployee(employeeEntity);
|
||||
employeeList.add(employee);
|
||||
}
|
||||
return employeeList;
|
||||
*/
|
||||
|
||||
// Stream APIを使用すると1行で書けます。
|
||||
return employeeEntityList.stream().map(EmployeeEntity::createEmployee).toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* EmployeeEntity(DataAccess層依存) から LoginUser (BusinessLogic層依存型)情報を作成します。
|
||||
*
|
||||
* @return loginUser (ログイン者の情報) インスタンス
|
||||
*/
|
||||
public LoginUser createLoginUser() {
|
||||
// 値を既に持ったインスタンスの生成に、コンストラクタを使用するとこうなります。
|
||||
return new LoginUser(
|
||||
getIdEmployee(),
|
||||
getNmEmployee(),
|
||||
getKnEmployee(),
|
||||
getMailAddress(),
|
||||
getPassword(),
|
||||
getAdminAuth(),
|
||||
getIdDepartment()
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.example.rhizome.app.infra.repository;
|
||||
|
||||
import com.example.rhizome.app.infra.entity.DepartmentEntity;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
|
||||
/**
|
||||
* Specification:
|
||||
* 関数型インターフェースです。
|
||||
* JPAの一部として提供されていて、エンティティの情報を元に動的にクエリを生成し、DBからデータを取得します。
|
||||
* 使い方:
|
||||
* toPredicate をOverrideして使います。
|
||||
* パラメータ:
|
||||
* Root<T>:ルートエンティティを指します。<T>に指定したエンティティ(今回はDepartmentEntity)を用いてメンバにアクセスします。
|
||||
* CriteriaQuery<\?>:サブクエリを作成する際に使用します。※今回は使用しません
|
||||
* CriteriaBuilder:条件式(Where句以降の条件)の部分のクエリを作るためのビルダーです。
|
||||
* 戻り値はクエリを格納しているPredicateオブジェクトとなります。
|
||||
*/
|
||||
@Repository
|
||||
public interface DepartmentRepository extends JpaRepository<DepartmentEntity, Integer>, JpaSpecificationExecutor<DepartmentEntity> {
|
||||
|
||||
|
||||
static Specification<DepartmentEntity> idDepartmentEqual(Integer idDepartment) {
|
||||
return idDepartment == null ?
|
||||
null :
|
||||
// 戻り値の型 Specification<DepartmentEntity> にキャスト
|
||||
(Specification<DepartmentEntity>)
|
||||
// ラムダ式で記載しているが書いてあることは criteriaBuilder を使って Where句の後の "'idDepartment' = idDepartment(変数)"
|
||||
// を作成している
|
||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.equal(root.get("idDepartment"), idDepartment);
|
||||
}
|
||||
|
||||
static Specification<DepartmentEntity> nmDepartmentEqual(String nmDepartment) {
|
||||
return (nmDepartment == null || nmDepartment.isEmpty()) ?
|
||||
null :
|
||||
(Specification<DepartmentEntity>)
|
||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.like(root.get("nmDepartment"), nmDepartment);
|
||||
}
|
||||
|
||||
|
||||
static Specification<DepartmentEntity> nmDepartmentLike(String nmDepartment) {
|
||||
return (nmDepartment == null || nmDepartment.isEmpty()) ?
|
||||
null :
|
||||
(Specification<DepartmentEntity>)
|
||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.like(root.get("nmDepartment"), "%" + nmDepartment + "%");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.example.rhizome.app.infra.repository;
|
||||
|
||||
import com.example.rhizome.app.infra.entity.EmployeeDepartmentEntity;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* ワンポイント情報(ここで登場する関数型インターフェース Specification について解説します)
|
||||
* Specification:
|
||||
* 関数型インターフェースです。
|
||||
* JPAの一部として提供されていて、エンティティの情報を元に動的にクエリを生成し、DBからデータを取得します。
|
||||
* 使い方:
|
||||
* toPredicate をOverrideして使います。
|
||||
* パラメータ:
|
||||
* Root<T>:ルートエンティティを指します。<T>に指定したエンティティ(今回はDepartmentEntity)を用いてメンバにアクセスします。
|
||||
* CriteriaQuery<\?>:サブクエリを作成する際に使用します。※今回は使用しません
|
||||
* CriteriaBuilder:条件式(Where句以降の条件)の部分のクエリを作るためのビルダーです。
|
||||
* 戻り値はクエリを格納しているPredicateオブジェクトとなります。
|
||||
*/
|
||||
@Repository
|
||||
public interface EmployeeInfoRepository extends JpaRepository<EmployeeDepartmentEntity, Integer>, JpaSpecificationExecutor<EmployeeDepartmentEntity> {
|
||||
|
||||
static Specification<EmployeeDepartmentEntity> idEmployeeEqual(Integer idEmployee) {
|
||||
return idEmployee == null ?
|
||||
null :
|
||||
// 戻り値の型 Specification<EmployeeDepartmentEntity> にキャスト
|
||||
(Specification<EmployeeDepartmentEntity>)
|
||||
// ラムダ式で記載しているが書いてあることは criteriaBuilder を使って Where句の後の "'idEmployee' = idEmployee(変数)"
|
||||
// を作成している
|
||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.equal(root.get("idEmployee"), idEmployee);
|
||||
}
|
||||
|
||||
static Specification<EmployeeDepartmentEntity> nmEmployeeEqual(String nmEmployee) {
|
||||
return (nmEmployee == null || nmEmployee.isEmpty()) ?
|
||||
null :
|
||||
(Specification<EmployeeDepartmentEntity>)
|
||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.like(root.get("nmEmployee"), "%" + nmEmployee + "%");
|
||||
}
|
||||
|
||||
static Specification<EmployeeDepartmentEntity> knEmployeeEqual(String knEmployee) {
|
||||
return (knEmployee == null || knEmployee.isEmpty()) ?
|
||||
null :
|
||||
(Specification<EmployeeDepartmentEntity>)
|
||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.like(root.get("knEmployee"), "%" + knEmployee + "%");
|
||||
}
|
||||
|
||||
static Specification<EmployeeDepartmentEntity> mailAddressEqual(String mailAddress) {
|
||||
return (mailAddress == null || mailAddress.isEmpty()) ?
|
||||
null :
|
||||
(Specification<EmployeeDepartmentEntity>)
|
||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.like(root.get("mailAddress"), "%" + mailAddress + "%");
|
||||
}
|
||||
|
||||
static Specification<EmployeeDepartmentEntity> idDepartmentEqual(Integer idDepartment) {
|
||||
return (root, query, criteriaBuilder) ->
|
||||
idDepartment == null ? null :
|
||||
criteriaBuilder.equal(root.join("department").get("idDepartment"), idDepartment);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.example.rhizome.app.infra.repository;
|
||||
|
||||
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface EmployeeRepository extends JpaRepository<EmployeeEntity, Integer> {
|
||||
Optional<EmployeeEntity> findByMailAddressAndPassword(String mailAddress, String password);
|
||||
|
||||
/**
|
||||
* メールアドレスで検索
|
||||
**/
|
||||
Optional<EmployeeEntity> findByMailAddress(String mail);
|
||||
|
||||
/**
|
||||
* IDで検索
|
||||
**/
|
||||
Optional<EmployeeEntity> findByIdEmployee(Integer idEmployee);
|
||||
|
||||
/**
|
||||
* IDで検索
|
||||
**/
|
||||
List<EmployeeEntity> findByIdDepartment(Integer idDepartment);
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
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.domain.model.LoginUser;
|
||||
import com.example.rhizome.app.domain.service.DeleteEmployee;
|
||||
import com.example.rhizome.app.domain.service.SearchDepartment;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.SessionKeyword;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
||||
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 String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||
|
||||
HttpSession httpSession;
|
||||
DeleteEmployee deleteEmployee;
|
||||
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) {
|
||||
|
||||
try {
|
||||
// 部署一覧を取得し、画面に返す用のクラスに詰め替える
|
||||
// 作成した部署一覧をセット
|
||||
model.addAttribute(
|
||||
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||
DepartmentForm.convertFrom(searchDepartment.selectAll())
|
||||
);
|
||||
|
||||
// 削除処理実施
|
||||
deleteExec(
|
||||
model,
|
||||
idEmployee,
|
||||
LoginUserForm.convertTo((LoginUserForm) httpSession.getAttribute(SessionKeyword.LOGIN_USER)));
|
||||
|
||||
// 検索画面に遷移
|
||||
return "forward:" + TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_INFO_FORM_EMPTY;
|
||||
|
||||
} catch (Exception e) {
|
||||
// ログイン情報の破棄
|
||||
httpSession.invalidate();
|
||||
|
||||
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) {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// 削除を実施
|
||||
deleteEmployee.deleteEmployee(idEmployee);
|
||||
|
||||
// 削除完了したメッセージをセット
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_INFO, new MessageForm(DELETE_COMPLETE));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
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 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.*;
|
||||
|
||||
@Controller
|
||||
public class IndexController {
|
||||
|
||||
HttpSession httpSession;
|
||||
|
||||
@Autowired
|
||||
public IndexController(HttpSession httpSession, LoginImpl loginImpl) {
|
||||
this.httpSession = httpSession;
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
|
||||
// 空のFormをSessionに用意
|
||||
model.addAttribute(PageReturnAttributeKeyword.LOGIN_INFO_FORM, loginUserForm());
|
||||
|
||||
// ログイン画面に遷移
|
||||
return LOGIN_HTML;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
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.domain.model.Employee;
|
||||
import com.example.rhizome.app.domain.service.SearchDepartment;
|
||||
import com.example.rhizome.app.domain.service.SearchEmployee;
|
||||
import com.example.rhizome.app.domain.service.impl.SearchDepartmentImpl;
|
||||
import com.example.rhizome.app.domain.service.impl.SearchEmployeeImpl;
|
||||
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.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 String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||
|
||||
HttpSession httpSession;
|
||||
SearchDepartment searchDepartment;
|
||||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
* 登録情報のチェックを行う
|
||||
*
|
||||
* @param insertEmployeeForm 登録情報
|
||||
* @param model ビューにデータを渡すためのコンテナ
|
||||
* @return 遷移先の画面
|
||||
*/
|
||||
@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()
|
||||
));
|
||||
|
||||
// 登録用パラメータチェック
|
||||
List<String> 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;
|
||||
}
|
||||
|
||||
final String DUPLICATION = "既に登録済みのメールアドレスです。";
|
||||
|
||||
// 登録対象のメールアドレスを元に検索
|
||||
List<Employee> 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;
|
||||
}
|
||||
|
||||
// 登録確認ページに遷移
|
||||
model.addAttribute(PageReturnAttributeKeyword.INSERT_EMPLOYEE_FORM, insertEmployeeForm);
|
||||
// 登録確認画面に遷移
|
||||
return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_CONFIRM_HTML;
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
// ログイン情報の破棄
|
||||
httpSession.invalidate();
|
||||
|
||||
e.printStackTrace();
|
||||
|
||||
// エラーログ出力
|
||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||
// エラー画面遷移
|
||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,198 @@
|
||||
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.domain.service.RegisterEmployee;
|
||||
import com.example.rhizome.app.domain.service.SearchDepartment;
|
||||
import com.example.rhizome.app.domain.service.impl.RegisterEmployeeImpl;
|
||||
import com.example.rhizome.app.domain.service.impl.SearchDepartmentImpl;
|
||||
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.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 String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||
|
||||
HttpSession httpSession;
|
||||
RegisterEmployee registerEmployee;
|
||||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
* 新規登録画面表示処理
|
||||
*
|
||||
* @param insertEmployeeForm 登録情報
|
||||
* @param model ビューにデータを渡すためのコンテナ
|
||||
* @return 遷移先の画面
|
||||
*/
|
||||
@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()
|
||||
));
|
||||
|
||||
// Confirm画面から渡ってきた値をチェック
|
||||
List<String> 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;
|
||||
}
|
||||
|
||||
// 登録処理
|
||||
registerEmployee.registerEmployee(InsertEmployeeForm.convertTo(insertEmployeeForm));
|
||||
// 登録結果画面に遷移
|
||||
return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_RESULT_HTML;
|
||||
|
||||
} catch (Exception e) {
|
||||
// ログイン情報の破棄
|
||||
httpSession.invalidate();
|
||||
|
||||
e.printStackTrace();
|
||||
|
||||
// エラーログ出力
|
||||
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<String> 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 = "所属部署";
|
||||
|
||||
List<String> error = new ArrayList<>();
|
||||
|
||||
// null or 空文字判定
|
||||
if (isNullOrBlank(employeeName)) {
|
||||
// エラー内容を追加
|
||||
error.add(EMPLOYEE_NAME_NULL_BLANK);
|
||||
}
|
||||
|
||||
// null or 空文字判定
|
||||
if (isNullOrBlank(employeeKana)) {
|
||||
// エラー内容を追加
|
||||
error.add(EMPLOYEE_KANA_NULL_BLANK);
|
||||
}
|
||||
|
||||
// null or 空文字判定
|
||||
if (isNullOrBlank(mailAddress)) {
|
||||
// エラー内容を追加
|
||||
error.add(MAIL_ADDRESS_NULL_BLANK);
|
||||
}
|
||||
|
||||
// null or 空文字判定
|
||||
if (isNullOrBlank(password)) {
|
||||
// エラー内容を追加
|
||||
error.add(PASSWORD_NULL_BLANK);
|
||||
}
|
||||
|
||||
// 管理者権限の値が不正か
|
||||
if (management == null) {
|
||||
// エラー内容を追加
|
||||
error.add(MANAGEMENT_ERROR);
|
||||
}
|
||||
|
||||
// 所属部署の値が不正か
|
||||
if (departmentId == null) {
|
||||
// エラー内容を追加
|
||||
error.add(DEPARTMENT_ID_NULL_BLANK);
|
||||
}
|
||||
|
||||
return error;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 仮引数を null or 空 判定する
|
||||
*
|
||||
* @param str 判定対象の文字列
|
||||
* @return true:null or 空 false:null or 空 では無い
|
||||
*/
|
||||
private static boolean isNullOrBlank(String str) {
|
||||
if (null == str) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return str.isBlank();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
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.domain.service.RegisterEmployee;
|
||||
import com.example.rhizome.app.domain.service.SearchDepartment;
|
||||
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.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 String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||
|
||||
HttpSession httpSession;
|
||||
RegisterEmployee registerEmployee;
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 登録画面表示処理
|
||||
*
|
||||
* @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()));
|
||||
|
||||
// パラメータをセット
|
||||
model.addAttribute(PageReturnAttributeKeyword.INSERT_EMPLOYEE_FORM, insertEmployeeForm);
|
||||
|
||||
// 登録画面に遷移
|
||||
return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML;
|
||||
|
||||
} catch (Exception e) {
|
||||
// ログイン情報の破棄
|
||||
httpSession.invalidate();
|
||||
|
||||
e.printStackTrace();
|
||||
|
||||
// エラーログ出力
|
||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||
// エラー画面遷移
|
||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
package com.example.rhizome.app.presentation.controller;
|
||||
|
||||
|
||||
import com.example.rhizome.app.domain.model.LoginInfo;
|
||||
import com.example.rhizome.app.domain.model.LoginUser;
|
||||
import com.example.rhizome.app.domain.service.Login;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.SessionKeyword;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
||||
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 String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||
|
||||
HttpSession httpSession;
|
||||
Login login;
|
||||
|
||||
@Autowired
|
||||
public LoginController(HttpSession httpSession, Login login) {
|
||||
this.httpSession = httpSession;
|
||||
this.login = login;
|
||||
}
|
||||
|
||||
@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) {
|
||||
|
||||
// ログに出力する
|
||||
final String MAIL_ADDRESS_PASSWORD_ERROR = "メールアドレス、パスワードの入力内容に誤りがあります";
|
||||
// 発生しうるErrorに対するメッセージ
|
||||
final String LOGIN_ERROR = "IDまたはパスワードが間違っています";
|
||||
|
||||
try {
|
||||
// mailAddress, password の入力に誤りがあるかチェック
|
||||
if (!LoginUserForm.checkParameter(loginInfoForm)) {
|
||||
|
||||
// mail,passwordが仕様を満たしていない場合
|
||||
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;
|
||||
}
|
||||
|
||||
// Login者情報インスタンスを作成
|
||||
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;
|
||||
}
|
||||
|
||||
// ログイン(インスタンス作成)
|
||||
LoginUser loginUser = login.doLogin(loginInfo);
|
||||
|
||||
// ログイン者の情報をセッション情報に格納
|
||||
// セッションに 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;
|
||||
}
|
||||
|
||||
// メニュー画面に遷移
|
||||
return TransitionTargetPageNameKeyword.MENU_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);
|
||||
|
||||
// セッションにログイン者情報があるか
|
||||
if (loginUserForm != null) {
|
||||
// セッションにログイン者情報がある場合
|
||||
return new LoginInfo(loginUserForm.getMailAddress(), loginUserForm.getPassword());
|
||||
}
|
||||
|
||||
// セッションにない場合は画面からの input 値 を取得
|
||||
return new LoginInfo(
|
||||
loginInfoForm.getMailAddress(),
|
||||
loginInfoForm.getPassword()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
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 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.LOGOUT;
|
||||
|
||||
/**
|
||||
* ログアウト処理のコントローラ
|
||||
*/
|
||||
@Controller
|
||||
public class LogoutController {
|
||||
|
||||
// ログ出力用インスタンス
|
||||
private final static Logger LOGGER = Logger.getLogger(LogoutController.class.getName());
|
||||
// エラーメッセージ用の定数フィールド
|
||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||
|
||||
HttpSession httpSession;
|
||||
|
||||
@Autowired
|
||||
public LogoutController(HttpSession httpSession) {
|
||||
this.httpSession = httpSession;
|
||||
}
|
||||
|
||||
@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();
|
||||
|
||||
// ログイン画面に遷移するための情報を設定
|
||||
model.addAttribute(PageReturnAttributeKeyword.LOGIN_INFO_FORM, loginUserForm());
|
||||
// login.html に遷移
|
||||
return TransitionTargetPageNameKeyword.LOGIN_HTML;
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
// エラーログ出力
|
||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||
// エラーページに遷移
|
||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
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.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();
|
||||
}
|
||||
|
||||
/**
|
||||
* メニュー画面に遷移
|
||||
*/
|
||||
@PermissionCheck
|
||||
@SessionCheck
|
||||
@RequestMapping(value = TransitionTargetPageNameKeyword.SHOW_MENU)
|
||||
public String showMenu() {
|
||||
// メニュー画面遷移
|
||||
return TransitionTargetPageNameKeyword.MENU_HTML;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
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.domain.service.SearchDepartment;
|
||||
import com.example.rhizome.app.domain.service.SearchEmployeeInfo;
|
||||
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.DepartmentForm;
|
||||
import com.example.rhizome.app.presentation.form.EmployeeInfoForm;
|
||||
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
|
||||
public class SelectEmployeeController {
|
||||
|
||||
// ログ出力用インスタンス
|
||||
private final static Logger LOGGER = Logger.getLogger(SelectEmployeeController.class.getName());
|
||||
// エラーメッセージ用の定数フィールド
|
||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||
|
||||
HttpSession httpSession;
|
||||
SearchDepartment searchDepartment;
|
||||
SearchEmployeeInfo searchEmployeeInfo;
|
||||
|
||||
@Autowired
|
||||
public SelectEmployeeController(HttpSession httpSession, SearchDepartment searchDepartment, SearchEmployeeInfo searchEmployeeInfo) {
|
||||
this.httpSession = httpSession;
|
||||
this.searchDepartment = searchDepartment;
|
||||
this.searchEmployeeInfo = searchEmployeeInfo;
|
||||
}
|
||||
|
||||
@ModelAttribute
|
||||
public SearchConditionEmployeeForm searchConditionEmployeeForm() {
|
||||
return new SearchConditionEmployeeForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* 社員検索画面表示処理コントローラ
|
||||
*
|
||||
* @param searchConditionEmployeeForm 検索画面のフォーム
|
||||
* @param model ビューにデータを渡すためのコンテナ
|
||||
* @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())
|
||||
);
|
||||
|
||||
// 検索条件を元に検索を実施
|
||||
// 取得した EmployeeInfo( employee + department )の情報を画面に返す用の型に詰め替えてセット
|
||||
model.addAttribute(PageReturnAttributeKeyword.EMPLOYEE_INFO_FORM_LIST, EmployeeInfoForm.convertFrom(searchEmployeeInfo.searchBy(SearchConditionEmployeeForm.convertTo(searchConditionEmployeeForm))));
|
||||
// 検索ページに遷移
|
||||
return TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_HTML;
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
// ログイン情報の破棄
|
||||
httpSession.invalidate();
|
||||
|
||||
e.printStackTrace();
|
||||
|
||||
// エラーログ出力
|
||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||
// エラー画面遷移
|
||||
return TransitionTargetPageNameKeyword.ERROR_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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
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.domain.model.EmployeeInfo;
|
||||
import com.example.rhizome.app.domain.model.SearchConditionEmployee;
|
||||
import com.example.rhizome.app.domain.service.SearchDepartment;
|
||||
import com.example.rhizome.app.domain.service.SearchEmployeeInfo;
|
||||
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.DepartmentForm;
|
||||
import com.example.rhizome.app.presentation.form.MessageForm;
|
||||
import com.example.rhizome.app.presentation.form.SearchConditionEmployeeForm;
|
||||
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
|
||||
public class UpdateEmployeeController {
|
||||
|
||||
// ログ出力用インスタンス
|
||||
private final static Logger LOGGER = Logger.getLogger(UpdateEmployeeController.class.getName());
|
||||
// エラーメッセージ用の定数フィールド
|
||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||
|
||||
HttpSession httpSession;
|
||||
SearchDepartment searchDepartment;
|
||||
SearchEmployeeInfo searchEmployeeInfo;
|
||||
|
||||
@Autowired
|
||||
public UpdateEmployeeController(HttpSession httpSession, SearchDepartment searchDepartment, SearchEmployeeInfo searchEmployeeInfo) {
|
||||
this.httpSession = httpSession;
|
||||
this.searchDepartment = searchDepartment;
|
||||
this.searchEmployeeInfo = searchEmployeeInfo;
|
||||
}
|
||||
|
||||
@ModelAttribute
|
||||
public SearchConditionEmployeeForm searchConditionEmployeeForm() {
|
||||
return new SearchConditionEmployeeForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新対象の employee が存在するか確認する為のコントローラ
|
||||
*
|
||||
* @param idEmployee 更新対象の employee の id
|
||||
* @param model ビューにデータを渡すためのコンテナ
|
||||
* @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 {
|
||||
// 部署一覧を取得し画面に返す値としてセット
|
||||
model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, DepartmentForm.convertFrom(searchDepartment.selectAll()));
|
||||
|
||||
// id を条件に更新対象のレコードを検索、取得する
|
||||
List<EmployeeInfo> employeeInfoList = searchEmployeeInfo.searchBy(
|
||||
new SearchConditionEmployee(idEmployee,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null));
|
||||
|
||||
// DBに更新対象のデータがあるか
|
||||
if (employeeInfoList.isEmpty()) {
|
||||
// ない場合はエラーメッセージをセットして検索画面に戻る
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(UPDATE_TARGET_ID_NOT_FOUND));
|
||||
return "forward:" + TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_INFO;
|
||||
}
|
||||
|
||||
// 更新画面に遷移
|
||||
model.addAttribute(PageReturnAttributeKeyword.UPDATE_EMPLOYEE_INFO_FORM, UpdateEmployeeInfoForm.convertFrom(employeeInfoList.get(0)));
|
||||
|
||||
// Update画面に遷移
|
||||
return TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_INPUT_HTML;
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
// ログイン情報の破棄
|
||||
httpSession.invalidate();
|
||||
|
||||
e.printStackTrace();
|
||||
|
||||
// エラーログ出力
|
||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||
// エラー画面遷移
|
||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
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.domain.model.Employee;
|
||||
import com.example.rhizome.app.domain.model.LoginUser;
|
||||
import com.example.rhizome.app.domain.service.SearchDepartment;
|
||||
import com.example.rhizome.app.domain.service.SearchEmployee;
|
||||
import com.example.rhizome.app.domain.service.UpdateEmployee;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.SessionKeyword;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
||||
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 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
|
||||
public class UpdateEmployeeResultController {
|
||||
|
||||
// ログ出力用インスタンス
|
||||
private final static Logger LOGGER = Logger.getLogger(UpdateEmployeeController.class.getName());
|
||||
// エラーメッセージ用の定数フィールド
|
||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||
|
||||
HttpSession httpSession;
|
||||
SearchDepartment searchDepartment;
|
||||
SearchEmployee searchEmployee;
|
||||
UpdateEmployee updateEmployee;
|
||||
|
||||
@Autowired
|
||||
public UpdateEmployeeResultController(HttpSession httpSession, SearchDepartment searchDepartment, SearchEmployee searchEmployee, UpdateEmployee updateEmployee) {
|
||||
this.httpSession = httpSession;
|
||||
this.searchDepartment = searchDepartment;
|
||||
this.searchEmployee = searchEmployee;
|
||||
this.updateEmployee = updateEmployee;
|
||||
}
|
||||
|
||||
/**
|
||||
* メールアドレスの重複チェック
|
||||
*
|
||||
* @param employeeList 元の employeeList
|
||||
* @param updateEmployeeInfoForm 更新対象のデータ
|
||||
* @return true:重複無し false:重複あり
|
||||
*/
|
||||
private static boolean checkDuplicateMailAddress(List<Employee> employeeList, UpdateEmployeeInfoForm updateEmployeeInfoForm) {
|
||||
// メールアドレスが既に使われていた場合
|
||||
if (!employeeList.isEmpty()) {
|
||||
// 重複が有った場合に、同一人物のものであれば上書きOKとする
|
||||
return Objects.equals(employeeList.get(0).getIdEmployee(), updateEmployeeInfoForm.getIdEmployee());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新結果画面表示処理
|
||||
*
|
||||
* @param updateEmployeeInfoForm 更新画面のフォーム
|
||||
* @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 NOTHING = "項目が空欄です。";
|
||||
final String ADMIN_USER = "更新対象者がログイン者のため、管理者権限を変更できません。";
|
||||
final String NO_TARGET = "更新対象のデータが見つかりません。";
|
||||
|
||||
final String UPDATE_COMPLETE = "更新が完了しました。";
|
||||
|
||||
|
||||
try {
|
||||
|
||||
// 部署一覧取得
|
||||
model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, DepartmentForm.convertFrom(searchDepartment.selectAll()));
|
||||
|
||||
// パスワードが仕様を満たしているか確認
|
||||
String error = UpdateEmployeeInfoForm.validatePassword(
|
||||
updateEmployeeInfoForm.getPassword(),
|
||||
updateEmployeeInfoForm.getPasswordConfirm()
|
||||
);
|
||||
|
||||
// エラーが存在するか
|
||||
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)) {
|
||||
// 存在する場合はエラーメッセージを設定して更新入力画面に遷移
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DUPLICATION));
|
||||
model.addAttribute(PageReturnAttributeKeyword.UPDATE_EMPLOYEE_INFO_FORM, updateEmployeeInfoForm);
|
||||
|
||||
return TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_INPUT_HTML;
|
||||
}
|
||||
|
||||
// session 情報からログイン者の情報を取得
|
||||
LoginUserForm loginUserForm = (LoginUserForm) httpSession.getAttribute(SessionKeyword.LOGIN_USER);
|
||||
|
||||
// ログイン者が更新対象で、権限を管理者権限から一般権限に変更しようとしているかチェック
|
||||
if (isUpdateTargetLoginUserAdminToNormal(updateEmployeeInfoForm, loginUserForm)) {
|
||||
// 存在する場合はエラーメッセージを設定して更新入力画面に遷移
|
||||
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)) {
|
||||
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;
|
||||
}
|
||||
|
||||
// 画面用の型からビジネスロジック用のモデルに変換し、Updateを実行
|
||||
updateEmployee.updateEmployee(beforeEmployee, UpdateEmployeeInfoForm.convertTo(updateEmployeeInfoForm));
|
||||
|
||||
// Update後の情報を再取得
|
||||
LoginUser updatedTargetEmployee = searchEmployee.searchLoginUser(updateEmployeeInfoForm.getMailAddress());
|
||||
|
||||
// ログイン者と更新した対象が同じアカウントだった場合、session情報を更新
|
||||
if (Objects.equals(updatedTargetEmployee.getIdEmployee(), loginUserForm.getIdEmployee())) {
|
||||
// ログイン者の情報をセッション情報に格納
|
||||
httpSession.setAttribute(SessionKeyword.LOGIN_USER, LoginUserForm.convertFrom(updatedTargetEmployee));
|
||||
}
|
||||
|
||||
// 更新結果のメッセージを画面にセットし一覧画面に遷移
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_INFO, new MessageForm(UPDATE_COMPLETE));
|
||||
|
||||
// forward 先で不用意な動作をしないために UpdateEmployeeInfoForm をクリア
|
||||
return "forward:" + TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_INFO_FORM_EMPTY;
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
// ログイン情報の破棄
|
||||
httpSession.invalidate();
|
||||
|
||||
e.printStackTrace();
|
||||
// エラーログ出力
|
||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||
// エラー画面遷移
|
||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* ログイン者がログイン者自身を更新する際
|
||||
* 管理者権限から一般権限に変更する内容も含まれているかチェックする
|
||||
*
|
||||
* @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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
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.domain.model.Employee;
|
||||
import com.example.rhizome.app.domain.service.SearchEmployee;
|
||||
import com.example.rhizome.app.domain.service.UpdateEmployee;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.SessionKeyword;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
||||
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.List;
|
||||
import java.util.Objects;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* 個人情報更新用コントローラ
|
||||
*/
|
||||
@Controller
|
||||
public class UpdatePersonalEmployeeResultController {
|
||||
|
||||
// ログ出力用インスタンス
|
||||
private final static Logger LOGGER = Logger.getLogger(UpdatePersonalEmployeeResultController.class.getName());
|
||||
|
||||
// エラーメッセージ用の定数フィールド
|
||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||
|
||||
HttpSession httpSession;
|
||||
SearchEmployee searchEmployee;
|
||||
UpdateEmployee updateEmployee;
|
||||
|
||||
@Autowired
|
||||
public UpdatePersonalEmployeeResultController(HttpSession httpSession, SearchEmployee searchEmployee, UpdateEmployee updateEmployee) {
|
||||
this.httpSession = httpSession;
|
||||
this.searchEmployee = searchEmployee;
|
||||
this.updateEmployee = updateEmployee;
|
||||
}
|
||||
|
||||
/**
|
||||
* メールアドレスの重複チェック
|
||||
*
|
||||
* @param employeeList 元の employeeList
|
||||
* @param updatePersonalUserForm 更新対象のデータ
|
||||
* @return true:重複無し false:重複あり
|
||||
*/
|
||||
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
|
||||
public UpdatePersonalUserForm personalUpdateUserForm() {
|
||||
return new UpdatePersonalUserForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* 個人情報更新結果画面表示処理
|
||||
*
|
||||
* @param updatePersonalUserForm 個人情報更新画面のフォーム
|
||||
* @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 DUPLICATION = "既に登録済みのメールアドレスです。";
|
||||
|
||||
try {
|
||||
|
||||
// 更新完了画面からの遷移の場合
|
||||
if (updatePersonalUserForm.getIdEmployee() == null) {
|
||||
// ログイン者の情報を取得
|
||||
LoginUserForm loginUserForm = (LoginUserForm) httpSession.getAttribute(SessionKeyword.LOGIN_USER);
|
||||
// ログイン者の情報を元に個人情報更新画面の初期表示用のインスタンスを作成
|
||||
model.addAttribute(PageReturnAttributeKeyword.UPDATE_PERSONAL_EMPLOYEE_USER_FORM, UpdatePersonalUserForm.convertFrom(searchEmployee.searchLoginUser(loginUserForm.getMailAddress())));
|
||||
|
||||
return TransitionTargetPageNameKeyword.UPDATE_PERSONAL_EMPLOYEE_INPUT_HTML;
|
||||
}
|
||||
|
||||
// パスワードが仕様を満たしているかチェック
|
||||
String error = UpdatePersonalUserForm.validatePassword(
|
||||
updatePersonalUserForm.getPassword(),
|
||||
updatePersonalUserForm.getPasswordConfirm()
|
||||
);
|
||||
|
||||
// エラーがあるか
|
||||
if (!error.isBlank()) {
|
||||
// エラーが有る場合メッセージをセットして個人情報更新入力画面に遷移
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(error));
|
||||
model.addAttribute(PageReturnAttributeKeyword.UPDATE_PERSONAL_EMPLOYEE_USER_FORM, updatePersonalUserForm);
|
||||
|
||||
return TransitionTargetPageNameKeyword.UPDATE_PERSONAL_EMPLOYEE_INPUT_HTML;
|
||||
}
|
||||
|
||||
// 入力必須を満たしているか
|
||||
if (!UpdatePersonalUserForm.hasErrorParameter(updatePersonalUserForm)) {
|
||||
// 満たしていない場合、メッセージをセットして個人情報更新入力画面に遷移
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(NOTHING));
|
||||
model.addAttribute(PageReturnAttributeKeyword.UPDATE_PERSONAL_EMPLOYEE_USER_FORM, updatePersonalUserForm);
|
||||
|
||||
return TransitionTargetPageNameKeyword.UPDATE_PERSONAL_EMPLOYEE_INPUT_HTML;
|
||||
}
|
||||
|
||||
// メールアドレス重複チェック
|
||||
if (!checkDuplicateMailAddress(
|
||||
searchEmployee.searchEmployee(updatePersonalUserForm.getMailAddress()),
|
||||
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;
|
||||
}
|
||||
|
||||
//更新前のEmployeeの情報を取得
|
||||
// 画面用のインスタンスから更新用のインスタンスに変換し、Update実施
|
||||
updateEmployee.updateEmployee(
|
||||
searchEmployee.searchEmployeeByIdEmployee(updatePersonalUserForm.getIdEmployee()),
|
||||
UpdatePersonalUserForm.convertTo(updatePersonalUserForm)
|
||||
);
|
||||
|
||||
// ログイン者の情報をセッション情報に格納
|
||||
httpSession.setAttribute(
|
||||
SessionKeyword.LOGIN_USER,
|
||||
LoginUserForm.convertFrom(
|
||||
searchEmployee.searchLoginUser(updatePersonalUserForm.getMailAddress()))
|
||||
);
|
||||
|
||||
// 更新結果画面に遷移
|
||||
return TransitionTargetPageNameKeyword.UPDATE_PERSONAL_RESULT_HTML;
|
||||
|
||||
} catch (Exception e) {
|
||||
// ログイン情報の破棄
|
||||
httpSession.invalidate();
|
||||
|
||||
// エラーログ出力
|
||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||
// エラー画面遷移
|
||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.example.rhizome.app.presentation.controller.pageproperty;
|
||||
|
||||
/**
|
||||
* Servlet から Servlet に返却する際に使用する文字列を管理するクラス
|
||||
*/
|
||||
public class PageReturnAttributeKeyword {
|
||||
|
||||
public static final String MESSAGE_ERROR = "messageError";
|
||||
public static final String MESSAGE_INFO = "messageInfo";
|
||||
|
||||
public static final String DEPARTMENT_FORM_LIST = "departmentFormList";
|
||||
public static final String UPDATE_EMPLOYEE_INFO_FORM = "updateEmployeeInfoForm";
|
||||
public static final String INSERT_EMPLOYEE_FORM = "insertEmployeeForm";
|
||||
public static final String LOGIN_INFO_FORM = "loginInfoForm";
|
||||
public static final String UPDATE_PERSONAL_EMPLOYEE_USER_FORM = "updatePersonalEmployeeUserForm";
|
||||
public static final String EMPLOYEE_INFO_FORM_LIST = "employeeInfoFormList";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.example.rhizome.app.presentation.controller.pageproperty;
|
||||
|
||||
/**
|
||||
* Sessionキーを管理する
|
||||
*/
|
||||
public class SessionKeyword {
|
||||
// SESSION情報として格納したいログイン者の情報
|
||||
public static final String LOGIN_USER = "loginUser";
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.example.rhizome.app.presentation.controller.pageproperty;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* システムで利用しているJSPのリスト
|
||||
*/
|
||||
public class TransitionTargetPageNameKeyword {
|
||||
|
||||
// 共通
|
||||
public static final String LOGIN_HTML = "login";
|
||||
|
||||
// 一般向け
|
||||
public static final String UPDATE_PERSONAL_EMPLOYEE_INPUT_HTML = "updatePersonalEmployeeInput";
|
||||
public static final String UPDATE_PERSONAL_RESULT_HTML = "updatePersonalEmployeeResult";
|
||||
|
||||
// 管理者向け
|
||||
public static final String MENU_HTML = "menu";
|
||||
public static final String SELECT_EMPLOYEE_HTML = "selectEmployee";
|
||||
public static final String INSERT_EMPLOYEE_INPUT_HTML = "insertEmployeeInput";
|
||||
public static final String INSERT_EMPLOYEE_CONFIRM_HTML = "insertEmployeeConfirm";
|
||||
public static final String INSERT_EMPLOYEE_RESULT_HTML = "insertEmployeeResult";
|
||||
public static final String UPDATE_EMPLOYEE_INPUT_HTML = "updateEmployeeInput";
|
||||
|
||||
public static final String ERROR_HTML = "error";
|
||||
|
||||
// 共通(Controller)
|
||||
public static final String INDEX_BLANK = "";
|
||||
public static final String INDEX_SLASH = "/";
|
||||
public static final String INDEX_LOGIN = "/login";
|
||||
public static final String LOGOUT = "/logout";
|
||||
public static final String DO_LOGIN = "/doLogin";
|
||||
|
||||
// 一般向け(Controller)
|
||||
public static final String PERSONAL_UPDATE_RESULT = "/updatePersonalEmployeeResult";
|
||||
|
||||
// 管理者向け(Controller)
|
||||
public static final String DELETE_EMPLOYEE = "/deleteEmployee";
|
||||
public static final String INSERT_EMPLOYEE_INPUT = "/insertEmployeeInput";
|
||||
public static final String INSERT_EMPLOYEE_CONFIRM = "/insertEmployeeConfirm";
|
||||
public static final String INSERT_EMPLOYEE = "/insertEmployee";
|
||||
public static final String SHOW_MENU = "/showMenu";
|
||||
public static final String SELECT_EMPLOYEE_INFO = "/selectEmployeeInfo";
|
||||
public static final String SELECT_EMPLOYEE_INFO_FORM_EMPTY = "/selectAll";
|
||||
public static final String SHOW_UPDATE_EMPLOYEE = "/showUpdateEmployee";
|
||||
public static final String UPDATE_EMPLOYEE_RESULT = "/updateEmployeeResult";
|
||||
|
||||
// Department
|
||||
// HTML
|
||||
// Controller
|
||||
|
||||
/**
|
||||
* 管理者向けのページリストを返す
|
||||
*
|
||||
* @return 管理者向けのページリスト
|
||||
*/
|
||||
public static Set<String> getAdminPageList() {
|
||||
|
||||
return Set.of(
|
||||
INDEX_BLANK,
|
||||
INDEX_SLASH,
|
||||
INDEX_LOGIN,
|
||||
LOGOUT,
|
||||
DO_LOGIN,
|
||||
DELETE_EMPLOYEE,
|
||||
INSERT_EMPLOYEE_INPUT,
|
||||
INSERT_EMPLOYEE_CONFIRM,
|
||||
INSERT_EMPLOYEE,
|
||||
SHOW_MENU,
|
||||
SELECT_EMPLOYEE_INFO,
|
||||
SELECT_EMPLOYEE_INFO_FORM_EMPTY,
|
||||
SHOW_UPDATE_EMPLOYEE,
|
||||
UPDATE_EMPLOYEE_RESULT
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 一般向けのページリストを返す
|
||||
*
|
||||
* @return 一般向けのページリスト
|
||||
*/
|
||||
public static Set<String> getUserPageList() {
|
||||
return Set.of(
|
||||
INDEX_BLANK,
|
||||
INDEX_SLASH,
|
||||
INDEX_LOGIN,
|
||||
LOGOUT,
|
||||
DO_LOGIN,
|
||||
PERSONAL_UPDATE_RESULT
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.example.rhizome.app.presentation.form;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Department;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 画面の表示に使う部署コード管理用のクラス
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DepartmentForm {
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
private Integer idDepartment;
|
||||
/**
|
||||
* 部署名
|
||||
*/
|
||||
private String nmDepartment;
|
||||
|
||||
/**
|
||||
* business 層の Department クラスから画面用(presentation 層)の DepartmentForm に
|
||||
* 変換します。
|
||||
*
|
||||
* @param department business 層の Department インスタンス
|
||||
* @return 画面用(presentation 層)の DepartmentForm インスタンス
|
||||
*/
|
||||
public static DepartmentForm convertFrom(Department department) {
|
||||
return new DepartmentForm(department.getIdDepartment(), department.getNmDepartment());
|
||||
}
|
||||
|
||||
/**
|
||||
* business 層の Department クラスから画面用(presentation 層)の DepartmentForm に
|
||||
* 変換します。(リスト版)
|
||||
*
|
||||
* @param departmentList business 層の Department インスタンスのリスト
|
||||
* @return 画面用(presentation 層)の DepartmentForm インスタンスのリスト
|
||||
*/
|
||||
public static List<DepartmentForm> convertFrom(List<Department> departmentList) {
|
||||
return departmentList.stream().map(DepartmentForm::convertFrom).toList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.example.rhizome.app.presentation.form;
|
||||
|
||||
|
||||
import com.example.rhizome.app.domain.model.EmployeeInfo;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 画面に表示するために employee と department を Join した構造を扱うクラス
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class EmployeeInfoForm {
|
||||
|
||||
/**
|
||||
* 社員ID
|
||||
*/
|
||||
private Integer idEmployee;
|
||||
/**
|
||||
* 社員名
|
||||
*/
|
||||
private String nmEmployee;
|
||||
/**
|
||||
* 社員名カナ
|
||||
*/
|
||||
private String knEmployee;
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
private String mailAddress;
|
||||
/**
|
||||
* パスワード
|
||||
*/
|
||||
private String password;
|
||||
/**
|
||||
* パスワード
|
||||
*/
|
||||
private Integer adminAuth;
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
private Integer idDepartment;
|
||||
/**
|
||||
* 部署名
|
||||
*/
|
||||
private String nmDepartment;
|
||||
|
||||
/**
|
||||
* business 層の EmployeeInfo クラスから画面用(presentation 層)の EmployeeInfoForm に
|
||||
* 変換します。
|
||||
*
|
||||
* @param employeeInfo business 層の EmployeeInfo インスタンス
|
||||
* @return クラスから画面用(presentation 層)の EmployeeInfoForm インスタンス
|
||||
*/
|
||||
public static EmployeeInfoForm convertFrom(EmployeeInfo employeeInfo) {
|
||||
return new EmployeeInfoForm(
|
||||
employeeInfo.getEmployee().getIdEmployee(),
|
||||
employeeInfo.getEmployee().getNmEmployee(),
|
||||
employeeInfo.getEmployee().getKnEmployee(),
|
||||
employeeInfo.getEmployee().getMailAddress(),
|
||||
employeeInfo.getEmployee().getPassword(),
|
||||
employeeInfo.getEmployee().getAdminAuth(),
|
||||
employeeInfo.getDepartment().getIdDepartment(),
|
||||
employeeInfo.getDepartment().getNmDepartment()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* business 層の EmployeeInfo クラスから画面用(presentation 層)の EmployeeInfoForm に
|
||||
* 変換します。(リスト版)
|
||||
*
|
||||
* @param employeeInfoList business 層の EmployeeInfo インスタンスのリスト
|
||||
* @return クラスから画面用(presentation 層)の EmployeeInfoForm インスタンスのリスト
|
||||
*/
|
||||
public static List<EmployeeInfoForm> convertFrom(List<EmployeeInfo> employeeInfoList) {
|
||||
return employeeInfoList.stream().map(EmployeeInfoForm::convertFrom).toList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
package com.example.rhizome.app.presentation.form;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Employee;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 画面から渡ってきた登録内容をまとめ、再度画面に表示する為のクラス
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class InsertEmployeeForm {
|
||||
|
||||
/**
|
||||
* 社員名
|
||||
*/
|
||||
private String nmEmployee;
|
||||
|
||||
/**
|
||||
* 社員名カナ
|
||||
*/
|
||||
private String knEmployee;
|
||||
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
private String mailAddress;
|
||||
|
||||
/**
|
||||
* パスワード
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 確認用パスワード
|
||||
*/
|
||||
private String passwordConfirm;
|
||||
|
||||
/**
|
||||
* 管理者権限
|
||||
*/
|
||||
private Integer adminAuth;
|
||||
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
private Integer idDepartment;
|
||||
|
||||
/**
|
||||
* パスワードのValidation
|
||||
* チェック対象にエラーが有った場合エラーリストに文言を追加する
|
||||
*
|
||||
* @param password 登録対象のパスワード
|
||||
* @param passwordConfirm 登録対象のパスワード再入力
|
||||
* @param error エラーリスト
|
||||
*/
|
||||
private static void checkPassword(String password, String passwordConfirm, List<String> error) {
|
||||
final String PASSWORD_NULL_BLANK = "パスワード が未入力です。";
|
||||
final String PASSWORD_CONFIRM_NULL_BLANK = "パスワード確認用 が未入力です。";
|
||||
final String PASSWORD_MISMATCH = "パスワード と パスワード確認用 が一致しません。";
|
||||
|
||||
if (isNullOrBlank(password)) {
|
||||
error.add(PASSWORD_NULL_BLANK);
|
||||
return;
|
||||
}
|
||||
if (isNullOrBlank(passwordConfirm)) {
|
||||
error.add(PASSWORD_CONFIRM_NULL_BLANK);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!password.equals(passwordConfirm)) {
|
||||
error.add(PASSWORD_MISMATCH);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 仮引数を null or 空 判定する
|
||||
*
|
||||
* @param str 判定対象の文字列
|
||||
* @return true:null or 空 false:null or 空 では無い
|
||||
*/
|
||||
private static boolean isNullOrBlank(String str) {
|
||||
if (null == str) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return str.isBlank();
|
||||
}
|
||||
|
||||
/**
|
||||
* 画面から渡ってきた登録内容をまとめ、ビジネスモデルに変換
|
||||
*
|
||||
* @param insertEmployeeForm 画面から渡ってきた登録内容
|
||||
* @return ビジネスモデルのインスタンス
|
||||
*/
|
||||
public static Employee convertTo(InsertEmployeeForm insertEmployeeForm) {
|
||||
return new Employee(
|
||||
null,
|
||||
insertEmployeeForm.getNmEmployee(),
|
||||
insertEmployeeForm.getKnEmployee(),
|
||||
insertEmployeeForm.getMailAddress(),
|
||||
insertEmployeeForm.getPassword(),
|
||||
insertEmployeeForm.getAdminAuth(),
|
||||
insertEmployeeForm.getIdDepartment()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 登録データのValidationを行う
|
||||
*
|
||||
* @return エラーが有った場合はエラー文言、無ければ空のリストが返る
|
||||
*/
|
||||
public List<String> validateParameter() {
|
||||
final String EMPLOYEE_NAME_NULL_BLANK = "社員名";
|
||||
final String EMPLOYEE_KANA_NULL_BLANK = "社員名フリガナ";
|
||||
final String MAIL_ADDRESS_NULL_BLANK = "メールアドレス";
|
||||
final String MANAGEMENT_ERROR = "管理者権限指定";
|
||||
final String DEPARTMENT_ID_NULL_BLANK = "所属部署";
|
||||
|
||||
List<String> error = new ArrayList<>();
|
||||
|
||||
if (isNullOrBlank(nmEmployee)) {
|
||||
error.add(EMPLOYEE_NAME_NULL_BLANK);
|
||||
}
|
||||
if (isNullOrBlank(knEmployee)) {
|
||||
error.add(EMPLOYEE_KANA_NULL_BLANK);
|
||||
}
|
||||
if (isNullOrBlank(mailAddress)) {
|
||||
error.add(MAIL_ADDRESS_NULL_BLANK);
|
||||
}
|
||||
|
||||
// パスワードが仕様を満たしているか確認
|
||||
checkPassword(password, passwordConfirm, error);
|
||||
|
||||
if (adminAuth == null) {
|
||||
error.add(MANAGEMENT_ERROR);
|
||||
}
|
||||
|
||||
if (idDepartment == null) {
|
||||
error.add(DEPARTMENT_ID_NULL_BLANK);
|
||||
}
|
||||
|
||||
return error;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.example.rhizome.app.presentation.form;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* ログインを試みる人を表現するモデルクラスです
|
||||
*/
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class LoginInfoForm {
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
private String mailAddress;
|
||||
/**
|
||||
* パスワード
|
||||
*/
|
||||
private String password;
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.example.rhizome.app.presentation.form;
|
||||
|
||||
|
||||
import com.example.rhizome.app.domain.model.LoginUser;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class LoginUserForm {
|
||||
/**
|
||||
* 社員ID
|
||||
*/
|
||||
private Integer idEmployee;
|
||||
/**
|
||||
* 社員名
|
||||
*/
|
||||
private String nmEmployee;
|
||||
/**
|
||||
* 社員名カナ
|
||||
*/
|
||||
private String knEmployee;
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
private String mailAddress;
|
||||
/**
|
||||
* パスワード
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 管理者権限
|
||||
*/
|
||||
private Integer adminAuth;
|
||||
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
private Integer idDepartment;
|
||||
|
||||
/**
|
||||
* business 層の LoginUser クラスから画面用(presentation 層)の LoginUserForm に
|
||||
* 変換します。
|
||||
*
|
||||
* @param loginUser business 層の LoginUser インスタンス
|
||||
* @return クラスから画面用(presentation 層)の LoginUserForm
|
||||
*/
|
||||
public static LoginUserForm convertFrom(LoginUser loginUser) {
|
||||
return new LoginUserForm(
|
||||
loginUser.getIdEmployee(),
|
||||
loginUser.getNmEmployee(),
|
||||
loginUser.getKnEmployee(),
|
||||
loginUser.getMailAddress(),
|
||||
loginUser.getPassword(),
|
||||
loginUser.getAdminAuth(),
|
||||
loginUser.getIdDepartment()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 画面用(presentation 層)の LoginUserForm クラスから business 層の LoginUser クラスに
|
||||
* 変換します。
|
||||
*
|
||||
* @param loginUserForm 画面用(presentation 層)の LoginUserForm インスタンス
|
||||
* @return business 層の LoginUser インスタンス
|
||||
*/
|
||||
public static LoginUser convertTo(LoginUserForm loginUserForm) {
|
||||
return new LoginUser(
|
||||
loginUserForm.getIdEmployee(),
|
||||
loginUserForm.getNmEmployee(),
|
||||
loginUserForm.getKnEmployee(),
|
||||
loginUserForm.getMailAddress(),
|
||||
loginUserForm.getPassword(),
|
||||
loginUserForm.getAdminAuth(),
|
||||
loginUserForm.getIdDepartment()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 画面から渡ってきた必須の値が仕様を満たしているか確認
|
||||
*
|
||||
* @param loginInfoForm 画面から渡ってきた mailAddress, password を格納しているインスタンス
|
||||
* @return true:仕様を満たしている , false:仕様を満たしていない
|
||||
*/
|
||||
public static boolean checkParameter(LoginInfoForm loginInfoForm) {
|
||||
if (null == loginInfoForm.getMailAddress()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (loginInfoForm.getMailAddress().isBlank()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (null == loginInfoForm.getPassword()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !loginInfoForm.getPassword().isBlank();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理者権限を持っているか確認
|
||||
*
|
||||
* @return true:管理者権限を持っている , false:管理者権限を持っていない
|
||||
*/
|
||||
public boolean isAdminUser() {
|
||||
return getAdminAuth() == 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.example.rhizome.app.presentation.form;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 画面に表示するエラーメッセージを管理するクラスです。
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class MessageForm {
|
||||
private String message;
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.example.rhizome.app.presentation.form;
|
||||
|
||||
import com.example.rhizome.app.domain.model.SearchConditionEmployee;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 画面から渡ってきた検索条件をまとめ、再度画面に表示する為のクラス
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class SearchConditionEmployeeForm {
|
||||
|
||||
/**
|
||||
* 社員ID
|
||||
*/
|
||||
private Integer idEmployee;
|
||||
/**
|
||||
* 社員名
|
||||
*/
|
||||
private String nmEmployee;
|
||||
/**
|
||||
* 社員名カナ
|
||||
*/
|
||||
private String knEmployee;
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
private String mailAddress;
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
private Integer idDepartment;
|
||||
|
||||
/**
|
||||
* business 層の SearchConditionEmployee クラスから画面用(presentation 層)の SearchConditionEmployeeForm に
|
||||
* 変換します。
|
||||
*
|
||||
* @param searchConditionEmployee business 層の SearchConditionEmployee インスタンス
|
||||
* @return 画面用(presentation 層)の SearchConditionEmployeeForm インスタンス
|
||||
*/
|
||||
public static SearchConditionEmployeeForm convertFrom(SearchConditionEmployee searchConditionEmployee) {
|
||||
return new SearchConditionEmployeeForm(
|
||||
searchConditionEmployee.getIdEmployee(),
|
||||
searchConditionEmployee.getNmEmployee(),
|
||||
searchConditionEmployee.getKnEmployee(),
|
||||
searchConditionEmployee.getMailAddress(),
|
||||
searchConditionEmployee.getIdDepartment()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 画面用(presentation 層)の SearchConditionEmployeeForm クラスから business 層の SearchConditionEmployee クラスに
|
||||
* 変換します。
|
||||
*
|
||||
* @param searchConditionEmployeeForm 画面用(presentation 層)の SearchConditionEmployeeForm インスタンス
|
||||
* @return business 層の SearchConditionEmployee インスタンス
|
||||
*/
|
||||
public static SearchConditionEmployee convertTo(SearchConditionEmployeeForm searchConditionEmployeeForm) {
|
||||
return new SearchConditionEmployee(
|
||||
searchConditionEmployeeForm.getIdEmployee(),
|
||||
searchConditionEmployeeForm.getNmEmployee(),
|
||||
searchConditionEmployeeForm.getKnEmployee(),
|
||||
searchConditionEmployeeForm.getMailAddress(),
|
||||
searchConditionEmployeeForm.getIdDepartment()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
package com.example.rhizome.app.presentation.form;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Employee;
|
||||
import com.example.rhizome.app.domain.model.EmployeeInfo;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 画面から渡ってきた更新内容をまとめ、再度画面に表示する為のクラス
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class UpdateEmployeeInfoForm {
|
||||
|
||||
/**
|
||||
* 社員ID
|
||||
*/
|
||||
private Integer idEmployee;
|
||||
/**
|
||||
* 社員名
|
||||
*/
|
||||
private String nmEmployee;
|
||||
/**
|
||||
* 社員名カナ
|
||||
*/
|
||||
private String knEmployee;
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
private String mailAddress;
|
||||
/**
|
||||
* パスワード
|
||||
*/
|
||||
private String password;
|
||||
/**
|
||||
* パスワード確認用
|
||||
*/
|
||||
private String passwordConfirm;
|
||||
/**
|
||||
* 管理者権限
|
||||
*/
|
||||
private Integer adminAuth;
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
private Integer idDepartment;
|
||||
|
||||
/**
|
||||
* business 層の EmployeeInfo クラスから画面用(presentation 層)の UpdateEmployeeInfoForm に
|
||||
* 変換します。
|
||||
*
|
||||
* @param employeeInfo business 層の EmployeeInfo インスタンス
|
||||
* @return 画面用(presentation 層)の UpdateEmployeeInfoForm インスタンス
|
||||
*/
|
||||
public static UpdateEmployeeInfoForm convertFrom(EmployeeInfo employeeInfo) {
|
||||
return new UpdateEmployeeInfoForm(
|
||||
employeeInfo.getEmployee().getIdEmployee(),
|
||||
employeeInfo.getEmployee().getNmEmployee(),
|
||||
employeeInfo.getEmployee().getKnEmployee(),
|
||||
employeeInfo.getEmployee().getMailAddress(),
|
||||
employeeInfo.getEmployee().getPassword(),
|
||||
null,
|
||||
employeeInfo.getEmployee().getAdminAuth(),
|
||||
employeeInfo.getDepartment().getIdDepartment()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* business 層の EmployeeInfo クラスから画面用(presentation 層)の UpdateEmployeeInfoForm に
|
||||
* 変換します。(リスト版)
|
||||
*
|
||||
* @param employeeInfoList business 層の EmployeeInfo インスタンスのリスト
|
||||
* @return 画面用(presentation 層)の UpdateEmployeeInfoForm インスタンスのリスト
|
||||
*/
|
||||
public static List<UpdateEmployeeInfoForm> convertFrom(List<EmployeeInfo> employeeInfoList) {
|
||||
return employeeInfoList.stream().map(UpdateEmployeeInfoForm::convertFrom).toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 画面用(presentation 層)の UpdateEmployeeInfoForm クラスから business 層の Employee クラスに
|
||||
* 変換します。
|
||||
*
|
||||
* @param updateEmployeeInfoForm 画面用(presentation 層)の UpdateEmployeeInfoForm インスタンス
|
||||
* @return business 層の Employee インスタンス
|
||||
*/
|
||||
public static Employee convertTo(UpdateEmployeeInfoForm updateEmployeeInfoForm) {
|
||||
return new Employee(
|
||||
updateEmployeeInfoForm.getIdEmployee(),
|
||||
updateEmployeeInfoForm.getNmEmployee(),
|
||||
updateEmployeeInfoForm.getKnEmployee(),
|
||||
updateEmployeeInfoForm.getMailAddress(),
|
||||
updateEmployeeInfoForm.getPassword(),
|
||||
updateEmployeeInfoForm.getAdminAuth(),
|
||||
updateEmployeeInfoForm.getIdDepartment()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 画面から渡ってきたパラメータのチェック
|
||||
*
|
||||
* @param updateEmployeeInfoForm 画面から渡ってきたパラメータ
|
||||
* @return true: エラー無し false:エラーあり(必須を満たしていない)
|
||||
*/
|
||||
public static boolean hasErrorParameter(UpdateEmployeeInfoForm updateEmployeeInfoForm) {
|
||||
|
||||
boolean errorFlag = !isNullOrBlank(updateEmployeeInfoForm.getNmEmployee());
|
||||
|
||||
if (!isNullOrBlank(updateEmployeeInfoForm.getKnEmployee())) {
|
||||
errorFlag = true;
|
||||
}
|
||||
if (!isNullOrBlank(updateEmployeeInfoForm.getMailAddress())) {
|
||||
errorFlag = true;
|
||||
}
|
||||
if (!isNullOrBlank(updateEmployeeInfoForm.getPassword())) {
|
||||
errorFlag = true;
|
||||
}
|
||||
|
||||
|
||||
return errorFlag;
|
||||
}
|
||||
|
||||
/**
|
||||
* パスワードの仕様チェック
|
||||
* パスワードが仕様を満たしてないか確認
|
||||
*
|
||||
* @param password 更新対象のパスワード
|
||||
* @param passwordConfirm 更新対象の確認用パスワード
|
||||
* @return 空文字: エラー無し それ以外:エラー内容
|
||||
*/
|
||||
public static String validatePassword(String password, String passwordConfirm) {
|
||||
|
||||
final String ERROR = "パスワードが一致していません";
|
||||
|
||||
if (areBothBlank(password, passwordConfirm)) {
|
||||
// どちらもnullまたは空白の場合はOK
|
||||
return "";
|
||||
}
|
||||
|
||||
// どちらかがnullまたは空白の場合のエラーハンドリング
|
||||
if (isEitherBlank(password, passwordConfirm)) {
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
// 値が異なった場合はエラーハンドリング
|
||||
if (!password.equals(passwordConfirm)) {
|
||||
return ERROR;
|
||||
}
|
||||
return "";
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 仮引数を null or 空 判定する
|
||||
*
|
||||
* @param str 判定対象の文字列
|
||||
* @return true:null or 空 false:null or 空 では無い
|
||||
*/
|
||||
private static boolean isNullOrBlank(String str) {
|
||||
if (null == str) {
|
||||
return true;
|
||||
}
|
||||
return str.isBlank();
|
||||
}
|
||||
|
||||
/**
|
||||
* パスワードが今回更新対象に含まれているかチェック
|
||||
*
|
||||
* @param password 更新対象のパスワード
|
||||
* @param passwordConfirm 更新対象の確認用パスワード
|
||||
* @return true:どちらもnullまたは空白の場合 false:それ以外
|
||||
*/
|
||||
private static boolean areBothBlank(String password, String passwordConfirm) {
|
||||
return (password == null || password.isBlank()) && (passwordConfirm == null || passwordConfirm.isBlank());
|
||||
}
|
||||
|
||||
/**
|
||||
* パスワードが今回更新対象に含まれているかチェック その2
|
||||
*
|
||||
* @param password 更新対象のパスワード
|
||||
* @param passwordConfirm 更新対象の確認用パスワード
|
||||
* @return true: 問題なし false:どちらかがnullまたは空白の場合
|
||||
*/
|
||||
// どちらかがnullまたは空白の場合のエラーハンドリング
|
||||
private static boolean isEitherBlank(String password, String passwordConfirm) {
|
||||
return password == null || password.isBlank() || passwordConfirm == null || passwordConfirm.isBlank();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
package com.example.rhizome.app.presentation.form;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Employee;
|
||||
import com.example.rhizome.app.domain.model.LoginUser;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 個人情報更新画面のフォームクラスです。
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class UpdatePersonalUserForm {
|
||||
/**
|
||||
* 社員ID
|
||||
*/
|
||||
private Integer idEmployee;
|
||||
/**
|
||||
* 社員名
|
||||
*/
|
||||
private String nmEmployee;
|
||||
/**
|
||||
* 社員名カナ
|
||||
*/
|
||||
private String knEmployee;
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
private String mailAddress;
|
||||
/**
|
||||
* パスワード
|
||||
*/
|
||||
private String password;
|
||||
/**
|
||||
* パスワード確認用
|
||||
*/
|
||||
private String passwordConfirm;
|
||||
|
||||
|
||||
/**
|
||||
* 画面用(presentation 層)の UpdatePersonalUserForm クラスから business 層の Employee クラスに
|
||||
* 変換します。
|
||||
*
|
||||
* @param updatePersonalUserForm 画面用(presentation 層)の UpdatePersonalUserForm インスタンス
|
||||
* @return business 層の Employee インスタンス
|
||||
*/
|
||||
public static Employee convertTo(UpdatePersonalUserForm updatePersonalUserForm) {
|
||||
return new Employee(
|
||||
updatePersonalUserForm.getIdEmployee(),
|
||||
updatePersonalUserForm.getNmEmployee(),
|
||||
updatePersonalUserForm.getKnEmployee(),
|
||||
updatePersonalUserForm.getMailAddress(),
|
||||
updatePersonalUserForm.getPassword(),
|
||||
null,
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* business 層の Employee クラスから画面用(presentation 層)の UpdatePersonalUserForm に
|
||||
* 変換します。(リスト版)
|
||||
*
|
||||
* @param employee business 層の employee インスタンスのリスト
|
||||
* @return クラスから画面用(presentation 層)の UpdatePersonalUserForm インスタンスのリスト
|
||||
*/
|
||||
public static UpdatePersonalUserForm convertFrom(Employee employee) {
|
||||
return new UpdatePersonalUserForm(
|
||||
employee.getIdEmployee(),
|
||||
employee.getNmEmployee(),
|
||||
employee.getKnEmployee(),
|
||||
employee.getMailAddress(),
|
||||
employee.getPassword(),
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* business 層の Employee クラスから画面用(presentation 層)の UpdatePersonalUserForm に
|
||||
* 変換します。(リスト版)
|
||||
*
|
||||
* @param loginUser business 層の loginUser インスタンスのリスト
|
||||
* @return クラスから画面用(presentation 層)の UpdatePersonalUserForm インスタンスのリスト
|
||||
*/
|
||||
public static UpdatePersonalUserForm convertFrom(LoginUser loginUser) {
|
||||
return new UpdatePersonalUserForm(
|
||||
loginUser.getIdEmployee(),
|
||||
loginUser.getNmEmployee(),
|
||||
loginUser.getKnEmployee(),
|
||||
loginUser.getMailAddress(),
|
||||
loginUser.getPassword(),
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 画面から渡ってきたパラメータのチェック
|
||||
*
|
||||
* @param updatePersonalUserForm 画面から渡ってきたパラメータ
|
||||
* @return true: エラー無し false:エラーあり(必須を満たしていない)
|
||||
*/
|
||||
public static boolean hasErrorParameter(UpdatePersonalUserForm updatePersonalUserForm) {
|
||||
|
||||
boolean errorFlag = !isNullOrBlank(updatePersonalUserForm.getNmEmployee());
|
||||
|
||||
if (!isNullOrBlank(updatePersonalUserForm.getKnEmployee())) {
|
||||
errorFlag = true;
|
||||
}
|
||||
if (!isNullOrBlank(updatePersonalUserForm.getMailAddress())) {
|
||||
errorFlag = true;
|
||||
}
|
||||
if (!isNullOrBlank(updatePersonalUserForm.getPassword())) {
|
||||
errorFlag = true;
|
||||
}
|
||||
|
||||
|
||||
return errorFlag;
|
||||
}
|
||||
|
||||
/**
|
||||
* パスワードの仕様チェック
|
||||
* パスワードが仕様を満たしてないか確認
|
||||
*
|
||||
* @param password 更新対象のパスワード
|
||||
* @param passwordConfirm 更新対象の確認用パスワード
|
||||
* @return 空文字: エラー無し それ以外:エラー内容
|
||||
*/
|
||||
public static String validatePassword(String password, String passwordConfirm) {
|
||||
|
||||
final String ERROR = "パスワードが一致していません";
|
||||
|
||||
if (areBothBlank(password, passwordConfirm)) {
|
||||
// どちらもnullまたは空白の場合はOK
|
||||
return "";
|
||||
}
|
||||
|
||||
// どちらかがnullまたは空白の場合のエラーハンドリング
|
||||
if (isEitherBlank(password, passwordConfirm)) {
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
// 値が異なった場合はエラーハンドリング
|
||||
if (!password.equals(passwordConfirm)) {
|
||||
return ERROR;
|
||||
}
|
||||
return "";
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 仮引数を null or 空 判定する
|
||||
*
|
||||
* @param str 判定対象の文字列
|
||||
* @return true:null or 空 false:null or 空 では無い
|
||||
*/
|
||||
private static boolean isNullOrBlank(String str) {
|
||||
if (null == str) {
|
||||
return true;
|
||||
}
|
||||
return str.isBlank();
|
||||
}
|
||||
|
||||
/**
|
||||
* パスワードが今回更新対象に含まれているかチェック
|
||||
*
|
||||
* @param password 更新対象のパスワード
|
||||
* @param passwordConfirm 更新対象の確認用パスワード
|
||||
* @return true:どちらもnullまたは空白の場合 false:それ以外
|
||||
*/
|
||||
private static boolean areBothBlank(String password, String passwordConfirm) {
|
||||
return (password == null || password.isBlank()) && (passwordConfirm == null || passwordConfirm.isBlank());
|
||||
}
|
||||
|
||||
/**
|
||||
* パスワードが今回更新対象に含まれているかチェック その2
|
||||
*
|
||||
* @param password 更新対象のパスワード
|
||||
* @param passwordConfirm 更新対象の確認用パスワード
|
||||
* @return true: 問題なし false:どちらかがnullまたは空白の場合
|
||||
*/
|
||||
private static boolean isEitherBlank(String password, String passwordConfirm) {
|
||||
return password == null || password.isBlank() || passwordConfirm == null || passwordConfirm.isBlank();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.example.rhizome.exception;
|
||||
|
||||
/**
|
||||
* 権限不足の例外を表現するクラスです。
|
||||
*/
|
||||
public class InsufficientPermissionException extends RuntimeException {
|
||||
|
||||
public InsufficientPermissionException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.example.rhizome.exception;
|
||||
|
||||
/**
|
||||
* 権限不足の例外を表現するクラスです。
|
||||
*/
|
||||
public class NoSessionException extends RuntimeException {
|
||||
|
||||
public NoSessionException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
3
src/main/resources/application.properties
Normal file
3
src/main/resources/application.properties
Normal file
@@ -0,0 +1,3 @@
|
||||
spring.datasource.url=jdbc:mysql://localhost:3306/rezodb
|
||||
spring.datasource.username=rezouser
|
||||
spring.datasource.password=Rezo_0000
|
||||
10563
src/main/resources/static/css/all.css
Normal file
10563
src/main/resources/static/css/all.css
Normal file
File diff suppressed because it is too large
Load Diff
2046
src/main/resources/static/css/brands.css
Normal file
2046
src/main/resources/static/css/brands.css
Normal file
File diff suppressed because it is too large
Load Diff
8438
src/main/resources/static/css/fontawesome.css
vendored
Normal file
8438
src/main/resources/static/css/fontawesome.css
vendored
Normal file
File diff suppressed because it is too large
Load Diff
22
src/main/resources/static/css/regular.css
Normal file
22
src/main/resources/static/css/regular.css
Normal file
@@ -0,0 +1,22 @@
|
||||
/*!
|
||||
* Font Awesome Free 6.4.2 by @fontawesome - https://fontawesome.com
|
||||
* License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
|
||||
* Copyright 2023 Fonticons, Inc.
|
||||
*/
|
||||
:root, :host {
|
||||
--fa-style-family-classic: 'Font Awesome 6 Free';
|
||||
--fa-font-regular: normal 400 1em/1 'Font Awesome 6 Free';
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Font Awesome 6 Free';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
font-display: block;
|
||||
src: url("../webfonts/fa-regular-400.woff2") format("woff2"), url("../webfonts/fa-regular-400.ttf") format("truetype");
|
||||
}
|
||||
|
||||
.far,
|
||||
.fa-regular {
|
||||
font-weight: 400;
|
||||
}
|
||||
22
src/main/resources/static/css/solid.css
Normal file
22
src/main/resources/static/css/solid.css
Normal file
@@ -0,0 +1,22 @@
|
||||
/*!
|
||||
* Font Awesome Free 6.4.2 by @fontawesome - https://fontawesome.com
|
||||
* License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
|
||||
* Copyright 2023 Fonticons, Inc.
|
||||
*/
|
||||
:root, :host {
|
||||
--fa-style-family-classic: 'Font Awesome 6 Free';
|
||||
--fa-font-solid: normal 900 1em/1 'Font Awesome 6 Free';
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Font Awesome 6 Free';
|
||||
font-style: normal;
|
||||
font-weight: 900;
|
||||
font-display: block;
|
||||
src: url("../webfonts/fa-solid-900.woff2") format("woff2"), url("../webfonts/fa-solid-900.ttf") format("truetype");
|
||||
}
|
||||
|
||||
.fas,
|
||||
.fa-solid {
|
||||
font-weight: 900;
|
||||
}
|
||||
171
src/main/resources/static/css/style.css
Normal file
171
src/main/resources/static/css/style.css
Normal file
@@ -0,0 +1,171 @@
|
||||
@CHARSET "UTF-8";
|
||||
|
||||
/* グローバル */
|
||||
* {
|
||||
color: #505050;
|
||||
}
|
||||
|
||||
h1 {
|
||||
border-left: 10px solid #696969;
|
||||
border-bottom: 1px solid #696969;
|
||||
padding: 10px;
|
||||
width: 50%;
|
||||
max-width: 960px;
|
||||
min-width: 640px;
|
||||
font-size: 15pt;
|
||||
font-weight: bold;
|
||||
display: flex; /* フレックスボックスを使う */
|
||||
justify-content: space-between; /* 左右の要素を端に寄せる */
|
||||
align-items: center; /* 上下中央に配置 */
|
||||
}
|
||||
|
||||
.rightSection {
|
||||
display: flex; /* フレックスボックスを使う */
|
||||
align-items: center; /* 上下中央に配置 */
|
||||
}
|
||||
|
||||
|
||||
/* 入力フォーム */
|
||||
|
||||
input, button, select {
|
||||
padding: 5px 15px 5px 15px;
|
||||
margin: 3px;
|
||||
/* border-radius: 5px; /* CSS3草案 */
|
||||
/* -webkit-border-radius: 5px; /* Safari,Google Chrome用 */
|
||||
/* -moz-border-radius: 5px; /* Firefox用 */
|
||||
}
|
||||
|
||||
input.readOnly {
|
||||
background-color: #696969;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
/* メッセージボックスデザイン */
|
||||
|
||||
.msgBox {
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
border: 1px solid #696969;
|
||||
width: 500px;
|
||||
}
|
||||
|
||||
.error {
|
||||
background-color: #ffb6c1;
|
||||
color: #ff0000;
|
||||
}
|
||||
|
||||
.warning {
|
||||
background-color: #ff8c00;
|
||||
color: #ff0000;
|
||||
}
|
||||
|
||||
.info {
|
||||
background-color: #b0c4de;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
/* 個別デザイン */
|
||||
|
||||
th.header {
|
||||
width: 150px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.loginInfo {
|
||||
font-size: 9pt;
|
||||
color: #008080;
|
||||
margin-right: 10px; /* ログアウトボタンとの間隔 */
|
||||
}
|
||||
|
||||
.logoutButton {
|
||||
font-size: 9pt;
|
||||
background-color: #008080;
|
||||
color: #ffffff;
|
||||
border: none;
|
||||
padding: 5px 10px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
td.btnArea {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.header-spacing {
|
||||
margin-top: 20px; /* 上部に20ピクセルのマージン */
|
||||
}
|
||||
|
||||
/* グリッドラインの追加 */
|
||||
.table-grid {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
.table-grid th, .table-grid td {
|
||||
border: 1px solid #ccc;
|
||||
padding: 8px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.table-grid th, .half-table-grid th {
|
||||
background-color: #f2f2f2;
|
||||
}
|
||||
|
||||
/* ストライプ効果(奇数行と偶数行で色を交互に) */
|
||||
.table-striped tbody tr:nth-child(odd) {
|
||||
background-color: #f2f2f2;
|
||||
}
|
||||
|
||||
/* ホバー効果(マウスオーバー時に行の色を変更) */
|
||||
.table-hover tbody tr:hover {
|
||||
background-color: #ccffcc; /* パステルグリーンの背景色 */
|
||||
}
|
||||
|
||||
/* レスポンシブデザイン(小さい画面でスクロール) */
|
||||
.table-responsive {
|
||||
overflow-x: auto;
|
||||
display: block;
|
||||
}
|
||||
|
||||
a.menuClass {
|
||||
color: #008080; /* ターコイズ色 */
|
||||
text-decoration: none; /* 下線をなくす */
|
||||
padding: 10px 20px; /* パディングを追加 */
|
||||
border: 1px solid #008080; /* 枠線を追加 */
|
||||
border-radius: 5px; /* 角を丸くする */
|
||||
display: inline-block; /* ブロック要素として表示 */
|
||||
transition: 0.3s; /* アニメーション効果 */
|
||||
}
|
||||
|
||||
a.menuClass:hover {
|
||||
background-color: #008080; /* マウスオーバー時の背景色 */
|
||||
color: #ffffff; /* マウスオーバー時の文字色 */
|
||||
}
|
||||
|
||||
table.menuClass td {
|
||||
padding: 20px; /* パディングを増やす */
|
||||
text-align: center; /* 中央寄せ */
|
||||
vertical-align: middle; /* 上下中央寄せ */
|
||||
}
|
||||
|
||||
table.menuClass td.description {
|
||||
text-align: left; /* 左寄せ */
|
||||
font-size: 14px; /* フォントサイズを少し大きく */
|
||||
color: #707070; /* 色を少し薄く */
|
||||
line-height: 1.5; /* 行間を調整 */
|
||||
}
|
||||
|
||||
input[type="submit"], input[type="reset"], button {
|
||||
color: #008080; /* ターコイズ色 */
|
||||
text-decoration: none; /* 下線をなくす */
|
||||
padding: 10px 20px; /* パディングを追加 */
|
||||
border: 1px solid #008080; /* 枠線を追加 */
|
||||
border-radius: 5px; /* 角を丸くする */
|
||||
background-color: transparent; /* 背景色を透明に */
|
||||
cursor: pointer; /* カーソルをポインターに */
|
||||
transition: 0.3s; /* アニメーション効果 */
|
||||
}
|
||||
|
||||
input[type="submit"]:hover, input[type="reset"]:hover, button:hover {
|
||||
background-color: #008080; /* マウスオーバー時の背景色 */
|
||||
color: #ffffff; /* マウスオーバー時の文字色 */
|
||||
}
|
||||
790
src/main/resources/static/css/svg-with-js.css
Normal file
790
src/main/resources/static/css/svg-with-js.css
Normal file
@@ -0,0 +1,790 @@
|
||||
/*!
|
||||
* Font Awesome Free 6.4.2 by @fontawesome - https://fontawesome.com
|
||||
* License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
|
||||
* Copyright 2023 Fonticons, Inc.
|
||||
*/
|
||||
:root, :host {
|
||||
--fa-font-solid: normal 900 1em/1 'Font Awesome 6 Solid';
|
||||
--fa-font-regular: normal 400 1em/1 'Font Awesome 6 Regular';
|
||||
--fa-font-light: normal 300 1em/1 'Font Awesome 6 Light';
|
||||
--fa-font-thin: normal 100 1em/1 'Font Awesome 6 Thin';
|
||||
--fa-font-duotone: normal 900 1em/1 'Font Awesome 6 Duotone';
|
||||
--fa-font-sharp-solid: normal 900 1em/1 'Font Awesome 6 Sharp';
|
||||
--fa-font-sharp-regular: normal 400 1em/1 'Font Awesome 6 Sharp';
|
||||
--fa-font-sharp-light: normal 300 1em/1 'Font Awesome 6 Sharp';
|
||||
--fa-font-brands: normal 400 1em/1 'Font Awesome 6 Brands';
|
||||
}
|
||||
|
||||
svg:not(:root).svg-inline--fa, svg:not(:host).svg-inline--fa {
|
||||
overflow: visible;
|
||||
box-sizing: content-box;
|
||||
}
|
||||
|
||||
.svg-inline--fa {
|
||||
display: var(--fa-display, inline-block);
|
||||
height: 1em;
|
||||
overflow: visible;
|
||||
vertical-align: -.125em;
|
||||
}
|
||||
|
||||
.svg-inline--fa.fa-2xs {
|
||||
vertical-align: 0.1em;
|
||||
}
|
||||
|
||||
.svg-inline--fa.fa-xs {
|
||||
vertical-align: 0em;
|
||||
}
|
||||
|
||||
.svg-inline--fa.fa-sm {
|
||||
vertical-align: -0.07143em;
|
||||
}
|
||||
|
||||
.svg-inline--fa.fa-lg {
|
||||
vertical-align: -0.2em;
|
||||
}
|
||||
|
||||
.svg-inline--fa.fa-xl {
|
||||
vertical-align: -0.25em;
|
||||
}
|
||||
|
||||
.svg-inline--fa.fa-2xl {
|
||||
vertical-align: -0.3125em;
|
||||
}
|
||||
|
||||
.svg-inline--fa.fa-pull-left {
|
||||
margin-right: var(--fa-pull-margin, 0.3em);
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.svg-inline--fa.fa-pull-right {
|
||||
margin-left: var(--fa-pull-margin, 0.3em);
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.svg-inline--fa.fa-li {
|
||||
width: var(--fa-li-width, 2em);
|
||||
top: 0.25em;
|
||||
}
|
||||
|
||||
.svg-inline--fa.fa-fw {
|
||||
width: var(--fa-fw-width, 1.25em);
|
||||
}
|
||||
|
||||
.fa-layers svg.svg-inline--fa {
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
margin: auto;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.fa-layers-text, .fa-layers-counter {
|
||||
display: inline-block;
|
||||
position: absolute;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.fa-layers {
|
||||
display: inline-block;
|
||||
height: 1em;
|
||||
position: relative;
|
||||
text-align: center;
|
||||
vertical-align: -.125em;
|
||||
width: 1em;
|
||||
}
|
||||
|
||||
.fa-layers svg.svg-inline--fa {
|
||||
-webkit-transform-origin: center center;
|
||||
transform-origin: center center;
|
||||
}
|
||||
|
||||
.fa-layers-text {
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
-webkit-transform: translate(-50%, -50%);
|
||||
transform: translate(-50%, -50%);
|
||||
-webkit-transform-origin: center center;
|
||||
transform-origin: center center;
|
||||
}
|
||||
|
||||
.fa-layers-counter {
|
||||
background-color: var(--fa-counter-background-color, #ff253a);
|
||||
border-radius: var(--fa-counter-border-radius, 1em);
|
||||
box-sizing: border-box;
|
||||
color: var(--fa-inverse, #fff);
|
||||
line-height: var(--fa-counter-line-height, 1);
|
||||
max-width: var(--fa-counter-max-width, 5em);
|
||||
min-width: var(--fa-counter-min-width, 1.5em);
|
||||
overflow: hidden;
|
||||
padding: var(--fa-counter-padding, 0.25em 0.5em);
|
||||
right: var(--fa-right, 0);
|
||||
text-overflow: ellipsis;
|
||||
top: var(--fa-top, 0);
|
||||
-webkit-transform: scale(var(--fa-counter-scale, 0.25));
|
||||
transform: scale(var(--fa-counter-scale, 0.25));
|
||||
-webkit-transform-origin: top right;
|
||||
transform-origin: top right;
|
||||
}
|
||||
|
||||
.fa-layers-bottom-right {
|
||||
bottom: var(--fa-bottom, 0);
|
||||
right: var(--fa-right, 0);
|
||||
top: auto;
|
||||
-webkit-transform: scale(var(--fa-layers-scale, 0.25));
|
||||
transform: scale(var(--fa-layers-scale, 0.25));
|
||||
-webkit-transform-origin: bottom right;
|
||||
transform-origin: bottom right;
|
||||
}
|
||||
|
||||
.fa-layers-bottom-left {
|
||||
bottom: var(--fa-bottom, 0);
|
||||
left: var(--fa-left, 0);
|
||||
right: auto;
|
||||
top: auto;
|
||||
-webkit-transform: scale(var(--fa-layers-scale, 0.25));
|
||||
transform: scale(var(--fa-layers-scale, 0.25));
|
||||
-webkit-transform-origin: bottom left;
|
||||
transform-origin: bottom left;
|
||||
}
|
||||
|
||||
.fa-layers-top-right {
|
||||
top: var(--fa-top, 0);
|
||||
right: var(--fa-right, 0);
|
||||
-webkit-transform: scale(var(--fa-layers-scale, 0.25));
|
||||
transform: scale(var(--fa-layers-scale, 0.25));
|
||||
-webkit-transform-origin: top right;
|
||||
transform-origin: top right;
|
||||
}
|
||||
|
||||
.fa-layers-top-left {
|
||||
left: var(--fa-left, 0);
|
||||
right: auto;
|
||||
top: var(--fa-top, 0);
|
||||
-webkit-transform: scale(var(--fa-layers-scale, 0.25));
|
||||
transform: scale(var(--fa-layers-scale, 0.25));
|
||||
-webkit-transform-origin: top left;
|
||||
transform-origin: top left;
|
||||
}
|
||||
|
||||
.fa-1x {
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
.fa-2x {
|
||||
font-size: 2em;
|
||||
}
|
||||
|
||||
.fa-3x {
|
||||
font-size: 3em;
|
||||
}
|
||||
|
||||
.fa-4x {
|
||||
font-size: 4em;
|
||||
}
|
||||
|
||||
.fa-5x {
|
||||
font-size: 5em;
|
||||
}
|
||||
|
||||
.fa-6x {
|
||||
font-size: 6em;
|
||||
}
|
||||
|
||||
.fa-7x {
|
||||
font-size: 7em;
|
||||
}
|
||||
|
||||
.fa-8x {
|
||||
font-size: 8em;
|
||||
}
|
||||
|
||||
.fa-9x {
|
||||
font-size: 9em;
|
||||
}
|
||||
|
||||
.fa-10x {
|
||||
font-size: 10em;
|
||||
}
|
||||
|
||||
.fa-2xs {
|
||||
font-size: 0.625em;
|
||||
line-height: 0.1em;
|
||||
vertical-align: 0.225em;
|
||||
}
|
||||
|
||||
.fa-xs {
|
||||
font-size: 0.75em;
|
||||
line-height: 0.08333em;
|
||||
vertical-align: 0.125em;
|
||||
}
|
||||
|
||||
.fa-sm {
|
||||
font-size: 0.875em;
|
||||
line-height: 0.07143em;
|
||||
vertical-align: 0.05357em;
|
||||
}
|
||||
|
||||
.fa-lg {
|
||||
font-size: 1.25em;
|
||||
line-height: 0.05em;
|
||||
vertical-align: -0.075em;
|
||||
}
|
||||
|
||||
.fa-xl {
|
||||
font-size: 1.5em;
|
||||
line-height: 0.04167em;
|
||||
vertical-align: -0.125em;
|
||||
}
|
||||
|
||||
.fa-2xl {
|
||||
font-size: 2em;
|
||||
line-height: 0.03125em;
|
||||
vertical-align: -0.1875em;
|
||||
}
|
||||
|
||||
.fa-fw {
|
||||
text-align: center;
|
||||
width: 1.25em;
|
||||
}
|
||||
|
||||
.fa-ul {
|
||||
list-style-type: none;
|
||||
margin-left: var(--fa-li-margin, 2.5em);
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.fa-ul > li {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.fa-li {
|
||||
left: calc(var(--fa-li-width, 2em) * -1);
|
||||
position: absolute;
|
||||
text-align: center;
|
||||
width: var(--fa-li-width, 2em);
|
||||
line-height: inherit;
|
||||
}
|
||||
|
||||
.fa-border {
|
||||
border-color: var(--fa-border-color, #eee);
|
||||
border-radius: var(--fa-border-radius, 0.1em);
|
||||
border-style: var(--fa-border-style, solid);
|
||||
border-width: var(--fa-border-width, 0.08em);
|
||||
padding: var(--fa-border-padding, 0.2em 0.25em 0.15em);
|
||||
}
|
||||
|
||||
.fa-pull-left {
|
||||
float: left;
|
||||
margin-right: var(--fa-pull-margin, 0.3em);
|
||||
}
|
||||
|
||||
.fa-pull-right {
|
||||
float: right;
|
||||
margin-left: var(--fa-pull-margin, 0.3em);
|
||||
}
|
||||
|
||||
.fa-beat {
|
||||
-webkit-animation-name: fa-beat;
|
||||
animation-name: fa-beat;
|
||||
-webkit-animation-delay: var(--fa-animation-delay, 0s);
|
||||
animation-delay: var(--fa-animation-delay, 0s);
|
||||
-webkit-animation-direction: var(--fa-animation-direction, normal);
|
||||
animation-direction: var(--fa-animation-direction, normal);
|
||||
-webkit-animation-duration: var(--fa-animation-duration, 1s);
|
||||
animation-duration: var(--fa-animation-duration, 1s);
|
||||
-webkit-animation-iteration-count: var(--fa-animation-iteration-count, infinite);
|
||||
animation-iteration-count: var(--fa-animation-iteration-count, infinite);
|
||||
-webkit-animation-timing-function: var(--fa-animation-timing, ease-in-out);
|
||||
animation-timing-function: var(--fa-animation-timing, ease-in-out);
|
||||
}
|
||||
|
||||
.fa-bounce {
|
||||
-webkit-animation-name: fa-bounce;
|
||||
animation-name: fa-bounce;
|
||||
-webkit-animation-delay: var(--fa-animation-delay, 0s);
|
||||
animation-delay: var(--fa-animation-delay, 0s);
|
||||
-webkit-animation-direction: var(--fa-animation-direction, normal);
|
||||
animation-direction: var(--fa-animation-direction, normal);
|
||||
-webkit-animation-duration: var(--fa-animation-duration, 1s);
|
||||
animation-duration: var(--fa-animation-duration, 1s);
|
||||
-webkit-animation-iteration-count: var(--fa-animation-iteration-count, infinite);
|
||||
animation-iteration-count: var(--fa-animation-iteration-count, infinite);
|
||||
-webkit-animation-timing-function: var(--fa-animation-timing, cubic-bezier(0.28, 0.84, 0.42, 1));
|
||||
animation-timing-function: var(--fa-animation-timing, cubic-bezier(0.28, 0.84, 0.42, 1));
|
||||
}
|
||||
|
||||
.fa-fade {
|
||||
-webkit-animation-name: fa-fade;
|
||||
animation-name: fa-fade;
|
||||
-webkit-animation-delay: var(--fa-animation-delay, 0s);
|
||||
animation-delay: var(--fa-animation-delay, 0s);
|
||||
-webkit-animation-direction: var(--fa-animation-direction, normal);
|
||||
animation-direction: var(--fa-animation-direction, normal);
|
||||
-webkit-animation-duration: var(--fa-animation-duration, 1s);
|
||||
animation-duration: var(--fa-animation-duration, 1s);
|
||||
-webkit-animation-iteration-count: var(--fa-animation-iteration-count, infinite);
|
||||
animation-iteration-count: var(--fa-animation-iteration-count, infinite);
|
||||
-webkit-animation-timing-function: var(--fa-animation-timing, cubic-bezier(0.4, 0, 0.6, 1));
|
||||
animation-timing-function: var(--fa-animation-timing, cubic-bezier(0.4, 0, 0.6, 1));
|
||||
}
|
||||
|
||||
.fa-beat-fade {
|
||||
-webkit-animation-name: fa-beat-fade;
|
||||
animation-name: fa-beat-fade;
|
||||
-webkit-animation-delay: var(--fa-animation-delay, 0s);
|
||||
animation-delay: var(--fa-animation-delay, 0s);
|
||||
-webkit-animation-direction: var(--fa-animation-direction, normal);
|
||||
animation-direction: var(--fa-animation-direction, normal);
|
||||
-webkit-animation-duration: var(--fa-animation-duration, 1s);
|
||||
animation-duration: var(--fa-animation-duration, 1s);
|
||||
-webkit-animation-iteration-count: var(--fa-animation-iteration-count, infinite);
|
||||
animation-iteration-count: var(--fa-animation-iteration-count, infinite);
|
||||
-webkit-animation-timing-function: var(--fa-animation-timing, cubic-bezier(0.4, 0, 0.6, 1));
|
||||
animation-timing-function: var(--fa-animation-timing, cubic-bezier(0.4, 0, 0.6, 1));
|
||||
}
|
||||
|
||||
.fa-flip {
|
||||
-webkit-animation-name: fa-flip;
|
||||
animation-name: fa-flip;
|
||||
-webkit-animation-delay: var(--fa-animation-delay, 0s);
|
||||
animation-delay: var(--fa-animation-delay, 0s);
|
||||
-webkit-animation-direction: var(--fa-animation-direction, normal);
|
||||
animation-direction: var(--fa-animation-direction, normal);
|
||||
-webkit-animation-duration: var(--fa-animation-duration, 1s);
|
||||
animation-duration: var(--fa-animation-duration, 1s);
|
||||
-webkit-animation-iteration-count: var(--fa-animation-iteration-count, infinite);
|
||||
animation-iteration-count: var(--fa-animation-iteration-count, infinite);
|
||||
-webkit-animation-timing-function: var(--fa-animation-timing, ease-in-out);
|
||||
animation-timing-function: var(--fa-animation-timing, ease-in-out);
|
||||
}
|
||||
|
||||
.fa-shake {
|
||||
-webkit-animation-name: fa-shake;
|
||||
animation-name: fa-shake;
|
||||
-webkit-animation-delay: var(--fa-animation-delay, 0s);
|
||||
animation-delay: var(--fa-animation-delay, 0s);
|
||||
-webkit-animation-direction: var(--fa-animation-direction, normal);
|
||||
animation-direction: var(--fa-animation-direction, normal);
|
||||
-webkit-animation-duration: var(--fa-animation-duration, 1s);
|
||||
animation-duration: var(--fa-animation-duration, 1s);
|
||||
-webkit-animation-iteration-count: var(--fa-animation-iteration-count, infinite);
|
||||
animation-iteration-count: var(--fa-animation-iteration-count, infinite);
|
||||
-webkit-animation-timing-function: var(--fa-animation-timing, linear);
|
||||
animation-timing-function: var(--fa-animation-timing, linear);
|
||||
}
|
||||
|
||||
.fa-spin {
|
||||
-webkit-animation-name: fa-spin;
|
||||
animation-name: fa-spin;
|
||||
-webkit-animation-delay: var(--fa-animation-delay, 0s);
|
||||
animation-delay: var(--fa-animation-delay, 0s);
|
||||
-webkit-animation-direction: var(--fa-animation-direction, normal);
|
||||
animation-direction: var(--fa-animation-direction, normal);
|
||||
-webkit-animation-duration: var(--fa-animation-duration, 2s);
|
||||
animation-duration: var(--fa-animation-duration, 2s);
|
||||
-webkit-animation-iteration-count: var(--fa-animation-iteration-count, infinite);
|
||||
animation-iteration-count: var(--fa-animation-iteration-count, infinite);
|
||||
-webkit-animation-timing-function: var(--fa-animation-timing, linear);
|
||||
animation-timing-function: var(--fa-animation-timing, linear);
|
||||
}
|
||||
|
||||
.fa-spin-reverse {
|
||||
--fa-animation-direction: reverse;
|
||||
}
|
||||
|
||||
.fa-pulse,
|
||||
.fa-spin-pulse {
|
||||
-webkit-animation-name: fa-spin;
|
||||
animation-name: fa-spin;
|
||||
-webkit-animation-direction: var(--fa-animation-direction, normal);
|
||||
animation-direction: var(--fa-animation-direction, normal);
|
||||
-webkit-animation-duration: var(--fa-animation-duration, 1s);
|
||||
animation-duration: var(--fa-animation-duration, 1s);
|
||||
-webkit-animation-iteration-count: var(--fa-animation-iteration-count, infinite);
|
||||
animation-iteration-count: var(--fa-animation-iteration-count, infinite);
|
||||
-webkit-animation-timing-function: var(--fa-animation-timing, steps(8));
|
||||
animation-timing-function: var(--fa-animation-timing, steps(8));
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.fa-beat,
|
||||
.fa-bounce,
|
||||
.fa-fade,
|
||||
.fa-beat-fade,
|
||||
.fa-flip,
|
||||
.fa-pulse,
|
||||
.fa-shake,
|
||||
.fa-spin,
|
||||
.fa-spin-pulse {
|
||||
-webkit-animation-delay: -1ms;
|
||||
animation-delay: -1ms;
|
||||
-webkit-animation-duration: 1ms;
|
||||
animation-duration: 1ms;
|
||||
-webkit-animation-iteration-count: 1;
|
||||
animation-iteration-count: 1;
|
||||
-webkit-transition-delay: 0s;
|
||||
transition-delay: 0s;
|
||||
-webkit-transition-duration: 0s;
|
||||
transition-duration: 0s;
|
||||
}
|
||||
}
|
||||
|
||||
@-webkit-keyframes fa-beat {
|
||||
0%, 90% {
|
||||
-webkit-transform: scale(1);
|
||||
transform: scale(1);
|
||||
}
|
||||
45% {
|
||||
-webkit-transform: scale(var(--fa-beat-scale, 1.25));
|
||||
transform: scale(var(--fa-beat-scale, 1.25));
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes fa-beat {
|
||||
0%, 90% {
|
||||
-webkit-transform: scale(1);
|
||||
transform: scale(1);
|
||||
}
|
||||
45% {
|
||||
-webkit-transform: scale(var(--fa-beat-scale, 1.25));
|
||||
transform: scale(var(--fa-beat-scale, 1.25));
|
||||
}
|
||||
}
|
||||
|
||||
@-webkit-keyframes fa-bounce {
|
||||
0% {
|
||||
-webkit-transform: scale(1, 1) translateY(0);
|
||||
transform: scale(1, 1) translateY(0);
|
||||
}
|
||||
10% {
|
||||
-webkit-transform: scale(var(--fa-bounce-start-scale-x, 1.1), var(--fa-bounce-start-scale-y, 0.9)) translateY(0);
|
||||
transform: scale(var(--fa-bounce-start-scale-x, 1.1), var(--fa-bounce-start-scale-y, 0.9)) translateY(0);
|
||||
}
|
||||
30% {
|
||||
-webkit-transform: scale(var(--fa-bounce-jump-scale-x, 0.9), var(--fa-bounce-jump-scale-y, 1.1)) translateY(var(--fa-bounce-height, -0.5em));
|
||||
transform: scale(var(--fa-bounce-jump-scale-x, 0.9), var(--fa-bounce-jump-scale-y, 1.1)) translateY(var(--fa-bounce-height, -0.5em));
|
||||
}
|
||||
50% {
|
||||
-webkit-transform: scale(var(--fa-bounce-land-scale-x, 1.05), var(--fa-bounce-land-scale-y, 0.95)) translateY(0);
|
||||
transform: scale(var(--fa-bounce-land-scale-x, 1.05), var(--fa-bounce-land-scale-y, 0.95)) translateY(0);
|
||||
}
|
||||
57% {
|
||||
-webkit-transform: scale(1, 1) translateY(var(--fa-bounce-rebound, -0.125em));
|
||||
transform: scale(1, 1) translateY(var(--fa-bounce-rebound, -0.125em));
|
||||
}
|
||||
64% {
|
||||
-webkit-transform: scale(1, 1) translateY(0);
|
||||
transform: scale(1, 1) translateY(0);
|
||||
}
|
||||
100% {
|
||||
-webkit-transform: scale(1, 1) translateY(0);
|
||||
transform: scale(1, 1) translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes fa-bounce {
|
||||
0% {
|
||||
-webkit-transform: scale(1, 1) translateY(0);
|
||||
transform: scale(1, 1) translateY(0);
|
||||
}
|
||||
10% {
|
||||
-webkit-transform: scale(var(--fa-bounce-start-scale-x, 1.1), var(--fa-bounce-start-scale-y, 0.9)) translateY(0);
|
||||
transform: scale(var(--fa-bounce-start-scale-x, 1.1), var(--fa-bounce-start-scale-y, 0.9)) translateY(0);
|
||||
}
|
||||
30% {
|
||||
-webkit-transform: scale(var(--fa-bounce-jump-scale-x, 0.9), var(--fa-bounce-jump-scale-y, 1.1)) translateY(var(--fa-bounce-height, -0.5em));
|
||||
transform: scale(var(--fa-bounce-jump-scale-x, 0.9), var(--fa-bounce-jump-scale-y, 1.1)) translateY(var(--fa-bounce-height, -0.5em));
|
||||
}
|
||||
50% {
|
||||
-webkit-transform: scale(var(--fa-bounce-land-scale-x, 1.05), var(--fa-bounce-land-scale-y, 0.95)) translateY(0);
|
||||
transform: scale(var(--fa-bounce-land-scale-x, 1.05), var(--fa-bounce-land-scale-y, 0.95)) translateY(0);
|
||||
}
|
||||
57% {
|
||||
-webkit-transform: scale(1, 1) translateY(var(--fa-bounce-rebound, -0.125em));
|
||||
transform: scale(1, 1) translateY(var(--fa-bounce-rebound, -0.125em));
|
||||
}
|
||||
64% {
|
||||
-webkit-transform: scale(1, 1) translateY(0);
|
||||
transform: scale(1, 1) translateY(0);
|
||||
}
|
||||
100% {
|
||||
-webkit-transform: scale(1, 1) translateY(0);
|
||||
transform: scale(1, 1) translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
@-webkit-keyframes fa-fade {
|
||||
50% {
|
||||
opacity: var(--fa-fade-opacity, 0.4);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes fa-fade {
|
||||
50% {
|
||||
opacity: var(--fa-fade-opacity, 0.4);
|
||||
}
|
||||
}
|
||||
|
||||
@-webkit-keyframes fa-beat-fade {
|
||||
0%, 100% {
|
||||
opacity: var(--fa-beat-fade-opacity, 0.4);
|
||||
-webkit-transform: scale(1);
|
||||
transform: scale(1);
|
||||
}
|
||||
50% {
|
||||
opacity: 1;
|
||||
-webkit-transform: scale(var(--fa-beat-fade-scale, 1.125));
|
||||
transform: scale(var(--fa-beat-fade-scale, 1.125));
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes fa-beat-fade {
|
||||
0%, 100% {
|
||||
opacity: var(--fa-beat-fade-opacity, 0.4);
|
||||
-webkit-transform: scale(1);
|
||||
transform: scale(1);
|
||||
}
|
||||
50% {
|
||||
opacity: 1;
|
||||
-webkit-transform: scale(var(--fa-beat-fade-scale, 1.125));
|
||||
transform: scale(var(--fa-beat-fade-scale, 1.125));
|
||||
}
|
||||
}
|
||||
|
||||
@-webkit-keyframes fa-flip {
|
||||
50% {
|
||||
-webkit-transform: rotate3d(var(--fa-flip-x, 0), var(--fa-flip-y, 1), var(--fa-flip-z, 0), var(--fa-flip-angle, -180deg));
|
||||
transform: rotate3d(var(--fa-flip-x, 0), var(--fa-flip-y, 1), var(--fa-flip-z, 0), var(--fa-flip-angle, -180deg));
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes fa-flip {
|
||||
50% {
|
||||
-webkit-transform: rotate3d(var(--fa-flip-x, 0), var(--fa-flip-y, 1), var(--fa-flip-z, 0), var(--fa-flip-angle, -180deg));
|
||||
transform: rotate3d(var(--fa-flip-x, 0), var(--fa-flip-y, 1), var(--fa-flip-z, 0), var(--fa-flip-angle, -180deg));
|
||||
}
|
||||
}
|
||||
|
||||
@-webkit-keyframes fa-shake {
|
||||
0% {
|
||||
-webkit-transform: rotate(-15deg);
|
||||
transform: rotate(-15deg);
|
||||
}
|
||||
4% {
|
||||
-webkit-transform: rotate(15deg);
|
||||
transform: rotate(15deg);
|
||||
}
|
||||
8%, 24% {
|
||||
-webkit-transform: rotate(-18deg);
|
||||
transform: rotate(-18deg);
|
||||
}
|
||||
12%, 28% {
|
||||
-webkit-transform: rotate(18deg);
|
||||
transform: rotate(18deg);
|
||||
}
|
||||
16% {
|
||||
-webkit-transform: rotate(-22deg);
|
||||
transform: rotate(-22deg);
|
||||
}
|
||||
20% {
|
||||
-webkit-transform: rotate(22deg);
|
||||
transform: rotate(22deg);
|
||||
}
|
||||
32% {
|
||||
-webkit-transform: rotate(-12deg);
|
||||
transform: rotate(-12deg);
|
||||
}
|
||||
36% {
|
||||
-webkit-transform: rotate(12deg);
|
||||
transform: rotate(12deg);
|
||||
}
|
||||
40%, 100% {
|
||||
-webkit-transform: rotate(0deg);
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes fa-shake {
|
||||
0% {
|
||||
-webkit-transform: rotate(-15deg);
|
||||
transform: rotate(-15deg);
|
||||
}
|
||||
4% {
|
||||
-webkit-transform: rotate(15deg);
|
||||
transform: rotate(15deg);
|
||||
}
|
||||
8%, 24% {
|
||||
-webkit-transform: rotate(-18deg);
|
||||
transform: rotate(-18deg);
|
||||
}
|
||||
12%, 28% {
|
||||
-webkit-transform: rotate(18deg);
|
||||
transform: rotate(18deg);
|
||||
}
|
||||
16% {
|
||||
-webkit-transform: rotate(-22deg);
|
||||
transform: rotate(-22deg);
|
||||
}
|
||||
20% {
|
||||
-webkit-transform: rotate(22deg);
|
||||
transform: rotate(22deg);
|
||||
}
|
||||
32% {
|
||||
-webkit-transform: rotate(-12deg);
|
||||
transform: rotate(-12deg);
|
||||
}
|
||||
36% {
|
||||
-webkit-transform: rotate(12deg);
|
||||
transform: rotate(12deg);
|
||||
}
|
||||
40%, 100% {
|
||||
-webkit-transform: rotate(0deg);
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
}
|
||||
|
||||
@-webkit-keyframes fa-spin {
|
||||
0% {
|
||||
-webkit-transform: rotate(0deg);
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
100% {
|
||||
-webkit-transform: rotate(360deg);
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes fa-spin {
|
||||
0% {
|
||||
-webkit-transform: rotate(0deg);
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
100% {
|
||||
-webkit-transform: rotate(360deg);
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
.fa-rotate-90 {
|
||||
-webkit-transform: rotate(90deg);
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
|
||||
.fa-rotate-180 {
|
||||
-webkit-transform: rotate(180deg);
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
.fa-rotate-270 {
|
||||
-webkit-transform: rotate(270deg);
|
||||
transform: rotate(270deg);
|
||||
}
|
||||
|
||||
.fa-flip-horizontal {
|
||||
-webkit-transform: scale(-1, 1);
|
||||
transform: scale(-1, 1);
|
||||
}
|
||||
|
||||
.fa-flip-vertical {
|
||||
-webkit-transform: scale(1, -1);
|
||||
transform: scale(1, -1);
|
||||
}
|
||||
|
||||
.fa-flip-both,
|
||||
.fa-flip-horizontal.fa-flip-vertical {
|
||||
-webkit-transform: scale(-1, -1);
|
||||
transform: scale(-1, -1);
|
||||
}
|
||||
|
||||
.fa-rotate-by {
|
||||
-webkit-transform: rotate(var(--fa-rotate-angle, none));
|
||||
transform: rotate(var(--fa-rotate-angle, none));
|
||||
}
|
||||
|
||||
.fa-stack {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
height: 2em;
|
||||
position: relative;
|
||||
width: 2.5em;
|
||||
}
|
||||
|
||||
.fa-stack-1x,
|
||||
.fa-stack-2x {
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
margin: auto;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
z-index: var(--fa-stack-z-index, auto);
|
||||
}
|
||||
|
||||
.svg-inline--fa.fa-stack-1x {
|
||||
height: 1em;
|
||||
width: 1.25em;
|
||||
}
|
||||
|
||||
.svg-inline--fa.fa-stack-2x {
|
||||
height: 2em;
|
||||
width: 2.5em;
|
||||
}
|
||||
|
||||
.fa-inverse {
|
||||
color: var(--fa-inverse, #fff);
|
||||
}
|
||||
|
||||
.sr-only,
|
||||
.fa-sr-only {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
padding: 0;
|
||||
margin: -1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
white-space: nowrap;
|
||||
border-width: 0;
|
||||
}
|
||||
|
||||
.sr-only-focusable:not(:focus),
|
||||
.fa-sr-only-focusable:not(:focus) {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
padding: 0;
|
||||
margin: -1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
white-space: nowrap;
|
||||
border-width: 0;
|
||||
}
|
||||
|
||||
.svg-inline--fa .fa-primary {
|
||||
fill: var(--fa-primary-color, currentColor);
|
||||
opacity: var(--fa-primary-opacity, 1);
|
||||
}
|
||||
|
||||
.svg-inline--fa .fa-secondary {
|
||||
fill: var(--fa-secondary-color, currentColor);
|
||||
opacity: var(--fa-secondary-opacity, 0.4);
|
||||
}
|
||||
|
||||
.svg-inline--fa.fa-swap-opacity .fa-primary {
|
||||
opacity: var(--fa-secondary-opacity, 0.4);
|
||||
}
|
||||
|
||||
.svg-inline--fa.fa-swap-opacity .fa-secondary {
|
||||
opacity: var(--fa-primary-opacity, 1);
|
||||
}
|
||||
|
||||
.svg-inline--fa mask .fa-primary,
|
||||
.svg-inline--fa mask .fa-secondary {
|
||||
fill: black;
|
||||
}
|
||||
|
||||
.fad.fa-inverse,
|
||||
.fa-duotone.fa-inverse {
|
||||
color: var(--fa-inverse, #fff);
|
||||
}
|
||||
30
src/main/resources/static/css/v4-font-face.css
Normal file
30
src/main/resources/static/css/v4-font-face.css
Normal file
@@ -0,0 +1,30 @@
|
||||
/*!
|
||||
* Font Awesome Free 6.4.2 by @fontawesome - https://fontawesome.com
|
||||
* License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
|
||||
* Copyright 2023 Fonticons, Inc.
|
||||
*/
|
||||
@font-face {
|
||||
font-family: 'FontAwesome';
|
||||
font-display: block;
|
||||
src: url("../webfonts/fa-solid-900.woff2") format("woff2"), url("../webfonts/fa-solid-900.ttf") format("truetype");
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'FontAwesome';
|
||||
font-display: block;
|
||||
src: url("../webfonts/fa-brands-400.woff2") format("woff2"), url("../webfonts/fa-brands-400.ttf") format("truetype");
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'FontAwesome';
|
||||
font-display: block;
|
||||
src: url("../webfonts/fa-regular-400.woff2") format("woff2"), url("../webfonts/fa-regular-400.ttf") format("truetype");
|
||||
unicode-range: U+F003, U+F006, U+F014, U+F016-F017, U+F01A-F01B, U+F01D, U+F022, U+F03E, U+F044, U+F046, U+F05C-F05D, U+F06E, U+F070, U+F087-F088, U+F08A, U+F094, U+F096-F097, U+F09D, U+F0A0, U+F0A2, U+F0A4-F0A7, U+F0C5, U+F0C7, U+F0E5-F0E6, U+F0EB, U+F0F6-F0F8, U+F10C, U+F114-F115, U+F118-F11A, U+F11C-F11D, U+F133, U+F147, U+F14E, U+F150-F152, U+F185-F186, U+F18E, U+F190-F192, U+F196, U+F1C1-F1C9, U+F1D9, U+F1DB, U+F1E3, U+F1EA, U+F1F7, U+F1F9, U+F20A, U+F247-F248, U+F24A, U+F24D, U+F255-F25B, U+F25D, U+F271-F274, U+F278, U+F27B, U+F28C, U+F28E, U+F29C, U+F2B5, U+F2B7, U+F2BA, U+F2BC, U+F2BE, U+F2C0-F2C1, U+F2C3, U+F2D0, U+F2D2, U+F2D4, U+F2DC;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'FontAwesome';
|
||||
font-display: block;
|
||||
src: url("../webfonts/fa-v4compatibility.woff2") format("woff2"), url("../webfonts/fa-v4compatibility.ttf") format("truetype");
|
||||
unicode-range: U+F041, U+F047, U+F065-F066, U+F07D-F07E, U+F080, U+F08B, U+F08E, U+F090, U+F09A, U+F0AC, U+F0AE, U+F0B2, U+F0D0, U+F0D6, U+F0E4, U+F0EC, U+F10A-F10B, U+F123, U+F13E, U+F148-F149, U+F14C, U+F156, U+F15E, U+F160-F161, U+F163, U+F175-F178, U+F195, U+F1F8, U+F219, U+F27A;
|
||||
}
|
||||
2818
src/main/resources/static/css/v4-shims.css
Normal file
2818
src/main/resources/static/css/v4-shims.css
Normal file
File diff suppressed because it is too large
Load Diff
25
src/main/resources/static/css/v5-font-face.css
Normal file
25
src/main/resources/static/css/v5-font-face.css
Normal file
@@ -0,0 +1,25 @@
|
||||
/*!
|
||||
* Font Awesome Free 6.4.2 by @fontawesome - https://fontawesome.com
|
||||
* License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
|
||||
* Copyright 2023 Fonticons, Inc.
|
||||
*/
|
||||
@font-face {
|
||||
font-family: 'Font Awesome 5 Brands';
|
||||
font-display: block;
|
||||
font-weight: 400;
|
||||
src: url("../webfonts/fa-brands-400.woff2") format("woff2"), url("../webfonts/fa-brands-400.ttf") format("truetype");
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Font Awesome 5 Free';
|
||||
font-display: block;
|
||||
font-weight: 900;
|
||||
src: url("../webfonts/fa-solid-900.woff2") format("woff2"), url("../webfonts/fa-solid-900.ttf") format("truetype");
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Font Awesome 5 Free';
|
||||
font-display: block;
|
||||
font-weight: 400;
|
||||
src: url("../webfonts/fa-regular-400.woff2") format("woff2"), url("../webfonts/fa-regular-400.ttf") format("truetype");
|
||||
}
|
||||
31
src/main/resources/static/js/common.js
Normal file
31
src/main/resources/static/js/common.js
Normal file
@@ -0,0 +1,31 @@
|
||||
function convertToKatakana(input) {
|
||||
// 漢字とローマ字を削除
|
||||
const valueWithoutKanjiAndRomaji = input.value.replace(/[\u4E00-\u9FFF\u0041-\u009F]/g, '');
|
||||
|
||||
// ひらがなをカタカナに変換
|
||||
const katakanaValue = valueWithoutKanjiAndRomaji.replace(/[\u3041-\u3096]/g, function (match) {
|
||||
const chr = match.charCodeAt(0) + 0x60;
|
||||
return String.fromCharCode(chr);
|
||||
});
|
||||
|
||||
input.value = katakanaValue;
|
||||
}
|
||||
|
||||
function logoutSubmit() {
|
||||
const form = document.createElement('form');
|
||||
form.setAttribute('method', 'post');
|
||||
form.setAttribute('action', 'logout');
|
||||
|
||||
// 動的送信用のHidden
|
||||
// 動的にFormを作成する場合は何かしら送信しないと、正しく動作しない
|
||||
const inputField = document.createElement("input");
|
||||
inputField.setAttribute("type", "hidden");
|
||||
inputField.setAttribute("value", "logout");
|
||||
|
||||
form.appendChild(inputField);
|
||||
|
||||
// フォームをDOMに追加
|
||||
document.body.appendChild(form);
|
||||
|
||||
form.submit();
|
||||
}
|
||||
BIN
src/main/resources/static/webfonts/fa-brands-400.ttf
Normal file
BIN
src/main/resources/static/webfonts/fa-brands-400.ttf
Normal file
Binary file not shown.
BIN
src/main/resources/static/webfonts/fa-brands-400.woff2
Normal file
BIN
src/main/resources/static/webfonts/fa-brands-400.woff2
Normal file
Binary file not shown.
BIN
src/main/resources/static/webfonts/fa-regular-400.ttf
Normal file
BIN
src/main/resources/static/webfonts/fa-regular-400.ttf
Normal file
Binary file not shown.
BIN
src/main/resources/static/webfonts/fa-regular-400.woff2
Normal file
BIN
src/main/resources/static/webfonts/fa-regular-400.woff2
Normal file
Binary file not shown.
BIN
src/main/resources/static/webfonts/fa-solid-900.ttf
Normal file
BIN
src/main/resources/static/webfonts/fa-solid-900.ttf
Normal file
Binary file not shown.
BIN
src/main/resources/static/webfonts/fa-solid-900.woff2
Normal file
BIN
src/main/resources/static/webfonts/fa-solid-900.woff2
Normal file
Binary file not shown.
BIN
src/main/resources/static/webfonts/fa-v4compatibility.ttf
Normal file
BIN
src/main/resources/static/webfonts/fa-v4compatibility.ttf
Normal file
Binary file not shown.
BIN
src/main/resources/static/webfonts/fa-v4compatibility.woff2
Normal file
BIN
src/main/resources/static/webfonts/fa-v4compatibility.woff2
Normal file
Binary file not shown.
20
src/main/resources/templates/error.html
Normal file
20
src/main/resources/templates/error.html
Normal file
@@ -0,0 +1,20 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<head>
|
||||
|
||||
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
|
||||
<!-- 外部のスクリプトファイルを読み込む -->
|
||||
<script th:src="@{/js/common.js}"></script>
|
||||
<!-- CSSの読み込み -->
|
||||
<link rel="stylesheet" th:href="@{/css/all.css}">
|
||||
<link rel=stylesheet th:href="@{/css/style.css}" type="text/css">
|
||||
<title>エラー</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>エラーが発生しました。</h1>
|
||||
|
||||
<div>ログインからやり直してください。</div>
|
||||
<a href="login">ログイン</a>
|
||||
</body>
|
||||
</html>
|
||||
157
src/main/resources/templates/insertEmployeeConfirm.html
Normal file
157
src/main/resources/templates/insertEmployeeConfirm.html
Normal file
@@ -0,0 +1,157 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<head>
|
||||
|
||||
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
|
||||
<!-- 外部のスクリプトファイルを読み込む -->
|
||||
<script th:src="@{/js/common.js}"></script>
|
||||
<!-- CSSの読み込み -->
|
||||
<link rel="stylesheet" th:href="@{/css/all.css}">
|
||||
<link rel=stylesheet th:href="@{/css/style.css}" type="text/css">
|
||||
<title>登録内容確認</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>登録内容確認
|
||||
<div class="rightSection">
|
||||
<span class="loginInfo">ログイン者名:<span th:text="${session.loginUser.nmEmployee}"></span></span>
|
||||
<button class="logoutButton" onclick="logoutSubmit()">ログアウト</button>
|
||||
</div>
|
||||
</h1>
|
||||
|
||||
<form action="insertEmployee"
|
||||
id="insertForm"
|
||||
method="post"
|
||||
th:object="${insertEmployeeForm}">
|
||||
|
||||
<div class="msgBox error" th:if="${messageError != null}">
|
||||
<span class="error" th:each="message : ${messageError.message}" th:text="${message}"></span>
|
||||
</div>
|
||||
<table>
|
||||
<tr>
|
||||
<th class="header">社員ID</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
name="empId"
|
||||
readonly="readonly"
|
||||
type="text"
|
||||
value="自動で設定されます"/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">社員名</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
name="nmEmployee"
|
||||
readonly="readonly"
|
||||
th:value="*{nmEmployee}"
|
||||
type="text"/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">社員名フリガナ</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
name="knEmployee"
|
||||
readonly="readonly"
|
||||
th:value="*{knEmployee}"
|
||||
type="text"/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">メールアドレス</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
name="mailAddress"
|
||||
readonly="readonly"
|
||||
th:value="*{mailAddress}"
|
||||
type="text"/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">パスワード</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
name="password"
|
||||
readonly="readonly"
|
||||
th:value="*{password}"
|
||||
type="password"/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">管理者権限</th>
|
||||
<td>
|
||||
<label>
|
||||
<input id="adminAuth1" name="adminAuth" onclick="return false;"
|
||||
th:checked="${insertEmployeeForm .adminAuth == 1}" type="radio"
|
||||
value="1"> 管理者権限
|
||||
</label>
|
||||
<label>
|
||||
<input id="adminAuth0" name="adminAuth" onclick="return false;"
|
||||
th:checked="${insertEmployeeForm.adminAuth == null or insertEmployeeForm.adminAuth == 0}"
|
||||
type="radio"
|
||||
value="0">
|
||||
一般権限
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">所属部署</th>
|
||||
<td>
|
||||
<label>
|
||||
<select name="idDepartment" required="required" th:field="*{idDepartment}">
|
||||
<th:block th:each="department : ${departmentFormList}">
|
||||
<th:block
|
||||
th:if="${insertEmployeeForm.idDepartment != null && department.idDepartment == insertEmployeeForm.idDepartment}">
|
||||
<option th:text="${department.nmDepartment}"
|
||||
th:value="${department.idDepartment}">
|
||||
</option>
|
||||
</th:block>
|
||||
</th:block>
|
||||
</select>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="btnArea" colspan="2">
|
||||
<input type="submit" value="登録"/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<a href="javascript:onClickEdit()">登録内容の編集</a> | <a href="showMenu">メニューに戻る</a>
|
||||
</form>
|
||||
|
||||
<script type="text/javascript">
|
||||
function onClickEdit() {
|
||||
const form = document.getElementById('insertForm');
|
||||
form.setAttribute('method', 'post');
|
||||
form.setAttribute('action', 'insertEmployeeInput');
|
||||
|
||||
// 確認画面から編集画面に戻ってきたときのフラグ(未使用)
|
||||
const inputField = document.createElement("input");
|
||||
inputField.setAttribute("type", "hidden");
|
||||
inputField.setAttribute("name", "backFlg");
|
||||
inputField.setAttribute("value", "edit");
|
||||
|
||||
form.appendChild(inputField);
|
||||
|
||||
// フォームをDOMに追加
|
||||
document.body.appendChild(form);
|
||||
|
||||
form.submit();
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
158
src/main/resources/templates/insertEmployeeInput.html
Normal file
158
src/main/resources/templates/insertEmployeeInput.html
Normal file
@@ -0,0 +1,158 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<head>
|
||||
|
||||
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
|
||||
<!-- 外部のスクリプトファイルを読み込む -->
|
||||
<script th:src="@{/js/common.js}"></script>
|
||||
<!-- CSSの読み込み -->
|
||||
<link rel="stylesheet" th:href="@{/css/all.css}">
|
||||
<link rel=stylesheet th:href="@{/css/style.css}" type="text/css">
|
||||
<title>社員登録</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>
|
||||
社員登録
|
||||
<div class="rightSection">
|
||||
<span class="loginInfo">ログイン者名:<span th:text="${session.loginUser.nmEmployee}"></span></span>
|
||||
<button class="logoutButton" onclick="logoutSubmit()">ログアウト</button>
|
||||
</div>
|
||||
</h1>
|
||||
<form action="insertEmployeeConfirm"
|
||||
method="post"
|
||||
th:object="${insertEmployeeForm}">
|
||||
|
||||
<div class="msgBox error" th:if="${messageError} != null">
|
||||
<span class="error" th:text="${messageError.message}"></span>
|
||||
</div>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th class="header">社員ID</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
readonly="readonly"
|
||||
type="text"
|
||||
value="自動で設定されます"
|
||||
/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">社員名</th>
|
||||
<td>
|
||||
<label>
|
||||
<input maxlength="50"
|
||||
placeholder="社員名"
|
||||
required="required"
|
||||
th:field="*{nmEmployee}"
|
||||
type="text"
|
||||
/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">社員名フリガナ</th>
|
||||
<td>
|
||||
<label>
|
||||
<input maxlength="50"
|
||||
oninput="convertToKatakana(this)"
|
||||
placeholder="フリガナ"
|
||||
required="required"
|
||||
th:field="*{knEmployee}"
|
||||
type="text"
|
||||
/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">メールアドレス</th>
|
||||
<td>
|
||||
<label>
|
||||
<input maxlength="100"
|
||||
placeholder="メールアドレス"
|
||||
required="required"
|
||||
th:field="*{mailAddress}"
|
||||
type="email"
|
||||
/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">パスワード</th>
|
||||
<td>
|
||||
<label>
|
||||
<input pattern="^(?=.*?[a-zA-Z])(?=.*?\d)[a-zA-Z\d]{3,10}$"
|
||||
placeholder="パスワード"
|
||||
required="required"
|
||||
th:field="*{password}"
|
||||
type="password"
|
||||
/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- *** Chrome等のブラウザの場合自動でセットされる可能性があるので注意書きを外にも *** -->
|
||||
<tr>
|
||||
<th></th>
|
||||
<td><span
|
||||
style="font-size:8pt; font-weight:bold; color:red;">※半角英数字をそれぞれ1種類以上含む3-10文字</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">パスワード確認用</th>
|
||||
<td>
|
||||
<label>
|
||||
<input pattern="^(?=.*?[a-zA-Z])(?=.*?\d)[a-zA-Z\d]{3,10}$"
|
||||
placeholder="パスワード確認用"
|
||||
required="required"
|
||||
th:field="*{passwordConfirm}"
|
||||
type="password"
|
||||
/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">管理者権限</th>
|
||||
<td>
|
||||
<label>
|
||||
<input id="adminAuth1" name="adminAuth" th:checked="${insertEmployeeForm .adminAuth == 1}"
|
||||
type="radio"
|
||||
value="1"> 管理者権限
|
||||
</label>
|
||||
<label>
|
||||
<input id="adminAuth0" name="adminAuth"
|
||||
th:checked="${insertEmployeeForm.adminAuth == null or insertEmployeeForm.adminAuth == 0}"
|
||||
type="radio"
|
||||
value="0">
|
||||
一般権限
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th class="header">所属部署</th>
|
||||
<td>
|
||||
<label>
|
||||
<select required="required" th:field="*{idDepartment}">
|
||||
<option th:each="department : ${departmentFormList}"
|
||||
th:selected="${insertEmployeeForm.idDepartment != null && department.idDepartment == insertEmployeeForm.idDepartment}"
|
||||
th:text="${department.nmDepartment}"
|
||||
th:value="${department.idDepartment}">
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="btnArea" colspan="2">
|
||||
<input type="submit" value="登録確認"/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<a href="showMenu">メニューに戻る</a>
|
||||
</body>
|
||||
</html>
|
||||
40
src/main/resources/templates/insertEmployeeResult.html
Normal file
40
src/main/resources/templates/insertEmployeeResult.html
Normal file
@@ -0,0 +1,40 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<head>
|
||||
|
||||
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
|
||||
<!-- 外部のスクリプトファイルを読み込む -->
|
||||
<script th:src="@{/js/common.js}"></script>
|
||||
<!-- CSSの読み込み -->
|
||||
<link rel="stylesheet" th:href="@{/css/all.css}">
|
||||
<link rel=stylesheet th:href="@{/css/style.css}" type="text/css">
|
||||
<title>社員登録完了</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h2>社員登録が完了しました</h2>
|
||||
<br/>
|
||||
<a href="javascript:insertSubmit()">続けて登録する</a> | <a href="showMenu">メニューに戻る</a>
|
||||
</body>
|
||||
<script type="text/javascript">
|
||||
function insertSubmit() {
|
||||
const form = document.createElement('form');
|
||||
form.setAttribute('method', 'post');
|
||||
form.setAttribute('action', 'insertEmployeeInput');
|
||||
|
||||
// 動的送信用のHidden
|
||||
// 動的にFormを作成する場合は何かしら送信しないと、正しく動作しない
|
||||
const inputField = document.createElement("input");
|
||||
inputField.setAttribute("type", "hidden");
|
||||
inputField.setAttribute("value", "select");
|
||||
|
||||
form.appendChild(inputField);
|
||||
|
||||
// フォームをDOMに追加
|
||||
document.body.appendChild(form);
|
||||
|
||||
form.submit();
|
||||
}
|
||||
</script>
|
||||
</html>
|
||||
63
src/main/resources/templates/login.html
Normal file
63
src/main/resources/templates/login.html
Normal file
@@ -0,0 +1,63 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<head>
|
||||
|
||||
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
|
||||
<!-- 外部のスクリプトファイルを読み込む -->
|
||||
<script th:src="@{/js/common.js}"></script>
|
||||
<!-- CSSの読み込み -->
|
||||
<link rel="stylesheet" th:href="@{/css/all.css}">
|
||||
<link rel=stylesheet th:href="@{/css/style.css}" type="text/css">
|
||||
<title>ログイン</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>ログイン</h1>
|
||||
<form action="doLogin"
|
||||
method="post"
|
||||
th:object="${loginInfoForm}">
|
||||
|
||||
<div class="msgBox error" th:if="${messageError} != null">
|
||||
<span class="error" th:text="${messageError.message}"></span>
|
||||
</div>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th class="header">メールアドレス</th>
|
||||
<td style="width: 250px;">
|
||||
<input placeholder="メールアドレス"
|
||||
required="required"
|
||||
style="width: 100%;"
|
||||
th:field="*{mailAddress}"
|
||||
type="text"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th style="text-align: right;">パスワード</th>
|
||||
<td>
|
||||
<input placeholder="パスワード"
|
||||
required="required"
|
||||
style="width: 100%;"
|
||||
th:field="*{password}"
|
||||
type="password"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="btnArea" colspan="2">
|
||||
<input type="submit" value="ログイン"/>
|
||||
<button onclick="clearInput()">リセット</button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</body>
|
||||
<script type="text/javascript">
|
||||
|
||||
function clearInput() {
|
||||
document.getElementById('mailAddress').value = '';
|
||||
document.getElementById('password').value = '';
|
||||
}
|
||||
|
||||
</script>
|
||||
</html>
|
||||
117
src/main/resources/templates/menu.html
Normal file
117
src/main/resources/templates/menu.html
Normal file
@@ -0,0 +1,117 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<head>
|
||||
|
||||
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
|
||||
<!-- 外部のスクリプトファイルを読み込む -->
|
||||
<script th:src="@{/js/common.js}"></script>
|
||||
<!-- CSSの読み込み -->
|
||||
<link rel="stylesheet" th:href="@{/css/all.css}">
|
||||
<link rel=stylesheet th:href="@{/css/style.css}" type="text/css">
|
||||
<title>メニュー</title>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>
|
||||
メインメニュー
|
||||
<div class="rightSection">
|
||||
<span class="loginInfo">ログイン者名:<span th:text="${session.loginUser.nmEmployee}"></span></span>
|
||||
<button class="logoutButton" onclick="logoutSubmit()">ログアウト</button>
|
||||
</div>
|
||||
</h1>
|
||||
<table class="menuClass">
|
||||
<tr>
|
||||
<td><a class="menuClass" href="javascript:selectEmployeeSubmit()"><i class="fas fa-search"></i> 社員検索 </a>
|
||||
</td>
|
||||
<td class="description">登録済みのユーザ一覧表示と</br>更新、削除を行います。</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><a class="menuClass" href="javascript:insertEmployeeSubmit()"><i class="fas fa-plus"></i> 社員登録 </a></td>
|
||||
<td class="description">新規でユーザ追加を行います。</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</body>
|
||||
|
||||
<script type="text/javascript">
|
||||
function selectEmployeeSubmit() {
|
||||
const form = document.createElement('form');
|
||||
form.setAttribute('method', 'post');
|
||||
form.setAttribute('action', 'selectEmployeeInfo');
|
||||
|
||||
// 動的送信用のHidden
|
||||
// 動的にFormを作成する場合は何かしら送信しないと、正しく動作しない
|
||||
const inputField = document.createElement("input");
|
||||
inputField.setAttribute("type", "hidden");
|
||||
inputField.setAttribute("value", "selectEmployeeInfo");
|
||||
|
||||
form.appendChild(inputField);
|
||||
|
||||
// フォームをDOMに追加
|
||||
document.body.appendChild(form);
|
||||
|
||||
form.submit();
|
||||
}
|
||||
|
||||
function selectDepartmentSubmit() {
|
||||
const form = document.createElement('form');
|
||||
form.setAttribute('method', 'post');
|
||||
form.setAttribute('action', 'selectDepartment');
|
||||
|
||||
// 動的送信用のHidden
|
||||
// 動的にFormを作成する場合は何かしら送信しないと、正しく動作しない
|
||||
const inputField = document.createElement("input");
|
||||
inputField.setAttribute("type", "hidden");
|
||||
inputField.setAttribute("value", "selectDepartment");
|
||||
|
||||
form.appendChild(inputField);
|
||||
|
||||
// フォームをDOMに追加
|
||||
document.body.appendChild(form);
|
||||
|
||||
form.submit();
|
||||
}
|
||||
|
||||
function insertEmployeeSubmit() {
|
||||
const form = document.createElement('form');
|
||||
form.setAttribute('method', 'post');
|
||||
form.setAttribute('action', 'insertEmployeeInput');
|
||||
|
||||
// 動的送信用のHidden
|
||||
// 動的にFormを作成する場合は何かしら送信しないと、正しく動作しない
|
||||
const inputField = document.createElement("input");
|
||||
inputField.setAttribute("type", "hidden");
|
||||
inputField.setAttribute("value", "insertEmployeeInput");
|
||||
|
||||
form.appendChild(inputField);
|
||||
|
||||
// フォームをDOMに追加
|
||||
document.body.appendChild(form);
|
||||
|
||||
form.submit();
|
||||
}
|
||||
|
||||
function insertDepartmentSubmit() {
|
||||
const form = document.createElement('form');
|
||||
form.setAttribute('method', 'post');
|
||||
form.setAttribute('action', 'insertDepartmentInput');
|
||||
|
||||
// 動的送信用のHidden
|
||||
// 動的にFormを作成する場合は何かしら送信しないと、正しく動作しない
|
||||
const inputField = document.createElement("input");
|
||||
inputField.setAttribute("type", "hidden");
|
||||
inputField.setAttribute("value", "insertDepartmentInput");
|
||||
|
||||
form.appendChild(inputField);
|
||||
|
||||
// フォームをDOMに追加
|
||||
document.body.appendChild(form);
|
||||
|
||||
form.submit();
|
||||
}
|
||||
</script>
|
||||
|
||||
</html>
|
||||
157
src/main/resources/templates/selectEmployee.html
Normal file
157
src/main/resources/templates/selectEmployee.html
Normal file
@@ -0,0 +1,157 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<head>
|
||||
|
||||
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
|
||||
<!-- 外部のスクリプトファイルを読み込む -->
|
||||
<script th:src="@{/js/common.js}"></script>
|
||||
<!-- CSSの読み込み -->
|
||||
<link rel="stylesheet" th:href="@{/css/all.css}">
|
||||
<link rel=stylesheet th:href="@{/css/style.css}" type="text/css">
|
||||
<title>検索</title>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<h1>
|
||||
検索条件入力
|
||||
<div class="rightSection">
|
||||
<span class="loginInfo">ログイン者名:<span th:text="${session.loginUser.nmEmployee}"></span></span>
|
||||
<button class="logoutButton" onclick="logoutSubmit()">ログアウト</button>
|
||||
</div>
|
||||
</h1>
|
||||
<form action="selectEmployeeInfo"
|
||||
method="post"
|
||||
th:object="${searchConditionEmployeeForm}">
|
||||
|
||||
<div class="msgBox error" th:if="${messageError} != null">
|
||||
<span class="error" th:text="${messageError.message}"></span>
|
||||
</div>
|
||||
<table>
|
||||
<tr>
|
||||
<th class="header">社員ID</th>
|
||||
<td>
|
||||
<input placeholder="社員ID"
|
||||
th:field="*{idEmployee}"
|
||||
type="number"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">社員名</th>
|
||||
<td>
|
||||
<input placeholder="社員名"
|
||||
th:field="*{nmEmployee}"
|
||||
type="text"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">社員名フリガナ</th>
|
||||
<td>
|
||||
<input oninput="convertToKatakana(this)"
|
||||
placeholder="フリガナ"
|
||||
th:field="*{knEmployee}"
|
||||
type="text"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">メールアドレス</th>
|
||||
<td>
|
||||
<input placeholder="メールアドレス"
|
||||
th:field="*{mailAddress}"
|
||||
type="email"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">所属部署</th>
|
||||
<td>
|
||||
<select th:field="*{idDepartment}">
|
||||
<option value=""></option>
|
||||
<option th:each="department : ${departmentFormList}"
|
||||
th:selected="${searchConditionEmployeeForm.idDepartment != null && department.idDepartment == searchConditionEmployeeForm.idDepartment}"
|
||||
th:text="${department.nmDepartment}"
|
||||
th:value="${department.idDepartment}">
|
||||
</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="btnArea" colspan="2">
|
||||
<input type="submit" value="検索"/>
|
||||
</td>
|
||||
<td class="btnArea" colspan="2">
|
||||
<button onclick="clearInput()">クリア</button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<div class="header-spacing"></div>
|
||||
<a href="showMenu">メニューに戻る</a>
|
||||
<div class="header-spacing"></div>
|
||||
<h1><span>検索結果</span></h1>
|
||||
<div class="header-spacing"></div>
|
||||
<th:block th:if="${messageInfo != null}">
|
||||
<script th:inline="javascript">
|
||||
alert([[${messageInfo.message}]]);
|
||||
</script>
|
||||
</th:block>
|
||||
<div class="header-spacing"></div>
|
||||
<th:block th:if="${employeeInfoFormList != null and employeeInfoFormList.size() > 0}">
|
||||
<!-- 検索結果が1件以上ある場合 -->
|
||||
<table class="table-grid table-striped table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 60px;">社員ID</th>
|
||||
<th style="width: 100px;">社員名</th>
|
||||
<th style="width: 150px;">フリガナ</th>
|
||||
<th style="width: 150px;">メールアドレス</th>
|
||||
<th style="width: 100px;">パスワード</th>
|
||||
<th style="width: 70px;">管理者フラグ</th>
|
||||
<th style="width: 150px;">所属部署</th>
|
||||
<th style="width: 150px;">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr th:each="employeeInfoForm : ${employeeInfoFormList}">
|
||||
<td th:text="${employeeInfoForm.idEmployee}"></td>
|
||||
<td th:text="${employeeInfoForm.nmEmployee}"></td>
|
||||
<td th:text="${employeeInfoForm.knEmployee}"></td>
|
||||
<td th:text="${employeeInfoForm.mailAddress}"></td>
|
||||
<td th:text="${employeeInfoForm.password}"></td>
|
||||
<td th:text="${employeeInfoForm.adminAuth}"></td>
|
||||
<td th:text="${employeeInfoForm.nmDepartment}"></td>
|
||||
<td>
|
||||
<!-- 更新フォーム -->
|
||||
<form action="showUpdateEmployee" method="post" style="display: inline;">
|
||||
<input name="idEmployee" th:value="${employeeInfoForm.idEmployee}" type="hidden">
|
||||
<input type="submit" value="更新">
|
||||
</form>
|
||||
<!-- 削除フォーム -->
|
||||
<form action="deleteEmployee" method="post" onsubmit="return confirm('本当に削除しますか?');"
|
||||
style="display: inline;">
|
||||
<input name="idEmployee" th:value="${employeeInfoForm.idEmployee}" type="hidden">
|
||||
<input type="submit" value="削除">
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</th:block>
|
||||
<th:block th:if="${employeeInfoFormList == null or employeeInfoFormList.size() == 0}">
|
||||
<!-- 検索結果が0件の場合 -->
|
||||
検索結果はありません。
|
||||
</th:block>
|
||||
|
||||
</body>
|
||||
<script type="text/javascript">
|
||||
|
||||
function clearInput() {
|
||||
document.getElementById('idEmployee').value = '';
|
||||
document.getElementById('nmEmployee').value = '';
|
||||
document.getElementById('knEmployee').value = '';
|
||||
document.getElementById('mailAddress').value = '';
|
||||
document.getElementById('idDepartment').selectedIndex = 0;
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
</html>
|
||||
181
src/main/resources/templates/updateEmployeeInput.html
Normal file
181
src/main/resources/templates/updateEmployeeInput.html
Normal file
@@ -0,0 +1,181 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<head>
|
||||
|
||||
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
|
||||
<!-- 外部のスクリプトファイルを読み込む -->
|
||||
<script th:src="@{/js/common.js}"></script>
|
||||
<!-- CSSの読み込み -->
|
||||
<link rel="stylesheet" th:href="@{/css/all.css}">
|
||||
<link rel=stylesheet th:href="@{/css/style.css}" type="text/css">
|
||||
<title>社員情報更新</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>
|
||||
社員情報更新
|
||||
<div class="rightSection">
|
||||
<span class="loginInfo">ログイン者名:<span th:text="${session.loginUser.nmEmployee}"></span></span>
|
||||
<button class="logoutButton" onclick="logoutSubmit()">ログアウト</button>
|
||||
</div>
|
||||
</h1>
|
||||
<form action="/updateEmployeeResult"
|
||||
method="post"
|
||||
onsubmit="return confirm('本当によろしいですか?');"
|
||||
th:object="${updateEmployeeInfoForm}"
|
||||
>
|
||||
<div class="msgBox error" th:if="${messageError != null}">
|
||||
<span class="error" th:each="message : ${messageError.message}" th:text="${message}"></span>
|
||||
</div>
|
||||
<table>
|
||||
<tr>
|
||||
<th class="header">社員ID</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
readonly="readonly"
|
||||
th:field="*{idEmployee}"
|
||||
type="text"
|
||||
/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">社員名</th>
|
||||
<td>
|
||||
<label>
|
||||
<input maxlength="50"
|
||||
placeholder="社員名"
|
||||
required="required"
|
||||
th:field="*{nmEmployee}"
|
||||
type="text"
|
||||
/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">社員名フリガナ</th>
|
||||
<td>
|
||||
<label>
|
||||
<input maxlength="50"
|
||||
oninput="convertToKatakana(this)"
|
||||
placeholder="フリガナ"
|
||||
required="required"
|
||||
th:field="*{knEmployee}"
|
||||
type="text"
|
||||
/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">メールアドレス</th>
|
||||
<td>
|
||||
<label>
|
||||
<input maxlength="100"
|
||||
placeholder="メールアドレス"
|
||||
required="required"
|
||||
th:field="*{mailAddress}"
|
||||
type="email"
|
||||
/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">パスワード</th>
|
||||
<td>
|
||||
<label>
|
||||
<input pattern="^(?=.*?[a-zA-Z])(?=.*?\d)[a-zA-Z\d]{3,10}$"
|
||||
placeholder="パスワード"
|
||||
th:field="*{password}"
|
||||
type="password"
|
||||
/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- *** Chrome等のブラウザの場合自動でセットされる可能性があるので注意書きを外にも *** -->
|
||||
<tr>
|
||||
<th></th>
|
||||
<td>
|
||||
<span style="font-size:8pt;
|
||||
font-weight:bold;
|
||||
color:red;">
|
||||
※半角英数字をそれぞれ1種類以上含む3-10文字
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">パスワード確認用</th>
|
||||
<td>
|
||||
<label>
|
||||
<input pattern="^(?=.*?[a-zA-Z])(?=.*?\d)[a-zA-Z\d]{3,10}$"
|
||||
placeholder="パスワード確認用"
|
||||
th:field="*{passwordConfirm}"
|
||||
type="password"
|
||||
/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">管理者権限</th>
|
||||
<td>
|
||||
<label>
|
||||
<input id="adminAuth1" name="adminAuth" th:checked="${updateEmployeeInfoForm.adminAuth == 1}"
|
||||
type="radio"
|
||||
value="1"> 管理者権限
|
||||
</label>
|
||||
<label>
|
||||
<input id="adminAuth0" name="adminAuth"
|
||||
th:checked="${updateEmployeeInfoForm.adminAuth == null or updateEmployeeInfoForm.adminAuth == 0}"
|
||||
type="radio"
|
||||
value="0">
|
||||
一般権限
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">所属部署</th>
|
||||
<td>
|
||||
<label>
|
||||
<select required="required" th:field="*{idDepartment}">
|
||||
<option th:each="department : ${departmentFormList}"
|
||||
th:selected="${updateEmployeeInfoForm.idDepartment != null && department.idDepartment == updateEmployeeInfoForm.idDepartment}"
|
||||
th:text="${department.nmDepartment}"
|
||||
th:value="${department.idDepartment}">
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="btnArea" colspan="2">
|
||||
<input type="submit" value="更新"/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<a href="javascript:selectSubmit()">一覧に戻る</a>
|
||||
</body>
|
||||
|
||||
<script>
|
||||
function selectSubmit() {
|
||||
const form = document.createElement('form');
|
||||
form.setAttribute('method', 'post');
|
||||
form.setAttribute('action', 'selectAll');
|
||||
|
||||
// 動的送信用のHidden
|
||||
// 動的にFormを作成する場合は何かしら送信しないと、正しく動作しない
|
||||
const inputField = document.createElement("input");
|
||||
inputField.setAttribute("type", "hidden");
|
||||
inputField.setAttribute("value", "selectAll");
|
||||
|
||||
form.appendChild(inputField);
|
||||
|
||||
// フォームをDOMに追加
|
||||
document.body.appendChild(form);
|
||||
|
||||
form.submit();
|
||||
}
|
||||
|
||||
</script>
|
||||
</html>
|
||||
108
src/main/resources/templates/updatePersonalEmployeeInput.html
Normal file
108
src/main/resources/templates/updatePersonalEmployeeInput.html
Normal file
@@ -0,0 +1,108 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<head>
|
||||
|
||||
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
|
||||
<!-- 外部のスクリプトファイルを読み込む -->
|
||||
<script th:src="@{/js/common.js}"></script>
|
||||
<!-- CSSの読み込み -->
|
||||
<link rel="stylesheet" th:href="@{/css/all.css}">
|
||||
<link rel=stylesheet th:href="@{/css/style.css}" type="text/css">
|
||||
<title>社員情報更新</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>
|
||||
社員情報更新
|
||||
<div class="rightSection">
|
||||
<span class="loginInfo">ログイン者名:<span th:text="${session.loginUser.nmEmployee}"></span></span>
|
||||
<button class="logoutButton" onclick="logoutSubmit()">ログアウト</button>
|
||||
</div>
|
||||
</h1>
|
||||
<form action="updatePersonalEmployeeResult"
|
||||
method="post"
|
||||
th:object="${updatePersonalEmployeeUserForm}">
|
||||
|
||||
<div class="msgBox error" th:if="${messageError != null}">
|
||||
<span class="error" th:each="message : ${messageError.message}" th:text="${message}"></span>
|
||||
</div>
|
||||
<table>
|
||||
<tr>
|
||||
<th class="header">社員名</th>
|
||||
<td>
|
||||
<input maxlength="50"
|
||||
placeholder="社員名"
|
||||
required
|
||||
th:name="nmEmployee"
|
||||
th:value="*{nmEmployee}"
|
||||
type="text"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">社員名フリガナ</th>
|
||||
<td>
|
||||
<input maxlength="50"
|
||||
name="knEmployee"
|
||||
oninput="convertToKatakana(this)"
|
||||
placeholder="フリガナ"
|
||||
required
|
||||
th:value="*{knEmployee}"
|
||||
type="text"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">メールアドレス</th>
|
||||
<td>
|
||||
<input maxlength="100"
|
||||
name="mailAddress"
|
||||
placeholder="メールアドレス"
|
||||
required
|
||||
th:value="*{mailAddress}"
|
||||
type="email"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">パスワード</th>
|
||||
<td>
|
||||
<input name="password"
|
||||
pattern="^(?=.*?[a-zA-Z])(?=.*?\d)[a-zA-Z\d]{3,10}$"
|
||||
placeholder="※更新する場合は入力"
|
||||
th:field="*{password}"
|
||||
type="password"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- *** Chrome等のブラウザの場合自動でセットされる可能性があるので注意書きを外にも *** -->
|
||||
<tr>
|
||||
<th></th>
|
||||
<td>
|
||||
<span style="font-size:8pt; font-weight:bold; color:red;">更新する場合は入力してください<br>
|
||||
※半角英数字をそれぞれ1種類以上含む3-10文字</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">パスワード確認</th>
|
||||
<td>
|
||||
<input name="passwordConfirm"
|
||||
pattern="^(?=.*?[a-zA-Z])(?=.*?\d)[a-zA-Z\d]{3,10}$"
|
||||
placeholder="※更新する場合は再入力"
|
||||
th:field="*{passwordConfirm}"
|
||||
type="password"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="btnArea" colspan="2">
|
||||
<input name="submit" type="submit" value="更新"/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<input name="idEmployee"
|
||||
th:value="*{idEmployee}"
|
||||
type="hidden"/>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,42 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<head>
|
||||
|
||||
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
|
||||
<!-- 外部のスクリプトファイルを読み込む -->
|
||||
<script th:src="@{/js/common.js}"></script>
|
||||
<!-- CSSの読み込み -->
|
||||
<link rel="stylesheet" th:href="@{/css/all.css}">
|
||||
<link rel=stylesheet th:href="@{/css/style.css}" type="text/css">
|
||||
<title>更新完了</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h2>更新が完了しました</h2>
|
||||
<br/>
|
||||
<a href="javascript:backSubmit()">戻る</a>
|
||||
</body>
|
||||
|
||||
<script type="text/javascript">
|
||||
function backSubmit() {
|
||||
const form = document.createElement('form');
|
||||
form.setAttribute('method', 'post');
|
||||
form.setAttribute('action', 'updatePersonalEmployeeResult');
|
||||
|
||||
// 動的送信用のHidden
|
||||
// 動的にFormを作成する場合は何かしら送信しないと、正しく動作しない
|
||||
const inputField = document.createElement("input");
|
||||
inputField.setAttribute("type", "hidden");
|
||||
inputField.setAttribute("value", "updatePersonalEmployeeResult");
|
||||
|
||||
form.appendChild(inputField);
|
||||
|
||||
// フォームをDOMに追加
|
||||
document.body.appendChild(form);
|
||||
|
||||
form.submit();
|
||||
}
|
||||
</script>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.example.rhizome.app.domain.model;
|
||||
|
||||
import com.example.rhizome.app.infra.record.DepartmentEnum;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
class DepartmentTest {
|
||||
|
||||
// テストデータの用意
|
||||
final static Department departmentTest = new Department(
|
||||
DepartmentEnum.TEST_DEPARTMENT.getIdDepartment(),
|
||||
DepartmentEnum.TEST_DEPARTMENT.getNmDepartment()
|
||||
);
|
||||
|
||||
// テストデータの用意
|
||||
final static Department departmentNull = new Department(
|
||||
DepartmentEnum.NULL_DEPARTMENT.getIdDepartment(),
|
||||
DepartmentEnum.NULL_DEPARTMENT.getNmDepartment()
|
||||
);
|
||||
|
||||
@Nested
|
||||
static class GetIdDepartmentTest {
|
||||
|
||||
@Test
|
||||
void getIdDepartment_正常系_IdDepartmentの取得() {
|
||||
// 期待値
|
||||
Integer expected = DepartmentEnum.TEST_DEPARTMENT.getIdDepartment();
|
||||
// 実測値
|
||||
Integer actual = departmentTest.getIdDepartment();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getIdDepartment_正常系_IdDepartmentの取得結果がnull() {
|
||||
|
||||
Integer expected = DepartmentEnum.NULL_DEPARTMENT.getIdDepartment();
|
||||
Integer actual = departmentNull.getIdDepartment();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class GetNmDepartmentTest {
|
||||
|
||||
@Test
|
||||
void getNmDepartment_正常系_NmDepartmentの取得() {
|
||||
|
||||
String expected = DepartmentEnum.TEST_DEPARTMENT.getNmDepartment();
|
||||
String actual = departmentTest.getNmDepartment();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getNmDepartment_正常系_NmDepartmentの取得結果がnull() {
|
||||
|
||||
String expected = DepartmentEnum.NULL_DEPARTMENT.getNmDepartment();
|
||||
String actual = departmentNull.getNmDepartment();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
package com.example.rhizome.app.domain.model;
|
||||
|
||||
import com.example.rhizome.app.infra.record.DepartmentEnum;
|
||||
import com.example.rhizome.app.infra.record.EmployeeEnum;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
class EmployeeInfoTest {
|
||||
|
||||
static EmployeeInfo testEmployeeInfo = new EmployeeInfo(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance(),
|
||||
DepartmentEnum.TEST_DEPARTMENT.getDepartmentInstance()
|
||||
);
|
||||
|
||||
static EmployeeInfo nullEmployeeInfo = new EmployeeInfo(
|
||||
EmployeeEnum.NULL_EMPLOYEE.getEmployeeInstance(),
|
||||
DepartmentEnum.NULL_DEPARTMENT.getDepartmentInstance()
|
||||
);
|
||||
|
||||
@Nested
|
||||
static class getIdEmployeeTest {
|
||||
@Test
|
||||
void getIdEmployee_正常系_IdEmployeeの取得() {
|
||||
Integer expected = EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee();
|
||||
Integer actual = testEmployeeInfo.getEmployee().getIdEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getIdEmployee_正常系_IdEmployeeの取得結果がnull() {
|
||||
Integer expected = EmployeeEnum.NULL_EMPLOYEE.getIdEmployee();
|
||||
Integer actual = nullEmployeeInfo.getEmployee().getIdEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class getNmEmployeeTest {
|
||||
@Test
|
||||
void getNmEmployee_正常系_NmEmployeeの取得() {
|
||||
String expected = EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee();
|
||||
String actual = testEmployeeInfo.getEmployee().getNmEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getNmEmployee_正常系_NmEmployeeの取得結果がnull() {
|
||||
String expected = EmployeeEnum.NULL_EMPLOYEE.getNmEmployee();
|
||||
String actual = nullEmployeeInfo.getEmployee().getNmEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class GetKnEmployeeTest {
|
||||
@Test
|
||||
void getKnEmployee_正常系_KnEmployeeの取得() {
|
||||
String expected = EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee();
|
||||
String actual = testEmployeeInfo.getEmployee().getKnEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getKnEmployee_正常系_KnEmployeeの取得結果がnull() {
|
||||
String expected = EmployeeEnum.NULL_EMPLOYEE.getKnEmployee();
|
||||
String actual = nullEmployeeInfo.getEmployee().getKnEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Nested
|
||||
static class GetMailAddressTest {
|
||||
@Test
|
||||
void getMailAddress_正常系_MailAddressの取得() {
|
||||
String expected = EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress();
|
||||
String actual = testEmployeeInfo.getEmployee().getMailAddress();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getMailAddress_正常系_MailAddressの取得結果がnull() {
|
||||
String expected = EmployeeEnum.NULL_EMPLOYEE.getMailAddress();
|
||||
String actual = nullEmployeeInfo.getEmployee().getMailAddress();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class GetPasswordTest {
|
||||
@Test
|
||||
void getPassword_正常系_Passwordの取得() {
|
||||
String expected = EmployeeEnum.ADMIN_EMPLOYEE.getPassword();
|
||||
String actual = testEmployeeInfo.getEmployee().getPassword();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getPassword_正常系_Passwordの取得結果がnull() {
|
||||
String expected = EmployeeEnum.NULL_EMPLOYEE.getPassword();
|
||||
String actual = nullEmployeeInfo.getEmployee().getPassword();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class GetAdminAuthTest {
|
||||
@Test
|
||||
void getAdminAuth_正常系_AdminAuthの取得() {
|
||||
Integer expected = EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth();
|
||||
Integer actual = testEmployeeInfo.getEmployee().getAdminAuth();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getAdminAuth_正常系_AdminAuthの取得結果がnull() {
|
||||
Integer expected = EmployeeEnum.NULL_EMPLOYEE.getAdminAuth();
|
||||
Integer actual = nullEmployeeInfo.getEmployee().getAdminAuth();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class GetIdDepartmentTest {
|
||||
@Test
|
||||
void getIdDepartment_正常系_IdDepartmentの取得() {
|
||||
Integer expected = DepartmentEnum.TEST_DEPARTMENT.getIdDepartment();
|
||||
Integer actual = testEmployeeInfo.getDepartment().getIdDepartment();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getIdDepartment_正常系_IdDepartmentの取得結果がnull() {
|
||||
Integer expected = DepartmentEnum.NULL_DEPARTMENT.getIdDepartment();
|
||||
Integer actual = nullEmployeeInfo.getDepartment().getIdDepartment();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class GetNmDepartmentTest {
|
||||
@Test
|
||||
void getNmDepartment_正常系_NmDepartmentの取得() {
|
||||
String expected = DepartmentEnum.TEST_DEPARTMENT.getNmDepartment();
|
||||
String actual = testEmployeeInfo.getDepartment().getNmDepartment();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getNmDepartment_正常系_NmDepartmentの取得結果がnull() {
|
||||
String expected = DepartmentEnum.NULL_DEPARTMENT.getNmDepartment();
|
||||
String actual = nullEmployeeInfo.getDepartment().getNmDepartment();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package com.example.rhizome.app.domain.model;
|
||||
|
||||
import com.example.rhizome.app.infra.record.EmployeeEnum;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
class EmployeeSearchTest {
|
||||
|
||||
static SearchConditionEmployee testSearchConditionEmployee = new SearchConditionEmployee(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdDepartment()
|
||||
);
|
||||
|
||||
static SearchConditionEmployee nullSearchConditionEmployee = new SearchConditionEmployee(
|
||||
EmployeeEnum.NULL_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.NULL_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.NULL_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.NULL_EMPLOYEE.getMailAddress(),
|
||||
EmployeeEnum.NULL_EMPLOYEE.getIdDepartment()
|
||||
);
|
||||
|
||||
@Nested
|
||||
static class getIdEmployeeTest {
|
||||
@Test
|
||||
void getIdEmployee_正常系_IdEmployeeの取得() {
|
||||
Integer expected = EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee();
|
||||
Integer actual = testSearchConditionEmployee.getIdEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getIdEmployee_正常系_IdEmployeeの取得結果がnull() {
|
||||
Integer expected = EmployeeEnum.NULL_EMPLOYEE.getIdEmployee();
|
||||
Integer actual = nullSearchConditionEmployee.getIdEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class getNmEmployeeTest {
|
||||
@Test
|
||||
void getNmEmployee_正常系_NmEmployeeの取得() {
|
||||
String expected = EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee();
|
||||
String actual = testSearchConditionEmployee.getNmEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getNmEmployee_正常系_NmEmployeeの取得結果がnull() {
|
||||
String expected = EmployeeEnum.NULL_EMPLOYEE.getNmEmployee();
|
||||
String actual = nullSearchConditionEmployee.getNmEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class GetKnEmployeeTest {
|
||||
@Test
|
||||
void getKnEmployee_正常系_KnEmployeeの取得() {
|
||||
String expected = EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee();
|
||||
String actual = testSearchConditionEmployee.getKnEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getKnEmployee_正常系_KnEmployeeの取得結果がnull() {
|
||||
String expected = EmployeeEnum.NULL_EMPLOYEE.getKnEmployee();
|
||||
String actual = nullSearchConditionEmployee.getKnEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class GetMailAddressTest {
|
||||
@Test
|
||||
void getMailAddress_正常系_MailAddressの取得() {
|
||||
String expected = EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress();
|
||||
String actual = testSearchConditionEmployee.getMailAddress();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getMailAddress_正常系_MailAddressの取得結果がnull() {
|
||||
String expected = EmployeeEnum.NULL_EMPLOYEE.getMailAddress();
|
||||
String actual = nullSearchConditionEmployee.getMailAddress();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class GetIdDepartmentTest {
|
||||
@Test
|
||||
void getIdDepartment_正常系_IdDepartmentの取得() {
|
||||
Integer expected = EmployeeEnum.ADMIN_EMPLOYEE.getIdDepartment();
|
||||
Integer actual = testSearchConditionEmployee.getIdDepartment();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getIdDepartment_正常系_IdDepartmentの取得結果がnull() {
|
||||
Integer expected = EmployeeEnum.NULL_EMPLOYEE.getIdDepartment();
|
||||
Integer actual = nullSearchConditionEmployee.getIdDepartment();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
package com.example.rhizome.app.domain.model;
|
||||
|
||||
import com.example.rhizome.app.infra.record.EmployeeEnum;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
class EmployeeTest {
|
||||
|
||||
final static Employee employeeTest = new Employee(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getPassword(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdDepartment()
|
||||
);
|
||||
|
||||
final static Employee employeeNull = new Employee(
|
||||
EmployeeEnum.NULL_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.NULL_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.NULL_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.NULL_EMPLOYEE.getMailAddress(),
|
||||
EmployeeEnum.NULL_EMPLOYEE.getPassword(),
|
||||
EmployeeEnum.NULL_EMPLOYEE.getAdminAuth(),
|
||||
EmployeeEnum.NULL_EMPLOYEE.getIdDepartment()
|
||||
);
|
||||
|
||||
@Nested
|
||||
static class getIdEmployeeTest {
|
||||
@Test
|
||||
void getIdEmployee_正常系_IdEmployeeの取得() {
|
||||
Integer expected = EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee();
|
||||
Integer actual = employeeTest.getIdEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getIdEmployee_正常系_IdEmployeeの取得結果がnull() {
|
||||
Integer expected = EmployeeEnum.NULL_EMPLOYEE.getIdEmployee();
|
||||
Integer actual = employeeNull.getIdEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class getNmEmployeeTest {
|
||||
@Test
|
||||
void getNmEmployee_正常系_NmEmployeeの取得() {
|
||||
String expected = EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee();
|
||||
String actual = employeeTest.getNmEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getNmEmployee_正常系_NmEmployeeの取得結果がnull() {
|
||||
String expected = EmployeeEnum.NULL_EMPLOYEE.getNmEmployee();
|
||||
String actual = employeeNull.getNmEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class GetKnEmployeeTest {
|
||||
@Test
|
||||
void getKnEmployee_正常系_KnEmployeeの取得() {
|
||||
String expected = EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee();
|
||||
String actual = employeeTest.getKnEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getKnEmployee_正常系_KnEmployeeの取得結果がnull() {
|
||||
String expected = EmployeeEnum.NULL_EMPLOYEE.getKnEmployee();
|
||||
String actual = employeeNull.getKnEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Nested
|
||||
static class GetMailAddressTest {
|
||||
@Test
|
||||
void getMailAddress_正常系_MailAddressの取得() {
|
||||
String expected = EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress();
|
||||
String actual = employeeTest.getMailAddress();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getMailAddress_正常系_MailAddressの取得結果がnull() {
|
||||
String expected = EmployeeEnum.NULL_EMPLOYEE.getMailAddress();
|
||||
String actual = employeeNull.getMailAddress();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class GetPasswordTest {
|
||||
@Test
|
||||
void getPassword_正常系_Passwordの取得() {
|
||||
String expected = EmployeeEnum.ADMIN_EMPLOYEE.getPassword();
|
||||
String actual = employeeTest.getPassword();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getPassword_正常系_Passwordの取得結果がnull() {
|
||||
String expected = EmployeeEnum.NULL_EMPLOYEE.getPassword();
|
||||
String actual = employeeNull.getPassword();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class GetAdminAuthTest {
|
||||
@Test
|
||||
void getAdminAuth_正常系_AdminAuthの取得() {
|
||||
Integer expected = EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth();
|
||||
Integer actual = employeeTest.getAdminAuth();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getAdminAuth_正常系_AdminAuthの取得結果がnull() {
|
||||
Integer expected = EmployeeEnum.NULL_EMPLOYEE.getAdminAuth();
|
||||
Integer actual = employeeNull.getAdminAuth();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class GetIdDepartmentTest {
|
||||
@Test
|
||||
void getIdDepartment_正常系_IdDepartmentの取得() {
|
||||
Integer expected = EmployeeEnum.ADMIN_EMPLOYEE.getIdDepartment();
|
||||
Integer actual = employeeTest.getIdDepartment();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getIdDepartment_正常系_IdDepartmentの取得結果がnull() {
|
||||
Integer expected = EmployeeEnum.NULL_EMPLOYEE.getIdDepartment();
|
||||
Integer actual = employeeNull.getIdDepartment();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.example.rhizome.app.domain.model;
|
||||
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
class LoginInfoTest {
|
||||
|
||||
static LoginInfo testLoginInfo = new LoginInfo("aaa", "bbb");
|
||||
static LoginInfo nullLoginInfo = new LoginInfo(null, null);
|
||||
|
||||
@Nested
|
||||
static class GetMailAddressTest {
|
||||
@Test
|
||||
void getMailAddress_正常系_MailAddressの取得() {
|
||||
String expected = "aaa";
|
||||
String actual = testLoginInfo.getMailAddress();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getMailAddress_正常系_MailAddressの取得結果がnull() {
|
||||
String expected = null;
|
||||
String actual = nullLoginInfo.getMailAddress();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class GetPasswordTest {
|
||||
@Test
|
||||
void getPassword_正常系_Passwordの取得() {
|
||||
String expected = "bbb";
|
||||
String actual = testLoginInfo.getPassword();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getPassword_正常系_Passwordの取得結果がnull() {
|
||||
String expected = null;
|
||||
String actual = nullLoginInfo.getPassword();
|
||||
;
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
package com.example.rhizome.app.domain.model;
|
||||
|
||||
import com.example.rhizome.app.infra.record.DepartmentEnum;
|
||||
import com.example.rhizome.app.infra.record.EmployeeEnum;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class LoginUserTest {
|
||||
|
||||
static LoginUser adminLoginUser = new LoginUser(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getPassword(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth(),
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getIdDepartment()
|
||||
);
|
||||
|
||||
static LoginUser normalLoginUser = new LoginUser(
|
||||
EmployeeEnum.NORMAL_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.NORMAL_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.NORMAL_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.NORMAL_EMPLOYEE.getMailAddress(),
|
||||
EmployeeEnum.NORMAL_EMPLOYEE.getPassword(),
|
||||
EmployeeEnum.NORMAL_EMPLOYEE.getAdminAuth(),
|
||||
EmployeeEnum.NORMAL_EMPLOYEE.getIdDepartment()
|
||||
);
|
||||
|
||||
static LoginUser nullLoginUser = new LoginUser(
|
||||
EmployeeEnum.NULL_EMPLOYEE.getIdEmployee(),
|
||||
EmployeeEnum.NULL_EMPLOYEE.getNmEmployee(),
|
||||
EmployeeEnum.NULL_EMPLOYEE.getKnEmployee(),
|
||||
EmployeeEnum.NULL_EMPLOYEE.getMailAddress(),
|
||||
EmployeeEnum.NULL_EMPLOYEE.getPassword(),
|
||||
EmployeeEnum.NULL_EMPLOYEE.getAdminAuth(),
|
||||
EmployeeEnum.NULL_EMPLOYEE.getIdDepartment()
|
||||
);
|
||||
|
||||
@Nested
|
||||
static class getIdEmployeeTest {
|
||||
@Test
|
||||
void getIdEmployee_正常系_IdEmployeeの取得() {
|
||||
Integer expected = EmployeeEnum.ADMIN_EMPLOYEE.getIdEmployee();
|
||||
Integer actual = adminLoginUser.getIdEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getIdEmployee_正常系_IdEmployeeの取得結果がnull() {
|
||||
Integer expected = EmployeeEnum.NULL_EMPLOYEE.getIdEmployee();
|
||||
Integer actual = nullLoginUser.getIdEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class getNmEmployeeTest {
|
||||
@Test
|
||||
void getNmEmployee_正常系_NmEmployeeの取得() {
|
||||
String expected = EmployeeEnum.ADMIN_EMPLOYEE.getNmEmployee();
|
||||
String actual = adminLoginUser.getNmEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getNmEmployee_正常系_NmEmployeeの取得結果がnull() {
|
||||
String expected = EmployeeEnum.NULL_EMPLOYEE.getNmEmployee();
|
||||
String actual = nullLoginUser.getNmEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class GetKnEmployeeTest {
|
||||
@Test
|
||||
void getKnEmployee_正常系_KnEmployeeの取得() {
|
||||
String expected = EmployeeEnum.ADMIN_EMPLOYEE.getKnEmployee();
|
||||
String actual = adminLoginUser.getKnEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getKnEmployee_正常系_KnEmployeeの取得結果がnull() {
|
||||
String expected = EmployeeEnum.NULL_EMPLOYEE.getKnEmployee();
|
||||
String actual = nullLoginUser.getKnEmployee();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class GetMailAddressTest {
|
||||
@Test
|
||||
void getMailAddress_正常系_MailAddressの取得() {
|
||||
String expected = EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress();
|
||||
String actual = adminLoginUser.getMailAddress();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getMailAddress_正常系_MailAddressの取得結果がnull() {
|
||||
String expected = EmployeeEnum.NULL_EMPLOYEE.getMailAddress();
|
||||
String actual = nullLoginUser.getMailAddress();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class GetPasswordTest {
|
||||
@Test
|
||||
void getPassword_正常系_Passwordの取得() {
|
||||
String expected = EmployeeEnum.ADMIN_EMPLOYEE.getPassword();
|
||||
String actual = adminLoginUser.getPassword();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getPassword_正常系_Passwordの取得結果がnull() {
|
||||
String expected = EmployeeEnum.NULL_EMPLOYEE.getPassword();
|
||||
String actual = nullLoginUser.getPassword();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class GetAdminAuthTest {
|
||||
@Test
|
||||
void getAdminAuth_正常系_AdminAuthの取得() {
|
||||
Integer expected = EmployeeEnum.ADMIN_EMPLOYEE.getAdminAuth();
|
||||
Integer actual = adminLoginUser.getAdminAuth();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getAdminAuth_正常系_AdminAuthの取得結果がnull() {
|
||||
Integer expected = EmployeeEnum.NULL_EMPLOYEE.getAdminAuth();
|
||||
Integer actual = nullLoginUser.getAdminAuth();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class GetIdDepartmentTest {
|
||||
@Test
|
||||
void getIdDepartment_正常系_IdDepartmentの取得() {
|
||||
Integer expected = DepartmentEnum.TEST_DEPARTMENT.getIdDepartment();
|
||||
Integer actual = adminLoginUser.getIdDepartment();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getIdDepartment_正常系_IdDepartmentの取得結果がnull() {
|
||||
Integer expected = DepartmentEnum.NULL_DEPARTMENT.getIdDepartment();
|
||||
Integer actual = nullLoginUser.getIdDepartment();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
static class IsAdminUserTest {
|
||||
@Test
|
||||
void isAdminUser_正常系_管理者である() {
|
||||
assertTrue(adminLoginUser.isAdminUser());
|
||||
}
|
||||
|
||||
@Test
|
||||
void isAdminUser_正常系_一般である() {
|
||||
assertFalse(normalLoginUser.isAdminUser());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.example.rhizome.app.domain.service.impl;
|
||||
|
||||
|
||||
import com.example.rhizome.app.domain.model.LoginUser;
|
||||
import com.example.rhizome.app.infra.record.LoginUserEnum;
|
||||
import com.example.rhizome.app.infra.repository.EmployeeRepository;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.ui.Model;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class DeleteEmployeeTest {
|
||||
|
||||
@Mock
|
||||
EmployeeRepository employeeRepository;
|
||||
|
||||
@Mock
|
||||
LoginUser loginUser;
|
||||
|
||||
@Mock
|
||||
Model model;
|
||||
|
||||
@InjectMocks
|
||||
DeleteEmployeeImpl deleteEmployeeImpl;
|
||||
|
||||
@Nested
|
||||
public class deleteExecTest {
|
||||
@Test
|
||||
public void deleteExec_正常系_アカウントの削除成功() {
|
||||
doNothing().when(employeeRepository).deleteById(any());
|
||||
deleteEmployeeImpl.deleteEmployee(LoginUserEnum.NORMAL_LOGIN_USER.getIdEmployee());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package com.example.rhizome.app.domain.service.impl;
|
||||
|
||||
import com.example.rhizome.app.domain.model.LoginInfo;
|
||||
import com.example.rhizome.app.domain.model.LoginUser;
|
||||
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||
import com.example.rhizome.app.infra.record.EmployeeEnum;
|
||||
import com.example.rhizome.app.infra.record.LoginUserEnum;
|
||||
import com.example.rhizome.app.infra.repository.EmployeeRepository;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class LoginImplTest {
|
||||
|
||||
@Mock
|
||||
EmployeeRepository employeeRepository;
|
||||
|
||||
@InjectMocks
|
||||
LoginImpl login;
|
||||
|
||||
@Nested
|
||||
class doLoginTest {
|
||||
@Test
|
||||
void doLogin_正常系_ログイン者情報取得() {
|
||||
when(employeeRepository.findByMailAddressAndPassword(anyString(), anyString()))
|
||||
.thenReturn(
|
||||
Optional.of(
|
||||
EmployeeEntity.convertFrom(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()
|
||||
)));
|
||||
|
||||
LoginUser actual = login.doLogin(new LoginInfo(EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(), EmployeeEnum.ADMIN_EMPLOYEE.getPassword()));
|
||||
LoginUser expected = LoginUserEnum.ADMIN_LOGIN_USER.getLoginUserInstance();
|
||||
|
||||
assertAll(
|
||||
() -> assertEquals(expected.getIdEmployee(), actual.getIdEmployee()),
|
||||
() -> assertEquals(expected.getNmEmployee(), actual.getNmEmployee()),
|
||||
() -> assertEquals(expected.getKnEmployee(), actual.getKnEmployee()),
|
||||
() -> assertEquals(expected.getMailAddress(), actual.getMailAddress()),
|
||||
() -> assertEquals(expected.getPassword(), actual.getPassword()),
|
||||
() -> assertEquals(expected.getAdminAuth(), actual.getAdminAuth()),
|
||||
() -> assertEquals(expected.getIdDepartment(), actual.getIdDepartment())
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void doLogin_正常系_ログイン者情報該当なし() {
|
||||
when(employeeRepository.findByMailAddressAndPassword(anyString(), anyString()))
|
||||
.thenReturn(Optional.empty());
|
||||
|
||||
|
||||
LoginUser actual = login.doLogin(new LoginInfo(EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(), EmployeeEnum.ADMIN_EMPLOYEE.getPassword()));
|
||||
|
||||
assertAll(
|
||||
() -> assertNull(actual.getIdEmployee()),
|
||||
() -> assertNull(actual.getNmEmployee()),
|
||||
() -> assertNull(actual.getKnEmployee()),
|
||||
() -> assertNull(actual.getMailAddress()),
|
||||
() -> assertNull(actual.getPassword()),
|
||||
() -> assertNull(actual.getAdminAuth()),
|
||||
() -> assertNull(actual.getIdDepartment())
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Nested
|
||||
class canLoginTest {
|
||||
@Test
|
||||
void canLogin_正常系_ログイン可能() {
|
||||
when(employeeRepository.findByMailAddressAndPassword(anyString(), anyString()))
|
||||
.thenReturn(
|
||||
Optional.of(
|
||||
EmployeeEntity.convertFrom(
|
||||
EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance()
|
||||
)));
|
||||
|
||||
boolean actual = login.canLogin(new LoginInfo(EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(), EmployeeEnum.ADMIN_EMPLOYEE.getPassword()));
|
||||
|
||||
assertTrue(actual);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void canLogin_正常系_ログイン不可() {
|
||||
when(employeeRepository.findByMailAddressAndPassword(anyString(), anyString()))
|
||||
.thenReturn(Optional.empty());
|
||||
|
||||
boolean actual = login.canLogin(new LoginInfo(EmployeeEnum.ADMIN_EMPLOYEE.getMailAddress(), EmployeeEnum.ADMIN_EMPLOYEE.getPassword()));
|
||||
|
||||
assertFalse(actual);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.example.rhizome.app.domain.service.impl;
|
||||
|
||||
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||
import com.example.rhizome.app.infra.record.EmployeeEnum;
|
||||
import com.example.rhizome.app.infra.repository.EmployeeRepository;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class RegisterEmployeeImplTest {
|
||||
|
||||
@InjectMocks
|
||||
RegisterEmployeeImpl registerEmployee;
|
||||
|
||||
@Mock
|
||||
EmployeeRepository employeeRepository;
|
||||
|
||||
@Nested
|
||||
class registerEmployeeTest {
|
||||
@Test
|
||||
void registerEmployee() {
|
||||
when(employeeRepository
|
||||
.save(EmployeeEntity
|
||||
.convertFrom(EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance())))
|
||||
.thenReturn((EmployeeEntity
|
||||
.convertFrom(EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance())));
|
||||
|
||||
registerEmployee
|
||||
.registerEmployee(EmployeeEnum.ADMIN_EMPLOYEE.getEmployeeInstance());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user