diff --git a/EM-System/pom.xml b/EM-System/pom.xml index 24be8c6..ede5bff 100644 --- a/EM-System/pom.xml +++ b/EM-System/pom.xml @@ -63,7 +63,7 @@ com.fasterxml.jackson.core jackson-databind - test + diff --git a/EM-System/src/main/java/com/example/rhizome/app/domain/model/AllDepartmentInfo.java b/EM-System/src/main/java/com/example/rhizome/app/domain/model/AllDepartmentInfo.java index a8a64a7..fbbcd90 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/domain/model/AllDepartmentInfo.java +++ b/EM-System/src/main/java/com/example/rhizome/app/domain/model/AllDepartmentInfo.java @@ -6,16 +6,16 @@ import lombok.Getter; @Getter @AllArgsConstructor public class AllDepartmentInfo { - /** - * 課情報 - */ - private final Division division; - /** - * 部情報 - */ - private final Department department; - /** - * 本部情報 - */ - private final Headquarters headquarters; + /** + * 課情報 + */ + private final Division division; + /** + * 部情報 + */ + private final Department department; + /** + * 本部情報 + */ + private final Headquarters headquarters; } diff --git a/EM-System/src/main/java/com/example/rhizome/app/domain/model/AllEmployeeInfo.java b/EM-System/src/main/java/com/example/rhizome/app/domain/model/AllEmployeeInfo.java index f128f8d..8723476 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/domain/model/AllEmployeeInfo.java +++ b/EM-System/src/main/java/com/example/rhizome/app/domain/model/AllEmployeeInfo.java @@ -3,23 +3,26 @@ package com.example.rhizome.app.domain.model; import lombok.AllArgsConstructor; import lombok.Getter; +/** + * 社員情報と全ての部署情報を表すモデルクラスです。 + */ @Getter @AllArgsConstructor public class AllEmployeeInfo { - /** - * 社員情報 - */ - private final Employee employee; - /** - * 課情報 - */ - private final Division division; - /** - * 部情報 - */ - private final Department department; - /** - * 本部情報 - */ - private final Headquarters headquarters; + /** + * 社員情報 + */ + private final Employee employee; + /** + * 課情報 + */ + private final Division division; + /** + * 部情報 + */ + private final Department department; + /** + * 本部情報 + */ + private final Headquarters headquarters; } diff --git a/EM-System/src/main/java/com/example/rhizome/app/domain/model/Department.java b/EM-System/src/main/java/com/example/rhizome/app/domain/model/Department.java index 9f9d0e1..27cf62a 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/domain/model/Department.java +++ b/EM-System/src/main/java/com/example/rhizome/app/domain/model/Department.java @@ -3,23 +3,27 @@ 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; - /** - * 表示・非表示フラグ - */ - private final Integer isDisplay; - /** - * 部ID - */ - private final Integer idHeadquarters; + * 部ID + */ + private final Integer idDepartment; + /** + * 部名 + */ + private final String nmDepartment; + /** + * 表示・非表示フラグ + */ + private final Integer isDisplay; + /** + * 部ID + */ + private final Integer idHeadquarters; } diff --git a/EM-System/src/main/java/com/example/rhizome/app/domain/model/DepartmentInfo.java b/EM-System/src/main/java/com/example/rhizome/app/domain/model/DepartmentInfo.java index 62f9e25..1d4e43c 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/domain/model/DepartmentInfo.java +++ b/EM-System/src/main/java/com/example/rhizome/app/domain/model/DepartmentInfo.java @@ -10,27 +10,27 @@ import lombok.Getter; @AllArgsConstructor public class DepartmentInfo { /** - * 本部ID - */ - private final Integer idHeadquarters; - /** - * 本部名 - */ - private final String nmHeadquarters; - /** - * 部ID - */ - private final Integer idDepartment; - /** - * 部名 - */ - private final String nmDepartment; - /** - * 課ID - */ - private final Integer idDivision; - /** - * 課名 - */ - private final String nmDivision; + * 本部ID + */ + private final Integer idHeadquarters; + /** + * 本部名 + */ + private final String nmHeadquarters; + /** + * 部ID + */ + private final Integer idDepartment; + /** + * 部名 + */ + private final String nmDepartment; + /** + * 課ID + */ + private final Integer idDivision; + /** + * 課名 + */ + private final String nmDivision; } diff --git a/EM-System/src/main/java/com/example/rhizome/app/domain/model/Division.java b/EM-System/src/main/java/com/example/rhizome/app/domain/model/Division.java index bab7c7e..8eeac2a 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/domain/model/Division.java +++ b/EM-System/src/main/java/com/example/rhizome/app/domain/model/Division.java @@ -9,20 +9,20 @@ import lombok.Getter; @Getter @AllArgsConstructor public class Division { - /** - * 課ID - */ - private final Integer idDivision; - /** - * 課名 - */ - private final String nmDivision; - /** - * 表示・非表示フラグ - */ - private final Integer isDisplay; - /** - * 部ID - */ - private final Integer idDepartment; + /** + * 課ID + */ + private final Integer idDivision; + /** + * 課名 + */ + private final String nmDivision; + /** + * 表示・非表示フラグ + */ + private final Integer isDisplay; + /** + * 部ID + */ + private final Integer idDepartment; } diff --git a/EM-System/src/main/java/com/example/rhizome/app/domain/model/Employee.java b/EM-System/src/main/java/com/example/rhizome/app/domain/model/Employee.java index a05d7bd..27c8560 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/domain/model/Employee.java +++ b/EM-System/src/main/java/com/example/rhizome/app/domain/model/Employee.java @@ -9,37 +9,37 @@ 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 String hireDate; - /** - * 管理者権限 - */ - private final Integer adminAuth; - /** - * 部署ID - */ - private final Integer idDivision; + /** + * 社員ID + */ + private final Integer idEmployee; + /** + * 社員名 + */ + private final String nmEmployee; + /** + * 社員名カナ + */ + private final String knEmployee; + /** + * メールアドレス + */ + private final String mailAddress; + /** + * パスワード + */ + private final String password; + /** + * 入社年月日 + */ + private final String hireDate; + /** + * 管理者権限 + */ + private final Integer adminAuth; + /** + * 部署ID + */ + private final Integer idDivision; } diff --git a/EM-System/src/main/java/com/example/rhizome/app/domain/model/EmployeeInfo.java b/EM-System/src/main/java/com/example/rhizome/app/domain/model/EmployeeInfo.java index c0738d1..3c4381c 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/domain/model/EmployeeInfo.java +++ b/EM-System/src/main/java/com/example/rhizome/app/domain/model/EmployeeInfo.java @@ -16,13 +16,13 @@ import lombok.Getter; @AllArgsConstructor public class EmployeeInfo { - /** - * 社員情報 - */ - private final Employee employee; - /** - * 課情報 - */ - private final Division division; - + /** + * 社員情報 + */ + private final Employee employee; + /** + * 課情報 + */ + private final Division division; + } diff --git a/EM-System/src/main/java/com/example/rhizome/app/domain/model/Headquarters.java b/EM-System/src/main/java/com/example/rhizome/app/domain/model/Headquarters.java index 54b2dc1..0d8ba6f 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/domain/model/Headquarters.java +++ b/EM-System/src/main/java/com/example/rhizome/app/domain/model/Headquarters.java @@ -10,15 +10,15 @@ import lombok.Getter; @AllArgsConstructor public class Headquarters { /** - * 本部ID - */ + * 本部ID + */ private final Integer idHeadquarters; /** - * 本部名 - */ + * 本部名 + */ private final String nmHeadquarters; /** - * 表示・非表示フラグ - */ + * 表示・非表示フラグ + */ private final Integer isDisplay; } diff --git a/EM-System/src/main/java/com/example/rhizome/app/domain/model/LoginInfo.java b/EM-System/src/main/java/com/example/rhizome/app/domain/model/LoginInfo.java index f694a54..2fe11e6 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/domain/model/LoginInfo.java +++ b/EM-System/src/main/java/com/example/rhizome/app/domain/model/LoginInfo.java @@ -10,13 +10,13 @@ import lombok.Getter; @Getter @AllArgsConstructor public class LoginInfo { - /** - * メールアドレス - */ - private String mailAddress; - /** - * パスワード - */ - private String password; + /** + * メールアドレス + */ + private String mailAddress; + /** + * パスワード + */ + private String password; } diff --git a/EM-System/src/main/java/com/example/rhizome/app/domain/model/LoginUser.java b/EM-System/src/main/java/com/example/rhizome/app/domain/model/LoginUser.java index 591610d..5fe4f21 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/domain/model/LoginUser.java +++ b/EM-System/src/main/java/com/example/rhizome/app/domain/model/LoginUser.java @@ -9,43 +9,43 @@ 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; + /** + * 社員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; + /** + * 管理者権限 + */ + private final Integer adminAuth; - /** - * 部署ID - */ - private final Integer idDivision; + /** + * 部署ID + */ + private final Integer idDivision; - /** - * ログインユーザが管理者か - * - * @return true:管理者 false:一般権限 - */ - public boolean isAdminUser() { - return getAdminAuth() == 1; - } + /** + * ログインユーザが管理者か + * + * @return true:管理者 false:一般権限 + */ + public boolean isAdminUser() { + return getAdminAuth() == 1; + } } diff --git a/EM-System/src/main/java/com/example/rhizome/app/domain/model/SearchConditionDepartment.java b/EM-System/src/main/java/com/example/rhizome/app/domain/model/SearchConditionDepartment.java index e285421..25e225d 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/domain/model/SearchConditionDepartment.java +++ b/EM-System/src/main/java/com/example/rhizome/app/domain/model/SearchConditionDepartment.java @@ -9,13 +9,13 @@ import lombok.Getter; @Getter @AllArgsConstructor public class SearchConditionDepartment { - /** - * ID - */ - private final Integer idDivision; - /** - * 名前 - */ - private final String nmDivision; + /** + * ID + */ + private final Integer idDivision; + /** + * 名前 + */ + private final String nmDivision; } diff --git a/EM-System/src/main/java/com/example/rhizome/app/domain/model/SearchConditionEmployee.java b/EM-System/src/main/java/com/example/rhizome/app/domain/model/SearchConditionEmployee.java index 06af4ae..7d30f55 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/domain/model/SearchConditionEmployee.java +++ b/EM-System/src/main/java/com/example/rhizome/app/domain/model/SearchConditionEmployee.java @@ -9,25 +9,25 @@ 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 idDivision; + /** + * 社員ID + */ + private final Integer idEmployee; + /** + * 社員名 + */ + private final String nmEmployee; + /** + * 社員名カナ + */ + private final String knEmployee; + /** + * メールアドレス + */ + private final String mailAddress; + /** + * 部署ID + */ + private final Integer idDivision; } diff --git a/EM-System/src/main/java/com/example/rhizome/app/domain/service/DeleteDepartment.java b/EM-System/src/main/java/com/example/rhizome/app/domain/service/DeleteDepartment.java index 1e0c03f..c0c0a0c 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/domain/service/DeleteDepartment.java +++ b/EM-System/src/main/java/com/example/rhizome/app/domain/service/DeleteDepartment.java @@ -1,6 +1,6 @@ package com.example.rhizome.app.domain.service; public interface DeleteDepartment { - void deleteDepartment(Integer idDivision); + void deleteDepartment(Integer idDivision); } diff --git a/EM-System/src/main/java/com/example/rhizome/app/domain/service/DeleteEmployee.java b/EM-System/src/main/java/com/example/rhizome/app/domain/service/DeleteEmployee.java index 50d102c..8f1003d 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/domain/service/DeleteEmployee.java +++ b/EM-System/src/main/java/com/example/rhizome/app/domain/service/DeleteEmployee.java @@ -1,6 +1,6 @@ package com.example.rhizome.app.domain.service; public interface DeleteEmployee { - void deleteEmployee(Integer idEmployee); + void deleteEmployee(Integer idEmployee); } diff --git a/EM-System/src/main/java/com/example/rhizome/app/domain/service/Login.java b/EM-System/src/main/java/com/example/rhizome/app/domain/service/Login.java index 7756d83..e6c0e9a 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/domain/service/Login.java +++ b/EM-System/src/main/java/com/example/rhizome/app/domain/service/Login.java @@ -4,7 +4,7 @@ import com.example.rhizome.app.domain.model.LoginInfo; import com.example.rhizome.app.domain.model.LoginUser; public interface Login { - LoginUser doLogin(LoginInfo loginInfo); + LoginUser doLogin(LoginInfo loginInfo); - boolean canLogin(LoginInfo loginInfo); + boolean canLogin(LoginInfo loginInfo); } diff --git a/EM-System/src/main/java/com/example/rhizome/app/domain/service/RegisterDepartment.java b/EM-System/src/main/java/com/example/rhizome/app/domain/service/RegisterDepartment.java index 3081bb1..20af15c 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/domain/service/RegisterDepartment.java +++ b/EM-System/src/main/java/com/example/rhizome/app/domain/service/RegisterDepartment.java @@ -3,5 +3,5 @@ package com.example.rhizome.app.domain.service; import com.example.rhizome.app.infra.entity.DivisionEntity; public interface RegisterDepartment { - void registerDepartment(DivisionEntity divisionEntity); + void registerDepartment(DivisionEntity divisionEntity); } diff --git a/EM-System/src/main/java/com/example/rhizome/app/domain/service/RegisterEmployee.java b/EM-System/src/main/java/com/example/rhizome/app/domain/service/RegisterEmployee.java index c4b1297..40ce399 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/domain/service/RegisterEmployee.java +++ b/EM-System/src/main/java/com/example/rhizome/app/domain/service/RegisterEmployee.java @@ -3,5 +3,5 @@ package com.example.rhizome.app.domain.service; import com.example.rhizome.app.domain.model.Employee; public interface RegisterEmployee { - void registerEmployee(Employee employee); + void registerEmployee(Employee employee); } diff --git a/EM-System/src/main/java/com/example/rhizome/app/domain/service/SearchDepartment.java b/EM-System/src/main/java/com/example/rhizome/app/domain/service/SearchDepartment.java index 5a72689..55b0d19 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/domain/service/SearchDepartment.java +++ b/EM-System/src/main/java/com/example/rhizome/app/domain/service/SearchDepartment.java @@ -9,30 +9,35 @@ import com.example.rhizome.app.domain.model.Headquarters; import com.example.rhizome.app.domain.model.SearchConditionDepartment; public interface SearchDepartment { - - List searchAllDepartmentTable(); - - List searchAllDepartmentTable(SearchConditionDepartment searchConditionDepartment); - - boolean searchAllDepartmentTable( - SearchConditionDepartment searchHeadquartersTable, - SearchConditionDepartment searchDepartmentTable, - SearchConditionDepartment searchDivisionTable); - - boolean searchAllDepartmentTable( - Integer idHeadquarters, - Integer idDepartment, - Integer idDivision); - List searchByHeadquarters(SearchConditionDepartment searchConditionDepartment); + List searchAllDepartmentTable(); + + List searchAllDepartmentTable(SearchConditionDepartment searchConditionDepartment); + + boolean searchAllDepartmentTable( + SearchConditionDepartment searchHeadquartersTable, + SearchConditionDepartment searchDepartmentTable, + SearchConditionDepartment searchDivisionTable); + + boolean searchAllDepartmentTable( + Integer idHeadquarters, + Integer idDepartment, + Integer idDivision); + + List searchByHeadquarters(SearchConditionDepartment searchConditionDepartment); + + List searchByDepartment(SearchConditionDepartment searchConditionDepartment); + + List searchByDivision(SearchConditionDepartment searchConditionDepartment); + + List searchByIdHeadquarters(Integer idHeadquarters); + + List searchByIdDepartment(Integer idDepartment); + + List searchHeadquartersByIdHeadquarters(Integer idHeadquarters); + + List searchDepartmentByIdDepartment(Integer idDepartment); + + List searchDivisionByIdDivision(Integer idDivision); - List searchByDepartment(SearchConditionDepartment searchConditionDepartment); - - List searchByDivision(SearchConditionDepartment searchConditionDepartment); - - ListsearchByIdHeadquarters(Integer idHeadquarters); - - ListsearchByIdDepartment(Integer idDepartment); - -// List searchByWithLike(SearchConditionDepartment searchConditionDepartment); } diff --git a/EM-System/src/main/java/com/example/rhizome/app/domain/service/SearchEmployee.java b/EM-System/src/main/java/com/example/rhizome/app/domain/service/SearchEmployee.java index d41696e..ff4e50d 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/domain/service/SearchEmployee.java +++ b/EM-System/src/main/java/com/example/rhizome/app/domain/service/SearchEmployee.java @@ -6,11 +6,11 @@ import com.example.rhizome.app.domain.model.Employee; import com.example.rhizome.app.domain.model.LoginUser; public interface SearchEmployee { - List searchEmployee(String mailAddress); + List searchEmployee(String mailAddress); - List searchEmployeeByIdDepartment(Integer idDivision); + List searchEmployeeByIdDepartment(Integer idDivision); - LoginUser searchLoginUser(String mailAddress); + LoginUser searchLoginUser(String mailAddress); - Employee searchEmployeeByIdEmployee(Integer idEmployee); + Employee searchEmployeeByIdEmployee(Integer idEmployee); } diff --git a/EM-System/src/main/java/com/example/rhizome/app/domain/service/SearchEmployeeInfo.java b/EM-System/src/main/java/com/example/rhizome/app/domain/service/SearchEmployeeInfo.java index 1c1698d..441efaa 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/domain/service/SearchEmployeeInfo.java +++ b/EM-System/src/main/java/com/example/rhizome/app/domain/service/SearchEmployeeInfo.java @@ -6,7 +6,7 @@ import com.example.rhizome.app.domain.model.AllEmployeeInfo; import com.example.rhizome.app.domain.model.SearchConditionEmployee; public interface SearchEmployeeInfo { - List selectAll(); + List selectAll(); - List searchBy(SearchConditionEmployee searchConditionEmployee); + List searchBy(SearchConditionEmployee searchConditionEmployee); } diff --git a/EM-System/src/main/java/com/example/rhizome/app/domain/service/UpdateDepartment.java b/EM-System/src/main/java/com/example/rhizome/app/domain/service/UpdateDepartment.java index b7f98f0..bcd5f3b 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/domain/service/UpdateDepartment.java +++ b/EM-System/src/main/java/com/example/rhizome/app/domain/service/UpdateDepartment.java @@ -3,6 +3,6 @@ package com.example.rhizome.app.domain.service; import com.example.rhizome.app.domain.model.DepartmentInfo; public interface UpdateDepartment { - void updateDepartment(DepartmentInfo departmentInfo); + void updateDepartment(DepartmentInfo departmentInfo); } diff --git a/EM-System/src/main/java/com/example/rhizome/app/domain/service/UpdateEmployee.java b/EM-System/src/main/java/com/example/rhizome/app/domain/service/UpdateEmployee.java index c857d4d..20dba6b 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/domain/service/UpdateEmployee.java +++ b/EM-System/src/main/java/com/example/rhizome/app/domain/service/UpdateEmployee.java @@ -3,6 +3,6 @@ package com.example.rhizome.app.domain.service; import com.example.rhizome.app.domain.model.Employee; public interface UpdateEmployee { - void updateEmployee(Employee beforeEmployee, Employee updateEmployee); + void updateEmployee(Employee beforeEmployee, Employee updateEmployee); } diff --git a/EM-System/src/main/java/com/example/rhizome/app/domain/service/impl/DeleteDepartmentImpl.java b/EM-System/src/main/java/com/example/rhizome/app/domain/service/impl/DeleteDepartmentImpl.java index 947a2b5..e2d985f 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/domain/service/impl/DeleteDepartmentImpl.java +++ b/EM-System/src/main/java/com/example/rhizome/app/domain/service/impl/DeleteDepartmentImpl.java @@ -19,7 +19,7 @@ public class DeleteDepartmentImpl implements DeleteDepartment { /** * コンストラクタ * - * @param departmentRepository DI対象 + * @param divisionRepository DI対象 */ @Autowired public DeleteDepartmentImpl(DivisionRepository divisionRepository) { @@ -28,12 +28,12 @@ public class DeleteDepartmentImpl implements DeleteDepartment { /** - * idDepartment を元に department データを削除 + * idDivision を元に division データを削除するメソッド * - * @param idDepartment 削除対象のidDepartment + * @param idDivision 削除対象のidDivision */ - public void deleteDepartment(Integer idDepartment) { - divisionRepository.deleteById(idDepartment); + public void deleteDepartment(Integer idDivision) { + divisionRepository.deleteByIdDivision(idDivision); } } diff --git a/EM-System/src/main/java/com/example/rhizome/app/domain/service/impl/DeleteEmployeeImpl.java b/EM-System/src/main/java/com/example/rhizome/app/domain/service/impl/DeleteEmployeeImpl.java index ca5a67a..80ce6a4 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/domain/service/impl/DeleteEmployeeImpl.java +++ b/EM-System/src/main/java/com/example/rhizome/app/domain/service/impl/DeleteEmployeeImpl.java @@ -1,11 +1,12 @@ 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; +import com.example.rhizome.app.domain.service.DeleteEmployee; +import com.example.rhizome.app.infra.repository.EmployeeRepository; + /** * Employee レコード削除関連の機能を持つサービス */ @@ -13,21 +14,20 @@ import org.springframework.transaction.annotation.Transactional; @Transactional public class DeleteEmployeeImpl implements DeleteEmployee { - EmployeeRepository employeeRepository; + EmployeeRepository employeeRepository; - @Autowired - public DeleteEmployeeImpl(EmployeeRepository employeeRepository) { - this.employeeRepository = employeeRepository; - } + @Autowired + public DeleteEmployeeImpl(EmployeeRepository employeeRepository) { + this.employeeRepository = employeeRepository; + } - - /** - * idEmployee を元に employee データを削除 - * - * @param idEmployee 削除対象のidEmployee - */ - public void deleteEmployee(Integer idEmployee) { - employeeRepository.deleteById(idEmployee); - } + /** + * idEmployee を元に employee データを削除するメソッド + * + * @param idEmployee 削除対象のidEmployee + */ + public void deleteEmployee(Integer idEmployee) { + employeeRepository.deleteById(idEmployee); + } } diff --git a/EM-System/src/main/java/com/example/rhizome/app/domain/service/impl/RegisterDepartmentImpl.java b/EM-System/src/main/java/com/example/rhizome/app/domain/service/impl/RegisterDepartmentImpl.java index 75693ee..64bf19a 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/domain/service/impl/RegisterDepartmentImpl.java +++ b/EM-System/src/main/java/com/example/rhizome/app/domain/service/impl/RegisterDepartmentImpl.java @@ -1,6 +1,5 @@ package com.example.rhizome.app.domain.service.impl; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -20,66 +19,66 @@ import com.example.rhizome.app.infra.repository.HeadquartersRepository; @Transactional public class RegisterDepartmentImpl implements RegisterDepartment { - DepartmentRepository departmentRepository; - DivisionRepository divisionRepository; - HeadquartersRepository headquartersRepository; - /** - * コンストラクタ - * - * @param departmentRepository DI対象 - */ - @Autowired - public RegisterDepartmentImpl(DepartmentRepository departmentRepository, - DivisionRepository divisionRepository, - HeadquartersRepository headquartersRepository) { - this.departmentRepository = departmentRepository; - this.divisionRepository = divisionRepository; - this.headquartersRepository = headquartersRepository; - } + DepartmentRepository departmentRepository; + DivisionRepository divisionRepository; + HeadquartersRepository headquartersRepository; - /** - * department インスタンスの内容を登録する - * - * @param department 登録対象のデータ - */ - public void registerDepartment(DivisionEntity divisionEntity) { - DepartmentEntity departmentEntity = divisionEntity.getDepartment(); - HeadquartersEntity headquartersEntity = divisionEntity.getDepartment().getHeadquarters(); - HeadquartersEntity originHeadquartersEntity = - headquartersRepository.findByNmHeadquarters( - divisionEntity.getDepartment().getHeadquarters().getNmHeadquarters()); - if(originHeadquartersEntity!=null){ - headquartersEntity=originHeadquartersEntity; - }else { - headquartersEntity = new HeadquartersEntity(); - headquartersEntity.setNmHeadquarters( - divisionEntity.getDepartment() - .getHeadquarters() - .getNmHeadquarters() - ); - } - - DepartmentEntity originDepartmentEntity = - departmentRepository.findByHeadquartersAndNmDepartment( - headquartersEntity, - divisionEntity.getDepartment().getNmDepartment()); - if(originDepartmentEntity!=null) { - departmentEntity=originDepartmentEntity; - }else { - departmentEntity = new DepartmentEntity(); - departmentEntity.setNmDepartment( - divisionEntity.getDepartment() - .getNmDepartment() - ); - } - - - divisionEntity.setIsDisplay(0); - departmentEntity.setIsDisplay(0); - headquartersEntity.setIsDisplay(0); - - departmentEntity.setHeadquarters(headquartersEntity); - divisionEntity.setDepartment(departmentEntity); - divisionRepository.save(divisionEntity); - } + /** + * コンストラクタ + * + * @param departmentRepository DI対象 + * @param divisionRepository DI対象 + * @param headquartersRepository DI対象 + */ + @Autowired + public RegisterDepartmentImpl(DepartmentRepository departmentRepository, + DivisionRepository divisionRepository, + HeadquartersRepository headquartersRepository) { + this.departmentRepository = departmentRepository; + this.divisionRepository = divisionRepository; + this.headquartersRepository = headquartersRepository; + } + + /** + * division,department,headquartersインスタンスの内容を登録する + * + * @param divisionEntity 登録対象のデータ + * @param departmentEntity 登録対象のデータ + * @param headquartersEntity 登録対象のデータ + */ + public void registerDepartment(DivisionEntity divisionEntity) { + DepartmentEntity departmentEntity = divisionEntity.getDepartment(); + HeadquartersEntity headquartersEntity = divisionEntity.getDepartment().getHeadquarters(); + HeadquartersEntity originHeadquartersEntity = headquartersRepository.findByNmHeadquarters( + divisionEntity.getDepartment().getHeadquarters().getNmHeadquarters()); + if (originHeadquartersEntity != null) { + headquartersEntity = originHeadquartersEntity; + } else { + headquartersEntity = new HeadquartersEntity(); + headquartersEntity.setNmHeadquarters( + divisionEntity.getDepartment() + .getHeadquarters() + .getNmHeadquarters()); + } + + DepartmentEntity originDepartmentEntity = departmentRepository.findByHeadquartersAndNmDepartment( + originHeadquartersEntity, + divisionEntity.getDepartment().getNmDepartment()); + if (originDepartmentEntity != null) { + departmentEntity = originDepartmentEntity; + } else { + departmentEntity = new DepartmentEntity(); + departmentEntity.setNmDepartment( + divisionEntity.getDepartment() + .getNmDepartment()); + } + + divisionEntity.setIsDisplay(0); + departmentEntity.setIsDisplay(0); + headquartersEntity.setIsDisplay(0); + + departmentEntity.setHeadquarters(headquartersEntity); + divisionEntity.setDepartment(departmentEntity); + divisionRepository.save(divisionEntity); + } } diff --git a/EM-System/src/main/java/com/example/rhizome/app/domain/service/impl/SearchDepartmentImpl.java b/EM-System/src/main/java/com/example/rhizome/app/domain/service/impl/SearchDepartmentImpl.java index eb4f739..b51e7c9 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/domain/service/impl/SearchDepartmentImpl.java +++ b/EM-System/src/main/java/com/example/rhizome/app/domain/service/impl/SearchDepartmentImpl.java @@ -1,6 +1,5 @@ package com.example.rhizome.app.domain.service.impl; - import java.util.List; import org.springframework.beans.factory.annotation.Autowired; @@ -23,6 +22,7 @@ import com.example.rhizome.app.infra.repository.DepartmentRepository; import com.example.rhizome.app.infra.repository.DivisionRepository; import com.example.rhizome.app.infra.repository.HeadquartersRepository; import com.example.rhizome.app.infra.repository.RegisterDepartmentRepository; +import com.example.rhizome.app.infra.repository.RegisterDivisionRepository; /** * 部署情報検索系の機能を集約させるサービスクラスです。 @@ -31,134 +31,217 @@ import com.example.rhizome.app.infra.repository.RegisterDepartmentRepository; @Transactional public class SearchDepartmentImpl implements SearchDepartment { DivisionRepository divisionRepository; - DepartmentRepository departmentRepository; - HeadquartersRepository headquartersRepository; - DepartmentInfoRepository departmentInfoRepository; - RegisterDepartmentRepository registerDepartmentRepository; - /** - * コンストラクタ - * - * @param departmentRepository DI対象 - */ - @Autowired - public SearchDepartmentImpl( - DepartmentRepository departmentRepository - ,DivisionRepository divisionRepository - ,HeadquartersRepository headquartersRepository - ,DepartmentInfoRepository departmentInfoRepository - ,RegisterDepartmentRepository registerDepartmentRepository) { - this.departmentRepository = departmentRepository; - this.divisionRepository = divisionRepository; - this.headquartersRepository = headquartersRepository; - this.departmentInfoRepository = departmentInfoRepository; - this.registerDepartmentRepository = registerDepartmentRepository; - } + DepartmentRepository departmentRepository; + HeadquartersRepository headquartersRepository; + DepartmentInfoRepository departmentInfoRepository; + RegisterDepartmentRepository registerDepartmentRepository; + RegisterDivisionRepository registerDivisionRepository; - /** - * 部署情報を全件取得する - * - * @return 取得した本部情報レコード全件 - */ - public ListsearchAllDepartmentTable(){ - return DepartmentInfoEntity.createDepartmentInfoList(departmentInfoRepository.searchAllDepartmentTable()); - } - - - - - public ListsearchAllDepartmentTable(SearchConditionDepartment searchConditionDepartment){ - return DepartmentInfoEntity.AfterSearchCreateDepartmentInfoList( - departmentInfoRepository.findAll(Specification - .where(DepartmentInfoRepository.idDivisionEqual(searchConditionDepartment.getIdDivision())) - .and(DepartmentInfoRepository.nmDivisionEqual(searchConditionDepartment.getNmDivision())) - ) - ); - } - public boolean searchAllDepartmentTable( - SearchConditionDepartment searchHeadquartersTable, - SearchConditionDepartment searchDepartmentTable, - SearchConditionDepartment searchDivisionTable){ - - if(departmentInfoRepository.searchAllDepartmentTable( + /** + * コンストラクタ + * + * @param divisionRepository DI対象 + * @param departmentRepository DI対象 + * @param headquartersRepository DI対象 + * @param departmentInfoRepository DI対象 + * @param RegisterDepartmentRepository DI対象 + * @param RegisterDivisionRepository DI対象 + */ + @Autowired + public SearchDepartmentImpl( + DepartmentRepository departmentRepository, DivisionRepository divisionRepository, + HeadquartersRepository headquartersRepository, DepartmentInfoRepository departmentInfoRepository, + RegisterDepartmentRepository registerDepartmentRepository, + RegisterDivisionRepository registerDivisionRepository) { + this.departmentRepository = departmentRepository; + this.divisionRepository = divisionRepository; + this.headquartersRepository = headquartersRepository; + this.departmentInfoRepository = departmentInfoRepository; + this.registerDepartmentRepository = registerDepartmentRepository; + this.registerDivisionRepository = registerDivisionRepository; + } + + /** + * 部署情報を全件取得する + * + * @return 取得した部署情報レコード全件 + */ + public List searchAllDepartmentTable() { + return DepartmentInfoEntity.createDepartmentInfoList(departmentInfoRepository.searchAllDepartmentTable()); + } + + /** + * 課の条件を基に部署情報を全件取得する + * @param SearchConditionDepartment 検索条件 + * @return 検索結果のレコード + */ + public List searchAllDepartmentTable(SearchConditionDepartment searchConditionDepartment) { + return DepartmentInfoEntity.AfterSearchCreateDepartmentInfoList( + departmentInfoRepository.findAll(Specification + .where(DepartmentInfoRepository.idDivisionEqual(searchConditionDepartment.getIdDivision())) + .and(DepartmentInfoRepository.nmDivisionEqual(searchConditionDepartment.getNmDivision())))); + } + + /** + * 三つの部署の名前を基に部署情報を取得する→重複チェック + * @param SearchConditionDepartment searchHeadquartersTable 検索条件 + * @param SearchConditionDepartment searchDepartmentTable 検索条件 + * @param SearchConditionDepartment searchDivisionTable 検索条件 + * @return 重複があればtrue + * @return 重複が無ければfalse + */ + public boolean searchAllDepartmentTable( + SearchConditionDepartment searchHeadquartersTable, + SearchConditionDepartment searchDepartmentTable, + SearchConditionDepartment searchDivisionTable) { + + if (departmentInfoRepository.searchAllDepartmentTable( searchHeadquartersTable.getNmDivision(), searchDepartmentTable.getNmDivision(), searchDivisionTable.getNmDivision()).isEmpty()) { - return false; - }else{ - return true; - } - } - - public boolean searchAllDepartmentTable( - Integer idHeadquarters, - Integer idDepartment, - Integer idDivision){ - - if(departmentInfoRepository.searchAllDepartmentTable( + return false; + } else { + return true; + } + } + + /** + * 三つの部署のIDを基に部署情報を取得する→重複チェック + * @param Integer idHeadquarters 検索条件 + * @param Integer idDepartment 検索条件 + * @param Integer idDivision 検索条件 + * @return 重複があればtrue + * @return 重複が無ければfalse + */ + public boolean searchAllDepartmentTable( + Integer idHeadquarters, + Integer idDepartment, + Integer idDivision) { + + if (departmentInfoRepository.searchAllDepartmentTable( idHeadquarters, idDepartment, idDivision).isEmpty()) { - return false; - }else{ - return true; - } - } - /** - * searchConditionDepartment の情報を元に Department のレコードを取得 - * - * @param searchConditionDepartment 検索条件 - * @return 検索結果のレコード - */ - public List searchByHeadquarters(SearchConditionDepartment searchConditionDepartment) { - - return HeadquartersEntity - .createHeadquartersList( - headquartersRepository.findAll(Specification - .where(HeadquartersRepository.idHeadquartersEqual(searchConditionDepartment.getIdDivision())) - .and(HeadquartersRepository.nmHeadquartersEqual(searchConditionDepartment.getNmDivision())) - ) - ); + return false; + } else { + return true; + } + } - } - public List searchByDepartment(SearchConditionDepartment searchConditionDepartment) { - // 動的に検索条件を絞り込む - // // Specification は Criteria API //の Predicate をラップしたもの - return DepartmentEntity - .createDepartmentList( - departmentRepository.findAll(Specification - .where(DepartmentRepository.idDepartmentEqual(searchConditionDepartment.getIdDivision())) - .and(DepartmentRepository.nmDepartmentEqual(searchConditionDepartment.getNmDivision())) - ) - ); + /** + * searchConditionDepartment の情報を元に Headquarters のレコードを取得 + * + * @param searchConditionDepartment 検索条件 + * @return 検索結果のレコード + */ + public List searchByHeadquarters(SearchConditionDepartment searchConditionDepartment) { - } - public List searchByDivision(SearchConditionDepartment searchConditionDepartment) { - // 動的に検索条件を絞り込む - // // Specification は Criteria AP//I の Predicate をラップしたもの - return DivisionEntity - .createDivisionList( - divisionRepository.findAll(Specification - .where(DivisionRepository.idDivisionEqual(searchConditionDepartment.getIdDivision())) - .and(DivisionRepository.nmDivisionEqual(searchConditionDepartment.getNmDivision())) - ) - ); + return HeadquartersEntity + .createHeadquartersList( + headquartersRepository.findAll(Specification + .where(HeadquartersRepository + .idHeadquartersEqual(searchConditionDepartment.getIdDivision())) + .and(HeadquartersRepository + .nmHeadquartersEqual(searchConditionDepartment.getNmDivision())))); - } - - public ListsearchByIdHeadquarters(Integer idHeadquarters){ - System.out.println("3"); - registerDepartmentRepository.findAll(Specification - .where(RegisterDepartmentRepository.idHeadquartersEqual(idHeadquarters))); - - System.out.println("SearchDepartmentImpl=>4"); - - return DepartmentEntity - .createDepartmentListBy(registerDepartmentRepository.findAll(Specification - .where(RegisterDepartmentRepository.idHeadquartersEqual(idHeadquarters)))); - } - public ListsearchByIdDepartment(Integer idDepartment){ - return DivisionEntity - .createDivisionList(divisionRepository.findAll(Specification - .where(DivisionRepository.idDepartmentEqual(idDepartment)))); - } + } + + /** + * searchConditionDepartment の情報を元に Department のレコードを取得 + * + * @param searchConditionDepartment 検索条件 + * @return 検索結果のレコード + */ + public List searchByDepartment(SearchConditionDepartment searchConditionDepartment) { + // 動的に検索条件を絞り込む + // // Specification は Criteria API //の Predicate をラップしたもの + return DepartmentEntity + .createDepartmentList( + departmentRepository.findAll(Specification + .where(DepartmentRepository + .idDepartmentEqual(searchConditionDepartment.getIdDivision())) + .and(DepartmentRepository + .nmDepartmentEqual(searchConditionDepartment.getNmDivision())))); + + } + + /** + * searchConditionDepartment の情報を元に Division のレコードを取得 + * + * @param searchConditionDepartment 検索条件 + * @return 検索結果のレコード + */ + public List searchByDivision(SearchConditionDepartment searchConditionDepartment) { + // 動的に検索条件を絞り込む + // // Specification は Criteria AP//I の Predicate をラップしたもの + return DivisionEntity + .createDivisionList( + divisionRepository.findAll(Specification + .where(DivisionRepository.idDivisionEqual(searchConditionDepartment.getIdDivision())) + .and(DivisionRepository.nmDivisionEqual(searchConditionDepartment.getNmDivision())))); + + } + + /** + * idHeadquarters の情報を元に Department のレコードを取得 + * + * @param Integer idHeadquarters 検索条件 + * @return 検索結果のレコード + */ + public List searchByIdHeadquarters(Integer idHeadquarters) { + registerDepartmentRepository.findAll(Specification + .where(RegisterDepartmentRepository.idHeadquartersEqual(idHeadquarters))); + + return DepartmentEntity + .createDepartmentListBy(registerDepartmentRepository.findAll(Specification + .where(RegisterDepartmentRepository.idHeadquartersEqual(idHeadquarters)))); + } + + /** + * idDepartment の情報を元に Division のレコードを取得 + * + * @param Integer idDepartment 検索条件 + * @return 検索結果のレコード + */ + public List searchByIdDepartment(Integer idDepartment) { + return DivisionEntity + .createRegisterDivisionList(registerDivisionRepository.findAll(Specification + .where(RegisterDivisionRepository.idDepartmentEqual(idDepartment)))); + } + + /** + * idHeadquarters の情報を元に Headquarters のレコードを取得 + * + * @param Integer idHeadquarters 検索条件 + * @return 検索結果のレコード + */ + public List searchHeadquartersByIdHeadquarters(Integer idHeadquarters) { + return HeadquartersEntity + .createHeadquartersList(headquartersRepository.findAll(Specification + .where(HeadquartersRepository.idHeadquartersEqual(idHeadquarters)))); + } + + /** + * idDepartment の情報を元に Department のレコードを取得 + * + * @param Integer idDepartment 検索条件 + * @return 検索結果のレコード + */ + public List searchDepartmentByIdDepartment(Integer idDepartment) { + return DepartmentEntity + .createDepartmentList(departmentRepository.findAll(Specification + .where(DepartmentRepository.idDepartmentEqual(idDepartment)))); + } + + /** + * idDivision の情報を元に Division のレコードを取得 + * + * @param Integer idDivision 検索条件 + * @return 検索結果のレコード + */ + public List searchDivisionByIdDivision(Integer idDivision) { + return DivisionEntity + .createDivisionList(divisionRepository.findAll(Specification + .where(DivisionRepository.idDivisionEqual(idDivision)))); + } } diff --git a/EM-System/src/main/java/com/example/rhizome/app/domain/service/impl/SearchEmployeeImpl.java b/EM-System/src/main/java/com/example/rhizome/app/domain/service/impl/SearchEmployeeImpl.java index 6dbbc14..73e41d8 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/domain/service/impl/SearchEmployeeImpl.java +++ b/EM-System/src/main/java/com/example/rhizome/app/domain/service/impl/SearchEmployeeImpl.java @@ -19,53 +19,52 @@ import com.example.rhizome.app.infra.repository.EmployeeRepository; @Transactional public class SearchEmployeeImpl implements SearchEmployee { - EmployeeRepository employeeRepository; + EmployeeRepository employeeRepository; - @Autowired - public SearchEmployeeImpl(EmployeeRepository employeeRepository) { - this.employeeRepository = employeeRepository; - } + @Autowired + public SearchEmployeeImpl(EmployeeRepository employeeRepository) { + this.employeeRepository = employeeRepository; + } + /** + * mailAddress を元に Employee Table を検索します。 + * + * @param mailAddress 検索対象の mailAddress + * @return Table から取得したレコードの情報 + */ + public List searchEmployee(String mailAddress) { + return EmployeeEntity.createEmployeeList(employeeRepository.findByMailAddress(mailAddress).stream().toList()); + } - /** - * mailAddress を元に Employee Table を検索します。 - * - * @param mailAddress 検索対象の mailAddress - * @return Table から取得したレコードの情報 - */ - public List 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(); + } - /** - * 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())); + } - /** - * 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 searchEmployeeByIdDepartment(Integer idDivision) { - return EmployeeEntity.createEmployeeList(employeeRepository.findByDivision_idDivision(idDivision)); - } + /** + * idDivision を元に Employee Table を検索します。 + * + * @param idDivision 本部ID + * @return Table から取得したレコードの情報 + */ + @Override + public List searchEmployeeByIdDepartment(Integer idDivision) { + return EmployeeEntity.createEmployeeList(employeeRepository.findByDivision_idDivision(idDivision)); + } } diff --git a/EM-System/src/main/java/com/example/rhizome/app/domain/service/impl/SearchEmployeeInfoImpl.java b/EM-System/src/main/java/com/example/rhizome/app/domain/service/impl/SearchEmployeeInfoImpl.java index e0a4cd0..6960baf 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/domain/service/impl/SearchEmployeeInfoImpl.java +++ b/EM-System/src/main/java/com/example/rhizome/app/domain/service/impl/SearchEmployeeInfoImpl.java @@ -20,45 +20,44 @@ import com.example.rhizome.app.infra.repository.EmployeeInfoRepository; @Transactional public class SearchEmployeeInfoImpl implements SearchEmployeeInfo { - EmployeeInfoRepository employeeInfoRepository; + EmployeeInfoRepository employeeInfoRepository; - @Autowired - public SearchEmployeeInfoImpl(EmployeeInfoRepository employeeInfoRepository) { - this.employeeInfoRepository = employeeInfoRepository; - } + @Autowired + public SearchEmployeeInfoImpl(EmployeeInfoRepository employeeInfoRepository) { + this.employeeInfoRepository = employeeInfoRepository; + } + /** + * EmployeeInfo (employee join division join department join headquarters) のレコードを全件取得 + * + * @return 取得したレコード全件 + */ + public List selectAll() { - /** - * EmployeeInfo (employee join department) のレコードを全件取得 - * - * @return 取得したレコード全件 - */ - public List selectAll() { + return EmployeeDepartmentEntity.createEmployeeInfoList(employeeInfoRepository.findAlltable()); - return EmployeeDepartmentEntity.createEmployeeInfoList(employeeInfoRepository.findAlltable()); + } - } + /** + * SearchConditionEmployee の情報を元に + * EmployeeInfo (employee join division join department join headquarters) + * のレコードを取得 + * + * @param searchConditionEmployee 検索条件 + * @return 検索結果のレコードリスト + */ + public List searchBy(SearchConditionEmployee searchConditionEmployee) { + // 動的に検索条件を絞り込む + // Specification は Criteria API の Predicate をラップしたもの - /** - * SearchConditionEmployee の情報を元に EmployeeInfo (employee join department) のレコードを取得 - * - * @param searchConditionEmployee 検索条件 - * @return 検索結果のレコードリスト - */ - public List searchBy(SearchConditionEmployee searchConditionEmployee) { - // 動的に検索条件を絞り込む - // Specification は Criteria API の Predicate をラップしたもの - - return EmployeeDepartmentEntity - .AfterSearchCreateEmployeeInfoList( - 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.idDivisionEqual(searchConditionEmployee.getIdDivision())) - ) - ); + return EmployeeDepartmentEntity + .AfterSearchCreateEmployeeInfoList( + 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.idDivisionEqual(searchConditionEmployee.getIdDivision())))); - } + } } diff --git a/EM-System/src/main/java/com/example/rhizome/app/domain/service/impl/TenureCalucImpl.java b/EM-System/src/main/java/com/example/rhizome/app/domain/service/impl/TenureCalucImpl.java index d452e00..415afc9 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/domain/service/impl/TenureCalucImpl.java +++ b/EM-System/src/main/java/com/example/rhizome/app/domain/service/impl/TenureCalucImpl.java @@ -6,21 +6,28 @@ import java.time.Period; import org.springframework.stereotype.Service; import com.example.rhizome.app.domain.service.TenureCalc; + @Service -public class TenureCalucImpl implements TenureCalc { - public String tenureCalc(String hireDate){ +public class TenureCalucImpl implements TenureCalc { + /** + * hireDate をもとに勤続年数を計算 + * + * @param String hireDate + * @return 計算結果の勤続年数 + */ + public String tenureCalc(String hireDate) { String tenure; LocalDate hiredate = LocalDate.parse(hireDate); LocalDate today = LocalDate.now(); Period period = Period.between(hiredate, today); - - if(period.getYears()<=0&&period.getMonths()<=0) { + + if (period.getYears() <= 0 && period.getMonths() <= 0) { tenure = "0年0ヶ月"; return tenure; - }else { - tenure=period.getYears()+"年"+period.getMonths()+"ヶ月"; + } else { + tenure = period.getYears() + "年" + period.getMonths() + "ヶ月"; return tenure; } - + } } diff --git a/EM-System/src/main/java/com/example/rhizome/app/domain/service/impl/UpdateDepartmentImpl.java b/EM-System/src/main/java/com/example/rhizome/app/domain/service/impl/UpdateDepartmentImpl.java index 2c1a17a..65de848 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/domain/service/impl/UpdateDepartmentImpl.java +++ b/EM-System/src/main/java/com/example/rhizome/app/domain/service/impl/UpdateDepartmentImpl.java @@ -18,38 +18,33 @@ import com.example.rhizome.app.infra.repository.DivisionRepository; @Transactional public class UpdateDepartmentImpl implements UpdateDepartment { - - DivisionRepository divisionRepository; - - @Autowired - public UpdateDepartmentImpl(DivisionRepository divisionRepository - ) { - this.divisionRepository = divisionRepository; - } + DivisionRepository divisionRepository; + + @Autowired + public UpdateDepartmentImpl(DivisionRepository divisionRepository) { + this.divisionRepository = divisionRepository; + } + + /** + * departmentInfo の情報を元に + * division table(division join department join headquarters) のレコードを更新する + * + * @param departmentInfo 更新のデータ + */ + public void updateDepartment(DepartmentInfo departmentInfo) { + DivisionEntity divisionEntity = DivisionEntity.convertFrom(departmentInfo); + DepartmentEntity departmentEntity = divisionEntity.getDepartment(); + HeadquartersEntity headquartersEntity = divisionEntity.getDepartment().getHeadquarters(); + departmentEntity.setNmDepartment( + divisionEntity.getDepartment() + .getNmDepartment()); + headquartersEntity.setNmHeadquarters( + divisionEntity.getDepartment() + .getHeadquarters() + .getNmHeadquarters()); + departmentEntity.setHeadquarters(headquartersEntity); + divisionEntity.setDepartment(departmentEntity); + divisionRepository.save(divisionEntity); + } - /** - * department の情報を元に department table のレコードを更新する - * - * @param department 更新のデータ - */ - public void updateDepartment(DepartmentInfo departmentInfo) { - DivisionEntity divisionEntity = DivisionEntity.convertFrom(departmentInfo); - DepartmentEntity departmentEntity = divisionEntity.getDepartment(); - HeadquartersEntity headquartersEntity = divisionEntity.getDepartment().getHeadquarters(); - departmentEntity.setNmDepartment( - divisionEntity.getDepartment() - .getNmDepartment() - ); - headquartersEntity.setNmHeadquarters( - divisionEntity.getDepartment() - .getHeadquarters() - .getNmHeadquarters() - ); - departmentEntity.setHeadquarters(headquartersEntity); - divisionEntity.setDepartment(departmentEntity); - divisionRepository.save(divisionEntity); - } - - - } diff --git a/EM-System/src/main/java/com/example/rhizome/app/domain/service/impl/UpdateEmployeeImpl.java b/EM-System/src/main/java/com/example/rhizome/app/domain/service/impl/UpdateEmployeeImpl.java index 5f46710..70b20f5 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/domain/service/impl/UpdateEmployeeImpl.java +++ b/EM-System/src/main/java/com/example/rhizome/app/domain/service/impl/UpdateEmployeeImpl.java @@ -16,47 +16,47 @@ import com.example.rhizome.app.infra.repository.EmployeeRepository; @Transactional public class UpdateEmployeeImpl implements UpdateEmployee { - EmployeeRepository employeeRepository; + EmployeeRepository employeeRepository; - @Autowired - public UpdateEmployeeImpl(EmployeeRepository employeeRepository) { - this.employeeRepository = employeeRepository; - } + @Autowired + public UpdateEmployeeImpl(EmployeeRepository employeeRepository) { + this.employeeRepository = employeeRepository; + } - /** - * employee の情報を元に employee table のレコードを更新する - * - * @param beforeEmployee 更新前のデータ - * @param updateEmployee 更新後のデータ - */ - public void updateEmployee(Employee beforeEmployee, Employee updateEmployee) { + /** + * employee の情報を元に employee table のレコードを更新する + * + * @param beforeEmployee 更新前のデータ + * @param updateEmployee 更新後のデータ + */ + public void updateEmployee(Employee beforeEmployee, Employee updateEmployee) { - employeeRepository.save(InsertEmployeeEntity.convertFrom(mergeEmployee(beforeEmployee, updateEmployee))); + employeeRepository.save(InsertEmployeeEntity.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.getHireDate(), - updateEmployee.getAdminAuth() == null ? beforeEmployee.getAdminAuth() : updateEmployee.getAdminAuth(), - updateEmployee.getIdDivision() == null ? beforeEmployee.getIdDivision() : updateEmployee.getIdDivision() - ); + /** + * 更新前のデータと更新対象のデータをマージする + * + * @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.getHireDate(), + updateEmployee.getAdminAuth() == null ? beforeEmployee.getAdminAuth() : updateEmployee.getAdminAuth(), + updateEmployee.getIdDivision() == null ? beforeEmployee.getIdDivision() + : updateEmployee.getIdDivision()); - } + } } diff --git a/EM-System/src/main/java/com/example/rhizome/app/infra/entity/DepartmentEntity.java b/EM-System/src/main/java/com/example/rhizome/app/infra/entity/DepartmentEntity.java index 1f021d1..df2ff62 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/infra/entity/DepartmentEntity.java +++ b/EM-System/src/main/java/com/example/rhizome/app/infra/entity/DepartmentEntity.java @@ -6,7 +6,6 @@ */ package com.example.rhizome.app.infra.entity; - import java.util.List; import javax.persistence.CascadeType; @@ -39,85 +38,87 @@ import lombok.NoArgsConstructor; @Data @NoArgsConstructor @AllArgsConstructor -//@NamedEntityGraph( -// name = "department_with_headquarters", -// includeAllAttributes = true -//) + 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; - /** - * 表示・非表示フラグ - */ - @Column(name = "is_display", nullable = false) - private Integer isDisplay; - - @ManyToOne(cascade = CascadeType.ALL) - @JoinColumn(name = "id_headquarters") - @Fetch(FetchMode.JOIN) - private HeadquartersEntity headquarters; - - /** - * DepartmentEntity(DataAccess層依存)から Department(BusinessLogic層依存型)に変換します。 - * - * @param departmentEntityList department Table のリスト - * @return List リスト - */ - public static List createDepartmentList(List departmentEntityList) { + /** + * 部ID + */ + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id_department", nullable = false) + private Integer idDepartment; + /** + * 部名 + */ + @Column(name = "nm_department", nullable = false) + private String nmDepartment; + /** + * 表示・非表示フラグ + */ + @Column(name = "is_display", nullable = false) + private Integer isDisplay; - // Stream API を利用するとこうなります。 - return departmentEntityList - .stream() - .map(departmentEntity -> new Department( - departmentEntity.getIdDepartment(), - departmentEntity.getNmDepartment(), - departmentEntity.getIsDisplay(), - departmentEntity.getHeadquarters() == null ? null : departmentEntity.getHeadquarters().getIdHeadquarters() - - )).toList(); - } + @ManyToOne(cascade = CascadeType.ALL) + @JoinColumn(name = "id_headquarters") + @Fetch(FetchMode.JOIN) + private HeadquartersEntity headquarters; - public static List createDepartmentListBy(List departmentEntityList) { + /** + * DepartmentEntity(DataAccess層依存)から Department(BusinessLogic層依存型)に変換します。(リスト版) + * + * @param departmentEntityList department Table のリスト + * @return List リスト + */ + public static List createDepartmentList(List departmentEntityList) { - // Stream API を利用するとこうなります。 - return departmentEntityList - .stream() - .map(departmentEntity -> new Department( - departmentEntity.getIdDepartment(), - departmentEntity.getNmDepartment(), - departmentEntity.getIsDisplay(), - departmentEntity.getIdHeadquarters() == null ? null : departmentEntity.getIdHeadquarters() - - )).toList(); - } + // Stream API を利用するとこうなります。 + return departmentEntityList + .stream() + .map(departmentEntity -> new Department( + departmentEntity.getIdDepartment(), + departmentEntity.getNmDepartment(), + departmentEntity.getIsDisplay(), + departmentEntity.getHeadquarters() == null ? null + : departmentEntity.getHeadquarters().getIdHeadquarters() - /** - * Department(BusinessLogic層依存型) から DepartmentEntity(DataAccess層依存)に変換します。 - * - * @param department department モデルの値 - * @return DepartmentEntity に変換したインスタンス - */ - public static DepartmentEntity convertFrom(DepartmentInfo departmentInfo) { - return new DepartmentEntity( - departmentInfo.getIdDepartment(), - departmentInfo.getNmDepartment(), - (Integer)0, - new HeadquartersEntity( - departmentInfo.getIdHeadquarters(), - departmentInfo.getNmHeadquarters(), - (Integer)0 - ) - ); -} + )).toList(); + } + + /** + * RegisterDepartmentEntity(DataAccess層依存)から Department(BusinessLogic層依存型)に変換します。(リスト版) + * + * @param departmentEntityList RegisterDepartmentEntity のリスト + * @return Departmentのリスト + */ + public static List createDepartmentListBy(List departmentEntityList) { + + // Stream API を利用するとこうなります。 + return departmentEntityList + .stream() + .map(departmentEntity -> new Department( + departmentEntity.getIdDepartment(), + departmentEntity.getNmDepartment(), + departmentEntity.getIsDisplay(), + departmentEntity.getIdHeadquarters() == null ? null : departmentEntity.getIdHeadquarters() + + )).toList(); + } + + /** + * DepartmentInfo から DepartmentEntity に変換します。 + * + * @param departmentInfo DepartmentInfo + * @return DepartmentEntity のインスタンス + */ + public static DepartmentEntity convertFrom(DepartmentInfo departmentInfo) { + return new DepartmentEntity( + departmentInfo.getIdDepartment(), + departmentInfo.getNmDepartment(), + (Integer) 0, + new HeadquartersEntity( + departmentInfo.getIdHeadquarters(), + departmentInfo.getNmHeadquarters(), + (Integer) 0)); + } } diff --git a/EM-System/src/main/java/com/example/rhizome/app/infra/entity/DepartmentInfoEntity.java b/EM-System/src/main/java/com/example/rhizome/app/infra/entity/DepartmentInfoEntity.java index 6cc30b6..a1234f3 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/infra/entity/DepartmentInfoEntity.java +++ b/EM-System/src/main/java/com/example/rhizome/app/infra/entity/DepartmentInfoEntity.java @@ -14,155 +14,152 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +/** + * Division join Department,Headquarters テーブルの Entity + * + */ @Data @AllArgsConstructor @NoArgsConstructor -@NamedEntityGraph( - name = "division_with_department_with_headquarters", - includeAllAttributes = true -) +@NamedEntityGraph(name = "division_with_department_with_headquarters", includeAllAttributes = true) public class DepartmentInfoEntity { - private DivisionEntity division; + private DivisionEntity division; - private DepartmentEntity department; + private DepartmentEntity department; - private HeadquartersEntity headquarters; + private HeadquartersEntity headquarters; - - public static DepartmentInfoEntity convertFrom(DepartmentInfo departmentInfo) { - return new DepartmentInfoEntity( - new DivisionEntity( - departmentInfo.getIdDivision(), - departmentInfo.getNmDivision(), - 0, - new DepartmentEntity( - departmentInfo.getIdDepartment(), - departmentInfo.getNmDepartment(), - 0, - new HeadquartersEntity( - departmentInfo.getIdHeadquarters(), - departmentInfo.getNmHeadquarters(), - 0 - ) - ) - ), - new DepartmentEntity( - departmentInfo.getIdDepartment(), - departmentInfo.getNmDepartment(), - 0, - new HeadquartersEntity( - departmentInfo.getIdHeadquarters(), - departmentInfo.getNmHeadquarters(), - 0 - ) - ), - new HeadquartersEntity( - departmentInfo.getIdHeadquarters(), - departmentInfo.getNmHeadquarters(), - 0 - ) - - ); - } - - /** - * EmployeeDepartmentEntity(DataAccess層依存) を EmployeeInfo(BusinessLogic層依存) に変換します。 - * - * @param employeeDepartmentEntity  EmployeeDepartmentEntity のインスタンス - * @return EmployeeInfo のインスタンス - */ - public static AllDepartmentInfo createDepartmentInfo(DepartmentInfoEntity departmentInfoEntity) { + /** + * DepartmentInfo をDepartmentInfoEntityに変換します。 + * + *@param departmentInfo DepartmentInfo のインスタンス + *@return DepartmentInfoEntityのインスタンス + */ + public static DepartmentInfoEntity convertFrom(DepartmentInfo departmentInfo) { + return new DepartmentInfoEntity( + new DivisionEntity( + departmentInfo.getIdDivision(), + departmentInfo.getNmDivision(), + 0, + new DepartmentEntity( + departmentInfo.getIdDepartment(), + departmentInfo.getNmDepartment(), + 0, + new HeadquartersEntity( + departmentInfo.getIdHeadquarters(), + departmentInfo.getNmHeadquarters(), + 0))), + new DepartmentEntity( + departmentInfo.getIdDepartment(), + departmentInfo.getNmDepartment(), + 0, + new HeadquartersEntity( + departmentInfo.getIdHeadquarters(), + departmentInfo.getNmHeadquarters(), + 0)), + new HeadquartersEntity( + departmentInfo.getIdHeadquarters(), + departmentInfo.getNmHeadquarters(), + 0) - // コンストラクタを使って書くとSetterを使用するより簡略化出来ます。 - // 混乱してしまう人は落ち着いて EmployeeInfo のフィールドを見に行って、 - // どうしてこの書き方が出来るのかを理解できる様になりましょう。 - return new AllDepartmentInfo( - new Division( - departmentInfoEntity.getDivision() - == null ? null : departmentInfoEntity.getDivision().getIdDivision(), - departmentInfoEntity.getDivision() - == null ? null : departmentInfoEntity.getDivision().getNmDivision(), - departmentInfoEntity.getDivision() - == null ? null : departmentInfoEntity.getDivision().getIsDisplay(), - departmentInfoEntity.getDepartment() - == null ? null : departmentInfoEntity.getDepartment().getIdDepartment() - ), - new Department( - departmentInfoEntity.getDepartment() - == null ? null : departmentInfoEntity.getDepartment().getIdDepartment(), - departmentInfoEntity.getDepartment() - == null ? null : departmentInfoEntity.getDepartment().getNmDepartment(), - departmentInfoEntity.getDepartment() - == null ? null : departmentInfoEntity.getDepartment().getIsDisplay(), - departmentInfoEntity.getHeadquarters() - == null ? null : departmentInfoEntity.getHeadquarters().getIdHeadquarters() - ), - new Headquarters( - departmentInfoEntity.getHeadquarters() - == null ? null : departmentInfoEntity.getHeadquarters().getIdHeadquarters(), - departmentInfoEntity.getHeadquarters() - == null ? null : departmentInfoEntity.getHeadquarters().getNmHeadquarters(), - departmentInfoEntity.getHeadquarters() - == null ? null : departmentInfoEntity.getHeadquarters().getIsDisplay() - ) - ); + ); + } - } + /** + * DepartmentInfoEntity を AllDepartmentInfo に変換します。 + * + * @param departmentInfoEntity  DepartmentInfoEntity のインスタンス + * @return AllDepartmentInfo のインスタンス + */ + public static AllDepartmentInfo createDepartmentInfo(DepartmentInfoEntity departmentInfoEntity) { - /** - * EmployeeDepartmentEntity(DataAccess層依存) を EmployeeInfo(BusinessLogic層依存) に変換します。 - * (リスト版) - * - * @param employeeDepartmentEntityList EmployeeDepartmentEntity インスタンスのリスト - * @return EmployeeInfo インスタンスのリスト - */ - public static List createDepartmentInfoList(List departmentInfoEntity) { + return new AllDepartmentInfo( + new Division( + departmentInfoEntity.getDivision() == null ? null + : departmentInfoEntity.getDivision().getIdDivision(), + departmentInfoEntity.getDivision() == null ? null + : departmentInfoEntity.getDivision().getNmDivision(), + departmentInfoEntity.getDivision() == null ? null + : departmentInfoEntity.getDivision().getIsDisplay(), + departmentInfoEntity.getDepartment() == null ? null + : departmentInfoEntity.getDepartment().getIdDepartment()), + new Department( + departmentInfoEntity.getDepartment() == null ? null + : departmentInfoEntity.getDepartment().getIdDepartment(), + departmentInfoEntity.getDepartment() == null ? null + : departmentInfoEntity.getDepartment().getNmDepartment(), + departmentInfoEntity.getDepartment() == null ? null + : departmentInfoEntity.getDepartment().getIsDisplay(), + departmentInfoEntity.getHeadquarters() == null ? null + : departmentInfoEntity.getHeadquarters().getIdHeadquarters()), + new Headquarters( + departmentInfoEntity.getHeadquarters() == null ? null + : departmentInfoEntity.getHeadquarters().getIdHeadquarters(), + departmentInfoEntity.getHeadquarters() == null ? null + : departmentInfoEntity.getHeadquarters().getNmHeadquarters(), + departmentInfoEntity.getHeadquarters() == null ? null + : departmentInfoEntity.getHeadquarters().getIsDisplay())); - // StreamAPI を使うとこうなります。 - return departmentInfoEntity.stream().map(DepartmentInfoEntity::createDepartmentInfo).toList(); + } - } + /** + * DepartmentInfoEntity を AllDepartmentInfo に変換します。 + * (リスト版) + * + * @param departmentInfoEntity DepartmentInfoEntity インスタンスのリスト + * @return AllDepartmentInfo インスタンスのリスト + */ + public static List createDepartmentInfoList(List departmentInfoEntity) { - - public static AllDepartmentInfo createDepartmentInfo(DivisionEntity divisionEntity) { + // StreamAPI を使うとこうなります。 + return departmentInfoEntity.stream().map(DepartmentInfoEntity::createDepartmentInfo).toList(); - // コンストラクタを使って書くとSetterを使用するより簡略化出来ます。 - // 混乱してしまう人は落ち着いて EmployeeInfo のフィールドを見に行って、 - // どうしてこの書き方が出来るのかを理解できる様になりましょう。 - return new AllDepartmentInfo( - new Division( - divisionEntity.getIdDivision(), - divisionEntity.getNmDivision(), - divisionEntity.getIsDisplay(), - divisionEntity.getDepartment().getIdDepartment() - ), - new Department( - divisionEntity.getDepartment() - == null ? null : divisionEntity.getDepartment().getIdDepartment(), - divisionEntity.getDepartment() - == null ? null : divisionEntity.getDepartment().getNmDepartment(), - divisionEntity.getDepartment() - == null ? null : divisionEntity.getDepartment().getIsDisplay(), - divisionEntity.getDepartment().getHeadquarters() - == null ? null : divisionEntity.getDepartment().getHeadquarters().getIdHeadquarters() - ), - new Headquarters( - divisionEntity.getDepartment().getHeadquarters() - == null ? null : divisionEntity.getDepartment().getHeadquarters().getIdHeadquarters(), - divisionEntity.getDepartment().getHeadquarters() - == null ? null : divisionEntity.getDepartment().getHeadquarters().getNmHeadquarters(), - divisionEntity.getDepartment().getHeadquarters() - == null ? null : divisionEntity.getDepartment().getHeadquarters().getIsDisplay() - ) - ); + } - } - public static List AfterSearchCreateDepartmentInfoList(List divisionEntity) { + /** + * DivisionEntity を AllDepartmentInfo に変換します。 + * + * @param divisionEntity DivisionEntity インスタンス + * @return AllDepartmentInfo インスタンス + */ + public static AllDepartmentInfo createDepartmentInfo(DivisionEntity divisionEntity) { - // StreamAPI を使うとこうなります。 - return divisionEntity.stream().map(DepartmentInfoEntity::createDepartmentInfo).toList(); + return new AllDepartmentInfo( + new Division( + divisionEntity.getIdDivision(), + divisionEntity.getNmDivision(), + divisionEntity.getIsDisplay(), + divisionEntity.getDepartment().getIdDepartment()), + new Department( + divisionEntity.getDepartment() == null ? null + : divisionEntity.getDepartment().getIdDepartment(), + divisionEntity.getDepartment() == null ? null + : divisionEntity.getDepartment().getNmDepartment(), + divisionEntity.getDepartment() == null ? null : divisionEntity.getDepartment().getIsDisplay(), + divisionEntity.getDepartment().getHeadquarters() == null ? null + : divisionEntity.getDepartment().getHeadquarters().getIdHeadquarters()), + new Headquarters( + divisionEntity.getDepartment().getHeadquarters() == null ? null + : divisionEntity.getDepartment().getHeadquarters().getIdHeadquarters(), + divisionEntity.getDepartment().getHeadquarters() == null ? null + : divisionEntity.getDepartment().getHeadquarters().getNmHeadquarters(), + divisionEntity.getDepartment().getHeadquarters() == null ? null + : divisionEntity.getDepartment().getHeadquarters().getIsDisplay())); - } + } + + /** + * DivisionEntity を AllDepartmentInfo に変換します。(リスト版) + * + * @param divisionEntity DivisionEntity インスタンスのリスト + * @return AllDepartmentInfo インスタンスのリスト + */ + public static List AfterSearchCreateDepartmentInfoList(List divisionEntity) { + + // StreamAPI を使うとこうなります。 + return divisionEntity.stream().map(DepartmentInfoEntity::createDepartmentInfo).toList(); + + } } diff --git a/EM-System/src/main/java/com/example/rhizome/app/infra/entity/DivisionEntity.java b/EM-System/src/main/java/com/example/rhizome/app/infra/entity/DivisionEntity.java index 97d6c18..4cc4b95 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/infra/entity/DivisionEntity.java +++ b/EM-System/src/main/java/com/example/rhizome/app/infra/entity/DivisionEntity.java @@ -21,82 +21,107 @@ import com.example.rhizome.app.domain.model.Division; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; - +/** + * Division テーブルの Entity + * + */ @Entity @Table(name = "division") @Data @NoArgsConstructor @AllArgsConstructor public class DivisionEntity { - /** - * 課ID - */ - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id_division", nullable = false) - private Integer idDivision; - /** - * 課名 - */ - @Column(name = "nm_division", nullable = false) - private String nmDivision; - /** - * 表示・非表示フラグ - */ - @Column(name = "is_display", nullable = false) - private Integer isDisplay; - - @ManyToOne(cascade = CascadeType.ALL) - @JoinColumn(name = "id_department") - @Fetch(FetchMode.JOIN) - private DepartmentEntity department; - - - - public static DivisionEntity convertFrom(DepartmentInfo departmentInfo) { - return new DivisionEntity( - departmentInfo.getIdDivision(), - departmentInfo.getNmDivision(), - (Integer)0, - new DepartmentEntity( - departmentInfo.getIdDepartment(), - departmentInfo.getNmDepartment(), - (Integer)0, - new HeadquartersEntity( - departmentInfo.getIdHeadquarters(), - departmentInfo.getNmHeadquarters(), - (Integer)0 - ) - ) - ); - } - - - public static Division createDivision(DivisionEntity divisionEntity) { - // 値を既に持ったインスタンスの生成に、コンストラクタを使用するとこうなります。 - return new Division( - divisionEntity.getIdDivision(), - divisionEntity.getNmDivision(), - divisionEntity.getIsDisplay(), - divisionEntity.getDepartment().getIdDepartment() - - ); - } - - - - public static List createDivisionList(List divisionEntityList) { + /** + * 課ID + */ + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id_division", nullable = false) + private Integer idDivision; + /** + * 課名 + */ + @Column(name = "nm_division", nullable = false) + private String nmDivision; + /** + * 表示・非表示フラグ + */ + @Column(name = "is_display", nullable = false) + private Integer isDisplay; - return divisionEntityList - .stream() - .map(DivisionEntity ::createDivision ).toList(); - } - + @ManyToOne(cascade = CascadeType.ALL) + @JoinColumn(name = "id_department") + @Fetch(FetchMode.JOIN) + private DepartmentEntity department; + + /** + * DepartmentInfo を DivisionEntity に変換します。 + * + * @param departmentInfo  DepartmentInfo のインスタンス + * @return DivisionEntity join Department,Headquarters のインスタンス + */ + public static DivisionEntity convertFrom(DepartmentInfo departmentInfo) { + return new DivisionEntity( + departmentInfo.getIdDivision(), + departmentInfo.getNmDivision(), + (Integer) 0, + new DepartmentEntity( + departmentInfo.getIdDepartment(), + departmentInfo.getNmDepartment(), + (Integer) 0, + new HeadquartersEntity( + departmentInfo.getIdHeadquarters(), + departmentInfo.getNmHeadquarters(), + (Integer) 0))); + } + + /** + * DivisionEntity を Divisionに変換します。 + * + * @param divisionEntity  DivisionEntity のインスタンス + * @return Divisionのインスタンス + */ + public static Division createDivision(DivisionEntity divisionEntity) { + // 値を既に持ったインスタンスの生成に、コンストラクタを使用するとこうなります。 + return new Division( + divisionEntity.getIdDivision(), + divisionEntity.getNmDivision(), + divisionEntity.getIsDisplay(), + divisionEntity.getDepartment().getIdDepartment() + + ); + } + + /** + * DivisionEntity を Divisionに変換します。(リスト版) + * + * @param divisionEntity  DivisionEntity のインスタンスのリスト + * @return Divisionのインスタンスのリスト + */ + public static List createDivisionList(List divisionEntityList) { + + return divisionEntityList + .stream() + .map(DivisionEntity::createDivision).toList(); + } + + /** + * RegisterDivisionEntity を Divisionに変換します。(リスト版) + * + * @param divisionEntityList  RegisterDivisionEntity のインスタンスのリスト + * @return Divisionのインスタンスのリスト + */ + public static List createRegisterDivisionList(List divisionEntityList) { + + return divisionEntityList + .stream() + .map(divisionEntity -> new Division( + divisionEntity.getIdDivision(), + divisionEntity.getNmDivision(), + divisionEntity.getIsDisplay(), + divisionEntity.getIdDepartment() == null ? null : divisionEntity.getIdDepartment() + + )).toList(); + } - - - - - - } diff --git a/EM-System/src/main/java/com/example/rhizome/app/infra/entity/EmployeeDepartmentEntity.java b/EM-System/src/main/java/com/example/rhizome/app/infra/entity/EmployeeDepartmentEntity.java index 3c4d86a..6410c9e 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/infra/entity/EmployeeDepartmentEntity.java +++ b/EM-System/src/main/java/com/example/rhizome/app/infra/entity/EmployeeDepartmentEntity.java @@ -15,149 +15,143 @@ import lombok.Data; import lombok.NoArgsConstructor; /** - * Employee + Department の Join 情報を保持するEntity + * Employee + Division + Department + Headquarters の Join 情報を保持するEntity * * @author IT-College */ @Data @AllArgsConstructor @NoArgsConstructor -@NamedEntityGraph( - name = "employee_with_division_with_department_with_headquarters", - includeAllAttributes = true -) +@NamedEntityGraph(name = "employee_with_division_with_department_with_headquarters", includeAllAttributes = true) public class EmployeeDepartmentEntity { - private EmployeeEntity Employee; + private EmployeeEntity Employee; - private DivisionEntity division; + private DivisionEntity division; - private DepartmentEntity department; + private DepartmentEntity department; - private HeadquartersEntity headquarters; + private HeadquartersEntity headquarters; - - /** - * EmployeeDepartmentEntity(DataAccess層依存) を EmployeeInfo(BusinessLogic層依存) に変換します。 - * - * @param employeeDepartmentEntity  EmployeeDepartmentEntity のインスタンス - * @return EmployeeInfo のインスタンス - */ - public static AllEmployeeInfo createEmployeeInfo(EmployeeDepartmentEntity employeeDepartmentEntity) { + /** + * EmployeeDepartmentEntity(DataAccess層依存) を AllEmployeeInfo(BusinessLogic層依存) に変換します。 + * + * @param employeeDepartmentEntity  EmployeeDepartmentEntity のインスタンス + * @return AllEmployeeInfo のインスタンス + */ + public static AllEmployeeInfo createEmployeeInfo(EmployeeDepartmentEntity employeeDepartmentEntity) { - // コンストラクタを使って書くとSetterを使用するより簡略化出来ます。 - // 混乱してしまう人は落ち着いて EmployeeInfo のフィールドを見に行って、 - // どうしてこの書き方が出来るのかを理解できる様になりましょう。 - return new AllEmployeeInfo( - new Employee( - employeeDepartmentEntity.getEmployee().getIdEmployee(), - employeeDepartmentEntity.getEmployee().getNmEmployee(), - employeeDepartmentEntity.getEmployee().getKnEmployee(), - employeeDepartmentEntity.getEmployee().getMailAddress(), - employeeDepartmentEntity.getEmployee().getPassword(), - employeeDepartmentEntity.getEmployee().getHireDate(), - employeeDepartmentEntity.getEmployee().getAdminAuth(), - employeeDepartmentEntity.getDivision() - == null ? null : employeeDepartmentEntity.getDivision().getIdDivision()), - new Division( - employeeDepartmentEntity.getDivision() - == null ? null : employeeDepartmentEntity.getDivision().getIdDivision(), - employeeDepartmentEntity.getDivision() - == null ? null : employeeDepartmentEntity.getDivision().getNmDivision(), - employeeDepartmentEntity.getDivision() - == null ? null : employeeDepartmentEntity.getDivision().getIsDisplay(), - employeeDepartmentEntity.getDepartment() - == null ? null : employeeDepartmentEntity.getDepartment().getIdDepartment() - ), - new Department( - employeeDepartmentEntity.getDepartment() - == null ? null : employeeDepartmentEntity.getDepartment().getIdDepartment(), - employeeDepartmentEntity.getDepartment() - == null ? null : employeeDepartmentEntity.getDepartment().getNmDepartment(), - employeeDepartmentEntity.getDepartment() - == null ? null : employeeDepartmentEntity.getDepartment().getIsDisplay(), - employeeDepartmentEntity.getHeadquarters() - == null ? null : employeeDepartmentEntity.getHeadquarters().getIdHeadquarters() - ), - new Headquarters( - employeeDepartmentEntity.getHeadquarters() - == null ? null : employeeDepartmentEntity.getHeadquarters().getIdHeadquarters(), - employeeDepartmentEntity.getHeadquarters() - == null ? null : employeeDepartmentEntity.getHeadquarters().getNmHeadquarters(), - employeeDepartmentEntity.getHeadquarters() - == null ? null : employeeDepartmentEntity.getHeadquarters().getIsDisplay() - ) - ); + // コンストラクタを使って書くとSetterを使用するより簡略化出来ます。 + // 混乱してしまう人は落ち着いて EmployeeInfo のフィールドを見に行って、 + // どうしてこの書き方が出来るのかを理解できる様になりましょう。 + return new AllEmployeeInfo( + new Employee( + employeeDepartmentEntity.getEmployee().getIdEmployee(), + employeeDepartmentEntity.getEmployee().getNmEmployee(), + employeeDepartmentEntity.getEmployee().getKnEmployee(), + employeeDepartmentEntity.getEmployee().getMailAddress(), + employeeDepartmentEntity.getEmployee().getPassword(), + employeeDepartmentEntity.getEmployee().getHireDate(), + employeeDepartmentEntity.getEmployee().getAdminAuth(), + employeeDepartmentEntity.getDivision() == null ? null + : employeeDepartmentEntity.getDivision().getIdDivision()), + new Division( + employeeDepartmentEntity.getDivision() == null ? null + : employeeDepartmentEntity.getDivision().getIdDivision(), + employeeDepartmentEntity.getDivision() == null ? null + : employeeDepartmentEntity.getDivision().getNmDivision(), + employeeDepartmentEntity.getDivision() == null ? null + : employeeDepartmentEntity.getDivision().getIsDisplay(), + employeeDepartmentEntity.getDepartment() == null ? null + : employeeDepartmentEntity.getDepartment().getIdDepartment()), + new Department( + employeeDepartmentEntity.getDepartment() == null ? null + : employeeDepartmentEntity.getDepartment().getIdDepartment(), + employeeDepartmentEntity.getDepartment() == null ? null + : employeeDepartmentEntity.getDepartment().getNmDepartment(), + employeeDepartmentEntity.getDepartment() == null ? null + : employeeDepartmentEntity.getDepartment().getIsDisplay(), + employeeDepartmentEntity.getHeadquarters() == null ? null + : employeeDepartmentEntity.getHeadquarters().getIdHeadquarters()), + new Headquarters( + employeeDepartmentEntity.getHeadquarters() == null ? null + : employeeDepartmentEntity.getHeadquarters().getIdHeadquarters(), + employeeDepartmentEntity.getHeadquarters() == null ? null + : employeeDepartmentEntity.getHeadquarters().getNmHeadquarters(), + employeeDepartmentEntity.getHeadquarters() == null ? null + : employeeDepartmentEntity.getHeadquarters().getIsDisplay())); - } + } - /** - * EmployeeDepartmentEntity(DataAccess層依存) を EmployeeInfo(BusinessLogic層依存) に変換します。 - * (リスト版) - * - * @param employeeDepartmentEntityList EmployeeDepartmentEntity インスタンスのリスト - * @return EmployeeInfo インスタンスのリスト - */ - public static List createEmployeeInfoList(List employeeDepartmentEntityList) { + /** + * EmployeeDepartmentEntity(DataAccess層依存) を AllEmployeeInfo(BusinessLogic層依存) に変換します。 + * (リスト版) + * + * @param employeeDepartmentEntityList EmployeeDepartmentEntity インスタンスのリスト + * @return AllEmployeeInfo インスタンスのリスト + */ + public static List createEmployeeInfoList( + List employeeDepartmentEntityList) { - // StreamAPI を使うとこうなります。 - return employeeDepartmentEntityList.stream().map(EmployeeDepartmentEntity::createEmployeeInfo).toList(); + // StreamAPI を使うとこうなります。 + return employeeDepartmentEntityList.stream().map(EmployeeDepartmentEntity::createEmployeeInfo).toList(); - } - - public static AllEmployeeInfo createEmployeeInfo(EmployeeEntity employeeEntity) { + } - // コンストラクタを使って書くとSetterを使用するより簡略化出来ます。 - // 混乱してしまう人は落ち着いて EmployeeInfo のフィールドを見に行って、 - // どうしてこの書き方が出来るのかを理解できる様になりましょう。 - return new AllEmployeeInfo( - new Employee( - employeeEntity.getIdEmployee(), - employeeEntity.getNmEmployee(), - employeeEntity.getKnEmployee(), - employeeEntity.getMailAddress(), - employeeEntity.getPassword(), - employeeEntity.getHireDate(), - employeeEntity.getAdminAuth(), - employeeEntity.getDivision() - == null ? null : employeeEntity.getDivision().getIdDivision()), - new Division( - employeeEntity.getDivision() - == null ? null : employeeEntity.getDivision().getIdDivision(), - employeeEntity.getDivision() - == null ? null : employeeEntity.getDivision().getNmDivision(), - employeeEntity.getDivision() - == null ? null : employeeEntity.getDivision().getIsDisplay(), - employeeEntity.getDivision().getDepartment() - == null ? null : employeeEntity.getDivision().getDepartment().getIdDepartment() - ), - new Department( - employeeEntity.getDivision().getDepartment() - == null ? null : employeeEntity.getDivision().getDepartment().getIdDepartment(), - employeeEntity.getDivision().getDepartment() - == null ? null : employeeEntity.getDivision().getDepartment().getNmDepartment(), - employeeEntity.getDivision().getDepartment() - == null ? null : employeeEntity.getDivision().getDepartment().getIsDisplay(), - employeeEntity.getDivision().getDepartment().getHeadquarters() - == null ? null : employeeEntity.getDivision().getDepartment().getHeadquarters().getIdHeadquarters() - ), - new Headquarters( - employeeEntity.getDivision().getDepartment().getHeadquarters() - == null ? null : employeeEntity.getDivision().getDepartment().getHeadquarters().getIdHeadquarters(), - employeeEntity.getDivision().getDepartment().getHeadquarters() - == null ? null : employeeEntity.getDivision().getDepartment().getHeadquarters().getNmHeadquarters(), - employeeEntity.getDivision().getDepartment().getHeadquarters() - == null ? null : employeeEntity.getDivision().getDepartment().getHeadquarters().getIsDisplay() - ) - ); + /** + * EmployeeEntity(DataAccess層依存) を AllEmployeeInfo(BusinessLogic層依存) に変換します。 + * + * @param employeeEntity  EmployeeEntity のインスタンス + * @return AllEmployeeInfo のインスタンス + */ + public static AllEmployeeInfo createEmployeeInfo(EmployeeEntity employeeEntity) { - } - - - public static List AfterSearchCreateEmployeeInfoList(List employeeEntityList) { + return new AllEmployeeInfo( + new Employee( + employeeEntity.getIdEmployee(), + employeeEntity.getNmEmployee(), + employeeEntity.getKnEmployee(), + employeeEntity.getMailAddress(), + employeeEntity.getPassword(), + employeeEntity.getHireDate(), + employeeEntity.getAdminAuth(), + employeeEntity.getDivision() == null ? null : employeeEntity.getDivision().getIdDivision()), + new Division( + employeeEntity.getDivision() == null ? null : employeeEntity.getDivision().getIdDivision(), + employeeEntity.getDivision() == null ? null : employeeEntity.getDivision().getNmDivision(), + employeeEntity.getDivision() == null ? null : employeeEntity.getDivision().getIsDisplay(), + employeeEntity.getDivision().getDepartment() == null ? null + : employeeEntity.getDivision().getDepartment().getIdDepartment()), + new Department( + employeeEntity.getDivision().getDepartment() == null ? null + : employeeEntity.getDivision().getDepartment().getIdDepartment(), + employeeEntity.getDivision().getDepartment() == null ? null + : employeeEntity.getDivision().getDepartment().getNmDepartment(), + employeeEntity.getDivision().getDepartment() == null ? null + : employeeEntity.getDivision().getDepartment().getIsDisplay(), + employeeEntity.getDivision().getDepartment().getHeadquarters() == null ? null + : employeeEntity.getDivision().getDepartment().getHeadquarters().getIdHeadquarters()), + new Headquarters( + employeeEntity.getDivision().getDepartment().getHeadquarters() == null ? null + : employeeEntity.getDivision().getDepartment().getHeadquarters().getIdHeadquarters(), + employeeEntity.getDivision().getDepartment().getHeadquarters() == null ? null + : employeeEntity.getDivision().getDepartment().getHeadquarters().getNmHeadquarters(), + employeeEntity.getDivision().getDepartment().getHeadquarters() == null ? null + : employeeEntity.getDivision().getDepartment().getHeadquarters().getIsDisplay())); - // StreamAPI を使うとこうなります。 - return employeeEntityList.stream().map(EmployeeDepartmentEntity::createEmployeeInfo).toList(); + } - } + /** + * EmployeeEntity(DataAccess層依存) を AllEmployeeInfo(BusinessLogic層依存) に変換します。(リスト版) + * + * @param employeeEntity  EmployeeEntity のインスタンスのリスト + * @return AllEmployeeInfo のインスタンスのリスト + */ + + public static List AfterSearchCreateEmployeeInfoList(List employeeEntityList) { + + // StreamAPI を使うとこうなります。 + return employeeEntityList.stream().map(EmployeeDepartmentEntity::createEmployeeInfo).toList(); + + } } diff --git a/EM-System/src/main/java/com/example/rhizome/app/infra/entity/EmployeeEntity.java b/EM-System/src/main/java/com/example/rhizome/app/infra/entity/EmployeeEntity.java index 7b0efab..787e417 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/infra/entity/EmployeeEntity.java +++ b/EM-System/src/main/java/com/example/rhizome/app/infra/entity/EmployeeEntity.java @@ -6,7 +6,6 @@ */ package com.example.rhizome.app.infra.entity; - import java.util.List; import javax.persistence.Column; @@ -33,7 +32,6 @@ import lombok.NoArgsConstructor; /** * EmployeeテーブルのEntity * - * @author IT-College */ @Entity @Table(name = "employee") @@ -42,159 +40,153 @@ import lombok.NoArgsConstructor; @AllArgsConstructor public class EmployeeEntity { - /** - * 社員ID - */ - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id_employee", nullable = false) - private Integer idEmployee; + /** + * 社員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 = "nm_employee", nullable = false) + private String nmEmployee; - /** - * 社員名カナ - */ - @Column(name = "kn_employee", nullable = false) - private String knEmployee; + /** + * 社員名カナ + */ + @Column(name = "kn_employee", nullable = false) + private String knEmployee; - /** - * メールアドレス - */ - @Column(name = "mail_address", nullable = false) - private String mailAddress; + /** + * メールアドレス + */ + @Column(name = "mail_address", nullable = false) + private String mailAddress; - /** - * パスワード - */ - @Column(name = "password", nullable = false) - private String password; + /** + * パスワード + */ + @Column(name = "password", nullable = false) + private String password; - /** - * 入社年月日 - */ - @Column(name = "hire_Date", nullable = false) - private String hireDate; - /** - * 管理者権限 - */ - @Column(name = "admin_auth", nullable = false) - private Integer adminAuth; + /** + * 入社年月日 + */ + @Column(name = "hire_Date", nullable = false) + private String hireDate; + /** + * 管理者権限 + */ + @Column(name = "admin_auth", nullable = false) + private Integer adminAuth; - /** - * 部署ID - */ - @ManyToOne - @JoinColumn(name = "id_division") - @Fetch(FetchMode.JOIN) - private DivisionEntity division; + /** + * 部署ID + */ + @ManyToOne + @JoinColumn(name = "id_division") + @Fetch(FetchMode.JOIN) + private DivisionEntity division; + /** + * EmployeeInfo(BusinessLogic 依存)を EmployeeEntity(DataAccess層依存)に変換します。 + * + * @param employeeInfo EmployeeInfo Table の中身 + * @return EmployeeEntity のインスタンス(1レコード分) + */ + public static EmployeeEntity convertFrom(EmployeeInfo employeeInfo) { + // 値を既に持ったインスタンスの生成に、コンストラクタを使用するとこうなります。 + return new EmployeeEntity( + employeeInfo.getEmployee().getIdEmployee(), + employeeInfo.getEmployee().getNmEmployee(), + employeeInfo.getEmployee().getKnEmployee(), + employeeInfo.getEmployee().getMailAddress(), + employeeInfo.getEmployee().getPassword(), + employeeInfo.getEmployee().getHireDate(), + employeeInfo.getEmployee().getAdminAuth(), + new DivisionEntity( + employeeInfo.getDivision().getIdDivision(), + employeeInfo.getDivision().getNmDivision(), + employeeInfo.getDivision().getIsDisplay(), + null)); + } - /** - * Employee(BusinessLogic 依存)を EmployeeEntity(DataAccess層依存)に変換します。 - * - * @param employee Employee Table の中身 - * @return EmployeeEntity のインスタンス(1レコード分) - */ - public static EmployeeEntity convertFrom(EmployeeInfo employeeInfo) { - // 値を既に持ったインスタンスの生成に、コンストラクタを使用するとこうなります。 - return new EmployeeEntity( - employeeInfo.getEmployee().getIdEmployee(), - employeeInfo.getEmployee().getNmEmployee(), - employeeInfo.getEmployee().getKnEmployee(), - employeeInfo.getEmployee().getMailAddress(), - employeeInfo.getEmployee().getPassword(), - employeeInfo.getEmployee().getHireDate(), - employeeInfo.getEmployee().getAdminAuth(), - new DivisionEntity( - employeeInfo.getDivision().getIdDivision(), - employeeInfo.getDivision().getNmDivision(), - employeeInfo.getDivision().getIsDisplay(), - null) - ); - } + /** + * SearchConditionEmployee(BusinessLogic 依存)を EmployeeEntity(DataAccess層依存)に変換します。 + * (コンストラクタを使用せず、Setterを利用したパターン) + * + * @param searchConditionEmployee 検索条件 + * @return EmployeeEntity のインスタンス(1レコード分) + */ + public static EmployeeEntity convertFrom(SearchConditionEmployee searchConditionEmployee) { + EmployeeEntity employeeEntity = new EmployeeEntity(); - /** - * 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.setIdEmployee(searchConditionEmployee.getIdEmployee()); - employeeEntity.setNmEmployee(searchConditionEmployee.getNmEmployee()); - employeeEntity.setKnEmployee(searchConditionEmployee.getKnEmployee()); - employeeEntity.setMailAddress(searchConditionEmployee.getMailAddress()); - - return employeeEntity; + 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.getHireDate(), - employeeEntity.getAdminAuth(), - employeeEntity.getDivision().getIdDivision() - ); - } + /** + * 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.getHireDate(), + employeeEntity.getAdminAuth(), + employeeEntity.getDivision().getIdDivision()); + } - /** - * EmployeeEntity(DataAccess層依存) から Employee (BusinessLogic層依存型)に変換します。(リスト版) - * - * @param employeeEntityList EmployeeEntity インスタンスのリスト - * @return Employee インスタンスのリスト - */ - public static List createEmployeeList(List employeeEntityList) { - /* 従来の書き方 - List employeeList = new ArrayList<>(); - for(EmployeeEntity employeeEntity:employeeEntityList){ - Employee employee = EmployeeEntity.createEmployee(employeeEntity); - employeeList.add(employee); - } - return employeeList; - */ + /** + * EmployeeEntity(DataAccess層依存) から Employee (BusinessLogic層依存型)に変換します。(リスト版) + * + * @param employeeEntityList EmployeeEntity インスタンスのリスト + * @return Employee インスタンスのリスト + */ + public static List createEmployeeList(List employeeEntityList) { + /* 従来の書き方 + List 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(); - } + // 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(), - getDivision().getIdDivision() - ); - } + /** + * EmployeeEntity(DataAccess層依存) から LoginUser (BusinessLogic層依存型)情報を作成します。 + * + * @return loginUser (ログイン者の情報) インスタンス + */ + public LoginUser createLoginUser() { + // 値を既に持ったインスタンスの生成に、コンストラクタを使用するとこうなります。 + return new LoginUser( + getIdEmployee(), + getNmEmployee(), + getKnEmployee(), + getMailAddress(), + getPassword(), + getAdminAuth(), + getDivision().getIdDivision()); + } - - } diff --git a/EM-System/src/main/java/com/example/rhizome/app/infra/entity/HeadquartersEntity.java b/EM-System/src/main/java/com/example/rhizome/app/infra/entity/HeadquartersEntity.java index 89384a4..a46b556 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/infra/entity/HeadquartersEntity.java +++ b/EM-System/src/main/java/com/example/rhizome/app/infra/entity/HeadquartersEntity.java @@ -16,6 +16,10 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +/** + * HeadquartersテーブルのEntity + * + */ @Entity @Table(name = "headquarters") @Data @@ -23,48 +27,55 @@ import lombok.NoArgsConstructor; @AllArgsConstructor public class HeadquartersEntity { /** - * 本部ID - */ - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id_headquarters", nullable = false) - private Integer idHeadquarters; - /** - * 本部名 - */ - @Column(name = "nm_headquarters", nullable = false) - private String nmHeadquarters; - /** - * 表示・非表示フラグ - */ - @Column(name = "is_display", nullable = false) - private Integer isDisplay; - - - - public static Headquarters createHeadquarters(HeadquartersEntity headquartersEntity) { - // 値を既に持ったインスタンスの生成に、コンストラクタを使用するとこうなります。 - return new Headquarters( - headquartersEntity.getIdHeadquarters(), - headquartersEntity.getNmHeadquarters(), - headquartersEntity.getIsDisplay() - ); - } - - - - public static List createHeadquartersList(List headquartersEntityList) { + * 本部ID + */ + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id_headquarters", nullable = false) + private Integer idHeadquarters; + /** + * 本部名 + */ + @Column(name = "nm_headquarters", nullable = false) + private String nmHeadquarters; + /** + * 表示・非表示フラグ + */ + @Column(name = "is_display", nullable = false) + private Integer isDisplay; - return headquartersEntityList - .stream() - .map(HeadquartersEntity ::createHeadquarters ).toList(); - } - - public static HeadquartersEntity convertFrom(DepartmentInfo departmentInfo) { - return new HeadquartersEntity( - departmentInfo.getIdHeadquarters(), - departmentInfo.getNmHeadquarters(), - (Integer)0 - ); - } + public static Headquarters createHeadquarters(HeadquartersEntity headquartersEntity) { + // 値を既に持ったインスタンスの生成に、コンストラクタを使用するとこうなります。 + return new Headquarters( + headquartersEntity.getIdHeadquarters(), + headquartersEntity.getNmHeadquarters(), + headquartersEntity.getIsDisplay()); + } + /** + * DBから返ってきたHeadquartersEntityのリストをHeadquartersのリストに変換する + * + * @param HeadquartersEntityのリスト + * @return headquartersのリスト + */ + public static List createHeadquartersList(List headquartersEntityList) { + + return headquartersEntityList + .stream() + .map(HeadquartersEntity::createHeadquarters).toList(); + } + + /** + * 三つのテーブルがつながった部署情報であるDepartmentInfoから + * 本部情報だけを引っ張ってきてHeadquartersEntityに入れる + * + * @param DepartmentInfo + * @return 新しく作成されたHeadquartersEntity + * + */ + public static HeadquartersEntity convertFrom(DepartmentInfo departmentInfo) { + return new HeadquartersEntity( + departmentInfo.getIdHeadquarters(), + departmentInfo.getNmHeadquarters(), + (Integer) 0); + } } diff --git a/EM-System/src/main/java/com/example/rhizome/app/infra/entity/InsertEmployeeEntity.java b/EM-System/src/main/java/com/example/rhizome/app/infra/entity/InsertEmployeeEntity.java index 3c2fce8..dbd708a 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/infra/entity/InsertEmployeeEntity.java +++ b/EM-System/src/main/java/com/example/rhizome/app/infra/entity/InsertEmployeeEntity.java @@ -14,9 +14,8 @@ import lombok.Data; import lombok.NoArgsConstructor; /** - * EmployeeテーブルのEntity + * 社員情報登録用のEmployeeテーブルのEntity * - * @author IT-College */ @Entity @Table(name = "employee") @@ -25,76 +24,73 @@ import lombok.NoArgsConstructor; @AllArgsConstructor public class InsertEmployeeEntity { - - /** - * 社員ID - */ - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id_employee", nullable = false) - private Integer idEmployee; + /** + * 社員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 = "nm_employee", nullable = false) + private String nmEmployee; - /** - * 社員名カナ - */ - @Column(name = "kn_employee", nullable = false) - private String knEmployee; + /** + * 社員名カナ + */ + @Column(name = "kn_employee", nullable = false) + private String knEmployee; - /** - * メールアドレス - */ - @Column(name = "mail_address", nullable = false) - private String mailAddress; + /** + * メールアドレス + */ + @Column(name = "mail_address", nullable = false) + private String mailAddress; - /** - * パスワード - */ - @Column(name = "password", nullable = false) - private String password; + /** + * パスワード + */ + @Column(name = "password", nullable = false) + private String password; - /** - * 入社年月日 - */ - @Column(name = "hire_Date", nullable = false) - private String hireDate; - /** - * 管理者権限 - */ - @Column(name = "admin_auth", nullable = false) - private Integer adminAuth; + /** + * 入社年月日 + */ + @Column(name = "hire_Date", nullable = false) + private String hireDate; + /** + * 管理者権限 + */ + @Column(name = "admin_auth", nullable = false) + private Integer adminAuth; - /** - * 部署ID - */ - @Column(name = "id_division", nullable = false) - private Integer idDivision; + /** + * 部署ID + */ + @Column(name = "id_division", nullable = false) + private Integer idDivision; + /** + * Employee(BusinessLogic 依存)を InsertEmployeeEntity(DataAccess層依存)に変換します。 + * + * @param employee Employee Table の中身 + * @return InsertEmployeeEntity のインスタンス(1レコード分) + */ + public static InsertEmployeeEntity convertFrom(Employee employee) { + // 値を既に持ったインスタンスの生成に、コンストラクタを使用するとこうなります。 + return new InsertEmployeeEntity( + employee.getIdEmployee(), + employee.getNmEmployee(), + employee.getKnEmployee(), + employee.getMailAddress(), + employee.getPassword(), + employee.getHireDate(), + employee.getAdminAuth(), + employee.getIdDivision()); + } - /** - * Employee(BusinessLogic 依存)を EmployeeEntity(DataAccess層依存)に変換します。 - * - * @param employee Employee Table の中身 - * @return EmployeeEntity のインスタンス(1レコード分) - */ - public static InsertEmployeeEntity convertFrom(Employee employee) { - // 値を既に持ったインスタンスの生成に、コンストラクタを使用するとこうなります。 - return new InsertEmployeeEntity( - employee.getIdEmployee(), - employee.getNmEmployee(), - employee.getKnEmployee(), - employee.getMailAddress(), - employee.getPassword(), - employee.getHireDate(), - employee.getAdminAuth(), - employee.getIdDivision() - ); - } - } diff --git a/EM-System/src/main/java/com/example/rhizome/app/infra/entity/RegisterDepartmentEntity.java b/EM-System/src/main/java/com/example/rhizome/app/infra/entity/RegisterDepartmentEntity.java index a35e32b..13136ab 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/infra/entity/RegisterDepartmentEntity.java +++ b/EM-System/src/main/java/com/example/rhizome/app/infra/entity/RegisterDepartmentEntity.java @@ -1,4 +1,5 @@ package com.example.rhizome.app.infra.entity; + import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -11,41 +12,36 @@ import lombok.Data; import lombok.NoArgsConstructor; /** - * Department テーブルの Entity + * 社員情報登録用のDepartment テーブルの Entity * - * @author IT-College */ @Entity @Table(name = "department") @Data @NoArgsConstructor @AllArgsConstructor -//@NamedEntityGraph( -// name = "department_with_headquarters", -// includeAllAttributes = true -//) + public class RegisterDepartmentEntity { - /** - * 部ID - */ - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id_department", nullable = false) - private Integer idDepartment; - /** - * 部名 - */ - @Column(name = "nm_department", nullable = false) - private String nmDepartment; - /** - * 表示・非表示フラグ - */ - @Column(name = "is_display", nullable = false) - private Integer isDisplay; - - @Column(name = "id_headquarters",nullable = false) - private Integer idHeadquarters; - + /** + * 部ID + */ + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id_department", nullable = false) + private Integer idDepartment; + /** + * 部名 + */ + @Column(name = "nm_department", nullable = false) + private String nmDepartment; + /** + * 表示・非表示フラグ + */ + @Column(name = "is_display", nullable = false) + private Integer isDisplay; + + @Column(name = "id_headquarters", nullable = false) + private Integer idHeadquarters; + } - diff --git a/EM-System/src/main/java/com/example/rhizome/app/infra/repository/DepartmentInfoRepository.java b/EM-System/src/main/java/com/example/rhizome/app/infra/repository/DepartmentInfoRepository.java index 40e4a7f..08f55da 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/infra/repository/DepartmentInfoRepository.java +++ b/EM-System/src/main/java/com/example/rhizome/app/infra/repository/DepartmentInfoRepository.java @@ -55,7 +55,6 @@ public interface DepartmentInfoRepository @EntityGraph(attributePaths = { "department", "department.headquarters" }) void save(@Nullable Specification spec); - @Query("SELECT DISTINCT new com.example.rhizome.app.infra.entity.DepartmentInfoEntity(di,de,h)FROM DivisionEntity di " + "INNER JOIN di.department de " @@ -68,7 +67,7 @@ public interface DepartmentInfoRepository @Param("nmHeadquarters") String nmHeadquarters, @Param("nmDepartment") String nmDepartment, @Param("nmDivision") String nmDivision); - + @Query("SELECT DISTINCT new com.example.rhizome.app.infra.entity.DepartmentInfoEntity(di,de,h)FROM DivisionEntity di " + "INNER JOIN di.department de " + "INNER JOIN de.headquarters h " @@ -80,7 +79,5 @@ public interface DepartmentInfoRepository @Param("idHeadquarters") Integer idHeadquarters, @Param("idDepartment") Integer idDepartment, @Param("idDivision") Integer idDivision); - - } \ No newline at end of file diff --git a/EM-System/src/main/java/com/example/rhizome/app/infra/repository/DepartmentRepository.java b/EM-System/src/main/java/com/example/rhizome/app/infra/repository/DepartmentRepository.java index a4d2359..c5a2556 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/infra/repository/DepartmentRepository.java +++ b/EM-System/src/main/java/com/example/rhizome/app/infra/repository/DepartmentRepository.java @@ -8,7 +8,6 @@ import org.springframework.stereotype.Repository; import com.example.rhizome.app.infra.entity.DepartmentEntity; import com.example.rhizome.app.infra.entity.HeadquartersEntity; - /** * Specification: * 関数型インターフェースです。 @@ -22,41 +21,30 @@ import com.example.rhizome.app.infra.entity.HeadquartersEntity; * 戻り値はクエリを格納しているPredicateオブジェクトとなります。 */ @Repository -public interface DepartmentRepository extends JpaRepository, JpaSpecificationExecutor { +public interface DepartmentRepository + extends JpaRepository, JpaSpecificationExecutor { + static Specification idDepartmentEqual(Integer idDepartment) { + return idDepartment == null ? null : + // 戻り値の型 Specification にキャスト + (Specification) + // ラムダ式で記載しているが書いてあることは criteriaBuilder を使って Where句の後の "'idDepartment' = idDepartment(変数)" + // を作成している + (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.equal(root.get("idDepartment"), idDepartment); + } - static Specification idDepartmentEqual(Integer idDepartment) { - return idDepartment == null ? - null : - // 戻り値の型 Specification にキャスト - (Specification) - // ラムダ式で記載しているが書いてあることは criteriaBuilder を使って Where句の後の "'idDepartment' = idDepartment(変数)" - // を作成している - (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.equal(root.get("idDepartment"), idDepartment); - } + static Specification nmDepartmentEqual(String nmDepartment) { + return (nmDepartment == null || nmDepartment.isEmpty()) ? null + : (Specification) (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder + .like(root.get("nmDepartment"), nmDepartment); + } - static Specification nmDepartmentEqual(String nmDepartment) { - return (nmDepartment == null || nmDepartment.isEmpty()) ? - null : - (Specification) - (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.like(root.get("nmDepartment"), nmDepartment); - } + static Specification nmDepartmentLike(String nmDepartment) { + return (nmDepartment == null || nmDepartment.isEmpty()) ? null + : (Specification) (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder + .like(root.get("nmDepartment"), "%" + nmDepartment + "%"); + } + DepartmentEntity findByHeadquartersAndNmDepartment(HeadquartersEntity headquartersEntity, String nmDepartment); - static Specification nmDepartmentLike(String nmDepartment) { - return (nmDepartment == null || nmDepartment.isEmpty()) ? - null : - (Specification) - (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.like(root.get("nmDepartment"), "%" + nmDepartment + "%"); - } - - - DepartmentEntity findByHeadquartersAndNmDepartment(HeadquartersEntity headquartersEntity,String nmDepartment); - -// @Query("SELECT DISTINCT new com.example.rhizome.app.infra.entity.DepartmentEntity(de,h)FROM DepartmentEntity de " -// + "INNER JOIN de.headquarters h " -// + "WHERE h.idHeadquarters =:idHeadquarters") -// List searchDepartmentByIdHeadquarters( -// @Param("idHeadquarters") Integer IdHeadquarters); - } diff --git a/EM-System/src/main/java/com/example/rhizome/app/infra/repository/DivisionRepository.java b/EM-System/src/main/java/com/example/rhizome/app/infra/repository/DivisionRepository.java index 34e8cc0..187cdad 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/infra/repository/DivisionRepository.java +++ b/EM-System/src/main/java/com/example/rhizome/app/infra/repository/DivisionRepository.java @@ -1,39 +1,48 @@ package com.example.rhizome.app.infra.repository; +import javax.transaction.Transactional; + import org.springframework.data.jpa.domain.Specification; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; import com.example.rhizome.app.infra.entity.DivisionEntity; @Repository -public interface DivisionRepository extends JpaRepository, JpaSpecificationExecutor{ - - static Specification idDivisionEqual(Integer idDivision) { - return idDivision == null ? - null : - // 戻り値の型 Specification にキャスト - (Specification) - // ラムダ式で記載しているが書いてあることは criteriaBuilder を使って Where句の後の "'idDepartment' = idDepartment(変数)" - // を作成している - (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.equal(root.get("idDivision"), idDivision); - } +public interface DivisionRepository + extends JpaRepository, JpaSpecificationExecutor { - static Specification nmDivisionEqual(String nmDivision) { - return (nmDivision == null || nmDivision.isEmpty()) ? - null : - (Specification) - (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.like(root.get("nmDivision"), nmDivision); - } - static Specification idDepartmentEqual(Integer idDepartment) { - return idDepartment == null ? - null : - // 戻り値の型 Specification にキャスト - (Specification) - // ラムダ式で記載しているが書いてあることは criteriaBuilder を使って Where句の後の "'idDepartment' = idDepartment(変数)" - // を作成している - (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.equal(root.get("idDepartment"), idDepartment); - } - + static Specification idDivisionEqual(Integer idDivision) { + return idDivision == null ? null : + // 戻り値の型 Specification にキャスト + (Specification) + // ラムダ式で記載しているが書いてあることは criteriaBuilder を使って Where句の後の "'idDepartment' = idDepartment(変数)" + // を作成している + (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.equal(root.get("idDivision"), idDivision); + } + + static Specification nmDivisionEqual(String nmDivision) { + return (nmDivision == null || nmDivision.isEmpty()) ? null + : (Specification) (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder + .like(root.get("nmDivision"), nmDivision); + } + + static Specification idDepartmentEqual(Integer idDepartment) { + return idDepartment == null ? null : + // 戻り値の型 Specification にキャスト + (Specification) + // ラムダ式で記載しているが書いてあることは criteriaBuilder を使って Where句の後の "'idDepartment' = idDepartment(変数)" + // を作成している + (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.equal(root.get("idDepartment"), idDepartment); + } + + @Transactional + @Modifying + @Query("DELETE FROM DivisionEntity di " + + "WHERE di.idDivision =:idDivision") + + void deleteByIdDivision(Integer idDivision); } diff --git a/EM-System/src/main/java/com/example/rhizome/app/infra/repository/EmployeeInfoRepository.java b/EM-System/src/main/java/com/example/rhizome/app/infra/repository/EmployeeInfoRepository.java index 3f09f16..110ebcd 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/infra/repository/EmployeeInfoRepository.java +++ b/EM-System/src/main/java/com/example/rhizome/app/infra/repository/EmployeeInfoRepository.java @@ -27,59 +27,48 @@ import com.example.rhizome.app.infra.entity.EmployeeEntity; * 戻り値はクエリを格納しているPredicateオブジェクトとなります。 */ @Repository -public interface EmployeeInfoRepository extends JpaRepository, JpaSpecificationExecutor { +public interface EmployeeInfoRepository + extends JpaRepository, JpaSpecificationExecutor { - static Specification idEmployeeEqual(Integer idEmployee) { - return idEmployee == null ? - null : - // 戻り値の型 Specification にキャスト - (Specification) - // ラムダ式で記載しているが書いてあることは criteriaBuilder を使って Where句の後の "'idEmployee' = idEmployee(変数)" - // を作成している - (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.equal(root.get("idEmployee"), idEmployee); - } + static Specification idEmployeeEqual(Integer idEmployee) { + return idEmployee == null ? null : + // 戻り値の型 Specification にキャスト + (Specification) + // ラムダ式で記載しているが書いてあることは criteriaBuilder を使って Where句の後の "'idEmployee' = idEmployee(変数)" + // を作成している + (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.equal(root.get("idEmployee"), idEmployee); + } - static Specification nmEmployeeEqual(String nmEmployee) { - return (nmEmployee == null || nmEmployee.isEmpty()) ? - null : - (Specification) - (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.like(root.get("nmEmployee"), "%" + nmEmployee + "%"); - } + static Specification nmEmployeeEqual(String nmEmployee) { + return (nmEmployee == null || nmEmployee.isEmpty()) ? null + : (Specification) (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder + .like(root.get("nmEmployee"), "%" + nmEmployee + "%"); + } - static Specification knEmployeeEqual(String knEmployee) { - return (knEmployee == null || knEmployee.isEmpty()) ? - null : - (Specification) - (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.like(root.get("knEmployee"), "%" + knEmployee + "%"); - } + static Specification knEmployeeEqual(String knEmployee) { + return (knEmployee == null || knEmployee.isEmpty()) ? null + : (Specification) (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder + .like(root.get("knEmployee"), "%" + knEmployee + "%"); + } - static Specification mailAddressEqual(String mailAddress) { - return (mailAddress == null || mailAddress.isEmpty()) ? - null : - (Specification) - (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.like(root.get("mailAddress"), "%" + mailAddress + "%"); - } + static Specification mailAddressEqual(String mailAddress) { + return (mailAddress == null || mailAddress.isEmpty()) ? null + : (Specification) (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder + .like(root.get("mailAddress"), "%" + mailAddress + "%"); + } - static Specification idDivisionEqual(Integer idDivision) { - return (root, query, criteriaBuilder) -> - idDivision == null ? null : - criteriaBuilder.equal(root.join("division").get("idDivision"), idDivision); - } - @Query("SELECT DISTINCT new com.example.rhizome.app.infra.entity.EmployeeDepartmentEntity(e,di,de,h)FROM EmployeeEntity e " - + "INNER JOIN e.division di " - + "INNER JOIN di.department de " - + "INNER JOIN de.headquarters h ") - List findAlltable(); - -// @Query("SELECT DISTINCT new com.example.rhizome.app.infra.entity.EmployeeDepartmentEntity(e,di,de,h)FROM EmployeeEntity e " -// + "INNER JOIN e.division di " -// + "INNER JOIN di.department de " -// + "INNER JOIN de.headquarters h " -// + "WHERE (:idEmployee IS NULL OR e.idEmployee = idEmployee) " -// + "AND (:nmEmployee IS NULL OR e.nmEmployee LIKE %nmEmployee%) " -// + "AND(:knEmployee IS NULL OR e.knEmployee LIKE %knEmployee%) " -// + "AND(:mailAddress IS NULL OR e.mailAddress Like %mailAddress%) " -// +"AND(:idDivision IS NULL OR e.idDivision LIKE %idDivision%)") - @EntityGraph(attributePaths = {"division", "division.department", "division.department.headquarters"}) - List findAll(@Nullable Specification spec); + static Specification idDivisionEqual(Integer idDivision) { + return (root, query, criteriaBuilder) -> idDivision == null ? null + : criteriaBuilder.equal(root.join("division").get("idDivision"), idDivision); + } + + @Query("SELECT DISTINCT new com.example.rhizome.app.infra.entity.EmployeeDepartmentEntity(e,di,de,h)FROM EmployeeEntity e " + + "INNER JOIN e.division di " + + "INNER JOIN di.department de " + + "INNER JOIN de.headquarters h ") + List findAlltable(); + + //全てのテーブルを結合してから検索 + @EntityGraph(attributePaths = { "division", "division.department", "division.department.headquarters" }) + List findAll(@Nullable Specification spec); } diff --git a/EM-System/src/main/java/com/example/rhizome/app/infra/repository/EmployeeRepository.java b/EM-System/src/main/java/com/example/rhizome/app/infra/repository/EmployeeRepository.java index 64e08be..2613311 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/infra/repository/EmployeeRepository.java +++ b/EM-System/src/main/java/com/example/rhizome/app/infra/repository/EmployeeRepository.java @@ -11,22 +11,22 @@ import com.example.rhizome.app.infra.entity.InsertEmployeeEntity; @Repository public interface EmployeeRepository extends JpaRepository { - Optional findByMailAddressAndPassword(String mailAddress, String password); + Optional findByMailAddressAndPassword(String mailAddress, String password); - /** - * メールアドレスで検索 - **/ - Optional findByMailAddress(String mail); + /** + * メールアドレスで検索 + **/ + Optional findByMailAddress(String mail); - /** - * IDで検索 - **/ - Optional findByIdEmployee(Integer idEmployee); + /** + * IDで検索 + **/ + Optional findByIdEmployee(Integer idEmployee); + + /** + * IDで検索 + **/ + List findByDivision_idDivision(Integer idDivision); - /** - * IDで検索 - **/ - List findByDivision_idDivision(Integer idDivision); - void save(InsertEmployeeEntity insertEmployeeEntity); } diff --git a/EM-System/src/main/java/com/example/rhizome/app/infra/repository/HeadquartersRepository.java b/EM-System/src/main/java/com/example/rhizome/app/infra/repository/HeadquartersRepository.java index 6f402a2..c2136bd 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/infra/repository/HeadquartersRepository.java +++ b/EM-System/src/main/java/com/example/rhizome/app/infra/repository/HeadquartersRepository.java @@ -8,24 +8,23 @@ import org.springframework.stereotype.Repository; import com.example.rhizome.app.infra.entity.HeadquartersEntity; @Repository -public interface HeadquartersRepository extends JpaRepository, JpaSpecificationExecutor{ +public interface HeadquartersRepository + extends JpaRepository, JpaSpecificationExecutor { static Specification idHeadquartersEqual(Integer idHeadquarters) { - return idHeadquarters == null ? - null : - // 戻り値の型 Specification にキャスト - (Specification) - // ラムダ式で記載しているが書いてあることは criteriaBuilder を使って Where句の後の "'idDepartment' = idDepartment(変数)" - // を作成している - (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.equal(root.get("idHeadquarters"), idHeadquarters); - } + return idHeadquarters == null ? null : + // 戻り値の型 Specification にキャスト + (Specification) + // ラムダ式で記載しているが書いてあることは criteriaBuilder を使って Where句の後の "'idDepartment' = idDepartment(変数)" + // を作成している + (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.equal(root.get("idHeadquarters"), + idHeadquarters); + } - static Specification nmHeadquartersEqual(String nmHeadquarters) { - return (nmHeadquarters == null || nmHeadquarters.isEmpty()) ? - null : - (Specification) - (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.like(root.get("nmHeadquarters"), nmHeadquarters); - } + static Specification nmHeadquartersEqual(String nmHeadquarters) { + return (nmHeadquarters == null || nmHeadquarters.isEmpty()) ? null + : (Specification) (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder + .like(root.get("nmHeadquarters"), nmHeadquarters); + } - - HeadquartersEntity findByNmHeadquarters(String nmHeadquarters); + HeadquartersEntity findByNmHeadquarters(String nmHeadquarters); } diff --git a/EM-System/src/main/java/com/example/rhizome/app/infra/repository/RegisterDepartmentRepository.java b/EM-System/src/main/java/com/example/rhizome/app/infra/repository/RegisterDepartmentRepository.java index 5c7b826..409183a 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/infra/repository/RegisterDepartmentRepository.java +++ b/EM-System/src/main/java/com/example/rhizome/app/infra/repository/RegisterDepartmentRepository.java @@ -6,18 +6,18 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.stereotype.Repository; import com.example.rhizome.app.infra.entity.RegisterDepartmentEntity; + @Repository -public interface RegisterDepartmentRepository extends JpaRepository, JpaSpecificationExecutor { - static Specification idHeadquartersEqual(Integer idHeadquarters) { - - System.out.println("RegisterDepartmentRepository=>5"); - - return idHeadquarters == null ? - null : - //戻り値の型 Specification にキャスト - (Specification) - - (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.equal(root.get("idHeadquarters"), idHeadquarters); - } +public interface RegisterDepartmentRepository + extends JpaRepository, JpaSpecificationExecutor { + static Specification idHeadquartersEqual(Integer idHeadquarters) { + + return idHeadquarters == null ? null : + //戻り値の型 Specification にキャスト + (Specification) + + (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.equal(root.get("idHeadquarters"), + idHeadquarters); + } } diff --git a/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/DeleteDepartmentController.java b/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/DeleteDepartmentController.java index 43958bd..c652ee5 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/DeleteDepartmentController.java +++ b/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/DeleteDepartmentController.java @@ -1,6 +1,5 @@ package com.example.rhizome.app.presentation.controller; - import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.*; import java.util.logging.Level; @@ -31,98 +30,95 @@ import com.example.rhizome.app.presentation.form.MessageForm; @Controller public class DeleteDepartmentController { - // ログ出力用インスタンス - private final static Logger LOGGER = Logger.getLogger(DeleteDepartmentController.class.getName()); + // ログ出力用インスタンス + private final static Logger LOGGER = Logger.getLogger(DeleteDepartmentController.class.getName()); - // エラーメッセージ用の定数フィールド - private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!"; + // エラーメッセージ用の定数フィールド + private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!"; - HttpSession httpSession; - DeleteDepartment deleteDepartment; - SearchDepartment searchDepartment; - SearchEmployee searchEmployee; + HttpSession httpSession; + DeleteDepartment deleteDepartment; + SearchDepartment searchDepartment; + SearchEmployee searchEmployee; - @Autowired - public DeleteDepartmentController( - DeleteDepartment deleteDepartment, - SearchDepartment searchDepartment, - SearchEmployee searchEmployee, - HttpSession httpSession - ) { - this.httpSession = httpSession; - this.deleteDepartment = deleteDepartment; - this.searchDepartment = searchDepartment; - this.searchEmployee = searchEmployee; - } + @Autowired + public DeleteDepartmentController( + DeleteDepartment deleteDepartment, + SearchDepartment searchDepartment, + SearchEmployee searchEmployee, + HttpSession httpSession) { + this.httpSession = httpSession; + this.deleteDepartment = deleteDepartment; + this.searchDepartment = searchDepartment; + this.searchEmployee = searchEmployee; + } - /** - * 削除処理のコントローラ - * - * @param idDepartment 削除対象のidDepartment - * @param model ビューにデータを渡すためのコンテナ - * @return 遷移先の画面 - */ - @PermissionCheck - @SessionCheck - @RequestMapping(value = DELETE_DEPARTMENT, method = RequestMethod.POST) - public String deleteEmployee(@RequestParam("idDivision") Integer idDivision, Model model) { + /** + * 削除処理のコントローラ + * + * @param idDivision 削除対象のidDivision + * @param model ビューにデータを渡すためのコンテナ + * @return 遷移先の画面 + */ + @PermissionCheck + @SessionCheck + @RequestMapping(value = DELETE_DEPARTMENT, method = RequestMethod.POST) + public String deleteEmployee(@RequestParam("idDivision") Integer idDivision, Model model) { - try { + try { - // 削除処理実施 - deleteExec(model, idDivision); + // 削除処理実施 + deleteExec(model, idDivision); - // 部署一覧を取得し、画面に返す用のクラスに詰め替える - // 作成した部署一覧をセット - model.addAttribute( - PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, - DepartmentForm.convertFrom( - searchDepartment.searchAllDepartmentTable() - ) - ); + // 部署一覧を取得し、画面に返す用のクラスに詰め替える + // 作成した部署一覧をセット + model.addAttribute( + PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, + DepartmentForm.convertFrom( + searchDepartment.searchAllDepartmentTable())); - // 検索画面に遷移 - return "forward:" + TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_ALL; + // 検索画面に遷移 + return "forward:" + TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_ALL; - } catch (Exception e) { - // ログイン情報の破棄 - httpSession.invalidate(); + } catch (Exception e) { + // ログイン情報の破棄 + httpSession.invalidate(); - e.printStackTrace(); - // エラーログ出力 - LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); - // エラー画面遷移 - return TransitionTargetPageNameKeyword.ERROR_HTML; - } - } + e.printStackTrace(); + // エラーログ出力 + LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); + // エラー画面遷移 + return TransitionTargetPageNameKeyword.ERROR_HTML; + } + } - /** - * 削除処理実施 - * - * @param model ビューにデータを渡すためのコンテナ - * @param idDepartment 削除対象のidDepartment - */ - private void deleteExec(Model model, Integer idDivision) { + /** + * 削除処理実施 + * + * @param model ビューにデータを渡すためのコンテナ + * @param idDepartment 削除対象のidDepartment + */ + private void deleteExec(Model model, Integer idDivision) { - final String DELETE_TARGET_ID_CAN_NOT_DELETE = "1名以上が所属している部署は削除出来ません。"; - final String DELETE_COMPLETE = "削除しました。"; + final String DELETE_TARGET_ID_CAN_NOT_DELETE = "1名以上が所属している部署は削除出来ません。"; + final String DELETE_COMPLETE = "削除しました。"; - // 1名上所属している人が居れば削除不可 - if (!searchEmployee.searchEmployeeByIdDepartment(idDivision).isEmpty()) { - // 削除対象だった場合 - // エラーメッセージをセット - model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DELETE_TARGET_ID_CAN_NOT_DELETE)); - // 検索画面に遷移 - return; - } + // 1名上所属している人が居れば削除不可 + if (!searchEmployee.searchEmployeeByIdDepartment(idDivision).isEmpty()) { + // 削除対象だった場合 + // エラーメッセージをセット + model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, + new MessageForm(DELETE_TARGET_ID_CAN_NOT_DELETE)); + // 検索画面に遷移 + return; + } - // 削除を実施 - deleteDepartment.deleteDepartment(idDivision); + // 削除を実施 + deleteDepartment.deleteDepartment(idDivision); - // 削除完了したメッセージをセット - model.addAttribute(PageReturnAttributeKeyword.MESSAGE_INFO, new MessageForm(DELETE_COMPLETE)); - - } + // 削除完了したメッセージをセット + model.addAttribute(PageReturnAttributeKeyword.MESSAGE_INFO, new MessageForm(DELETE_COMPLETE)); + } } diff --git a/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/DeleteEmployeeController.java b/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/DeleteEmployeeController.java index 431a9fb..7cc9f13 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/DeleteEmployeeController.java +++ b/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/DeleteEmployeeController.java @@ -76,7 +76,8 @@ public class DeleteEmployeeController { deleteExec( model, idEmployee, - LoginUserForm.convertTo((LoginUserForm) httpSession.getAttribute(SessionKeyword.LOGIN_USER))); + LoginUserForm.convertTo( + (LoginUserForm) httpSession.getAttribute(SessionKeyword.LOGIN_USER))); // 検索画面に遷移 return "forward:" + TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_INFO_FORM_EMPTY; diff --git a/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/IndexController.java b/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/IndexController.java index 93da70a..8671309 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/IndexController.java +++ b/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/IndexController.java @@ -1,50 +1,51 @@ package com.example.rhizome.app.presentation.controller; -import com.example.rhizome.app.domain.service.impl.LoginImpl; -import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword; -import com.example.rhizome.app.presentation.form.LoginUserForm; +import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.*; + +import javax.servlet.http.HttpSession; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; -import javax.servlet.http.HttpSession; - -import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.*; +import com.example.rhizome.app.domain.service.impl.LoginImpl; +import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword; +import com.example.rhizome.app.presentation.form.LoginUserForm; @Controller public class IndexController { - HttpSession httpSession; + HttpSession httpSession; - @Autowired - public IndexController(HttpSession httpSession, LoginImpl loginImpl) { - this.httpSession = httpSession; - } + @Autowired + public IndexController(HttpSession httpSession, LoginImpl loginImpl) { + this.httpSession = httpSession; + } - @ModelAttribute - public LoginUserForm loginUserForm() { - return new LoginUserForm(); - } + @ModelAttribute + public LoginUserForm loginUserForm() { + return new LoginUserForm(); + } - /** - * ログイン画面表示処理 - * - * @param model ビューにデータを渡すためのコンテナ - * @return 遷移先の画面 - */ - @RequestMapping(value = {INDEX_BLANK, INDEX_SLASH, INDEX_LOGIN}) - public String index(Model model) { - // セッション情報を破棄 - if (httpSession != null) { - httpSession.invalidate(); - } + /** + * ログイン画面表示処理 + * + * @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()); + // 空のFormをSessionに用意 + model.addAttribute(PageReturnAttributeKeyword.LOGIN_INFO_FORM, loginUserForm()); - // ログイン画面に遷移 - return LOGIN_HTML; - } + // ログイン画面に遷移 + return LOGIN_HTML; + } } diff --git a/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/InsertDepartmentConfirmController.java b/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/InsertDepartmentConfirmController.java index c948aa9..52aa441 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/InsertDepartmentConfirmController.java +++ b/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/InsertDepartmentConfirmController.java @@ -31,104 +31,98 @@ import com.example.rhizome.app.presentation.form.MessageForm; @Controller public class InsertDepartmentConfirmController { - // ログ出力用インスタンス - private final static Logger LOGGER = Logger.getLogger(InsertDepartmentConfirmController.class.getName()); + // ログ出力用インスタンス + private final static Logger LOGGER = Logger.getLogger(InsertDepartmentConfirmController.class.getName()); - // エラーメッセージ用の定数フィールド - private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!"; + // エラーメッセージ用の定数フィールド + private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!"; - HttpSession httpSession; - SearchDepartment searchDepartment; + HttpSession httpSession; + SearchDepartment searchDepartment; - @Autowired - public InsertDepartmentConfirmController( - HttpSession httpSession, - SearchDepartmentImpl searchDepartment - ) { - this.httpSession = httpSession; - this.searchDepartment = searchDepartment; - } + @Autowired + public InsertDepartmentConfirmController( + HttpSession httpSession, + SearchDepartmentImpl searchDepartment) { + this.httpSession = httpSession; + this.searchDepartment = searchDepartment; + } - @ModelAttribute - public InsertDepartmentForm insertDepartmentForm() { - return new InsertDepartmentForm(); - } + @ModelAttribute + public InsertDepartmentForm insertDepartmentForm() { + return new InsertDepartmentForm(); + } - /** - * 登録情報のチェックを行う - * - * @param insertDepartmentForm 登録情報 - * @param model ビューにデータを渡すためのコンテナ - * @return 遷移先の画面 - */ - @PermissionCheck - @SessionCheck - @RequestMapping(value = INSERT_DEPARTMENT_CONFIRM, method = RequestMethod.POST) - public String insertDepartmentConfirm(InsertDepartmentForm insertDepartmentForm, Model model) { + /** + * 登録情報のチェックを行う + * + * @param insertDepartmentForm 登録情報 + * @param model ビューにデータを渡すためのコンテナ + * @return 遷移先の画面 + */ + @PermissionCheck + @SessionCheck + @RequestMapping(value = INSERT_DEPARTMENT_CONFIRM, method = RequestMethod.POST) + public String insertDepartmentConfirm(InsertDepartmentForm insertDepartmentForm, Model model) { - final String DUPLICATION = "既に同名の本部名または部または課が存在します。"; - final String IRREGULARITY = "本部名または部または課が不正です。"; + final String DUPLICATION = "既に同名の本部名または部または課が存在します。"; + final String IRREGULARITY = "本部名または部または課が不正です。"; - try { - model.addAttribute( - PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, - DepartmentForm.convertFrom( - searchDepartment.searchAllDepartmentTable()) - ); - - // 入力内容に誤りがあるか - if (insertDepartmentForm.haveNmDepartment()) { - // 誤りがあった場合 - // 誤りがあった箇所のエラーメッセージを表示 - model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(IRREGULARITY)); - // 画面に返す為の登録情報をセット - model.addAttribute(PageReturnAttributeKeyword.INSERT_DEPARTMENT_FORM, insertDepartmentForm); - // 登録画面に遷移 - return INSERT_DEPARTMENT_INPUT_HTML; - } - - SearchConditionDepartment searchHeadquartersTable =new SearchConditionDepartment( - null, - insertDepartmentForm.getNmHeadquarters()); - SearchConditionDepartment searchDepartmentTable = new SearchConditionDepartment( - null, - insertDepartmentForm.getNmDepartment()); - SearchConditionDepartment searchDivisionTable = new SearchConditionDepartment( - null, - insertDepartmentForm.getNmDivision()); - - // 部署名で重複が無いかチェック - if (searchDepartment.searchAllDepartmentTable( - searchHeadquartersTable, - searchDepartmentTable, - searchDivisionTable)){ + try { + model.addAttribute( + PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, + DepartmentForm.convertFrom( + searchDepartment.searchAllDepartmentTable())); - // 存在する場合はエラーメッセージを設定して更新入力画面に遷移 - model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DUPLICATION)); - model.addAttribute(PageReturnAttributeKeyword.INSERT_DEPARTMENT_FORM, insertDepartmentForm); + // 入力内容に誤りがあるか + if (insertDepartmentForm.haveNmDepartment()) { + // 誤りがあった場合 + // 誤りがあった箇所のエラーメッセージを表示 + model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(IRREGULARITY)); + // 画面に返す為の登録情報をセット + model.addAttribute(PageReturnAttributeKeyword.INSERT_DEPARTMENT_FORM, insertDepartmentForm); + // 登録画面に遷移 + return INSERT_DEPARTMENT_INPUT_HTML; + } + //重複のチェック用の各部署のSearchConditionDeopartmentを用意 + SearchConditionDepartment searchHeadquartersTable = new SearchConditionDepartment( + null, + insertDepartmentForm.getNmHeadquarters()); + SearchConditionDepartment searchDepartmentTable = new SearchConditionDepartment( + null, + insertDepartmentForm.getNmDepartment()); + SearchConditionDepartment searchDivisionTable = new SearchConditionDepartment( + null, + insertDepartmentForm.getNmDivision()); - return TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_INPUT_HTML; - } + // 部署の組み合わせで重複が無いかチェック + if (searchDepartment.searchAllDepartmentTable( + searchHeadquartersTable, + searchDepartmentTable, + searchDivisionTable)) { - // 登録確認ページに遷移 - model.addAttribute(PageReturnAttributeKeyword.INSERT_DEPARTMENT_FORM, insertDepartmentForm); - // 登録確認画面に遷移 - return TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_CONFIRM_HTML; + // 存在する場合はエラーメッセージを設定して更新入力画面に遷移 + model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DUPLICATION)); + model.addAttribute(PageReturnAttributeKeyword.INSERT_DEPARTMENT_FORM, insertDepartmentForm); + return TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_INPUT_HTML; + } - } catch (Exception e) { - // ログイン情報の破棄 - httpSession.invalidate(); + // 登録確認ページに遷移 + model.addAttribute(PageReturnAttributeKeyword.INSERT_DEPARTMENT_FORM, insertDepartmentForm); + // 登録確認画面に遷移 + return TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_CONFIRM_HTML; - e.printStackTrace(); + } catch (Exception e) { + // ログイン情報の破棄 + httpSession.invalidate(); - // エラーログ出力 - LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); - // エラー画面遷移 - return TransitionTargetPageNameKeyword.ERROR_HTML; - } - } + e.printStackTrace(); + + // エラーログ出力 + LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); + // エラー画面遷移 + return TransitionTargetPageNameKeyword.ERROR_HTML; + } + } } - - - diff --git a/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/InsertDepartmentController.java b/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/InsertDepartmentController.java index 0789a8b..c2ce801 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/InsertDepartmentController.java +++ b/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/InsertDepartmentController.java @@ -34,110 +34,104 @@ import com.example.rhizome.app.presentation.form.MessageForm; @Controller public class InsertDepartmentController { - private final SearchDepartmentImpl searchDepartmentImpl; + private final SearchDepartmentImpl searchDepartmentImpl; // ログ出力用インスタンス - private final static Logger LOGGER = Logger.getLogger(InsertDepartmentController.class.getName()); + private final static Logger LOGGER = Logger.getLogger(InsertDepartmentController.class.getName()); - // エラーメッセージ用の定数フィールド - private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!"; + // エラーメッセージ用の定数フィールド + private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!"; - HttpSession httpSession; - RegisterDepartment registerDepartment; - SearchDepartment searchDepartment; + HttpSession httpSession; + RegisterDepartment registerDepartment; + SearchDepartment searchDepartment; - @Autowired - public InsertDepartmentController(HttpSession httpSession, RegisterDepartment registerDepartment, SearchDepartment searchDepartment, SearchDepartmentImpl searchDepartmentImpl) { - this.httpSession = httpSession; - this.registerDepartment = registerDepartment; - this.searchDepartment = searchDepartment; + @Autowired + public InsertDepartmentController(HttpSession httpSession, RegisterDepartment registerDepartment, + SearchDepartment searchDepartment, SearchDepartmentImpl searchDepartmentImpl) { + this.httpSession = httpSession; + this.registerDepartment = registerDepartment; + this.searchDepartment = searchDepartment; this.searchDepartmentImpl = searchDepartmentImpl; - } + } - @ModelAttribute - public InsertDepartmentForm insertDepartmentForm() { - return new InsertDepartmentForm(); - } + @ModelAttribute + public InsertDepartmentForm insertDepartmentForm() { + return new InsertDepartmentForm(); + } - /** - * 新規登録画面表示処理 - * - * @param insertDepartmentForm 登録情報 - * @param model ビューにデータを渡すためのコンテナ - * @return 遷移先の画面 - */ - @PermissionCheck - @SessionCheck - @RequestMapping(value = INSERT_DEPARTMENT, method = RequestMethod.POST) - public String insertDepartment(InsertDepartmentForm insertDepartmentForm, Model model) { + /** + * 新規登録画面表示処理 + * + * @param insertDepartmentForm 登録情報 + * @param model ビューにデータを渡すためのコンテナ + * @return 遷移先の画面 + */ + @PermissionCheck + @SessionCheck + @RequestMapping(value = INSERT_DEPARTMENT, method = RequestMethod.POST) + public String insertDepartment(InsertDepartmentForm insertDepartmentForm, Model model) { - final String DUPLICATION = "既に同名の部署が存在します。"; - final String IRREGULARITY = "部署名が不正です。"; + final String DUPLICATION = "既に同名の部署が存在します。"; + final String IRREGULARITY = "部署名が不正です。"; - try { - // 部署一覧を取得し、画面に返す用のクラスに詰め替える - // 作成した部署一覧をセット - model.addAttribute( - PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, - DepartmentForm.convertFrom( - searchDepartment.searchAllDepartmentTable() - )); + try { + // 部署一覧を取得し、画面に返す用のクラスに詰め替える + // 作成した部署一覧をセット + model.addAttribute( + PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, + DepartmentForm.convertFrom( + searchDepartment.searchAllDepartmentTable())); - // 入力内容に誤りがあるか - if (insertDepartmentForm.haveNmDepartment()) { - // 誤りがあった場合 - // 誤りがあった箇所のエラーメッセージを表示 - model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(IRREGULARITY)); - // 画面に返す為の登録情報をセット - model.addAttribute(PageReturnAttributeKeyword.INSERT_DEPARTMENT_FORM, insertDepartmentForm); - // 登録画面に遷移 - return INSERT_DEPARTMENT_INPUT_HTML; - } - + // 入力内容に誤りがあるか + if (insertDepartmentForm.haveNmDepartment()) { + // 誤りがあった場合 + // 誤りがあった箇所のエラーメッセージを表示 + model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(IRREGULARITY)); + // 画面に返す為の登録情報をセット + model.addAttribute(PageReturnAttributeKeyword.INSERT_DEPARTMENT_FORM, insertDepartmentForm); + // 登録画面に遷移 + return INSERT_DEPARTMENT_INPUT_HTML; + } - // 部署名で重複が無いかチェック - if (searchDepartment.searchAllDepartmentTable( - new SearchConditionDepartment( - insertDepartmentForm.getIdHeadquarters(), - insertDepartmentForm.getNmHeadquarters()), - new SearchConditionDepartment( - insertDepartmentForm.getIdDepartment(), - insertDepartmentForm.getNmDepartment()), - new SearchConditionDepartment( - insertDepartmentForm.getIdDivision(), - insertDepartmentForm.getNmDivision()))) { + // 部署の組み合わせで重複が無いかチェック + if (searchDepartment.searchAllDepartmentTable( + new SearchConditionDepartment( + insertDepartmentForm.getIdHeadquarters(), + insertDepartmentForm.getNmHeadquarters()), + new SearchConditionDepartment( + insertDepartmentForm.getIdDepartment(), + insertDepartmentForm.getNmDepartment()), + new SearchConditionDepartment( + insertDepartmentForm.getIdDivision(), + insertDepartmentForm.getNmDivision()))) { + // 存在する場合はエラーメッセージを設定して更新入力画面に遷移 + model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DUPLICATION)); + model.addAttribute(PageReturnAttributeKeyword.INSERT_DEPARTMENT_FORM, insertDepartmentForm); - // 存在する場合はエラーメッセージを設定して更新入力画面に遷移 - model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DUPLICATION)); - model.addAttribute(PageReturnAttributeKeyword.INSERT_DEPARTMENT_FORM, insertDepartmentForm); + return TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_INPUT_HTML; + } + //divisionEntityにinsertDepartmentFormで画面から渡ってきた値を入れる + DepartmentInfo departmentInfo = InsertDepartmentForm.convertTo(insertDepartmentForm); + DivisionEntity divisionEntity = DivisionEntity.convertFrom(departmentInfo); - return TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_INPUT_HTML; - } - DepartmentInfo departmentInfo = InsertDepartmentForm.convertTo(insertDepartmentForm); - - DivisionEntity divisionEntity = DivisionEntity.convertFrom(departmentInfo); - - System.out.println(divisionEntity); - // 登録処理 - registerDepartment.registerDepartment(divisionEntity); - - // 登録結果画面に遷移 - return TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_RESULT_HTML; + // 登録処理 + registerDepartment.registerDepartment(divisionEntity); - } catch (Exception e) { - // ログイン情報の破棄 - httpSession.invalidate(); + // 登録結果画面に遷移 + return TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_RESULT_HTML; - e.printStackTrace(); + } catch (Exception e) { + // ログイン情報の破棄 + httpSession.invalidate(); - // エラーログ出力 - LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); - // エラー画面遷移 - return TransitionTargetPageNameKeyword.ERROR_HTML; - } - } + e.printStackTrace(); + + // エラーログ出力 + LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); + // エラー画面遷移 + return TransitionTargetPageNameKeyword.ERROR_HTML; + } + } } - - - diff --git a/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/InsertDepartmentInputController.java b/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/InsertDepartmentInputController.java index 67d0bec..e4014c5 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/InsertDepartmentInputController.java +++ b/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/InsertDepartmentInputController.java @@ -17,7 +17,9 @@ import com.example.rhizome.aop.aspect.SessionCheck; 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.DepartmentInfoForm; +import com.example.rhizome.app.presentation.form.DivisionInfoForm; +import com.example.rhizome.app.presentation.form.HeadquartersInfoForm; import com.example.rhizome.app.presentation.form.InsertDepartmentForm; /** @@ -26,67 +28,70 @@ import com.example.rhizome.app.presentation.form.InsertDepartmentForm; @Controller public class InsertDepartmentInputController { - // ログ出力用インスタンス - private final static Logger LOGGER = Logger.getLogger(InsertDepartmentInputController.class.getName()); + // ログ出力用インスタンス + private final static Logger LOGGER = Logger.getLogger(InsertDepartmentInputController.class.getName()); - // エラーメッセージ用の定数フィールド - private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!"; + // エラーメッセージ用の定数フィールド + private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!"; - HttpSession httpSession; - SearchDepartment searchDepartment; + HttpSession httpSession; + SearchDepartment searchDepartment; - @Autowired - public InsertDepartmentInputController( - HttpSession httpSession, - SearchDepartment searchDepartment - ) { - this.httpSession = httpSession; - this.searchDepartment = searchDepartment; - } + @Autowired + public InsertDepartmentInputController( + HttpSession httpSession, + SearchDepartment searchDepartment) { + this.httpSession = httpSession; + this.searchDepartment = searchDepartment; + } - @ModelAttribute - public InsertDepartmentForm insertDepartmentForm() { - return new InsertDepartmentForm(); - } + @ModelAttribute + public InsertDepartmentForm insertDepartmentForm() { + return new InsertDepartmentForm(); + } + /** + * 部署登録画面表示処理 + * + * @param insertDepartmentForm 登録画面のフォーム + * @param model ビューにデータを渡すためのコンテナ + * @return 遷移先の画面 + */ + @SessionCheck + @PermissionCheck + @RequestMapping(value = TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_INPUT, method = RequestMethod.POST) + public String insertInput(InsertDepartmentForm insertDepartmentForm, Model model) { - /** - * 部署登録画面表示処理 - * - * @param insertDepartmentForm 登録画面のフォーム - * @param model ビューにデータを渡すためのコンテナ - * @return 遷移先の画面 - */ - @SessionCheck - @PermissionCheck - @RequestMapping(value = TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_INPUT, method = RequestMethod.POST) - public String insertInput(InsertDepartmentForm insertDepartmentForm, Model model) { + try { + //各部署情報を重複魚消して表示するために別々に画面へ送る + model.addAttribute( + PageReturnAttributeKeyword.HEADQUARTERS_FORM_LIST, + HeadquartersInfoForm.convertFrom( + searchDepartment.searchAllDepartmentTable())); + model.addAttribute( + PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, + DepartmentInfoForm.convertFromTo( + searchDepartment.searchAllDepartmentTable())); + model.addAttribute( + PageReturnAttributeKeyword.DIVISION_FORM_LIST, + DivisionInfoForm.convertFromTo( + searchDepartment.searchAllDepartmentTable())); + // パラメータをセット + model.addAttribute(PageReturnAttributeKeyword.INSERT_DEPARTMENT_FORM, insertDepartmentForm); - try { - model.addAttribute( - PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, - DepartmentForm.convertFrom( - searchDepartment.searchAllDepartmentTable()) - ); - // パラメータをセット - model.addAttribute(PageReturnAttributeKeyword.INSERT_DEPARTMENT_FORM, insertDepartmentForm); + // 登録画面に遷移 + return TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_INPUT_HTML; - // 登録画面に遷移 - return TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_INPUT_HTML; + } catch (Exception e) { + // ログイン情報の破棄 + httpSession.invalidate(); - } catch (Exception e) { - // ログイン情報の破棄 - httpSession.invalidate(); + e.printStackTrace(); - e.printStackTrace(); - - // エラーログ出力 - LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); - // エラー画面遷移 - return TransitionTargetPageNameKeyword.ERROR_HTML; - } - } + // エラーログ出力 + LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); + // エラー画面遷移 + return TransitionTargetPageNameKeyword.ERROR_HTML; + } + } } - - - diff --git a/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/InsertEmployeeConfirmController.java b/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/InsertEmployeeConfirmController.java index 144f2af..dc48996 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/InsertEmployeeConfirmController.java +++ b/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/InsertEmployeeConfirmController.java @@ -34,113 +34,97 @@ import com.example.rhizome.app.presentation.form.MessageForm; @Controller public class InsertEmployeeConfirmController { - // ログ出力用インスタンス - private final static Logger LOGGER = Logger.getLogger(InsertEmployeeConfirmController.class.getName()); + // ログ出力用インスタンス + private final static Logger LOGGER = Logger.getLogger(InsertEmployeeConfirmController.class.getName()); - // エラーメッセージ用の定数フィールド - private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!"; + // エラーメッセージ用の定数フィールド + private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!"; - HttpSession httpSession; - SearchDepartment searchDepartment; - SearchEmployee searchEmployee; + HttpSession httpSession; + SearchDepartment searchDepartment; + SearchEmployee searchEmployee; - @Autowired - public InsertEmployeeConfirmController( - HttpSession httpSession, - SearchDepartmentImpl searchDepartment, - SearchEmployeeImpl searchEmployee - ) { - this.httpSession = httpSession; - this.searchDepartment = searchDepartment; - this.searchEmployee = searchEmployee; - } + @Autowired + public InsertEmployeeConfirmController( + HttpSession httpSession, + SearchDepartmentImpl searchDepartment, + SearchEmployeeImpl searchEmployee) { + this.httpSession = httpSession; + this.searchDepartment = searchDepartment; + this.searchEmployee = searchEmployee; + } - @ModelAttribute - public InsertEmployeeForm insertEmployeeForm() { - return new InsertEmployeeForm(); - } + @ModelAttribute + public InsertEmployeeForm insertEmployeeForm() { + return new InsertEmployeeForm(); + } - /** - * 登録情報のチェックを行う - * - * @param insertEmployeeForm 登録情報 - * @param model ビューにデータを渡すためのコンテナ - * @return 遷移先の画面 - */ - @PermissionCheck - @SessionCheck - @RequestMapping(value = INSERT_EMPLOYEE_CONFIRM, method = RequestMethod.POST) - public String insertEmployeeConfirm(InsertEmployeeForm insertEmployeeForm, Model model) { + /** + * 登録情報のチェックを行う + * + * @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.searchAllDepartmentTable() - )); + try { + // 部署一覧を取得し、画面に返す用のクラスに詰め替える + // 作成した部署一覧をセット + model.addAttribute( + PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, + DepartmentForm.convertFrom( + searchDepartment.searchAllDepartmentTable())); - // 登録用パラメータチェック - List error = insertEmployeeForm.validateParameter(); + // 登録用パラメータチェック + List error = insertEmployeeForm.validateParameter(); - // 入力内容に誤りがあるか - if (!error.isEmpty()) { - // 誤りがあった場合 - // 誤りがあった箇所のエラーメッセージを表示 - model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(String.join(", ", error) + "が不正です。")); - // 画面に返す為の登録情報をセット - model.addAttribute(PageReturnAttributeKeyword.INSERT_EMPLOYEE_FORM, insertEmployeeForm); - // 登録画面に遷移 - return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML; - } + // 入力内容に誤りがあるか + if (!error.isEmpty()) { + // 誤りがあった場合 + // 誤りがあった箇所のエラーメッセージを表示 + model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, + new MessageForm(String.join(", ", error) + "が不正です。")); + // 画面に返す為の登録情報をセット + model.addAttribute(PageReturnAttributeKeyword.INSERT_EMPLOYEE_FORM, insertEmployeeForm); + // 登録画面に遷移 + return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML; + } - final String DUPLICATION = "既に登録済みのメールアドレスです。"; + final String DUPLICATION = "既に登録済みのメールアドレスです。"; - // 登録対象のメールアドレスを元に検索 - List employeeList = searchEmployee.searchEmployee(insertEmployeeForm.getMailAddress()); + // 登録対象のメールアドレスを元に検索 + List employeeList = searchEmployee.searchEmployee(insertEmployeeForm.getMailAddress()); - // 検索結果があるか - if (!employeeList.isEmpty()) { - // 検索した結果0件ではない場合 - // 重複を許さないため、エラー処理 - model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DUPLICATION)); - // 画面に返す為の登録情報をセット - model.addAttribute(PageReturnAttributeKeyword.INSERT_EMPLOYEE_FORM, insertEmployeeForm); - // 登録画面に遷移 - return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML; - } - - - final String DEPARTMENT_VALID ="部署情報の組み合わせが違います。"; - if(!searchDepartment.searchAllDepartmentTable( - insertEmployeeForm.getIdHeadquarters() - ,insertEmployeeForm.getIdDepartment() - ,insertEmployeeForm.getIdDivision())) { - model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DEPARTMENT_VALID)); - model.addAttribute(PageReturnAttributeKeyword.INSERT_EMPLOYEE_FORM, insertEmployeeForm); - return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML; - } + // 検索結果があるか + 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; + // 登録確認ページに遷移 + model.addAttribute(PageReturnAttributeKeyword.INSERT_EMPLOYEE_FORM, insertEmployeeForm); + // 登録確認画面に遷移 + return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_CONFIRM_HTML; + } catch (Exception e) { + // ログイン情報の破棄 + httpSession.invalidate(); - } catch (Exception e) { - // ログイン情報の破棄 - httpSession.invalidate(); + e.printStackTrace(); - e.printStackTrace(); - - // エラーログ出力 - LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); - // エラー画面遷移 - return TransitionTargetPageNameKeyword.ERROR_HTML; - } - } + // エラーログ出力 + LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); + // エラー画面遷移 + return TransitionTargetPageNameKeyword.ERROR_HTML; + } + } } - - - diff --git a/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/InsertEmployeeController.java b/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/InsertEmployeeController.java index deabb66..0653ee4 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/InsertEmployeeController.java +++ b/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/InsertEmployeeController.java @@ -34,185 +34,171 @@ import com.example.rhizome.app.presentation.form.MessageForm; @Controller public class InsertEmployeeController { - // ログ出力用インスタンス - private final static Logger LOGGER = Logger.getLogger(InsertEmployeeController.class.getName()); + // ログ出力用インスタンス + private final static Logger LOGGER = Logger.getLogger(InsertEmployeeController.class.getName()); - // エラーメッセージ用の定数フィールド - private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!"; + // エラーメッセージ用の定数フィールド + private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!"; - HttpSession httpSession; - RegisterEmployee registerEmployee; - SearchDepartment searchDepartment; + HttpSession httpSession; + RegisterEmployee registerEmployee; + SearchDepartment searchDepartment; - @Autowired - public InsertEmployeeController(HttpSession httpSession, RegisterEmployeeImpl registerEmployee, SearchDepartmentImpl searchDepartment) { - this.httpSession = httpSession; - this.registerEmployee = registerEmployee; - this.searchDepartment = searchDepartment; - } + @Autowired + public InsertEmployeeController(HttpSession httpSession, RegisterEmployeeImpl registerEmployee, + SearchDepartmentImpl searchDepartment) { + this.httpSession = httpSession; + this.registerEmployee = registerEmployee; + this.searchDepartment = searchDepartment; + } - @ModelAttribute - public InsertEmployeeForm insertEmployeeForm() { - return new InsertEmployeeForm(); - } + @ModelAttribute + public InsertEmployeeForm insertEmployeeForm() { + return new InsertEmployeeForm(); + } - /** - * 新規登録画面表示処理 - * - * @param insertEmployeeForm 登録情報 - * @param model ビューにデータを渡すためのコンテナ - * @return 遷移先の画面 - */ - @PermissionCheck - @SessionCheck - @RequestMapping(value = INSERT_EMPLOYEE, method = RequestMethod.POST) - public String insertEmployee(InsertEmployeeForm insertEmployeeForm, Model model) { + /** + * 新規登録画面表示処理 + * + * @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.searchAllDepartmentTable() - )); + try { + // 部署一覧を取得し、画面に返す用のクラスに詰め替える + // 作成した部署一覧をセット + model.addAttribute( + PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, + DepartmentForm.convertFrom( + searchDepartment.searchAllDepartmentTable())); - // Confirm画面から渡ってきた値をチェック - List error = validateParameter( - insertEmployeeForm.getNmEmployee(), - insertEmployeeForm.getKnEmployee(), - insertEmployeeForm.getMailAddress(), - insertEmployeeForm.getPassword(), - insertEmployeeForm.getHireDate(), - insertEmployeeForm.getAdminAuth(), - insertEmployeeForm.getIdDivision() - ); + // Confirm画面から渡ってきた値をチェック + List error = validateParameter( + insertEmployeeForm.getNmEmployee(), + insertEmployeeForm.getKnEmployee(), + insertEmployeeForm.getMailAddress(), + insertEmployeeForm.getPassword(), + insertEmployeeForm.getHireDate(), + insertEmployeeForm.getAdminAuth(), + insertEmployeeForm.getIdDivision()); - // エラーが1件以上有る場合 - if (!error.isEmpty()) { - // エラー内容を画面に表示 - model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(String.join(", ", error) + "が不正です。")); - // 登録画面に遷移 - return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML; - } - - final String DEPARTMENT_VALID ="部署情報の組み合わせが違います。"; - if(!searchDepartment.searchAllDepartmentTable( - insertEmployeeForm.getIdHeadquarters() - ,insertEmployeeForm.getIdDepartment() - ,insertEmployeeForm.getIdDivision())) { - model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DEPARTMENT_VALID)); - model.addAttribute(PageReturnAttributeKeyword.INSERT_EMPLOYEE_FORM, insertEmployeeForm); - return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML; - } + // エラーが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; + // 登録処理 + registerEmployee.registerEmployee(InsertEmployeeForm.convertTo(insertEmployeeForm)); + // 登録結果画面に遷移 + return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_RESULT_HTML; - } catch (Exception e) { - // ログイン情報の破棄 - httpSession.invalidate(); + } catch (Exception e) { + // ログイン情報の破棄 + httpSession.invalidate(); - e.printStackTrace(); + e.printStackTrace(); - // エラーログ出力 - LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); - // エラー画面遷移 - return TransitionTargetPageNameKeyword.ERROR_HTML; - } - } + // エラーログ出力 + LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); + // エラー画面遷移 + return TransitionTargetPageNameKeyword.ERROR_HTML; + } + } - /** - * @param employeeName 登録対象の名前 - * @param employeeKana 登録対象のカナ - * @param mailAddress 登録対象のメールアドレス - * @param password 登録対象のパスワード - * @param management システム権限 - * @param departmentId 部署ID - * @return エラーが有った場合はエラー文言、無ければ空のリストが返る - */ - private List validateParameter( - String employeeName, - String employeeKana, - String mailAddress, - String password, - String hireDate, - Integer management, - Integer departmentId - ) { + /** + * @param employeeName 登録対象の名前 + * @param employeeKana 登録対象のカナ + * @param mailAddress 登録対象のメールアドレス + * @param password 登録対象のパスワード + * @param management システム権限 + * @param departmentId 部署ID + * @return エラーが有った場合はエラー文言、無ければ空のリストが返る + */ + private List validateParameter( + String employeeName, + String employeeKana, + String mailAddress, + String password, + String hireDate, + 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 HIREDATE_NULL_BLANK = "入社年月日"; - final String MANAGEMENT_ERROR = "管理者権限指定"; - final String DEPARTMENT_ID_NULL_BLANK = "所属部署"; + final String EMPLOYEE_NAME_NULL_BLANK = "社員名"; + final String EMPLOYEE_KANA_NULL_BLANK = "社員名フリガナ"; + final String MAIL_ADDRESS_NULL_BLANK = "メールアドレス"; + final String PASSWORD_NULL_BLANK = "パスワード"; + final String HIREDATE_NULL_BLANK = "入社年月日"; + final String MANAGEMENT_ERROR = "管理者権限指定"; + final String DEPARTMENT_ID_NULL_BLANK = "所属部署"; - List error = new ArrayList<>(); + List error = new ArrayList<>(); - // null or 空文字判定 - if (isNullOrBlank(employeeName)) { - // エラー内容を追加 - error.add(EMPLOYEE_NAME_NULL_BLANK); - } + // 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(employeeKana)) { + // エラー内容を追加 + error.add(EMPLOYEE_KANA_NULL_BLANK); + } - // null or 空文字判定 - if (isNullOrBlank(mailAddress)) { - // エラー内容を追加 - error.add(MAIL_ADDRESS_NULL_BLANK); - } + // null or 空文字判定 + if (isNullOrBlank(mailAddress)) { + // エラー内容を追加 + error.add(MAIL_ADDRESS_NULL_BLANK); + } - // null or 空文字判定 - if (isNullOrBlank(password)) { - // エラー内容を追加 - error.add(PASSWORD_NULL_BLANK); - } - // null or 空文字判定 - if (isNullOrBlank(hireDate)) { - // エラー内容を追加 - error.add(HIREDATE_NULL_BLANK); - } + // null or 空文字判定 + if (isNullOrBlank(password)) { + // エラー内容を追加 + error.add(PASSWORD_NULL_BLANK); + } + // null or 空文字判定 + if (isNullOrBlank(hireDate)) { + // エラー内容を追加 + error.add(HIREDATE_NULL_BLANK); + } - // 管理者権限の値が不正か - if (management == null) { - // エラー内容を追加 - error.add(MANAGEMENT_ERROR); - } + // 管理者権限の値が不正か + if (management == null) { + // エラー内容を追加 + error.add(MANAGEMENT_ERROR); + } - // 所属部署の値が不正か - if (departmentId == null) { - // エラー内容を追加 - error.add(DEPARTMENT_ID_NULL_BLANK); - } + // 所属部署の値が不正か + if (departmentId == null) { + // エラー内容を追加 + error.add(DEPARTMENT_ID_NULL_BLANK); + } - return error; + return error; - } + } - /** - * 仮引数を null or 空 判定する - * - * @param str 判定対象の文字列 - * @return true:null or 空 false:null or 空 では無い - */ - private static boolean isNullOrBlank(String str) { - if (null == str) { - return true; - } + /** + * 仮引数を 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(); - } + return str.isBlank(); + } } - - - diff --git a/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/InsertEmployeeInputController.java b/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/InsertEmployeeInputController.java index 5b053b0..ce28215 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/InsertEmployeeInputController.java +++ b/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/InsertEmployeeInputController.java @@ -35,135 +35,109 @@ import com.example.rhizome.app.presentation.form.InsertEmployeeForm; @Controller public class InsertEmployeeInputController { - // ログ出力用インスタンス - private final static Logger LOGGER = Logger.getLogger(InsertEmployeeInputController.class.getName()); + // ログ出力用インスタンス + private final static Logger LOGGER = Logger.getLogger(InsertEmployeeInputController.class.getName()); - // エラーメッセージ用の定数フィールド - private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!"; + // エラーメッセージ用の定数フィールド + private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!"; - HttpSession httpSession; - RegisterEmployee registerEmployee; - SearchDepartment searchDepartment; + HttpSession httpSession; + RegisterEmployee registerEmployee; + SearchDepartment searchDepartment; - @Autowired - public InsertEmployeeInputController(HttpSession httpSession, RegisterEmployee registerEmployee, SearchDepartment searchDepartment) { - this.httpSession = httpSession; - this.registerEmployee = registerEmployee; - this.searchDepartment = searchDepartment; - } + @Autowired + public InsertEmployeeInputController(HttpSession httpSession, RegisterEmployee registerEmployee, + SearchDepartment searchDepartment) { + this.httpSession = httpSession; + this.registerEmployee = registerEmployee; + this.searchDepartment = searchDepartment; + } - @ModelAttribute - public InsertEmployeeForm insertEmployeeForm() { - return new InsertEmployeeForm(); - } + @ModelAttribute + public InsertEmployeeForm insertEmployeeForm() { + return new InsertEmployeeForm(); + } - //プルダウン絞り込み無し実装用 -// /** -// * 登録画面表示処理 -// * -// * @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.searchAllDepartmentTable())); -// -// // パラメータをセット -// 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; -// } -// } - //プルダウン絞り込み実装用 - @SessionCheck - @PermissionCheck - @RequestMapping(value = INSERT_EMPLOYEE_INPUT, method = RequestMethod.POST) - public String insertInput(InsertEmployeeForm insertEmployeeForm, Model model) { + /** + * 社員情報登録画面の表示を行う + * + * @param InsertEmployeeFormを保持したインスタンス + * @param model ビューにデータを渡すためのコンテナ + * @return 遷移先の画面 + */ + @SessionCheck + @PermissionCheck + @RequestMapping(value = INSERT_EMPLOYEE_INPUT, method = RequestMethod.POST) + public String insertInput(InsertEmployeeForm insertEmployeeForm, Model model) { - try { - // 部署コードリストを作成し、画面に返す値としてセット - model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST - ,HeadquartersInfoForm.convertFrom( - searchDepartment.searchAllDepartmentTable())); + try { - // パラメータをセット - model.addAttribute(PageReturnAttributeKeyword.INSERT_EMPLOYEE_FORM, insertEmployeeForm); + // 部署コードリストを作成し、画面に返す値としてセット + model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, HeadquartersInfoForm.convertFrom( + searchDepartment.searchAllDepartmentTable())); - // 登録画面に遷移 - return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML; + // パラメータをセット + model.addAttribute(PageReturnAttributeKeyword.INSERT_EMPLOYEE_FORM, insertEmployeeForm); - } catch (Exception e) { - // ログイン情報の破棄 - httpSession.invalidate(); + // 登録画面に遷移 + return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML; - e.printStackTrace(); + } catch (Exception e) { + // ログイン情報の破棄 + httpSession.invalidate(); - // エラーログ出力 - LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); - // エラー画面遷移 - return TransitionTargetPageNameKeyword.ERROR_HTML; - } - } - - @GetMapping("insertEmployeeInput/searchDepartment" ) - @ResponseBody - public ListdepartmentsByHeadquarters( - @RequestParam("id_headquarters")Integer idHeadquarters){ - System.out.println("koko"); - - List departmentByHeadquarters= - DepartmentInfoForm.convertFrom( - searchDepartment.searchByIdHeadquarters(idHeadquarters)); - System.out.println("2"); - return departmentByHeadquarters - .stream() - .map(DepartmentInfoForm-> new DepartmentInfoForm( - DepartmentInfoForm.getIdDepartment(), - DepartmentInfoForm.getNmDepartment())) - .distinct() - .toList(); - - - } - @GetMapping("/insertEmployeeInput/searchDepartment/searchDivision") - @ResponseBody - public ListdivisionBydepartment( - @RequestParam("idDepartment")Integer idDepartment){ - List divisionBydepartment= - DivisionInfoForm.convertFrom( - searchDepartment.searchByIdDepartment(idDepartment)); - - return divisionBydepartment - .stream() - .map(DivisionInfoForm-> new DivisionInfoForm( - DivisionInfoForm.getIdDivision(), - DivisionInfoForm.getNmDivision())) - .distinct() - .toList(); - - - } + e.printStackTrace(); + + // エラーログ出力 + LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); + // エラー画面遷移 + return TransitionTargetPageNameKeyword.ERROR_HTML; + } + } + + /** + * 社員情報登録画面の部情報のプルダウンの表示を行う + * + * @param idHeadquarters + * @return 遷移先の画面 + */ + //画面で本部のプルダウンが選択された時にJSでこのメソッドに飛ぶ + @GetMapping("insertEmployeeInput/searchDepartment") + @ResponseBody + public List departmentsByHeadquarters( + @RequestParam("id_headquarters") Integer idHeadquarters) { + List departmentByHeadquarters = DepartmentInfoForm.convertFrom( + searchDepartment.searchByIdHeadquarters(idHeadquarters)); + return departmentByHeadquarters + .stream() + .map(DepartmentInfoForm -> new DepartmentInfoForm( + DepartmentInfoForm.getIdDepartment(), + DepartmentInfoForm.getNmDepartment())) + .distinct() + .toList(); + + } + + /** + * 社員情報登録画面の課情報のプルダウンの表示を行う + * + * @param idDepartment + * @return 遷移先の画面 + */ + //画面で部のプルダウンが選択された時にJSでこのメソッドに飛ぶ + @GetMapping("/insertEmployeeInput/searchDepartment/searchDivision") + @ResponseBody + public List divisionBydepartment( + @RequestParam("id_department") Integer idDepartment) { + List divisionByDepartment = DivisionInfoForm.convertFrom( + searchDepartment.searchByIdDepartment(idDepartment)); + return divisionByDepartment + .stream() + .map(DivisionInfoForm -> new DivisionInfoForm( + DivisionInfoForm.getIdDivision(), + DivisionInfoForm.getNmDivision())) + .distinct() + .toList(); + + } } - - - diff --git a/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/LoginController.java b/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/LoginController.java index 036bee3..882d364 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/LoginController.java +++ b/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/LoginController.java @@ -1,5 +1,18 @@ package com.example.rhizome.app.presentation.controller; +import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.*; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.servlet.http.HttpSession; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; import com.example.rhizome.app.domain.model.LoginInfo; import com.example.rhizome.app.domain.model.LoginUser; @@ -11,18 +24,6 @@ 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; /** * ログイン関連のコントローラ @@ -30,119 +31,120 @@ import static com.example.rhizome.app.presentation.controller.pageproperty.Trans @Controller public class LoginController { - // ログ出力用インスタンス - private final static Logger LOGGER = Logger.getLogger(LoginController.class.getName()); + // ログ出力用インスタンス + private final static Logger LOGGER = Logger.getLogger(LoginController.class.getName()); - // エラーメッセージ用の定数フィールド - private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!"; + // エラーメッセージ用の定数フィールド + private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!"; - HttpSession httpSession; - Login login; + HttpSession httpSession; + Login login; - @Autowired - public LoginController(HttpSession httpSession, Login login) { - this.httpSession = httpSession; - this.login = login; - } + @Autowired + public LoginController(HttpSession httpSession, Login login) { + this.httpSession = httpSession; + this.login = login; + } - @ModelAttribute - public LoginUserForm loginUserForm() { - return new LoginUserForm(); - } + @ModelAttribute + public LoginUserForm loginUserForm() { + return new LoginUserForm(); + } - /** - * 画面から渡ってきたパラメータのチェックを行う - * - * @param loginInfoForm mailAddress, password を保持したインスタンス - * @param model ビューにデータを渡すためのコンテナ - * @return 遷移先の画面 - */ - @RequestMapping(value = DO_LOGIN, method = RequestMethod.POST) - public String doLogin(LoginInfoForm loginInfoForm, Model model) { + /** + * 画面から渡ってきたパラメータのチェックを行う + * + * @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またはパスワードが間違っています"; + // ログに出力する + final String MAIL_ADDRESS_PASSWORD_ERROR = "メールアドレス、パスワードの入力内容に誤りがあります"; + // 発生しうるErrorに対するメッセージ + final String LOGIN_ERROR = "IDまたはパスワードが間違っています"; - try { - // mailAddress, password の入力に誤りがあるかチェック - if (!LoginUserForm.checkParameter(loginInfoForm)) { + try { + // mailAddress, password の入力に誤りがあるかチェック + if (!LoginUserForm.checkParameter(loginInfoForm)) { - // mail,passwordが仕様を満たしていない場合 - model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(MAIL_ADDRESS_PASSWORD_ERROR)); + // 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.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者情報インスタンスを作成 + 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; - } + // 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 loginUser = login.doLogin(loginInfo); - // ログイン者の情報をセッション情報に格納 - // セッションに loginUser 情報を保持し続ける = ログイン中として扱う - httpSession.setAttribute(SessionKeyword.LOGIN_USER, LoginUserForm.convertFrom(loginUser)); + // ログイン者の情報をセッション情報に格納 + // セッションに loginUser 情報を保持し続ける = ログイン中として扱う + httpSession.setAttribute(SessionKeyword.LOGIN_USER, LoginUserForm.convertFrom(loginUser)); - // 管理者かチェック - if (!loginUser.isAdminUser()) { - // 管理者ではない場合直で自分の情報を更新するページに遷移する - // 編集対象のログイン者の情報を画面に渡す値にセット - model.addAttribute(PageReturnAttributeKeyword.UPDATE_PERSONAL_EMPLOYEE_USER_FORM, UpdatePersonalUserForm.convertFrom(loginUser)); - // 個人の情報更新ページに遷移 - return TransitionTargetPageNameKeyword.UPDATE_PERSONAL_EMPLOYEE_INPUT_HTML; - } + // 管理者かチェック + if (!loginUser.isAdminUser()) { + // 管理者ではない場合直で自分の情報を更新するページに遷移する + // 編集対象のログイン者の情報を画面に渡す値にセット + model.addAttribute(PageReturnAttributeKeyword.UPDATE_PERSONAL_EMPLOYEE_USER_FORM, + UpdatePersonalUserForm.convertFrom(loginUser)); + // 個人の情報更新ページに遷移 + return TransitionTargetPageNameKeyword.UPDATE_PERSONAL_EMPLOYEE_INPUT_HTML; + } - // メニュー画面に遷移 - return TransitionTargetPageNameKeyword.MENU_HTML; + // メニュー画面に遷移 + return TransitionTargetPageNameKeyword.MENU_HTML; - } catch (Exception e) { - // ログイン情報の破棄 - httpSession.invalidate(); - e.printStackTrace(); - // エラーログ出力 - LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); - // エラー画面に遷移 - return TransitionTargetPageNameKeyword.ERROR_HTML; - } - } + } catch (Exception e) { + // ログイン情報の破棄 + httpSession.invalidate(); + e.printStackTrace(); + // エラーログ出力 + LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); + // エラー画面に遷移 + return TransitionTargetPageNameKeyword.ERROR_HTML; + } + } - /** - * ログイン者情報のインスタンスを作成 - * - * @param httpSession セッション情報 - * @param loginInfoForm mailAddress, password を保持したインスタンス - */ - private static LoginInfo createLoginInfo(HttpSession httpSession, LoginInfoForm loginInfoForm) { - // セッションからログイン者情報を取得 - LoginUserForm loginUserForm = (LoginUserForm) httpSession.getAttribute(SessionKeyword.LOGIN_USER); + /** + * ログイン者情報のインスタンスを作成 + * + * @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()); - } + // セッションにログイン者情報があるか + if (loginUserForm != null) { + // セッションにログイン者情報がある場合 + return new LoginInfo(loginUserForm.getMailAddress(), loginUserForm.getPassword()); + } - // セッションにない場合は画面からの input 値 を取得 - return new LoginInfo( - loginInfoForm.getMailAddress(), - loginInfoForm.getPassword() - ); - } + // セッションにない場合は画面からの input 値 を取得 + return new LoginInfo( + loginInfoForm.getMailAddress(), + loginInfoForm.getPassword()); + } } diff --git a/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/LogoutController.java b/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/LogoutController.java index dbc94fc..6e580b8 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/LogoutController.java +++ b/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/LogoutController.java @@ -1,10 +1,12 @@ package com.example.rhizome.app.presentation.controller; -import com.example.rhizome.aop.aspect.PermissionCheck; -import com.example.rhizome.aop.aspect.SessionCheck; -import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword; -import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword; -import com.example.rhizome.app.presentation.form.LoginUserForm; +import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.*; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.servlet.http.HttpSession; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; @@ -12,11 +14,11 @@ 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; +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; /** * ログアウト処理のコントローラ @@ -24,50 +26,50 @@ import static com.example.rhizome.app.presentation.controller.pageproperty.Trans @Controller public class LogoutController { - // ログ出力用インスタンス - private final static Logger LOGGER = Logger.getLogger(LogoutController.class.getName()); - // エラーメッセージ用の定数フィールド - private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!"; + // ログ出力用インスタンス + private final static Logger LOGGER = Logger.getLogger(LogoutController.class.getName()); + // エラーメッセージ用の定数フィールド + private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!"; - HttpSession httpSession; + HttpSession httpSession; - @Autowired - public LogoutController(HttpSession httpSession) { - this.httpSession = httpSession; - } + @Autowired + public LogoutController(HttpSession httpSession) { + this.httpSession = httpSession; + } - @ModelAttribute - public LoginUserForm loginUserForm() { - return new LoginUserForm(); - } + @ModelAttribute + public LoginUserForm loginUserForm() { + return new LoginUserForm(); + } - /** - * ログアウト処理 - * - * @param model ビューにデータを渡すためのコンテナ - * @return 遷移先の画面 - */ - @PermissionCheck - @SessionCheck - @RequestMapping(value = LOGOUT, method = RequestMethod.POST) - public String doLogout(Model model) { - try { - // セッション情報の破棄 - httpSession.invalidate(); + /** + * ログアウト処理 + * + * @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; + // ログイン画面に遷移するための情報を設定 + model.addAttribute(PageReturnAttributeKeyword.LOGIN_INFO_FORM, loginUserForm()); + // login.html に遷移 + return TransitionTargetPageNameKeyword.LOGIN_HTML; - } catch (Exception e) { + } catch (Exception e) { - // エラーログ出力 - LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); - // エラーページに遷移 - return TransitionTargetPageNameKeyword.ERROR_HTML; - } + // エラーログ出力 + LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); + // エラーページに遷移 + return TransitionTargetPageNameKeyword.ERROR_HTML; + } - } + } } diff --git a/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/MenuController.java b/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/MenuController.java index 7ba1e9f..c3c6f4a 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/MenuController.java +++ b/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/MenuController.java @@ -1,12 +1,13 @@ package com.example.rhizome.app.presentation.controller; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; + import com.example.rhizome.aop.aspect.PermissionCheck; import com.example.rhizome.aop.aspect.SessionCheck; import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword; import com.example.rhizome.app.presentation.form.MessageForm; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.RequestMapping; /** * メニュー画面表示用コントローラ @@ -14,20 +15,20 @@ import org.springframework.web.bind.annotation.RequestMapping; @Controller public class MenuController { - @ModelAttribute - public MessageForm messageForm() { - return new MessageForm(); - } + @ModelAttribute + public MessageForm messageForm() { + return new MessageForm(); + } - /** - * メニュー画面に遷移 - */ - @PermissionCheck - @SessionCheck - @RequestMapping(value = TransitionTargetPageNameKeyword.SHOW_MENU) - public String showMenu() { - // メニュー画面遷移 - return TransitionTargetPageNameKeyword.MENU_HTML; - } + /** + * メニュー画面に遷移 + */ + @PermissionCheck + @SessionCheck + @RequestMapping(value = TransitionTargetPageNameKeyword.SHOW_MENU) + public String showMenu() { + // メニュー画面遷移 + return TransitionTargetPageNameKeyword.MENU_HTML; + } } diff --git a/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/SelectDepartmentController.java b/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/SelectDepartmentController.java index 06231de..d8d589b 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/SelectDepartmentController.java +++ b/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/SelectDepartmentController.java @@ -26,99 +26,98 @@ import com.example.rhizome.app.presentation.form.SearchConditionDepartmentForm; @Controller public class SelectDepartmentController { - // ログ出力用インスタンス - private final static Logger LOGGER = Logger.getLogger(SelectDepartmentController.class.getName()); - // エラーメッセージ用の定数フィールド - private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!"; + // ログ出力用インスタンス + private final static Logger LOGGER = Logger.getLogger(SelectDepartmentController.class.getName()); + // エラーメッセージ用の定数フィールド + private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!"; - HttpSession httpSession; - SearchDepartment searchDepartment; + HttpSession httpSession; + SearchDepartment searchDepartment; - @Autowired - public SelectDepartmentController(HttpSession httpSession, SearchDepartment searchDepartment) { - this.httpSession = httpSession; - this.searchDepartment = searchDepartment; - } + @Autowired + public SelectDepartmentController(HttpSession httpSession, SearchDepartment searchDepartment) { + this.httpSession = httpSession; + this.searchDepartment = searchDepartment; + } - @ModelAttribute - public SearchConditionDepartmentForm searchConditionDepartmentForm() { - return new SearchConditionDepartmentForm(); - } + @ModelAttribute + public SearchConditionDepartmentForm searchConditionDepartmentForm() { + return new SearchConditionDepartmentForm(); + } - /** - * 部署検索画面表示処理コントローラ - * - * @param model ビューにデータを渡すためのコンテナ - * @return 遷移先の画面 - */ - @PermissionCheck - @SessionCheck - @RequestMapping(value = TransitionTargetPageNameKeyword.SELECT_DEPARTMENT, method = RequestMethod.POST) - public String select(SearchConditionDepartmentForm searchConditionDepartmentForm, Model model) { + /** + * 部署検索画面表示処理コントローラ + * + * @param model ビューにデータを渡すためのコンテナ + * @return 遷移先の画面 + */ + @PermissionCheck + @SessionCheck + @RequestMapping(value = TransitionTargetPageNameKeyword.SELECT_DEPARTMENT, method = RequestMethod.POST) + public String select(SearchConditionDepartmentForm searchConditionDepartmentForm, Model model) { - try { + try { - // 部署一覧を取得し、画面に返す用のクラスに詰め替える - // 作成した部署一覧をセット - model.addAttribute( - PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, - DepartmentForm.convertFrom( - searchDepartment.searchAllDepartmentTable(SearchConditionDepartmentForm.convertTo(searchConditionDepartmentForm)) - - )); + // 部署一覧を取得し、画面に返す用のクラスに詰め替える + // 作成した部署一覧をセット + model.addAttribute( + PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, + DepartmentForm.convertFrom( + searchDepartment.searchAllDepartmentTable( + SearchConditionDepartmentForm.convertTo(searchConditionDepartmentForm)) - // 検索ページに遷移 - return TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_HTML; + )); - } catch (Exception e) { - // ログイン情報の破棄 - httpSession.invalidate(); + // 検索ページに遷移 + return TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_HTML; - e.printStackTrace(); + } catch (Exception e) { + // ログイン情報の破棄 + httpSession.invalidate(); - // エラーログ出力 - LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); - // エラー画面遷移 - return TransitionTargetPageNameKeyword.ERROR_HTML; - } + e.printStackTrace(); - } + // エラーログ出力 + LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); + // エラー画面遷移 + return TransitionTargetPageNameKeyword.ERROR_HTML; + } - /** - * 部署検索画面表示処理コントローラ - * - * @param model ビューにデータを渡すためのコンテナ - * @return 遷移先の画面 - */ - @PermissionCheck - @SessionCheck - @RequestMapping(value = TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_ALL, method = RequestMethod.POST) - public String selectAll(Model model) { + } - try { - // 部署一覧を取得し、画面に返す用のクラスに詰め替える - // 作成した部署一覧をセット - model.addAttribute( - PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, - DepartmentForm.convertFrom( - searchDepartment.searchAllDepartmentTable() - ) - ); + /** + * 部署検索画面表示処理コントローラ + * + * @param model ビューにデータを渡すためのコンテナ + * @return 遷移先の画面 + */ + @PermissionCheck + @SessionCheck + @RequestMapping(value = TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_ALL, method = RequestMethod.POST) + public String selectAll(Model model) { - // 検索ページに遷移 - return TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_HTML; + try { + // 部署一覧を取得し、画面に返す用のクラスに詰め替える + // 作成した部署一覧をセット + model.addAttribute( + PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, + DepartmentForm.convertFrom( + searchDepartment.searchAllDepartmentTable())); - } catch (Exception e) { - // ログイン情報の破棄 - httpSession.invalidate(); + // 検索ページに遷移 + return TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_HTML; - e.printStackTrace(); + } catch (Exception e) { + // ログイン情報の破棄 + httpSession.invalidate(); - // エラーログ出力 - LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); - // エラー画面遷移 - return TransitionTargetPageNameKeyword.ERROR_HTML; - } + e.printStackTrace(); - } + // エラーログ出力 + LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); + // エラー画面遷移 + return TransitionTargetPageNameKeyword.ERROR_HTML; + } + + } } diff --git a/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/SelectEmployeeController.java b/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/SelectEmployeeController.java index 93dabaa..9012e80 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/SelectEmployeeController.java +++ b/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/SelectEmployeeController.java @@ -75,9 +75,11 @@ public class SelectEmployeeController { ); // 検索条件を元に検索を実施 // 取得した EmployeeInfo( employee + department )の情報を画面に返す用の型に詰め替えてセット + //プラスで勤続年数を計算してformにセット - - ListemployeeInfoForm = EmployeeInfoForm.convertFrom(searchEmployeeInfo.searchBy(SearchConditionEmployeeForm.convertTo(searchConditionEmployeeForm))); + ListemployeeInfoForm = EmployeeInfoForm.convertFrom( + searchEmployeeInfo.searchBy( + SearchConditionEmployeeForm.convertTo(searchConditionEmployeeForm))); for(EmployeeInfoForm form:employeeInfoForm) { String tenure = tenureCalc.tenureCalc(form.getHireDate()); form.setTenure(tenure); diff --git a/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/UpdateDepartmentResultController.java b/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/UpdateDepartmentResultController.java index 4c491a0..4ab9ac8 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/UpdateDepartmentResultController.java +++ b/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/UpdateDepartmentResultController.java @@ -1,6 +1,6 @@ package com.example.rhizome.app.presentation.controller; - +import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; @@ -15,6 +15,9 @@ import org.springframework.web.bind.annotation.RequestMethod; import com.example.rhizome.aop.aspect.PermissionCheck; import com.example.rhizome.aop.aspect.SessionCheck; +import com.example.rhizome.app.domain.model.Department; +import com.example.rhizome.app.domain.model.Division; +import com.example.rhizome.app.domain.model.Headquarters; import com.example.rhizome.app.domain.model.SearchConditionDepartment; import com.example.rhizome.app.domain.service.SearchDepartment; import com.example.rhizome.app.domain.service.UpdateDepartment; @@ -30,92 +33,139 @@ import com.example.rhizome.app.presentation.form.UpdateDepartmentForm; @Controller public class UpdateDepartmentResultController { - // ログ出力用インスタンス - private final static Logger LOGGER = Logger.getLogger(UpdateEmployeeController.class.getName()); - // エラーメッセージ用の定数フィールド - private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!"; + // ログ出力用インスタンス + private final static Logger LOGGER = Logger.getLogger(UpdateEmployeeController.class.getName()); + // エラーメッセージ用の定数フィールド + private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!"; - HttpSession httpSession; - SearchDepartment searchDepartment; - UpdateDepartment updateDepartment; - + HttpSession httpSession; + SearchDepartment searchDepartment; + UpdateDepartment updateDepartment; - @Autowired - public UpdateDepartmentResultController(HttpSession httpSession, SearchDepartment searchDepartment, UpdateDepartment updateDepartment) { - this.httpSession = httpSession; - this.searchDepartment = searchDepartment; - this.updateDepartment = updateDepartment; - } - - /** - * 更新結果画面表示処理 - * - * @param updateDepartmentForm 更新画面のフォーム - * @param model ビューにデータを渡すためのコンテナ - * @return 遷移先の画面 - */ - @PermissionCheck - @SessionCheck - @RequestMapping(value = TransitionTargetPageNameKeyword.UPDATE_DEPARTMENT_RESULT, method = RequestMethod.POST) - public String updateEmployeeResult(@ModelAttribute UpdateDepartmentForm updateDepartmentForm, Model model) { + @Autowired + public UpdateDepartmentResultController(HttpSession httpSession, SearchDepartment searchDepartment, + UpdateDepartment updateDepartment) { + this.httpSession = httpSession; + this.searchDepartment = searchDepartment; + this.updateDepartment = updateDepartment; + } - final String NOTHING = "項目が空欄です。"; - final String DUPLICATION = "既に同名の部署が存在するか、値が変更されていません。"; - final String UPDATE_COMPLETE = "更新が完了しました。"; + /** + * 更新結果画面表示処理 + * + * @param updateDepartmentForm 更新画面のフォーム + * @param model ビューにデータを渡すためのコンテナ + * @return 遷移先の画面 + */ + @PermissionCheck + @SessionCheck + @RequestMapping(value = TransitionTargetPageNameKeyword.UPDATE_DEPARTMENT_RESULT, method = RequestMethod.POST) + public String updateEmployeeResult(@ModelAttribute UpdateDepartmentForm updateDepartmentForm, Model model) { - try { - // 更新対象の部署データがない - if (updateDepartmentForm.getNmHeadquarters().isBlank()|| - updateDepartmentForm.getNmDepartment().isBlank()|| - updateDepartmentForm.getNmDivision().isBlank()) { - model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(NOTHING)); - model.addAttribute(PageReturnAttributeKeyword.UPDATE_DEPARTMENT_FORM, updateDepartmentForm); + final String NOTHING = "項目が空欄です。"; + final String DUPLICATION = "既に同名の部署が存在するか、値が変更されていません。"; + final String UPDATE_COMPLETE = "更新が完了しました。"; - return TransitionTargetPageNameKeyword.UPDATE_DEPARTMENT_INPUT_HTML; - } + try { + // 更新対象の部署データがない + if (updateDepartmentForm.getNmHeadquarters().isBlank() || + updateDepartmentForm.getNmDepartment().isBlank() || + updateDepartmentForm.getNmDivision().isBlank()) { + model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(NOTHING)); + model.addAttribute(PageReturnAttributeKeyword.UPDATE_DEPARTMENT_FORM, updateDepartmentForm); - // 部署名で重複が無いかチェック - if (searchDepartment.searchAllDepartmentTable( - new SearchConditionDepartment( - updateDepartmentForm.getIdHeadquarters(), - updateDepartmentForm.getNmHeadquarters()), - new SearchConditionDepartment( - updateDepartmentForm.getIdDepartment(), - updateDepartmentForm.getNmDepartment()), - new SearchConditionDepartment( - updateDepartmentForm.getIdDivision(), - updateDepartmentForm.getNmDivision()))) { - // 存在する場合はエラーメッセージを設定して更新入力画面に遷移 - model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DUPLICATION)); - model.addAttribute(PageReturnAttributeKeyword.UPDATE_DEPARTMENT_FORM, updateDepartmentForm); + return TransitionTargetPageNameKeyword.UPDATE_DEPARTMENT_INPUT_HTML; + } + // 部署名で重複が無いかチェック + List beforeHeadquartersList = searchDepartment + .searchHeadquartersByIdHeadquarters(updateDepartmentForm.getIdHeadquarters()); + List beforeDepartmentList = searchDepartment + .searchDepartmentByIdDepartment(updateDepartmentForm.getIdDepartment()); + List beforeDivisionList = searchDepartment + .searchDivisionByIdDivision(updateDepartmentForm.getIdDivision()); - return TransitionTargetPageNameKeyword.UPDATE_DEPARTMENT_INPUT_HTML; - } + Headquarters beforeHeadquarters = beforeHeadquartersList.get(0); + Department beforeDepartment = beforeDepartmentList.get(0); + Division beforeDivision = beforeDivisionList.get(0); - // 部署情報更新 - updateDepartment.updateDepartment(UpdateDepartmentForm.convertTo(updateDepartmentForm)); + Headquarters afterHeadquarters = new Headquarters( + updateDepartmentForm.getIdHeadquarters(), + updateDepartmentForm.getNmHeadquarters(), + null); + Department afterDepartment = new Department( + updateDepartmentForm.getIdDepartment(), + updateDepartmentForm.getNmDepartment(), + null, + updateDepartmentForm.getIdHeadquarters()); + Division afterDivision = new Division( + updateDepartmentForm.getIdDivision(), + updateDepartmentForm.getNmDivision(), + null, + updateDepartmentForm.getIdDepartment()); - // 部署一覧取得 - model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, DepartmentForm.convertFrom( - searchDepartment.searchAllDepartmentTable()) - ); - // 更新結果のメッセージを画面にセットし一覧画面に遷移 - model.addAttribute(PageReturnAttributeKeyword.MESSAGE_INFO, new MessageForm(UPDATE_COMPLETE)); + if (searchDepartment.searchAllDepartmentTable( + new SearchConditionDepartment( + updateDepartmentForm.getIdHeadquarters(), + updateDepartmentForm.getNmHeadquarters()), + new SearchConditionDepartment( + updateDepartmentForm.getIdDepartment(), + updateDepartmentForm.getNmDepartment()), + new SearchConditionDepartment( + updateDepartmentForm.getIdDivision(), + updateDepartmentForm.getNmDivision())) - // forward 先で不用意な動作をしないために UpdateEmployeeInfoForm をクリア - return "forward:" + TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_ALL; + || (!beforeHeadquarters.getNmHeadquarters().equals(afterHeadquarters.getNmHeadquarters()) + && + !searchDepartment.searchByHeadquarters( + new SearchConditionDepartment( + null, + updateDepartmentForm.getNmHeadquarters())) + .isEmpty()) + || (!beforeDepartment.getNmDepartment().equals(afterDepartment.getNmDepartment()) + && + !searchDepartment.searchByDepartment( + new SearchConditionDepartment( + null, + updateDepartmentForm.getNmDepartment())) + .isEmpty()) + || (!beforeDivision.getNmDivision().equals(afterDivision.getNmDivision()) + && + !searchDepartment.searchByDivision( + new SearchConditionDepartment( + null, + updateDepartmentForm.getNmDivision())) + .isEmpty()) + ) { + // 存在する場合はエラーメッセージを設定して更新入力画面に遷移 + model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DUPLICATION)); + model.addAttribute(PageReturnAttributeKeyword.UPDATE_DEPARTMENT_FORM, updateDepartmentForm); - } catch (Exception e) { - // ログイン情報の破棄 - httpSession.invalidate(); + return TransitionTargetPageNameKeyword.UPDATE_DEPARTMENT_INPUT_HTML; + } - e.printStackTrace(); - // エラーログ出力 - LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); - // エラー画面遷移 - return TransitionTargetPageNameKeyword.ERROR_HTML; - } + // 部署情報更新 + updateDepartment.updateDepartment(UpdateDepartmentForm.convertTo(updateDepartmentForm)); - } + // 部署一覧取得 + model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, DepartmentForm.convertFrom( + searchDepartment.searchAllDepartmentTable())); + // 更新結果のメッセージを画面にセットし一覧画面に遷移 + model.addAttribute(PageReturnAttributeKeyword.MESSAGE_INFO, new MessageForm(UPDATE_COMPLETE)); + + // forward 先で不用意な動作をしないために UpdateEmployeeInfoForm をクリア + return "forward:" + TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_ALL; + + } catch (Exception e) { + // ログイン情報の破棄 + httpSession.invalidate(); + + e.printStackTrace(); + // エラーログ出力 + LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); + // エラー画面遷移 + return TransitionTargetPageNameKeyword.ERROR_HTML; + } + + } } diff --git a/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/UpdateEmployeeController.java b/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/UpdateEmployeeController.java index a20c3de..908716d 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/UpdateEmployeeController.java +++ b/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/UpdateEmployeeController.java @@ -9,20 +9,27 @@ import javax.servlet.http.HttpSession; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; 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 org.springframework.web.bind.annotation.ResponseBody; import com.example.rhizome.aop.aspect.PermissionCheck; import com.example.rhizome.aop.aspect.SessionCheck; +import com.example.rhizome.app.domain.model.AllDepartmentInfo; import com.example.rhizome.app.domain.model.AllEmployeeInfo; +import com.example.rhizome.app.domain.model.SearchConditionDepartment; import com.example.rhizome.app.domain.model.SearchConditionEmployee; +import com.example.rhizome.app.domain.service.RegisterEmployee; 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.DepartmentInfoForm; +import com.example.rhizome.app.presentation.form.DivisionInfoForm; +import com.example.rhizome.app.presentation.form.HeadquartersInfoForm; import com.example.rhizome.app.presentation.form.MessageForm; import com.example.rhizome.app.presentation.form.SearchConditionEmployeeForm; import com.example.rhizome.app.presentation.form.UpdateEmployeeInfoForm; @@ -33,78 +40,136 @@ import com.example.rhizome.app.presentation.form.UpdateEmployeeInfoForm; @Controller public class UpdateEmployeeController { - // ログ出力用インスタンス - private final static Logger LOGGER = Logger.getLogger(UpdateEmployeeController.class.getName()); - // エラーメッセージ用の定数フィールド - private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!"; + // ログ出力用インスタンス + private final static Logger LOGGER = Logger.getLogger(UpdateEmployeeController.class.getName()); + // エラーメッセージ用の定数フィールド + private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!"; - HttpSession httpSession; - SearchDepartment searchDepartment; - SearchEmployeeInfo searchEmployeeInfo; + HttpSession httpSession; + SearchDepartment searchDepartment; + SearchEmployeeInfo searchEmployeeInfo; + RegisterEmployee registerEmployee; - @Autowired - public UpdateEmployeeController(HttpSession httpSession, SearchDepartment searchDepartment, SearchEmployeeInfo searchEmployeeInfo) { - this.httpSession = httpSession; - this.searchDepartment = searchDepartment; - this.searchEmployeeInfo = searchEmployeeInfo; - } + @Autowired + public UpdateEmployeeController(HttpSession httpSession, SearchDepartment searchDepartment, + SearchEmployeeInfo searchEmployeeInfo, RegisterEmployee registerEmployee) { + this.httpSession = httpSession; + this.searchDepartment = searchDepartment; + this.searchEmployeeInfo = searchEmployeeInfo; + this.registerEmployee = registerEmployee; + } - @ModelAttribute - public SearchConditionEmployeeForm searchConditionEmployeeForm() { - return new SearchConditionEmployeeForm(); - } + @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 = "更新対象のデータが見つかりません。"; + /** + * 更新対象の 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.searchAllDepartmentTable())); + try { + // 部署コードリストを作成し、画面に返す値としてセット + model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, HeadquartersInfoForm.convertFrom( + searchDepartment.searchAllDepartmentTable())); + // id を条件に更新対象のレコードを検索、取得する + List employeeInfoList = searchEmployeeInfo.searchBy( + new SearchConditionEmployee(idEmployee, + null, + null, + null, + null)); - // id を条件に更新対象のレコードを検索、取得する - List 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; + } + //idDivisionからidHeadquartersを調べてUpdateEmployeeInfoFormに入れる + System.out.println("A"); + UpdateEmployeeInfoForm updateInfo = UpdateEmployeeInfoForm.convertFrom(employeeInfoList.get(0)); + SearchConditionDepartment beforeUpdate = new SearchConditionDepartment( + updateInfo.getIdDivision(), + null); + List afterSearchDepartment = searchDepartment.searchAllDepartmentTable(beforeUpdate); - // DBに更新対象のデータがあるか - if (employeeInfoList.isEmpty()) { - // ない場合はエラーメッセージをセットして検索画面に戻る - model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(UPDATE_TARGET_ID_NOT_FOUND)); - return "forward:" + TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_INFO; - } + updateInfo.setIdHeadquarters(afterSearchDepartment.get(0).getHeadquarters().getIdHeadquarters()); - // 更新画面に遷移 - model.addAttribute(PageReturnAttributeKeyword.UPDATE_EMPLOYEE_INFO_FORM, UpdateEmployeeInfoForm.convertFrom(employeeInfoList.get(0))); + // 更新画面に遷移 + model.addAttribute(PageReturnAttributeKeyword.UPDATE_EMPLOYEE_INFO_FORM, + updateInfo); - // Update画面に遷移 - return TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_INPUT_HTML; + // Update画面に遷移 + return TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_INPUT_HTML; + } catch (Exception e) { + // ログイン情報の破棄 + httpSession.invalidate(); - } catch (Exception e) { - // ログイン情報の破棄 - httpSession.invalidate(); + e.printStackTrace(); - e.printStackTrace(); + // エラーログ出力 + LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); + // エラー画面遷移 + return TransitionTargetPageNameKeyword.ERROR_HTML; - // エラーログ出力 - LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e); - // エラー画面遷移 - return TransitionTargetPageNameKeyword.ERROR_HTML; + } + } - } - } + /** + * 社員情報更新画面の部情報のプルダウンの表示を行う + * + * @param idHeadquarters + * @return 遷移先の画面 + */ + //画面で本部のプルダウンが選択された時にJSでこのメソッドに飛ぶ + @GetMapping("updateEmployeeInput/searchDepartment") + @ResponseBody + public List departmentsByHeadquarters( + @RequestParam("id_headquarters") Integer idHeadquarters) { + List departmentByHeadquarters = DepartmentInfoForm.convertFrom( + searchDepartment.searchByIdHeadquarters(idHeadquarters)); + return departmentByHeadquarters + .stream() + .map(DepartmentInfoForm -> new DepartmentInfoForm( + DepartmentInfoForm.getIdDepartment(), + DepartmentInfoForm.getNmDepartment())) + .distinct() + .toList(); + + } + + /** + * 社員情報更新画面の課情報のプルダウンの表示を行う + * + * @param idDepartment + * @return 遷移先の画面 + */ + //画面で部のプルダウンが選択された時にJSでこのメソッドに飛ぶ + @GetMapping("/updateEmployeeInput/searchDepartment/searchDivision") + @ResponseBody + public List divisionBydepartment( + @RequestParam("id_department") Integer idDepartment) { + List divisionByDepartment = DivisionInfoForm.convertFrom( + searchDepartment.searchByIdDepartment(idDepartment)); + return divisionByDepartment + .stream() + .map(DivisionInfoForm -> new DivisionInfoForm( + DivisionInfoForm.getIdDivision(), + DivisionInfoForm.getNmDivision())) + .distinct() + .toList(); + + } } diff --git a/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/UpdateEmployeeResultController.java b/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/UpdateEmployeeResultController.java index e6fbaaa..8e35d8f 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/UpdateEmployeeResultController.java +++ b/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/UpdateEmployeeResultController.java @@ -151,6 +151,7 @@ public class UpdateEmployeeResultController { return TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_INPUT_HTML; } + //勤続年数は更新対象ではないのでそのまま移し替える updateEmployeeInfoForm.setHireDate(beforeEmployee.getHireDate()); // 画面用の型からビジネスロジック用のモデルに変換し、Updateを実行 diff --git a/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/pageproperty/PageReturnAttributeKeyword.java b/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/pageproperty/PageReturnAttributeKeyword.java index 281c7b4..7daacce 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/pageproperty/PageReturnAttributeKeyword.java +++ b/EM-System/src/main/java/com/example/rhizome/app/presentation/controller/pageproperty/PageReturnAttributeKeyword.java @@ -16,5 +16,7 @@ public class PageReturnAttributeKeyword { 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"; + public static final String HEADQUARTERS_FORM_LIST = "headquartersFormList"; + public static final String DIVISION_FORM_LIST = "divisionFormList"; } diff --git a/EM-System/src/main/java/com/example/rhizome/app/presentation/form/DepartmentForm.java b/EM-System/src/main/java/com/example/rhizome/app/presentation/form/DepartmentForm.java index a6d7325..14f54e3 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/presentation/form/DepartmentForm.java +++ b/EM-System/src/main/java/com/example/rhizome/app/presentation/form/DepartmentForm.java @@ -66,6 +66,6 @@ public class DepartmentForm { */ public static List convertFrom(ListallDepartmentInfoList ) { - return allDepartmentInfoList.stream().map(DepartmentForm::convertFrom).toList(); + return allDepartmentInfoList.stream().map(DepartmentForm::convertFrom).distinct().toList(); } } diff --git a/EM-System/src/main/java/com/example/rhizome/app/presentation/form/DepartmentInfoForm.java b/EM-System/src/main/java/com/example/rhizome/app/presentation/form/DepartmentInfoForm.java index 99f6367..ef9584f 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/presentation/form/DepartmentInfoForm.java +++ b/EM-System/src/main/java/com/example/rhizome/app/presentation/form/DepartmentInfoForm.java @@ -2,6 +2,7 @@ package com.example.rhizome.app.presentation.form; import java.util.List; +import com.example.rhizome.app.domain.model.AllDepartmentInfo; import com.example.rhizome.app.domain.model.Department; import lombok.AllArgsConstructor; @@ -34,4 +35,14 @@ public class DepartmentInfoForm { ) { return DepartmentList.stream().map(DepartmentInfoForm::convertFrom).toList(); } + public static DepartmentInfoForm convertFrom(AllDepartmentInfo allDepartmentInfo) { + return new DepartmentInfoForm( + allDepartmentInfo.getDepartment().getIdDepartment(), + allDepartmentInfo.getDepartment().getNmDepartment() + ); + } + public static List convertFromTo(ListAllDepartmentInfoList + ) { + return AllDepartmentInfoList.stream().map(DepartmentInfoForm::convertFrom).distinct().toList(); + } } \ No newline at end of file diff --git a/EM-System/src/main/java/com/example/rhizome/app/presentation/form/DivisionInfoForm.java b/EM-System/src/main/java/com/example/rhizome/app/presentation/form/DivisionInfoForm.java index 2a0028e..7e5b73f 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/presentation/form/DivisionInfoForm.java +++ b/EM-System/src/main/java/com/example/rhizome/app/presentation/form/DivisionInfoForm.java @@ -2,6 +2,7 @@ package com.example.rhizome.app.presentation.form; import java.util.List; +import com.example.rhizome.app.domain.model.AllDepartmentInfo; import com.example.rhizome.app.domain.model.Division; import lombok.AllArgsConstructor; @@ -32,4 +33,14 @@ public class DivisionInfoForm { ) { return divisionList.stream().map(DivisionInfoForm::convertFrom).toList(); } + public static DivisionInfoForm convertFrom(AllDepartmentInfo allDepartmentInfo) { + return new DivisionInfoForm( + allDepartmentInfo.getDivision().getIdDivision(), + allDepartmentInfo.getDivision().getNmDivision() + ); + } + public static List convertFromTo(ListAllDepartmentInfoList + ) { + return AllDepartmentInfoList.stream().map(DivisionInfoForm::convertFrom).distinct().toList(); + } } \ No newline at end of file diff --git a/EM-System/src/main/java/com/example/rhizome/app/presentation/form/EmployeeInfoForm.java b/EM-System/src/main/java/com/example/rhizome/app/presentation/form/EmployeeInfoForm.java index 15c4c7a..6e35855 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/presentation/form/EmployeeInfoForm.java +++ b/EM-System/src/main/java/com/example/rhizome/app/presentation/form/EmployeeInfoForm.java @@ -1,6 +1,5 @@ package com.example.rhizome.app.presentation.form; - import java.util.List; import com.example.rhizome.app.domain.model.AllEmployeeInfo; @@ -17,97 +16,94 @@ import lombok.NoArgsConstructor; @NoArgsConstructor public class EmployeeInfoForm { - /** - * 社員ID - */ - private Integer idEmployee; - /** - * 社員名 - */ - private String nmEmployee; - /** - * 社員名カナ - */ - private String knEmployee; - /** - * メールアドレス - */ - private String mailAddress; - /** - * パスワード - */ - private String password; - /** - * 入社年月日 - */ - private String hireDate; - /** - * 勤続年数 - */ - private String tenure; - /** - * 管理者権限 - */ - private Integer adminAuth; - /** - * 本部ID - */ - private Integer idHeadquarters; - /** - * 本部名 - */ - private String nmHeadquarters; - /** - * 部ID - */ - private Integer idDepartment; - /** - * 部名 - */ - private String nmDepartment; - /** - * 課ID - */ - private Integer idDivision; - /** - * 課名 - */ - private String nmDivision; + /** + * 社員ID + */ + private Integer idEmployee; + /** + * 社員名 + */ + private String nmEmployee; + /** + * 社員名カナ + */ + private String knEmployee; + /** + * メールアドレス + */ + private String mailAddress; + /** + * パスワード + */ + private String password; + /** + * 入社年月日 + */ + private String hireDate; + /** + * 勤続年数 + */ + private String tenure; + /** + * 管理者権限 + */ + private Integer adminAuth; + /** + * 本部ID + */ + private Integer idHeadquarters; + /** + * 本部名 + */ + private String nmHeadquarters; + /** + * 部ID + */ + private Integer idDepartment; + /** + * 部名 + */ + private String nmDepartment; + /** + * 課ID + */ + private Integer idDivision; + /** + * 課名 + */ + private String nmDivision; - /** - * business 層の EmployeeInfo クラスから画面用(presentation 層)の EmployeeInfoForm に - * 変換します。 - * - * @param employeeInfo business 層の EmployeeInfo インスタンス - * @return クラスから画面用(presentation 層)の EmployeeInfoForm インスタンス - */ - public static EmployeeInfoForm convertFrom(AllEmployeeInfo allEmployeeInfo) { - return new EmployeeInfoForm( - allEmployeeInfo.getEmployee().getIdEmployee(), - allEmployeeInfo.getEmployee().getNmEmployee(), - allEmployeeInfo.getEmployee().getKnEmployee(), - allEmployeeInfo.getEmployee().getMailAddress(), - allEmployeeInfo.getEmployee().getPassword(), - allEmployeeInfo.getEmployee().getHireDate(), - null, - allEmployeeInfo.getEmployee().getAdminAuth(), - allEmployeeInfo.getHeadquarters().getIdHeadquarters(), - allEmployeeInfo.getHeadquarters().getNmHeadquarters(), - allEmployeeInfo.getDepartment().getIdDepartment(), - allEmployeeInfo.getDepartment().getNmDepartment(), - allEmployeeInfo.getDivision().getIdDivision(), - allEmployeeInfo.getDivision().getNmDivision() - ); - } + /** + * AllEmployeeInfo からEmployeeInfoForm に変換します。 + * + * @param allEmployeeInfo AllEmployeeInfo インスタンス + * @return EmployeeInfoForm インスタンス + */ + public static EmployeeInfoForm convertFrom(AllEmployeeInfo allEmployeeInfo) { + return new EmployeeInfoForm( + allEmployeeInfo.getEmployee().getIdEmployee(), + allEmployeeInfo.getEmployee().getNmEmployee(), + allEmployeeInfo.getEmployee().getKnEmployee(), + allEmployeeInfo.getEmployee().getMailAddress(), + allEmployeeInfo.getEmployee().getPassword(), + allEmployeeInfo.getEmployee().getHireDate(), + null, + allEmployeeInfo.getEmployee().getAdminAuth(), + allEmployeeInfo.getHeadquarters().getIdHeadquarters(), + allEmployeeInfo.getHeadquarters().getNmHeadquarters(), + allEmployeeInfo.getDepartment().getIdDepartment(), + allEmployeeInfo.getDepartment().getNmDepartment(), + allEmployeeInfo.getDivision().getIdDivision(), + allEmployeeInfo.getDivision().getNmDivision()); + } - /** - * business 層の EmployeeInfo クラスから画面用(presentation 層)の EmployeeInfoForm に - * 変換します。(リスト版) - * - * @param employeeInfoList business 層の EmployeeInfo インスタンスのリスト - * @return クラスから画面用(presentation 層)の EmployeeInfoForm インスタンスのリスト - */ - public static List convertFrom(List allEmployeeInfoList) { - return allEmployeeInfoList.stream().map(EmployeeInfoForm::convertFrom).toList(); - } + /** + * AllEmployeeInfo からEmployeeInfoForm に変換します。(リスト版) + * + * @param allEmployeeInfo AllEmployeeInfo インスタンスのリスト + * @return EmployeeInfoForm インスタンスのリスト + */ + public static List convertFrom(List allEmployeeInfoList) { + return allEmployeeInfoList.stream().map(EmployeeInfoForm::convertFrom).toList(); + } } diff --git a/EM-System/src/main/java/com/example/rhizome/app/presentation/form/HeadquartersInfoForm.java b/EM-System/src/main/java/com/example/rhizome/app/presentation/form/HeadquartersInfoForm.java index 64ef35e..88d51fa 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/presentation/form/HeadquartersInfoForm.java +++ b/EM-System/src/main/java/com/example/rhizome/app/presentation/form/HeadquartersInfoForm.java @@ -13,24 +13,34 @@ import lombok.NoArgsConstructor; @NoArgsConstructor public class HeadquartersInfoForm { /** - * 本部ID - */ - private Integer idHeadquarters; - /** - * 本部名 - */ - private String nmHeadquarters; - - - - public static HeadquartersInfoForm convertFrom(AllDepartmentInfo allDepartmentInfo) { - return new HeadquartersInfoForm( - allDepartmentInfo.getHeadquarters().getIdHeadquarters(), - allDepartmentInfo.getHeadquarters().getNmHeadquarters() - ); - } - public static List convertFrom(ListallDepartmentInfoList - ) { - return allDepartmentInfoList.stream().map(HeadquartersInfoForm::convertFrom).toList(); - } + * 本部ID + */ + private Integer idHeadquarters; + /** + * 本部名 + */ + private String nmHeadquarters; + + /** + * AllDepartmentInfoから HeadquartersInfoFormに変換します。 + * + * @param allDepartmentInfo AllDepartmentInfo インスタンス + * @return HeadquartersInfoForm インスタンス + */ + + public static HeadquartersInfoForm convertFrom(AllDepartmentInfo allDepartmentInfo) { + return new HeadquartersInfoForm( + allDepartmentInfo.getHeadquarters().getIdHeadquarters(), + allDepartmentInfo.getHeadquarters().getNmHeadquarters()); + } + + /** + * AllDepartmentInfoから HeadquartersInfoFormに変換します。(リスト版) + * + * @param allDepartmentInfo AllDepartmentInfo インスタンスのリスト + * @return HeadquartersInfoForm インスタンスのリスト + */ + public static List convertFrom(List allDepartmentInfoList) { + return allDepartmentInfoList.stream().map(HeadquartersInfoForm::convertFrom).distinct().toList(); + } } \ No newline at end of file diff --git a/EM-System/src/main/java/com/example/rhizome/app/presentation/form/InsertDepartmentForm.java b/EM-System/src/main/java/com/example/rhizome/app/presentation/form/InsertDepartmentForm.java index a4eddf3..3e1da7e 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/presentation/form/InsertDepartmentForm.java +++ b/EM-System/src/main/java/com/example/rhizome/app/presentation/form/InsertDepartmentForm.java @@ -40,10 +40,10 @@ public class InsertDepartmentForm { private String nmDivision; /** - * 画面用(presentation 層)の InsertDepartmentForm クラス を Business 層の Department クラスに変換 + * 画面用(presentation 層)の InsertDepartmentForm クラス を Business 層の DepartmentInfo クラスに変換 * * @param insertDepartmentForm presentation 層用のクラス - * @return Business 層用のモデル + * @return DepartmentFormのインスタンス */ public static DepartmentInfo convertTo(InsertDepartmentForm insertDepartmentForm) { return new DepartmentInfo(insertDepartmentForm.getIdHeadquarters(), diff --git a/EM-System/src/main/java/com/example/rhizome/app/presentation/form/InsertEmployeeForm.java b/EM-System/src/main/java/com/example/rhizome/app/presentation/form/InsertEmployeeForm.java index 3ea0beb..9c840ad 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/presentation/form/InsertEmployeeForm.java +++ b/EM-System/src/main/java/com/example/rhizome/app/presentation/form/InsertEmployeeForm.java @@ -17,157 +17,155 @@ import lombok.NoArgsConstructor; @NoArgsConstructor public class InsertEmployeeForm { - /** - * 社員名 - */ - private String nmEmployee; + /** + * 社員名 + */ + private String nmEmployee; - /** - * 社員名カナ - */ - private String knEmployee; + /** + * 社員名カナ + */ + private String knEmployee; - /** - * メールアドレス - */ - private String mailAddress; + /** + * メールアドレス + */ + private String mailAddress; - /** - * パスワード - */ - private String password; + /** + * パスワード + */ + private String password; - /** - * 確認用パスワード - */ - private String passwordConfirm; - /** - * 入社年月日 - */ - private String hireDate; + /** + * 確認用パスワード + */ + private String passwordConfirm; + /** + * 入社年月日 + */ + private String hireDate; - /** - * 管理者権限 - */ - private Integer adminAuth; + /** + * 管理者権限 + */ + private Integer adminAuth; - /** - * 本部ID - */ - private Integer idHeadquarters; - - /** - * 部ID - */ - private Integer idDepartment; - - /** - * 課ID - */ - private Integer idDivision; - + /** + * 本部ID + */ + private Integer idHeadquarters; - /** - * パスワードのValidation - * チェック対象にエラーが有った場合エラーリストに文言を追加する - * - * @param password 登録対象のパスワード - * @param passwordConfirm 登録対象のパスワード再入力 - * @param error エラーリスト - */ - private static void checkPassword(String password, String passwordConfirm, List error) { - final String PASSWORD_NULL_BLANK = "パスワード が未入力です。"; - final String PASSWORD_CONFIRM_NULL_BLANK = "パスワード確認用 が未入力です。"; - final String PASSWORD_MISMATCH = "パスワード と パスワード確認用 が一致しません。"; + /** + * 部ID + */ + private Integer idDepartment; - if (isNullOrBlank(password)) { - error.add(PASSWORD_NULL_BLANK); - return; - } - if (isNullOrBlank(passwordConfirm)) { - error.add(PASSWORD_CONFIRM_NULL_BLANK); - return; - } + /** + * 課ID + */ + private Integer idDivision; - if (!password.equals(passwordConfirm)) { - error.add(PASSWORD_MISMATCH); - } - } + /** + * パスワードのValidation + * チェック対象にエラーが有った場合エラーリストに文言を追加する + * + * @param password 登録対象のパスワード + * @param passwordConfirm 登録対象のパスワード再入力 + * @param error エラーリスト + */ + private static void checkPassword(String password, String passwordConfirm, List error) { + final String PASSWORD_NULL_BLANK = "パスワード が未入力です。"; + final String PASSWORD_CONFIRM_NULL_BLANK = "パスワード確認用 が未入力です。"; + final String PASSWORD_MISMATCH = "パスワード と パスワード確認用 が一致しません。"; - /** - * 仮引数を null or 空 判定する - * - * @param str 判定対象の文字列 - * @return true:null or 空 false:null or 空 では無い - */ - private static boolean isNullOrBlank(String str) { - if (null == str) { - return true; - } + if (isNullOrBlank(password)) { + error.add(PASSWORD_NULL_BLANK); + return; + } + if (isNullOrBlank(passwordConfirm)) { + error.add(PASSWORD_CONFIRM_NULL_BLANK); + return; + } - return str.isBlank(); - } + if (!password.equals(passwordConfirm)) { + error.add(PASSWORD_MISMATCH); + } + } - /** - * 画面から渡ってきた登録内容をまとめ、ビジネスモデルに変換 - * - * @param insertEmployeeForm 画面から渡ってきた登録内容 - * @return ビジネスモデルのインスタンス - */ - public static Employee convertTo(InsertEmployeeForm insertEmployeeForm) { - return new Employee( - null, - insertEmployeeForm.getNmEmployee(), - insertEmployeeForm.getKnEmployee(), - insertEmployeeForm.getMailAddress(), - insertEmployeeForm.getPassword(), - insertEmployeeForm.getHireDate(), - insertEmployeeForm.getAdminAuth(), - insertEmployeeForm.getIdDivision() - ); - } + /** + * 仮引数を null or 空 判定する + * + * @param str 判定対象の文字列 + * @return true:null or 空 false:null or 空 では無い + */ + private static boolean isNullOrBlank(String str) { + if (null == str) { + return true; + } - /** - * 登録データのValidationを行う - * - * @return エラーが有った場合はエラー文言、無ければ空のリストが返る - */ - public List 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 = "所属部署"; - final String HIREDATE_NULL_BLANK ="入社年月日"; + return str.isBlank(); + } - List error = new ArrayList<>(); + /** + * 画面から渡ってきた登録内容をまとめ、ビジネスモデルに変換 + * + * @param insertEmployeeForm 画面から渡ってきた登録内容 + * @return ビジネスモデルのインスタンス + */ + public static Employee convertTo(InsertEmployeeForm insertEmployeeForm) { + return new Employee( + null, + insertEmployeeForm.getNmEmployee(), + insertEmployeeForm.getKnEmployee(), + insertEmployeeForm.getMailAddress(), + insertEmployeeForm.getPassword(), + insertEmployeeForm.getHireDate(), + insertEmployeeForm.getAdminAuth(), + insertEmployeeForm.getIdDivision()); + } - 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); - } + /** + * 登録データのValidationを行う + * + * @return エラーが有った場合はエラー文言、無ければ空のリストが返る + */ + public List 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 = "所属部署"; + final String HIREDATE_NULL_BLANK = "入社年月日"; - // パスワードが仕様を満たしているか確認 - checkPassword(password, passwordConfirm, error); + List error = new ArrayList<>(); - if (adminAuth == null) { - error.add(MANAGEMENT_ERROR); - } + 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); + } - if (idDivision == null) { - error.add(DEPARTMENT_ID_NULL_BLANK); - } - if(isNullOrBlank(hireDate)) { - error.add(HIREDATE_NULL_BLANK); - } + // パスワードが仕様を満たしているか確認 + checkPassword(password, passwordConfirm, error); - return error; + if (adminAuth == null) { + error.add(MANAGEMENT_ERROR); + } - } + if (idDivision == null) { + error.add(DEPARTMENT_ID_NULL_BLANK); + } + if (isNullOrBlank(hireDate)) { + error.add(HIREDATE_NULL_BLANK); + } + + return error; + + } } diff --git a/EM-System/src/main/java/com/example/rhizome/app/presentation/form/LoginInfoForm.java b/EM-System/src/main/java/com/example/rhizome/app/presentation/form/LoginInfoForm.java index 94104d7..31f9559 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/presentation/form/LoginInfoForm.java +++ b/EM-System/src/main/java/com/example/rhizome/app/presentation/form/LoginInfoForm.java @@ -12,12 +12,12 @@ import lombok.NoArgsConstructor; @AllArgsConstructor @NoArgsConstructor public class LoginInfoForm { - /** - * メールアドレス - */ - private String mailAddress; - /** - * パスワード - */ - private String password; + /** + * メールアドレス + */ + private String mailAddress; + /** + * パスワード + */ + private String password; } diff --git a/EM-System/src/main/java/com/example/rhizome/app/presentation/form/LoginUserForm.java b/EM-System/src/main/java/com/example/rhizome/app/presentation/form/LoginUserForm.java index 5db8dca..1e07447 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/presentation/form/LoginUserForm.java +++ b/EM-System/src/main/java/com/example/rhizome/app/presentation/form/LoginUserForm.java @@ -1,6 +1,5 @@ package com.example.rhizome.app.presentation.form; - import com.example.rhizome.app.domain.model.LoginUser; import lombok.AllArgsConstructor; @@ -11,104 +10,102 @@ import lombok.NoArgsConstructor; @AllArgsConstructor @NoArgsConstructor public class LoginUserForm { - /** - * 社員ID - */ - private Integer idEmployee; - /** - * 社員名 - */ - private String nmEmployee; - /** - * 社員名カナ - */ - private String knEmployee; - /** - * メールアドレス - */ - private String mailAddress; - /** - * パスワード - */ - private String password; + /** + * 社員ID + */ + private Integer idEmployee; + /** + * 社員名 + */ + private String nmEmployee; + /** + * 社員名カナ + */ + private String knEmployee; + /** + * メールアドレス + */ + private String mailAddress; + /** + * パスワード + */ + private String password; - /** - * 管理者権限 - */ - private Integer adminAuth; + /** + * 管理者権限 + */ + private Integer adminAuth; - /** - * 課ID - */ - private Integer idDepartment; + /** + * 課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.getIdDivision() - ); - } + /** + * 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.getIdDivision()); + } - /** - * 画面用(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() - ); - } + /** + * 画面用(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; - } + /** + * 画面から渡ってきた必須の値が仕様を満たしているか確認 + * + * @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 (loginInfoForm.getMailAddress().isBlank()) { + return false; + } - if (null == loginInfoForm.getPassword()) { - return false; - } + if (null == loginInfoForm.getPassword()) { + return false; + } - return !loginInfoForm.getPassword().isBlank(); + return !loginInfoForm.getPassword().isBlank(); - } + } - /** - * 管理者権限を持っているか確認 - * - * @return true:管理者権限を持っている , false:管理者権限を持っていない - */ - public boolean isAdminUser() { - return getAdminAuth() == 1; - } + /** + * 管理者権限を持っているか確認 + * + * @return true:管理者権限を持っている , false:管理者権限を持っていない + */ + public boolean isAdminUser() { + return getAdminAuth() == 1; + } } diff --git a/EM-System/src/main/java/com/example/rhizome/app/presentation/form/MessageForm.java b/EM-System/src/main/java/com/example/rhizome/app/presentation/form/MessageForm.java index 2ea9ca6..946d3d6 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/presentation/form/MessageForm.java +++ b/EM-System/src/main/java/com/example/rhizome/app/presentation/form/MessageForm.java @@ -11,5 +11,5 @@ import lombok.NoArgsConstructor; @AllArgsConstructor @NoArgsConstructor public class MessageForm { - private String message; + private String message; } diff --git a/EM-System/src/main/java/com/example/rhizome/app/presentation/form/SearchConditionDepartmentForm.java b/EM-System/src/main/java/com/example/rhizome/app/presentation/form/SearchConditionDepartmentForm.java index 8a8552f..e4365ed 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/presentation/form/SearchConditionDepartmentForm.java +++ b/EM-System/src/main/java/com/example/rhizome/app/presentation/form/SearchConditionDepartmentForm.java @@ -16,49 +16,48 @@ import lombok.NoArgsConstructor; @AllArgsConstructor @NoArgsConstructor public class SearchConditionDepartmentForm { - /** - * 部署ID - */ - private Integer idDivision; - /** - * 部署名 - */ - private String nmDivision; + /** + * 部署ID + */ + private Integer idDivision; + /** + * 部署名 + */ + private String nmDivision; - /** - * business 層の Department クラスから画面用(presentation 層)の SearchConditionDepartmentForm に - * 変換します。 - * - * @param department business 層の Department インスタンス - * @return 画面用(presentation 層)の SearchConditionDepartmentForm インスタンス - */ - public static SearchConditionDepartmentForm convertFrom(Department department) { - return new SearchConditionDepartmentForm(department.getIdDepartment(), department.getNmDepartment()); - } + /** + * business 層の Department クラスから画面用(presentation 層)の SearchConditionDepartmentForm に + * 変換します。 + * + * @param department business 層の Department インスタンス + * @return 画面用(presentation 層)の SearchConditionDepartmentForm インスタンス + */ + public static SearchConditionDepartmentForm convertFrom(Department department) { + return new SearchConditionDepartmentForm(department.getIdDepartment(), department.getNmDepartment()); + } - /** - * business 層の Department クラスから画面用(presentation 層)の SearchConditionDepartmentForm に - * 変換します。(リスト版) - * - * @param departmentList business 層の Department インスタンスのリスト - * @return 画面用(presentation 層)の SearchConditionDepartmentForm インスタンスのリスト - */ - public static List convertFrom(List departmentList) { - return departmentList.stream().map(SearchConditionDepartmentForm::convertFrom).toList(); - } + /** + * business 層の Department クラスから画面用(presentation 層)の SearchConditionDepartmentForm に + * 変換します。(リスト版) + * + * @param departmentList business 層の Department インスタンスのリスト + * @return 画面用(presentation 層)の SearchConditionDepartmentForm インスタンスのリスト + */ + public static List convertFrom(List departmentList) { + return departmentList.stream().map(SearchConditionDepartmentForm::convertFrom).toList(); + } - /** - * presentation 層の SearchConditionDepartmentForm クラスから画面用(Business 層)の SearchConditionDepartment に - * 変換します。(リスト版) - * - * @param searchConditionDepartmentForm 検索画面の情報 - * @return 画面用(Business 層)の SearchConditionDepartment インスタンスのリスト - */ - public static SearchConditionDepartment convertTo(SearchConditionDepartmentForm searchConditionDepartmentForm) { - return new SearchConditionDepartment( - searchConditionDepartmentForm.getIdDivision(), - searchConditionDepartmentForm.nmDivision - ); + /** + * presentation 層の SearchConditionDepartmentForm クラスから画面用(Business 層)の SearchConditionDepartment に + * 変換します。(リスト版) + * + * @param searchConditionDepartmentForm 検索画面の情報 + * @return 画面用(Business 層)の SearchConditionDepartment インスタンスのリスト + */ + public static SearchConditionDepartment convertTo(SearchConditionDepartmentForm searchConditionDepartmentForm) { + return new SearchConditionDepartment( + searchConditionDepartmentForm.getIdDivision(), + searchConditionDepartmentForm.nmDivision); - } + } } diff --git a/EM-System/src/main/java/com/example/rhizome/app/presentation/form/SearchConditionEmployeeForm.java b/EM-System/src/main/java/com/example/rhizome/app/presentation/form/SearchConditionEmployeeForm.java index b62ad3b..2d5f537 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/presentation/form/SearchConditionEmployeeForm.java +++ b/EM-System/src/main/java/com/example/rhizome/app/presentation/form/SearchConditionEmployeeForm.java @@ -14,58 +14,56 @@ import lombok.NoArgsConstructor; @NoArgsConstructor public class SearchConditionEmployeeForm { - /** - * 社員ID - */ - private Integer idEmployee; - /** - * 社員名 - */ - private String nmEmployee; - /** - * 社員名カナ - */ - private String knEmployee; - /** - * メールアドレス - */ - private String mailAddress; - /** - * 部署ID - */ - private Integer idDivision; + /** + * 社員ID + */ + private Integer idEmployee; + /** + * 社員名 + */ + private String nmEmployee; + /** + * 社員名カナ + */ + private String knEmployee; + /** + * メールアドレス + */ + private String mailAddress; + /** + * 部署ID + */ + private Integer idDivision; - /** - * 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.getIdDivision() - ); - } + /** + * 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.getIdDivision()); + } - /** - * 画面用(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.getIdDivision() - ); - } + /** + * 画面用(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.getIdDivision()); + } } diff --git a/EM-System/src/main/java/com/example/rhizome/app/presentation/form/UpdateDepartmentForm.java b/EM-System/src/main/java/com/example/rhizome/app/presentation/form/UpdateDepartmentForm.java index 54286b7..e848e75 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/presentation/form/UpdateDepartmentForm.java +++ b/EM-System/src/main/java/com/example/rhizome/app/presentation/form/UpdateDepartmentForm.java @@ -13,83 +13,62 @@ import lombok.Data; @AllArgsConstructor public class UpdateDepartmentForm { - /** - * 本部ID - */ - private Integer idHeadquarters; - /** - * 本部名 - */ - private String nmHeadquarters; - /** - * 部ID - */ - private Integer idDepartment; - /** - * 部名 - */ - private String nmDepartment; - /** - * 課ID - */ - private Integer idDivision; - /** - * 課名 - */ - private String nmDivision; - /** - * business 層の Department クラスから画面用(presentation 層)の UpdateDepartmentForm に - * 変換します。 - * - * @param department business 層の Department インスタンス - * @return 画面用(presentation 層)の UpdateDepartmentForm インスタンス - */ - public static UpdateDepartmentForm convertFrom(AllDepartmentInfo allDepartmentInfo) { - return new UpdateDepartmentForm( - allDepartmentInfo.getHeadquarters().getIdHeadquarters(), - allDepartmentInfo.getHeadquarters().getNmHeadquarters(), - allDepartmentInfo.getDepartment().getIdDepartment(), - allDepartmentInfo.getDepartment().getNmDepartment(), - allDepartmentInfo.getDivision().getIdDivision(), - allDepartmentInfo.getDivision().getNmDivision()); - } + /** + * 本部ID + */ + private Integer idHeadquarters; + /** + * 本部名 + */ + private String nmHeadquarters; + /** + * 部ID + */ + private Integer idDepartment; + /** + * 部名 + */ + private String nmDepartment; + /** + * 課ID + */ + private Integer idDivision; + /** + * 課名 + */ + private String nmDivision; - /** - * business 層の Department クラスから画面用(presentation 層)の UpdateDepartmentForm に - * 変換します。(リスト版) - * - * @param departmentList business 層の Department インスタンスのリスト - * @return 画面用(presentation 層)の UpdateDepartmentForm インスタンスのリスト - */ -// public static List convertFrom(List departmentList) { -// return departmentList.stream().map(UpdateDepartmentForm::convertFrom).toList(); -// } + /** + * AllDepartmentInfoクラスから UpdateDepartmentForm に変換します。 + * + * @param allDepartmentInfo AllDepartmentInfo インスタンス + * @return 画面用(presentation 層)の UpdateDepartmentForm インスタンス + */ + public static UpdateDepartmentForm convertFrom(AllDepartmentInfo allDepartmentInfo) { + return new UpdateDepartmentForm( + allDepartmentInfo.getHeadquarters().getIdHeadquarters(), + allDepartmentInfo.getHeadquarters().getNmHeadquarters(), + allDepartmentInfo.getDepartment().getIdDepartment(), + allDepartmentInfo.getDepartment().getNmDepartment(), + allDepartmentInfo.getDivision().getIdDivision(), + allDepartmentInfo.getDivision().getNmDivision()); + } - /** - * presentation 層の UpdateDepartmentForm クラスから Business 層の Department クラスに - * 変換します。 - * - * @param updateDepartmentForm presentation 層のインスタンス - * @return Business 層の Department インスタンス - */ -// public static Department convertTo(UpdateDepartmentForm updateDepartmentForm) { -// return new Department( -// updateDepartmentForm.getIdDepartment(), -// updateDepartmentForm.getNmDepartment(), -// (Integer)0, -// updateDepartmentForm.getIdHeadquarters() -// -// ); -// } - public static DepartmentInfo convertTo(UpdateDepartmentForm updateDepartmentForm) { - return new DepartmentInfo( - updateDepartmentForm.getIdHeadquarters(), - updateDepartmentForm.getNmHeadquarters(), - updateDepartmentForm.getIdDepartment(), - updateDepartmentForm.getNmDepartment(), - updateDepartmentForm.getIdDivision(), - updateDepartmentForm.getNmDivision() - - ); - } + /** + * UpdateDepartmentFormから DepartmentInfo に変換します。 + * + * @param updateDepartmentForm UpdateDepartmentFormインスタンス + * @return DepartmentInfo インスタンス + */ + public static DepartmentInfo convertTo(UpdateDepartmentForm updateDepartmentForm) { + return new DepartmentInfo( + updateDepartmentForm.getIdHeadquarters(), + updateDepartmentForm.getNmHeadquarters(), + updateDepartmentForm.getIdDepartment(), + updateDepartmentForm.getNmDepartment(), + updateDepartmentForm.getIdDivision(), + updateDepartmentForm.getNmDivision() + + ); + } } diff --git a/EM-System/src/main/java/com/example/rhizome/app/presentation/form/UpdateEmployeeInfoForm.java b/EM-System/src/main/java/com/example/rhizome/app/presentation/form/UpdateEmployeeInfoForm.java index 5e24de0..ce57822 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/presentation/form/UpdateEmployeeInfoForm.java +++ b/EM-System/src/main/java/com/example/rhizome/app/presentation/form/UpdateEmployeeInfoForm.java @@ -17,183 +17,184 @@ import lombok.NoArgsConstructor; @NoArgsConstructor public class UpdateEmployeeInfoForm { - /** - * 社員ID - */ - private Integer idEmployee; - /** - * 社員名 - */ - private String nmEmployee; - /** - * 社員名カナ - */ - private String knEmployee; - /** - * メールアドレス - */ - private String mailAddress; - /** - * パスワード - */ - private String password; - /** - * パスワード確認用 - */ - private String passwordConfirm; - /** - * 入社年月日 - */ - private String hireDate; - /** - * 管理者権限 - */ - private Integer adminAuth; - /** - * 部署ID - */ - private Integer idDivision; + /** + * 社員ID + */ + private Integer idEmployee; + /** + * 社員名 + */ + private String nmEmployee; + /** + * 社員名カナ + */ + private String knEmployee; + /** + * メールアドレス + */ + private String mailAddress; + /** + * パスワード + */ + private String password; + /** + * パスワード確認用 + */ + private String passwordConfirm; + /** + * 入社年月日 + */ + private String hireDate; + /** + * 管理者権限 + */ + private Integer adminAuth; + /** + * 部ID + */ + private Integer idDivision; + /** + * 本部ID + */ + private Integer idHeadquarters; - /** - * business 層の EmployeeInfo クラスから画面用(presentation 層)の UpdateEmployeeInfoForm に - * 変換します。 - * - * @param employeeInfo business 層の EmployeeInfo インスタンス - * @return 画面用(presentation 層)の UpdateEmployeeInfoForm インスタンス - */ - public static UpdateEmployeeInfoForm convertFrom(AllEmployeeInfo allemployeeInfo) { - return new UpdateEmployeeInfoForm( - allemployeeInfo.getEmployee().getIdEmployee(), - allemployeeInfo.getEmployee().getNmEmployee(), - allemployeeInfo.getEmployee().getKnEmployee(), - allemployeeInfo.getEmployee().getMailAddress(), - allemployeeInfo.getEmployee().getPassword(), - null, - allemployeeInfo.getEmployee().getHireDate(), - allemployeeInfo.getEmployee().getAdminAuth(), - allemployeeInfo.getDivision().getIdDivision() - ); - } + /** + * AllEmployeeInfo クラスからUpdateEmployeeInfoForm に変換します。 + * + * @param allemployeeInfo AllEmployeeInfo インスタンス + * @return 画面用(presentation 層)の UpdateEmployeeInfoForm インスタンス + */ + public static UpdateEmployeeInfoForm convertFrom(AllEmployeeInfo allemployeeInfo) { + return new UpdateEmployeeInfoForm( + allemployeeInfo.getEmployee().getIdEmployee(), + allemployeeInfo.getEmployee().getNmEmployee(), + allemployeeInfo.getEmployee().getKnEmployee(), + allemployeeInfo.getEmployee().getMailAddress(), + allemployeeInfo.getEmployee().getPassword(), + null, + allemployeeInfo.getEmployee().getHireDate(), + allemployeeInfo.getEmployee().getAdminAuth(), + allemployeeInfo.getDivision().getIdDivision(), + allemployeeInfo.getHeadquarters().getIdHeadquarters()); - /** - * business 層の EmployeeInfo クラスから画面用(presentation 層)の UpdateEmployeeInfoForm に - * 変換します。(リスト版) - * - * @param employeeInfoList business 層の EmployeeInfo インスタンスのリスト - * @return 画面用(presentation 層)の UpdateEmployeeInfoForm インスタンスのリスト - */ - public static List convertFrom(List allemployeeInfoList) { - return allemployeeInfoList.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.getHireDate(), - updateEmployeeInfoForm.getAdminAuth(), - updateEmployeeInfoForm.getIdDivision() - ); - } + /** + * AllEmployeeInfo クラスから画面用 UpdateEmployeeInfoForm に変換します。(リスト版) + * + * @param allemployeeInfoList business 層の AllEmployeeInfo インスタンスのリスト + * @return 画面用(presentation 層)の UpdateEmployeeInfoForm インスタンスのリスト + */ + public static List convertFrom(List allemployeeInfoList) { + return allemployeeInfoList.stream().map(UpdateEmployeeInfoForm::convertFrom).toList(); + } - /** - * 画面から渡ってきたパラメータのチェック - * - * @param updateEmployeeInfoForm 画面から渡ってきたパラメータ - * @return true: エラー無し false:エラーあり(必須を満たしていない) - */ - public static boolean hasErrorParameter(UpdateEmployeeInfoForm updateEmployeeInfoForm) { + /** + * 画面用(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.getHireDate(), + updateEmployeeInfoForm.getAdminAuth(), + updateEmployeeInfoForm.getIdDivision()); + } - boolean errorFlag = !isNullOrBlank(updateEmployeeInfoForm.getNmEmployee()); + /** + * 画面から渡ってきたパラメータのチェック + * + * @param updateEmployeeInfoForm 画面から渡ってきたパラメータ + * @return true: エラー無し false:エラーあり(必須を満たしていない) + */ + public static boolean hasErrorParameter(UpdateEmployeeInfoForm updateEmployeeInfoForm) { - if (!isNullOrBlank(updateEmployeeInfoForm.getKnEmployee())) { - errorFlag = true; - } - if (!isNullOrBlank(updateEmployeeInfoForm.getMailAddress())) { - errorFlag = true; - } - if (!isNullOrBlank(updateEmployeeInfoForm.getPassword())) { - errorFlag = true; - } + 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; - } + return errorFlag; + } - /** - * パスワードの仕様チェック - * パスワードが仕様を満たしてないか確認 - * - * @param password 更新対象のパスワード - * @param passwordConfirm 更新対象の確認用パスワード - * @return 空文字: エラー無し それ以外:エラー内容 - */ - public static String validatePassword(String password, String passwordConfirm) { + /** + * パスワードの仕様チェック + * パスワードが仕様を満たしてないか確認 + * + * @param password 更新対象のパスワード + * @param passwordConfirm 更新対象の確認用パスワード + * @return 空文字: エラー無し それ以外:エラー内容 + */ + public static String validatePassword(String password, String passwordConfirm) { - final String ERROR = "パスワードが一致していません"; + final String ERROR = "パスワードが一致していません"; - if (areBothBlank(password, passwordConfirm)) { - // どちらもnullまたは空白の場合はOK - return ""; - } + if (areBothBlank(password, passwordConfirm)) { + // どちらもnullまたは空白の場合はOK + return ""; + } - // どちらかがnullまたは空白の場合のエラーハンドリング - if (isEitherBlank(password, passwordConfirm)) { - return ERROR; - } + // どちらかがnullまたは空白の場合のエラーハンドリング + if (isEitherBlank(password, passwordConfirm)) { + return ERROR; + } - // 値が異なった場合はエラーハンドリング - if (!password.equals(passwordConfirm)) { - return ERROR; - } - return ""; + // 値が異なった場合はエラーハンドリング + 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(); - } + /** + * 仮引数を 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()); - } + /** + * パスワードが今回更新対象に含まれているかチェック + * + * @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(); - } + /** + * パスワードが今回更新対象に含まれているかチェック その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(); + } } diff --git a/EM-System/src/main/java/com/example/rhizome/app/presentation/form/UpdatePersonalUserForm.java b/EM-System/src/main/java/com/example/rhizome/app/presentation/form/UpdatePersonalUserForm.java index 30cfb67..deefddb 100644 --- a/EM-System/src/main/java/com/example/rhizome/app/presentation/form/UpdatePersonalUserForm.java +++ b/EM-System/src/main/java/com/example/rhizome/app/presentation/form/UpdatePersonalUserForm.java @@ -14,180 +14,177 @@ import lombok.NoArgsConstructor; @AllArgsConstructor @NoArgsConstructor public class UpdatePersonalUserForm { - /** - * 社員ID - */ - private Integer idEmployee; - /** - * 社員名 - */ - private String nmEmployee; - /** - * 社員名カナ - */ - private String knEmployee; - /** - * メールアドレス - */ - private String mailAddress; - /** - * パスワード - */ - private String password; - /** - * パスワード確認用 - */ - private String passwordConfirm; - /** - * 入社年月日 - */ - private String hireDate; + /** + * 社員ID + */ + private Integer idEmployee; + /** + * 社員名 + */ + private String nmEmployee; + /** + * 社員名カナ + */ + private String knEmployee; + /** + * メールアドレス + */ + private String mailAddress; + /** + * パスワード + */ + private String password; + /** + * パスワード確認用 + */ + private String passwordConfirm; + /** + * 入社年月日 + */ + private String hireDate; - /** - * 画面用(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(), - updatePersonalUserForm.getHireDate(), - null, - null - ); - } + /** + * 画面用(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(), + updatePersonalUserForm.getHireDate(), + 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, - employee.getHireDate() - - ); - } + /** + * 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, + employee.getHireDate() - /** - * 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, - null - ); - } + ); + } - /** - * 画面から渡ってきたパラメータのチェック - * - * @param updatePersonalUserForm 画面から渡ってきたパラメータ - * @return true: エラー無し false:エラーあり(必須を満たしていない) - */ - public static boolean hasErrorParameter(UpdatePersonalUserForm updatePersonalUserForm) { + /** + * 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, + null); + } - boolean errorFlag = !isNullOrBlank(updatePersonalUserForm.getNmEmployee()); + /** + * 画面から渡ってきたパラメータのチェック + * + * @param updatePersonalUserForm 画面から渡ってきたパラメータ + * @return true: エラー無し false:エラーあり(必須を満たしていない) + */ + public static boolean hasErrorParameter(UpdatePersonalUserForm updatePersonalUserForm) { - if (!isNullOrBlank(updatePersonalUserForm.getKnEmployee())) { - errorFlag = true; - } - if (!isNullOrBlank(updatePersonalUserForm.getMailAddress())) { - errorFlag = true; - } - if (!isNullOrBlank(updatePersonalUserForm.getPassword())) { - errorFlag = true; - } + 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; - } + return errorFlag; + } - /** - * パスワードの仕様チェック - * パスワードが仕様を満たしてないか確認 - * - * @param password 更新対象のパスワード - * @param passwordConfirm 更新対象の確認用パスワード - * @return 空文字: エラー無し それ以外:エラー内容 - */ - public static String validatePassword(String password, String passwordConfirm) { + /** + * パスワードの仕様チェック + * パスワードが仕様を満たしてないか確認 + * + * @param password 更新対象のパスワード + * @param passwordConfirm 更新対象の確認用パスワード + * @return 空文字: エラー無し それ以外:エラー内容 + */ + public static String validatePassword(String password, String passwordConfirm) { - final String ERROR = "パスワードが一致していません"; + final String ERROR = "パスワードが一致していません"; - if (areBothBlank(password, passwordConfirm)) { - // どちらもnullまたは空白の場合はOK - return ""; - } + if (areBothBlank(password, passwordConfirm)) { + // どちらもnullまたは空白の場合はOK + return ""; + } - // どちらかがnullまたは空白の場合のエラーハンドリング - if (isEitherBlank(password, passwordConfirm)) { - return ERROR; - } + // どちらかがnullまたは空白の場合のエラーハンドリング + if (isEitherBlank(password, passwordConfirm)) { + return ERROR; + } - // 値が異なった場合はエラーハンドリング - if (!password.equals(passwordConfirm)) { - return ERROR; - } - return ""; + // 値が異なった場合はエラーハンドリング + 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(); - } + /** + * 仮引数を 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()); - } + /** + * パスワードが今回更新対象に含まれているかチェック + * + * @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(); - } + /** + * パスワードが今回更新対象に含まれているかチェック その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(); + } } diff --git a/EM-System/src/main/resources/templates/insertDepartmentInput.html b/EM-System/src/main/resources/templates/insertDepartmentInput.html index 61c2afe..8989543 100644 --- a/EM-System/src/main/resources/templates/insertDepartmentInput.html +++ b/EM-System/src/main/resources/templates/insertDepartmentInput.html @@ -35,11 +35,13 @@ + 本部名 @@ -47,18 +49,17 @@ + 部ID @@ -67,11 +68,13 @@ + 部名 @@ -79,10 +82,9 @@