【組織の階層構造導入】実装
This commit is contained in:
@@ -63,7 +63,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
<scope>test</scope>
|
<!-- <scope>test</scope>-->
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|||||||
@@ -6,16 +6,16 @@ import lombok.Getter;
|
|||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class AllDepartmentInfo {
|
public class AllDepartmentInfo {
|
||||||
/**
|
/**
|
||||||
* 課情報
|
* 課情報
|
||||||
*/
|
*/
|
||||||
private final Division division;
|
private final Division division;
|
||||||
/**
|
/**
|
||||||
* 部情報
|
* 部情報
|
||||||
*/
|
*/
|
||||||
private final Department department;
|
private final Department department;
|
||||||
/**
|
/**
|
||||||
* 本部情報
|
* 本部情報
|
||||||
*/
|
*/
|
||||||
private final Headquarters headquarters;
|
private final Headquarters headquarters;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,23 +3,26 @@ package com.example.rhizome.app.domain.model;
|
|||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 社員情報と全ての部署情報を表すモデルクラスです。
|
||||||
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class AllEmployeeInfo {
|
public class AllEmployeeInfo {
|
||||||
/**
|
/**
|
||||||
* 社員情報
|
* 社員情報
|
||||||
*/
|
*/
|
||||||
private final Employee employee;
|
private final Employee employee;
|
||||||
/**
|
/**
|
||||||
* 課情報
|
* 課情報
|
||||||
*/
|
*/
|
||||||
private final Division division;
|
private final Division division;
|
||||||
/**
|
/**
|
||||||
* 部情報
|
* 部情報
|
||||||
*/
|
*/
|
||||||
private final Department department;
|
private final Department department;
|
||||||
/**
|
/**
|
||||||
* 本部情報
|
* 本部情報
|
||||||
*/
|
*/
|
||||||
private final Headquarters headquarters;
|
private final Headquarters headquarters;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,23 +3,27 @@ package com.example.rhizome.app.domain.model;
|
|||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部情報を表すモデルクラスです。
|
||||||
|
*/
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class Department {
|
public class Department {
|
||||||
/**
|
/**
|
||||||
* 部ID
|
* 部ID
|
||||||
*/
|
*/
|
||||||
private final Integer idDepartment;
|
private final Integer idDepartment;
|
||||||
/**
|
/**
|
||||||
* 部名
|
* 部名
|
||||||
*/
|
*/
|
||||||
private final String nmDepartment;
|
private final String nmDepartment;
|
||||||
/**
|
/**
|
||||||
* 表示・非表示フラグ
|
* 表示・非表示フラグ
|
||||||
*/
|
*/
|
||||||
private final Integer isDisplay;
|
private final Integer isDisplay;
|
||||||
/**
|
/**
|
||||||
* 部ID
|
* 部ID
|
||||||
*/
|
*/
|
||||||
private final Integer idHeadquarters;
|
private final Integer idHeadquarters;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,27 +10,27 @@ import lombok.Getter;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class DepartmentInfo {
|
public class DepartmentInfo {
|
||||||
/**
|
/**
|
||||||
* 本部ID
|
* 本部ID
|
||||||
*/
|
*/
|
||||||
private final Integer idHeadquarters;
|
private final Integer idHeadquarters;
|
||||||
/**
|
/**
|
||||||
* 本部名
|
* 本部名
|
||||||
*/
|
*/
|
||||||
private final String nmHeadquarters;
|
private final String nmHeadquarters;
|
||||||
/**
|
/**
|
||||||
* 部ID
|
* 部ID
|
||||||
*/
|
*/
|
||||||
private final Integer idDepartment;
|
private final Integer idDepartment;
|
||||||
/**
|
/**
|
||||||
* 部名
|
* 部名
|
||||||
*/
|
*/
|
||||||
private final String nmDepartment;
|
private final String nmDepartment;
|
||||||
/**
|
/**
|
||||||
* 課ID
|
* 課ID
|
||||||
*/
|
*/
|
||||||
private final Integer idDivision;
|
private final Integer idDivision;
|
||||||
/**
|
/**
|
||||||
* 課名
|
* 課名
|
||||||
*/
|
*/
|
||||||
private final String nmDivision;
|
private final String nmDivision;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,20 +9,20 @@ import lombok.Getter;
|
|||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class Division {
|
public class Division {
|
||||||
/**
|
/**
|
||||||
* 課ID
|
* 課ID
|
||||||
*/
|
*/
|
||||||
private final Integer idDivision;
|
private final Integer idDivision;
|
||||||
/**
|
/**
|
||||||
* 課名
|
* 課名
|
||||||
*/
|
*/
|
||||||
private final String nmDivision;
|
private final String nmDivision;
|
||||||
/**
|
/**
|
||||||
* 表示・非表示フラグ
|
* 表示・非表示フラグ
|
||||||
*/
|
*/
|
||||||
private final Integer isDisplay;
|
private final Integer isDisplay;
|
||||||
/**
|
/**
|
||||||
* 部ID
|
* 部ID
|
||||||
*/
|
*/
|
||||||
private final Integer idDepartment;
|
private final Integer idDepartment;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,37 +9,37 @@ import lombok.Getter;
|
|||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class Employee {
|
public class Employee {
|
||||||
/**
|
/**
|
||||||
* 社員ID
|
* 社員ID
|
||||||
*/
|
*/
|
||||||
private final Integer idEmployee;
|
private final Integer idEmployee;
|
||||||
/**
|
/**
|
||||||
* 社員名
|
* 社員名
|
||||||
*/
|
*/
|
||||||
private final String nmEmployee;
|
private final String nmEmployee;
|
||||||
/**
|
/**
|
||||||
* 社員名カナ
|
* 社員名カナ
|
||||||
*/
|
*/
|
||||||
private final String knEmployee;
|
private final String knEmployee;
|
||||||
/**
|
/**
|
||||||
* メールアドレス
|
* メールアドレス
|
||||||
*/
|
*/
|
||||||
private final String mailAddress;
|
private final String mailAddress;
|
||||||
/**
|
/**
|
||||||
* パスワード
|
* パスワード
|
||||||
*/
|
*/
|
||||||
private final String password;
|
private final String password;
|
||||||
/**
|
/**
|
||||||
* 入社年月日
|
* 入社年月日
|
||||||
*/
|
*/
|
||||||
private final String hireDate;
|
private final String hireDate;
|
||||||
/**
|
/**
|
||||||
* 管理者権限
|
* 管理者権限
|
||||||
*/
|
*/
|
||||||
private final Integer adminAuth;
|
private final Integer adminAuth;
|
||||||
/**
|
/**
|
||||||
* 部署ID
|
* 部署ID
|
||||||
*/
|
*/
|
||||||
private final Integer idDivision;
|
private final Integer idDivision;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,13 +16,13 @@ import lombok.Getter;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class EmployeeInfo {
|
public class EmployeeInfo {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 社員情報
|
* 社員情報
|
||||||
*/
|
*/
|
||||||
private final Employee employee;
|
private final Employee employee;
|
||||||
/**
|
/**
|
||||||
* 課情報
|
* 課情報
|
||||||
*/
|
*/
|
||||||
private final Division division;
|
private final Division division;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,15 +10,15 @@ import lombok.Getter;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class Headquarters {
|
public class Headquarters {
|
||||||
/**
|
/**
|
||||||
* 本部ID
|
* 本部ID
|
||||||
*/
|
*/
|
||||||
private final Integer idHeadquarters;
|
private final Integer idHeadquarters;
|
||||||
/**
|
/**
|
||||||
* 本部名
|
* 本部名
|
||||||
*/
|
*/
|
||||||
private final String nmHeadquarters;
|
private final String nmHeadquarters;
|
||||||
/**
|
/**
|
||||||
* 表示・非表示フラグ
|
* 表示・非表示フラグ
|
||||||
*/
|
*/
|
||||||
private final Integer isDisplay;
|
private final Integer isDisplay;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,13 +10,13 @@ import lombok.Getter;
|
|||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class LoginInfo {
|
public class LoginInfo {
|
||||||
/**
|
/**
|
||||||
* メールアドレス
|
* メールアドレス
|
||||||
*/
|
*/
|
||||||
private String mailAddress;
|
private String mailAddress;
|
||||||
/**
|
/**
|
||||||
* パスワード
|
* パスワード
|
||||||
*/
|
*/
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,43 +9,43 @@ import lombok.Getter;
|
|||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class LoginUser {
|
public class LoginUser {
|
||||||
/**
|
/**
|
||||||
* 社員ID
|
* 社員ID
|
||||||
*/
|
*/
|
||||||
private final Integer idEmployee;
|
private final Integer idEmployee;
|
||||||
/**
|
/**
|
||||||
* 社員名
|
* 社員名
|
||||||
*/
|
*/
|
||||||
private final String nmEmployee;
|
private final String nmEmployee;
|
||||||
/**
|
/**
|
||||||
* 社員名カナ
|
* 社員名カナ
|
||||||
*/
|
*/
|
||||||
private final String knEmployee;
|
private final String knEmployee;
|
||||||
/**
|
/**
|
||||||
* メールアドレス
|
* メールアドレス
|
||||||
*/
|
*/
|
||||||
private final String mailAddress;
|
private final String mailAddress;
|
||||||
/**
|
/**
|
||||||
* パスワード
|
* パスワード
|
||||||
*/
|
*/
|
||||||
private final String password;
|
private final String password;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 管理者権限
|
* 管理者権限
|
||||||
*/
|
*/
|
||||||
private final Integer adminAuth;
|
private final Integer adminAuth;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部署ID
|
* 部署ID
|
||||||
*/
|
*/
|
||||||
private final Integer idDivision;
|
private final Integer idDivision;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ログインユーザが管理者か
|
* ログインユーザが管理者か
|
||||||
*
|
*
|
||||||
* @return true:管理者 false:一般権限
|
* @return true:管理者 false:一般権限
|
||||||
*/
|
*/
|
||||||
public boolean isAdminUser() {
|
public boolean isAdminUser() {
|
||||||
return getAdminAuth() == 1;
|
return getAdminAuth() == 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,13 +9,13 @@ import lombok.Getter;
|
|||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class SearchConditionDepartment {
|
public class SearchConditionDepartment {
|
||||||
/**
|
/**
|
||||||
* ID
|
* ID
|
||||||
*/
|
*/
|
||||||
private final Integer idDivision;
|
private final Integer idDivision;
|
||||||
/**
|
/**
|
||||||
* 名前
|
* 名前
|
||||||
*/
|
*/
|
||||||
private final String nmDivision;
|
private final String nmDivision;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,25 +9,25 @@ import lombok.Getter;
|
|||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class SearchConditionEmployee {
|
public class SearchConditionEmployee {
|
||||||
/**
|
/**
|
||||||
* 社員ID
|
* 社員ID
|
||||||
*/
|
*/
|
||||||
private final Integer idEmployee;
|
private final Integer idEmployee;
|
||||||
/**
|
/**
|
||||||
* 社員名
|
* 社員名
|
||||||
*/
|
*/
|
||||||
private final String nmEmployee;
|
private final String nmEmployee;
|
||||||
/**
|
/**
|
||||||
* 社員名カナ
|
* 社員名カナ
|
||||||
*/
|
*/
|
||||||
private final String knEmployee;
|
private final String knEmployee;
|
||||||
/**
|
/**
|
||||||
* メールアドレス
|
* メールアドレス
|
||||||
*/
|
*/
|
||||||
private final String mailAddress;
|
private final String mailAddress;
|
||||||
/**
|
/**
|
||||||
* 部署ID
|
* 部署ID
|
||||||
*/
|
*/
|
||||||
private final Integer idDivision;
|
private final Integer idDivision;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.example.rhizome.app.domain.service;
|
package com.example.rhizome.app.domain.service;
|
||||||
|
|
||||||
public interface DeleteDepartment {
|
public interface DeleteDepartment {
|
||||||
void deleteDepartment(Integer idDivision);
|
void deleteDepartment(Integer idDivision);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.example.rhizome.app.domain.service;
|
package com.example.rhizome.app.domain.service;
|
||||||
|
|
||||||
public interface DeleteEmployee {
|
public interface DeleteEmployee {
|
||||||
void deleteEmployee(Integer idEmployee);
|
void deleteEmployee(Integer idEmployee);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import com.example.rhizome.app.domain.model.LoginInfo;
|
|||||||
import com.example.rhizome.app.domain.model.LoginUser;
|
import com.example.rhizome.app.domain.model.LoginUser;
|
||||||
|
|
||||||
public interface Login {
|
public interface Login {
|
||||||
LoginUser doLogin(LoginInfo loginInfo);
|
LoginUser doLogin(LoginInfo loginInfo);
|
||||||
|
|
||||||
boolean canLogin(LoginInfo loginInfo);
|
boolean canLogin(LoginInfo loginInfo);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,5 +3,5 @@ package com.example.rhizome.app.domain.service;
|
|||||||
import com.example.rhizome.app.infra.entity.DivisionEntity;
|
import com.example.rhizome.app.infra.entity.DivisionEntity;
|
||||||
|
|
||||||
public interface RegisterDepartment {
|
public interface RegisterDepartment {
|
||||||
void registerDepartment(DivisionEntity divisionEntity);
|
void registerDepartment(DivisionEntity divisionEntity);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,5 +3,5 @@ package com.example.rhizome.app.domain.service;
|
|||||||
import com.example.rhizome.app.domain.model.Employee;
|
import com.example.rhizome.app.domain.model.Employee;
|
||||||
|
|
||||||
public interface RegisterEmployee {
|
public interface RegisterEmployee {
|
||||||
void registerEmployee(Employee employee);
|
void registerEmployee(Employee employee);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,30 +9,35 @@ import com.example.rhizome.app.domain.model.Headquarters;
|
|||||||
import com.example.rhizome.app.domain.model.SearchConditionDepartment;
|
import com.example.rhizome.app.domain.model.SearchConditionDepartment;
|
||||||
|
|
||||||
public interface SearchDepartment {
|
public interface SearchDepartment {
|
||||||
|
|
||||||
List<AllDepartmentInfo> searchAllDepartmentTable();
|
|
||||||
|
|
||||||
List<AllDepartmentInfo> searchAllDepartmentTable(SearchConditionDepartment searchConditionDepartment);
|
|
||||||
|
|
||||||
boolean searchAllDepartmentTable(
|
|
||||||
SearchConditionDepartment searchHeadquartersTable,
|
|
||||||
SearchConditionDepartment searchDepartmentTable,
|
|
||||||
SearchConditionDepartment searchDivisionTable);
|
|
||||||
|
|
||||||
boolean searchAllDepartmentTable(
|
|
||||||
Integer idHeadquarters,
|
|
||||||
Integer idDepartment,
|
|
||||||
Integer idDivision);
|
|
||||||
|
|
||||||
List<Headquarters> searchByHeadquarters(SearchConditionDepartment searchConditionDepartment);
|
List<AllDepartmentInfo> searchAllDepartmentTable();
|
||||||
|
|
||||||
|
List<AllDepartmentInfo> searchAllDepartmentTable(SearchConditionDepartment searchConditionDepartment);
|
||||||
|
|
||||||
|
boolean searchAllDepartmentTable(
|
||||||
|
SearchConditionDepartment searchHeadquartersTable,
|
||||||
|
SearchConditionDepartment searchDepartmentTable,
|
||||||
|
SearchConditionDepartment searchDivisionTable);
|
||||||
|
|
||||||
|
boolean searchAllDepartmentTable(
|
||||||
|
Integer idHeadquarters,
|
||||||
|
Integer idDepartment,
|
||||||
|
Integer idDivision);
|
||||||
|
|
||||||
|
List<Headquarters> searchByHeadquarters(SearchConditionDepartment searchConditionDepartment);
|
||||||
|
|
||||||
|
List<Department> searchByDepartment(SearchConditionDepartment searchConditionDepartment);
|
||||||
|
|
||||||
|
List<Division> searchByDivision(SearchConditionDepartment searchConditionDepartment);
|
||||||
|
|
||||||
|
List<Department> searchByIdHeadquarters(Integer idHeadquarters);
|
||||||
|
|
||||||
|
List<Division> searchByIdDepartment(Integer idDepartment);
|
||||||
|
|
||||||
|
List<Headquarters> searchHeadquartersByIdHeadquarters(Integer idHeadquarters);
|
||||||
|
|
||||||
|
List<Department> searchDepartmentByIdDepartment(Integer idDepartment);
|
||||||
|
|
||||||
|
List<Division> searchDivisionByIdDivision(Integer idDivision);
|
||||||
|
|
||||||
List<Department> searchByDepartment(SearchConditionDepartment searchConditionDepartment);
|
|
||||||
|
|
||||||
List<Division> searchByDivision(SearchConditionDepartment searchConditionDepartment);
|
|
||||||
|
|
||||||
List<Department>searchByIdHeadquarters(Integer idHeadquarters);
|
|
||||||
|
|
||||||
List<Division>searchByIdDepartment(Integer idDepartment);
|
|
||||||
|
|
||||||
// List<DepartmentInfo> searchByWithLike(SearchConditionDepartment searchConditionDepartment);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,11 +6,11 @@ import com.example.rhizome.app.domain.model.Employee;
|
|||||||
import com.example.rhizome.app.domain.model.LoginUser;
|
import com.example.rhizome.app.domain.model.LoginUser;
|
||||||
|
|
||||||
public interface SearchEmployee {
|
public interface SearchEmployee {
|
||||||
List<Employee> searchEmployee(String mailAddress);
|
List<Employee> searchEmployee(String mailAddress);
|
||||||
|
|
||||||
List<Employee> searchEmployeeByIdDepartment(Integer idDivision);
|
List<Employee> searchEmployeeByIdDepartment(Integer idDivision);
|
||||||
|
|
||||||
LoginUser searchLoginUser(String mailAddress);
|
LoginUser searchLoginUser(String mailAddress);
|
||||||
|
|
||||||
Employee searchEmployeeByIdEmployee(Integer idEmployee);
|
Employee searchEmployeeByIdEmployee(Integer idEmployee);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import com.example.rhizome.app.domain.model.AllEmployeeInfo;
|
|||||||
import com.example.rhizome.app.domain.model.SearchConditionEmployee;
|
import com.example.rhizome.app.domain.model.SearchConditionEmployee;
|
||||||
|
|
||||||
public interface SearchEmployeeInfo {
|
public interface SearchEmployeeInfo {
|
||||||
List<AllEmployeeInfo> selectAll();
|
List<AllEmployeeInfo> selectAll();
|
||||||
|
|
||||||
List<AllEmployeeInfo> searchBy(SearchConditionEmployee searchConditionEmployee);
|
List<AllEmployeeInfo> searchBy(SearchConditionEmployee searchConditionEmployee);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,6 @@ package com.example.rhizome.app.domain.service;
|
|||||||
import com.example.rhizome.app.domain.model.DepartmentInfo;
|
import com.example.rhizome.app.domain.model.DepartmentInfo;
|
||||||
|
|
||||||
public interface UpdateDepartment {
|
public interface UpdateDepartment {
|
||||||
void updateDepartment(DepartmentInfo departmentInfo);
|
void updateDepartment(DepartmentInfo departmentInfo);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,6 @@ package com.example.rhizome.app.domain.service;
|
|||||||
import com.example.rhizome.app.domain.model.Employee;
|
import com.example.rhizome.app.domain.model.Employee;
|
||||||
|
|
||||||
public interface UpdateEmployee {
|
public interface UpdateEmployee {
|
||||||
void updateEmployee(Employee beforeEmployee, Employee updateEmployee);
|
void updateEmployee(Employee beforeEmployee, Employee updateEmployee);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public class DeleteDepartmentImpl implements DeleteDepartment {
|
|||||||
/**
|
/**
|
||||||
* コンストラクタ
|
* コンストラクタ
|
||||||
*
|
*
|
||||||
* @param departmentRepository DI対象
|
* @param divisionRepository DI対象
|
||||||
*/
|
*/
|
||||||
@Autowired
|
@Autowired
|
||||||
public DeleteDepartmentImpl(DivisionRepository divisionRepository) {
|
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) {
|
public void deleteDepartment(Integer idDivision) {
|
||||||
divisionRepository.deleteById(idDepartment);
|
divisionRepository.deleteByIdDivision(idDivision);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
package com.example.rhizome.app.domain.service.impl;
|
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.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import com.example.rhizome.app.domain.service.DeleteEmployee;
|
||||||
|
import com.example.rhizome.app.infra.repository.EmployeeRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Employee レコード削除関連の機能を持つサービス
|
* Employee レコード削除関連の機能を持つサービス
|
||||||
*/
|
*/
|
||||||
@@ -13,21 +14,20 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
@Transactional
|
@Transactional
|
||||||
public class DeleteEmployeeImpl implements DeleteEmployee {
|
public class DeleteEmployeeImpl implements DeleteEmployee {
|
||||||
|
|
||||||
EmployeeRepository employeeRepository;
|
EmployeeRepository employeeRepository;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public DeleteEmployeeImpl(EmployeeRepository employeeRepository) {
|
public DeleteEmployeeImpl(EmployeeRepository employeeRepository) {
|
||||||
this.employeeRepository = employeeRepository;
|
this.employeeRepository = employeeRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/**
|
* idEmployee を元に employee データを削除するメソッド
|
||||||
* idEmployee を元に employee データを削除
|
*
|
||||||
*
|
* @param idEmployee 削除対象のidEmployee
|
||||||
* @param idEmployee 削除対象のidEmployee
|
*/
|
||||||
*/
|
public void deleteEmployee(Integer idEmployee) {
|
||||||
public void deleteEmployee(Integer idEmployee) {
|
employeeRepository.deleteById(idEmployee);
|
||||||
employeeRepository.deleteById(idEmployee);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.example.rhizome.app.domain.service.impl;
|
package com.example.rhizome.app.domain.service.impl;
|
||||||
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@@ -20,66 +19,66 @@ import com.example.rhizome.app.infra.repository.HeadquartersRepository;
|
|||||||
@Transactional
|
@Transactional
|
||||||
public class RegisterDepartmentImpl implements RegisterDepartment {
|
public class RegisterDepartmentImpl implements RegisterDepartment {
|
||||||
|
|
||||||
DepartmentRepository departmentRepository;
|
DepartmentRepository departmentRepository;
|
||||||
DivisionRepository divisionRepository;
|
DivisionRepository divisionRepository;
|
||||||
HeadquartersRepository headquartersRepository;
|
HeadquartersRepository headquartersRepository;
|
||||||
/**
|
|
||||||
* コンストラクタ
|
|
||||||
*
|
|
||||||
* @param departmentRepository DI対象
|
|
||||||
*/
|
|
||||||
@Autowired
|
|
||||||
public RegisterDepartmentImpl(DepartmentRepository departmentRepository,
|
|
||||||
DivisionRepository divisionRepository,
|
|
||||||
HeadquartersRepository headquartersRepository) {
|
|
||||||
this.departmentRepository = departmentRepository;
|
|
||||||
this.divisionRepository = divisionRepository;
|
|
||||||
this.headquartersRepository = headquartersRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* department インスタンスの内容を登録する
|
* コンストラクタ
|
||||||
*
|
*
|
||||||
* @param department 登録対象のデータ
|
* @param departmentRepository DI対象
|
||||||
*/
|
* @param divisionRepository DI対象
|
||||||
public void registerDepartment(DivisionEntity divisionEntity) {
|
* @param headquartersRepository DI対象
|
||||||
DepartmentEntity departmentEntity = divisionEntity.getDepartment();
|
*/
|
||||||
HeadquartersEntity headquartersEntity = divisionEntity.getDepartment().getHeadquarters();
|
@Autowired
|
||||||
HeadquartersEntity originHeadquartersEntity =
|
public RegisterDepartmentImpl(DepartmentRepository departmentRepository,
|
||||||
headquartersRepository.findByNmHeadquarters(
|
DivisionRepository divisionRepository,
|
||||||
divisionEntity.getDepartment().getHeadquarters().getNmHeadquarters());
|
HeadquartersRepository headquartersRepository) {
|
||||||
if(originHeadquartersEntity!=null){
|
this.departmentRepository = departmentRepository;
|
||||||
headquartersEntity=originHeadquartersEntity;
|
this.divisionRepository = divisionRepository;
|
||||||
}else {
|
this.headquartersRepository = headquartersRepository;
|
||||||
headquartersEntity = new HeadquartersEntity();
|
}
|
||||||
headquartersEntity.setNmHeadquarters(
|
|
||||||
divisionEntity.getDepartment()
|
/**
|
||||||
.getHeadquarters()
|
* division,department,headquartersインスタンスの内容を登録する
|
||||||
.getNmHeadquarters()
|
*
|
||||||
);
|
* @param divisionEntity 登録対象のデータ
|
||||||
}
|
* @param departmentEntity 登録対象のデータ
|
||||||
|
* @param headquartersEntity 登録対象のデータ
|
||||||
DepartmentEntity originDepartmentEntity =
|
*/
|
||||||
departmentRepository.findByHeadquartersAndNmDepartment(
|
public void registerDepartment(DivisionEntity divisionEntity) {
|
||||||
headquartersEntity,
|
DepartmentEntity departmentEntity = divisionEntity.getDepartment();
|
||||||
divisionEntity.getDepartment().getNmDepartment());
|
HeadquartersEntity headquartersEntity = divisionEntity.getDepartment().getHeadquarters();
|
||||||
if(originDepartmentEntity!=null) {
|
HeadquartersEntity originHeadquartersEntity = headquartersRepository.findByNmHeadquarters(
|
||||||
departmentEntity=originDepartmentEntity;
|
divisionEntity.getDepartment().getHeadquarters().getNmHeadquarters());
|
||||||
}else {
|
if (originHeadquartersEntity != null) {
|
||||||
departmentEntity = new DepartmentEntity();
|
headquartersEntity = originHeadquartersEntity;
|
||||||
departmentEntity.setNmDepartment(
|
} else {
|
||||||
divisionEntity.getDepartment()
|
headquartersEntity = new HeadquartersEntity();
|
||||||
.getNmDepartment()
|
headquartersEntity.setNmHeadquarters(
|
||||||
);
|
divisionEntity.getDepartment()
|
||||||
}
|
.getHeadquarters()
|
||||||
|
.getNmHeadquarters());
|
||||||
|
}
|
||||||
divisionEntity.setIsDisplay(0);
|
|
||||||
departmentEntity.setIsDisplay(0);
|
DepartmentEntity originDepartmentEntity = departmentRepository.findByHeadquartersAndNmDepartment(
|
||||||
headquartersEntity.setIsDisplay(0);
|
originHeadquartersEntity,
|
||||||
|
divisionEntity.getDepartment().getNmDepartment());
|
||||||
departmentEntity.setHeadquarters(headquartersEntity);
|
if (originDepartmentEntity != null) {
|
||||||
divisionEntity.setDepartment(departmentEntity);
|
departmentEntity = originDepartmentEntity;
|
||||||
divisionRepository.save(divisionEntity);
|
} 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.example.rhizome.app.domain.service.impl;
|
package com.example.rhizome.app.domain.service.impl;
|
||||||
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
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.DivisionRepository;
|
||||||
import com.example.rhizome.app.infra.repository.HeadquartersRepository;
|
import com.example.rhizome.app.infra.repository.HeadquartersRepository;
|
||||||
import com.example.rhizome.app.infra.repository.RegisterDepartmentRepository;
|
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
|
@Transactional
|
||||||
public class SearchDepartmentImpl implements SearchDepartment {
|
public class SearchDepartmentImpl implements SearchDepartment {
|
||||||
DivisionRepository divisionRepository;
|
DivisionRepository divisionRepository;
|
||||||
DepartmentRepository departmentRepository;
|
DepartmentRepository departmentRepository;
|
||||||
HeadquartersRepository headquartersRepository;
|
HeadquartersRepository headquartersRepository;
|
||||||
DepartmentInfoRepository departmentInfoRepository;
|
DepartmentInfoRepository departmentInfoRepository;
|
||||||
RegisterDepartmentRepository registerDepartmentRepository;
|
RegisterDepartmentRepository registerDepartmentRepository;
|
||||||
/**
|
RegisterDivisionRepository registerDivisionRepository;
|
||||||
* コンストラクタ
|
|
||||||
*
|
|
||||||
* @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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部署情報を全件取得する
|
* コンストラクタ
|
||||||
*
|
*
|
||||||
* @return 取得した本部情報レコード全件
|
* @param divisionRepository DI対象
|
||||||
*/
|
* @param departmentRepository DI対象
|
||||||
public List<AllDepartmentInfo>searchAllDepartmentTable(){
|
* @param headquartersRepository DI対象
|
||||||
return DepartmentInfoEntity.createDepartmentInfoList(departmentInfoRepository.searchAllDepartmentTable());
|
* @param departmentInfoRepository DI対象
|
||||||
}
|
* @param RegisterDepartmentRepository DI対象
|
||||||
|
* @param RegisterDivisionRepository DI対象
|
||||||
|
*/
|
||||||
|
@Autowired
|
||||||
|
public SearchDepartmentImpl(
|
||||||
public List<AllDepartmentInfo>searchAllDepartmentTable(SearchConditionDepartment searchConditionDepartment){
|
DepartmentRepository departmentRepository, DivisionRepository divisionRepository,
|
||||||
return DepartmentInfoEntity.AfterSearchCreateDepartmentInfoList(
|
HeadquartersRepository headquartersRepository, DepartmentInfoRepository departmentInfoRepository,
|
||||||
departmentInfoRepository.findAll(Specification
|
RegisterDepartmentRepository registerDepartmentRepository,
|
||||||
.where(DepartmentInfoRepository.idDivisionEqual(searchConditionDepartment.getIdDivision()))
|
RegisterDivisionRepository registerDivisionRepository) {
|
||||||
.and(DepartmentInfoRepository.nmDivisionEqual(searchConditionDepartment.getNmDivision()))
|
this.departmentRepository = departmentRepository;
|
||||||
)
|
this.divisionRepository = divisionRepository;
|
||||||
);
|
this.headquartersRepository = headquartersRepository;
|
||||||
}
|
this.departmentInfoRepository = departmentInfoRepository;
|
||||||
public boolean searchAllDepartmentTable(
|
this.registerDepartmentRepository = registerDepartmentRepository;
|
||||||
SearchConditionDepartment searchHeadquartersTable,
|
this.registerDivisionRepository = registerDivisionRepository;
|
||||||
SearchConditionDepartment searchDepartmentTable,
|
}
|
||||||
SearchConditionDepartment searchDivisionTable){
|
|
||||||
|
/**
|
||||||
if(departmentInfoRepository.searchAllDepartmentTable(
|
* 部署情報を全件取得する
|
||||||
|
*
|
||||||
|
* @return 取得した部署情報レコード全件
|
||||||
|
*/
|
||||||
|
public List<AllDepartmentInfo> searchAllDepartmentTable() {
|
||||||
|
return DepartmentInfoEntity.createDepartmentInfoList(departmentInfoRepository.searchAllDepartmentTable());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 課の条件を基に部署情報を全件取得する
|
||||||
|
* @param SearchConditionDepartment 検索条件
|
||||||
|
* @return 検索結果のレコード
|
||||||
|
*/
|
||||||
|
public List<AllDepartmentInfo> 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(),
|
searchHeadquartersTable.getNmDivision(),
|
||||||
searchDepartmentTable.getNmDivision(),
|
searchDepartmentTable.getNmDivision(),
|
||||||
searchDivisionTable.getNmDivision()).isEmpty()) {
|
searchDivisionTable.getNmDivision()).isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}else{
|
} else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean searchAllDepartmentTable(
|
/**
|
||||||
Integer idHeadquarters,
|
* 三つの部署のIDを基に部署情報を取得する→重複チェック
|
||||||
Integer idDepartment,
|
* @param Integer idHeadquarters 検索条件
|
||||||
Integer idDivision){
|
* @param Integer idDepartment 検索条件
|
||||||
|
* @param Integer idDivision 検索条件
|
||||||
if(departmentInfoRepository.searchAllDepartmentTable(
|
* @return 重複があればtrue
|
||||||
|
* @return 重複が無ければfalse
|
||||||
|
*/
|
||||||
|
public boolean searchAllDepartmentTable(
|
||||||
|
Integer idHeadquarters,
|
||||||
|
Integer idDepartment,
|
||||||
|
Integer idDivision) {
|
||||||
|
|
||||||
|
if (departmentInfoRepository.searchAllDepartmentTable(
|
||||||
idHeadquarters,
|
idHeadquarters,
|
||||||
idDepartment,
|
idDepartment,
|
||||||
idDivision).isEmpty()) {
|
idDivision).isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}else{
|
} else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* searchConditionDepartment の情報を元に Department のレコードを取得
|
|
||||||
*
|
|
||||||
* @param searchConditionDepartment 検索条件
|
|
||||||
* @return 検索結果のレコード
|
|
||||||
*/
|
|
||||||
public List<Headquarters> searchByHeadquarters(SearchConditionDepartment searchConditionDepartment) {
|
|
||||||
|
|
||||||
return HeadquartersEntity
|
|
||||||
.createHeadquartersList(
|
|
||||||
headquartersRepository.findAll(Specification
|
|
||||||
.where(HeadquartersRepository.idHeadquartersEqual(searchConditionDepartment.getIdDivision()))
|
|
||||||
.and(HeadquartersRepository.nmHeadquartersEqual(searchConditionDepartment.getNmDivision()))
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
/**
|
||||||
public List<Department> searchByDepartment(SearchConditionDepartment searchConditionDepartment) {
|
* searchConditionDepartment の情報を元に Headquarters のレコードを取得
|
||||||
// 動的に検索条件を絞り込む
|
*
|
||||||
// // Specification は Criteria API //の Predicate をラップしたもの
|
* @param searchConditionDepartment 検索条件
|
||||||
return DepartmentEntity
|
* @return 検索結果のレコード
|
||||||
.createDepartmentList(
|
*/
|
||||||
departmentRepository.findAll(Specification
|
public List<Headquarters> searchByHeadquarters(SearchConditionDepartment searchConditionDepartment) {
|
||||||
.where(DepartmentRepository.idDepartmentEqual(searchConditionDepartment.getIdDivision()))
|
|
||||||
.and(DepartmentRepository.nmDepartmentEqual(searchConditionDepartment.getNmDivision()))
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
return HeadquartersEntity
|
||||||
public List<Division> searchByDivision(SearchConditionDepartment searchConditionDepartment) {
|
.createHeadquartersList(
|
||||||
// 動的に検索条件を絞り込む
|
headquartersRepository.findAll(Specification
|
||||||
// // Specification は Criteria AP//I の Predicate をラップしたもの
|
.where(HeadquartersRepository
|
||||||
return DivisionEntity
|
.idHeadquartersEqual(searchConditionDepartment.getIdDivision()))
|
||||||
.createDivisionList(
|
.and(HeadquartersRepository
|
||||||
divisionRepository.findAll(Specification
|
.nmHeadquartersEqual(searchConditionDepartment.getNmDivision()))));
|
||||||
.where(DivisionRepository.idDivisionEqual(searchConditionDepartment.getIdDivision()))
|
|
||||||
.and(DivisionRepository.nmDivisionEqual(searchConditionDepartment.getNmDivision()))
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Department>searchByIdHeadquarters(Integer idHeadquarters){
|
/**
|
||||||
System.out.println("3");
|
* searchConditionDepartment の情報を元に Department のレコードを取得
|
||||||
registerDepartmentRepository.findAll(Specification
|
*
|
||||||
.where(RegisterDepartmentRepository.idHeadquartersEqual(idHeadquarters)));
|
* @param searchConditionDepartment 検索条件
|
||||||
|
* @return 検索結果のレコード
|
||||||
System.out.println("SearchDepartmentImpl=>4");
|
*/
|
||||||
|
public List<Department> searchByDepartment(SearchConditionDepartment searchConditionDepartment) {
|
||||||
return DepartmentEntity
|
// 動的に検索条件を絞り込む
|
||||||
.createDepartmentListBy(registerDepartmentRepository.findAll(Specification
|
// // Specification は Criteria API //の Predicate をラップしたもの
|
||||||
.where(RegisterDepartmentRepository.idHeadquartersEqual(idHeadquarters))));
|
return DepartmentEntity
|
||||||
}
|
.createDepartmentList(
|
||||||
public List<Division>searchByIdDepartment(Integer idDepartment){
|
departmentRepository.findAll(Specification
|
||||||
return DivisionEntity
|
.where(DepartmentRepository
|
||||||
.createDivisionList(divisionRepository.findAll(Specification
|
.idDepartmentEqual(searchConditionDepartment.getIdDivision()))
|
||||||
.where(DivisionRepository.idDepartmentEqual(idDepartment))));
|
.and(DepartmentRepository
|
||||||
}
|
.nmDepartmentEqual(searchConditionDepartment.getNmDivision()))));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* searchConditionDepartment の情報を元に Division のレコードを取得
|
||||||
|
*
|
||||||
|
* @param searchConditionDepartment 検索条件
|
||||||
|
* @return 検索結果のレコード
|
||||||
|
*/
|
||||||
|
public List<Division> 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<Department> 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<Division> searchByIdDepartment(Integer idDepartment) {
|
||||||
|
return DivisionEntity
|
||||||
|
.createRegisterDivisionList(registerDivisionRepository.findAll(Specification
|
||||||
|
.where(RegisterDivisionRepository.idDepartmentEqual(idDepartment))));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* idHeadquarters の情報を元に Headquarters のレコードを取得
|
||||||
|
*
|
||||||
|
* @param Integer idHeadquarters 検索条件
|
||||||
|
* @return 検索結果のレコード
|
||||||
|
*/
|
||||||
|
public List<Headquarters> searchHeadquartersByIdHeadquarters(Integer idHeadquarters) {
|
||||||
|
return HeadquartersEntity
|
||||||
|
.createHeadquartersList(headquartersRepository.findAll(Specification
|
||||||
|
.where(HeadquartersRepository.idHeadquartersEqual(idHeadquarters))));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* idDepartment の情報を元に Department のレコードを取得
|
||||||
|
*
|
||||||
|
* @param Integer idDepartment 検索条件
|
||||||
|
* @return 検索結果のレコード
|
||||||
|
*/
|
||||||
|
public List<Department> searchDepartmentByIdDepartment(Integer idDepartment) {
|
||||||
|
return DepartmentEntity
|
||||||
|
.createDepartmentList(departmentRepository.findAll(Specification
|
||||||
|
.where(DepartmentRepository.idDepartmentEqual(idDepartment))));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* idDivision の情報を元に Division のレコードを取得
|
||||||
|
*
|
||||||
|
* @param Integer idDivision 検索条件
|
||||||
|
* @return 検索結果のレコード
|
||||||
|
*/
|
||||||
|
public List<Division> searchDivisionByIdDivision(Integer idDivision) {
|
||||||
|
return DivisionEntity
|
||||||
|
.createDivisionList(divisionRepository.findAll(Specification
|
||||||
|
.where(DivisionRepository.idDivisionEqual(idDivision))));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,53 +19,52 @@ import com.example.rhizome.app.infra.repository.EmployeeRepository;
|
|||||||
@Transactional
|
@Transactional
|
||||||
public class SearchEmployeeImpl implements SearchEmployee {
|
public class SearchEmployeeImpl implements SearchEmployee {
|
||||||
|
|
||||||
EmployeeRepository employeeRepository;
|
EmployeeRepository employeeRepository;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public SearchEmployeeImpl(EmployeeRepository employeeRepository) {
|
public SearchEmployeeImpl(EmployeeRepository employeeRepository) {
|
||||||
this.employeeRepository = employeeRepository;
|
this.employeeRepository = employeeRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mailAddress を元に Employee Table を検索します。
|
||||||
|
*
|
||||||
|
* @param mailAddress 検索対象の mailAddress
|
||||||
|
* @return Table から取得したレコードの情報
|
||||||
|
*/
|
||||||
|
public List<Employee> searchEmployee(String mailAddress) {
|
||||||
|
return EmployeeEntity.createEmployeeList(employeeRepository.findByMailAddress(mailAddress).stream().toList());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* mailAddress を元に Employee Table を検索します。
|
* mailAddress を元に ログイン者の情報 を検索します。
|
||||||
*
|
*
|
||||||
* @param mailAddress 検索対象の mailAddress
|
* @param mailAddress 検索対象の mailAddress
|
||||||
* @return Table から取得したレコードの情報
|
* @return login者の情報
|
||||||
*/
|
*/
|
||||||
public List<Employee> searchEmployee(String mailAddress) {
|
public LoginUser searchLoginUser(String mailAddress) {
|
||||||
return EmployeeEntity.createEmployeeList(employeeRepository.findByMailAddress(mailAddress).stream().toList());
|
return employeeRepository.findByMailAddress(mailAddress).orElse(new EmployeeEntity()).createLoginUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* mailAddress を元に ログイン者の情報 を検索します。
|
* idEmployee を元に Employee Table を検索します。
|
||||||
*
|
*
|
||||||
* @param mailAddress 検索対象の mailAddress
|
* @param idEmployee 検索対象の idEmployee
|
||||||
* @return login者の情報
|
* @return Table から取得したレコードの情報
|
||||||
*/
|
*/
|
||||||
public LoginUser searchLoginUser(String mailAddress) {
|
public Employee searchEmployeeByIdEmployee(Integer idEmployee) {
|
||||||
return employeeRepository.findByMailAddress(mailAddress).orElse(new EmployeeEntity()).createLoginUser();
|
return EmployeeEntity
|
||||||
}
|
.createEmployee(employeeRepository.findByIdEmployee(idEmployee).orElse(new EmployeeEntity()));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* idEmployee を元に Employee Table を検索します。
|
* idDivision を元に Employee Table を検索します。
|
||||||
*
|
*
|
||||||
* @param idEmployee 検索対象の idEmployee
|
* @param idDivision 本部ID
|
||||||
* @return Table から取得したレコードの情報
|
* @return Table から取得したレコードの情報
|
||||||
*/
|
*/
|
||||||
public Employee searchEmployeeByIdEmployee(Integer idEmployee) {
|
@Override
|
||||||
return EmployeeEntity.createEmployee(employeeRepository.findByIdEmployee(idEmployee).orElse(new EmployeeEntity()));
|
public List<Employee> searchEmployeeByIdDepartment(Integer idDivision) {
|
||||||
}
|
return EmployeeEntity.createEmployeeList(employeeRepository.findByDivision_idDivision(idDivision));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* idDepartment を元に Employee Table を検索します。
|
|
||||||
*
|
|
||||||
* @param idDepartment 部署ID
|
|
||||||
* @return Table から取得したレコードの情報
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<Employee> searchEmployeeByIdDepartment(Integer idDivision) {
|
|
||||||
return EmployeeEntity.createEmployeeList(employeeRepository.findByDivision_idDivision(idDivision));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,45 +20,44 @@ import com.example.rhizome.app.infra.repository.EmployeeInfoRepository;
|
|||||||
@Transactional
|
@Transactional
|
||||||
public class SearchEmployeeInfoImpl implements SearchEmployeeInfo {
|
public class SearchEmployeeInfoImpl implements SearchEmployeeInfo {
|
||||||
|
|
||||||
EmployeeInfoRepository employeeInfoRepository;
|
EmployeeInfoRepository employeeInfoRepository;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public SearchEmployeeInfoImpl(EmployeeInfoRepository employeeInfoRepository) {
|
public SearchEmployeeInfoImpl(EmployeeInfoRepository employeeInfoRepository) {
|
||||||
this.employeeInfoRepository = employeeInfoRepository;
|
this.employeeInfoRepository = employeeInfoRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EmployeeInfo (employee join division join department join headquarters) のレコードを全件取得
|
||||||
|
*
|
||||||
|
* @return 取得したレコード全件
|
||||||
|
*/
|
||||||
|
public List<AllEmployeeInfo> selectAll() {
|
||||||
|
|
||||||
/**
|
return EmployeeDepartmentEntity.createEmployeeInfoList(employeeInfoRepository.findAlltable());
|
||||||
* EmployeeInfo (employee join department) のレコードを全件取得
|
|
||||||
*
|
|
||||||
* @return 取得したレコード全件
|
|
||||||
*/
|
|
||||||
public List<AllEmployeeInfo> selectAll() {
|
|
||||||
|
|
||||||
return EmployeeDepartmentEntity.createEmployeeInfoList(employeeInfoRepository.findAlltable());
|
}
|
||||||
|
|
||||||
}
|
/**
|
||||||
|
* SearchConditionEmployee の情報を元に
|
||||||
|
* EmployeeInfo (employee join division join department join headquarters)
|
||||||
|
* のレコードを取得
|
||||||
|
*
|
||||||
|
* @param searchConditionEmployee 検索条件
|
||||||
|
* @return 検索結果のレコードリスト
|
||||||
|
*/
|
||||||
|
public List<AllEmployeeInfo> searchBy(SearchConditionEmployee searchConditionEmployee) {
|
||||||
|
// 動的に検索条件を絞り込む
|
||||||
|
// Specification は Criteria API の Predicate をラップしたもの
|
||||||
|
|
||||||
/**
|
return EmployeeDepartmentEntity
|
||||||
* SearchConditionEmployee の情報を元に EmployeeInfo (employee join department) のレコードを取得
|
.AfterSearchCreateEmployeeInfoList(
|
||||||
*
|
employeeInfoRepository.findAll(Specification
|
||||||
* @param searchConditionEmployee 検索条件
|
.where(EmployeeInfoRepository.idEmployeeEqual(searchConditionEmployee.getIdEmployee()))
|
||||||
* @return 検索結果のレコードリスト
|
.and(EmployeeInfoRepository.nmEmployeeEqual(searchConditionEmployee.getNmEmployee()))
|
||||||
*/
|
.and(EmployeeInfoRepository.knEmployeeEqual(searchConditionEmployee.getKnEmployee()))
|
||||||
public List<AllEmployeeInfo> searchBy(SearchConditionEmployee searchConditionEmployee) {
|
.and(EmployeeInfoRepository.mailAddressEqual(searchConditionEmployee.getMailAddress()))
|
||||||
// 動的に検索条件を絞り込む
|
.and(EmployeeInfoRepository.idDivisionEqual(searchConditionEmployee.getIdDivision()))));
|
||||||
// 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()))
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,21 +6,28 @@ import java.time.Period;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import com.example.rhizome.app.domain.service.TenureCalc;
|
import com.example.rhizome.app.domain.service.TenureCalc;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class TenureCalucImpl implements TenureCalc {
|
public class TenureCalucImpl implements TenureCalc {
|
||||||
public String tenureCalc(String hireDate){
|
/**
|
||||||
|
* hireDate をもとに勤続年数を計算
|
||||||
|
*
|
||||||
|
* @param String hireDate
|
||||||
|
* @return 計算結果の勤続年数
|
||||||
|
*/
|
||||||
|
public String tenureCalc(String hireDate) {
|
||||||
String tenure;
|
String tenure;
|
||||||
LocalDate hiredate = LocalDate.parse(hireDate);
|
LocalDate hiredate = LocalDate.parse(hireDate);
|
||||||
LocalDate today = LocalDate.now();
|
LocalDate today = LocalDate.now();
|
||||||
Period period = Period.between(hiredate, today);
|
Period period = Period.between(hiredate, today);
|
||||||
|
|
||||||
if(period.getYears()<=0&&period.getMonths()<=0) {
|
if (period.getYears() <= 0 && period.getMonths() <= 0) {
|
||||||
tenure = "0年0ヶ月";
|
tenure = "0年0ヶ月";
|
||||||
return tenure;
|
return tenure;
|
||||||
}else {
|
} else {
|
||||||
tenure=period.getYears()+"年"+period.getMonths()+"ヶ月";
|
tenure = period.getYears() + "年" + period.getMonths() + "ヶ月";
|
||||||
return tenure;
|
return tenure;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,38 +18,33 @@ import com.example.rhizome.app.infra.repository.DivisionRepository;
|
|||||||
@Transactional
|
@Transactional
|
||||||
public class UpdateDepartmentImpl implements UpdateDepartment {
|
public class UpdateDepartmentImpl implements UpdateDepartment {
|
||||||
|
|
||||||
|
DivisionRepository divisionRepository;
|
||||||
DivisionRepository divisionRepository;
|
|
||||||
|
@Autowired
|
||||||
@Autowired
|
public UpdateDepartmentImpl(DivisionRepository divisionRepository) {
|
||||||
public UpdateDepartmentImpl(DivisionRepository divisionRepository
|
this.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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,47 +16,47 @@ import com.example.rhizome.app.infra.repository.EmployeeRepository;
|
|||||||
@Transactional
|
@Transactional
|
||||||
public class UpdateEmployeeImpl implements UpdateEmployee {
|
public class UpdateEmployeeImpl implements UpdateEmployee {
|
||||||
|
|
||||||
EmployeeRepository employeeRepository;
|
EmployeeRepository employeeRepository;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public UpdateEmployeeImpl(EmployeeRepository employeeRepository) {
|
public UpdateEmployeeImpl(EmployeeRepository employeeRepository) {
|
||||||
this.employeeRepository = employeeRepository;
|
this.employeeRepository = employeeRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* employee の情報を元に employee table のレコードを更新する
|
* employee の情報を元に employee table のレコードを更新する
|
||||||
*
|
*
|
||||||
* @param beforeEmployee 更新前のデータ
|
* @param beforeEmployee 更新前のデータ
|
||||||
* @param updateEmployee 更新後のデータ
|
* @param updateEmployee 更新後のデータ
|
||||||
*/
|
*/
|
||||||
public void updateEmployee(Employee beforeEmployee, Employee 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 beforeEmployee 更新前のデータ
|
||||||
* @param updateEmployee 更新対象のデータ
|
* @param updateEmployee 更新対象のデータ
|
||||||
* @return マージしたデータ
|
* @return マージしたデータ
|
||||||
*/
|
*/
|
||||||
private Employee mergeEmployee(Employee beforeEmployee, Employee updateEmployee) {
|
private Employee mergeEmployee(Employee beforeEmployee, Employee updateEmployee) {
|
||||||
// 更新対象のデータのパスワードが空文字の場合は、更新前のパスワードを使用する
|
// 更新対象のデータのパスワードが空文字の場合は、更新前のパスワードを使用する
|
||||||
// 更新対象のデータの管理者権限が null の場合は、更新前の管理者権限を使用する
|
// 更新対象のデータの管理者権限が null の場合は、更新前の管理者権限を使用する
|
||||||
// 更新対象のデータの部署IDが null の場合は、更新前の部署IDを使用する
|
// 更新対象のデータの部署IDが null の場合は、更新前の部署IDを使用する
|
||||||
return new Employee(
|
return new Employee(
|
||||||
updateEmployee.getIdEmployee(),
|
updateEmployee.getIdEmployee(),
|
||||||
updateEmployee.getNmEmployee(),
|
updateEmployee.getNmEmployee(),
|
||||||
updateEmployee.getKnEmployee(),
|
updateEmployee.getKnEmployee(),
|
||||||
updateEmployee.getMailAddress(),
|
updateEmployee.getMailAddress(),
|
||||||
updateEmployee.getPassword().isBlank() ? beforeEmployee.getPassword() : updateEmployee.getPassword(),
|
updateEmployee.getPassword().isBlank() ? beforeEmployee.getPassword() : updateEmployee.getPassword(),
|
||||||
updateEmployee.getHireDate(),
|
updateEmployee.getHireDate(),
|
||||||
updateEmployee.getAdminAuth() == null ? beforeEmployee.getAdminAuth() : updateEmployee.getAdminAuth(),
|
updateEmployee.getAdminAuth() == null ? beforeEmployee.getAdminAuth() : updateEmployee.getAdminAuth(),
|
||||||
updateEmployee.getIdDivision() == null ? beforeEmployee.getIdDivision() : updateEmployee.getIdDivision()
|
updateEmployee.getIdDivision() == null ? beforeEmployee.getIdDivision()
|
||||||
);
|
: updateEmployee.getIdDivision());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.example.rhizome.app.infra.entity;
|
package com.example.rhizome.app.infra.entity;
|
||||||
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
@@ -39,85 +38,87 @@ import lombok.NoArgsConstructor;
|
|||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
//@NamedEntityGraph(
|
|
||||||
// name = "department_with_headquarters",
|
|
||||||
// includeAllAttributes = true
|
|
||||||
//)
|
|
||||||
public class DepartmentEntity {
|
public class DepartmentEntity {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部ID
|
* 部ID
|
||||||
*/
|
*/
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
@Column(name = "id_department", nullable = false)
|
@Column(name = "id_department", nullable = false)
|
||||||
private Integer idDepartment;
|
private Integer idDepartment;
|
||||||
/**
|
/**
|
||||||
* 部名
|
* 部名
|
||||||
*/
|
*/
|
||||||
@Column(name = "nm_department", nullable = false)
|
@Column(name = "nm_department", nullable = false)
|
||||||
private String nmDepartment;
|
private String nmDepartment;
|
||||||
/**
|
/**
|
||||||
* 表示・非表示フラグ
|
* 表示・非表示フラグ
|
||||||
*/
|
*/
|
||||||
@Column(name = "is_display", nullable = false)
|
@Column(name = "is_display", nullable = false)
|
||||||
private Integer isDisplay;
|
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<Department> リスト
|
|
||||||
*/
|
|
||||||
public static List<Department> createDepartmentList(List<DepartmentEntity> departmentEntityList) {
|
|
||||||
|
|
||||||
// Stream API を利用するとこうなります。
|
@ManyToOne(cascade = CascadeType.ALL)
|
||||||
return departmentEntityList
|
@JoinColumn(name = "id_headquarters")
|
||||||
.stream()
|
@Fetch(FetchMode.JOIN)
|
||||||
.map(departmentEntity -> new Department(
|
private HeadquartersEntity headquarters;
|
||||||
departmentEntity.getIdDepartment(),
|
|
||||||
departmentEntity.getNmDepartment(),
|
|
||||||
departmentEntity.getIsDisplay(),
|
|
||||||
departmentEntity.getHeadquarters() == null ? null : departmentEntity.getHeadquarters().getIdHeadquarters()
|
|
||||||
|
|
||||||
)).toList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<Department> createDepartmentListBy(List<RegisterDepartmentEntity> departmentEntityList) {
|
/**
|
||||||
|
* DepartmentEntity(DataAccess層依存)から Department(BusinessLogic層依存型)に変換します。(リスト版)
|
||||||
|
*
|
||||||
|
* @param departmentEntityList department Table のリスト
|
||||||
|
* @return List<Department> リスト
|
||||||
|
*/
|
||||||
|
public static List<Department> createDepartmentList(List<DepartmentEntity> departmentEntityList) {
|
||||||
|
|
||||||
// Stream API を利用するとこうなります。
|
// Stream API を利用するとこうなります。
|
||||||
return departmentEntityList
|
return departmentEntityList
|
||||||
.stream()
|
.stream()
|
||||||
.map(departmentEntity -> new Department(
|
.map(departmentEntity -> new Department(
|
||||||
departmentEntity.getIdDepartment(),
|
departmentEntity.getIdDepartment(),
|
||||||
departmentEntity.getNmDepartment(),
|
departmentEntity.getNmDepartment(),
|
||||||
departmentEntity.getIsDisplay(),
|
departmentEntity.getIsDisplay(),
|
||||||
departmentEntity.getIdHeadquarters() == null ? null : departmentEntity.getIdHeadquarters()
|
departmentEntity.getHeadquarters() == null ? null
|
||||||
|
: departmentEntity.getHeadquarters().getIdHeadquarters()
|
||||||
)).toList();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
)).toList();
|
||||||
* Department(BusinessLogic層依存型) から DepartmentEntity(DataAccess層依存)に変換します。
|
}
|
||||||
*
|
|
||||||
* @param department department モデルの値
|
/**
|
||||||
* @return DepartmentEntity に変換したインスタンス
|
* RegisterDepartmentEntity(DataAccess層依存)から Department(BusinessLogic層依存型)に変換します。(リスト版)
|
||||||
*/
|
*
|
||||||
public static DepartmentEntity convertFrom(DepartmentInfo departmentInfo) {
|
* @param departmentEntityList RegisterDepartmentEntity のリスト
|
||||||
return new DepartmentEntity(
|
* @return Departmentのリスト
|
||||||
departmentInfo.getIdDepartment(),
|
*/
|
||||||
departmentInfo.getNmDepartment(),
|
public static List<Department> createDepartmentListBy(List<RegisterDepartmentEntity> departmentEntityList) {
|
||||||
(Integer)0,
|
|
||||||
new HeadquartersEntity(
|
// Stream API を利用するとこうなります。
|
||||||
departmentInfo.getIdHeadquarters(),
|
return departmentEntityList
|
||||||
departmentInfo.getNmHeadquarters(),
|
.stream()
|
||||||
(Integer)0
|
.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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,155 +14,152 @@ import lombok.AllArgsConstructor;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Division join Department,Headquarters テーブルの Entity
|
||||||
|
*
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@NamedEntityGraph(
|
@NamedEntityGraph(name = "division_with_department_with_headquarters", includeAllAttributes = true)
|
||||||
name = "division_with_department_with_headquarters",
|
|
||||||
includeAllAttributes = true
|
|
||||||
)
|
|
||||||
public class DepartmentInfoEntity {
|
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) {
|
* DepartmentInfo をDepartmentInfoEntityに変換します。
|
||||||
return new DepartmentInfoEntity(
|
*
|
||||||
new DivisionEntity(
|
*@param departmentInfo DepartmentInfo のインスタンス
|
||||||
departmentInfo.getIdDivision(),
|
*@return DepartmentInfoEntityのインスタンス
|
||||||
departmentInfo.getNmDivision(),
|
*/
|
||||||
0,
|
public static DepartmentInfoEntity convertFrom(DepartmentInfo departmentInfo) {
|
||||||
new DepartmentEntity(
|
return new DepartmentInfoEntity(
|
||||||
departmentInfo.getIdDepartment(),
|
new DivisionEntity(
|
||||||
departmentInfo.getNmDepartment(),
|
departmentInfo.getIdDivision(),
|
||||||
0,
|
departmentInfo.getNmDivision(),
|
||||||
new HeadquartersEntity(
|
0,
|
||||||
departmentInfo.getIdHeadquarters(),
|
new DepartmentEntity(
|
||||||
departmentInfo.getNmHeadquarters(),
|
departmentInfo.getIdDepartment(),
|
||||||
0
|
departmentInfo.getNmDepartment(),
|
||||||
)
|
0,
|
||||||
)
|
new HeadquartersEntity(
|
||||||
),
|
departmentInfo.getIdHeadquarters(),
|
||||||
new DepartmentEntity(
|
departmentInfo.getNmHeadquarters(),
|
||||||
departmentInfo.getIdDepartment(),
|
0))),
|
||||||
departmentInfo.getNmDepartment(),
|
new DepartmentEntity(
|
||||||
0,
|
departmentInfo.getIdDepartment(),
|
||||||
new HeadquartersEntity(
|
departmentInfo.getNmDepartment(),
|
||||||
departmentInfo.getIdHeadquarters(),
|
0,
|
||||||
departmentInfo.getNmHeadquarters(),
|
new HeadquartersEntity(
|
||||||
0
|
departmentInfo.getIdHeadquarters(),
|
||||||
)
|
departmentInfo.getNmHeadquarters(),
|
||||||
),
|
0)),
|
||||||
new HeadquartersEntity(
|
new HeadquartersEntity(
|
||||||
departmentInfo.getIdHeadquarters(),
|
departmentInfo.getIdHeadquarters(),
|
||||||
departmentInfo.getNmHeadquarters(),
|
departmentInfo.getNmHeadquarters(),
|
||||||
0
|
0)
|
||||||
)
|
|
||||||
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* EmployeeDepartmentEntity(DataAccess層依存) を EmployeeInfo(BusinessLogic層依存) に変換します。
|
|
||||||
*
|
|
||||||
* @param employeeDepartmentEntity EmployeeDepartmentEntity のインスタンス
|
|
||||||
* @return EmployeeInfo のインスタンス
|
|
||||||
*/
|
|
||||||
public static AllDepartmentInfo createDepartmentInfo(DepartmentInfoEntity departmentInfoEntity) {
|
|
||||||
|
|
||||||
// コンストラクタを使って書くと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) {
|
||||||
|
|
||||||
/**
|
return new AllDepartmentInfo(
|
||||||
* EmployeeDepartmentEntity(DataAccess層依存) を EmployeeInfo(BusinessLogic層依存) に変換します。
|
new Division(
|
||||||
* (リスト版)
|
departmentInfoEntity.getDivision() == null ? null
|
||||||
*
|
: departmentInfoEntity.getDivision().getIdDivision(),
|
||||||
* @param employeeDepartmentEntityList EmployeeDepartmentEntity インスタンスのリスト
|
departmentInfoEntity.getDivision() == null ? null
|
||||||
* @return EmployeeInfo インスタンスのリスト
|
: departmentInfoEntity.getDivision().getNmDivision(),
|
||||||
*/
|
departmentInfoEntity.getDivision() == null ? null
|
||||||
public static List<AllDepartmentInfo> createDepartmentInfoList(List<DepartmentInfoEntity> departmentInfoEntity) {
|
: 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<AllDepartmentInfo> createDepartmentInfoList(List<DepartmentInfoEntity> departmentInfoEntity) {
|
||||||
|
|
||||||
|
// StreamAPI を使うとこうなります。
|
||||||
public static AllDepartmentInfo createDepartmentInfo(DivisionEntity divisionEntity) {
|
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<AllDepartmentInfo> AfterSearchCreateDepartmentInfoList(List<DivisionEntity> divisionEntity) {
|
* DivisionEntity を AllDepartmentInfo に変換します。
|
||||||
|
*
|
||||||
|
* @param divisionEntity DivisionEntity インスタンス
|
||||||
|
* @return AllDepartmentInfo インスタンス
|
||||||
|
*/
|
||||||
|
public static AllDepartmentInfo createDepartmentInfo(DivisionEntity divisionEntity) {
|
||||||
|
|
||||||
// StreamAPI を使うとこうなります。
|
return new AllDepartmentInfo(
|
||||||
return divisionEntity.stream().map(DepartmentInfoEntity::createDepartmentInfo).toList();
|
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<AllDepartmentInfo> AfterSearchCreateDepartmentInfoList(List<DivisionEntity> divisionEntity) {
|
||||||
|
|
||||||
|
// StreamAPI を使うとこうなります。
|
||||||
|
return divisionEntity.stream().map(DepartmentInfoEntity::createDepartmentInfo).toList();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,82 +21,107 @@ import com.example.rhizome.app.domain.model.Division;
|
|||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
/**
|
||||||
|
* Division テーブルの Entity
|
||||||
|
*
|
||||||
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "division")
|
@Table(name = "division")
|
||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class DivisionEntity {
|
public class DivisionEntity {
|
||||||
/**
|
/**
|
||||||
* 課ID
|
* 課ID
|
||||||
*/
|
*/
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
@Column(name = "id_division", nullable = false)
|
@Column(name = "id_division", nullable = false)
|
||||||
private Integer idDivision;
|
private Integer idDivision;
|
||||||
/**
|
/**
|
||||||
* 課名
|
* 課名
|
||||||
*/
|
*/
|
||||||
@Column(name = "nm_division", nullable = false)
|
@Column(name = "nm_division", nullable = false)
|
||||||
private String nmDivision;
|
private String nmDivision;
|
||||||
/**
|
/**
|
||||||
* 表示・非表示フラグ
|
* 表示・非表示フラグ
|
||||||
*/
|
*/
|
||||||
@Column(name = "is_display", nullable = false)
|
@Column(name = "is_display", nullable = false)
|
||||||
private Integer isDisplay;
|
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<Division> createDivisionList(List<DivisionEntity> divisionEntityList) {
|
|
||||||
|
|
||||||
return divisionEntityList
|
@ManyToOne(cascade = CascadeType.ALL)
|
||||||
.stream()
|
@JoinColumn(name = "id_department")
|
||||||
.map(DivisionEntity ::createDivision ).toList();
|
@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<Division> createDivisionList(List<DivisionEntity> divisionEntityList) {
|
||||||
|
|
||||||
|
return divisionEntityList
|
||||||
|
.stream()
|
||||||
|
.map(DivisionEntity::createDivision).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RegisterDivisionEntity を Divisionに変換します。(リスト版)
|
||||||
|
*
|
||||||
|
* @param divisionEntityList RegisterDivisionEntity のインスタンスのリスト
|
||||||
|
* @return Divisionのインスタンスのリスト
|
||||||
|
*/
|
||||||
|
public static List<Division> createRegisterDivisionList(List<RegisterDivisionEntity> divisionEntityList) {
|
||||||
|
|
||||||
|
return divisionEntityList
|
||||||
|
.stream()
|
||||||
|
.map(divisionEntity -> new Division(
|
||||||
|
divisionEntity.getIdDivision(),
|
||||||
|
divisionEntity.getNmDivision(),
|
||||||
|
divisionEntity.getIsDisplay(),
|
||||||
|
divisionEntity.getIdDepartment() == null ? null : divisionEntity.getIdDepartment()
|
||||||
|
|
||||||
|
)).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,149 +15,143 @@ import lombok.Data;
|
|||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Employee + Department の Join 情報を保持するEntity
|
* Employee + Division + Department + Headquarters の Join 情報を保持するEntity
|
||||||
*
|
*
|
||||||
* @author IT-College
|
* @author IT-College
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@NamedEntityGraph(
|
@NamedEntityGraph(name = "employee_with_division_with_department_with_headquarters", includeAllAttributes = true)
|
||||||
name = "employee_with_division_with_department_with_headquarters",
|
|
||||||
includeAllAttributes = true
|
|
||||||
)
|
|
||||||
public class EmployeeDepartmentEntity {
|
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層依存) を AllEmployeeInfo(BusinessLogic層依存) に変換します。
|
||||||
* EmployeeDepartmentEntity(DataAccess層依存) を EmployeeInfo(BusinessLogic層依存) に変換します。
|
*
|
||||||
*
|
* @param employeeDepartmentEntity EmployeeDepartmentEntity のインスタンス
|
||||||
* @param employeeDepartmentEntity EmployeeDepartmentEntity のインスタンス
|
* @return AllEmployeeInfo のインスタンス
|
||||||
* @return EmployeeInfo のインスタンス
|
*/
|
||||||
*/
|
public static AllEmployeeInfo createEmployeeInfo(EmployeeDepartmentEntity employeeDepartmentEntity) {
|
||||||
public static AllEmployeeInfo createEmployeeInfo(EmployeeDepartmentEntity employeeDepartmentEntity) {
|
|
||||||
|
|
||||||
// コンストラクタを使って書くとSetterを使用するより簡略化出来ます。
|
// コンストラクタを使って書くとSetterを使用するより簡略化出来ます。
|
||||||
// 混乱してしまう人は落ち着いて EmployeeInfo のフィールドを見に行って、
|
// 混乱してしまう人は落ち着いて EmployeeInfo のフィールドを見に行って、
|
||||||
// どうしてこの書き方が出来るのかを理解できる様になりましょう。
|
// どうしてこの書き方が出来るのかを理解できる様になりましょう。
|
||||||
return new AllEmployeeInfo(
|
return new AllEmployeeInfo(
|
||||||
new Employee(
|
new Employee(
|
||||||
employeeDepartmentEntity.getEmployee().getIdEmployee(),
|
employeeDepartmentEntity.getEmployee().getIdEmployee(),
|
||||||
employeeDepartmentEntity.getEmployee().getNmEmployee(),
|
employeeDepartmentEntity.getEmployee().getNmEmployee(),
|
||||||
employeeDepartmentEntity.getEmployee().getKnEmployee(),
|
employeeDepartmentEntity.getEmployee().getKnEmployee(),
|
||||||
employeeDepartmentEntity.getEmployee().getMailAddress(),
|
employeeDepartmentEntity.getEmployee().getMailAddress(),
|
||||||
employeeDepartmentEntity.getEmployee().getPassword(),
|
employeeDepartmentEntity.getEmployee().getPassword(),
|
||||||
employeeDepartmentEntity.getEmployee().getHireDate(),
|
employeeDepartmentEntity.getEmployee().getHireDate(),
|
||||||
employeeDepartmentEntity.getEmployee().getAdminAuth(),
|
employeeDepartmentEntity.getEmployee().getAdminAuth(),
|
||||||
employeeDepartmentEntity.getDivision()
|
employeeDepartmentEntity.getDivision() == null ? null
|
||||||
== null ? null : employeeDepartmentEntity.getDivision().getIdDivision()),
|
: employeeDepartmentEntity.getDivision().getIdDivision()),
|
||||||
new Division(
|
new Division(
|
||||||
employeeDepartmentEntity.getDivision()
|
employeeDepartmentEntity.getDivision() == null ? null
|
||||||
== null ? null : employeeDepartmentEntity.getDivision().getIdDivision(),
|
: employeeDepartmentEntity.getDivision().getIdDivision(),
|
||||||
employeeDepartmentEntity.getDivision()
|
employeeDepartmentEntity.getDivision() == null ? null
|
||||||
== null ? null : employeeDepartmentEntity.getDivision().getNmDivision(),
|
: employeeDepartmentEntity.getDivision().getNmDivision(),
|
||||||
employeeDepartmentEntity.getDivision()
|
employeeDepartmentEntity.getDivision() == null ? null
|
||||||
== null ? null : employeeDepartmentEntity.getDivision().getIsDisplay(),
|
: employeeDepartmentEntity.getDivision().getIsDisplay(),
|
||||||
employeeDepartmentEntity.getDepartment()
|
employeeDepartmentEntity.getDepartment() == null ? null
|
||||||
== null ? null : employeeDepartmentEntity.getDepartment().getIdDepartment()
|
: employeeDepartmentEntity.getDepartment().getIdDepartment()),
|
||||||
),
|
new Department(
|
||||||
new Department(
|
employeeDepartmentEntity.getDepartment() == null ? null
|
||||||
employeeDepartmentEntity.getDepartment()
|
: employeeDepartmentEntity.getDepartment().getIdDepartment(),
|
||||||
== null ? null : employeeDepartmentEntity.getDepartment().getIdDepartment(),
|
employeeDepartmentEntity.getDepartment() == null ? null
|
||||||
employeeDepartmentEntity.getDepartment()
|
: employeeDepartmentEntity.getDepartment().getNmDepartment(),
|
||||||
== null ? null : employeeDepartmentEntity.getDepartment().getNmDepartment(),
|
employeeDepartmentEntity.getDepartment() == null ? null
|
||||||
employeeDepartmentEntity.getDepartment()
|
: employeeDepartmentEntity.getDepartment().getIsDisplay(),
|
||||||
== null ? null : employeeDepartmentEntity.getDepartment().getIsDisplay(),
|
employeeDepartmentEntity.getHeadquarters() == null ? null
|
||||||
employeeDepartmentEntity.getHeadquarters()
|
: employeeDepartmentEntity.getHeadquarters().getIdHeadquarters()),
|
||||||
== null ? null : employeeDepartmentEntity.getHeadquarters().getIdHeadquarters()
|
new Headquarters(
|
||||||
),
|
employeeDepartmentEntity.getHeadquarters() == null ? null
|
||||||
new Headquarters(
|
: employeeDepartmentEntity.getHeadquarters().getIdHeadquarters(),
|
||||||
employeeDepartmentEntity.getHeadquarters()
|
employeeDepartmentEntity.getHeadquarters() == null ? null
|
||||||
== null ? null : employeeDepartmentEntity.getHeadquarters().getIdHeadquarters(),
|
: employeeDepartmentEntity.getHeadquarters().getNmHeadquarters(),
|
||||||
employeeDepartmentEntity.getHeadquarters()
|
employeeDepartmentEntity.getHeadquarters() == null ? null
|
||||||
== null ? null : employeeDepartmentEntity.getHeadquarters().getNmHeadquarters(),
|
: employeeDepartmentEntity.getHeadquarters().getIsDisplay()));
|
||||||
employeeDepartmentEntity.getHeadquarters()
|
|
||||||
== null ? null : employeeDepartmentEntity.getHeadquarters().getIsDisplay()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EmployeeDepartmentEntity(DataAccess層依存) を EmployeeInfo(BusinessLogic層依存) に変換します。
|
* EmployeeDepartmentEntity(DataAccess層依存) を AllEmployeeInfo(BusinessLogic層依存) に変換します。
|
||||||
* (リスト版)
|
* (リスト版)
|
||||||
*
|
*
|
||||||
* @param employeeDepartmentEntityList EmployeeDepartmentEntity インスタンスのリスト
|
* @param employeeDepartmentEntityList EmployeeDepartmentEntity インスタンスのリスト
|
||||||
* @return EmployeeInfo インスタンスのリスト
|
* @return AllEmployeeInfo インスタンスのリスト
|
||||||
*/
|
*/
|
||||||
public static List<AllEmployeeInfo> createEmployeeInfoList(List<EmployeeDepartmentEntity> employeeDepartmentEntityList) {
|
public static List<AllEmployeeInfo> createEmployeeInfoList(
|
||||||
|
List<EmployeeDepartmentEntity> employeeDepartmentEntityList) {
|
||||||
|
|
||||||
// StreamAPI を使うとこうなります。
|
// StreamAPI を使うとこうなります。
|
||||||
return employeeDepartmentEntityList.stream().map(EmployeeDepartmentEntity::createEmployeeInfo).toList();
|
return employeeDepartmentEntityList.stream().map(EmployeeDepartmentEntity::createEmployeeInfo).toList();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AllEmployeeInfo createEmployeeInfo(EmployeeEntity employeeEntity) {
|
|
||||||
|
|
||||||
// コンストラクタを使って書くとSetterを使用するより簡略化出来ます。
|
/**
|
||||||
// 混乱してしまう人は落ち着いて EmployeeInfo のフィールドを見に行って、
|
* EmployeeEntity(DataAccess層依存) を AllEmployeeInfo(BusinessLogic層依存) に変換します。
|
||||||
// どうしてこの書き方が出来るのかを理解できる様になりましょう。
|
*
|
||||||
return new AllEmployeeInfo(
|
* @param employeeEntity EmployeeEntity のインスタンス
|
||||||
new Employee(
|
* @return AllEmployeeInfo のインスタンス
|
||||||
employeeEntity.getIdEmployee(),
|
*/
|
||||||
employeeEntity.getNmEmployee(),
|
public static AllEmployeeInfo createEmployeeInfo(EmployeeEntity employeeEntity) {
|
||||||
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()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
return new AllEmployeeInfo(
|
||||||
|
new Employee(
|
||||||
|
employeeEntity.getIdEmployee(),
|
||||||
public static List<AllEmployeeInfo> AfterSearchCreateEmployeeInfoList(List<EmployeeEntity> employeeEntityList) {
|
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<AllEmployeeInfo> AfterSearchCreateEmployeeInfoList(List<EmployeeEntity> employeeEntityList) {
|
||||||
|
|
||||||
|
// StreamAPI を使うとこうなります。
|
||||||
|
return employeeEntityList.stream().map(EmployeeDepartmentEntity::createEmployeeInfo).toList();
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.example.rhizome.app.infra.entity;
|
package com.example.rhizome.app.infra.entity;
|
||||||
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
@@ -33,7 +32,6 @@ import lombok.NoArgsConstructor;
|
|||||||
/**
|
/**
|
||||||
* EmployeeテーブルのEntity
|
* EmployeeテーブルのEntity
|
||||||
*
|
*
|
||||||
* @author IT-College
|
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "employee")
|
@Table(name = "employee")
|
||||||
@@ -42,159 +40,153 @@ import lombok.NoArgsConstructor;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class EmployeeEntity {
|
public class EmployeeEntity {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 社員ID
|
* 社員ID
|
||||||
*/
|
*/
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
@Column(name = "id_employee", nullable = false)
|
@Column(name = "id_employee", nullable = false)
|
||||||
private Integer idEmployee;
|
private Integer idEmployee;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 社員名
|
* 社員名
|
||||||
*/
|
*/
|
||||||
@Column(name = "nm_employee", nullable = false)
|
@Column(name = "nm_employee", nullable = false)
|
||||||
private String nmEmployee;
|
private String nmEmployee;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 社員名カナ
|
* 社員名カナ
|
||||||
*/
|
*/
|
||||||
@Column(name = "kn_employee", nullable = false)
|
@Column(name = "kn_employee", nullable = false)
|
||||||
private String knEmployee;
|
private String knEmployee;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* メールアドレス
|
* メールアドレス
|
||||||
*/
|
*/
|
||||||
@Column(name = "mail_address", nullable = false)
|
@Column(name = "mail_address", nullable = false)
|
||||||
private String mailAddress;
|
private String mailAddress;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* パスワード
|
* パスワード
|
||||||
*/
|
*/
|
||||||
@Column(name = "password", nullable = false)
|
@Column(name = "password", nullable = false)
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 入社年月日
|
* 入社年月日
|
||||||
*/
|
*/
|
||||||
@Column(name = "hire_Date", nullable = false)
|
@Column(name = "hire_Date", nullable = false)
|
||||||
private String hireDate;
|
private String hireDate;
|
||||||
/**
|
/**
|
||||||
* 管理者権限
|
* 管理者権限
|
||||||
*/
|
*/
|
||||||
@Column(name = "admin_auth", nullable = false)
|
@Column(name = "admin_auth", nullable = false)
|
||||||
private Integer adminAuth;
|
private Integer adminAuth;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部署ID
|
* 部署ID
|
||||||
*/
|
*/
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "id_division")
|
@JoinColumn(name = "id_division")
|
||||||
@Fetch(FetchMode.JOIN)
|
@Fetch(FetchMode.JOIN)
|
||||||
private DivisionEntity division;
|
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層依存)に変換します。
|
* SearchConditionEmployee(BusinessLogic 依存)を EmployeeEntity(DataAccess層依存)に変換します。
|
||||||
*
|
* (コンストラクタを使用せず、Setterを利用したパターン)
|
||||||
* @param employee Employee Table の中身
|
*
|
||||||
* @return EmployeeEntity のインスタンス(1レコード分)
|
* @param searchConditionEmployee 検索条件
|
||||||
*/
|
* @return EmployeeEntity のインスタンス(1レコード分)
|
||||||
public static EmployeeEntity convertFrom(EmployeeInfo employeeInfo) {
|
*/
|
||||||
// 値を既に持ったインスタンスの生成に、コンストラクタを使用するとこうなります。
|
public static EmployeeEntity convertFrom(SearchConditionEmployee searchConditionEmployee) {
|
||||||
return new EmployeeEntity(
|
EmployeeEntity employeeEntity = 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)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
employeeEntity.setIdEmployee(searchConditionEmployee.getIdEmployee());
|
||||||
* SearchConditionEmployee(BusinessLogic 依存)を EmployeeEntity(DataAccess層依存)に変換します。
|
employeeEntity.setNmEmployee(searchConditionEmployee.getNmEmployee());
|
||||||
* (コンストラクタを使用せず、Setterを利用したパターン)
|
employeeEntity.setKnEmployee(searchConditionEmployee.getKnEmployee());
|
||||||
*
|
employeeEntity.setMailAddress(searchConditionEmployee.getMailAddress());
|
||||||
* @param searchConditionEmployee 検索条件
|
|
||||||
* @return EmployeeEntity のインスタンス(1レコード分)
|
|
||||||
*/
|
|
||||||
public static EmployeeEntity convertFrom(SearchConditionEmployee searchConditionEmployee) {
|
|
||||||
EmployeeEntity employeeEntity = new EmployeeEntity();
|
|
||||||
|
|
||||||
employeeEntity.setIdEmployee(searchConditionEmployee.getIdEmployee());
|
return employeeEntity;
|
||||||
employeeEntity.setNmEmployee(searchConditionEmployee.getNmEmployee());
|
|
||||||
employeeEntity.setKnEmployee(searchConditionEmployee.getKnEmployee());
|
|
||||||
employeeEntity.setMailAddress(searchConditionEmployee.getMailAddress());
|
|
||||||
|
|
||||||
return employeeEntity;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EmployeeEntity(DataAccess層依存)から Employee (BusinessLogic層依存型)に変換します。
|
* EmployeeEntity(DataAccess層依存)から Employee (BusinessLogic層依存型)に変換します。
|
||||||
*
|
*
|
||||||
* @param employeeEntity Employee Table のインスタンス
|
* @param employeeEntity Employee Table のインスタンス
|
||||||
* @return employee インスタンス
|
* @return employee インスタンス
|
||||||
*/
|
*/
|
||||||
public static Employee createEmployee(EmployeeEntity employeeEntity) {
|
public static Employee createEmployee(EmployeeEntity employeeEntity) {
|
||||||
// 値を既に持ったインスタンスの生成に、コンストラクタを使用するとこうなります。
|
// 値を既に持ったインスタンスの生成に、コンストラクタを使用するとこうなります。
|
||||||
return new Employee(
|
return new Employee(
|
||||||
employeeEntity.getIdEmployee(),
|
employeeEntity.getIdEmployee(),
|
||||||
employeeEntity.getNmEmployee(),
|
employeeEntity.getNmEmployee(),
|
||||||
employeeEntity.getKnEmployee(),
|
employeeEntity.getKnEmployee(),
|
||||||
employeeEntity.getMailAddress(),
|
employeeEntity.getMailAddress(),
|
||||||
employeeEntity.getPassword(),
|
employeeEntity.getPassword(),
|
||||||
employeeEntity.getHireDate(),
|
employeeEntity.getHireDate(),
|
||||||
employeeEntity.getAdminAuth(),
|
employeeEntity.getAdminAuth(),
|
||||||
employeeEntity.getDivision().getIdDivision()
|
employeeEntity.getDivision().getIdDivision());
|
||||||
);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EmployeeEntity(DataAccess層依存) から Employee (BusinessLogic層依存型)に変換します。(リスト版)
|
* EmployeeEntity(DataAccess層依存) から Employee (BusinessLogic層依存型)に変換します。(リスト版)
|
||||||
*
|
*
|
||||||
* @param employeeEntityList EmployeeEntity インスタンスのリスト
|
* @param employeeEntityList EmployeeEntity インスタンスのリスト
|
||||||
* @return Employee インスタンスのリスト
|
* @return Employee インスタンスのリスト
|
||||||
*/
|
*/
|
||||||
public static List<Employee> createEmployeeList(List<EmployeeEntity> employeeEntityList) {
|
public static List<Employee> createEmployeeList(List<EmployeeEntity> employeeEntityList) {
|
||||||
/* 従来の書き方
|
/* 従来の書き方
|
||||||
List<Employee> employeeList = new ArrayList<>();
|
List<Employee> employeeList = new ArrayList<>();
|
||||||
for(EmployeeEntity employeeEntity:employeeEntityList){
|
for(EmployeeEntity employeeEntity:employeeEntityList){
|
||||||
Employee employee = EmployeeEntity.createEmployee(employeeEntity);
|
Employee employee = EmployeeEntity.createEmployee(employeeEntity);
|
||||||
employeeList.add(employee);
|
employeeList.add(employee);
|
||||||
}
|
}
|
||||||
return employeeList;
|
return employeeList;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Stream APIを使用すると1行で書けます。
|
// Stream APIを使用すると1行で書けます。
|
||||||
return employeeEntityList.stream().map(EmployeeEntity::createEmployee).toList();
|
return employeeEntityList.stream().map(EmployeeEntity::createEmployee).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EmployeeEntity(DataAccess層依存) から LoginUser (BusinessLogic層依存型)情報を作成します。
|
* EmployeeEntity(DataAccess層依存) から LoginUser (BusinessLogic層依存型)情報を作成します。
|
||||||
*
|
*
|
||||||
* @return loginUser (ログイン者の情報) インスタンス
|
* @return loginUser (ログイン者の情報) インスタンス
|
||||||
*/
|
*/
|
||||||
public LoginUser createLoginUser() {
|
public LoginUser createLoginUser() {
|
||||||
// 値を既に持ったインスタンスの生成に、コンストラクタを使用するとこうなります。
|
// 値を既に持ったインスタンスの生成に、コンストラクタを使用するとこうなります。
|
||||||
return new LoginUser(
|
return new LoginUser(
|
||||||
getIdEmployee(),
|
getIdEmployee(),
|
||||||
getNmEmployee(),
|
getNmEmployee(),
|
||||||
getKnEmployee(),
|
getKnEmployee(),
|
||||||
getMailAddress(),
|
getMailAddress(),
|
||||||
getPassword(),
|
getPassword(),
|
||||||
getAdminAuth(),
|
getAdminAuth(),
|
||||||
getDivision().getIdDivision()
|
getDivision().getIdDivision());
|
||||||
);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ import lombok.AllArgsConstructor;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HeadquartersテーブルのEntity
|
||||||
|
*
|
||||||
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "headquarters")
|
@Table(name = "headquarters")
|
||||||
@Data
|
@Data
|
||||||
@@ -23,48 +27,55 @@ import lombok.NoArgsConstructor;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class HeadquartersEntity {
|
public class HeadquartersEntity {
|
||||||
/**
|
/**
|
||||||
* 本部ID
|
* 本部ID
|
||||||
*/
|
*/
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
@Column(name = "id_headquarters", nullable = false)
|
@Column(name = "id_headquarters", nullable = false)
|
||||||
private Integer idHeadquarters;
|
private Integer idHeadquarters;
|
||||||
/**
|
/**
|
||||||
* 本部名
|
* 本部名
|
||||||
*/
|
*/
|
||||||
@Column(name = "nm_headquarters", nullable = false)
|
@Column(name = "nm_headquarters", nullable = false)
|
||||||
private String nmHeadquarters;
|
private String nmHeadquarters;
|
||||||
/**
|
/**
|
||||||
* 表示・非表示フラグ
|
* 表示・非表示フラグ
|
||||||
*/
|
*/
|
||||||
@Column(name = "is_display", nullable = false)
|
@Column(name = "is_display", nullable = false)
|
||||||
private Integer isDisplay;
|
private Integer isDisplay;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static Headquarters createHeadquarters(HeadquartersEntity headquartersEntity) {
|
|
||||||
// 値を既に持ったインスタンスの生成に、コンストラクタを使用するとこうなります。
|
|
||||||
return new Headquarters(
|
|
||||||
headquartersEntity.getIdHeadquarters(),
|
|
||||||
headquartersEntity.getNmHeadquarters(),
|
|
||||||
headquartersEntity.getIsDisplay()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static List<Headquarters> createHeadquartersList(List<HeadquartersEntity> headquartersEntityList) {
|
|
||||||
|
|
||||||
return headquartersEntityList
|
public static Headquarters createHeadquarters(HeadquartersEntity headquartersEntity) {
|
||||||
.stream()
|
// 値を既に持ったインスタンスの生成に、コンストラクタを使用するとこうなります。
|
||||||
.map(HeadquartersEntity ::createHeadquarters ).toList();
|
return new Headquarters(
|
||||||
}
|
headquartersEntity.getIdHeadquarters(),
|
||||||
|
headquartersEntity.getNmHeadquarters(),
|
||||||
public static HeadquartersEntity convertFrom(DepartmentInfo departmentInfo) {
|
headquartersEntity.getIsDisplay());
|
||||||
return new HeadquartersEntity(
|
}
|
||||||
departmentInfo.getIdHeadquarters(),
|
/**
|
||||||
departmentInfo.getNmHeadquarters(),
|
* DBから返ってきたHeadquartersEntityのリストをHeadquartersのリストに変換する
|
||||||
(Integer)0
|
*
|
||||||
);
|
* @param HeadquartersEntityのリスト
|
||||||
}
|
* @return headquartersのリスト
|
||||||
|
*/
|
||||||
|
public static List<Headquarters> createHeadquartersList(List<HeadquartersEntity> 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,9 +14,8 @@ import lombok.Data;
|
|||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EmployeeテーブルのEntity
|
* 社員情報登録用のEmployeeテーブルのEntity
|
||||||
*
|
*
|
||||||
* @author IT-College
|
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "employee")
|
@Table(name = "employee")
|
||||||
@@ -25,76 +24,73 @@ import lombok.NoArgsConstructor;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
|
||||||
public class InsertEmployeeEntity {
|
public class InsertEmployeeEntity {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 社員ID
|
* 社員ID
|
||||||
*/
|
*/
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
@Column(name = "id_employee", nullable = false)
|
@Column(name = "id_employee", nullable = false)
|
||||||
private Integer idEmployee;
|
private Integer idEmployee;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 社員名
|
* 社員名
|
||||||
*/
|
*/
|
||||||
@Column(name = "nm_employee", nullable = false)
|
@Column(name = "nm_employee", nullable = false)
|
||||||
private String nmEmployee;
|
private String nmEmployee;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 社員名カナ
|
* 社員名カナ
|
||||||
*/
|
*/
|
||||||
@Column(name = "kn_employee", nullable = false)
|
@Column(name = "kn_employee", nullable = false)
|
||||||
private String knEmployee;
|
private String knEmployee;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* メールアドレス
|
* メールアドレス
|
||||||
*/
|
*/
|
||||||
@Column(name = "mail_address", nullable = false)
|
@Column(name = "mail_address", nullable = false)
|
||||||
private String mailAddress;
|
private String mailAddress;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* パスワード
|
* パスワード
|
||||||
*/
|
*/
|
||||||
@Column(name = "password", nullable = false)
|
@Column(name = "password", nullable = false)
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 入社年月日
|
* 入社年月日
|
||||||
*/
|
*/
|
||||||
@Column(name = "hire_Date", nullable = false)
|
@Column(name = "hire_Date", nullable = false)
|
||||||
private String hireDate;
|
private String hireDate;
|
||||||
/**
|
/**
|
||||||
* 管理者権限
|
* 管理者権限
|
||||||
*/
|
*/
|
||||||
@Column(name = "admin_auth", nullable = false)
|
@Column(name = "admin_auth", nullable = false)
|
||||||
private Integer adminAuth;
|
private Integer adminAuth;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部署ID
|
* 部署ID
|
||||||
*/
|
*/
|
||||||
@Column(name = "id_division", nullable = false)
|
@Column(name = "id_division", nullable = false)
|
||||||
private Integer idDivision;
|
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()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
package com.example.rhizome.app.infra.entity;
|
package com.example.rhizome.app.infra.entity;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
@@ -11,41 +12,36 @@ import lombok.Data;
|
|||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Department テーブルの Entity
|
* 社員情報登録用のDepartment テーブルの Entity
|
||||||
*
|
*
|
||||||
* @author IT-College
|
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "department")
|
@Table(name = "department")
|
||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
//@NamedEntityGraph(
|
|
||||||
// name = "department_with_headquarters",
|
|
||||||
// includeAllAttributes = true
|
|
||||||
//)
|
|
||||||
public class RegisterDepartmentEntity {
|
public class RegisterDepartmentEntity {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部ID
|
* 部ID
|
||||||
*/
|
*/
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
@Column(name = "id_department", nullable = false)
|
@Column(name = "id_department", nullable = false)
|
||||||
private Integer idDepartment;
|
private Integer idDepartment;
|
||||||
/**
|
/**
|
||||||
* 部名
|
* 部名
|
||||||
*/
|
*/
|
||||||
@Column(name = "nm_department", nullable = false)
|
@Column(name = "nm_department", nullable = false)
|
||||||
private String nmDepartment;
|
private String nmDepartment;
|
||||||
/**
|
/**
|
||||||
* 表示・非表示フラグ
|
* 表示・非表示フラグ
|
||||||
*/
|
*/
|
||||||
@Column(name = "is_display", nullable = false)
|
@Column(name = "is_display", nullable = false)
|
||||||
private Integer isDisplay;
|
private Integer isDisplay;
|
||||||
|
|
||||||
@Column(name = "id_headquarters",nullable = false)
|
@Column(name = "id_headquarters", nullable = false)
|
||||||
private Integer idHeadquarters;
|
private Integer idHeadquarters;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ public interface DepartmentInfoRepository
|
|||||||
|
|
||||||
@EntityGraph(attributePaths = { "department", "department.headquarters" })
|
@EntityGraph(attributePaths = { "department", "department.headquarters" })
|
||||||
void save(@Nullable Specification<DivisionEntity> spec);
|
void save(@Nullable Specification<DivisionEntity> spec);
|
||||||
|
|
||||||
|
|
||||||
@Query("SELECT DISTINCT new com.example.rhizome.app.infra.entity.DepartmentInfoEntity(di,de,h)FROM DivisionEntity di "
|
@Query("SELECT DISTINCT new com.example.rhizome.app.infra.entity.DepartmentInfoEntity(di,de,h)FROM DivisionEntity di "
|
||||||
+ "INNER JOIN di.department de "
|
+ "INNER JOIN di.department de "
|
||||||
@@ -68,7 +67,7 @@ public interface DepartmentInfoRepository
|
|||||||
@Param("nmHeadquarters") String nmHeadquarters,
|
@Param("nmHeadquarters") String nmHeadquarters,
|
||||||
@Param("nmDepartment") String nmDepartment,
|
@Param("nmDepartment") String nmDepartment,
|
||||||
@Param("nmDivision") String nmDivision);
|
@Param("nmDivision") String nmDivision);
|
||||||
|
|
||||||
@Query("SELECT DISTINCT new com.example.rhizome.app.infra.entity.DepartmentInfoEntity(di,de,h)FROM DivisionEntity di "
|
@Query("SELECT DISTINCT new com.example.rhizome.app.infra.entity.DepartmentInfoEntity(di,de,h)FROM DivisionEntity di "
|
||||||
+ "INNER JOIN di.department de "
|
+ "INNER JOIN di.department de "
|
||||||
+ "INNER JOIN de.headquarters h "
|
+ "INNER JOIN de.headquarters h "
|
||||||
@@ -80,7 +79,5 @@ public interface DepartmentInfoRepository
|
|||||||
@Param("idHeadquarters") Integer idHeadquarters,
|
@Param("idHeadquarters") Integer idHeadquarters,
|
||||||
@Param("idDepartment") Integer idDepartment,
|
@Param("idDepartment") Integer idDepartment,
|
||||||
@Param("idDivision") Integer idDivision);
|
@Param("idDivision") Integer idDivision);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -8,7 +8,6 @@ import org.springframework.stereotype.Repository;
|
|||||||
import com.example.rhizome.app.infra.entity.DepartmentEntity;
|
import com.example.rhizome.app.infra.entity.DepartmentEntity;
|
||||||
import com.example.rhizome.app.infra.entity.HeadquartersEntity;
|
import com.example.rhizome.app.infra.entity.HeadquartersEntity;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specification:
|
* Specification:
|
||||||
* 関数型インターフェースです。
|
* 関数型インターフェースです。
|
||||||
@@ -22,41 +21,30 @@ import com.example.rhizome.app.infra.entity.HeadquartersEntity;
|
|||||||
* 戻り値はクエリを格納しているPredicateオブジェクトとなります。
|
* 戻り値はクエリを格納しているPredicateオブジェクトとなります。
|
||||||
*/
|
*/
|
||||||
@Repository
|
@Repository
|
||||||
public interface DepartmentRepository extends JpaRepository<DepartmentEntity, Integer>, JpaSpecificationExecutor<DepartmentEntity> {
|
public interface DepartmentRepository
|
||||||
|
extends JpaRepository<DepartmentEntity, Integer>, JpaSpecificationExecutor<DepartmentEntity> {
|
||||||
|
|
||||||
|
static Specification<DepartmentEntity> idDepartmentEqual(Integer idDepartment) {
|
||||||
|
return idDepartment == null ? null :
|
||||||
|
// 戻り値の型 Specification<DepartmentEntity> にキャスト
|
||||||
|
(Specification<DepartmentEntity>)
|
||||||
|
// ラムダ式で記載しているが書いてあることは criteriaBuilder を使って Where句の後の "'idDepartment' = idDepartment(変数)"
|
||||||
|
// を作成している
|
||||||
|
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.equal(root.get("idDepartment"), idDepartment);
|
||||||
|
}
|
||||||
|
|
||||||
static Specification<DepartmentEntity> idDepartmentEqual(Integer idDepartment) {
|
static Specification<DepartmentEntity> nmDepartmentEqual(String nmDepartment) {
|
||||||
return idDepartment == null ?
|
return (nmDepartment == null || nmDepartment.isEmpty()) ? null
|
||||||
null :
|
: (Specification<DepartmentEntity>) (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder
|
||||||
// 戻り値の型 Specification<DepartmentEntity> にキャスト
|
.like(root.get("nmDepartment"), nmDepartment);
|
||||||
(Specification<DepartmentEntity>)
|
}
|
||||||
// ラムダ式で記載しているが書いてあることは criteriaBuilder を使って Where句の後の "'idDepartment' = idDepartment(変数)"
|
|
||||||
// を作成している
|
|
||||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.equal(root.get("idDepartment"), idDepartment);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Specification<DepartmentEntity> nmDepartmentEqual(String nmDepartment) {
|
static Specification<DepartmentEntity> nmDepartmentLike(String nmDepartment) {
|
||||||
return (nmDepartment == null || nmDepartment.isEmpty()) ?
|
return (nmDepartment == null || nmDepartment.isEmpty()) ? null
|
||||||
null :
|
: (Specification<DepartmentEntity>) (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder
|
||||||
(Specification<DepartmentEntity>)
|
.like(root.get("nmDepartment"), "%" + nmDepartment + "%");
|
||||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.like(root.get("nmDepartment"), nmDepartment);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
DepartmentEntity findByHeadquartersAndNmDepartment(HeadquartersEntity headquartersEntity, String nmDepartment);
|
||||||
|
|
||||||
static Specification<DepartmentEntity> nmDepartmentLike(String nmDepartment) {
|
|
||||||
return (nmDepartment == null || nmDepartment.isEmpty()) ?
|
|
||||||
null :
|
|
||||||
(Specification<DepartmentEntity>)
|
|
||||||
(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<DepartmentEntity> searchDepartmentByIdHeadquarters(
|
|
||||||
// @Param("idHeadquarters") Integer IdHeadquarters);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,39 +1,48 @@
|
|||||||
package com.example.rhizome.app.infra.repository;
|
package com.example.rhizome.app.infra.repository;
|
||||||
|
|
||||||
|
import javax.transaction.Transactional;
|
||||||
|
|
||||||
import org.springframework.data.jpa.domain.Specification;
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
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 org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import com.example.rhizome.app.infra.entity.DivisionEntity;
|
import com.example.rhizome.app.infra.entity.DivisionEntity;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface DivisionRepository extends JpaRepository<DivisionEntity, Integer>, JpaSpecificationExecutor<DivisionEntity>{
|
public interface DivisionRepository
|
||||||
|
extends JpaRepository<DivisionEntity, Integer>, JpaSpecificationExecutor<DivisionEntity> {
|
||||||
static Specification<DivisionEntity> idDivisionEqual(Integer idDivision) {
|
|
||||||
return idDivision == null ?
|
|
||||||
null :
|
|
||||||
// 戻り値の型 Specification<DepartmentEntity> にキャスト
|
|
||||||
(Specification<DivisionEntity>)
|
|
||||||
// ラムダ式で記載しているが書いてあることは criteriaBuilder を使って Where句の後の "'idDepartment' = idDepartment(変数)"
|
|
||||||
// を作成している
|
|
||||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.equal(root.get("idDivision"), idDivision);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Specification<DivisionEntity> nmDivisionEqual(String nmDivision) {
|
static Specification<DivisionEntity> idDivisionEqual(Integer idDivision) {
|
||||||
return (nmDivision == null || nmDivision.isEmpty()) ?
|
return idDivision == null ? null :
|
||||||
null :
|
// 戻り値の型 Specification<DepartmentEntity> にキャスト
|
||||||
(Specification<DivisionEntity>)
|
(Specification<DivisionEntity>)
|
||||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.like(root.get("nmDivision"), nmDivision);
|
// ラムダ式で記載しているが書いてあることは criteriaBuilder を使って Where句の後の "'idDepartment' = idDepartment(変数)"
|
||||||
}
|
// を作成している
|
||||||
static Specification<DivisionEntity> idDepartmentEqual(Integer idDepartment) {
|
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.equal(root.get("idDivision"), idDivision);
|
||||||
return idDepartment == null ?
|
}
|
||||||
null :
|
|
||||||
// 戻り値の型 Specification<DepartmentEntity> にキャスト
|
static Specification<DivisionEntity> nmDivisionEqual(String nmDivision) {
|
||||||
(Specification<DivisionEntity>)
|
return (nmDivision == null || nmDivision.isEmpty()) ? null
|
||||||
// ラムダ式で記載しているが書いてあることは criteriaBuilder を使って Where句の後の "'idDepartment' = idDepartment(変数)"
|
: (Specification<DivisionEntity>) (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder
|
||||||
// を作成している
|
.like(root.get("nmDivision"), nmDivision);
|
||||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.equal(root.get("idDepartment"), idDepartment);
|
}
|
||||||
}
|
|
||||||
|
static Specification<DivisionEntity> idDepartmentEqual(Integer idDepartment) {
|
||||||
|
return idDepartment == null ? null :
|
||||||
|
// 戻り値の型 Specification<DepartmentEntity> にキャスト
|
||||||
|
(Specification<DivisionEntity>)
|
||||||
|
// ラムダ式で記載しているが書いてあることは 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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,59 +27,48 @@ import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
|||||||
* 戻り値はクエリを格納しているPredicateオブジェクトとなります。
|
* 戻り値はクエリを格納しているPredicateオブジェクトとなります。
|
||||||
*/
|
*/
|
||||||
@Repository
|
@Repository
|
||||||
public interface EmployeeInfoRepository extends JpaRepository<EmployeeEntity, Integer>, JpaSpecificationExecutor<EmployeeEntity> {
|
public interface EmployeeInfoRepository
|
||||||
|
extends JpaRepository<EmployeeEntity, Integer>, JpaSpecificationExecutor<EmployeeEntity> {
|
||||||
|
|
||||||
static Specification<EmployeeEntity> idEmployeeEqual(Integer idEmployee) {
|
static Specification<EmployeeEntity> idEmployeeEqual(Integer idEmployee) {
|
||||||
return idEmployee == null ?
|
return idEmployee == null ? null :
|
||||||
null :
|
// 戻り値の型 Specification<EmployeeDepartmentEntity> にキャスト
|
||||||
// 戻り値の型 Specification<EmployeeDepartmentEntity> にキャスト
|
(Specification<EmployeeEntity>)
|
||||||
(Specification<EmployeeEntity>)
|
// ラムダ式で記載しているが書いてあることは criteriaBuilder を使って Where句の後の "'idEmployee' = idEmployee(変数)"
|
||||||
// ラムダ式で記載しているが書いてあることは criteriaBuilder を使って Where句の後の "'idEmployee' = idEmployee(変数)"
|
// を作成している
|
||||||
// を作成している
|
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.equal(root.get("idEmployee"), idEmployee);
|
||||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.equal(root.get("idEmployee"), idEmployee);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static Specification<EmployeeEntity> nmEmployeeEqual(String nmEmployee) {
|
static Specification<EmployeeEntity> nmEmployeeEqual(String nmEmployee) {
|
||||||
return (nmEmployee == null || nmEmployee.isEmpty()) ?
|
return (nmEmployee == null || nmEmployee.isEmpty()) ? null
|
||||||
null :
|
: (Specification<EmployeeEntity>) (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder
|
||||||
(Specification<EmployeeEntity>)
|
.like(root.get("nmEmployee"), "%" + nmEmployee + "%");
|
||||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.like(root.get("nmEmployee"), "%" + nmEmployee + "%");
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static Specification<EmployeeEntity> knEmployeeEqual(String knEmployee) {
|
static Specification<EmployeeEntity> knEmployeeEqual(String knEmployee) {
|
||||||
return (knEmployee == null || knEmployee.isEmpty()) ?
|
return (knEmployee == null || knEmployee.isEmpty()) ? null
|
||||||
null :
|
: (Specification<EmployeeEntity>) (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder
|
||||||
(Specification<EmployeeEntity>)
|
.like(root.get("knEmployee"), "%" + knEmployee + "%");
|
||||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.like(root.get("knEmployee"), "%" + knEmployee + "%");
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static Specification<EmployeeEntity> mailAddressEqual(String mailAddress) {
|
static Specification<EmployeeEntity> mailAddressEqual(String mailAddress) {
|
||||||
return (mailAddress == null || mailAddress.isEmpty()) ?
|
return (mailAddress == null || mailAddress.isEmpty()) ? null
|
||||||
null :
|
: (Specification<EmployeeEntity>) (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder
|
||||||
(Specification<EmployeeEntity>)
|
.like(root.get("mailAddress"), "%" + mailAddress + "%");
|
||||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.like(root.get("mailAddress"), "%" + mailAddress + "%");
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static Specification<EmployeeEntity> idDivisionEqual(Integer idDivision) {
|
static Specification<EmployeeEntity> idDivisionEqual(Integer idDivision) {
|
||||||
return (root, query, criteriaBuilder) ->
|
return (root, query, criteriaBuilder) -> idDivision == null ? null
|
||||||
idDivision == null ? null :
|
: criteriaBuilder.equal(root.join("division").get("idDivision"), idDivision);
|
||||||
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 "
|
@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 e.division di "
|
||||||
+ "INNER JOIN di.department de "
|
+ "INNER JOIN di.department de "
|
||||||
+ "INNER JOIN de.headquarters h ")
|
+ "INNER JOIN de.headquarters h ")
|
||||||
List<EmployeeDepartmentEntity> findAlltable();
|
List<EmployeeDepartmentEntity> findAlltable();
|
||||||
|
|
||||||
// @Query("SELECT DISTINCT new com.example.rhizome.app.infra.entity.EmployeeDepartmentEntity(e,di,de,h)FROM EmployeeEntity e "
|
//全てのテーブルを結合してから検索
|
||||||
// + "INNER JOIN e.division di "
|
@EntityGraph(attributePaths = { "division", "division.department", "division.department.headquarters" })
|
||||||
// + "INNER JOIN di.department de "
|
List<EmployeeEntity> findAll(@Nullable Specification<EmployeeEntity> spec);
|
||||||
// + "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<EmployeeEntity> findAll(@Nullable Specification<EmployeeEntity> spec);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,22 +11,22 @@ import com.example.rhizome.app.infra.entity.InsertEmployeeEntity;
|
|||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface EmployeeRepository extends JpaRepository<EmployeeEntity, Integer> {
|
public interface EmployeeRepository extends JpaRepository<EmployeeEntity, Integer> {
|
||||||
Optional<EmployeeEntity> findByMailAddressAndPassword(String mailAddress, String password);
|
Optional<EmployeeEntity> findByMailAddressAndPassword(String mailAddress, String password);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* メールアドレスで検索
|
* メールアドレスで検索
|
||||||
**/
|
**/
|
||||||
Optional<EmployeeEntity> findByMailAddress(String mail);
|
Optional<EmployeeEntity> findByMailAddress(String mail);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IDで検索
|
* IDで検索
|
||||||
**/
|
**/
|
||||||
Optional<EmployeeEntity> findByIdEmployee(Integer idEmployee);
|
Optional<EmployeeEntity> findByIdEmployee(Integer idEmployee);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* IDで検索
|
||||||
|
**/
|
||||||
|
List<EmployeeEntity> findByDivision_idDivision(Integer idDivision);
|
||||||
|
|
||||||
/**
|
|
||||||
* IDで検索
|
|
||||||
**/
|
|
||||||
List<EmployeeEntity> findByDivision_idDivision(Integer idDivision);
|
|
||||||
|
|
||||||
void save(InsertEmployeeEntity insertEmployeeEntity);
|
void save(InsertEmployeeEntity insertEmployeeEntity);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,24 +8,23 @@ import org.springframework.stereotype.Repository;
|
|||||||
import com.example.rhizome.app.infra.entity.HeadquartersEntity;
|
import com.example.rhizome.app.infra.entity.HeadquartersEntity;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface HeadquartersRepository extends JpaRepository<HeadquartersEntity, Integer>, JpaSpecificationExecutor<HeadquartersEntity>{
|
public interface HeadquartersRepository
|
||||||
|
extends JpaRepository<HeadquartersEntity, Integer>, JpaSpecificationExecutor<HeadquartersEntity> {
|
||||||
static Specification<HeadquartersEntity> idHeadquartersEqual(Integer idHeadquarters) {
|
static Specification<HeadquartersEntity> idHeadquartersEqual(Integer idHeadquarters) {
|
||||||
return idHeadquarters == null ?
|
return idHeadquarters == null ? null :
|
||||||
null :
|
// 戻り値の型 Specification<DepartmentEntity> にキャスト
|
||||||
// 戻り値の型 Specification<DepartmentEntity> にキャスト
|
(Specification<HeadquartersEntity>)
|
||||||
(Specification<HeadquartersEntity>)
|
// ラムダ式で記載しているが書いてあることは criteriaBuilder を使って Where句の後の "'idDepartment' = idDepartment(変数)"
|
||||||
// ラムダ式で記載しているが書いてあることは criteriaBuilder を使って Where句の後の "'idDepartment' = idDepartment(変数)"
|
// を作成している
|
||||||
// を作成している
|
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.equal(root.get("idHeadquarters"),
|
||||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.equal(root.get("idHeadquarters"), idHeadquarters);
|
idHeadquarters);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Specification<HeadquartersEntity> nmHeadquartersEqual(String nmHeadquarters) {
|
static Specification<HeadquartersEntity> nmHeadquartersEqual(String nmHeadquarters) {
|
||||||
return (nmHeadquarters == null || nmHeadquarters.isEmpty()) ?
|
return (nmHeadquarters == null || nmHeadquarters.isEmpty()) ? null
|
||||||
null :
|
: (Specification<HeadquartersEntity>) (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder
|
||||||
(Specification<HeadquartersEntity>)
|
.like(root.get("nmHeadquarters"), nmHeadquarters);
|
||||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.like(root.get("nmHeadquarters"), nmHeadquarters);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
HeadquartersEntity findByNmHeadquarters(String nmHeadquarters);
|
||||||
HeadquartersEntity findByNmHeadquarters(String nmHeadquarters);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,18 +6,18 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
|||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import com.example.rhizome.app.infra.entity.RegisterDepartmentEntity;
|
import com.example.rhizome.app.infra.entity.RegisterDepartmentEntity;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface RegisterDepartmentRepository extends JpaRepository<RegisterDepartmentEntity, Integer>, JpaSpecificationExecutor<RegisterDepartmentEntity> {
|
public interface RegisterDepartmentRepository
|
||||||
static Specification<RegisterDepartmentEntity> idHeadquartersEqual(Integer idHeadquarters) {
|
extends JpaRepository<RegisterDepartmentEntity, Integer>, JpaSpecificationExecutor<RegisterDepartmentEntity> {
|
||||||
|
static Specification<RegisterDepartmentEntity> idHeadquartersEqual(Integer idHeadquarters) {
|
||||||
System.out.println("RegisterDepartmentRepository=>5");
|
|
||||||
|
return idHeadquarters == null ? null :
|
||||||
return idHeadquarters == null ?
|
//戻り値の型 Specification<DepartmentEntity> にキャスト
|
||||||
null :
|
(Specification<RegisterDepartmentEntity>)
|
||||||
//戻り値の型 Specification<DepartmentEntity> にキャスト
|
|
||||||
(Specification<RegisterDepartmentEntity>)
|
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.equal(root.get("idHeadquarters"),
|
||||||
|
idHeadquarters);
|
||||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.equal(root.get("idHeadquarters"), idHeadquarters);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.example.rhizome.app.presentation.controller;
|
package com.example.rhizome.app.presentation.controller;
|
||||||
|
|
||||||
|
|
||||||
import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.*;
|
import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.*;
|
||||||
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@@ -31,98 +30,95 @@ import com.example.rhizome.app.presentation.form.MessageForm;
|
|||||||
@Controller
|
@Controller
|
||||||
public class DeleteDepartmentController {
|
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;
|
HttpSession httpSession;
|
||||||
DeleteDepartment deleteDepartment;
|
DeleteDepartment deleteDepartment;
|
||||||
SearchDepartment searchDepartment;
|
SearchDepartment searchDepartment;
|
||||||
SearchEmployee searchEmployee;
|
SearchEmployee searchEmployee;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public DeleteDepartmentController(
|
public DeleteDepartmentController(
|
||||||
DeleteDepartment deleteDepartment,
|
DeleteDepartment deleteDepartment,
|
||||||
SearchDepartment searchDepartment,
|
SearchDepartment searchDepartment,
|
||||||
SearchEmployee searchEmployee,
|
SearchEmployee searchEmployee,
|
||||||
HttpSession httpSession
|
HttpSession httpSession) {
|
||||||
) {
|
this.httpSession = httpSession;
|
||||||
this.httpSession = httpSession;
|
this.deleteDepartment = deleteDepartment;
|
||||||
this.deleteDepartment = deleteDepartment;
|
this.searchDepartment = searchDepartment;
|
||||||
this.searchDepartment = searchDepartment;
|
this.searchEmployee = searchEmployee;
|
||||||
this.searchEmployee = searchEmployee;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 削除処理のコントローラ
|
* 削除処理のコントローラ
|
||||||
*
|
*
|
||||||
* @param idDepartment 削除対象のidDepartment
|
* @param idDivision 削除対象のidDivision
|
||||||
* @param model ビューにデータを渡すためのコンテナ
|
* @param model ビューにデータを渡すためのコンテナ
|
||||||
* @return 遷移先の画面
|
* @return 遷移先の画面
|
||||||
*/
|
*/
|
||||||
@PermissionCheck
|
@PermissionCheck
|
||||||
@SessionCheck
|
@SessionCheck
|
||||||
@RequestMapping(value = DELETE_DEPARTMENT, method = RequestMethod.POST)
|
@RequestMapping(value = DELETE_DEPARTMENT, method = RequestMethod.POST)
|
||||||
public String deleteEmployee(@RequestParam("idDivision") Integer idDivision, Model model) {
|
public String deleteEmployee(@RequestParam("idDivision") Integer idDivision, Model model) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// 削除処理実施
|
// 削除処理実施
|
||||||
deleteExec(model, idDivision);
|
deleteExec(model, idDivision);
|
||||||
|
|
||||||
// 部署一覧を取得し、画面に返す用のクラスに詰め替える
|
// 部署一覧を取得し、画面に返す用のクラスに詰め替える
|
||||||
// 作成した部署一覧をセット
|
// 作成した部署一覧をセット
|
||||||
model.addAttribute(
|
model.addAttribute(
|
||||||
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||||
DepartmentForm.convertFrom(
|
DepartmentForm.convertFrom(
|
||||||
searchDepartment.searchAllDepartmentTable()
|
searchDepartment.searchAllDepartmentTable()));
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
// 検索画面に遷移
|
// 検索画面に遷移
|
||||||
return "forward:" + TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_ALL;
|
return "forward:" + TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_ALL;
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// ログイン情報の破棄
|
// ログイン情報の破棄
|
||||||
httpSession.invalidate();
|
httpSession.invalidate();
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
// エラーログ出力
|
// エラーログ出力
|
||||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||||
// エラー画面遷移
|
// エラー画面遷移
|
||||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 削除処理実施
|
* 削除処理実施
|
||||||
*
|
*
|
||||||
* @param model ビューにデータを渡すためのコンテナ
|
* @param model ビューにデータを渡すためのコンテナ
|
||||||
* @param idDepartment 削除対象のidDepartment
|
* @param idDepartment 削除対象のidDepartment
|
||||||
*/
|
*/
|
||||||
private void deleteExec(Model model, Integer idDivision) {
|
private void deleteExec(Model model, Integer idDivision) {
|
||||||
|
|
||||||
final String DELETE_TARGET_ID_CAN_NOT_DELETE = "1名以上が所属している部署は削除出来ません。";
|
final String DELETE_TARGET_ID_CAN_NOT_DELETE = "1名以上が所属している部署は削除出来ません。";
|
||||||
final String DELETE_COMPLETE = "削除しました。";
|
final String DELETE_COMPLETE = "削除しました。";
|
||||||
|
|
||||||
// 1名上所属している人が居れば削除不可
|
// 1名上所属している人が居れば削除不可
|
||||||
if (!searchEmployee.searchEmployeeByIdDepartment(idDivision).isEmpty()) {
|
if (!searchEmployee.searchEmployeeByIdDepartment(idDivision).isEmpty()) {
|
||||||
// 削除対象だった場合
|
// 削除対象だった場合
|
||||||
// エラーメッセージをセット
|
// エラーメッセージをセット
|
||||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DELETE_TARGET_ID_CAN_NOT_DELETE));
|
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR,
|
||||||
// 検索画面に遷移
|
new MessageForm(DELETE_TARGET_ID_CAN_NOT_DELETE));
|
||||||
return;
|
// 検索画面に遷移
|
||||||
}
|
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));
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,7 +76,8 @@ public class DeleteEmployeeController {
|
|||||||
deleteExec(
|
deleteExec(
|
||||||
model,
|
model,
|
||||||
idEmployee,
|
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;
|
return "forward:" + TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_INFO_FORM_EMPTY;
|
||||||
|
|||||||
@@ -1,50 +1,51 @@
|
|||||||
package com.example.rhizome.app.presentation.controller;
|
package com.example.rhizome.app.presentation.controller;
|
||||||
|
|
||||||
import com.example.rhizome.app.domain.service.impl.LoginImpl;
|
import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.*;
|
||||||
import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
|
|
||||||
import com.example.rhizome.app.presentation.form.LoginUserForm;
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
import javax.servlet.http.HttpSession;
|
import com.example.rhizome.app.domain.service.impl.LoginImpl;
|
||||||
|
import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
|
||||||
import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.*;
|
import com.example.rhizome.app.presentation.form.LoginUserForm;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class IndexController {
|
public class IndexController {
|
||||||
|
|
||||||
HttpSession httpSession;
|
HttpSession httpSession;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public IndexController(HttpSession httpSession, LoginImpl loginImpl) {
|
public IndexController(HttpSession httpSession, LoginImpl loginImpl) {
|
||||||
this.httpSession = httpSession;
|
this.httpSession = httpSession;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ModelAttribute
|
@ModelAttribute
|
||||||
public LoginUserForm loginUserForm() {
|
public LoginUserForm loginUserForm() {
|
||||||
return new LoginUserForm();
|
return new LoginUserForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ログイン画面表示処理
|
* ログイン画面表示処理
|
||||||
*
|
*
|
||||||
* @param model ビューにデータを渡すためのコンテナ
|
* @param model ビューにデータを渡すためのコンテナ
|
||||||
* @return 遷移先の画面
|
* @return 遷移先の画面
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = {INDEX_BLANK, INDEX_SLASH, INDEX_LOGIN})
|
@RequestMapping(value = { INDEX_BLANK, INDEX_SLASH, INDEX_LOGIN })
|
||||||
public String index(Model model) {
|
public String index(Model model) {
|
||||||
// セッション情報を破棄
|
// セッション情報を破棄
|
||||||
if (httpSession != null) {
|
if (httpSession != null) {
|
||||||
httpSession.invalidate();
|
httpSession.invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 空のFormをSessionに用意
|
// 空のFormをSessionに用意
|
||||||
model.addAttribute(PageReturnAttributeKeyword.LOGIN_INFO_FORM, loginUserForm());
|
model.addAttribute(PageReturnAttributeKeyword.LOGIN_INFO_FORM, loginUserForm());
|
||||||
|
|
||||||
// ログイン画面に遷移
|
// ログイン画面に遷移
|
||||||
return LOGIN_HTML;
|
return LOGIN_HTML;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,104 +31,98 @@ import com.example.rhizome.app.presentation.form.MessageForm;
|
|||||||
@Controller
|
@Controller
|
||||||
public class InsertDepartmentConfirmController {
|
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;
|
HttpSession httpSession;
|
||||||
SearchDepartment searchDepartment;
|
SearchDepartment searchDepartment;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public InsertDepartmentConfirmController(
|
public InsertDepartmentConfirmController(
|
||||||
HttpSession httpSession,
|
HttpSession httpSession,
|
||||||
SearchDepartmentImpl searchDepartment
|
SearchDepartmentImpl searchDepartment) {
|
||||||
) {
|
this.httpSession = httpSession;
|
||||||
this.httpSession = httpSession;
|
this.searchDepartment = searchDepartment;
|
||||||
this.searchDepartment = searchDepartment;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@ModelAttribute
|
@ModelAttribute
|
||||||
public InsertDepartmentForm insertDepartmentForm() {
|
public InsertDepartmentForm insertDepartmentForm() {
|
||||||
return new InsertDepartmentForm();
|
return new InsertDepartmentForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登録情報のチェックを行う
|
* 登録情報のチェックを行う
|
||||||
*
|
*
|
||||||
* @param insertDepartmentForm 登録情報
|
* @param insertDepartmentForm 登録情報
|
||||||
* @param model ビューにデータを渡すためのコンテナ
|
* @param model ビューにデータを渡すためのコンテナ
|
||||||
* @return 遷移先の画面
|
* @return 遷移先の画面
|
||||||
*/
|
*/
|
||||||
@PermissionCheck
|
@PermissionCheck
|
||||||
@SessionCheck
|
@SessionCheck
|
||||||
@RequestMapping(value = INSERT_DEPARTMENT_CONFIRM, method = RequestMethod.POST)
|
@RequestMapping(value = INSERT_DEPARTMENT_CONFIRM, method = RequestMethod.POST)
|
||||||
public String insertDepartmentConfirm(InsertDepartmentForm insertDepartmentForm, Model model) {
|
public String insertDepartmentConfirm(InsertDepartmentForm insertDepartmentForm, Model model) {
|
||||||
|
|
||||||
final String DUPLICATION = "既に同名の本部名または部または課が存在します。";
|
final String DUPLICATION = "既に同名の本部名または部または課が存在します。";
|
||||||
final String IRREGULARITY = "本部名または部または課が不正です。";
|
final String IRREGULARITY = "本部名または部または課が不正です。";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
model.addAttribute(
|
model.addAttribute(
|
||||||
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||||
DepartmentForm.convertFrom(
|
DepartmentForm.convertFrom(
|
||||||
searchDepartment.searchAllDepartmentTable())
|
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)){
|
|
||||||
|
|
||||||
// 存在する場合はエラーメッセージを設定して更新入力画面に遷移
|
// 入力内容に誤りがあるか
|
||||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DUPLICATION));
|
if (insertDepartmentForm.haveNmDepartment()) {
|
||||||
model.addAttribute(PageReturnAttributeKeyword.INSERT_DEPARTMENT_FORM, insertDepartmentForm);
|
// 誤りがあった場合
|
||||||
|
// 誤りがあった箇所のエラーメッセージを表示
|
||||||
|
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);
|
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DUPLICATION));
|
||||||
// 登録確認画面に遷移
|
model.addAttribute(PageReturnAttributeKeyword.INSERT_DEPARTMENT_FORM, insertDepartmentForm);
|
||||||
return TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_CONFIRM_HTML;
|
|
||||||
|
|
||||||
|
return TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_INPUT_HTML;
|
||||||
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
// 登録確認ページに遷移
|
||||||
// ログイン情報の破棄
|
model.addAttribute(PageReturnAttributeKeyword.INSERT_DEPARTMENT_FORM, insertDepartmentForm);
|
||||||
httpSession.invalidate();
|
// 登録確認画面に遷移
|
||||||
|
return TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_CONFIRM_HTML;
|
||||||
|
|
||||||
e.printStackTrace();
|
} catch (Exception e) {
|
||||||
|
// ログイン情報の破棄
|
||||||
|
httpSession.invalidate();
|
||||||
|
|
||||||
// エラーログ出力
|
e.printStackTrace();
|
||||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
|
||||||
// エラー画面遷移
|
// エラーログ出力
|
||||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||||
}
|
// エラー画面遷移
|
||||||
}
|
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -34,110 +34,104 @@ import com.example.rhizome.app.presentation.form.MessageForm;
|
|||||||
@Controller
|
@Controller
|
||||||
public class InsertDepartmentController {
|
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;
|
HttpSession httpSession;
|
||||||
RegisterDepartment registerDepartment;
|
RegisterDepartment registerDepartment;
|
||||||
SearchDepartment searchDepartment;
|
SearchDepartment searchDepartment;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public InsertDepartmentController(HttpSession httpSession, RegisterDepartment registerDepartment, SearchDepartment searchDepartment, SearchDepartmentImpl searchDepartmentImpl) {
|
public InsertDepartmentController(HttpSession httpSession, RegisterDepartment registerDepartment,
|
||||||
this.httpSession = httpSession;
|
SearchDepartment searchDepartment, SearchDepartmentImpl searchDepartmentImpl) {
|
||||||
this.registerDepartment = registerDepartment;
|
this.httpSession = httpSession;
|
||||||
this.searchDepartment = searchDepartment;
|
this.registerDepartment = registerDepartment;
|
||||||
|
this.searchDepartment = searchDepartment;
|
||||||
this.searchDepartmentImpl = searchDepartmentImpl;
|
this.searchDepartmentImpl = searchDepartmentImpl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ModelAttribute
|
@ModelAttribute
|
||||||
public InsertDepartmentForm insertDepartmentForm() {
|
public InsertDepartmentForm insertDepartmentForm() {
|
||||||
return new InsertDepartmentForm();
|
return new InsertDepartmentForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新規登録画面表示処理
|
* 新規登録画面表示処理
|
||||||
*
|
*
|
||||||
* @param insertDepartmentForm 登録情報
|
* @param insertDepartmentForm 登録情報
|
||||||
* @param model ビューにデータを渡すためのコンテナ
|
* @param model ビューにデータを渡すためのコンテナ
|
||||||
* @return 遷移先の画面
|
* @return 遷移先の画面
|
||||||
*/
|
*/
|
||||||
@PermissionCheck
|
@PermissionCheck
|
||||||
@SessionCheck
|
@SessionCheck
|
||||||
@RequestMapping(value = INSERT_DEPARTMENT, method = RequestMethod.POST)
|
@RequestMapping(value = INSERT_DEPARTMENT, method = RequestMethod.POST)
|
||||||
public String insertDepartment(InsertDepartmentForm insertDepartmentForm, Model model) {
|
public String insertDepartment(InsertDepartmentForm insertDepartmentForm, Model model) {
|
||||||
|
|
||||||
final String DUPLICATION = "既に同名の部署が存在します。";
|
final String DUPLICATION = "既に同名の部署が存在します。";
|
||||||
final String IRREGULARITY = "部署名が不正です。";
|
final String IRREGULARITY = "部署名が不正です。";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 部署一覧を取得し、画面に返す用のクラスに詰め替える
|
// 部署一覧を取得し、画面に返す用のクラスに詰め替える
|
||||||
// 作成した部署一覧をセット
|
// 作成した部署一覧をセット
|
||||||
model.addAttribute(
|
model.addAttribute(
|
||||||
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||||
DepartmentForm.convertFrom(
|
DepartmentForm.convertFrom(
|
||||||
searchDepartment.searchAllDepartmentTable()
|
searchDepartment.searchAllDepartmentTable()));
|
||||||
));
|
|
||||||
|
|
||||||
// 入力内容に誤りがあるか
|
// 入力内容に誤りがあるか
|
||||||
if (insertDepartmentForm.haveNmDepartment()) {
|
if (insertDepartmentForm.haveNmDepartment()) {
|
||||||
// 誤りがあった場合
|
// 誤りがあった場合
|
||||||
// 誤りがあった箇所のエラーメッセージを表示
|
// 誤りがあった箇所のエラーメッセージを表示
|
||||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(IRREGULARITY));
|
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(IRREGULARITY));
|
||||||
// 画面に返す為の登録情報をセット
|
// 画面に返す為の登録情報をセット
|
||||||
model.addAttribute(PageReturnAttributeKeyword.INSERT_DEPARTMENT_FORM, insertDepartmentForm);
|
model.addAttribute(PageReturnAttributeKeyword.INSERT_DEPARTMENT_FORM, insertDepartmentForm);
|
||||||
// 登録画面に遷移
|
// 登録画面に遷移
|
||||||
return INSERT_DEPARTMENT_INPUT_HTML;
|
return INSERT_DEPARTMENT_INPUT_HTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 部署名で重複が無いかチェック
|
// 部署の組み合わせで重複が無いかチェック
|
||||||
if (searchDepartment.searchAllDepartmentTable(
|
if (searchDepartment.searchAllDepartmentTable(
|
||||||
new SearchConditionDepartment(
|
new SearchConditionDepartment(
|
||||||
insertDepartmentForm.getIdHeadquarters(),
|
insertDepartmentForm.getIdHeadquarters(),
|
||||||
insertDepartmentForm.getNmHeadquarters()),
|
insertDepartmentForm.getNmHeadquarters()),
|
||||||
new SearchConditionDepartment(
|
new SearchConditionDepartment(
|
||||||
insertDepartmentForm.getIdDepartment(),
|
insertDepartmentForm.getIdDepartment(),
|
||||||
insertDepartmentForm.getNmDepartment()),
|
insertDepartmentForm.getNmDepartment()),
|
||||||
new SearchConditionDepartment(
|
new SearchConditionDepartment(
|
||||||
insertDepartmentForm.getIdDivision(),
|
insertDepartmentForm.getIdDivision(),
|
||||||
insertDepartmentForm.getNmDivision()))) {
|
insertDepartmentForm.getNmDivision()))) {
|
||||||
|
|
||||||
|
// 存在する場合はエラーメッセージを設定して更新入力画面に遷移
|
||||||
|
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DUPLICATION));
|
||||||
|
model.addAttribute(PageReturnAttributeKeyword.INSERT_DEPARTMENT_FORM, insertDepartmentForm);
|
||||||
|
|
||||||
// 存在する場合はエラーメッセージを設定して更新入力画面に遷移
|
return TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_INPUT_HTML;
|
||||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DUPLICATION));
|
}
|
||||||
model.addAttribute(PageReturnAttributeKeyword.INSERT_DEPARTMENT_FORM, insertDepartmentForm);
|
//divisionEntityにinsertDepartmentFormで画面から渡ってきた値を入れる
|
||||||
|
DepartmentInfo departmentInfo = InsertDepartmentForm.convertTo(insertDepartmentForm);
|
||||||
|
DivisionEntity divisionEntity = DivisionEntity.convertFrom(departmentInfo);
|
||||||
|
|
||||||
return TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_INPUT_HTML;
|
// 登録処理
|
||||||
}
|
registerDepartment.registerDepartment(divisionEntity);
|
||||||
DepartmentInfo departmentInfo = InsertDepartmentForm.convertTo(insertDepartmentForm);
|
|
||||||
|
|
||||||
DivisionEntity divisionEntity = DivisionEntity.convertFrom(departmentInfo);
|
|
||||||
|
|
||||||
System.out.println(divisionEntity);
|
|
||||||
// 登録処理
|
|
||||||
registerDepartment.registerDepartment(divisionEntity);
|
|
||||||
|
|
||||||
// 登録結果画面に遷移
|
|
||||||
return TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_RESULT_HTML;
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
// 登録結果画面に遷移
|
||||||
// ログイン情報の破棄
|
return TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_RESULT_HTML;
|
||||||
httpSession.invalidate();
|
|
||||||
|
|
||||||
e.printStackTrace();
|
} catch (Exception e) {
|
||||||
|
// ログイン情報の破棄
|
||||||
|
httpSession.invalidate();
|
||||||
|
|
||||||
// エラーログ出力
|
e.printStackTrace();
|
||||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
|
||||||
// エラー画面遷移
|
// エラーログ出力
|
||||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||||
}
|
// エラー画面遷移
|
||||||
}
|
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,9 @@ import com.example.rhizome.aop.aspect.SessionCheck;
|
|||||||
import com.example.rhizome.app.domain.service.SearchDepartment;
|
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.PageReturnAttributeKeyword;
|
||||||
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
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;
|
import com.example.rhizome.app.presentation.form.InsertDepartmentForm;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -26,67 +28,70 @@ import com.example.rhizome.app.presentation.form.InsertDepartmentForm;
|
|||||||
@Controller
|
@Controller
|
||||||
public class InsertDepartmentInputController {
|
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;
|
HttpSession httpSession;
|
||||||
SearchDepartment searchDepartment;
|
SearchDepartment searchDepartment;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public InsertDepartmentInputController(
|
public InsertDepartmentInputController(
|
||||||
HttpSession httpSession,
|
HttpSession httpSession,
|
||||||
SearchDepartment searchDepartment
|
SearchDepartment searchDepartment) {
|
||||||
) {
|
this.httpSession = httpSession;
|
||||||
this.httpSession = httpSession;
|
this.searchDepartment = searchDepartment;
|
||||||
this.searchDepartment = searchDepartment;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@ModelAttribute
|
@ModelAttribute
|
||||||
public InsertDepartmentForm insertDepartmentForm() {
|
public InsertDepartmentForm insertDepartmentForm() {
|
||||||
return new 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) {
|
||||||
|
|
||||||
/**
|
try {
|
||||||
* 部署登録画面表示処理
|
//各部署情報を重複魚消して表示するために別々に画面へ送る
|
||||||
*
|
model.addAttribute(
|
||||||
* @param insertDepartmentForm 登録画面のフォーム
|
PageReturnAttributeKeyword.HEADQUARTERS_FORM_LIST,
|
||||||
* @param model ビューにデータを渡すためのコンテナ
|
HeadquartersInfoForm.convertFrom(
|
||||||
* @return 遷移先の画面
|
searchDepartment.searchAllDepartmentTable()));
|
||||||
*/
|
model.addAttribute(
|
||||||
@SessionCheck
|
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||||
@PermissionCheck
|
DepartmentInfoForm.convertFromTo(
|
||||||
@RequestMapping(value = TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_INPUT, method = RequestMethod.POST)
|
searchDepartment.searchAllDepartmentTable()));
|
||||||
public String insertInput(InsertDepartmentForm insertDepartmentForm, Model model) {
|
model.addAttribute(
|
||||||
|
PageReturnAttributeKeyword.DIVISION_FORM_LIST,
|
||||||
|
DivisionInfoForm.convertFromTo(
|
||||||
|
searchDepartment.searchAllDepartmentTable()));
|
||||||
|
// パラメータをセット
|
||||||
|
model.addAttribute(PageReturnAttributeKeyword.INSERT_DEPARTMENT_FORM, insertDepartmentForm);
|
||||||
|
|
||||||
try {
|
// 登録画面に遷移
|
||||||
model.addAttribute(
|
return TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_INPUT_HTML;
|
||||||
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
|
||||||
DepartmentForm.convertFrom(
|
|
||||||
searchDepartment.searchAllDepartmentTable())
|
|
||||||
);
|
|
||||||
// パラメータをセット
|
|
||||||
model.addAttribute(PageReturnAttributeKeyword.INSERT_DEPARTMENT_FORM, insertDepartmentForm);
|
|
||||||
|
|
||||||
// 登録画面に遷移
|
} catch (Exception e) {
|
||||||
return TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_INPUT_HTML;
|
// ログイン情報の破棄
|
||||||
|
httpSession.invalidate();
|
||||||
|
|
||||||
} catch (Exception e) {
|
e.printStackTrace();
|
||||||
// ログイン情報の破棄
|
|
||||||
httpSession.invalidate();
|
|
||||||
|
|
||||||
e.printStackTrace();
|
// エラーログ出力
|
||||||
|
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||||
// エラーログ出力
|
// エラー画面遷移
|
||||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||||
// エラー画面遷移
|
}
|
||||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -34,113 +34,97 @@ import com.example.rhizome.app.presentation.form.MessageForm;
|
|||||||
@Controller
|
@Controller
|
||||||
public class InsertEmployeeConfirmController {
|
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;
|
HttpSession httpSession;
|
||||||
SearchDepartment searchDepartment;
|
SearchDepartment searchDepartment;
|
||||||
SearchEmployee searchEmployee;
|
SearchEmployee searchEmployee;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public InsertEmployeeConfirmController(
|
public InsertEmployeeConfirmController(
|
||||||
HttpSession httpSession,
|
HttpSession httpSession,
|
||||||
SearchDepartmentImpl searchDepartment,
|
SearchDepartmentImpl searchDepartment,
|
||||||
SearchEmployeeImpl searchEmployee
|
SearchEmployeeImpl searchEmployee) {
|
||||||
) {
|
this.httpSession = httpSession;
|
||||||
this.httpSession = httpSession;
|
this.searchDepartment = searchDepartment;
|
||||||
this.searchDepartment = searchDepartment;
|
this.searchEmployee = searchEmployee;
|
||||||
this.searchEmployee = searchEmployee;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@ModelAttribute
|
@ModelAttribute
|
||||||
public InsertEmployeeForm insertEmployeeForm() {
|
public InsertEmployeeForm insertEmployeeForm() {
|
||||||
return new InsertEmployeeForm();
|
return new InsertEmployeeForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登録情報のチェックを行う
|
* 登録情報のチェックを行う
|
||||||
*
|
*
|
||||||
* @param insertEmployeeForm 登録情報
|
* @param insertEmployeeForm 登録情報
|
||||||
* @param model ビューにデータを渡すためのコンテナ
|
* @param model ビューにデータを渡すためのコンテナ
|
||||||
* @return 遷移先の画面
|
* @return 遷移先の画面
|
||||||
*/
|
*/
|
||||||
@PermissionCheck
|
@PermissionCheck
|
||||||
@SessionCheck
|
@SessionCheck
|
||||||
@RequestMapping(value = INSERT_EMPLOYEE_CONFIRM, method = RequestMethod.POST)
|
@RequestMapping(value = INSERT_EMPLOYEE_CONFIRM, method = RequestMethod.POST)
|
||||||
public String insertEmployeeConfirm(InsertEmployeeForm insertEmployeeForm, Model model) {
|
public String insertEmployeeConfirm(InsertEmployeeForm insertEmployeeForm, Model model) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 部署一覧を取得し、画面に返す用のクラスに詰め替える
|
// 部署一覧を取得し、画面に返す用のクラスに詰め替える
|
||||||
// 作成した部署一覧をセット
|
// 作成した部署一覧をセット
|
||||||
model.addAttribute(
|
model.addAttribute(
|
||||||
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||||
DepartmentForm.convertFrom(
|
DepartmentForm.convertFrom(
|
||||||
searchDepartment.searchAllDepartmentTable()
|
searchDepartment.searchAllDepartmentTable()));
|
||||||
));
|
|
||||||
|
|
||||||
// 登録用パラメータチェック
|
// 登録用パラメータチェック
|
||||||
List<String> error = insertEmployeeForm.validateParameter();
|
List<String> error = insertEmployeeForm.validateParameter();
|
||||||
|
|
||||||
// 入力内容に誤りがあるか
|
// 入力内容に誤りがあるか
|
||||||
if (!error.isEmpty()) {
|
if (!error.isEmpty()) {
|
||||||
// 誤りがあった場合
|
// 誤りがあった場合
|
||||||
// 誤りがあった箇所のエラーメッセージを表示
|
// 誤りがあった箇所のエラーメッセージを表示
|
||||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(String.join(", ", error) + "が不正です。"));
|
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR,
|
||||||
// 画面に返す為の登録情報をセット
|
new MessageForm(String.join(", ", error) + "が不正です。"));
|
||||||
model.addAttribute(PageReturnAttributeKeyword.INSERT_EMPLOYEE_FORM, insertEmployeeForm);
|
// 画面に返す為の登録情報をセット
|
||||||
// 登録画面に遷移
|
model.addAttribute(PageReturnAttributeKeyword.INSERT_EMPLOYEE_FORM, insertEmployeeForm);
|
||||||
return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML;
|
// 登録画面に遷移
|
||||||
}
|
return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML;
|
||||||
|
}
|
||||||
|
|
||||||
final String DUPLICATION = "既に登録済みのメールアドレスです。";
|
final String DUPLICATION = "既に登録済みのメールアドレスです。";
|
||||||
|
|
||||||
// 登録対象のメールアドレスを元に検索
|
// 登録対象のメールアドレスを元に検索
|
||||||
List<Employee> employeeList = searchEmployee.searchEmployee(insertEmployeeForm.getMailAddress());
|
List<Employee> employeeList = searchEmployee.searchEmployee(insertEmployeeForm.getMailAddress());
|
||||||
|
|
||||||
// 検索結果があるか
|
// 検索結果があるか
|
||||||
if (!employeeList.isEmpty()) {
|
if (!employeeList.isEmpty()) {
|
||||||
// 検索した結果0件ではない場合
|
// 検索した結果0件ではない場合
|
||||||
// 重複を許さないため、エラー処理
|
// 重複を許さないため、エラー処理
|
||||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DUPLICATION));
|
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DUPLICATION));
|
||||||
// 画面に返す為の登録情報をセット
|
// 画面に返す為の登録情報をセット
|
||||||
model.addAttribute(PageReturnAttributeKeyword.INSERT_EMPLOYEE_FORM, insertEmployeeForm);
|
model.addAttribute(PageReturnAttributeKeyword.INSERT_EMPLOYEE_FORM, insertEmployeeForm);
|
||||||
// 登録画面に遷移
|
// 登録画面に遷移
|
||||||
return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML;
|
return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 登録確認ページに遷移
|
// 登録確認ページに遷移
|
||||||
model.addAttribute(PageReturnAttributeKeyword.INSERT_EMPLOYEE_FORM, insertEmployeeForm);
|
model.addAttribute(PageReturnAttributeKeyword.INSERT_EMPLOYEE_FORM, insertEmployeeForm);
|
||||||
// 登録確認画面に遷移
|
// 登録確認画面に遷移
|
||||||
return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_CONFIRM_HTML;
|
return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_CONFIRM_HTML;
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
// ログイン情報の破棄
|
||||||
|
httpSession.invalidate();
|
||||||
|
|
||||||
} catch (Exception e) {
|
e.printStackTrace();
|
||||||
// ログイン情報の破棄
|
|
||||||
httpSession.invalidate();
|
|
||||||
|
|
||||||
e.printStackTrace();
|
// エラーログ出力
|
||||||
|
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||||
// エラーログ出力
|
// エラー画面遷移
|
||||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||||
// エラー画面遷移
|
}
|
||||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -34,185 +34,171 @@ import com.example.rhizome.app.presentation.form.MessageForm;
|
|||||||
@Controller
|
@Controller
|
||||||
public class InsertEmployeeController {
|
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;
|
HttpSession httpSession;
|
||||||
RegisterEmployee registerEmployee;
|
RegisterEmployee registerEmployee;
|
||||||
SearchDepartment searchDepartment;
|
SearchDepartment searchDepartment;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public InsertEmployeeController(HttpSession httpSession, RegisterEmployeeImpl registerEmployee, SearchDepartmentImpl searchDepartment) {
|
public InsertEmployeeController(HttpSession httpSession, RegisterEmployeeImpl registerEmployee,
|
||||||
this.httpSession = httpSession;
|
SearchDepartmentImpl searchDepartment) {
|
||||||
this.registerEmployee = registerEmployee;
|
this.httpSession = httpSession;
|
||||||
this.searchDepartment = searchDepartment;
|
this.registerEmployee = registerEmployee;
|
||||||
}
|
this.searchDepartment = searchDepartment;
|
||||||
|
}
|
||||||
|
|
||||||
@ModelAttribute
|
@ModelAttribute
|
||||||
public InsertEmployeeForm insertEmployeeForm() {
|
public InsertEmployeeForm insertEmployeeForm() {
|
||||||
return new InsertEmployeeForm();
|
return new InsertEmployeeForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新規登録画面表示処理
|
* 新規登録画面表示処理
|
||||||
*
|
*
|
||||||
* @param insertEmployeeForm 登録情報
|
* @param insertEmployeeForm 登録情報
|
||||||
* @param model ビューにデータを渡すためのコンテナ
|
* @param model ビューにデータを渡すためのコンテナ
|
||||||
* @return 遷移先の画面
|
* @return 遷移先の画面
|
||||||
*/
|
*/
|
||||||
@PermissionCheck
|
@PermissionCheck
|
||||||
@SessionCheck
|
@SessionCheck
|
||||||
@RequestMapping(value = INSERT_EMPLOYEE, method = RequestMethod.POST)
|
@RequestMapping(value = INSERT_EMPLOYEE, method = RequestMethod.POST)
|
||||||
public String insertEmployee(InsertEmployeeForm insertEmployeeForm, Model model) {
|
public String insertEmployee(InsertEmployeeForm insertEmployeeForm, Model model) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 部署一覧を取得し、画面に返す用のクラスに詰め替える
|
// 部署一覧を取得し、画面に返す用のクラスに詰め替える
|
||||||
// 作成した部署一覧をセット
|
// 作成した部署一覧をセット
|
||||||
model.addAttribute(
|
model.addAttribute(
|
||||||
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||||
DepartmentForm.convertFrom(
|
DepartmentForm.convertFrom(
|
||||||
searchDepartment.searchAllDepartmentTable()
|
searchDepartment.searchAllDepartmentTable()));
|
||||||
));
|
|
||||||
|
|
||||||
// Confirm画面から渡ってきた値をチェック
|
// Confirm画面から渡ってきた値をチェック
|
||||||
List<String> error = validateParameter(
|
List<String> error = validateParameter(
|
||||||
insertEmployeeForm.getNmEmployee(),
|
insertEmployeeForm.getNmEmployee(),
|
||||||
insertEmployeeForm.getKnEmployee(),
|
insertEmployeeForm.getKnEmployee(),
|
||||||
insertEmployeeForm.getMailAddress(),
|
insertEmployeeForm.getMailAddress(),
|
||||||
insertEmployeeForm.getPassword(),
|
insertEmployeeForm.getPassword(),
|
||||||
insertEmployeeForm.getHireDate(),
|
insertEmployeeForm.getHireDate(),
|
||||||
insertEmployeeForm.getAdminAuth(),
|
insertEmployeeForm.getAdminAuth(),
|
||||||
insertEmployeeForm.getIdDivision()
|
insertEmployeeForm.getIdDivision());
|
||||||
);
|
|
||||||
|
|
||||||
// エラーが1件以上有る場合
|
// エラーが1件以上有る場合
|
||||||
if (!error.isEmpty()) {
|
if (!error.isEmpty()) {
|
||||||
// エラー内容を画面に表示
|
// エラー内容を画面に表示
|
||||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(String.join(", ", error) + "が不正です。"));
|
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR,
|
||||||
// 登録画面に遷移
|
new MessageForm(String.join(", ", error) + "が不正です。"));
|
||||||
return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML;
|
// 登録画面に遷移
|
||||||
}
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 登録処理
|
// 登録処理
|
||||||
registerEmployee.registerEmployee(InsertEmployeeForm.convertTo(insertEmployeeForm));
|
registerEmployee.registerEmployee(InsertEmployeeForm.convertTo(insertEmployeeForm));
|
||||||
// 登録結果画面に遷移
|
// 登録結果画面に遷移
|
||||||
return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_RESULT_HTML;
|
return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_RESULT_HTML;
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// ログイン情報の破棄
|
// ログイン情報の破棄
|
||||||
httpSession.invalidate();
|
httpSession.invalidate();
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
// エラーログ出力
|
// エラーログ出力
|
||||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||||
// エラー画面遷移
|
// エラー画面遷移
|
||||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param employeeName 登録対象の名前
|
* @param employeeName 登録対象の名前
|
||||||
* @param employeeKana 登録対象のカナ
|
* @param employeeKana 登録対象のカナ
|
||||||
* @param mailAddress 登録対象のメールアドレス
|
* @param mailAddress 登録対象のメールアドレス
|
||||||
* @param password 登録対象のパスワード
|
* @param password 登録対象のパスワード
|
||||||
* @param management システム権限
|
* @param management システム権限
|
||||||
* @param departmentId 部署ID
|
* @param departmentId 部署ID
|
||||||
* @return エラーが有った場合はエラー文言、無ければ空のリストが返る
|
* @return エラーが有った場合はエラー文言、無ければ空のリストが返る
|
||||||
*/
|
*/
|
||||||
private List<String> validateParameter(
|
private List<String> validateParameter(
|
||||||
String employeeName,
|
String employeeName,
|
||||||
String employeeKana,
|
String employeeKana,
|
||||||
String mailAddress,
|
String mailAddress,
|
||||||
String password,
|
String password,
|
||||||
String hireDate,
|
String hireDate,
|
||||||
Integer management,
|
Integer management,
|
||||||
Integer departmentId
|
Integer departmentId) {
|
||||||
) {
|
|
||||||
|
|
||||||
final String EMPLOYEE_NAME_NULL_BLANK = "社員名";
|
final String EMPLOYEE_NAME_NULL_BLANK = "社員名";
|
||||||
final String EMPLOYEE_KANA_NULL_BLANK = "社員名フリガナ";
|
final String EMPLOYEE_KANA_NULL_BLANK = "社員名フリガナ";
|
||||||
final String MAIL_ADDRESS_NULL_BLANK = "メールアドレス";
|
final String MAIL_ADDRESS_NULL_BLANK = "メールアドレス";
|
||||||
final String PASSWORD_NULL_BLANK = "パスワード";
|
final String PASSWORD_NULL_BLANK = "パスワード";
|
||||||
final String HIREDATE_NULL_BLANK = "入社年月日";
|
final String HIREDATE_NULL_BLANK = "入社年月日";
|
||||||
final String MANAGEMENT_ERROR = "管理者権限指定";
|
final String MANAGEMENT_ERROR = "管理者権限指定";
|
||||||
final String DEPARTMENT_ID_NULL_BLANK = "所属部署";
|
final String DEPARTMENT_ID_NULL_BLANK = "所属部署";
|
||||||
|
|
||||||
List<String> error = new ArrayList<>();
|
List<String> error = new ArrayList<>();
|
||||||
|
|
||||||
// null or 空文字判定
|
// null or 空文字判定
|
||||||
if (isNullOrBlank(employeeName)) {
|
if (isNullOrBlank(employeeName)) {
|
||||||
// エラー内容を追加
|
// エラー内容を追加
|
||||||
error.add(EMPLOYEE_NAME_NULL_BLANK);
|
error.add(EMPLOYEE_NAME_NULL_BLANK);
|
||||||
}
|
}
|
||||||
|
|
||||||
// null or 空文字判定
|
// null or 空文字判定
|
||||||
if (isNullOrBlank(employeeKana)) {
|
if (isNullOrBlank(employeeKana)) {
|
||||||
// エラー内容を追加
|
// エラー内容を追加
|
||||||
error.add(EMPLOYEE_KANA_NULL_BLANK);
|
error.add(EMPLOYEE_KANA_NULL_BLANK);
|
||||||
}
|
}
|
||||||
|
|
||||||
// null or 空文字判定
|
// null or 空文字判定
|
||||||
if (isNullOrBlank(mailAddress)) {
|
if (isNullOrBlank(mailAddress)) {
|
||||||
// エラー内容を追加
|
// エラー内容を追加
|
||||||
error.add(MAIL_ADDRESS_NULL_BLANK);
|
error.add(MAIL_ADDRESS_NULL_BLANK);
|
||||||
}
|
}
|
||||||
|
|
||||||
// null or 空文字判定
|
// null or 空文字判定
|
||||||
if (isNullOrBlank(password)) {
|
if (isNullOrBlank(password)) {
|
||||||
// エラー内容を追加
|
// エラー内容を追加
|
||||||
error.add(PASSWORD_NULL_BLANK);
|
error.add(PASSWORD_NULL_BLANK);
|
||||||
}
|
}
|
||||||
// null or 空文字判定
|
// null or 空文字判定
|
||||||
if (isNullOrBlank(hireDate)) {
|
if (isNullOrBlank(hireDate)) {
|
||||||
// エラー内容を追加
|
// エラー内容を追加
|
||||||
error.add(HIREDATE_NULL_BLANK);
|
error.add(HIREDATE_NULL_BLANK);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 管理者権限の値が不正か
|
// 管理者権限の値が不正か
|
||||||
if (management == null) {
|
if (management == null) {
|
||||||
// エラー内容を追加
|
// エラー内容を追加
|
||||||
error.add(MANAGEMENT_ERROR);
|
error.add(MANAGEMENT_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 所属部署の値が不正か
|
// 所属部署の値が不正か
|
||||||
if (departmentId == null) {
|
if (departmentId == null) {
|
||||||
// エラー内容を追加
|
// エラー内容を追加
|
||||||
error.add(DEPARTMENT_ID_NULL_BLANK);
|
error.add(DEPARTMENT_ID_NULL_BLANK);
|
||||||
}
|
}
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 仮引数を null or 空 判定する
|
* 仮引数を null or 空 判定する
|
||||||
*
|
*
|
||||||
* @param str 判定対象の文字列
|
* @param str 判定対象の文字列
|
||||||
* @return true:null or 空 false:null or 空 では無い
|
* @return true:null or 空 false:null or 空 では無い
|
||||||
*/
|
*/
|
||||||
private static boolean isNullOrBlank(String str) {
|
private static boolean isNullOrBlank(String str) {
|
||||||
if (null == str) {
|
if (null == str) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return str.isBlank();
|
return str.isBlank();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -35,135 +35,109 @@ import com.example.rhizome.app.presentation.form.InsertEmployeeForm;
|
|||||||
@Controller
|
@Controller
|
||||||
public class InsertEmployeeInputController {
|
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;
|
HttpSession httpSession;
|
||||||
RegisterEmployee registerEmployee;
|
RegisterEmployee registerEmployee;
|
||||||
SearchDepartment searchDepartment;
|
SearchDepartment searchDepartment;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public InsertEmployeeInputController(HttpSession httpSession, RegisterEmployee registerEmployee, SearchDepartment searchDepartment) {
|
public InsertEmployeeInputController(HttpSession httpSession, RegisterEmployee registerEmployee,
|
||||||
this.httpSession = httpSession;
|
SearchDepartment searchDepartment) {
|
||||||
this.registerEmployee = registerEmployee;
|
this.httpSession = httpSession;
|
||||||
this.searchDepartment = searchDepartment;
|
this.registerEmployee = registerEmployee;
|
||||||
}
|
this.searchDepartment = searchDepartment;
|
||||||
|
}
|
||||||
|
|
||||||
@ModelAttribute
|
@ModelAttribute
|
||||||
public InsertEmployeeForm insertEmployeeForm() {
|
public InsertEmployeeForm insertEmployeeForm() {
|
||||||
return new InsertEmployeeForm();
|
return new InsertEmployeeForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
//プルダウン絞り込み無し実装用
|
/**
|
||||||
// /**
|
* 社員情報登録画面の表示を行う
|
||||||
// * 登録画面表示処理
|
*
|
||||||
// *
|
* @param InsertEmployeeFormを保持したインスタンス
|
||||||
// * @param insertEmployeeForm 登録画面のフォーム
|
* @param model ビューにデータを渡すためのコンテナ
|
||||||
// * @param model ビューにデータを渡すためのコンテナ
|
* @return 遷移先の画面
|
||||||
// * @return 遷移先の画面
|
*/
|
||||||
// */
|
@SessionCheck
|
||||||
// @SessionCheck
|
@PermissionCheck
|
||||||
// @PermissionCheck
|
@RequestMapping(value = INSERT_EMPLOYEE_INPUT, method = RequestMethod.POST)
|
||||||
// @RequestMapping(value = INSERT_EMPLOYEE_INPUT, method = RequestMethod.POST)
|
public String insertInput(InsertEmployeeForm insertEmployeeForm, Model model) {
|
||||||
// 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) {
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 部署コードリストを作成し、画面に返す値としてセット
|
|
||||||
model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST
|
|
||||||
,HeadquartersInfoForm.convertFrom(
|
|
||||||
searchDepartment.searchAllDepartmentTable()));
|
|
||||||
|
|
||||||
// パラメータをセット
|
// 部署コードリストを作成し、画面に返す値としてセット
|
||||||
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) {
|
// 登録画面に遷移
|
||||||
// ログイン情報の破棄
|
return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML;
|
||||||
httpSession.invalidate();
|
|
||||||
|
|
||||||
e.printStackTrace();
|
} catch (Exception e) {
|
||||||
|
// ログイン情報の破棄
|
||||||
|
httpSession.invalidate();
|
||||||
|
|
||||||
// エラーログ出力
|
e.printStackTrace();
|
||||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
|
||||||
// エラー画面遷移
|
// エラーログ出力
|
||||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||||
}
|
// エラー画面遷移
|
||||||
}
|
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||||
|
}
|
||||||
@GetMapping("insertEmployeeInput/searchDepartment" )
|
}
|
||||||
@ResponseBody
|
|
||||||
public List<DepartmentInfoForm>departmentsByHeadquarters(
|
/**
|
||||||
@RequestParam("id_headquarters")Integer idHeadquarters){
|
* 社員情報登録画面の部情報のプルダウンの表示を行う
|
||||||
System.out.println("koko");
|
*
|
||||||
|
* @param idHeadquarters
|
||||||
List<DepartmentInfoForm> departmentByHeadquarters=
|
* @return 遷移先の画面
|
||||||
DepartmentInfoForm.convertFrom(
|
*/
|
||||||
searchDepartment.searchByIdHeadquarters(idHeadquarters));
|
//画面で本部のプルダウンが選択された時にJSでこのメソッドに飛ぶ
|
||||||
System.out.println("2");
|
@GetMapping("insertEmployeeInput/searchDepartment")
|
||||||
return departmentByHeadquarters
|
@ResponseBody
|
||||||
.stream()
|
public List<DepartmentInfoForm> departmentsByHeadquarters(
|
||||||
.map(DepartmentInfoForm-> new DepartmentInfoForm(
|
@RequestParam("id_headquarters") Integer idHeadquarters) {
|
||||||
DepartmentInfoForm.getIdDepartment(),
|
List<DepartmentInfoForm> departmentByHeadquarters = DepartmentInfoForm.convertFrom(
|
||||||
DepartmentInfoForm.getNmDepartment()))
|
searchDepartment.searchByIdHeadquarters(idHeadquarters));
|
||||||
.distinct()
|
return departmentByHeadquarters
|
||||||
.toList();
|
.stream()
|
||||||
|
.map(DepartmentInfoForm -> new DepartmentInfoForm(
|
||||||
|
DepartmentInfoForm.getIdDepartment(),
|
||||||
}
|
DepartmentInfoForm.getNmDepartment()))
|
||||||
@GetMapping("/insertEmployeeInput/searchDepartment/searchDivision")
|
.distinct()
|
||||||
@ResponseBody
|
.toList();
|
||||||
public List<DivisionInfoForm>divisionBydepartment(
|
|
||||||
@RequestParam("idDepartment")Integer idDepartment){
|
}
|
||||||
List<DivisionInfoForm> divisionBydepartment=
|
|
||||||
DivisionInfoForm.convertFrom(
|
/**
|
||||||
searchDepartment.searchByIdDepartment(idDepartment));
|
* 社員情報登録画面の課情報のプルダウンの表示を行う
|
||||||
|
*
|
||||||
return divisionBydepartment
|
* @param idDepartment
|
||||||
.stream()
|
* @return 遷移先の画面
|
||||||
.map(DivisionInfoForm-> new DivisionInfoForm(
|
*/
|
||||||
DivisionInfoForm.getIdDivision(),
|
//画面で部のプルダウンが選択された時にJSでこのメソッドに飛ぶ
|
||||||
DivisionInfoForm.getNmDivision()))
|
@GetMapping("/insertEmployeeInput/searchDepartment/searchDivision")
|
||||||
.distinct()
|
@ResponseBody
|
||||||
.toList();
|
public List<DivisionInfoForm> divisionBydepartment(
|
||||||
|
@RequestParam("id_department") Integer idDepartment) {
|
||||||
|
List<DivisionInfoForm> divisionByDepartment = DivisionInfoForm.convertFrom(
|
||||||
}
|
searchDepartment.searchByIdDepartment(idDepartment));
|
||||||
|
return divisionByDepartment
|
||||||
|
.stream()
|
||||||
|
.map(DivisionInfoForm -> new DivisionInfoForm(
|
||||||
|
DivisionInfoForm.getIdDivision(),
|
||||||
|
DivisionInfoForm.getNmDivision()))
|
||||||
|
.distinct()
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,18 @@
|
|||||||
package com.example.rhizome.app.presentation.controller;
|
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.LoginInfo;
|
||||||
import com.example.rhizome.app.domain.model.LoginUser;
|
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.LoginUserForm;
|
||||||
import com.example.rhizome.app.presentation.form.MessageForm;
|
import com.example.rhizome.app.presentation.form.MessageForm;
|
||||||
import com.example.rhizome.app.presentation.form.UpdatePersonalUserForm;
|
import com.example.rhizome.app.presentation.form.UpdatePersonalUserForm;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.ui.Model;
|
|
||||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpSession;
|
|
||||||
import java.util.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
|
@Controller
|
||||||
public class LoginController {
|
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;
|
HttpSession httpSession;
|
||||||
Login login;
|
Login login;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public LoginController(HttpSession httpSession, Login login) {
|
public LoginController(HttpSession httpSession, Login login) {
|
||||||
this.httpSession = httpSession;
|
this.httpSession = httpSession;
|
||||||
this.login = login;
|
this.login = login;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ModelAttribute
|
@ModelAttribute
|
||||||
public LoginUserForm loginUserForm() {
|
public LoginUserForm loginUserForm() {
|
||||||
return new LoginUserForm();
|
return new LoginUserForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 画面から渡ってきたパラメータのチェックを行う
|
* 画面から渡ってきたパラメータのチェックを行う
|
||||||
*
|
*
|
||||||
* @param loginInfoForm mailAddress, password を保持したインスタンス
|
* @param loginInfoForm mailAddress, password を保持したインスタンス
|
||||||
* @param model ビューにデータを渡すためのコンテナ
|
* @param model ビューにデータを渡すためのコンテナ
|
||||||
* @return 遷移先の画面
|
* @return 遷移先の画面
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = DO_LOGIN, method = RequestMethod.POST)
|
@RequestMapping(value = DO_LOGIN, method = RequestMethod.POST)
|
||||||
public String doLogin(LoginInfoForm loginInfoForm, Model model) {
|
public String doLogin(LoginInfoForm loginInfoForm, Model model) {
|
||||||
|
|
||||||
// ログに出力する
|
// ログに出力する
|
||||||
final String MAIL_ADDRESS_PASSWORD_ERROR = "メールアドレス、パスワードの入力内容に誤りがあります";
|
final String MAIL_ADDRESS_PASSWORD_ERROR = "メールアドレス、パスワードの入力内容に誤りがあります";
|
||||||
// 発生しうるErrorに対するメッセージ
|
// 発生しうるErrorに対するメッセージ
|
||||||
final String LOGIN_ERROR = "IDまたはパスワードが間違っています";
|
final String LOGIN_ERROR = "IDまたはパスワードが間違っています";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// mailAddress, password の入力に誤りがあるかチェック
|
// mailAddress, password の入力に誤りがあるかチェック
|
||||||
if (!LoginUserForm.checkParameter(loginInfoForm)) {
|
if (!LoginUserForm.checkParameter(loginInfoForm)) {
|
||||||
|
|
||||||
// mail,passwordが仕様を満たしていない場合
|
// mail,passwordが仕様を満たしていない場合
|
||||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(MAIL_ADDRESS_PASSWORD_ERROR));
|
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR,
|
||||||
|
new MessageForm(MAIL_ADDRESS_PASSWORD_ERROR));
|
||||||
|
|
||||||
// エラーだった場合に login.html に処理を戻す。mailAddress, password を login.htmlに表示するために
|
// エラーだった場合に login.html に処理を戻す。mailAddress, password を login.htmlに表示するために
|
||||||
// ここで addAttribute する
|
// ここで addAttribute する
|
||||||
model.addAttribute(PageReturnAttributeKeyword.LOGIN_INFO_FORM, loginInfoForm);
|
model.addAttribute(PageReturnAttributeKeyword.LOGIN_INFO_FORM, loginInfoForm);
|
||||||
// login.html に遷移する様に設定
|
// login.html に遷移する様に設定
|
||||||
return TransitionTargetPageNameKeyword.LOGIN_HTML;
|
return TransitionTargetPageNameKeyword.LOGIN_HTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Login者情報インスタンスを作成
|
// Login者情報インスタンスを作成
|
||||||
LoginInfo loginInfo = createLoginInfo(httpSession, loginInfoForm);
|
LoginInfo loginInfo = createLoginInfo(httpSession, loginInfoForm);
|
||||||
|
|
||||||
// login 可能かチェック
|
// login 可能かチェック
|
||||||
if (!login.canLogin(loginInfo)) {
|
if (!login.canLogin(loginInfo)) {
|
||||||
// ログイン不可の場合、エラーメッセージをセットして入力された値とともに login.html を再表示
|
// ログイン不可の場合、エラーメッセージをセットして入力された値とともに login.html を再表示
|
||||||
// 画面に表示するエラーメッセージをセット
|
// 画面に表示するエラーメッセージをセット
|
||||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(LOGIN_ERROR));
|
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(LOGIN_ERROR));
|
||||||
// 画面に表示する mailAddress, password をセット
|
// 画面に表示する mailAddress, password をセット
|
||||||
model.addAttribute(PageReturnAttributeKeyword.LOGIN_INFO_FORM, loginInfoForm);
|
model.addAttribute(PageReturnAttributeKeyword.LOGIN_INFO_FORM, loginInfoForm);
|
||||||
// login.html に遷移
|
// login.html に遷移
|
||||||
return TransitionTargetPageNameKeyword.LOGIN_HTML;
|
return TransitionTargetPageNameKeyword.LOGIN_HTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ログイン(インスタンス作成)
|
// ログイン(インスタンス作成)
|
||||||
LoginUser loginUser = login.doLogin(loginInfo);
|
LoginUser loginUser = login.doLogin(loginInfo);
|
||||||
|
|
||||||
// ログイン者の情報をセッション情報に格納
|
// ログイン者の情報をセッション情報に格納
|
||||||
// セッションに loginUser 情報を保持し続ける = ログイン中として扱う
|
// セッションに loginUser 情報を保持し続ける = ログイン中として扱う
|
||||||
httpSession.setAttribute(SessionKeyword.LOGIN_USER, LoginUserForm.convertFrom(loginUser));
|
httpSession.setAttribute(SessionKeyword.LOGIN_USER, LoginUserForm.convertFrom(loginUser));
|
||||||
|
|
||||||
// 管理者かチェック
|
// 管理者かチェック
|
||||||
if (!loginUser.isAdminUser()) {
|
if (!loginUser.isAdminUser()) {
|
||||||
// 管理者ではない場合直で自分の情報を更新するページに遷移する
|
// 管理者ではない場合直で自分の情報を更新するページに遷移する
|
||||||
// 編集対象のログイン者の情報を画面に渡す値にセット
|
// 編集対象のログイン者の情報を画面に渡す値にセット
|
||||||
model.addAttribute(PageReturnAttributeKeyword.UPDATE_PERSONAL_EMPLOYEE_USER_FORM, UpdatePersonalUserForm.convertFrom(loginUser));
|
model.addAttribute(PageReturnAttributeKeyword.UPDATE_PERSONAL_EMPLOYEE_USER_FORM,
|
||||||
// 個人の情報更新ページに遷移
|
UpdatePersonalUserForm.convertFrom(loginUser));
|
||||||
return TransitionTargetPageNameKeyword.UPDATE_PERSONAL_EMPLOYEE_INPUT_HTML;
|
// 個人の情報更新ページに遷移
|
||||||
}
|
return TransitionTargetPageNameKeyword.UPDATE_PERSONAL_EMPLOYEE_INPUT_HTML;
|
||||||
|
}
|
||||||
|
|
||||||
// メニュー画面に遷移
|
// メニュー画面に遷移
|
||||||
return TransitionTargetPageNameKeyword.MENU_HTML;
|
return TransitionTargetPageNameKeyword.MENU_HTML;
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// ログイン情報の破棄
|
// ログイン情報の破棄
|
||||||
httpSession.invalidate();
|
httpSession.invalidate();
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
// エラーログ出力
|
// エラーログ出力
|
||||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||||
// エラー画面に遷移
|
// エラー画面に遷移
|
||||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ログイン者情報のインスタンスを作成
|
* ログイン者情報のインスタンスを作成
|
||||||
*
|
*
|
||||||
* @param httpSession セッション情報
|
* @param httpSession セッション情報
|
||||||
* @param loginInfoForm mailAddress, password を保持したインスタンス
|
* @param loginInfoForm mailAddress, password を保持したインスタンス
|
||||||
*/
|
*/
|
||||||
private static LoginInfo createLoginInfo(HttpSession httpSession, LoginInfoForm loginInfoForm) {
|
private static LoginInfo createLoginInfo(HttpSession httpSession, LoginInfoForm loginInfoForm) {
|
||||||
// セッションからログイン者情報を取得
|
// セッションからログイン者情報を取得
|
||||||
LoginUserForm loginUserForm = (LoginUserForm) httpSession.getAttribute(SessionKeyword.LOGIN_USER);
|
LoginUserForm loginUserForm = (LoginUserForm) httpSession.getAttribute(SessionKeyword.LOGIN_USER);
|
||||||
|
|
||||||
// セッションにログイン者情報があるか
|
// セッションにログイン者情報があるか
|
||||||
if (loginUserForm != null) {
|
if (loginUserForm != null) {
|
||||||
// セッションにログイン者情報がある場合
|
// セッションにログイン者情報がある場合
|
||||||
return new LoginInfo(loginUserForm.getMailAddress(), loginUserForm.getPassword());
|
return new LoginInfo(loginUserForm.getMailAddress(), loginUserForm.getPassword());
|
||||||
}
|
}
|
||||||
|
|
||||||
// セッションにない場合は画面からの input 値 を取得
|
// セッションにない場合は画面からの input 値 を取得
|
||||||
return new LoginInfo(
|
return new LoginInfo(
|
||||||
loginInfoForm.getMailAddress(),
|
loginInfoForm.getMailAddress(),
|
||||||
loginInfoForm.getPassword()
|
loginInfoForm.getPassword());
|
||||||
);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
package com.example.rhizome.app.presentation.controller;
|
package com.example.rhizome.app.presentation.controller;
|
||||||
|
|
||||||
import com.example.rhizome.aop.aspect.PermissionCheck;
|
import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.*;
|
||||||
import com.example.rhizome.aop.aspect.SessionCheck;
|
|
||||||
import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
|
import java.util.logging.Level;
|
||||||
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
import java.util.logging.Logger;
|
||||||
import com.example.rhizome.app.presentation.form.LoginUserForm;
|
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
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.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
|
||||||
import javax.servlet.http.HttpSession;
|
import com.example.rhizome.aop.aspect.PermissionCheck;
|
||||||
import java.util.logging.Level;
|
import com.example.rhizome.aop.aspect.SessionCheck;
|
||||||
import java.util.logging.Logger;
|
import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
|
||||||
|
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
||||||
import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.LOGOUT;
|
import com.example.rhizome.app.presentation.form.LoginUserForm;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ログアウト処理のコントローラ
|
* ログアウト処理のコントローラ
|
||||||
@@ -24,50 +26,50 @@ import static com.example.rhizome.app.presentation.controller.pageproperty.Trans
|
|||||||
@Controller
|
@Controller
|
||||||
public class LogoutController {
|
public class LogoutController {
|
||||||
|
|
||||||
// ログ出力用インスタンス
|
// ログ出力用インスタンス
|
||||||
private final static Logger LOGGER = Logger.getLogger(LogoutController.class.getName());
|
private final static Logger LOGGER = Logger.getLogger(LogoutController.class.getName());
|
||||||
// エラーメッセージ用の定数フィールド
|
// エラーメッセージ用の定数フィールド
|
||||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||||
|
|
||||||
HttpSession httpSession;
|
HttpSession httpSession;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public LogoutController(HttpSession httpSession) {
|
public LogoutController(HttpSession httpSession) {
|
||||||
this.httpSession = httpSession;
|
this.httpSession = httpSession;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ModelAttribute
|
@ModelAttribute
|
||||||
public LoginUserForm loginUserForm() {
|
public LoginUserForm loginUserForm() {
|
||||||
return new LoginUserForm();
|
return new LoginUserForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ログアウト処理
|
* ログアウト処理
|
||||||
*
|
*
|
||||||
* @param model ビューにデータを渡すためのコンテナ
|
* @param model ビューにデータを渡すためのコンテナ
|
||||||
* @return 遷移先の画面
|
* @return 遷移先の画面
|
||||||
*/
|
*/
|
||||||
@PermissionCheck
|
@PermissionCheck
|
||||||
@SessionCheck
|
@SessionCheck
|
||||||
@RequestMapping(value = LOGOUT, method = RequestMethod.POST)
|
@RequestMapping(value = LOGOUT, method = RequestMethod.POST)
|
||||||
public String doLogout(Model model) {
|
public String doLogout(Model model) {
|
||||||
try {
|
try {
|
||||||
// セッション情報の破棄
|
// セッション情報の破棄
|
||||||
httpSession.invalidate();
|
httpSession.invalidate();
|
||||||
|
|
||||||
// ログイン画面に遷移するための情報を設定
|
// ログイン画面に遷移するための情報を設定
|
||||||
model.addAttribute(PageReturnAttributeKeyword.LOGIN_INFO_FORM, loginUserForm());
|
model.addAttribute(PageReturnAttributeKeyword.LOGIN_INFO_FORM, loginUserForm());
|
||||||
// login.html に遷移
|
// login.html に遷移
|
||||||
return TransitionTargetPageNameKeyword.LOGIN_HTML;
|
return TransitionTargetPageNameKeyword.LOGIN_HTML;
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
// エラーログ出力
|
// エラーログ出力
|
||||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||||
// エラーページに遷移
|
// エラーページに遷移
|
||||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
package com.example.rhizome.app.presentation.controller;
|
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.PermissionCheck;
|
||||||
import com.example.rhizome.aop.aspect.SessionCheck;
|
import com.example.rhizome.aop.aspect.SessionCheck;
|
||||||
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
||||||
import com.example.rhizome.app.presentation.form.MessageForm;
|
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
|
@Controller
|
||||||
public class MenuController {
|
public class MenuController {
|
||||||
|
|
||||||
@ModelAttribute
|
@ModelAttribute
|
||||||
public MessageForm messageForm() {
|
public MessageForm messageForm() {
|
||||||
return new MessageForm();
|
return new MessageForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* メニュー画面に遷移
|
* メニュー画面に遷移
|
||||||
*/
|
*/
|
||||||
@PermissionCheck
|
@PermissionCheck
|
||||||
@SessionCheck
|
@SessionCheck
|
||||||
@RequestMapping(value = TransitionTargetPageNameKeyword.SHOW_MENU)
|
@RequestMapping(value = TransitionTargetPageNameKeyword.SHOW_MENU)
|
||||||
public String showMenu() {
|
public String showMenu() {
|
||||||
// メニュー画面遷移
|
// メニュー画面遷移
|
||||||
return TransitionTargetPageNameKeyword.MENU_HTML;
|
return TransitionTargetPageNameKeyword.MENU_HTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,99 +26,98 @@ import com.example.rhizome.app.presentation.form.SearchConditionDepartmentForm;
|
|||||||
@Controller
|
@Controller
|
||||||
public class SelectDepartmentController {
|
public class SelectDepartmentController {
|
||||||
|
|
||||||
// ログ出力用インスタンス
|
// ログ出力用インスタンス
|
||||||
private final static Logger LOGGER = Logger.getLogger(SelectDepartmentController.class.getName());
|
private final static Logger LOGGER = Logger.getLogger(SelectDepartmentController.class.getName());
|
||||||
// エラーメッセージ用の定数フィールド
|
// エラーメッセージ用の定数フィールド
|
||||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||||
|
|
||||||
HttpSession httpSession;
|
HttpSession httpSession;
|
||||||
SearchDepartment searchDepartment;
|
SearchDepartment searchDepartment;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public SelectDepartmentController(HttpSession httpSession, SearchDepartment searchDepartment) {
|
public SelectDepartmentController(HttpSession httpSession, SearchDepartment searchDepartment) {
|
||||||
this.httpSession = httpSession;
|
this.httpSession = httpSession;
|
||||||
this.searchDepartment = searchDepartment;
|
this.searchDepartment = searchDepartment;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ModelAttribute
|
@ModelAttribute
|
||||||
public SearchConditionDepartmentForm searchConditionDepartmentForm() {
|
public SearchConditionDepartmentForm searchConditionDepartmentForm() {
|
||||||
return new SearchConditionDepartmentForm();
|
return new SearchConditionDepartmentForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部署検索画面表示処理コントローラ
|
* 部署検索画面表示処理コントローラ
|
||||||
*
|
*
|
||||||
* @param model ビューにデータを渡すためのコンテナ
|
* @param model ビューにデータを渡すためのコンテナ
|
||||||
* @return 遷移先の画面
|
* @return 遷移先の画面
|
||||||
*/
|
*/
|
||||||
@PermissionCheck
|
@PermissionCheck
|
||||||
@SessionCheck
|
@SessionCheck
|
||||||
@RequestMapping(value = TransitionTargetPageNameKeyword.SELECT_DEPARTMENT, method = RequestMethod.POST)
|
@RequestMapping(value = TransitionTargetPageNameKeyword.SELECT_DEPARTMENT, method = RequestMethod.POST)
|
||||||
public String select(SearchConditionDepartmentForm searchConditionDepartmentForm, Model model) {
|
public String select(SearchConditionDepartmentForm searchConditionDepartmentForm, Model model) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// 部署一覧を取得し、画面に返す用のクラスに詰め替える
|
// 部署一覧を取得し、画面に返す用のクラスに詰め替える
|
||||||
// 作成した部署一覧をセット
|
// 作成した部署一覧をセット
|
||||||
model.addAttribute(
|
model.addAttribute(
|
||||||
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||||
DepartmentForm.convertFrom(
|
DepartmentForm.convertFrom(
|
||||||
searchDepartment.searchAllDepartmentTable(SearchConditionDepartmentForm.convertTo(searchConditionDepartmentForm))
|
searchDepartment.searchAllDepartmentTable(
|
||||||
|
SearchConditionDepartmentForm.convertTo(searchConditionDepartmentForm))
|
||||||
));
|
|
||||||
|
|
||||||
// 検索ページに遷移
|
));
|
||||||
return TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_HTML;
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
// 検索ページに遷移
|
||||||
// ログイン情報の破棄
|
return TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_HTML;
|
||||||
httpSession.invalidate();
|
|
||||||
|
|
||||||
e.printStackTrace();
|
} catch (Exception e) {
|
||||||
|
// ログイン情報の破棄
|
||||||
|
httpSession.invalidate();
|
||||||
|
|
||||||
// エラーログ出力
|
e.printStackTrace();
|
||||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
|
||||||
// エラー画面遷移
|
|
||||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
// エラーログ出力
|
||||||
|
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||||
|
// エラー画面遷移
|
||||||
|
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
}
|
||||||
* 部署検索画面表示処理コントローラ
|
|
||||||
*
|
|
||||||
* @param model ビューにデータを渡すためのコンテナ
|
|
||||||
* @return 遷移先の画面
|
|
||||||
*/
|
|
||||||
@PermissionCheck
|
|
||||||
@SessionCheck
|
|
||||||
@RequestMapping(value = TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_ALL, method = RequestMethod.POST)
|
|
||||||
public String selectAll(Model model) {
|
|
||||||
|
|
||||||
try {
|
/**
|
||||||
// 部署一覧を取得し、画面に返す用のクラスに詰め替える
|
* 部署検索画面表示処理コントローラ
|
||||||
// 作成した部署一覧をセット
|
*
|
||||||
model.addAttribute(
|
* @param model ビューにデータを渡すためのコンテナ
|
||||||
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
* @return 遷移先の画面
|
||||||
DepartmentForm.convertFrom(
|
*/
|
||||||
searchDepartment.searchAllDepartmentTable()
|
@PermissionCheck
|
||||||
)
|
@SessionCheck
|
||||||
);
|
@RequestMapping(value = TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_ALL, method = RequestMethod.POST)
|
||||||
|
public String selectAll(Model model) {
|
||||||
|
|
||||||
// 検索ページに遷移
|
try {
|
||||||
return TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_HTML;
|
// 部署一覧を取得し、画面に返す用のクラスに詰め替える
|
||||||
|
// 作成した部署一覧をセット
|
||||||
|
model.addAttribute(
|
||||||
|
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||||
|
DepartmentForm.convertFrom(
|
||||||
|
searchDepartment.searchAllDepartmentTable()));
|
||||||
|
|
||||||
} catch (Exception e) {
|
// 検索ページに遷移
|
||||||
// ログイン情報の破棄
|
return TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_HTML;
|
||||||
httpSession.invalidate();
|
|
||||||
|
|
||||||
e.printStackTrace();
|
} catch (Exception e) {
|
||||||
|
// ログイン情報の破棄
|
||||||
|
httpSession.invalidate();
|
||||||
|
|
||||||
// エラーログ出力
|
e.printStackTrace();
|
||||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
|
||||||
// エラー画面遷移
|
|
||||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
// エラーログ出力
|
||||||
|
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||||
|
// エラー画面遷移
|
||||||
|
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,9 +75,11 @@ public class SelectEmployeeController {
|
|||||||
);
|
);
|
||||||
// 検索条件を元に検索を実施
|
// 検索条件を元に検索を実施
|
||||||
// 取得した EmployeeInfo( employee + department )の情報を画面に返す用の型に詰め替えてセット
|
// 取得した EmployeeInfo( employee + department )の情報を画面に返す用の型に詰め替えてセット
|
||||||
|
//プラスで勤続年数を計算してformにセット
|
||||||
|
|
||||||
|
List<EmployeeInfoForm>employeeInfoForm = EmployeeInfoForm.convertFrom(
|
||||||
List<EmployeeInfoForm>employeeInfoForm = EmployeeInfoForm.convertFrom(searchEmployeeInfo.searchBy(SearchConditionEmployeeForm.convertTo(searchConditionEmployeeForm)));
|
searchEmployeeInfo.searchBy(
|
||||||
|
SearchConditionEmployeeForm.convertTo(searchConditionEmployeeForm)));
|
||||||
for(EmployeeInfoForm form:employeeInfoForm) {
|
for(EmployeeInfoForm form:employeeInfoForm) {
|
||||||
String tenure = tenureCalc.tenureCalc(form.getHireDate());
|
String tenure = tenureCalc.tenureCalc(form.getHireDate());
|
||||||
form.setTenure(tenure);
|
form.setTenure(tenure);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.example.rhizome.app.presentation.controller;
|
package com.example.rhizome.app.presentation.controller;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
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.PermissionCheck;
|
||||||
import com.example.rhizome.aop.aspect.SessionCheck;
|
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.model.SearchConditionDepartment;
|
||||||
import com.example.rhizome.app.domain.service.SearchDepartment;
|
import com.example.rhizome.app.domain.service.SearchDepartment;
|
||||||
import com.example.rhizome.app.domain.service.UpdateDepartment;
|
import com.example.rhizome.app.domain.service.UpdateDepartment;
|
||||||
@@ -30,92 +33,139 @@ import com.example.rhizome.app.presentation.form.UpdateDepartmentForm;
|
|||||||
@Controller
|
@Controller
|
||||||
public class UpdateDepartmentResultController {
|
public class UpdateDepartmentResultController {
|
||||||
|
|
||||||
// ログ出力用インスタンス
|
// ログ出力用インスタンス
|
||||||
private final static Logger LOGGER = Logger.getLogger(UpdateEmployeeController.class.getName());
|
private final static Logger LOGGER = Logger.getLogger(UpdateEmployeeController.class.getName());
|
||||||
// エラーメッセージ用の定数フィールド
|
// エラーメッセージ用の定数フィールド
|
||||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||||
|
|
||||||
HttpSession httpSession;
|
HttpSession httpSession;
|
||||||
SearchDepartment searchDepartment;
|
SearchDepartment searchDepartment;
|
||||||
UpdateDepartment updateDepartment;
|
UpdateDepartment updateDepartment;
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public UpdateDepartmentResultController(HttpSession httpSession, SearchDepartment searchDepartment, UpdateDepartment updateDepartment) {
|
public UpdateDepartmentResultController(HttpSession httpSession, SearchDepartment searchDepartment,
|
||||||
this.httpSession = httpSession;
|
UpdateDepartment updateDepartment) {
|
||||||
this.searchDepartment = searchDepartment;
|
this.httpSession = httpSession;
|
||||||
this.updateDepartment = updateDepartment;
|
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) {
|
|
||||||
|
|
||||||
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 {
|
final String NOTHING = "項目が空欄です。";
|
||||||
// 更新対象の部署データがない
|
final String DUPLICATION = "既に同名の部署が存在するか、値が変更されていません。";
|
||||||
if (updateDepartmentForm.getNmHeadquarters().isBlank()||
|
final String UPDATE_COMPLETE = "更新が完了しました。";
|
||||||
updateDepartmentForm.getNmDepartment().isBlank()||
|
|
||||||
updateDepartmentForm.getNmDivision().isBlank()) {
|
|
||||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(NOTHING));
|
|
||||||
model.addAttribute(PageReturnAttributeKeyword.UPDATE_DEPARTMENT_FORM, updateDepartmentForm);
|
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
// 部署名で重複が無いかチェック
|
return TransitionTargetPageNameKeyword.UPDATE_DEPARTMENT_INPUT_HTML;
|
||||||
if (searchDepartment.searchAllDepartmentTable(
|
}
|
||||||
new SearchConditionDepartment(
|
// 部署名で重複が無いかチェック
|
||||||
updateDepartmentForm.getIdHeadquarters(),
|
List<Headquarters> beforeHeadquartersList = searchDepartment
|
||||||
updateDepartmentForm.getNmHeadquarters()),
|
.searchHeadquartersByIdHeadquarters(updateDepartmentForm.getIdHeadquarters());
|
||||||
new SearchConditionDepartment(
|
List<Department> beforeDepartmentList = searchDepartment
|
||||||
updateDepartmentForm.getIdDepartment(),
|
.searchDepartmentByIdDepartment(updateDepartmentForm.getIdDepartment());
|
||||||
updateDepartmentForm.getNmDepartment()),
|
List<Division> beforeDivisionList = searchDepartment
|
||||||
new SearchConditionDepartment(
|
.searchDivisionByIdDivision(updateDepartmentForm.getIdDivision());
|
||||||
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;
|
Headquarters beforeHeadquarters = beforeHeadquartersList.get(0);
|
||||||
}
|
Department beforeDepartment = beforeDepartmentList.get(0);
|
||||||
|
Division beforeDivision = beforeDivisionList.get(0);
|
||||||
|
|
||||||
// 部署情報更新
|
Headquarters afterHeadquarters = new Headquarters(
|
||||||
updateDepartment.updateDepartment(UpdateDepartmentForm.convertTo(updateDepartmentForm));
|
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());
|
||||||
|
|
||||||
// 部署一覧取得
|
if (searchDepartment.searchAllDepartmentTable(
|
||||||
model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, DepartmentForm.convertFrom(
|
new SearchConditionDepartment(
|
||||||
searchDepartment.searchAllDepartmentTable())
|
updateDepartmentForm.getIdHeadquarters(),
|
||||||
);
|
updateDepartmentForm.getNmHeadquarters()),
|
||||||
// 更新結果のメッセージを画面にセットし一覧画面に遷移
|
new SearchConditionDepartment(
|
||||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_INFO, new MessageForm(UPDATE_COMPLETE));
|
updateDepartmentForm.getIdDepartment(),
|
||||||
|
updateDepartmentForm.getNmDepartment()),
|
||||||
|
new SearchConditionDepartment(
|
||||||
|
updateDepartmentForm.getIdDivision(),
|
||||||
|
updateDepartmentForm.getNmDivision()))
|
||||||
|
|
||||||
// forward 先で不用意な動作をしないために UpdateEmployeeInfoForm をクリア
|
|| (!beforeHeadquarters.getNmHeadquarters().equals(afterHeadquarters.getNmHeadquarters())
|
||||||
return "forward:" + TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_ALL;
|
&&
|
||||||
|
!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) {
|
return TransitionTargetPageNameKeyword.UPDATE_DEPARTMENT_INPUT_HTML;
|
||||||
// ログイン情報の破棄
|
}
|
||||||
httpSession.invalidate();
|
|
||||||
|
|
||||||
e.printStackTrace();
|
// 部署情報更新
|
||||||
// エラーログ出力
|
updateDepartment.updateDepartment(UpdateDepartmentForm.convertTo(updateDepartmentForm));
|
||||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
|
||||||
// エラー画面遷移
|
|
||||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
// 部署一覧取得
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,20 +9,27 @@ import javax.servlet.http.HttpSession;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
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.ModelAttribute;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
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.PermissionCheck;
|
||||||
import com.example.rhizome.aop.aspect.SessionCheck;
|
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.AllEmployeeInfo;
|
||||||
|
import com.example.rhizome.app.domain.model.SearchConditionDepartment;
|
||||||
import com.example.rhizome.app.domain.model.SearchConditionEmployee;
|
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.SearchDepartment;
|
||||||
import com.example.rhizome.app.domain.service.SearchEmployeeInfo;
|
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.PageReturnAttributeKeyword;
|
||||||
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
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.MessageForm;
|
||||||
import com.example.rhizome.app.presentation.form.SearchConditionEmployeeForm;
|
import com.example.rhizome.app.presentation.form.SearchConditionEmployeeForm;
|
||||||
import com.example.rhizome.app.presentation.form.UpdateEmployeeInfoForm;
|
import com.example.rhizome.app.presentation.form.UpdateEmployeeInfoForm;
|
||||||
@@ -33,78 +40,136 @@ import com.example.rhizome.app.presentation.form.UpdateEmployeeInfoForm;
|
|||||||
@Controller
|
@Controller
|
||||||
public class UpdateEmployeeController {
|
public class UpdateEmployeeController {
|
||||||
|
|
||||||
// ログ出力用インスタンス
|
// ログ出力用インスタンス
|
||||||
private final static Logger LOGGER = Logger.getLogger(UpdateEmployeeController.class.getName());
|
private final static Logger LOGGER = Logger.getLogger(UpdateEmployeeController.class.getName());
|
||||||
// エラーメッセージ用の定数フィールド
|
// エラーメッセージ用の定数フィールド
|
||||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||||
|
|
||||||
HttpSession httpSession;
|
HttpSession httpSession;
|
||||||
SearchDepartment searchDepartment;
|
SearchDepartment searchDepartment;
|
||||||
SearchEmployeeInfo searchEmployeeInfo;
|
SearchEmployeeInfo searchEmployeeInfo;
|
||||||
|
RegisterEmployee registerEmployee;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public UpdateEmployeeController(HttpSession httpSession, SearchDepartment searchDepartment, SearchEmployeeInfo searchEmployeeInfo) {
|
public UpdateEmployeeController(HttpSession httpSession, SearchDepartment searchDepartment,
|
||||||
this.httpSession = httpSession;
|
SearchEmployeeInfo searchEmployeeInfo, RegisterEmployee registerEmployee) {
|
||||||
this.searchDepartment = searchDepartment;
|
this.httpSession = httpSession;
|
||||||
this.searchEmployeeInfo = searchEmployeeInfo;
|
this.searchDepartment = searchDepartment;
|
||||||
}
|
this.searchEmployeeInfo = searchEmployeeInfo;
|
||||||
|
this.registerEmployee = registerEmployee;
|
||||||
|
}
|
||||||
|
|
||||||
@ModelAttribute
|
@ModelAttribute
|
||||||
public SearchConditionEmployeeForm searchConditionEmployeeForm() {
|
public SearchConditionEmployeeForm searchConditionEmployeeForm() {
|
||||||
return new SearchConditionEmployeeForm();
|
return new SearchConditionEmployeeForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新対象の employee が存在するか確認する為のコントローラ
|
* 更新対象の employee が存在するか確認する為のコントローラ
|
||||||
*
|
*
|
||||||
* @param idEmployee 更新対象の employee の id
|
* @param idEmployee 更新対象の employee の id
|
||||||
* @param model ビューにデータを渡すためのコンテナ
|
* @param model ビューにデータを渡すためのコンテナ
|
||||||
* @return 遷移先の画面
|
* @return 遷移先の画面
|
||||||
*/
|
*/
|
||||||
@PermissionCheck
|
@PermissionCheck
|
||||||
@SessionCheck
|
@SessionCheck
|
||||||
@RequestMapping(value = TransitionTargetPageNameKeyword.SHOW_UPDATE_EMPLOYEE, method = RequestMethod.POST)
|
@RequestMapping(value = TransitionTargetPageNameKeyword.SHOW_UPDATE_EMPLOYEE, method = RequestMethod.POST)
|
||||||
public String showUpdateEmployee(@RequestParam("idEmployee") Integer idEmployee, Model model) {
|
public String showUpdateEmployee(@RequestParam("idEmployee") Integer idEmployee, Model model) {
|
||||||
final String UPDATE_TARGET_ID_NOT_FOUND = "更新対象のデータが見つかりません。";
|
final String UPDATE_TARGET_ID_NOT_FOUND = "更新対象のデータが見つかりません。";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 部署一覧を取得し画面に返す値としてセット
|
// 部署コードリストを作成し、画面に返す値としてセット
|
||||||
model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, DepartmentForm.convertFrom(
|
model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, HeadquartersInfoForm.convertFrom(
|
||||||
searchDepartment.searchAllDepartmentTable()));
|
searchDepartment.searchAllDepartmentTable()));
|
||||||
|
// id を条件に更新対象のレコードを検索、取得する
|
||||||
|
List<AllEmployeeInfo> employeeInfoList = searchEmployeeInfo.searchBy(
|
||||||
|
new SearchConditionEmployee(idEmployee,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null));
|
||||||
|
|
||||||
// id を条件に更新対象のレコードを検索、取得する
|
// DBに更新対象のデータがあるか
|
||||||
List<AllEmployeeInfo> employeeInfoList = searchEmployeeInfo.searchBy(
|
if (employeeInfoList.isEmpty()) {
|
||||||
new SearchConditionEmployee(idEmployee,
|
// ない場合はエラーメッセージをセットして検索画面に戻る
|
||||||
null,
|
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR,
|
||||||
null,
|
new MessageForm(UPDATE_TARGET_ID_NOT_FOUND));
|
||||||
null,
|
return "forward:" + TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_INFO;
|
||||||
null));
|
}
|
||||||
|
//idDivisionからidHeadquartersを調べてUpdateEmployeeInfoFormに入れる
|
||||||
|
System.out.println("A");
|
||||||
|
UpdateEmployeeInfoForm updateInfo = UpdateEmployeeInfoForm.convertFrom(employeeInfoList.get(0));
|
||||||
|
SearchConditionDepartment beforeUpdate = new SearchConditionDepartment(
|
||||||
|
updateInfo.getIdDivision(),
|
||||||
|
null);
|
||||||
|
List<AllDepartmentInfo> afterSearchDepartment = searchDepartment.searchAllDepartmentTable(beforeUpdate);
|
||||||
|
|
||||||
// DBに更新対象のデータがあるか
|
updateInfo.setIdHeadquarters(afterSearchDepartment.get(0).getHeadquarters().getIdHeadquarters());
|
||||||
if (employeeInfoList.isEmpty()) {
|
|
||||||
// ない場合はエラーメッセージをセットして検索画面に戻る
|
|
||||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(UPDATE_TARGET_ID_NOT_FOUND));
|
|
||||||
return "forward:" + TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_INFO;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 更新画面に遷移
|
// 更新画面に遷移
|
||||||
model.addAttribute(PageReturnAttributeKeyword.UPDATE_EMPLOYEE_INFO_FORM, UpdateEmployeeInfoForm.convertFrom(employeeInfoList.get(0)));
|
model.addAttribute(PageReturnAttributeKeyword.UPDATE_EMPLOYEE_INFO_FORM,
|
||||||
|
updateInfo);
|
||||||
|
|
||||||
// Update画面に遷移
|
// Update画面に遷移
|
||||||
return TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_INPUT_HTML;
|
return TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_INPUT_HTML;
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
// ログイン情報の破棄
|
||||||
|
httpSession.invalidate();
|
||||||
|
|
||||||
} catch (Exception e) {
|
e.printStackTrace();
|
||||||
// ログイン情報の破棄
|
|
||||||
httpSession.invalidate();
|
|
||||||
|
|
||||||
e.printStackTrace();
|
// エラーログ出力
|
||||||
|
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||||
|
// エラー画面遷移
|
||||||
|
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||||
|
|
||||||
// エラーログ出力
|
}
|
||||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
}
|
||||||
// エラー画面遷移
|
|
||||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
|
||||||
|
|
||||||
}
|
/**
|
||||||
}
|
* 社員情報更新画面の部情報のプルダウンの表示を行う
|
||||||
|
*
|
||||||
|
* @param idHeadquarters
|
||||||
|
* @return 遷移先の画面
|
||||||
|
*/
|
||||||
|
//画面で本部のプルダウンが選択された時にJSでこのメソッドに飛ぶ
|
||||||
|
@GetMapping("updateEmployeeInput/searchDepartment")
|
||||||
|
@ResponseBody
|
||||||
|
public List<DepartmentInfoForm> departmentsByHeadquarters(
|
||||||
|
@RequestParam("id_headquarters") Integer idHeadquarters) {
|
||||||
|
List<DepartmentInfoForm> 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<DivisionInfoForm> divisionBydepartment(
|
||||||
|
@RequestParam("id_department") Integer idDepartment) {
|
||||||
|
List<DivisionInfoForm> divisionByDepartment = DivisionInfoForm.convertFrom(
|
||||||
|
searchDepartment.searchByIdDepartment(idDepartment));
|
||||||
|
return divisionByDepartment
|
||||||
|
.stream()
|
||||||
|
.map(DivisionInfoForm -> new DivisionInfoForm(
|
||||||
|
DivisionInfoForm.getIdDivision(),
|
||||||
|
DivisionInfoForm.getNmDivision()))
|
||||||
|
.distinct()
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,6 +151,7 @@ public class UpdateEmployeeResultController {
|
|||||||
return TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_INPUT_HTML;
|
return TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_INPUT_HTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//勤続年数は更新対象ではないのでそのまま移し替える
|
||||||
updateEmployeeInfoForm.setHireDate(beforeEmployee.getHireDate());
|
updateEmployeeInfoForm.setHireDate(beforeEmployee.getHireDate());
|
||||||
|
|
||||||
// 画面用の型からビジネスロジック用のモデルに変換し、Updateを実行
|
// 画面用の型からビジネスロジック用のモデルに変換し、Updateを実行
|
||||||
|
|||||||
@@ -16,5 +16,7 @@ public class PageReturnAttributeKeyword {
|
|||||||
public static final String LOGIN_INFO_FORM = "loginInfoForm";
|
public static final String LOGIN_INFO_FORM = "loginInfoForm";
|
||||||
public static final String UPDATE_PERSONAL_EMPLOYEE_USER_FORM = "updatePersonalEmployeeUserForm";
|
public static final String UPDATE_PERSONAL_EMPLOYEE_USER_FORM = "updatePersonalEmployeeUserForm";
|
||||||
public static final String EMPLOYEE_INFO_FORM_LIST = "employeeInfoFormList";
|
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";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,6 +66,6 @@ public class DepartmentForm {
|
|||||||
*/
|
*/
|
||||||
public static List<DepartmentForm> convertFrom(List<AllDepartmentInfo>allDepartmentInfoList
|
public static List<DepartmentForm> convertFrom(List<AllDepartmentInfo>allDepartmentInfoList
|
||||||
) {
|
) {
|
||||||
return allDepartmentInfoList.stream().map(DepartmentForm::convertFrom).toList();
|
return allDepartmentInfoList.stream().map(DepartmentForm::convertFrom).distinct().toList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.example.rhizome.app.presentation.form;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.example.rhizome.app.domain.model.AllDepartmentInfo;
|
||||||
import com.example.rhizome.app.domain.model.Department;
|
import com.example.rhizome.app.domain.model.Department;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
@@ -34,4 +35,14 @@ public class DepartmentInfoForm {
|
|||||||
) {
|
) {
|
||||||
return DepartmentList.stream().map(DepartmentInfoForm::convertFrom).toList();
|
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<DepartmentInfoForm> convertFromTo(List<AllDepartmentInfo>AllDepartmentInfoList
|
||||||
|
) {
|
||||||
|
return AllDepartmentInfoList.stream().map(DepartmentInfoForm::convertFrom).distinct().toList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@ package com.example.rhizome.app.presentation.form;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.example.rhizome.app.domain.model.AllDepartmentInfo;
|
||||||
import com.example.rhizome.app.domain.model.Division;
|
import com.example.rhizome.app.domain.model.Division;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
@@ -32,4 +33,14 @@ public class DivisionInfoForm {
|
|||||||
) {
|
) {
|
||||||
return divisionList.stream().map(DivisionInfoForm::convertFrom).toList();
|
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<DivisionInfoForm> convertFromTo(List<AllDepartmentInfo>AllDepartmentInfoList
|
||||||
|
) {
|
||||||
|
return AllDepartmentInfoList.stream().map(DivisionInfoForm::convertFrom).distinct().toList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.example.rhizome.app.presentation.form;
|
package com.example.rhizome.app.presentation.form;
|
||||||
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.example.rhizome.app.domain.model.AllEmployeeInfo;
|
import com.example.rhizome.app.domain.model.AllEmployeeInfo;
|
||||||
@@ -17,97 +16,94 @@ import lombok.NoArgsConstructor;
|
|||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class EmployeeInfoForm {
|
public class EmployeeInfoForm {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 社員ID
|
* 社員ID
|
||||||
*/
|
*/
|
||||||
private Integer idEmployee;
|
private Integer idEmployee;
|
||||||
/**
|
/**
|
||||||
* 社員名
|
* 社員名
|
||||||
*/
|
*/
|
||||||
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 hireDate;
|
private String hireDate;
|
||||||
/**
|
/**
|
||||||
* 勤続年数
|
* 勤続年数
|
||||||
*/
|
*/
|
||||||
private String tenure;
|
private String tenure;
|
||||||
/**
|
/**
|
||||||
* 管理者権限
|
* 管理者権限
|
||||||
*/
|
*/
|
||||||
private Integer adminAuth;
|
private Integer adminAuth;
|
||||||
/**
|
/**
|
||||||
* 本部ID
|
* 本部ID
|
||||||
*/
|
*/
|
||||||
private Integer idHeadquarters;
|
private Integer idHeadquarters;
|
||||||
/**
|
/**
|
||||||
* 本部名
|
* 本部名
|
||||||
*/
|
*/
|
||||||
private String nmHeadquarters;
|
private String nmHeadquarters;
|
||||||
/**
|
/**
|
||||||
* 部ID
|
* 部ID
|
||||||
*/
|
*/
|
||||||
private Integer idDepartment;
|
private Integer idDepartment;
|
||||||
/**
|
/**
|
||||||
* 部名
|
* 部名
|
||||||
*/
|
*/
|
||||||
private String nmDepartment;
|
private String nmDepartment;
|
||||||
/**
|
/**
|
||||||
* 課ID
|
* 課ID
|
||||||
*/
|
*/
|
||||||
private Integer idDivision;
|
private Integer idDivision;
|
||||||
/**
|
/**
|
||||||
* 課名
|
* 課名
|
||||||
*/
|
*/
|
||||||
private String nmDivision;
|
private String nmDivision;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* business 層の EmployeeInfo クラスから画面用(presentation 層)の EmployeeInfoForm に
|
* AllEmployeeInfo からEmployeeInfoForm に変換します。
|
||||||
* 変換します。
|
*
|
||||||
*
|
* @param allEmployeeInfo AllEmployeeInfo インスタンス
|
||||||
* @param employeeInfo business 層の EmployeeInfo インスタンス
|
* @return EmployeeInfoForm インスタンス
|
||||||
* @return クラスから画面用(presentation 層)の EmployeeInfoForm インスタンス
|
*/
|
||||||
*/
|
public static EmployeeInfoForm convertFrom(AllEmployeeInfo allEmployeeInfo) {
|
||||||
public static EmployeeInfoForm convertFrom(AllEmployeeInfo allEmployeeInfo) {
|
return new EmployeeInfoForm(
|
||||||
return new EmployeeInfoForm(
|
allEmployeeInfo.getEmployee().getIdEmployee(),
|
||||||
allEmployeeInfo.getEmployee().getIdEmployee(),
|
allEmployeeInfo.getEmployee().getNmEmployee(),
|
||||||
allEmployeeInfo.getEmployee().getNmEmployee(),
|
allEmployeeInfo.getEmployee().getKnEmployee(),
|
||||||
allEmployeeInfo.getEmployee().getKnEmployee(),
|
allEmployeeInfo.getEmployee().getMailAddress(),
|
||||||
allEmployeeInfo.getEmployee().getMailAddress(),
|
allEmployeeInfo.getEmployee().getPassword(),
|
||||||
allEmployeeInfo.getEmployee().getPassword(),
|
allEmployeeInfo.getEmployee().getHireDate(),
|
||||||
allEmployeeInfo.getEmployee().getHireDate(),
|
null,
|
||||||
null,
|
allEmployeeInfo.getEmployee().getAdminAuth(),
|
||||||
allEmployeeInfo.getEmployee().getAdminAuth(),
|
allEmployeeInfo.getHeadquarters().getIdHeadquarters(),
|
||||||
allEmployeeInfo.getHeadquarters().getIdHeadquarters(),
|
allEmployeeInfo.getHeadquarters().getNmHeadquarters(),
|
||||||
allEmployeeInfo.getHeadquarters().getNmHeadquarters(),
|
allEmployeeInfo.getDepartment().getIdDepartment(),
|
||||||
allEmployeeInfo.getDepartment().getIdDepartment(),
|
allEmployeeInfo.getDepartment().getNmDepartment(),
|
||||||
allEmployeeInfo.getDepartment().getNmDepartment(),
|
allEmployeeInfo.getDivision().getIdDivision(),
|
||||||
allEmployeeInfo.getDivision().getIdDivision(),
|
allEmployeeInfo.getDivision().getNmDivision());
|
||||||
allEmployeeInfo.getDivision().getNmDivision()
|
}
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* business 層の EmployeeInfo クラスから画面用(presentation 層)の EmployeeInfoForm に
|
* AllEmployeeInfo からEmployeeInfoForm に変換します。(リスト版)
|
||||||
* 変換します。(リスト版)
|
*
|
||||||
*
|
* @param allEmployeeInfo AllEmployeeInfo インスタンスのリスト
|
||||||
* @param employeeInfoList business 層の EmployeeInfo インスタンスのリスト
|
* @return EmployeeInfoForm インスタンスのリスト
|
||||||
* @return クラスから画面用(presentation 層)の EmployeeInfoForm インスタンスのリスト
|
*/
|
||||||
*/
|
public static List<EmployeeInfoForm> convertFrom(List<AllEmployeeInfo> allEmployeeInfoList) {
|
||||||
public static List<EmployeeInfoForm> convertFrom(List<AllEmployeeInfo> allEmployeeInfoList) {
|
return allEmployeeInfoList.stream().map(EmployeeInfoForm::convertFrom).toList();
|
||||||
return allEmployeeInfoList.stream().map(EmployeeInfoForm::convertFrom).toList();
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,24 +13,34 @@ import lombok.NoArgsConstructor;
|
|||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class HeadquartersInfoForm {
|
public class HeadquartersInfoForm {
|
||||||
/**
|
/**
|
||||||
* 本部ID
|
* 本部ID
|
||||||
*/
|
*/
|
||||||
private Integer idHeadquarters;
|
private Integer idHeadquarters;
|
||||||
/**
|
/**
|
||||||
* 本部名
|
* 本部名
|
||||||
*/
|
*/
|
||||||
private String nmHeadquarters;
|
private String nmHeadquarters;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AllDepartmentInfoから HeadquartersInfoFormに変換します。
|
||||||
public static HeadquartersInfoForm convertFrom(AllDepartmentInfo allDepartmentInfo) {
|
*
|
||||||
return new HeadquartersInfoForm(
|
* @param allDepartmentInfo AllDepartmentInfo インスタンス
|
||||||
allDepartmentInfo.getHeadquarters().getIdHeadquarters(),
|
* @return HeadquartersInfoForm インスタンス
|
||||||
allDepartmentInfo.getHeadquarters().getNmHeadquarters()
|
*/
|
||||||
);
|
|
||||||
}
|
public static HeadquartersInfoForm convertFrom(AllDepartmentInfo allDepartmentInfo) {
|
||||||
public static List<HeadquartersInfoForm> convertFrom(List<AllDepartmentInfo>allDepartmentInfoList
|
return new HeadquartersInfoForm(
|
||||||
) {
|
allDepartmentInfo.getHeadquarters().getIdHeadquarters(),
|
||||||
return allDepartmentInfoList.stream().map(HeadquartersInfoForm::convertFrom).toList();
|
allDepartmentInfo.getHeadquarters().getNmHeadquarters());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AllDepartmentInfoから HeadquartersInfoFormに変換します。(リスト版)
|
||||||
|
*
|
||||||
|
* @param allDepartmentInfo AllDepartmentInfo インスタンスのリスト
|
||||||
|
* @return HeadquartersInfoForm インスタンスのリスト
|
||||||
|
*/
|
||||||
|
public static List<HeadquartersInfoForm> convertFrom(List<AllDepartmentInfo> allDepartmentInfoList) {
|
||||||
|
return allDepartmentInfoList.stream().map(HeadquartersInfoForm::convertFrom).distinct().toList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -40,10 +40,10 @@ public class InsertDepartmentForm {
|
|||||||
private String nmDivision;
|
private String nmDivision;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 画面用(presentation 層)の InsertDepartmentForm クラス を Business 層の Department クラスに変換
|
* 画面用(presentation 層)の InsertDepartmentForm クラス を Business 層の DepartmentInfo クラスに変換
|
||||||
*
|
*
|
||||||
* @param insertDepartmentForm presentation 層用のクラス
|
* @param insertDepartmentForm presentation 層用のクラス
|
||||||
* @return Business 層用のモデル
|
* @return DepartmentFormのインスタンス
|
||||||
*/
|
*/
|
||||||
public static DepartmentInfo convertTo(InsertDepartmentForm insertDepartmentForm) {
|
public static DepartmentInfo convertTo(InsertDepartmentForm insertDepartmentForm) {
|
||||||
return new DepartmentInfo(insertDepartmentForm.getIdHeadquarters(),
|
return new DepartmentInfo(insertDepartmentForm.getIdHeadquarters(),
|
||||||
|
|||||||
@@ -17,157 +17,155 @@ import lombok.NoArgsConstructor;
|
|||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class InsertEmployeeForm {
|
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 passwordConfirm;
|
||||||
/**
|
/**
|
||||||
* 入社年月日
|
* 入社年月日
|
||||||
*/
|
*/
|
||||||
private String hireDate;
|
private String hireDate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 管理者権限
|
* 管理者権限
|
||||||
*/
|
*/
|
||||||
private Integer adminAuth;
|
private Integer adminAuth;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 本部ID
|
* 本部ID
|
||||||
*/
|
*/
|
||||||
private Integer idHeadquarters;
|
private Integer idHeadquarters;
|
||||||
|
|
||||||
/**
|
|
||||||
* 部ID
|
|
||||||
*/
|
|
||||||
private Integer idDepartment;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 課ID
|
|
||||||
*/
|
|
||||||
private Integer idDivision;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* パスワードのValidation
|
* 部ID
|
||||||
* チェック対象にエラーが有った場合エラーリストに文言を追加する
|
*/
|
||||||
*
|
private Integer idDepartment;
|
||||||
* @param password 登録対象のパスワード
|
|
||||||
* @param passwordConfirm 登録対象のパスワード再入力
|
|
||||||
* @param error エラーリスト
|
|
||||||
*/
|
|
||||||
private static void checkPassword(String password, String passwordConfirm, List<String> error) {
|
|
||||||
final String PASSWORD_NULL_BLANK = "パスワード が未入力です。";
|
|
||||||
final String PASSWORD_CONFIRM_NULL_BLANK = "パスワード確認用 が未入力です。";
|
|
||||||
final String PASSWORD_MISMATCH = "パスワード と パスワード確認用 が一致しません。";
|
|
||||||
|
|
||||||
if (isNullOrBlank(password)) {
|
/**
|
||||||
error.add(PASSWORD_NULL_BLANK);
|
* 課ID
|
||||||
return;
|
*/
|
||||||
}
|
private Integer idDivision;
|
||||||
if (isNullOrBlank(passwordConfirm)) {
|
|
||||||
error.add(PASSWORD_CONFIRM_NULL_BLANK);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!password.equals(passwordConfirm)) {
|
/**
|
||||||
error.add(PASSWORD_MISMATCH);
|
* パスワードのValidation
|
||||||
}
|
* チェック対象にエラーが有った場合エラーリストに文言を追加する
|
||||||
}
|
*
|
||||||
|
* @param password 登録対象のパスワード
|
||||||
|
* @param passwordConfirm 登録対象のパスワード再入力
|
||||||
|
* @param error エラーリスト
|
||||||
|
*/
|
||||||
|
private static void checkPassword(String password, String passwordConfirm, List<String> error) {
|
||||||
|
final String PASSWORD_NULL_BLANK = "パスワード が未入力です。";
|
||||||
|
final String PASSWORD_CONFIRM_NULL_BLANK = "パスワード確認用 が未入力です。";
|
||||||
|
final String PASSWORD_MISMATCH = "パスワード と パスワード確認用 が一致しません。";
|
||||||
|
|
||||||
/**
|
if (isNullOrBlank(password)) {
|
||||||
* 仮引数を null or 空 判定する
|
error.add(PASSWORD_NULL_BLANK);
|
||||||
*
|
return;
|
||||||
* @param str 判定対象の文字列
|
}
|
||||||
* @return true:null or 空 false:null or 空 では無い
|
if (isNullOrBlank(passwordConfirm)) {
|
||||||
*/
|
error.add(PASSWORD_CONFIRM_NULL_BLANK);
|
||||||
private static boolean isNullOrBlank(String str) {
|
return;
|
||||||
if (null == str) {
|
}
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return str.isBlank();
|
if (!password.equals(passwordConfirm)) {
|
||||||
}
|
error.add(PASSWORD_MISMATCH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 画面から渡ってきた登録内容をまとめ、ビジネスモデルに変換
|
* 仮引数を null or 空 判定する
|
||||||
*
|
*
|
||||||
* @param insertEmployeeForm 画面から渡ってきた登録内容
|
* @param str 判定対象の文字列
|
||||||
* @return ビジネスモデルのインスタンス
|
* @return true:null or 空 false:null or 空 では無い
|
||||||
*/
|
*/
|
||||||
public static Employee convertTo(InsertEmployeeForm insertEmployeeForm) {
|
private static boolean isNullOrBlank(String str) {
|
||||||
return new Employee(
|
if (null == str) {
|
||||||
null,
|
return true;
|
||||||
insertEmployeeForm.getNmEmployee(),
|
}
|
||||||
insertEmployeeForm.getKnEmployee(),
|
|
||||||
insertEmployeeForm.getMailAddress(),
|
|
||||||
insertEmployeeForm.getPassword(),
|
|
||||||
insertEmployeeForm.getHireDate(),
|
|
||||||
insertEmployeeForm.getAdminAuth(),
|
|
||||||
insertEmployeeForm.getIdDivision()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
return str.isBlank();
|
||||||
* 登録データのValidationを行う
|
}
|
||||||
*
|
|
||||||
* @return エラーが有った場合はエラー文言、無ければ空のリストが返る
|
|
||||||
*/
|
|
||||||
public List<String> validateParameter() {
|
|
||||||
final String EMPLOYEE_NAME_NULL_BLANK = "社員名";
|
|
||||||
final String EMPLOYEE_KANA_NULL_BLANK = "社員名フリガナ";
|
|
||||||
final String MAIL_ADDRESS_NULL_BLANK = "メールアドレス";
|
|
||||||
final String MANAGEMENT_ERROR = "管理者権限指定";
|
|
||||||
final String DEPARTMENT_ID_NULL_BLANK = "所属部署";
|
|
||||||
final String HIREDATE_NULL_BLANK ="入社年月日";
|
|
||||||
|
|
||||||
List<String> 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);
|
* 登録データのValidationを行う
|
||||||
}
|
*
|
||||||
if (isNullOrBlank(knEmployee)) {
|
* @return エラーが有った場合はエラー文言、無ければ空のリストが返る
|
||||||
error.add(EMPLOYEE_KANA_NULL_BLANK);
|
*/
|
||||||
}
|
public List<String> validateParameter() {
|
||||||
if (isNullOrBlank(mailAddress)) {
|
final String EMPLOYEE_NAME_NULL_BLANK = "社員名";
|
||||||
error.add(MAIL_ADDRESS_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 = "入社年月日";
|
||||||
|
|
||||||
// パスワードが仕様を満たしているか確認
|
List<String> error = new ArrayList<>();
|
||||||
checkPassword(password, passwordConfirm, error);
|
|
||||||
|
|
||||||
if (adminAuth == null) {
|
if (isNullOrBlank(nmEmployee)) {
|
||||||
error.add(MANAGEMENT_ERROR);
|
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);
|
checkPassword(password, passwordConfirm, error);
|
||||||
}
|
|
||||||
if(isNullOrBlank(hireDate)) {
|
|
||||||
error.add(HIREDATE_NULL_BLANK);
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,12 +12,12 @@ import lombok.NoArgsConstructor;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class LoginInfoForm {
|
public class LoginInfoForm {
|
||||||
/**
|
/**
|
||||||
* メールアドレス
|
* メールアドレス
|
||||||
*/
|
*/
|
||||||
private String mailAddress;
|
private String mailAddress;
|
||||||
/**
|
/**
|
||||||
* パスワード
|
* パスワード
|
||||||
*/
|
*/
|
||||||
private String password;
|
private String password;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.example.rhizome.app.presentation.form;
|
package com.example.rhizome.app.presentation.form;
|
||||||
|
|
||||||
|
|
||||||
import com.example.rhizome.app.domain.model.LoginUser;
|
import com.example.rhizome.app.domain.model.LoginUser;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
@@ -11,104 +10,102 @@ import lombok.NoArgsConstructor;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class LoginUserForm {
|
public class LoginUserForm {
|
||||||
/**
|
/**
|
||||||
* 社員ID
|
* 社員ID
|
||||||
*/
|
*/
|
||||||
private Integer idEmployee;
|
private Integer idEmployee;
|
||||||
/**
|
/**
|
||||||
* 社員名
|
* 社員名
|
||||||
*/
|
*/
|
||||||
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 Integer adminAuth;
|
private Integer adminAuth;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 課ID
|
* 課ID
|
||||||
*/
|
*/
|
||||||
private Integer idDepartment;
|
private Integer idDepartment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* business 層の LoginUser クラスから画面用(presentation 層)の LoginUserForm に
|
* business 層の LoginUser クラスから画面用(presentation 層)の LoginUserForm に
|
||||||
* 変換します。
|
* 変換します。
|
||||||
*
|
*
|
||||||
* @param loginUser business 層の LoginUser インスタンス
|
* @param loginUser business 層の LoginUser インスタンス
|
||||||
* @return クラスから画面用(presentation 層)の LoginUserForm
|
* @return クラスから画面用(presentation 層)の LoginUserForm
|
||||||
*/
|
*/
|
||||||
public static LoginUserForm convertFrom(LoginUser loginUser) {
|
public static LoginUserForm convertFrom(LoginUser loginUser) {
|
||||||
return new LoginUserForm(
|
return new LoginUserForm(
|
||||||
loginUser.getIdEmployee(),
|
loginUser.getIdEmployee(),
|
||||||
loginUser.getNmEmployee(),
|
loginUser.getNmEmployee(),
|
||||||
loginUser.getKnEmployee(),
|
loginUser.getKnEmployee(),
|
||||||
loginUser.getMailAddress(),
|
loginUser.getMailAddress(),
|
||||||
loginUser.getPassword(),
|
loginUser.getPassword(),
|
||||||
loginUser.getAdminAuth(),
|
loginUser.getAdminAuth(),
|
||||||
loginUser.getIdDivision()
|
loginUser.getIdDivision());
|
||||||
);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 画面用(presentation 層)の LoginUserForm クラスから business 層の LoginUser クラスに
|
* 画面用(presentation 層)の LoginUserForm クラスから business 層の LoginUser クラスに
|
||||||
* 変換します。
|
* 変換します。
|
||||||
*
|
*
|
||||||
* @param loginUserForm 画面用(presentation 層)の LoginUserForm インスタンス
|
* @param loginUserForm 画面用(presentation 層)の LoginUserForm インスタンス
|
||||||
* @return business 層の LoginUser インスタンス
|
* @return business 層の LoginUser インスタンス
|
||||||
*/
|
*/
|
||||||
public static LoginUser convertTo(LoginUserForm loginUserForm) {
|
public static LoginUser convertTo(LoginUserForm loginUserForm) {
|
||||||
return new LoginUser(
|
return new LoginUser(
|
||||||
loginUserForm.getIdEmployee(),
|
loginUserForm.getIdEmployee(),
|
||||||
loginUserForm.getNmEmployee(),
|
loginUserForm.getNmEmployee(),
|
||||||
loginUserForm.getKnEmployee(),
|
loginUserForm.getKnEmployee(),
|
||||||
loginUserForm.getMailAddress(),
|
loginUserForm.getMailAddress(),
|
||||||
loginUserForm.getPassword(),
|
loginUserForm.getPassword(),
|
||||||
loginUserForm.getAdminAuth(),
|
loginUserForm.getAdminAuth(),
|
||||||
loginUserForm.getIdDepartment()
|
loginUserForm.getIdDepartment());
|
||||||
);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 画面から渡ってきた必須の値が仕様を満たしているか確認
|
* 画面から渡ってきた必須の値が仕様を満たしているか確認
|
||||||
*
|
*
|
||||||
* @param loginInfoForm 画面から渡ってきた mailAddress, password を格納しているインスタンス
|
* @param loginInfoForm 画面から渡ってきた mailAddress, password を格納しているインスタンス
|
||||||
* @return true:仕様を満たしている , false:仕様を満たしていない
|
* @return true:仕様を満たしている , false:仕様を満たしていない
|
||||||
*/
|
*/
|
||||||
public static boolean checkParameter(LoginInfoForm loginInfoForm) {
|
public static boolean checkParameter(LoginInfoForm loginInfoForm) {
|
||||||
if (null == loginInfoForm.getMailAddress()) {
|
if (null == loginInfoForm.getMailAddress()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loginInfoForm.getMailAddress().isBlank()) {
|
if (loginInfoForm.getMailAddress().isBlank()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null == loginInfoForm.getPassword()) {
|
if (null == loginInfoForm.getPassword()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return !loginInfoForm.getPassword().isBlank();
|
return !loginInfoForm.getPassword().isBlank();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 管理者権限を持っているか確認
|
* 管理者権限を持っているか確認
|
||||||
*
|
*
|
||||||
* @return true:管理者権限を持っている , false:管理者権限を持っていない
|
* @return true:管理者権限を持っている , false:管理者権限を持っていない
|
||||||
*/
|
*/
|
||||||
public boolean isAdminUser() {
|
public boolean isAdminUser() {
|
||||||
return getAdminAuth() == 1;
|
return getAdminAuth() == 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,5 +11,5 @@ import lombok.NoArgsConstructor;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class MessageForm {
|
public class MessageForm {
|
||||||
private String message;
|
private String message;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,49 +16,48 @@ import lombok.NoArgsConstructor;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class SearchConditionDepartmentForm {
|
public class SearchConditionDepartmentForm {
|
||||||
/**
|
/**
|
||||||
* 部署ID
|
* 部署ID
|
||||||
*/
|
*/
|
||||||
private Integer idDivision;
|
private Integer idDivision;
|
||||||
/**
|
/**
|
||||||
* 部署名
|
* 部署名
|
||||||
*/
|
*/
|
||||||
private String nmDivision;
|
private String nmDivision;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* business 層の Department クラスから画面用(presentation 層)の SearchConditionDepartmentForm に
|
* business 層の Department クラスから画面用(presentation 層)の SearchConditionDepartmentForm に
|
||||||
* 変換します。
|
* 変換します。
|
||||||
*
|
*
|
||||||
* @param department business 層の Department インスタンス
|
* @param department business 層の Department インスタンス
|
||||||
* @return 画面用(presentation 層)の SearchConditionDepartmentForm インスタンス
|
* @return 画面用(presentation 層)の SearchConditionDepartmentForm インスタンス
|
||||||
*/
|
*/
|
||||||
public static SearchConditionDepartmentForm convertFrom(Department department) {
|
public static SearchConditionDepartmentForm convertFrom(Department department) {
|
||||||
return new SearchConditionDepartmentForm(department.getIdDepartment(), department.getNmDepartment());
|
return new SearchConditionDepartmentForm(department.getIdDepartment(), department.getNmDepartment());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* business 層の Department クラスから画面用(presentation 層)の SearchConditionDepartmentForm に
|
* business 層の Department クラスから画面用(presentation 層)の SearchConditionDepartmentForm に
|
||||||
* 変換します。(リスト版)
|
* 変換します。(リスト版)
|
||||||
*
|
*
|
||||||
* @param departmentList business 層の Department インスタンスのリスト
|
* @param departmentList business 層の Department インスタンスのリスト
|
||||||
* @return 画面用(presentation 層)の SearchConditionDepartmentForm インスタンスのリスト
|
* @return 画面用(presentation 層)の SearchConditionDepartmentForm インスタンスのリスト
|
||||||
*/
|
*/
|
||||||
public static List<SearchConditionDepartmentForm> convertFrom(List<Department> departmentList) {
|
public static List<SearchConditionDepartmentForm> convertFrom(List<Department> departmentList) {
|
||||||
return departmentList.stream().map(SearchConditionDepartmentForm::convertFrom).toList();
|
return departmentList.stream().map(SearchConditionDepartmentForm::convertFrom).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* presentation 層の SearchConditionDepartmentForm クラスから画面用(Business 層)の SearchConditionDepartment に
|
* presentation 層の SearchConditionDepartmentForm クラスから画面用(Business 層)の SearchConditionDepartment に
|
||||||
* 変換します。(リスト版)
|
* 変換します。(リスト版)
|
||||||
*
|
*
|
||||||
* @param searchConditionDepartmentForm 検索画面の情報
|
* @param searchConditionDepartmentForm 検索画面の情報
|
||||||
* @return 画面用(Business 層)の SearchConditionDepartment インスタンスのリスト
|
* @return 画面用(Business 層)の SearchConditionDepartment インスタンスのリスト
|
||||||
*/
|
*/
|
||||||
public static SearchConditionDepartment convertTo(SearchConditionDepartmentForm searchConditionDepartmentForm) {
|
public static SearchConditionDepartment convertTo(SearchConditionDepartmentForm searchConditionDepartmentForm) {
|
||||||
return new SearchConditionDepartment(
|
return new SearchConditionDepartment(
|
||||||
searchConditionDepartmentForm.getIdDivision(),
|
searchConditionDepartmentForm.getIdDivision(),
|
||||||
searchConditionDepartmentForm.nmDivision
|
searchConditionDepartmentForm.nmDivision);
|
||||||
);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,58 +14,56 @@ import lombok.NoArgsConstructor;
|
|||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class SearchConditionEmployeeForm {
|
public class SearchConditionEmployeeForm {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 社員ID
|
* 社員ID
|
||||||
*/
|
*/
|
||||||
private Integer idEmployee;
|
private Integer idEmployee;
|
||||||
/**
|
/**
|
||||||
* 社員名
|
* 社員名
|
||||||
*/
|
*/
|
||||||
private String nmEmployee;
|
private String nmEmployee;
|
||||||
/**
|
/**
|
||||||
* 社員名カナ
|
* 社員名カナ
|
||||||
*/
|
*/
|
||||||
private String knEmployee;
|
private String knEmployee;
|
||||||
/**
|
/**
|
||||||
* メールアドレス
|
* メールアドレス
|
||||||
*/
|
*/
|
||||||
private String mailAddress;
|
private String mailAddress;
|
||||||
/**
|
/**
|
||||||
* 部署ID
|
* 部署ID
|
||||||
*/
|
*/
|
||||||
private Integer idDivision;
|
private Integer idDivision;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* business 層の SearchConditionEmployee クラスから画面用(presentation 層)の SearchConditionEmployeeForm に
|
* business 層の SearchConditionEmployee クラスから画面用(presentation 層)の SearchConditionEmployeeForm に
|
||||||
* 変換します。
|
* 変換します。
|
||||||
*
|
*
|
||||||
* @param searchConditionEmployee business 層の SearchConditionEmployee インスタンス
|
* @param searchConditionEmployee business 層の SearchConditionEmployee インスタンス
|
||||||
* @return 画面用(presentation 層)の SearchConditionEmployeeForm インスタンス
|
* @return 画面用(presentation 層)の SearchConditionEmployeeForm インスタンス
|
||||||
*/
|
*/
|
||||||
public static SearchConditionEmployeeForm convertFrom(SearchConditionEmployee searchConditionEmployee) {
|
public static SearchConditionEmployeeForm convertFrom(SearchConditionEmployee searchConditionEmployee) {
|
||||||
return new SearchConditionEmployeeForm(
|
return new SearchConditionEmployeeForm(
|
||||||
searchConditionEmployee.getIdEmployee(),
|
searchConditionEmployee.getIdEmployee(),
|
||||||
searchConditionEmployee.getNmEmployee(),
|
searchConditionEmployee.getNmEmployee(),
|
||||||
searchConditionEmployee.getKnEmployee(),
|
searchConditionEmployee.getKnEmployee(),
|
||||||
searchConditionEmployee.getMailAddress(),
|
searchConditionEmployee.getMailAddress(),
|
||||||
searchConditionEmployee.getIdDivision()
|
searchConditionEmployee.getIdDivision());
|
||||||
);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 画面用(presentation 層)の SearchConditionEmployeeForm クラスから business 層の SearchConditionEmployee クラスに
|
* 画面用(presentation 層)の SearchConditionEmployeeForm クラスから business 層の SearchConditionEmployee クラスに
|
||||||
* 変換します。
|
* 変換します。
|
||||||
*
|
*
|
||||||
* @param searchConditionEmployeeForm 画面用(presentation 層)の SearchConditionEmployeeForm インスタンス
|
* @param searchConditionEmployeeForm 画面用(presentation 層)の SearchConditionEmployeeForm インスタンス
|
||||||
* @return business 層の SearchConditionEmployee インスタンス
|
* @return business 層の SearchConditionEmployee インスタンス
|
||||||
*/
|
*/
|
||||||
public static SearchConditionEmployee convertTo(SearchConditionEmployeeForm searchConditionEmployeeForm) {
|
public static SearchConditionEmployee convertTo(SearchConditionEmployeeForm searchConditionEmployeeForm) {
|
||||||
return new SearchConditionEmployee(
|
return new SearchConditionEmployee(
|
||||||
searchConditionEmployeeForm.getIdEmployee(),
|
searchConditionEmployeeForm.getIdEmployee(),
|
||||||
searchConditionEmployeeForm.getNmEmployee(),
|
searchConditionEmployeeForm.getNmEmployee(),
|
||||||
searchConditionEmployeeForm.getKnEmployee(),
|
searchConditionEmployeeForm.getKnEmployee(),
|
||||||
searchConditionEmployeeForm.getMailAddress(),
|
searchConditionEmployeeForm.getMailAddress(),
|
||||||
searchConditionEmployeeForm.getIdDivision()
|
searchConditionEmployeeForm.getIdDivision());
|
||||||
);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,83 +13,62 @@ import lombok.Data;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
|
||||||
public class UpdateDepartmentForm {
|
public class UpdateDepartmentForm {
|
||||||
/**
|
/**
|
||||||
* 本部ID
|
* 本部ID
|
||||||
*/
|
*/
|
||||||
private Integer idHeadquarters;
|
private Integer idHeadquarters;
|
||||||
/**
|
/**
|
||||||
* 本部名
|
* 本部名
|
||||||
*/
|
*/
|
||||||
private String nmHeadquarters;
|
private String nmHeadquarters;
|
||||||
/**
|
/**
|
||||||
* 部ID
|
* 部ID
|
||||||
*/
|
*/
|
||||||
private Integer idDepartment;
|
private Integer idDepartment;
|
||||||
/**
|
/**
|
||||||
* 部名
|
* 部名
|
||||||
*/
|
*/
|
||||||
private String nmDepartment;
|
private String nmDepartment;
|
||||||
/**
|
/**
|
||||||
* 課ID
|
* 課ID
|
||||||
*/
|
*/
|
||||||
private Integer idDivision;
|
private Integer idDivision;
|
||||||
/**
|
/**
|
||||||
* 課名
|
* 課名
|
||||||
*/
|
*/
|
||||||
private String nmDivision;
|
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());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* business 層の Department クラスから画面用(presentation 層)の UpdateDepartmentForm に
|
* AllDepartmentInfoクラスから UpdateDepartmentForm に変換します。
|
||||||
* 変換します。(リスト版)
|
*
|
||||||
*
|
* @param allDepartmentInfo AllDepartmentInfo インスタンス
|
||||||
* @param departmentList business 層の Department インスタンスのリスト
|
* @return 画面用(presentation 層)の UpdateDepartmentForm インスタンス
|
||||||
* @return 画面用(presentation 層)の UpdateDepartmentForm インスタンスのリスト
|
*/
|
||||||
*/
|
public static UpdateDepartmentForm convertFrom(AllDepartmentInfo allDepartmentInfo) {
|
||||||
// public static List<UpdateDepartmentForm> convertFrom(List<Department> departmentList) {
|
return new UpdateDepartmentForm(
|
||||||
// return departmentList.stream().map(UpdateDepartmentForm::convertFrom).toList();
|
allDepartmentInfo.getHeadquarters().getIdHeadquarters(),
|
||||||
// }
|
allDepartmentInfo.getHeadquarters().getNmHeadquarters(),
|
||||||
|
allDepartmentInfo.getDepartment().getIdDepartment(),
|
||||||
|
allDepartmentInfo.getDepartment().getNmDepartment(),
|
||||||
|
allDepartmentInfo.getDivision().getIdDivision(),
|
||||||
|
allDepartmentInfo.getDivision().getNmDivision());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* presentation 層の UpdateDepartmentForm クラスから Business 層の Department クラスに
|
* UpdateDepartmentFormから DepartmentInfo に変換します。
|
||||||
* 変換します。
|
*
|
||||||
*
|
* @param updateDepartmentForm UpdateDepartmentFormインスタンス
|
||||||
* @param updateDepartmentForm presentation 層のインスタンス
|
* @return DepartmentInfo インスタンス
|
||||||
* @return Business 層の Department インスタンス
|
*/
|
||||||
*/
|
public static DepartmentInfo convertTo(UpdateDepartmentForm updateDepartmentForm) {
|
||||||
// public static Department convertTo(UpdateDepartmentForm updateDepartmentForm) {
|
return new DepartmentInfo(
|
||||||
// return new Department(
|
updateDepartmentForm.getIdHeadquarters(),
|
||||||
// updateDepartmentForm.getIdDepartment(),
|
updateDepartmentForm.getNmHeadquarters(),
|
||||||
// updateDepartmentForm.getNmDepartment(),
|
updateDepartmentForm.getIdDepartment(),
|
||||||
// (Integer)0,
|
updateDepartmentForm.getNmDepartment(),
|
||||||
// updateDepartmentForm.getIdHeadquarters()
|
updateDepartmentForm.getIdDivision(),
|
||||||
//
|
updateDepartmentForm.getNmDivision()
|
||||||
// );
|
|
||||||
// }
|
);
|
||||||
public static DepartmentInfo convertTo(UpdateDepartmentForm updateDepartmentForm) {
|
}
|
||||||
return new DepartmentInfo(
|
|
||||||
updateDepartmentForm.getIdHeadquarters(),
|
|
||||||
updateDepartmentForm.getNmHeadquarters(),
|
|
||||||
updateDepartmentForm.getIdDepartment(),
|
|
||||||
updateDepartmentForm.getNmDepartment(),
|
|
||||||
updateDepartmentForm.getIdDivision(),
|
|
||||||
updateDepartmentForm.getNmDivision()
|
|
||||||
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,183 +17,184 @@ import lombok.NoArgsConstructor;
|
|||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class UpdateEmployeeInfoForm {
|
public class UpdateEmployeeInfoForm {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 社員ID
|
* 社員ID
|
||||||
*/
|
*/
|
||||||
private Integer idEmployee;
|
private Integer idEmployee;
|
||||||
/**
|
/**
|
||||||
* 社員名
|
* 社員名
|
||||||
*/
|
*/
|
||||||
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 passwordConfirm;
|
||||||
/**
|
/**
|
||||||
* 入社年月日
|
* 入社年月日
|
||||||
*/
|
*/
|
||||||
private String hireDate;
|
private String hireDate;
|
||||||
/**
|
/**
|
||||||
* 管理者権限
|
* 管理者権限
|
||||||
*/
|
*/
|
||||||
private Integer adminAuth;
|
private Integer adminAuth;
|
||||||
/**
|
/**
|
||||||
* 部署ID
|
* 部ID
|
||||||
*/
|
*/
|
||||||
private Integer idDivision;
|
private Integer idDivision;
|
||||||
|
/**
|
||||||
|
* 本部ID
|
||||||
|
*/
|
||||||
|
private Integer idHeadquarters;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* business 層の EmployeeInfo クラスから画面用(presentation 層)の UpdateEmployeeInfoForm に
|
* AllEmployeeInfo クラスからUpdateEmployeeInfoForm に変換します。
|
||||||
* 変換します。
|
*
|
||||||
*
|
* @param allemployeeInfo AllEmployeeInfo インスタンス
|
||||||
* @param employeeInfo business 層の EmployeeInfo インスタンス
|
* @return 画面用(presentation 層)の UpdateEmployeeInfoForm インスタンス
|
||||||
* @return 画面用(presentation 層)の UpdateEmployeeInfoForm インスタンス
|
*/
|
||||||
*/
|
public static UpdateEmployeeInfoForm convertFrom(AllEmployeeInfo allemployeeInfo) {
|
||||||
public static UpdateEmployeeInfoForm convertFrom(AllEmployeeInfo allemployeeInfo) {
|
return new UpdateEmployeeInfoForm(
|
||||||
return new UpdateEmployeeInfoForm(
|
allemployeeInfo.getEmployee().getIdEmployee(),
|
||||||
allemployeeInfo.getEmployee().getIdEmployee(),
|
allemployeeInfo.getEmployee().getNmEmployee(),
|
||||||
allemployeeInfo.getEmployee().getNmEmployee(),
|
allemployeeInfo.getEmployee().getKnEmployee(),
|
||||||
allemployeeInfo.getEmployee().getKnEmployee(),
|
allemployeeInfo.getEmployee().getMailAddress(),
|
||||||
allemployeeInfo.getEmployee().getMailAddress(),
|
allemployeeInfo.getEmployee().getPassword(),
|
||||||
allemployeeInfo.getEmployee().getPassword(),
|
null,
|
||||||
null,
|
allemployeeInfo.getEmployee().getHireDate(),
|
||||||
allemployeeInfo.getEmployee().getHireDate(),
|
allemployeeInfo.getEmployee().getAdminAuth(),
|
||||||
allemployeeInfo.getEmployee().getAdminAuth(),
|
allemployeeInfo.getDivision().getIdDivision(),
|
||||||
allemployeeInfo.getDivision().getIdDivision()
|
allemployeeInfo.getHeadquarters().getIdHeadquarters());
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
}
|
||||||
* business 層の EmployeeInfo クラスから画面用(presentation 層)の UpdateEmployeeInfoForm に
|
|
||||||
* 変換します。(リスト版)
|
|
||||||
*
|
|
||||||
* @param employeeInfoList business 層の EmployeeInfo インスタンスのリスト
|
|
||||||
* @return 画面用(presentation 層)の UpdateEmployeeInfoForm インスタンスのリスト
|
|
||||||
*/
|
|
||||||
public static List<UpdateEmployeeInfoForm> convertFrom(List<AllEmployeeInfo> allemployeeInfoList) {
|
|
||||||
return allemployeeInfoList.stream().map(UpdateEmployeeInfoForm::convertFrom).toList();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 画面用(presentation 層)の UpdateEmployeeInfoForm クラスから business 層の Employee クラスに
|
* AllEmployeeInfo クラスから画面用 UpdateEmployeeInfoForm に変換します。(リスト版)
|
||||||
* 変換します。
|
*
|
||||||
*
|
* @param allemployeeInfoList business 層の AllEmployeeInfo インスタンスのリスト
|
||||||
* @param updateEmployeeInfoForm 画面用(presentation 層)の UpdateEmployeeInfoForm インスタンス
|
* @return 画面用(presentation 層)の UpdateEmployeeInfoForm インスタンスのリスト
|
||||||
* @return business 層の Employee インスタンス
|
*/
|
||||||
*/
|
public static List<UpdateEmployeeInfoForm> convertFrom(List<AllEmployeeInfo> allemployeeInfoList) {
|
||||||
public static Employee convertTo(UpdateEmployeeInfoForm updateEmployeeInfoForm) {
|
return allemployeeInfoList.stream().map(UpdateEmployeeInfoForm::convertFrom).toList();
|
||||||
return new Employee(
|
}
|
||||||
updateEmployeeInfoForm.getIdEmployee(),
|
|
||||||
updateEmployeeInfoForm.getNmEmployee(),
|
|
||||||
updateEmployeeInfoForm.getKnEmployee(),
|
|
||||||
updateEmployeeInfoForm.getMailAddress(),
|
|
||||||
updateEmployeeInfoForm.getPassword(),
|
|
||||||
updateEmployeeInfoForm.getHireDate(),
|
|
||||||
updateEmployeeInfoForm.getAdminAuth(),
|
|
||||||
updateEmployeeInfoForm.getIdDivision()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 画面から渡ってきたパラメータのチェック
|
* 画面用(presentation 層)の UpdateEmployeeInfoForm クラスから business 層の Employee クラスに
|
||||||
*
|
* 変換します。
|
||||||
* @param updateEmployeeInfoForm 画面から渡ってきたパラメータ
|
*
|
||||||
* @return true: エラー無し false:エラーあり(必須を満たしていない)
|
* @param updateEmployeeInfoForm 画面用(presentation 層)の UpdateEmployeeInfoForm インスタンス
|
||||||
*/
|
* @return business 層の Employee インスタンス
|
||||||
public static boolean hasErrorParameter(UpdateEmployeeInfoForm updateEmployeeInfoForm) {
|
*/
|
||||||
|
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())) {
|
boolean errorFlag = !isNullOrBlank(updateEmployeeInfoForm.getNmEmployee());
|
||||||
errorFlag = true;
|
|
||||||
}
|
|
||||||
if (!isNullOrBlank(updateEmployeeInfoForm.getMailAddress())) {
|
|
||||||
errorFlag = true;
|
|
||||||
}
|
|
||||||
if (!isNullOrBlank(updateEmployeeInfoForm.getPassword())) {
|
|
||||||
errorFlag = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
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 password 更新対象のパスワード
|
||||||
* @param passwordConfirm 更新対象の確認用パスワード
|
* @param passwordConfirm 更新対象の確認用パスワード
|
||||||
* @return 空文字: エラー無し それ以外:エラー内容
|
* @return 空文字: エラー無し それ以外:エラー内容
|
||||||
*/
|
*/
|
||||||
public static String validatePassword(String password, String passwordConfirm) {
|
public static String validatePassword(String password, String passwordConfirm) {
|
||||||
|
|
||||||
final String ERROR = "パスワードが一致していません";
|
final String ERROR = "パスワードが一致していません";
|
||||||
|
|
||||||
if (areBothBlank(password, passwordConfirm)) {
|
if (areBothBlank(password, passwordConfirm)) {
|
||||||
// どちらもnullまたは空白の場合はOK
|
// どちらもnullまたは空白の場合はOK
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// どちらかがnullまたは空白の場合のエラーハンドリング
|
// どちらかがnullまたは空白の場合のエラーハンドリング
|
||||||
if (isEitherBlank(password, passwordConfirm)) {
|
if (isEitherBlank(password, passwordConfirm)) {
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 値が異なった場合はエラーハンドリング
|
// 値が異なった場合はエラーハンドリング
|
||||||
if (!password.equals(passwordConfirm)) {
|
if (!password.equals(passwordConfirm)) {
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 仮引数を null or 空 判定する
|
* 仮引数を null or 空 判定する
|
||||||
*
|
*
|
||||||
* @param str 判定対象の文字列
|
* @param str 判定対象の文字列
|
||||||
* @return true:null or 空 false:null or 空 では無い
|
* @return true:null or 空 false:null or 空 では無い
|
||||||
*/
|
*/
|
||||||
private static boolean isNullOrBlank(String str) {
|
private static boolean isNullOrBlank(String str) {
|
||||||
if (null == str) {
|
if (null == str) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return str.isBlank();
|
return str.isBlank();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* パスワードが今回更新対象に含まれているかチェック
|
* パスワードが今回更新対象に含まれているかチェック
|
||||||
*
|
*
|
||||||
* @param password 更新対象のパスワード
|
* @param password 更新対象のパスワード
|
||||||
* @param passwordConfirm 更新対象の確認用パスワード
|
* @param passwordConfirm 更新対象の確認用パスワード
|
||||||
* @return true:どちらもnullまたは空白の場合 false:それ以外
|
* @return true:どちらもnullまたは空白の場合 false:それ以外
|
||||||
*/
|
*/
|
||||||
private static boolean areBothBlank(String password, String passwordConfirm) {
|
private static boolean areBothBlank(String password, String passwordConfirm) {
|
||||||
return (password == null || password.isBlank()) && (passwordConfirm == null || passwordConfirm.isBlank());
|
return (password == null || password.isBlank()) && (passwordConfirm == null || passwordConfirm.isBlank());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* パスワードが今回更新対象に含まれているかチェック その2
|
* パスワードが今回更新対象に含まれているかチェック その2
|
||||||
*
|
*
|
||||||
* @param password 更新対象のパスワード
|
* @param password 更新対象のパスワード
|
||||||
* @param passwordConfirm 更新対象の確認用パスワード
|
* @param passwordConfirm 更新対象の確認用パスワード
|
||||||
* @return true: 問題なし false:どちらかがnullまたは空白の場合
|
* @return true: 問題なし false:どちらかがnullまたは空白の場合
|
||||||
*/
|
*/
|
||||||
// どちらかがnullまたは空白の場合のエラーハンドリング
|
// どちらかがnullまたは空白の場合のエラーハンドリング
|
||||||
private static boolean isEitherBlank(String password, String passwordConfirm) {
|
private static boolean isEitherBlank(String password, String passwordConfirm) {
|
||||||
return password == null || password.isBlank() || passwordConfirm == null || passwordConfirm.isBlank();
|
return password == null || password.isBlank() || passwordConfirm == null || passwordConfirm.isBlank();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,180 +14,177 @@ import lombok.NoArgsConstructor;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class UpdatePersonalUserForm {
|
public class UpdatePersonalUserForm {
|
||||||
/**
|
/**
|
||||||
* 社員ID
|
* 社員ID
|
||||||
*/
|
*/
|
||||||
private Integer idEmployee;
|
private Integer idEmployee;
|
||||||
/**
|
/**
|
||||||
* 社員名
|
* 社員名
|
||||||
*/
|
*/
|
||||||
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 passwordConfirm;
|
||||||
/**
|
/**
|
||||||
* 入社年月日
|
* 入社年月日
|
||||||
*/
|
*/
|
||||||
private String hireDate;
|
private String hireDate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 画面用(presentation 層)の UpdatePersonalUserForm クラスから business 層の Employee クラスに
|
* 画面用(presentation 層)の UpdatePersonalUserForm クラスから business 層の Employee クラスに
|
||||||
* 変換します。
|
* 変換します。
|
||||||
*
|
*
|
||||||
* @param updatePersonalUserForm 画面用(presentation 層)の UpdatePersonalUserForm インスタンス
|
* @param updatePersonalUserForm 画面用(presentation 層)の UpdatePersonalUserForm インスタンス
|
||||||
* @return business 層の Employee インスタンス
|
* @return business 層の Employee インスタンス
|
||||||
*/
|
*/
|
||||||
public static Employee convertTo(UpdatePersonalUserForm updatePersonalUserForm) {
|
public static Employee convertTo(UpdatePersonalUserForm updatePersonalUserForm) {
|
||||||
return new Employee(
|
return new Employee(
|
||||||
updatePersonalUserForm.getIdEmployee(),
|
updatePersonalUserForm.getIdEmployee(),
|
||||||
updatePersonalUserForm.getNmEmployee(),
|
updatePersonalUserForm.getNmEmployee(),
|
||||||
updatePersonalUserForm.getKnEmployee(),
|
updatePersonalUserForm.getKnEmployee(),
|
||||||
updatePersonalUserForm.getMailAddress(),
|
updatePersonalUserForm.getMailAddress(),
|
||||||
updatePersonalUserForm.getPassword(),
|
updatePersonalUserForm.getPassword(),
|
||||||
updatePersonalUserForm.getHireDate(),
|
updatePersonalUserForm.getHireDate(),
|
||||||
null,
|
null,
|
||||||
null
|
null);
|
||||||
);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* business 層の Employee クラスから画面用(presentation 層)の UpdatePersonalUserForm に
|
* business 層の Employee クラスから画面用(presentation 層)の UpdatePersonalUserForm に
|
||||||
* 変換します。(リスト版)
|
* 変換します。(リスト版)
|
||||||
*
|
*
|
||||||
* @param employee business 層の employee インスタンスのリスト
|
* @param employee business 層の employee インスタンスのリスト
|
||||||
* @return クラスから画面用(presentation 層)の UpdatePersonalUserForm インスタンスのリスト
|
* @return クラスから画面用(presentation 層)の UpdatePersonalUserForm インスタンスのリスト
|
||||||
*/
|
*/
|
||||||
public static UpdatePersonalUserForm convertFrom(Employee employee) {
|
public static UpdatePersonalUserForm convertFrom(Employee employee) {
|
||||||
return new UpdatePersonalUserForm(
|
return new UpdatePersonalUserForm(
|
||||||
employee.getIdEmployee(),
|
employee.getIdEmployee(),
|
||||||
employee.getNmEmployee(),
|
employee.getNmEmployee(),
|
||||||
employee.getKnEmployee(),
|
employee.getKnEmployee(),
|
||||||
employee.getMailAddress(),
|
employee.getMailAddress(),
|
||||||
employee.getPassword(),
|
employee.getPassword(),
|
||||||
null,
|
null,
|
||||||
employee.getHireDate()
|
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
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 画面から渡ってきたパラメータのチェック
|
* business 層の Employee クラスから画面用(presentation 層)の UpdatePersonalUserForm に
|
||||||
*
|
* 変換します。(リスト版)
|
||||||
* @param updatePersonalUserForm 画面から渡ってきたパラメータ
|
*
|
||||||
* @return true: エラー無し false:エラーあり(必須を満たしていない)
|
* @param loginUser business 層の loginUser インスタンスのリスト
|
||||||
*/
|
* @return クラスから画面用(presentation 層)の UpdatePersonalUserForm インスタンスのリスト
|
||||||
public static boolean hasErrorParameter(UpdatePersonalUserForm 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())) {
|
boolean errorFlag = !isNullOrBlank(updatePersonalUserForm.getNmEmployee());
|
||||||
errorFlag = true;
|
|
||||||
}
|
|
||||||
if (!isNullOrBlank(updatePersonalUserForm.getMailAddress())) {
|
|
||||||
errorFlag = true;
|
|
||||||
}
|
|
||||||
if (!isNullOrBlank(updatePersonalUserForm.getPassword())) {
|
|
||||||
errorFlag = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
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 password 更新対象のパスワード
|
||||||
* @param passwordConfirm 更新対象の確認用パスワード
|
* @param passwordConfirm 更新対象の確認用パスワード
|
||||||
* @return 空文字: エラー無し それ以外:エラー内容
|
* @return 空文字: エラー無し それ以外:エラー内容
|
||||||
*/
|
*/
|
||||||
public static String validatePassword(String password, String passwordConfirm) {
|
public static String validatePassword(String password, String passwordConfirm) {
|
||||||
|
|
||||||
final String ERROR = "パスワードが一致していません";
|
final String ERROR = "パスワードが一致していません";
|
||||||
|
|
||||||
if (areBothBlank(password, passwordConfirm)) {
|
if (areBothBlank(password, passwordConfirm)) {
|
||||||
// どちらもnullまたは空白の場合はOK
|
// どちらもnullまたは空白の場合はOK
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// どちらかがnullまたは空白の場合のエラーハンドリング
|
// どちらかがnullまたは空白の場合のエラーハンドリング
|
||||||
if (isEitherBlank(password, passwordConfirm)) {
|
if (isEitherBlank(password, passwordConfirm)) {
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 値が異なった場合はエラーハンドリング
|
// 値が異なった場合はエラーハンドリング
|
||||||
if (!password.equals(passwordConfirm)) {
|
if (!password.equals(passwordConfirm)) {
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 仮引数を null or 空 判定する
|
* 仮引数を null or 空 判定する
|
||||||
*
|
*
|
||||||
* @param str 判定対象の文字列
|
* @param str 判定対象の文字列
|
||||||
* @return true:null or 空 false:null or 空 では無い
|
* @return true:null or 空 false:null or 空 では無い
|
||||||
*/
|
*/
|
||||||
private static boolean isNullOrBlank(String str) {
|
private static boolean isNullOrBlank(String str) {
|
||||||
if (null == str) {
|
if (null == str) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return str.isBlank();
|
return str.isBlank();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* パスワードが今回更新対象に含まれているかチェック
|
* パスワードが今回更新対象に含まれているかチェック
|
||||||
*
|
*
|
||||||
* @param password 更新対象のパスワード
|
* @param password 更新対象のパスワード
|
||||||
* @param passwordConfirm 更新対象の確認用パスワード
|
* @param passwordConfirm 更新対象の確認用パスワード
|
||||||
* @return true:どちらもnullまたは空白の場合 false:それ以外
|
* @return true:どちらもnullまたは空白の場合 false:それ以外
|
||||||
*/
|
*/
|
||||||
private static boolean areBothBlank(String password, String passwordConfirm) {
|
private static boolean areBothBlank(String password, String passwordConfirm) {
|
||||||
return (password == null || password.isBlank()) && (passwordConfirm == null || passwordConfirm.isBlank());
|
return (password == null || password.isBlank()) && (passwordConfirm == null || passwordConfirm.isBlank());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* パスワードが今回更新対象に含まれているかチェック その2
|
* パスワードが今回更新対象に含まれているかチェック その2
|
||||||
*
|
*
|
||||||
* @param password 更新対象のパスワード
|
* @param password 更新対象のパスワード
|
||||||
* @param passwordConfirm 更新対象の確認用パスワード
|
* @param passwordConfirm 更新対象の確認用パスワード
|
||||||
* @return true: 問題なし false:どちらかがnullまたは空白の場合
|
* @return true: 問題なし false:どちらかがnullまたは空白の場合
|
||||||
*/
|
*/
|
||||||
private static boolean isEitherBlank(String password, String passwordConfirm) {
|
private static boolean isEitherBlank(String password, String passwordConfirm) {
|
||||||
return password == null || password.isBlank() || passwordConfirm == null || passwordConfirm.isBlank();
|
return password == null || password.isBlank() || passwordConfirm == null || passwordConfirm.isBlank();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,11 +35,13 @@
|
|||||||
</label>
|
</label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th class="header">本部名</th>
|
<th class="header">本部名</th>
|
||||||
<td>
|
<td>
|
||||||
<label>
|
<label>
|
||||||
<input maxlength="50" placeholder="本部名" th:field="*{nmHeadquarters}" type="text"id= "nmHeadquarters1" />
|
<input maxlength="50" placeholder="本部名" th:field="*{nmHeadquarters}" type="text"
|
||||||
|
id="nmHeadquarters1" />
|
||||||
</label>
|
</label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -47,18 +49,17 @@
|
|||||||
<th class="header"></th>
|
<th class="header"></th>
|
||||||
<td>
|
<td>
|
||||||
<label>
|
<label>
|
||||||
<select th:field="*{nmHeadquarters}"id= "nmHeadquarters2">
|
<select th:field="*{nmHeadquarters}" id="nmHeadquarters2">
|
||||||
<option value="">本部を選択</option>
|
<option value="">本部を選択</option>
|
||||||
<option
|
<option th:each="headquarters : ${headquartersFormList}"
|
||||||
th:each="headquarters : ${departmentFormList}"
|
|
||||||
th:selected="${insertDepartmentForm.idHeadquarters != null && headquarters.idHeadquarters == insertDepartmentForm.idHeadquarters}"
|
th:selected="${insertDepartmentForm.idHeadquarters != null && headquarters.idHeadquarters == insertDepartmentForm.idHeadquarters}"
|
||||||
th:text="${headquarters.nmHeadquarters}" th:value="${headquarters.nmHeadquarters}"
|
th:text="${headquarters.nmHeadquarters}" th:value="${headquarters.nmHeadquarters}">
|
||||||
>
|
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th class="header">部ID</th>
|
<th class="header">部ID</th>
|
||||||
<td>
|
<td>
|
||||||
@@ -67,11 +68,13 @@
|
|||||||
</label>
|
</label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th class="header">部名</th>
|
<th class="header">部名</th>
|
||||||
<td>
|
<td>
|
||||||
<label>
|
<label>
|
||||||
<input maxlength="50" placeholder="部名" th:field="*{nmDepartment}" type="text" id="nmDepartment1"/>
|
<input maxlength="50" placeholder="部名" th:field="*{nmDepartment}" type="text"
|
||||||
|
id="nmDepartment1" />
|
||||||
</label>
|
</label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -79,10 +82,9 @@
|
|||||||
<th class="header"></th>
|
<th class="header"></th>
|
||||||
<td>
|
<td>
|
||||||
<label>
|
<label>
|
||||||
<select th:field="*{nmDepartment}"id="nmDepartment2">
|
<select th:field="*{nmDepartment}" id="nmDepartment2">
|
||||||
<option value="">部を選択</option>
|
<option value="">部を選択</option>
|
||||||
<option
|
<option th:each="department : ${departmentFormList}"
|
||||||
th:each="department : ${departmentFormList}"
|
|
||||||
th:selected="${insertDepartmentForm.idDepartment != null && department.idDepartment == insertDepartmentForm.idDepartment}"
|
th:selected="${insertDepartmentForm.idDepartment != null && department.idDepartment == insertDepartmentForm.idDepartment}"
|
||||||
th:text="${department.nmDepartment}" th:value="${department.nmDepartment}">
|
th:text="${department.nmDepartment}" th:value="${department.nmDepartment}">
|
||||||
</option>
|
</option>
|
||||||
@@ -100,11 +102,12 @@
|
|||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th class="header">課名</th>
|
<th class="header">課名</th>
|
||||||
<td>
|
<td>
|
||||||
<label>
|
<label>
|
||||||
<input maxlength="50" placeholder="課名" th:field="*{nmDivision}" type="text" id="nmDivision1"/>
|
<input maxlength="50" placeholder="課名" th:field="*{nmDivision}" type="text" id="nmDivision1" />
|
||||||
</label>
|
</label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -115,9 +118,9 @@
|
|||||||
<th class="header"></th>
|
<th class="header"></th>
|
||||||
<td>
|
<td>
|
||||||
<label>
|
<label>
|
||||||
<select th:field="*{nmDivision}"id="nmDivision2">
|
<select th:field="*{nmDivision}" id="nmDivision2">
|
||||||
<option value="">課を選択</option>
|
<option value="">課を選択</option>
|
||||||
<option th:each="division : ${departmentFormList}"
|
<option th:each="division : ${divisionFormList}"
|
||||||
th:selected="${insertDepartmentForm.idDivision != null && division.idDivision == insertDepartmentForm.idDivision}"
|
th:selected="${insertDepartmentForm.idDivision != null && division.idDivision == insertDepartmentForm.idDivision}"
|
||||||
th:text="${division.nmDivision}" th:value="${division.nmDivision}">
|
th:text="${division.nmDivision}" th:value="${division.nmDivision}">
|
||||||
</option>
|
</option>
|
||||||
@@ -138,24 +141,49 @@
|
|||||||
<a href="showMenu">メニューに戻る</a>
|
<a href="showMenu">メニューに戻る</a>
|
||||||
</body>
|
</body>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
document.getElementById('insertDepartmentForm').addEventListener('submit',function(e){
|
const nmHeadquarters1 = document.getElementById('nmHeadquarters1');
|
||||||
if(document.getElementById('nmHeadquarters1').value!==""){
|
const nmHeadquarters2 = document.getElementById('nmHeadquarters2');
|
||||||
document.getElementById('nmHeadquarters2').removeAttribute('name');
|
|
||||||
}else if(document.getElementById('nmHeadquarters2').value!==""){
|
document.getElementById('insertDepartmentForm').addEventListener('submit', function (e) {
|
||||||
document.getElementById('nmHeadquarters1').removeAttribute('name');
|
if (nmHeadquarters1.value !== "") {
|
||||||
|
nmHeadquarters2.removeAttribute('name');
|
||||||
|
} else if (nmHeadquarters2.value !== "") {
|
||||||
|
nmHeadquarters1.removeAttribute('name');
|
||||||
}
|
}
|
||||||
if(document.getElementById('nmDepartment1').value!==""){
|
// ↓両方の入力欄が空で登録確認ボタンを押した時用どちらかの空の情報を送る
|
||||||
document.getElementById('nmDepartment2').removeAttribute('name');
|
// (どちらかじゃないと","が入ってしまう)
|
||||||
}else if(document.getElementById('nmDepartment2').value!==""){
|
else if (nmHeadquarters2.value === "" && nmHeadquarters1.value === "") {
|
||||||
document.getElementById('nmDepartment1').removeAttribute('name');
|
nmHeadquarters2.removeAttribute('name');
|
||||||
|
|
||||||
}
|
}
|
||||||
if(document.getElementById('nmDivision1').value!==""){
|
|
||||||
document.getElementById('nmDivision2').removeAttribute('name');
|
const nmDepartment1 = document.getElementById('nmDepartment1');
|
||||||
}else if(document.getElementById('nmDivision2').value!==""){
|
const nmDepartment2 = document.getElementById('nmDepartment2');
|
||||||
document.getElementById('nmDivision1').removeAttribute('name');
|
|
||||||
|
if (nmDepartment1.value !== "") {
|
||||||
|
nmDepartment2.removeAttribute('name');
|
||||||
|
} else if (nmDepartment2.value !== "") {
|
||||||
|
nmDepartment1.removeAttribute('name');
|
||||||
|
// ↓両方の入力欄が空で登録確認ボタンを押した時用どちらかの空の情報を送る
|
||||||
|
// (どちらかじゃないと","が入ってしまう)
|
||||||
|
} else if (nmDepartment1.value === "" && nmDepartment2.value === "") {
|
||||||
|
nmDepartment2.removeAttribute('name');
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
const nmDivision1 = document.getElementById('nmDivision1');
|
||||||
|
const nmDivision2 = document.getElementById('nmDivision2');
|
||||||
|
|
||||||
|
if (document.getElementById('nmDivision1').value !== "") {
|
||||||
|
document.getElementById('nmDivision2').removeAttribute('name');
|
||||||
|
} else if (document.getElementById('nmDivision2').value !== "") {
|
||||||
|
document.getElementById('nmDivision1').removeAttribute('name');
|
||||||
|
// ↓両方の入力欄が空で登録確認ボタンを押した時用どちらかの空の情報を送る
|
||||||
|
// (どちらかじゃないと","が入ってしまう)
|
||||||
|
} else if (nmDivision1.value === "" && nmDivision2.value === "") {
|
||||||
|
nmDivision2.removeAttribute('name');
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -152,7 +152,7 @@
|
|||||||
|
|
||||||
<label>
|
<label>
|
||||||
<select id="headquartersSelect" required="required" th:field="*{idHeadquarters}">
|
<select id="headquartersSelect" required="required" th:field="*{idHeadquarters}">
|
||||||
|
<option value="">本部を選択</option>
|
||||||
<option th:each="headquarters : ${departmentFormList}"
|
<option th:each="headquarters : ${departmentFormList}"
|
||||||
th:utext="
|
th:utext="
|
||||||
${headquarters.nmHeadquarters}"
|
${headquarters.nmHeadquarters}"
|
||||||
@@ -166,41 +166,19 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th class="header" >所属部</th>
|
<th class="header" >所属部</th>
|
||||||
<td>
|
<td>
|
||||||
<!-- プルダウン絞り込み実装用-->
|
|
||||||
<label>
|
<label>
|
||||||
<select id="departmentSelect" required="required" th:field="*{idDepartment}">
|
<select id="departmentSelect" required="required" th:field="*{idDepartment}">
|
||||||
<option value="">先に本部を選択してください</option>
|
<option value="">先に本部を選択してください</option>
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
<!-- プルダウン絞り込み無し実装用-->
|
|
||||||
<!-- <label>-->
|
|
||||||
<!-- <select id="departmentSelect" required="required" th:field="*{idDepartment}">-->
|
|
||||||
|
|
||||||
<!-- <option th:each="department : ${departmentFormList}"-->
|
|
||||||
<!-- th:utext="-->
|
|
||||||
<!-- ${department.nmDepartment}"-->
|
|
||||||
<!-- th:value="${department.idDepartment}">-->
|
|
||||||
<!-- </option>-->
|
|
||||||
|
|
||||||
<!-- </select>-->
|
|
||||||
<!-- </label>-->
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="header" >所属課</th>
|
<th class="header" >所属課</th>
|
||||||
<td>
|
<td>
|
||||||
<!-- プルダウン絞り込み無し実装用-->
|
|
||||||
<!-- <label>-->
|
|
||||||
<!-- <select id="divisionSelect" required="required" th:field="*{idDivision}">-->
|
|
||||||
<!-- <option th:each="division : ${departmentFormList}"-->
|
|
||||||
<!-- th:utext="-->
|
|
||||||
<!-- ${division.nmDivision}"-->
|
|
||||||
<!-- th:value="${division.idDivision}">-->
|
|
||||||
<!-- </option>-->
|
|
||||||
<!-- </select>-->
|
|
||||||
<!-- </label>-->
|
|
||||||
<!-- プルダウン絞り込み実装用-->
|
|
||||||
<label>
|
<label>
|
||||||
<select id="divisionSelect" required="required" th:field="*{idDivision}">
|
<select id="divisionSelect" required="required" th:field="*{idDivision}">
|
||||||
<option value="">先に部を選択してください</option>
|
<option value="">先に部を選択してください</option>
|
||||||
@@ -218,7 +196,7 @@
|
|||||||
</form>
|
</form>
|
||||||
<a href="showMenu">メニューに戻る</a>
|
<a href="showMenu">メニューに戻る</a>
|
||||||
</body>
|
</body>
|
||||||
<!--プルダウン絞り込み実装用(途中)-->
|
<!--プルダウン絞り込み実装用-->
|
||||||
<script>
|
<script>
|
||||||
const headquartersSelect = document.getElementById('headquartersSelect');
|
const headquartersSelect = document.getElementById('headquartersSelect');
|
||||||
const departmentSelect = document.getElementById('departmentSelect');
|
const departmentSelect = document.getElementById('departmentSelect');
|
||||||
@@ -231,7 +209,7 @@ headquartersSelect.addEventListener('change', function() {
|
|||||||
divisionSelect.disabled = true;
|
divisionSelect.disabled = true;
|
||||||
departmentSelect.innerHTML = '<option value="">-- 部を選択 --</option>';
|
departmentSelect.innerHTML = '<option value="">-- 部を選択 --</option>';
|
||||||
divisionSelect.innerHTML = '<option value="">-- 先に部を選択してください --</option>';
|
divisionSelect.innerHTML = '<option value="">-- 先に部を選択してください --</option>';
|
||||||
console.log("koko");
|
|
||||||
if (!id_headquarters) return;
|
if (!id_headquarters) return;
|
||||||
fetch(`insertEmployeeInput/searchDepartment?id_headquarters=${id_headquarters}`,{
|
fetch(`insertEmployeeInput/searchDepartment?id_headquarters=${id_headquarters}`,{
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
@@ -241,7 +219,6 @@ headquartersSelect.addEventListener('change', function() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
.then(res => {
|
.then(res => {
|
||||||
console.log("koko");
|
|
||||||
return res.json();
|
return res.json();
|
||||||
})
|
})
|
||||||
.then(list => {
|
.then(list => {
|
||||||
@@ -256,6 +233,33 @@ headquartersSelect.addEventListener('change', function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
departmentSelect.addEventListener('change', function() {
|
||||||
|
const id_department = this.value;
|
||||||
|
|
||||||
|
divisionSelect.disabled = true;
|
||||||
|
divisionSelect.innerHTML = '<option value="">-- 課を選択 --</option>';
|
||||||
|
if (!id_department) return;
|
||||||
|
fetch(`/insertEmployeeInput/searchDepartment/searchDivision?id_department=${id_department}`,{
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
'Accept': 'application/json'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
.then(res => {
|
||||||
|
return res.json();
|
||||||
|
})
|
||||||
|
.then(list => {
|
||||||
|
divisionSelect.disabled = false;
|
||||||
|
list.forEach(form => {
|
||||||
|
const opt = document.createElement('option');
|
||||||
|
opt.value = form.idDivision;
|
||||||
|
opt.textContent = form.nmDivision;
|
||||||
|
divisionSelect.appendChild(opt);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
type="text"/>
|
type="text"/>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<!-- 現状は課のみで検索ができる仕様-->
|
||||||
<tr>
|
<tr>
|
||||||
<td class="btnArea" colspan="2">
|
<td class="btnArea" colspan="2">
|
||||||
<input type="submit" value="検索"/>
|
<input type="submit" value="検索"/>
|
||||||
|
|||||||
@@ -71,6 +71,7 @@
|
|||||||
th:text="${division.nmDivision}"
|
th:text="${division.nmDivision}"
|
||||||
th:value="${division.idDivision}">
|
th:value="${division.idDivision}">
|
||||||
</option>
|
</option>
|
||||||
|
<!-- 現状課だけでの検索の実装-->
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -126,6 +127,7 @@
|
|||||||
${employeeInfoForm.nmDepartment}+'<br/>・'+
|
${employeeInfoForm.nmDepartment}+'<br/>・'+
|
||||||
${employeeInfoForm.nmDivision}"
|
${employeeInfoForm.nmDivision}"
|
||||||
></td>
|
></td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
<!-- 更新フォーム -->
|
<!-- 更新フォーム -->
|
||||||
<form action="showUpdateEmployee" method="post" style="display: inline;">
|
<form action="showUpdateEmployee" method="post" style="display: inline;">
|
||||||
|
|||||||
@@ -3,206 +3,245 @@
|
|||||||
|
|
||||||
<head>
|
<head>
|
||||||
|
|
||||||
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
|
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
|
||||||
<!-- 外部のスクリプトファイルを読み込む -->
|
<!-- 外部のスクリプトファイルを読み込む -->
|
||||||
<script th:src="@{/js/common.js}"></script>
|
<script th:src="@{/js/common.js}"></script>
|
||||||
<!-- CSSの読み込み -->
|
<!-- CSSの読み込み -->
|
||||||
<link rel="stylesheet" th:href="@{/css/all.css}">
|
<link rel="stylesheet" th:href="@{/css/all.css}">
|
||||||
<link rel=stylesheet th:href="@{/css/style.css}" type="text/css">
|
<link rel=stylesheet th:href="@{/css/style.css}" type="text/css">
|
||||||
<title>社員情報更新</title>
|
<title>社員情報更新</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<h1>
|
<h1>
|
||||||
社員情報更新
|
社員情報更新
|
||||||
<div class="rightSection">
|
<div class="rightSection">
|
||||||
<span class="loginInfo">ログイン者名:<span th:text="${session.loginUser.nmEmployee}"></span></span>
|
<span class="loginInfo">ログイン者名:<span th:text="${session.loginUser.nmEmployee}"></span></span>
|
||||||
<button class="logoutButton" onclick="logoutSubmit()">ログアウト</button>
|
<button class="logoutButton" onclick="logoutSubmit()">ログアウト</button>
|
||||||
</div>
|
</div>
|
||||||
</h1>
|
</h1>
|
||||||
<form action="/updateEmployeeResult"
|
<form action="/updateEmployeeResult" method="post" onsubmit="return confirm('本当によろしいですか?');"
|
||||||
method="post"
|
th:object="${updateEmployeeInfoForm}">
|
||||||
onsubmit="return confirm('本当によろしいですか?');"
|
<div class="msgBox error" th:if="${messageError != null}">
|
||||||
th:object="${updateEmployeeInfoForm}"
|
<span class="error" th:each="message : ${messageError.message}" th:text="${message}"></span>
|
||||||
>
|
</div>
|
||||||
<div class="msgBox error" th:if="${messageError != null}">
|
<table>
|
||||||
<span class="error" th:each="message : ${messageError.message}" th:text="${message}"></span>
|
<tr>
|
||||||
</div>
|
<th class="header">社員ID</th>
|
||||||
<table>
|
<td>
|
||||||
<tr>
|
<label>
|
||||||
<th class="header">社員ID</th>
|
<input class="readOnly" readonly="readonly" th:field="*{idEmployee}" type="text" />
|
||||||
<td>
|
</label>
|
||||||
<label>
|
</td>
|
||||||
<input class="readOnly"
|
</tr>
|
||||||
readonly="readonly"
|
<tr>
|
||||||
th:field="*{idEmployee}"
|
<th class="header">社員名</th>
|
||||||
type="text"
|
<td>
|
||||||
/>
|
<label>
|
||||||
</label>
|
<input maxlength="50" placeholder="社員名" required="required" th:field="*{nmEmployee}"
|
||||||
</td>
|
type="text" />
|
||||||
</tr>
|
</label>
|
||||||
<tr>
|
</td>
|
||||||
<th class="header">社員名</th>
|
</tr>
|
||||||
<td>
|
<tr>
|
||||||
<label>
|
<th class="header">社員名フリガナ</th>
|
||||||
<input maxlength="50"
|
<td>
|
||||||
placeholder="社員名"
|
<label>
|
||||||
required="required"
|
<input maxlength="50" oninput="convertToKatakana(this)" placeholder="フリガナ" required="required"
|
||||||
th:field="*{nmEmployee}"
|
th:field="*{knEmployee}" type="text" />
|
||||||
type="text"
|
</label>
|
||||||
/>
|
</td>
|
||||||
</label>
|
</tr>
|
||||||
</td>
|
<tr>
|
||||||
</tr>
|
<th class="header">メールアドレス</th>
|
||||||
<tr>
|
<td>
|
||||||
<th class="header">社員名フリガナ</th>
|
<label>
|
||||||
<td>
|
<input maxlength="100" placeholder="メールアドレス" required="required" th:field="*{mailAddress}"
|
||||||
<label>
|
type="email" />
|
||||||
<input maxlength="50"
|
</label>
|
||||||
oninput="convertToKatakana(this)"
|
</td>
|
||||||
placeholder="フリガナ"
|
</tr>
|
||||||
required="required"
|
<tr>
|
||||||
th:field="*{knEmployee}"
|
<th class="header">パスワード</th>
|
||||||
type="text"
|
<td>
|
||||||
/>
|
<label>
|
||||||
</label>
|
<input pattern="^(?=.*?[a-zA-Z])(?=.*?\d)[a-zA-Z\d]{3,10}$" placeholder="パスワード"
|
||||||
</td>
|
th:field="*{password}" type="password" />
|
||||||
</tr>
|
</label>
|
||||||
<tr>
|
</td>
|
||||||
<th class="header">メールアドレス</th>
|
</tr>
|
||||||
<td>
|
<!-- *** Chrome等のブラウザの場合自動でセットされる可能性があるので注意書きを外にも *** -->
|
||||||
<label>
|
<tr>
|
||||||
<input maxlength="100"
|
<th></th>
|
||||||
placeholder="メールアドレス"
|
<td>
|
||||||
required="required"
|
<span style="font-size:8pt;
|
||||||
th:field="*{mailAddress}"
|
|
||||||
type="email"
|
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th class="header">パスワード</th>
|
|
||||||
<td>
|
|
||||||
<label>
|
|
||||||
<input pattern="^(?=.*?[a-zA-Z])(?=.*?\d)[a-zA-Z\d]{3,10}$"
|
|
||||||
placeholder="パスワード"
|
|
||||||
th:field="*{password}"
|
|
||||||
type="password"
|
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<!-- *** Chrome等のブラウザの場合自動でセットされる可能性があるので注意書きを外にも *** -->
|
|
||||||
<tr>
|
|
||||||
<th></th>
|
|
||||||
<td>
|
|
||||||
<span style="font-size:8pt;
|
|
||||||
font-weight:bold;
|
font-weight:bold;
|
||||||
color:red;">
|
color:red;">
|
||||||
※半角英数字をそれぞれ1種類以上含む3-10文字
|
※半角英数字をそれぞれ1種類以上含む3-10文字
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="header">パスワード確認用</th>
|
<th class="header">パスワード確認用</th>
|
||||||
<td>
|
<td>
|
||||||
<label>
|
<label>
|
||||||
<input pattern="^(?=.*?[a-zA-Z])(?=.*?\d)[a-zA-Z\d]{3,10}$"
|
<input pattern="^(?=.*?[a-zA-Z])(?=.*?\d)[a-zA-Z\d]{3,10}$" placeholder="パスワード確認用"
|
||||||
placeholder="パスワード確認用"
|
th:field="*{passwordConfirm}" type="password" />
|
||||||
th:field="*{passwordConfirm}"
|
</label>
|
||||||
type="password"
|
</td>
|
||||||
/>
|
</tr>
|
||||||
</label>
|
<tr>
|
||||||
</td>
|
<th class="header">管理者権限</th>
|
||||||
</tr>
|
<td>
|
||||||
<tr>
|
<label>
|
||||||
<th class="header">管理者権限</th>
|
<input id="adminAuth1" name="adminAuth" th:checked="${updateEmployeeInfoForm.adminAuth == 1}"
|
||||||
<td>
|
type="radio" value="1"> 管理者権限
|
||||||
<label>
|
</label>
|
||||||
<input id="adminAuth1" name="adminAuth" th:checked="${updateEmployeeInfoForm.adminAuth == 1}"
|
<label>
|
||||||
type="radio"
|
<input id="adminAuth0" name="adminAuth"
|
||||||
value="1"> 管理者権限
|
th:checked="${updateEmployeeInfoForm.adminAuth == null or updateEmployeeInfoForm.adminAuth == 0}"
|
||||||
</label>
|
type="radio" value="0">
|
||||||
<label>
|
一般権限
|
||||||
<input id="adminAuth0" name="adminAuth"
|
</label>
|
||||||
th:checked="${updateEmployeeInfoForm.adminAuth == null or updateEmployeeInfoForm.adminAuth == 0}"
|
</td>
|
||||||
type="radio"
|
</tr>
|
||||||
value="0">
|
<tr>
|
||||||
一般権限
|
|
||||||
</label>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
|
|
||||||
<th class="header" style="vertical-align: top;">所属部署</th>
|
<th class="header">所属本部</th>
|
||||||
<td>
|
<td>
|
||||||
|
|
||||||
<label>
|
<label>
|
||||||
<select required="required" >
|
<select id="headquartersSelect" required="required" th:field="*{idHeadquarters}">
|
||||||
|
<option value="">本部を選択</option>
|
||||||
<option th:each="headquarters : ${departmentFormList}"
|
<option th:each="headquarters : ${departmentFormList}" th:utext="
|
||||||
th:utext="
|
${headquarters.nmHeadquarters}" th:value="${headquarters.idHeadquarters}">
|
||||||
${headquarters.nmHeadquarters}"
|
</option>
|
||||||
th:value="${headquarters.idHeadquarters}">
|
|
||||||
</option>
|
</select>
|
||||||
|
</label>
|
||||||
</select>
|
</td>
|
||||||
</label>
|
</tr>
|
||||||
<br>
|
<tr>
|
||||||
<label>
|
<th class="header">所属部</th>
|
||||||
<select required="required" >
|
<td>
|
||||||
<option th:each="department : ${departmentFormList}"
|
<label>
|
||||||
|
<select id="departmentSelect" required="required">
|
||||||
th:utext="
|
<option value="">先に本部を選択してください</option>
|
||||||
${department.nmDepartment}"
|
|
||||||
th:value="${department.idDepartment}">
|
</select>
|
||||||
</option>
|
</label>
|
||||||
|
|
||||||
</select>
|
</td>
|
||||||
</label>
|
</tr>
|
||||||
<br>
|
<tr>
|
||||||
<label>
|
<th class="header">所属課</th>
|
||||||
<select required="required" th:field="*{idDivision}">
|
<td>
|
||||||
<option th:each="division : ${departmentFormList}"
|
|
||||||
th:utext="
|
<label>
|
||||||
${division.nmDivision}"
|
<select id="divisionSelect" required="required" th:field="*{idDivision}">
|
||||||
th:value="${division.idDivision}">
|
<option value="">先に部を選択してください</option>
|
||||||
</option>
|
</select>
|
||||||
</select>
|
</label>
|
||||||
</label>
|
|
||||||
|
</td>
|
||||||
</td>
|
</tr>
|
||||||
</tr>
|
<tr>
|
||||||
<tr>
|
<td class="btnArea" colspan="2">
|
||||||
<td class="btnArea" colspan="2">
|
<input type="submit" value="更新" />
|
||||||
<input type="submit" value="更新"/>
|
</td>
|
||||||
</td>
|
</tr>
|
||||||
</tr>
|
</table>
|
||||||
</table>
|
</form>
|
||||||
</form>
|
<a href="javascript:selectSubmit()">一覧に戻る</a>
|
||||||
<a href="javascript:selectSubmit()">一覧に戻る</a>
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
function selectSubmit() {
|
function selectSubmit() {
|
||||||
const form = document.createElement('form');
|
const form = document.createElement('form');
|
||||||
form.setAttribute('method', 'post');
|
form.setAttribute('method', 'post');
|
||||||
form.setAttribute('action', 'selectAll');
|
form.setAttribute('action', 'selectAll');
|
||||||
|
|
||||||
// 動的送信用のHidden
|
// 動的送信用のHidden
|
||||||
// 動的にFormを作成する場合は何かしら送信しないと、正しく動作しない
|
// 動的にFormを作成する場合は何かしら送信しないと、正しく動作しない
|
||||||
const inputField = document.createElement("input");
|
const inputField = document.createElement("input");
|
||||||
inputField.setAttribute("type", "hidden");
|
inputField.setAttribute("type", "hidden");
|
||||||
inputField.setAttribute("value", "selectAll");
|
inputField.setAttribute("value", "selectAll");
|
||||||
|
|
||||||
|
form.appendChild(inputField);
|
||||||
|
|
||||||
|
// フォームをDOMに追加
|
||||||
|
document.body.appendChild(form);
|
||||||
|
|
||||||
|
form.submit();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const headquartersSelect = document.getElementById('headquartersSelect');
|
||||||
|
const departmentSelect = document.getElementById('departmentSelect');
|
||||||
|
const divisionSelect = document.getElementById('divisionSelect');
|
||||||
|
|
||||||
|
headquartersSelect.addEventListener('change', function () {
|
||||||
|
const id_headquarters = this.value;
|
||||||
|
|
||||||
|
departmentSelect.disabled = true;
|
||||||
|
divisionSelect.disabled = true;
|
||||||
|
departmentSelect.innerHTML = '<option value="">-- 部を選択 --</option>';
|
||||||
|
divisionSelect.innerHTML = '<option value="">-- 先に部を選択してください --</option>';
|
||||||
|
|
||||||
|
if (!id_headquarters) return;
|
||||||
|
fetch(`updateEmployeeInput/searchDepartment?id_headquarters=${id_headquarters}`, {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
'Accept': 'application/json'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
.then(res => {
|
||||||
|
return res.json();
|
||||||
|
})
|
||||||
|
.then(list => {
|
||||||
|
departmentSelect.disabled = false;
|
||||||
|
list.forEach(form => {
|
||||||
|
const opt = document.createElement('option');
|
||||||
|
opt.value = form.idDepartment;
|
||||||
|
opt.textContent = form.nmDepartment;
|
||||||
|
departmentSelect.appendChild(opt);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
departmentSelect.addEventListener('change', function () {
|
||||||
|
const id_department = this.value;
|
||||||
|
|
||||||
|
divisionSelect.disabled = true;
|
||||||
|
divisionSelect.innerHTML = '<option value="">-- 課を選択 --</option>';
|
||||||
|
if (!id_department) return;
|
||||||
|
fetch(`/updateEmployeeInput/searchDepartment/searchDivision?id_department=${id_department}`, {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
'Accept': 'application/json'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
.then(res => {
|
||||||
|
return res.json();
|
||||||
|
})
|
||||||
|
.then(list => {
|
||||||
|
divisionSelect.disabled = false;
|
||||||
|
list.forEach(form => {
|
||||||
|
const opt = document.createElement('option');
|
||||||
|
opt.value = form.idDivision;
|
||||||
|
opt.textContent = form.nmDivision;
|
||||||
|
divisionSelect.appendChild(opt);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
form.appendChild(inputField);
|
|
||||||
|
|
||||||
// フォームをDOMに追加
|
|
||||||
document.body.appendChild(form);
|
|
||||||
|
|
||||||
form.submit();
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
Reference in New Issue
Block a user