Compare commits
10 Commits
master
...
95e1bbb06c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
95e1bbb06c | ||
|
|
e6de486548 | ||
|
|
d21e3eee9f | ||
|
|
2e748dc1cb | ||
|
|
d2c78b12aa | ||
|
|
178690c7b9 | ||
|
|
8b44c7a7b6 | ||
|
|
50caa2eef4 | ||
|
|
d12cf13982 | ||
|
|
f9c41459e7 |
1
pom.xml
1
pom.xml
@@ -17,6 +17,7 @@
|
|||||||
<description>Demo project for Spring Boot</description>
|
<description>Demo project for Spring Boot</description>
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>17</java.version>
|
<java.version>17</java.version>
|
||||||
|
<lombok.version>1.18.34</lombok.version>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -3,19 +3,10 @@ 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
|
|
||||||
*/
|
|
||||||
private final Integer idDepartment;
|
private final Integer idDepartment;
|
||||||
/**
|
|
||||||
* 部署名
|
|
||||||
*/
|
|
||||||
private final String nmDepartment;
|
private final String nmDepartment;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,39 +3,15 @@ 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 Employee {
|
public class Employee {
|
||||||
/**
|
|
||||||
* 社員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
|
|
||||||
*/
|
|
||||||
private final Integer idDepartment;
|
private final Integer idDepartment;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,28 +1,14 @@
|
|||||||
/*
|
|
||||||
* EmployeeInfo.java
|
|
||||||
* 作成 IT-College 2016
|
|
||||||
*------------------------------------------------------------
|
|
||||||
* Copyright(c) Rhizome Inc. All Rights Reserved.
|
|
||||||
*/
|
|
||||||
package com.example.rhizome.app.domain.model;
|
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 EmployeeInfo {
|
public class EmployeeInfo {
|
||||||
|
|
||||||
/**
|
|
||||||
* 社員情報
|
|
||||||
*/
|
|
||||||
private final Employee employee;
|
private final Employee employee;
|
||||||
/**
|
|
||||||
* 部署名
|
|
||||||
*/
|
|
||||||
private final Department department;
|
private final Department department;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,20 +3,12 @@ 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 LoginInfo {
|
public class LoginInfo {
|
||||||
/**
|
|
||||||
* メールアドレス
|
|
||||||
*/
|
|
||||||
private String mailAddress;
|
private String mailAddress;
|
||||||
/**
|
|
||||||
* パスワード
|
|
||||||
*/
|
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,48 +3,23 @@ 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 LoginUser {
|
public class LoginUser {
|
||||||
/**
|
|
||||||
* 社員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
|
|
||||||
*/
|
|
||||||
private final Integer idDepartment;
|
private final Integer idDepartment;
|
||||||
|
|
||||||
/**
|
|
||||||
* ログインユーザが管理者か
|
|
||||||
*
|
|
||||||
* @return true:管理者 false:一般権限
|
|
||||||
*/
|
|
||||||
public boolean isAdminUser() {
|
public boolean isAdminUser() {
|
||||||
return getAdminAuth() == 1;
|
return getAdminAuth() == 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,19 +3,11 @@ 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 SearchConditionDepartment {
|
public class SearchConditionDepartment {
|
||||||
/**
|
|
||||||
* 部署ID
|
|
||||||
*/
|
|
||||||
private final Integer idDepartment;
|
private final Integer idDepartment;
|
||||||
/**
|
|
||||||
* 部署名
|
|
||||||
*/
|
|
||||||
private final String nmDepartment;
|
private final String nmDepartment;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,31 +3,13 @@ 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 SearchConditionEmployee {
|
public class SearchConditionEmployee {
|
||||||
/**
|
|
||||||
* 社員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
|
|
||||||
*/
|
|
||||||
private final Integer idDepartment;
|
private final Integer idDepartment;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package com.example.rhizome.app.domain.service;
|
package com.example.rhizome.app.domain.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.example.rhizome.app.domain.model.EmployeeInfo;
|
import com.example.rhizome.app.domain.model.EmployeeInfo;
|
||||||
import com.example.rhizome.app.domain.model.SearchConditionEmployee;
|
import com.example.rhizome.app.domain.model.SearchConditionEmployee;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface SearchEmployeeInfo {
|
public interface SearchEmployeeInfo {
|
||||||
List<EmployeeInfo> selectAll();
|
List<EmployeeInfo> selectAll();
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +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;
|
||||||
* Employee レコード削除関連の機能を持つサービス
|
import com.example.rhizome.app.infra.repository.EmployeeRepository;
|
||||||
*/
|
|
||||||
@Service
|
@Service
|
||||||
@Transactional
|
@Transactional
|
||||||
public class DeleteEmployeeImpl implements DeleteEmployee {
|
public class DeleteEmployeeImpl implements DeleteEmployee {
|
||||||
@@ -20,12 +18,6 @@ public class DeleteEmployeeImpl implements DeleteEmployee {
|
|||||||
this.employeeRepository = employeeRepository;
|
this.employeeRepository = employeeRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* idEmployee を元に employee データを削除
|
|
||||||
*
|
|
||||||
* @param idEmployee 削除対象のidEmployee
|
|
||||||
*/
|
|
||||||
public void deleteEmployee(Integer idEmployee) {
|
public void deleteEmployee(Integer idEmployee) {
|
||||||
employeeRepository.deleteById(idEmployee);
|
employeeRepository.deleteById(idEmployee);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,15 @@
|
|||||||
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.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
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;
|
||||||
import com.example.rhizome.app.domain.service.Login;
|
import com.example.rhizome.app.domain.service.Login;
|
||||||
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||||
import com.example.rhizome.app.infra.repository.EmployeeRepository;
|
import com.example.rhizome.app.infra.repository.EmployeeRepository;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ログイン系の機能を集約させるサービスクラスです。
|
|
||||||
*/
|
|
||||||
@Service
|
@Service
|
||||||
@Transactional
|
@Transactional
|
||||||
public class LoginImpl implements Login {
|
public class LoginImpl implements Login {
|
||||||
@@ -23,15 +21,7 @@ public class LoginImpl implements Login {
|
|||||||
this.employeeRepository = employeeRepository;
|
this.employeeRepository = employeeRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* メールアドレス、パスワードでログイン判定を行う
|
|
||||||
*
|
|
||||||
* @param loginInfo ログインを試みるアカウント
|
|
||||||
* @return loginUser のインスタンス
|
|
||||||
*/
|
|
||||||
public LoginUser doLogin(LoginInfo loginInfo) {
|
public LoginUser doLogin(LoginInfo loginInfo) {
|
||||||
// ログイン情報を元にログインユーザーを取得
|
|
||||||
return employeeRepository
|
return employeeRepository
|
||||||
.findByMailAddressAndPassword(loginInfo.getMailAddress(), loginInfo.getPassword())
|
.findByMailAddressAndPassword(loginInfo.getMailAddress(), loginInfo.getPassword())
|
||||||
.orElse(new EmployeeEntity())
|
.orElse(new EmployeeEntity())
|
||||||
@@ -39,14 +29,7 @@ public class LoginImpl implements Login {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* メールアドレス、パスワードでログイン判定を行う
|
|
||||||
*
|
|
||||||
* @param loginInfo ログインを試みるアカウント
|
|
||||||
* @return loginUser のインスタンス
|
|
||||||
*/
|
|
||||||
public boolean canLogin(LoginInfo loginInfo) {
|
public boolean canLogin(LoginInfo loginInfo) {
|
||||||
// ログイン情報を元にログインユーザーを取得
|
|
||||||
return employeeRepository
|
return employeeRepository
|
||||||
.findByMailAddressAndPassword(loginInfo.getMailAddress(), loginInfo.getPassword())
|
.findByMailAddressAndPassword(loginInfo.getMailAddress(), loginInfo.getPassword())
|
||||||
.isPresent();
|
.isPresent();
|
||||||
|
|||||||
@@ -1,17 +1,14 @@
|
|||||||
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.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import com.example.rhizome.app.domain.model.Employee;
|
import com.example.rhizome.app.domain.model.Employee;
|
||||||
import com.example.rhizome.app.domain.service.RegisterEmployee;
|
import com.example.rhizome.app.domain.service.RegisterEmployee;
|
||||||
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||||
import com.example.rhizome.app.infra.repository.EmployeeRepository;
|
import com.example.rhizome.app.infra.repository.EmployeeRepository;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Employee テーブルの登録系の機能を集約させるサービスクラスです。
|
|
||||||
*/
|
|
||||||
@Service
|
@Service
|
||||||
@Transactional
|
@Transactional
|
||||||
public class RegisterEmployeeImpl implements RegisterEmployee {
|
public class RegisterEmployeeImpl implements RegisterEmployee {
|
||||||
@@ -23,11 +20,6 @@ public class RegisterEmployeeImpl implements RegisterEmployee {
|
|||||||
this.employeeRepository = employeeRepository;
|
this.employeeRepository = employeeRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* employee インスタンスの内容を登録する
|
|
||||||
*
|
|
||||||
* @param employee 登録対象のデータ
|
|
||||||
*/
|
|
||||||
public void registerEmployee(Employee employee) {
|
public void registerEmployee(Employee employee) {
|
||||||
employeeRepository.save(EmployeeEntity.convertFrom(employee));
|
employeeRepository.save(EmployeeEntity.convertFrom(employee));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,82 +1,75 @@
|
|||||||
package com.example.rhizome.app.domain.service.impl;
|
package com.example.rhizome.app.domain.service.impl;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import com.example.rhizome.app.domain.model.Department;
|
import com.example.rhizome.app.domain.model.Department;
|
||||||
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.infra.entity.DepartmentEntity;
|
import com.example.rhizome.app.infra.entity.DepartmentEntity;
|
||||||
import com.example.rhizome.app.infra.repository.DepartmentRepository;
|
import com.example.rhizome.app.infra.repository.DepartmentRepository;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.data.jpa.domain.Specification;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 部署情報検索系の機能を集約させるサービスクラスです。
|
|
||||||
*/
|
|
||||||
@Service
|
@Service
|
||||||
@Transactional
|
@Transactional
|
||||||
public class SearchDepartmentImpl implements SearchDepartment {
|
public class SearchDepartmentImpl implements SearchDepartment {
|
||||||
|
|
||||||
DepartmentRepository departmentRepository;
|
DepartmentRepository departmentRepository;
|
||||||
|
|
||||||
/**
|
|
||||||
* コンストラクタ
|
|
||||||
*
|
|
||||||
* @param departmentRepository DI対象
|
|
||||||
*/
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public SearchDepartmentImpl(DepartmentRepository departmentRepository) {
|
public SearchDepartmentImpl(DepartmentRepository departmentRepository) {
|
||||||
this.departmentRepository = departmentRepository;
|
this.departmentRepository = departmentRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 部署情報を全件取得する
|
|
||||||
*
|
|
||||||
* @return 取得した部署情報レコード全件
|
|
||||||
*/
|
|
||||||
public List<Department> selectAll() {
|
public List<Department> selectAll() {
|
||||||
return DepartmentEntity.createDepartmentList(departmentRepository.findAll());
|
return DepartmentEntity.createDepartmentList(departmentRepository.findAll());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* searchConditionDepartment の情報を元に Department のレコードを取得
|
|
||||||
*
|
|
||||||
* @param searchConditionDepartment 検索条件
|
|
||||||
* @return 検索結果のレコード
|
|
||||||
*/
|
|
||||||
public List<Department> searchBy(SearchConditionDepartment searchConditionDepartment) {
|
public List<Department> searchBy(SearchConditionDepartment searchConditionDepartment) {
|
||||||
// 動的に検索条件を絞り込む
|
|
||||||
// Specification は Criteria API の Predicate をラップしたもの
|
|
||||||
return DepartmentEntity
|
return DepartmentEntity
|
||||||
.createDepartmentList(
|
.createDepartmentList(
|
||||||
departmentRepository.findAll(Specification
|
departmentRepository.findAll(Specification
|
||||||
.where(DepartmentRepository.idDepartmentEqual(searchConditionDepartment.getIdDepartment()))
|
.where(DepartmentRepository
|
||||||
.and(DepartmentRepository.nmDepartmentEqual(searchConditionDepartment.getNmDepartment()))
|
.idDepartmentEqual(searchConditionDepartment.getIdDepartment()))
|
||||||
)
|
.and(DepartmentRepository
|
||||||
);
|
.nmDepartmentEqual(searchConditionDepartment.getNmDepartment()))));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* searchConditionDepartment の情報を元に Department のレコードを取得
|
|
||||||
* 部分一致検索
|
|
||||||
*
|
|
||||||
* @param searchConditionDepartment 検索条件
|
|
||||||
* @return 検索結果のレコード
|
|
||||||
*/
|
|
||||||
public List<Department> searchByWithLike(SearchConditionDepartment searchConditionDepartment) {
|
public List<Department> searchByWithLike(SearchConditionDepartment searchConditionDepartment) {
|
||||||
// 動的に検索条件を絞り込む
|
|
||||||
// Specification は Criteria API の Predicate をラップしたもの
|
|
||||||
return DepartmentEntity
|
return DepartmentEntity
|
||||||
.createDepartmentList(
|
.createDepartmentList(
|
||||||
departmentRepository.findAll(Specification
|
departmentRepository.findAll(Specification
|
||||||
.where(DepartmentRepository.idDepartmentEqual(searchConditionDepartment.getIdDepartment()))
|
.where(DepartmentRepository
|
||||||
.and(DepartmentRepository.nmDepartmentLike(searchConditionDepartment.getNmDepartment()))
|
.idDepartmentEqual(searchConditionDepartment.getIdDepartment()))
|
||||||
)
|
.and(DepartmentRepository
|
||||||
);
|
.nmDepartmentLike(searchConditionDepartment.getNmDepartment()))));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Department> searchByDepartmentName(SearchConditionDepartment searchConditionDepartment) {
|
||||||
|
|
||||||
|
return DepartmentEntity
|
||||||
|
.createDepartmentList(
|
||||||
|
departmentRepository.findAll(Specification
|
||||||
|
.where(DepartmentRepository
|
||||||
|
.nmDepartmentEqual(searchConditionDepartment.getNmDepartment()))));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Department> searchByDepartmentId(SearchConditionDepartment searchConditionDepartment) {
|
||||||
|
|
||||||
|
return DepartmentEntity
|
||||||
|
.createDepartmentList(
|
||||||
|
departmentRepository.findAll(Specification
|
||||||
|
.where(DepartmentRepository
|
||||||
|
.idDepartmentEqual(searchConditionDepartment.getIdDepartment()))));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,17 @@
|
|||||||
package com.example.rhizome.app.domain.service.impl;
|
package com.example.rhizome.app.domain.service.impl;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import com.example.rhizome.app.domain.model.Employee;
|
import com.example.rhizome.app.domain.model.Employee;
|
||||||
import com.example.rhizome.app.domain.model.LoginUser;
|
import com.example.rhizome.app.domain.model.LoginUser;
|
||||||
import com.example.rhizome.app.domain.service.SearchEmployee;
|
import com.example.rhizome.app.domain.service.SearchEmployee;
|
||||||
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||||
import com.example.rhizome.app.infra.repository.EmployeeRepository;
|
import com.example.rhizome.app.infra.repository.EmployeeRepository;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Employee テーブル検索系の機能を集約させるサービスクラスです。
|
|
||||||
*/
|
|
||||||
@Service
|
@Service
|
||||||
@Transactional
|
@Transactional
|
||||||
public class SearchEmployeeImpl implements SearchEmployee {
|
public class SearchEmployeeImpl implements SearchEmployee {
|
||||||
@@ -25,44 +23,19 @@ public class SearchEmployeeImpl implements SearchEmployee {
|
|||||||
this.employeeRepository = employeeRepository;
|
this.employeeRepository = employeeRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* mailAddress を元に Employee Table を検索します。
|
|
||||||
*
|
|
||||||
* @param mailAddress 検索対象の mailAddress
|
|
||||||
* @return Table から取得したレコードの情報
|
|
||||||
*/
|
|
||||||
public List<Employee> searchEmployee(String mailAddress) {
|
public List<Employee> searchEmployee(String mailAddress) {
|
||||||
return EmployeeEntity.createEmployeeList(employeeRepository.findByMailAddress(mailAddress).stream().toList());
|
return EmployeeEntity.createEmployeeList(employeeRepository.findByMailAddress(mailAddress).stream().toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* mailAddress を元に ログイン者の情報 を検索します。
|
|
||||||
*
|
|
||||||
* @param mailAddress 検索対象の mailAddress
|
|
||||||
* @return login者の情報
|
|
||||||
*/
|
|
||||||
public LoginUser searchLoginUser(String mailAddress) {
|
public LoginUser searchLoginUser(String mailAddress) {
|
||||||
return employeeRepository.findByMailAddress(mailAddress).orElse(new EmployeeEntity()).createLoginUser();
|
return employeeRepository.findByMailAddress(mailAddress).orElse(new EmployeeEntity()).createLoginUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* idEmployee を元に Employee Table を検索します。
|
|
||||||
*
|
|
||||||
* @param idEmployee 検索対象の idEmployee
|
|
||||||
* @return Table から取得したレコードの情報
|
|
||||||
*/
|
|
||||||
public Employee searchEmployeeByIdEmployee(Integer idEmployee) {
|
public Employee searchEmployeeByIdEmployee(Integer idEmployee) {
|
||||||
return EmployeeEntity.createEmployee(employeeRepository.findByIdEmployee(idEmployee).orElse(new EmployeeEntity()));
|
return EmployeeEntity
|
||||||
|
.createEmployee(employeeRepository.findByIdEmployee(idEmployee).orElse(new EmployeeEntity()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* idDepartment を元に Employee Table を検索します。
|
|
||||||
*
|
|
||||||
* @param idDepartment 部署ID
|
|
||||||
* @return Table から取得したレコードの情報
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public List<Employee> searchEmployeeByIdDepartment(Integer idDepartment) {
|
public List<Employee> searchEmployeeByIdDepartment(Integer idDepartment) {
|
||||||
return EmployeeEntity.createEmployeeList(employeeRepository.findByIdDepartment(idDepartment));
|
return EmployeeEntity.createEmployeeList(employeeRepository.findByIdDepartment(idDepartment));
|
||||||
|
|||||||
@@ -1,20 +1,18 @@
|
|||||||
package com.example.rhizome.app.domain.service.impl;
|
package com.example.rhizome.app.domain.service.impl;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import com.example.rhizome.app.domain.model.EmployeeInfo;
|
import com.example.rhizome.app.domain.model.EmployeeInfo;
|
||||||
import com.example.rhizome.app.domain.model.SearchConditionEmployee;
|
import com.example.rhizome.app.domain.model.SearchConditionEmployee;
|
||||||
import com.example.rhizome.app.domain.service.SearchEmployeeInfo;
|
import com.example.rhizome.app.domain.service.SearchEmployeeInfo;
|
||||||
import com.example.rhizome.app.infra.entity.EmployeeDepartmentEntity;
|
import com.example.rhizome.app.infra.entity.EmployeeDepartmentEntity;
|
||||||
import com.example.rhizome.app.infra.repository.EmployeeInfoRepository;
|
import com.example.rhizome.app.infra.repository.EmployeeInfoRepository;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.data.jpa.domain.Specification;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SearchEmployeeInfoImpl (employee join department) 検索系の機能を集約させるサービスクラスです
|
|
||||||
*/
|
|
||||||
@Service
|
@Service
|
||||||
@Transactional
|
@Transactional
|
||||||
public class SearchEmployeeInfoImpl implements SearchEmployeeInfo {
|
public class SearchEmployeeInfoImpl implements SearchEmployeeInfo {
|
||||||
@@ -26,27 +24,13 @@ public class SearchEmployeeInfoImpl implements SearchEmployeeInfo {
|
|||||||
this.employeeInfoRepository = employeeInfoRepository;
|
this.employeeInfoRepository = employeeInfoRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* EmployeeInfo (employee join department) のレコードを全件取得
|
|
||||||
*
|
|
||||||
* @return 取得したレコード全件
|
|
||||||
*/
|
|
||||||
public List<EmployeeInfo> selectAll() {
|
public List<EmployeeInfo> selectAll() {
|
||||||
|
|
||||||
return EmployeeDepartmentEntity.createEmployeeInfoList(employeeInfoRepository.findAll());
|
return EmployeeDepartmentEntity.createEmployeeInfoList(employeeInfoRepository.findAll());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* SearchConditionEmployee の情報を元に EmployeeInfo (employee join department) のレコードを取得
|
|
||||||
*
|
|
||||||
* @param searchConditionEmployee 検索条件
|
|
||||||
* @return 検索結果のレコードリスト
|
|
||||||
*/
|
|
||||||
public List<EmployeeInfo> searchBy(SearchConditionEmployee searchConditionEmployee) {
|
public List<EmployeeInfo> searchBy(SearchConditionEmployee searchConditionEmployee) {
|
||||||
// 動的に検索条件を絞り込む
|
|
||||||
// Specification は Criteria API の Predicate をラップしたもの
|
|
||||||
return EmployeeDepartmentEntity
|
return EmployeeDepartmentEntity
|
||||||
.createEmployeeInfoList(
|
.createEmployeeInfoList(
|
||||||
employeeInfoRepository.findAll(Specification
|
employeeInfoRepository.findAll(Specification
|
||||||
@@ -54,9 +38,8 @@ public class SearchEmployeeInfoImpl implements SearchEmployeeInfo {
|
|||||||
.and(EmployeeInfoRepository.nmEmployeeEqual(searchConditionEmployee.getNmEmployee()))
|
.and(EmployeeInfoRepository.nmEmployeeEqual(searchConditionEmployee.getNmEmployee()))
|
||||||
.and(EmployeeInfoRepository.knEmployeeEqual(searchConditionEmployee.getKnEmployee()))
|
.and(EmployeeInfoRepository.knEmployeeEqual(searchConditionEmployee.getKnEmployee()))
|
||||||
.and(EmployeeInfoRepository.mailAddressEqual(searchConditionEmployee.getMailAddress()))
|
.and(EmployeeInfoRepository.mailAddressEqual(searchConditionEmployee.getMailAddress()))
|
||||||
.and(EmployeeInfoRepository.idDepartmentEqual(searchConditionEmployee.getIdDepartment()))
|
.and(EmployeeInfoRepository
|
||||||
)
|
.idDepartmentEqual(searchConditionEmployee.getIdDepartment()))));
|
||||||
);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,14 @@
|
|||||||
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.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import com.example.rhizome.app.domain.model.Employee;
|
import com.example.rhizome.app.domain.model.Employee;
|
||||||
import com.example.rhizome.app.domain.service.UpdateEmployee;
|
import com.example.rhizome.app.domain.service.UpdateEmployee;
|
||||||
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||||
import com.example.rhizome.app.infra.repository.EmployeeRepository;
|
import com.example.rhizome.app.infra.repository.EmployeeRepository;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* employee の更新系の機能を集約させるサービスクラスです。
|
|
||||||
*/
|
|
||||||
@Service
|
@Service
|
||||||
@Transactional
|
@Transactional
|
||||||
public class UpdateEmployeeImpl implements UpdateEmployee {
|
public class UpdateEmployeeImpl implements UpdateEmployee {
|
||||||
@@ -22,29 +20,13 @@ public class UpdateEmployeeImpl implements UpdateEmployee {
|
|||||||
this.employeeRepository = employeeRepository;
|
this.employeeRepository = employeeRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* employee の情報を元に employee table のレコードを更新する
|
|
||||||
*
|
|
||||||
* @param beforeEmployee 更新前のデータ
|
|
||||||
* @param updateEmployee 更新後のデータ
|
|
||||||
*/
|
|
||||||
public void updateEmployee(Employee beforeEmployee, Employee updateEmployee) {
|
public void updateEmployee(Employee beforeEmployee, Employee updateEmployee) {
|
||||||
|
|
||||||
employeeRepository.save(EmployeeEntity.convertFrom(mergeEmployee(beforeEmployee, updateEmployee)));
|
employeeRepository.save(EmployeeEntity.convertFrom(mergeEmployee(beforeEmployee, updateEmployee)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新前のデータと更新対象のデータをマージする
|
|
||||||
*
|
|
||||||
* @param beforeEmployee 更新前のデータ
|
|
||||||
* @param updateEmployee 更新対象のデータ
|
|
||||||
* @return マージしたデータ
|
|
||||||
*/
|
|
||||||
private Employee mergeEmployee(Employee beforeEmployee, Employee updateEmployee) {
|
private Employee mergeEmployee(Employee beforeEmployee, Employee updateEmployee) {
|
||||||
// 更新対象のデータのパスワードが空文字の場合は、更新前のパスワードを使用する
|
|
||||||
// 更新対象のデータの管理者権限が null の場合は、更新前の管理者権限を使用する
|
|
||||||
// 更新対象のデータの部署IDが null の場合は、更新前の部署IDを使用する
|
|
||||||
return new Employee(
|
return new Employee(
|
||||||
updateEmployee.getIdEmployee(),
|
updateEmployee.getIdEmployee(),
|
||||||
updateEmployee.getNmEmployee(),
|
updateEmployee.getNmEmployee(),
|
||||||
@@ -52,8 +34,8 @@ public class UpdateEmployeeImpl implements UpdateEmployee {
|
|||||||
updateEmployee.getMailAddress(),
|
updateEmployee.getMailAddress(),
|
||||||
updateEmployee.getPassword().isBlank() ? beforeEmployee.getPassword() : updateEmployee.getPassword(),
|
updateEmployee.getPassword().isBlank() ? beforeEmployee.getPassword() : updateEmployee.getPassword(),
|
||||||
updateEmployee.getAdminAuth() == null ? beforeEmployee.getAdminAuth() : updateEmployee.getAdminAuth(),
|
updateEmployee.getAdminAuth() == null ? beforeEmployee.getAdminAuth() : updateEmployee.getAdminAuth(),
|
||||||
updateEmployee.getIdDepartment() == null ? beforeEmployee.getIdDepartment() : updateEmployee.getIdDepartment()
|
updateEmployee.getIdDepartment() == null ? beforeEmployee.getIdDepartment()
|
||||||
);
|
: updateEmployee.getIdDepartment());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,25 +1,20 @@
|
|||||||
/*
|
|
||||||
* Department.java
|
|
||||||
* 作成 IT-College 2016
|
|
||||||
*------------------------------------------------------------
|
|
||||||
* Copyright(c) Rhizome Inc. All Rights Reserved.
|
|
||||||
*/
|
|
||||||
package com.example.rhizome.app.infra.entity;
|
package com.example.rhizome.app.infra.entity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.GenerationType;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
|
||||||
import com.example.rhizome.app.domain.model.Department;
|
import com.example.rhizome.app.domain.model.Department;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import javax.persistence.*;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Department テーブルの Entity
|
|
||||||
*
|
|
||||||
* @author IT-College
|
|
||||||
*/
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "department")
|
@Table(name = "department")
|
||||||
@Data
|
@Data
|
||||||
@@ -27,46 +22,26 @@ import java.util.List;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class DepartmentEntity {
|
public class DepartmentEntity {
|
||||||
|
|
||||||
/**
|
|
||||||
* 部署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;
|
||||||
|
|
||||||
/**
|
|
||||||
* DepartmentEntity(DataAccess層依存)から Department(BusinessLogic層依存型)に変換します。
|
|
||||||
*
|
|
||||||
* @param departmentEntityList department Table のリスト
|
|
||||||
* @return List<Department> リスト
|
|
||||||
*/
|
|
||||||
public static List<Department> createDepartmentList(List<DepartmentEntity> departmentEntityList) {
|
public static List<Department> createDepartmentList(List<DepartmentEntity> departmentEntityList) {
|
||||||
|
|
||||||
// Stream API を利用するとこうなります。
|
|
||||||
return departmentEntityList
|
return departmentEntityList
|
||||||
.stream()
|
.stream()
|
||||||
.map(departmentEntity -> new Department(
|
.map(departmentEntity -> new Department(
|
||||||
departmentEntity.getIdDepartment(),
|
departmentEntity.getIdDepartment(),
|
||||||
departmentEntity.getNmDepartment()
|
departmentEntity.getNmDepartment()))
|
||||||
)).toList();
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Department(BusinessLogic層依存型) から DepartmentEntity(DataAccess層依存)に変換します。
|
|
||||||
*
|
|
||||||
* @param department department モデルの値
|
|
||||||
* @return DepartmentEntity に変換したインスタンス
|
|
||||||
*/
|
|
||||||
public static DepartmentEntity convertFrom(Department department) {
|
public static DepartmentEntity convertFrom(Department department) {
|
||||||
return new DepartmentEntity(
|
return new DepartmentEntity(
|
||||||
department.getIdDepartment(),
|
department.getIdDepartment(),
|
||||||
department.getNmDepartment()
|
department.getNmDepartment());
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,68 +1,53 @@
|
|||||||
package com.example.rhizome.app.infra.entity;
|
package com.example.rhizome.app.infra.entity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.GenerationType;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.JoinColumn;
|
||||||
|
import javax.persistence.ManyToOne;
|
||||||
|
import javax.persistence.NamedEntityGraph;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
import org.hibernate.annotations.Fetch;
|
||||||
|
import org.hibernate.annotations.FetchMode;
|
||||||
|
|
||||||
import com.example.rhizome.app.domain.model.Department;
|
import com.example.rhizome.app.domain.model.Department;
|
||||||
import com.example.rhizome.app.domain.model.Employee;
|
import com.example.rhizome.app.domain.model.Employee;
|
||||||
import com.example.rhizome.app.domain.model.EmployeeInfo;
|
import com.example.rhizome.app.domain.model.EmployeeInfo;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import org.hibernate.annotations.Fetch;
|
|
||||||
import org.hibernate.annotations.FetchMode;
|
|
||||||
|
|
||||||
import javax.persistence.*;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Employee + Department の Join 情報を保持するEntity
|
|
||||||
*
|
|
||||||
* @author IT-College
|
|
||||||
*/
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "employee")
|
@Table(name = "employee")
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@NamedEntityGraph(
|
@NamedEntityGraph(name = "employee_with_department", includeAllAttributes = true)
|
||||||
name = "employee_with_department",
|
|
||||||
includeAllAttributes = true
|
|
||||||
)
|
|
||||||
public class EmployeeDepartmentEntity {
|
public class EmployeeDepartmentEntity {
|
||||||
|
|
||||||
/**
|
|
||||||
* 社員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 = "admin_auth", nullable = false)
|
@Column(name = "admin_auth", nullable = false)
|
||||||
private Integer adminAuth;
|
private Integer adminAuth;
|
||||||
|
|
||||||
@@ -71,17 +56,8 @@ public class EmployeeDepartmentEntity {
|
|||||||
@Fetch(FetchMode.JOIN)
|
@Fetch(FetchMode.JOIN)
|
||||||
private DepartmentEntity department;
|
private DepartmentEntity department;
|
||||||
|
|
||||||
/**
|
|
||||||
* EmployeeDepartmentEntity(DataAccess層依存) を EmployeeInfo(BusinessLogic層依存) に変換します。
|
|
||||||
*
|
|
||||||
* @param employeeDepartmentEntity EmployeeDepartmentEntity のインスタンス
|
|
||||||
* @return EmployeeInfo のインスタンス
|
|
||||||
*/
|
|
||||||
public static EmployeeInfo createEmployeeInfo(EmployeeDepartmentEntity employeeDepartmentEntity) {
|
public static EmployeeInfo createEmployeeInfo(EmployeeDepartmentEntity employeeDepartmentEntity) {
|
||||||
|
|
||||||
// コンストラクタを使って書くとSetterを使用するより簡略化出来ます。
|
|
||||||
// 混乱してしまう人は落ち着いて EmployeeInfo のフィールドを見に行って、
|
|
||||||
// どうしてこの書き方が出来るのかを理解できる様になりましょう。
|
|
||||||
return new EmployeeInfo(
|
return new EmployeeInfo(
|
||||||
new Employee(
|
new Employee(
|
||||||
employeeDepartmentEntity.getIdEmployee(),
|
employeeDepartmentEntity.getIdEmployee(),
|
||||||
@@ -90,29 +66,21 @@ public class EmployeeDepartmentEntity {
|
|||||||
employeeDepartmentEntity.getMailAddress(),
|
employeeDepartmentEntity.getMailAddress(),
|
||||||
employeeDepartmentEntity.getPassword(),
|
employeeDepartmentEntity.getPassword(),
|
||||||
employeeDepartmentEntity.getAdminAuth(),
|
employeeDepartmentEntity.getAdminAuth(),
|
||||||
employeeDepartmentEntity.getDepartment() == null ? null : employeeDepartmentEntity.getDepartment().getIdDepartment()
|
employeeDepartmentEntity.getDepartment() == null ? null
|
||||||
),
|
: employeeDepartmentEntity.getDepartment().getIdDepartment()),
|
||||||
new Department(
|
new Department(
|
||||||
employeeDepartmentEntity.getDepartment() == null ? null : employeeDepartmentEntity.getDepartment().getIdDepartment(),
|
employeeDepartmentEntity.getDepartment() == null ? null
|
||||||
employeeDepartmentEntity.getDepartment() == null ? null : employeeDepartmentEntity.getDepartment().getNmDepartment()
|
: employeeDepartmentEntity.getDepartment().getIdDepartment(),
|
||||||
)
|
employeeDepartmentEntity.getDepartment() == null ? null
|
||||||
);
|
: employeeDepartmentEntity.getDepartment().getNmDepartment()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public static List<EmployeeInfo> createEmployeeInfoList(
|
||||||
* EmployeeDepartmentEntity(DataAccess層依存) を EmployeeInfo(BusinessLogic層依存) に変換します。
|
List<EmployeeDepartmentEntity> employeeDepartmentEntityList) {
|
||||||
* (リスト版)
|
|
||||||
*
|
|
||||||
* @param employeeDepartmentEntityList EmployeeDepartmentEntity インスタンスのリスト
|
|
||||||
* @return EmployeeInfo インスタンスのリスト
|
|
||||||
*/
|
|
||||||
public static List<EmployeeInfo> createEmployeeInfoList(List<EmployeeDepartmentEntity> employeeDepartmentEntityList) {
|
|
||||||
|
|
||||||
// StreamAPI を使うとこうなります。
|
|
||||||
return employeeDepartmentEntityList.stream().map(EmployeeDepartmentEntity::createEmployeeInfo).toList();
|
return employeeDepartmentEntityList.stream().map(EmployeeDepartmentEntity::createEmployeeInfo).toList();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,27 +1,22 @@
|
|||||||
/*
|
|
||||||
* Employee.java
|
|
||||||
* 作成 IT-College 2016
|
|
||||||
*------------------------------------------------------------
|
|
||||||
* Copyright(c) Rhizome Inc. All Rights Reserved.
|
|
||||||
*/
|
|
||||||
package com.example.rhizome.app.infra.entity;
|
package com.example.rhizome.app.infra.entity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.GenerationType;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
|
||||||
import com.example.rhizome.app.domain.model.Employee;
|
import com.example.rhizome.app.domain.model.Employee;
|
||||||
import com.example.rhizome.app.domain.model.LoginUser;
|
import com.example.rhizome.app.domain.model.LoginUser;
|
||||||
import com.example.rhizome.app.domain.model.SearchConditionEmployee;
|
import com.example.rhizome.app.domain.model.SearchConditionEmployee;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import javax.persistence.*;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* EmployeeテーブルのEntity
|
|
||||||
*
|
|
||||||
* @author IT-College
|
|
||||||
*/
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "employee")
|
@Table(name = "employee")
|
||||||
@Data
|
@Data
|
||||||
@@ -29,59 +24,30 @@ import java.util.List;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class EmployeeEntity {
|
public class EmployeeEntity {
|
||||||
|
|
||||||
/**
|
|
||||||
* 社員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 = "admin_auth", nullable = false)
|
@Column(name = "admin_auth", nullable = false)
|
||||||
private Integer adminAuth;
|
private Integer adminAuth;
|
||||||
|
|
||||||
/**
|
|
||||||
* 部署ID
|
|
||||||
*/
|
|
||||||
@Column(name = "id_department", nullable = false)
|
@Column(name = "id_department", nullable = false)
|
||||||
private Integer idDepartment;
|
private Integer idDepartment;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Employee(BusinessLogic 依存)を EmployeeEntity(DataAccess層依存)に変換します。
|
|
||||||
*
|
|
||||||
* @param employee Employee Table の中身
|
|
||||||
* @return EmployeeEntity のインスタンス(1レコード分)
|
|
||||||
*/
|
|
||||||
public static EmployeeEntity convertFrom(Employee employee) {
|
public static EmployeeEntity convertFrom(Employee employee) {
|
||||||
// 値を既に持ったインスタンスの生成に、コンストラクタを使用するとこうなります。
|
|
||||||
return new EmployeeEntity(
|
return new EmployeeEntity(
|
||||||
employee.getIdEmployee(),
|
employee.getIdEmployee(),
|
||||||
employee.getNmEmployee(),
|
employee.getNmEmployee(),
|
||||||
@@ -89,17 +55,9 @@ public class EmployeeEntity {
|
|||||||
employee.getMailAddress(),
|
employee.getMailAddress(),
|
||||||
employee.getPassword(),
|
employee.getPassword(),
|
||||||
employee.getAdminAuth(),
|
employee.getAdminAuth(),
|
||||||
employee.getIdDepartment()
|
employee.getIdDepartment());
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* SearchConditionEmployee(BusinessLogic 依存)を EmployeeEntity(DataAccess層依存)に変換します。
|
|
||||||
* (コンストラクタを使用せず、Setterを利用したパターン)
|
|
||||||
*
|
|
||||||
* @param searchConditionEmployee 検索条件
|
|
||||||
* @return EmployeeEntity のインスタンス(1レコード分)
|
|
||||||
*/
|
|
||||||
public static EmployeeEntity convertFrom(SearchConditionEmployee searchConditionEmployee) {
|
public static EmployeeEntity convertFrom(SearchConditionEmployee searchConditionEmployee) {
|
||||||
EmployeeEntity employeeEntity = new EmployeeEntity();
|
EmployeeEntity employeeEntity = new EmployeeEntity();
|
||||||
|
|
||||||
@@ -109,19 +67,11 @@ public class EmployeeEntity {
|
|||||||
employeeEntity.setMailAddress(searchConditionEmployee.getMailAddress());
|
employeeEntity.setMailAddress(searchConditionEmployee.getMailAddress());
|
||||||
employeeEntity.setIdDepartment(searchConditionEmployee.getIdDepartment());
|
employeeEntity.setIdDepartment(searchConditionEmployee.getIdDepartment());
|
||||||
|
|
||||||
|
|
||||||
return employeeEntity;
|
return employeeEntity;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* EmployeeEntity(DataAccess層依存)から Employee (BusinessLogic層依存型)に変換します。
|
|
||||||
*
|
|
||||||
* @param employeeEntity Employee Table のインスタンス
|
|
||||||
* @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(),
|
||||||
@@ -129,37 +79,14 @@ public class EmployeeEntity {
|
|||||||
employeeEntity.getMailAddress(),
|
employeeEntity.getMailAddress(),
|
||||||
employeeEntity.getPassword(),
|
employeeEntity.getPassword(),
|
||||||
employeeEntity.getAdminAuth(),
|
employeeEntity.getAdminAuth(),
|
||||||
employeeEntity.getIdDepartment()
|
employeeEntity.getIdDepartment());
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* EmployeeEntity(DataAccess層依存) から Employee (BusinessLogic層依存型)に変換します。(リスト版)
|
|
||||||
*
|
|
||||||
* @param employeeEntityList EmployeeEntity インスタンスのリスト
|
|
||||||
* @return Employee インスタンスのリスト
|
|
||||||
*/
|
|
||||||
public static List<Employee> createEmployeeList(List<EmployeeEntity> employeeEntityList) {
|
public static List<Employee> createEmployeeList(List<EmployeeEntity> employeeEntityList) {
|
||||||
/* 従来の書き方
|
|
||||||
List<Employee> employeeList = new ArrayList<>();
|
|
||||||
for(EmployeeEntity employeeEntity:employeeEntityList){
|
|
||||||
Employee employee = EmployeeEntity.createEmployee(employeeEntity);
|
|
||||||
employeeList.add(employee);
|
|
||||||
}
|
|
||||||
return employeeList;
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Stream APIを使用すると1行で書けます。
|
|
||||||
return employeeEntityList.stream().map(EmployeeEntity::createEmployee).toList();
|
return employeeEntityList.stream().map(EmployeeEntity::createEmployee).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* EmployeeEntity(DataAccess層依存) から LoginUser (BusinessLogic層依存型)情報を作成します。
|
|
||||||
*
|
|
||||||
* @return loginUser (ログイン者の情報) インスタンス
|
|
||||||
*/
|
|
||||||
public LoginUser createLoginUser() {
|
public LoginUser createLoginUser() {
|
||||||
// 値を既に持ったインスタンスの生成に、コンストラクタを使用するとこうなります。
|
|
||||||
return new LoginUser(
|
return new LoginUser(
|
||||||
getIdEmployee(),
|
getIdEmployee(),
|
||||||
getNmEmployee(),
|
getNmEmployee(),
|
||||||
@@ -167,8 +94,7 @@ public class EmployeeEntity {
|
|||||||
getMailAddress(),
|
getMailAddress(),
|
||||||
getPassword(),
|
getPassword(),
|
||||||
getAdminAuth(),
|
getAdminAuth(),
|
||||||
getIdDepartment()
|
getIdDepartment());
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,50 +1,31 @@
|
|||||||
package com.example.rhizome.app.infra.repository;
|
package com.example.rhizome.app.infra.repository;
|
||||||
|
|
||||||
import com.example.rhizome.app.infra.entity.DepartmentEntity;
|
|
||||||
import org.springframework.data.jpa.domain.Specification;
|
import org.springframework.data.jpa.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.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.example.rhizome.app.infra.entity.DepartmentEntity;
|
||||||
|
|
||||||
/**
|
|
||||||
* Specification:
|
|
||||||
* 関数型インターフェースです。
|
|
||||||
* JPAの一部として提供されていて、エンティティの情報を元に動的にクエリを生成し、DBからデータを取得します。
|
|
||||||
* 使い方:
|
|
||||||
* toPredicate をOverrideして使います。
|
|
||||||
* パラメータ:
|
|
||||||
* Root<T>:ルートエンティティを指します。<T>に指定したエンティティ(今回はDepartmentEntity)を用いてメンバにアクセスします。
|
|
||||||
* CriteriaQuery<\?>:サブクエリを作成する際に使用します。※今回は使用しません
|
|
||||||
* CriteriaBuilder:条件式(Where句以降の条件)の部分のクエリを作るためのビルダーです。
|
|
||||||
* 戻り値はクエリを格納している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) {
|
static Specification<DepartmentEntity> idDepartmentEqual(Integer idDepartment) {
|
||||||
return idDepartment == null ?
|
return idDepartment == null ? null
|
||||||
null :
|
: (Specification<DepartmentEntity>) (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder
|
||||||
// 戻り値の型 Specification<DepartmentEntity> にキャスト
|
.equal(root.get("idDepartment"), idDepartment);
|
||||||
(Specification<DepartmentEntity>)
|
|
||||||
// ラムダ式で記載しているが書いてあることは criteriaBuilder を使って Where句の後の "'idDepartment' = idDepartment(変数)"
|
|
||||||
// を作成している
|
|
||||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.equal(root.get("idDepartment"), idDepartment);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Specification<DepartmentEntity> nmDepartmentEqual(String nmDepartment) {
|
static Specification<DepartmentEntity> nmDepartmentEqual(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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Specification<DepartmentEntity> nmDepartmentLike(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 + "%");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,61 +1,42 @@
|
|||||||
package com.example.rhizome.app.infra.repository;
|
package com.example.rhizome.app.infra.repository;
|
||||||
|
|
||||||
import com.example.rhizome.app.infra.entity.EmployeeDepartmentEntity;
|
|
||||||
import org.springframework.data.jpa.domain.Specification;
|
import org.springframework.data.jpa.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.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
/**
|
import com.example.rhizome.app.infra.entity.EmployeeDepartmentEntity;
|
||||||
* ワンポイント情報(ここで登場する関数型インターフェース Specification について解説します)
|
|
||||||
* Specification:
|
|
||||||
* 関数型インターフェースです。
|
|
||||||
* JPAの一部として提供されていて、エンティティの情報を元に動的にクエリを生成し、DBからデータを取得します。
|
|
||||||
* 使い方:
|
|
||||||
* toPredicate をOverrideして使います。
|
|
||||||
* パラメータ:
|
|
||||||
* Root<T>:ルートエンティティを指します。<T>に指定したエンティティ(今回はDepartmentEntity)を用いてメンバにアクセスします。
|
|
||||||
* CriteriaQuery<\?>:サブクエリを作成する際に使用します。※今回は使用しません
|
|
||||||
* CriteriaBuilder:条件式(Where句以降の条件)の部分のクエリを作るためのビルダーです。
|
|
||||||
* 戻り値はクエリを格納しているPredicateオブジェクトとなります。
|
|
||||||
*/
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface EmployeeInfoRepository extends JpaRepository<EmployeeDepartmentEntity, Integer>, JpaSpecificationExecutor<EmployeeDepartmentEntity> {
|
public interface EmployeeInfoRepository
|
||||||
|
extends JpaRepository<EmployeeDepartmentEntity, Integer>, JpaSpecificationExecutor<EmployeeDepartmentEntity> {
|
||||||
|
|
||||||
static Specification<EmployeeDepartmentEntity> idEmployeeEqual(Integer idEmployee) {
|
static Specification<EmployeeDepartmentEntity> idEmployeeEqual(Integer idEmployee) {
|
||||||
return idEmployee == null ?
|
return idEmployee == null ? null
|
||||||
null :
|
: (Specification<EmployeeDepartmentEntity>) (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder
|
||||||
// 戻り値の型 Specification<EmployeeDepartmentEntity> にキャスト
|
.equal(root.get("idEmployee"), idEmployee);
|
||||||
(Specification<EmployeeDepartmentEntity>)
|
|
||||||
// ラムダ式で記載しているが書いてあることは criteriaBuilder を使って Where句の後の "'idEmployee' = idEmployee(変数)"
|
|
||||||
// を作成している
|
|
||||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.equal(root.get("idEmployee"), idEmployee);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Specification<EmployeeDepartmentEntity> nmEmployeeEqual(String nmEmployee) {
|
static Specification<EmployeeDepartmentEntity> nmEmployeeEqual(String nmEmployee) {
|
||||||
return (nmEmployee == null || nmEmployee.isEmpty()) ?
|
return (nmEmployee == null || nmEmployee.isEmpty()) ? null
|
||||||
null :
|
: (Specification<EmployeeDepartmentEntity>) (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder
|
||||||
(Specification<EmployeeDepartmentEntity>)
|
.like(root.get("nmEmployee"), "%" + nmEmployee + "%");
|
||||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.like(root.get("nmEmployee"), "%" + nmEmployee + "%");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Specification<EmployeeDepartmentEntity> knEmployeeEqual(String knEmployee) {
|
static Specification<EmployeeDepartmentEntity> knEmployeeEqual(String knEmployee) {
|
||||||
return (knEmployee == null || knEmployee.isEmpty()) ?
|
return (knEmployee == null || knEmployee.isEmpty()) ? null
|
||||||
null :
|
: (Specification<EmployeeDepartmentEntity>) (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder
|
||||||
(Specification<EmployeeDepartmentEntity>)
|
.like(root.get("knEmployee"), "%" + knEmployee + "%");
|
||||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.like(root.get("knEmployee"), "%" + knEmployee + "%");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Specification<EmployeeDepartmentEntity> mailAddressEqual(String mailAddress) {
|
static Specification<EmployeeDepartmentEntity> mailAddressEqual(String mailAddress) {
|
||||||
return (mailAddress == null || mailAddress.isEmpty()) ?
|
return (mailAddress == null || mailAddress.isEmpty()) ? null
|
||||||
null :
|
: (Specification<EmployeeDepartmentEntity>) (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder
|
||||||
(Specification<EmployeeDepartmentEntity>)
|
.like(root.get("mailAddress"), "%" + mailAddress + "%");
|
||||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.like(root.get("mailAddress"), "%" + mailAddress + "%");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Specification<EmployeeDepartmentEntity> idDepartmentEqual(Integer idDepartment) {
|
static Specification<EmployeeDepartmentEntity> idDepartmentEqual(Integer idDepartment) {
|
||||||
return (root, query, criteriaBuilder) ->
|
return (root, query, criteriaBuilder) -> idDepartment == null ? null
|
||||||
idDepartment == null ? null :
|
: criteriaBuilder.equal(root.join("department").get("idDepartment"), idDepartment);
|
||||||
criteriaBuilder.equal(root.join("department").get("idDepartment"), idDepartment);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,28 +1,20 @@
|
|||||||
package com.example.rhizome.app.infra.repository;
|
package com.example.rhizome.app.infra.repository;
|
||||||
|
|
||||||
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
|
||||||
import org.springframework.stereotype.Repository;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||||
|
|
||||||
@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で検索
|
|
||||||
**/
|
|
||||||
Optional<EmployeeEntity> findByIdEmployee(Integer idEmployee);
|
Optional<EmployeeEntity> findByIdEmployee(Integer idEmployee);
|
||||||
|
|
||||||
/**
|
|
||||||
* IDで検索
|
|
||||||
**/
|
|
||||||
List<EmployeeEntity> findByIdDepartment(Integer idDepartment);
|
List<EmployeeEntity> findByIdDepartment(Integer idDepartment);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,19 @@
|
|||||||
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.Objects;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
import com.example.rhizome.aop.aspect.PermissionCheck;
|
import com.example.rhizome.aop.aspect.PermissionCheck;
|
||||||
import com.example.rhizome.aop.aspect.SessionCheck;
|
import com.example.rhizome.aop.aspect.SessionCheck;
|
||||||
@@ -12,30 +26,12 @@ import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTa
|
|||||||
import com.example.rhizome.app.presentation.form.DepartmentForm;
|
import com.example.rhizome.app.presentation.form.DepartmentForm;
|
||||||
import com.example.rhizome.app.presentation.form.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 org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.ui.Model;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpSession;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.DELETE_EMPLOYEE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 削除処理のコントロータ
|
|
||||||
*/
|
|
||||||
@Controller
|
@Controller
|
||||||
public class DeleteEmployeeController {
|
public class DeleteEmployeeController {
|
||||||
|
|
||||||
// ログ出力用インスタンス
|
|
||||||
private final static Logger LOGGER = Logger.getLogger(DeleteEmployeeController.class.getName());
|
private final static Logger LOGGER = Logger.getLogger(DeleteEmployeeController.class.getName());
|
||||||
|
|
||||||
// エラーメッセージ用の定数フィールド
|
|
||||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||||
|
|
||||||
HttpSession httpSession;
|
HttpSession httpSession;
|
||||||
@@ -43,78 +39,52 @@ public class DeleteEmployeeController {
|
|||||||
SearchDepartment searchDepartment;
|
SearchDepartment searchDepartment;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public DeleteEmployeeController(DeleteEmployee deleteEmployee, SearchDepartment searchDepartment, HttpSession httpSession) {
|
public DeleteEmployeeController(DeleteEmployee deleteEmployee, SearchDepartment searchDepartment,
|
||||||
|
HttpSession httpSession) {
|
||||||
this.httpSession = httpSession;
|
this.httpSession = httpSession;
|
||||||
this.deleteEmployee = deleteEmployee;
|
this.deleteEmployee = deleteEmployee;
|
||||||
this.searchDepartment = searchDepartment;
|
this.searchDepartment = searchDepartment;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 削除処理のコントローラ
|
|
||||||
*
|
|
||||||
* @param idEmployee 削除対象のemployeeId
|
|
||||||
* @param model ビューにデータを渡すためのコンテナ
|
|
||||||
* @return 遷移先の画面
|
|
||||||
*/
|
|
||||||
@PermissionCheck
|
@PermissionCheck
|
||||||
@SessionCheck
|
@SessionCheck
|
||||||
@RequestMapping(value = DELETE_EMPLOYEE, method = RequestMethod.POST)
|
@RequestMapping(value = DELETE_EMPLOYEE, method = RequestMethod.POST)
|
||||||
public String deleteEmployee(@RequestParam("idEmployee") Integer idEmployee, Model model) {
|
public String deleteEmployee(@RequestParam("idEmployee") Integer idEmployee, Model model) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 部署一覧を取得し、画面に返す用のクラスに詰め替える
|
|
||||||
// 作成した部署一覧をセット
|
|
||||||
model.addAttribute(
|
model.addAttribute(
|
||||||
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||||
DepartmentForm.convertFrom(searchDepartment.selectAll())
|
DepartmentForm.convertFrom(searchDepartment.selectAll()));
|
||||||
);
|
|
||||||
|
|
||||||
// 削除処理実施
|
|
||||||
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;
|
||||||
|
|
||||||
} 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 idEmployee 削除対象のemployeeId
|
|
||||||
* @param loginUser ログインユーザー情報
|
|
||||||
*/
|
|
||||||
private void deleteExec(Model model, Integer idEmployee, LoginUser loginUser) {
|
private void deleteExec(Model model, Integer idEmployee, LoginUser loginUser) {
|
||||||
|
|
||||||
final String DELETE_TARGET_ID_CAN_NOT_DELETE = "ログイン者自身は削除出来ません。";
|
final String DELETE_TARGET_ID_CAN_NOT_DELETE = "ログイン者自身は削除出来ません。";
|
||||||
final String DELETE_COMPLETE = "削除しました。";
|
final String DELETE_COMPLETE = "削除しました。";
|
||||||
|
|
||||||
// ログインしている人が、削除対象かチェック
|
|
||||||
if (Objects.equals(loginUser.getIdEmployee(), idEmployee)) {
|
if (Objects.equals(loginUser.getIdEmployee(), idEmployee)) {
|
||||||
// 削除対象だった場合
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 削除を実施
|
|
||||||
deleteEmployee.deleteEmployee(idEmployee);
|
deleteEmployee.deleteEmployee(idEmployee);
|
||||||
|
|
||||||
// 削除完了したメッセージをセット
|
|
||||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_INFO, new MessageForm(DELETE_COMPLETE));
|
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_INFO, new MessageForm(DELETE_COMPLETE));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,18 @@
|
|||||||
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 {
|
||||||
@@ -28,23 +29,14 @@ public class IndexController {
|
|||||||
return new LoginUserForm();
|
return new LoginUserForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@RequestMapping(value = { INDEX_BLANK, INDEX_SLASH, INDEX_LOGIN })
|
||||||
* ログイン画面表示処理
|
|
||||||
*
|
|
||||||
* @param model ビューにデータを渡すためのコンテナ
|
|
||||||
* @return 遷移先の画面
|
|
||||||
*/
|
|
||||||
@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に用意
|
|
||||||
model.addAttribute(PageReturnAttributeKeyword.LOGIN_INFO_FORM, loginUserForm());
|
model.addAttribute(PageReturnAttributeKeyword.LOGIN_INFO_FORM, loginUserForm());
|
||||||
|
|
||||||
// ログイン画面に遷移
|
|
||||||
return LOGIN_HTML;
|
return LOGIN_HTML;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,20 @@
|
|||||||
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.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
|
||||||
import com.example.rhizome.aop.aspect.PermissionCheck;
|
import com.example.rhizome.aop.aspect.PermissionCheck;
|
||||||
import com.example.rhizome.aop.aspect.SessionCheck;
|
import com.example.rhizome.aop.aspect.SessionCheck;
|
||||||
import com.example.rhizome.app.domain.model.Employee;
|
import com.example.rhizome.app.domain.model.Employee;
|
||||||
@@ -12,30 +27,12 @@ import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTa
|
|||||||
import com.example.rhizome.app.presentation.form.DepartmentForm;
|
import com.example.rhizome.app.presentation.form.DepartmentForm;
|
||||||
import com.example.rhizome.app.presentation.form.InsertEmployeeForm;
|
import com.example.rhizome.app.presentation.form.InsertEmployeeForm;
|
||||||
import com.example.rhizome.app.presentation.form.MessageForm;
|
import com.example.rhizome.app.presentation.form.MessageForm;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.ui.Model;
|
|
||||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpSession;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_CONFIRM;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新規登録者情報チェック用のコントローラ
|
|
||||||
*/
|
|
||||||
@Controller
|
@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;
|
||||||
@@ -46,8 +43,7 @@ public class InsertEmployeeConfirmController {
|
|||||||
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;
|
||||||
@@ -58,76 +54,46 @@ public class InsertEmployeeConfirmController {
|
|||||||
return new InsertEmployeeForm();
|
return new InsertEmployeeForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 登録情報のチェックを行う
|
|
||||||
*
|
|
||||||
* @param insertEmployeeForm 登録情報
|
|
||||||
* @param model ビューにデータを渡すためのコンテナ
|
|
||||||
* @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.selectAll()
|
searchDepartment.selectAll()));
|
||||||
));
|
|
||||||
|
|
||||||
// 登録用パラメータチェック
|
|
||||||
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件ではない場合
|
|
||||||
// 重複を許さないため、エラー処理
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 登録確認ページに遷移
|
|
||||||
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) {
|
} 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,21 @@
|
|||||||
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.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
|
||||||
import com.example.rhizome.aop.aspect.PermissionCheck;
|
import com.example.rhizome.aop.aspect.PermissionCheck;
|
||||||
import com.example.rhizome.aop.aspect.SessionCheck;
|
import com.example.rhizome.aop.aspect.SessionCheck;
|
||||||
import com.example.rhizome.app.domain.service.RegisterEmployee;
|
import com.example.rhizome.app.domain.service.RegisterEmployee;
|
||||||
@@ -11,31 +27,12 @@ import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTa
|
|||||||
import com.example.rhizome.app.presentation.form.DepartmentForm;
|
import com.example.rhizome.app.presentation.form.DepartmentForm;
|
||||||
import com.example.rhizome.app.presentation.form.InsertEmployeeForm;
|
import com.example.rhizome.app.presentation.form.InsertEmployeeForm;
|
||||||
import com.example.rhizome.app.presentation.form.MessageForm;
|
import com.example.rhizome.app.presentation.form.MessageForm;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.ui.Model;
|
|
||||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpSession;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.INSERT_EMPLOYEE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新規登録用のコントローラ
|
|
||||||
*/
|
|
||||||
@Controller
|
@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;
|
||||||
@@ -43,7 +40,8 @@ public class InsertEmployeeController {
|
|||||||
SearchDepartment searchDepartment;
|
SearchDepartment searchDepartment;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public InsertEmployeeController(HttpSession httpSession, RegisterEmployeeImpl registerEmployee, SearchDepartmentImpl searchDepartment) {
|
public InsertEmployeeController(HttpSession httpSession, RegisterEmployeeImpl registerEmployee,
|
||||||
|
SearchDepartmentImpl searchDepartment) {
|
||||||
this.httpSession = httpSession;
|
this.httpSession = httpSession;
|
||||||
this.registerEmployee = registerEmployee;
|
this.registerEmployee = registerEmployee;
|
||||||
this.searchDepartment = searchDepartment;
|
this.searchDepartment = searchDepartment;
|
||||||
@@ -54,80 +52,51 @@ public class InsertEmployeeController {
|
|||||||
return new InsertEmployeeForm();
|
return new InsertEmployeeForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 新規登録画面表示処理
|
|
||||||
*
|
|
||||||
* @param insertEmployeeForm 登録情報
|
|
||||||
* @param model ビューにデータを渡すためのコンテナ
|
|
||||||
* @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.selectAll()
|
searchDepartment.selectAll()));
|
||||||
));
|
|
||||||
|
|
||||||
// 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.getAdminAuth(),
|
insertEmployeeForm.getAdminAuth(),
|
||||||
insertEmployeeForm.getIdDepartment()
|
insertEmployeeForm.getIdDepartment());
|
||||||
);
|
|
||||||
|
|
||||||
// エラーが1件以上有る場合
|
|
||||||
if (!error.isEmpty()) {
|
if (!error.isEmpty()) {
|
||||||
// エラー内容を画面に表示
|
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR,
|
||||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(String.join(", ", error) + "が不正です。"));
|
new MessageForm(String.join(", ", error) + "が不正です。"));
|
||||||
// 登録画面に遷移
|
|
||||||
return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML;
|
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 employeeKana 登録対象のカナ
|
|
||||||
* @param mailAddress 登録対象のメールアドレス
|
|
||||||
* @param password 登録対象のパスワード
|
|
||||||
* @param management システム権限
|
|
||||||
* @param departmentId 部署ID
|
|
||||||
* @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,
|
||||||
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 = "社員名フリガナ";
|
||||||
@@ -138,39 +107,27 @@ public class InsertEmployeeController {
|
|||||||
|
|
||||||
List<String> error = new ArrayList<>();
|
List<String> error = new ArrayList<>();
|
||||||
|
|
||||||
// null or 空文字判定
|
|
||||||
if (isNullOrBlank(employeeName)) {
|
if (isNullOrBlank(employeeName)) {
|
||||||
// エラー内容を追加
|
|
||||||
error.add(EMPLOYEE_NAME_NULL_BLANK);
|
error.add(EMPLOYEE_NAME_NULL_BLANK);
|
||||||
}
|
}
|
||||||
|
|
||||||
// null or 空文字判定
|
|
||||||
if (isNullOrBlank(employeeKana)) {
|
if (isNullOrBlank(employeeKana)) {
|
||||||
// エラー内容を追加
|
|
||||||
error.add(EMPLOYEE_KANA_NULL_BLANK);
|
error.add(EMPLOYEE_KANA_NULL_BLANK);
|
||||||
}
|
}
|
||||||
|
|
||||||
// null or 空文字判定
|
|
||||||
if (isNullOrBlank(mailAddress)) {
|
if (isNullOrBlank(mailAddress)) {
|
||||||
// エラー内容を追加
|
|
||||||
error.add(MAIL_ADDRESS_NULL_BLANK);
|
error.add(MAIL_ADDRESS_NULL_BLANK);
|
||||||
}
|
}
|
||||||
|
|
||||||
// null or 空文字判定
|
|
||||||
if (isNullOrBlank(password)) {
|
if (isNullOrBlank(password)) {
|
||||||
// エラー内容を追加
|
|
||||||
error.add(PASSWORD_NULL_BLANK);
|
error.add(PASSWORD_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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,12 +135,6 @@ public class InsertEmployeeController {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 仮引数を null or 空 判定する
|
|
||||||
*
|
|
||||||
* @param str 判定対象の文字列
|
|
||||||
* @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;
|
||||||
@@ -193,6 +144,3 @@ public class InsertEmployeeController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,19 @@
|
|||||||
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.aop.aspect.PermissionCheck;
|
import com.example.rhizome.aop.aspect.PermissionCheck;
|
||||||
import com.example.rhizome.aop.aspect.SessionCheck;
|
import com.example.rhizome.aop.aspect.SessionCheck;
|
||||||
import com.example.rhizome.app.domain.service.RegisterEmployee;
|
import com.example.rhizome.app.domain.service.RegisterEmployee;
|
||||||
@@ -8,29 +22,12 @@ import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAt
|
|||||||
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.DepartmentForm;
|
||||||
import com.example.rhizome.app.presentation.form.InsertEmployeeForm;
|
import com.example.rhizome.app.presentation.form.InsertEmployeeForm;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.ui.Model;
|
|
||||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpSession;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登録画面表示用コントローラ
|
|
||||||
*/
|
|
||||||
@Controller
|
@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;
|
||||||
@@ -38,7 +35,8 @@ public class InsertEmployeeInputController {
|
|||||||
SearchDepartment searchDepartment;
|
SearchDepartment searchDepartment;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public InsertEmployeeInputController(HttpSession httpSession, RegisterEmployee registerEmployee, SearchDepartment searchDepartment) {
|
public InsertEmployeeInputController(HttpSession httpSession, RegisterEmployee registerEmployee,
|
||||||
|
SearchDepartment searchDepartment) {
|
||||||
this.httpSession = httpSession;
|
this.httpSession = httpSession;
|
||||||
this.registerEmployee = registerEmployee;
|
this.registerEmployee = registerEmployee;
|
||||||
this.searchDepartment = searchDepartment;
|
this.searchDepartment = searchDepartment;
|
||||||
@@ -49,42 +47,26 @@ public class InsertEmployeeInputController {
|
|||||||
return new InsertEmployeeForm();
|
return new InsertEmployeeForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登録画面表示処理
|
|
||||||
*
|
|
||||||
* @param insertEmployeeForm 登録画面のフォーム
|
|
||||||
* @param model ビューにデータを渡すためのコンテナ
|
|
||||||
* @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 {
|
try {
|
||||||
// 部署コードリストを作成し、画面に返す値としてセット
|
model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||||
model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, DepartmentForm.convertFrom(searchDepartment.selectAll()));
|
DepartmentForm.convertFrom(searchDepartment.selectAll()));
|
||||||
|
|
||||||
// パラメータをセット
|
|
||||||
model.addAttribute(PageReturnAttributeKeyword.INSERT_EMPLOYEE_FORM, insertEmployeeForm);
|
model.addAttribute(PageReturnAttributeKeyword.INSERT_EMPLOYEE_FORM, insertEmployeeForm);
|
||||||
|
|
||||||
// 登録画面に遷移
|
|
||||||
return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML;
|
return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML;
|
||||||
|
|
||||||
} catch (Exception e) {
|
} 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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,29 +24,12 @@ 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;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ログイン関連のコントローラ
|
|
||||||
*/
|
|
||||||
@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;
|
||||||
@@ -50,99 +46,59 @@ public class LoginController {
|
|||||||
return new LoginUserForm();
|
return new LoginUserForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 画面から渡ってきたパラメータのチェックを行う
|
|
||||||
*
|
|
||||||
* @param loginInfoForm mailAddress, password を保持したインスタンス
|
|
||||||
* @param model ビューにデータを渡すためのコンテナ
|
|
||||||
* @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に対するメッセージ
|
|
||||||
final String LOGIN_ERROR = "IDまたはパスワードが間違っています";
|
final String LOGIN_ERROR = "IDまたはパスワードが間違っています";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// mailAddress, password の入力に誤りがあるかチェック
|
|
||||||
if (!LoginUserForm.checkParameter(loginInfoForm)) {
|
if (!LoginUserForm.checkParameter(loginInfoForm)) {
|
||||||
|
|
||||||
// mail,passwordが仕様を満たしていない場合
|
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR,
|
||||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(MAIL_ADDRESS_PASSWORD_ERROR));
|
new MessageForm(MAIL_ADDRESS_PASSWORD_ERROR));
|
||||||
|
|
||||||
// エラーだった場合に login.html に処理を戻す。mailAddress, password を login.htmlに表示するために
|
|
||||||
// ここで addAttribute する
|
|
||||||
model.addAttribute(PageReturnAttributeKeyword.LOGIN_INFO_FORM, loginInfoForm);
|
model.addAttribute(PageReturnAttributeKeyword.LOGIN_INFO_FORM, loginInfoForm);
|
||||||
// login.html に遷移する様に設定
|
|
||||||
return TransitionTargetPageNameKeyword.LOGIN_HTML;
|
return TransitionTargetPageNameKeyword.LOGIN_HTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Login者情報インスタンスを作成
|
|
||||||
LoginInfo loginInfo = createLoginInfo(httpSession, loginInfoForm);
|
LoginInfo loginInfo = createLoginInfo(httpSession, loginInfoForm);
|
||||||
|
|
||||||
// login 可能かチェック
|
|
||||||
if (!login.canLogin(loginInfo)) {
|
if (!login.canLogin(loginInfo)) {
|
||||||
// ログイン不可の場合、エラーメッセージをセットして入力された値とともに login.html を再表示
|
|
||||||
// 画面に表示するエラーメッセージをセット
|
|
||||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(LOGIN_ERROR));
|
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(LOGIN_ERROR));
|
||||||
// 画面に表示する mailAddress, password をセット
|
|
||||||
model.addAttribute(PageReturnAttributeKeyword.LOGIN_INFO_FORM, loginInfoForm);
|
model.addAttribute(PageReturnAttributeKeyword.LOGIN_INFO_FORM, loginInfoForm);
|
||||||
// login.html に遷移
|
|
||||||
return TransitionTargetPageNameKeyword.LOGIN_HTML;
|
return TransitionTargetPageNameKeyword.LOGIN_HTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ログイン(インスタンス作成)
|
|
||||||
LoginUser loginUser = login.doLogin(loginInfo);
|
LoginUser loginUser = login.doLogin(loginInfo);
|
||||||
|
|
||||||
// ログイン者の情報をセッション情報に格納
|
|
||||||
// セッションに loginUser 情報を保持し続ける = ログイン中として扱う
|
|
||||||
httpSession.setAttribute(SessionKeyword.LOGIN_USER, LoginUserForm.convertFrom(loginUser));
|
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 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 値 を取得
|
|
||||||
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,21 +14,16 @@ 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 com.example.rhizome.app.presentation.form.LoginUserForm;
|
||||||
|
|
||||||
import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.LOGOUT;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ログアウト処理のコントローラ
|
|
||||||
*/
|
|
||||||
@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;
|
||||||
@@ -41,30 +38,19 @@ public class LogoutController {
|
|||||||
return new LoginUserForm();
|
return new LoginUserForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* ログアウト処理
|
|
||||||
*
|
|
||||||
* @param model ビューにデータを渡すためのコンテナ
|
|
||||||
* @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 に遷移
|
|
||||||
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,16 +1,14 @@
|
|||||||
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;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* メニュー画面表示用コントローラ
|
|
||||||
*/
|
|
||||||
@Controller
|
@Controller
|
||||||
public class MenuController {
|
public class MenuController {
|
||||||
|
|
||||||
@@ -19,14 +17,10 @@ public class MenuController {
|
|||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,17 @@
|
|||||||
package com.example.rhizome.app.presentation.controller;
|
package com.example.rhizome.app.presentation.controller;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
|
||||||
import com.example.rhizome.aop.aspect.PermissionCheck;
|
import com.example.rhizome.aop.aspect.PermissionCheck;
|
||||||
import com.example.rhizome.aop.aspect.SessionCheck;
|
import com.example.rhizome.aop.aspect.SessionCheck;
|
||||||
import com.example.rhizome.app.domain.service.SearchDepartment;
|
import com.example.rhizome.app.domain.service.SearchDepartment;
|
||||||
@@ -9,26 +21,11 @@ import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTa
|
|||||||
import com.example.rhizome.app.presentation.form.DepartmentForm;
|
import com.example.rhizome.app.presentation.form.DepartmentForm;
|
||||||
import com.example.rhizome.app.presentation.form.EmployeeInfoForm;
|
import com.example.rhizome.app.presentation.form.EmployeeInfoForm;
|
||||||
import com.example.rhizome.app.presentation.form.SearchConditionEmployeeForm;
|
import com.example.rhizome.app.presentation.form.SearchConditionEmployeeForm;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.ui.Model;
|
|
||||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpSession;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 社員検索画面用コントローラ リスト全件表示、検索表示、更新、削除が可能
|
|
||||||
*/
|
|
||||||
@Controller
|
@Controller
|
||||||
public class SelectEmployeeController {
|
public class SelectEmployeeController {
|
||||||
|
|
||||||
// ログ出力用インスタンス
|
|
||||||
private final static Logger LOGGER = Logger.getLogger(SelectEmployeeController.class.getName());
|
private final static Logger LOGGER = Logger.getLogger(SelectEmployeeController.class.getName());
|
||||||
// エラーメッセージ用の定数フィールド
|
|
||||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||||
|
|
||||||
HttpSession httpSession;
|
HttpSession httpSession;
|
||||||
@@ -36,7 +33,8 @@ public class SelectEmployeeController {
|
|||||||
SearchEmployeeInfo searchEmployeeInfo;
|
SearchEmployeeInfo searchEmployeeInfo;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public SelectEmployeeController(HttpSession httpSession, SearchDepartment searchDepartment, SearchEmployeeInfo searchEmployeeInfo) {
|
public SelectEmployeeController(HttpSession httpSession, SearchDepartment searchDepartment,
|
||||||
|
SearchEmployeeInfo searchEmployeeInfo) {
|
||||||
this.httpSession = httpSession;
|
this.httpSession = httpSession;
|
||||||
this.searchDepartment = searchDepartment;
|
this.searchDepartment = searchDepartment;
|
||||||
this.searchEmployeeInfo = searchEmployeeInfo;
|
this.searchEmployeeInfo = searchEmployeeInfo;
|
||||||
@@ -47,75 +45,42 @@ public class SelectEmployeeController {
|
|||||||
return new SearchConditionEmployeeForm();
|
return new SearchConditionEmployeeForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 社員検索画面表示処理コントローラ
|
|
||||||
*
|
|
||||||
* @param searchConditionEmployeeForm 検索画面のフォーム
|
|
||||||
* @param model ビューにデータを渡すためのコンテナ
|
|
||||||
* @return 遷移先の画面
|
|
||||||
*/
|
|
||||||
@PermissionCheck
|
@PermissionCheck
|
||||||
@SessionCheck
|
@SessionCheck
|
||||||
@RequestMapping(value = TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_INFO, method = RequestMethod.POST)
|
@RequestMapping(value = TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_INFO, method = RequestMethod.POST)
|
||||||
public String select(SearchConditionEmployeeForm searchConditionEmployeeForm, Model model) {
|
public String select(SearchConditionEmployeeForm searchConditionEmployeeForm, Model model) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// 部署一覧を取得し、画面に返す用のクラスに詰め替える
|
|
||||||
// 作成した部署一覧をセット
|
|
||||||
model.addAttribute(
|
model.addAttribute(
|
||||||
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||||
DepartmentForm.convertFrom(searchDepartment.selectAll())
|
DepartmentForm.convertFrom(searchDepartment.selectAll()));
|
||||||
);
|
|
||||||
|
|
||||||
// 検索条件を元に検索を実施
|
model.addAttribute(PageReturnAttributeKeyword.EMPLOYEE_INFO_FORM_LIST, EmployeeInfoForm.convertFrom(
|
||||||
// 取得した EmployeeInfo( employee + department )の情報を画面に返す用の型に詰め替えてセット
|
searchEmployeeInfo.searchBy(SearchConditionEmployeeForm.convertTo(searchConditionEmployeeForm))));
|
||||||
model.addAttribute(PageReturnAttributeKeyword.EMPLOYEE_INFO_FORM_LIST, EmployeeInfoForm.convertFrom(searchEmployeeInfo.searchBy(SearchConditionEmployeeForm.convertTo(searchConditionEmployeeForm))));
|
|
||||||
// 検索ページに遷移
|
|
||||||
return TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_HTML;
|
return TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_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 model ビューにデータを渡すためのコンテナ
|
|
||||||
* @return 遷移先の画面
|
|
||||||
*/
|
|
||||||
@PermissionCheck
|
|
||||||
@SessionCheck
|
|
||||||
@RequestMapping(value = TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_INFO_FORM_EMPTY, method = RequestMethod.POST)
|
@RequestMapping(value = TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_INFO_FORM_EMPTY, method = RequestMethod.POST)
|
||||||
public String select(Model model) {
|
public String select(Model model) {
|
||||||
|
|
||||||
// 部署一覧を取得し、画面に返す用のクラスに詰め替える
|
|
||||||
// 作成した部署一覧をセット
|
|
||||||
model.addAttribute(
|
model.addAttribute(
|
||||||
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||||
DepartmentForm.convertFrom(searchDepartment.selectAll())
|
DepartmentForm.convertFrom(searchDepartment.selectAll()));
|
||||||
);
|
|
||||||
|
|
||||||
// 検索条件を元に検索を実施
|
|
||||||
model.addAttribute(PageReturnAttributeKeyword.EMPLOYEE_INFO_FORM_LIST,
|
model.addAttribute(PageReturnAttributeKeyword.EMPLOYEE_INFO_FORM_LIST,
|
||||||
EmployeeInfoForm.convertFrom(
|
EmployeeInfoForm.convertFrom(
|
||||||
searchEmployeeInfo.searchBy(
|
searchEmployeeInfo.searchBy(
|
||||||
SearchConditionEmployeeForm.convertTo(searchConditionEmployeeForm())
|
SearchConditionEmployeeForm.convertTo(searchConditionEmployeeForm()))));
|
||||||
)));
|
|
||||||
|
|
||||||
// 検索ページに遷移
|
|
||||||
return TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_HTML;
|
return TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_HTML;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,19 @@
|
|||||||
package com.example.rhizome.app.presentation.controller;
|
package com.example.rhizome.app.presentation.controller;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
import com.example.rhizome.aop.aspect.PermissionCheck;
|
import com.example.rhizome.aop.aspect.PermissionCheck;
|
||||||
import com.example.rhizome.aop.aspect.SessionCheck;
|
import com.example.rhizome.aop.aspect.SessionCheck;
|
||||||
import com.example.rhizome.app.domain.model.EmployeeInfo;
|
import com.example.rhizome.app.domain.model.EmployeeInfo;
|
||||||
@@ -12,28 +26,11 @@ import com.example.rhizome.app.presentation.form.DepartmentForm;
|
|||||||
import com.example.rhizome.app.presentation.form.MessageForm;
|
import com.example.rhizome.app.presentation.form.MessageForm;
|
||||||
import com.example.rhizome.app.presentation.form.SearchConditionEmployeeForm;
|
import com.example.rhizome.app.presentation.form.SearchConditionEmployeeForm;
|
||||||
import com.example.rhizome.app.presentation.form.UpdateEmployeeInfoForm;
|
import com.example.rhizome.app.presentation.form.UpdateEmployeeInfoForm;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.ui.Model;
|
|
||||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpSession;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新対象の employee が存在するか確認する為のコントローラ
|
|
||||||
*/
|
|
||||||
@Controller
|
@Controller
|
||||||
public class UpdateEmployeeController {
|
public class UpdateEmployeeController {
|
||||||
|
|
||||||
// ログ出力用インスタンス
|
|
||||||
private final static Logger LOGGER = Logger.getLogger(UpdateEmployeeController.class.getName());
|
private final static Logger LOGGER = Logger.getLogger(UpdateEmployeeController.class.getName());
|
||||||
// エラーメッセージ用の定数フィールド
|
|
||||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||||
|
|
||||||
HttpSession httpSession;
|
HttpSession httpSession;
|
||||||
@@ -41,7 +38,8 @@ public class UpdateEmployeeController {
|
|||||||
SearchEmployeeInfo searchEmployeeInfo;
|
SearchEmployeeInfo searchEmployeeInfo;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public UpdateEmployeeController(HttpSession httpSession, SearchDepartment searchDepartment, SearchEmployeeInfo searchEmployeeInfo) {
|
public UpdateEmployeeController(HttpSession httpSession, SearchDepartment searchDepartment,
|
||||||
|
SearchEmployeeInfo searchEmployeeInfo) {
|
||||||
this.httpSession = httpSession;
|
this.httpSession = httpSession;
|
||||||
this.searchDepartment = searchDepartment;
|
this.searchDepartment = searchDepartment;
|
||||||
this.searchEmployeeInfo = searchEmployeeInfo;
|
this.searchEmployeeInfo = searchEmployeeInfo;
|
||||||
@@ -52,13 +50,6 @@ public class UpdateEmployeeController {
|
|||||||
return new SearchConditionEmployeeForm();
|
return new SearchConditionEmployeeForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新対象の employee が存在するか確認する為のコントローラ
|
|
||||||
*
|
|
||||||
* @param idEmployee 更新対象の employee の id
|
|
||||||
* @param model ビューにデータを渡すためのコンテナ
|
|
||||||
* @return 遷移先の画面
|
|
||||||
*/
|
|
||||||
@PermissionCheck
|
@PermissionCheck
|
||||||
@SessionCheck
|
@SessionCheck
|
||||||
@RequestMapping(value = TransitionTargetPageNameKeyword.SHOW_UPDATE_EMPLOYEE, method = RequestMethod.POST)
|
@RequestMapping(value = TransitionTargetPageNameKeyword.SHOW_UPDATE_EMPLOYEE, method = RequestMethod.POST)
|
||||||
@@ -66,10 +57,9 @@ public class UpdateEmployeeController {
|
|||||||
final String UPDATE_TARGET_ID_NOT_FOUND = "更新対象のデータが見つかりません。";
|
final String UPDATE_TARGET_ID_NOT_FOUND = "更新対象のデータが見つかりません。";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 部署一覧を取得し画面に返す値としてセット
|
model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||||
model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, DepartmentForm.convertFrom(searchDepartment.selectAll()));
|
DepartmentForm.convertFrom(searchDepartment.selectAll()));
|
||||||
|
|
||||||
// id を条件に更新対象のレコードを検索、取得する
|
|
||||||
List<EmployeeInfo> employeeInfoList = searchEmployeeInfo.searchBy(
|
List<EmployeeInfo> employeeInfoList = searchEmployeeInfo.searchBy(
|
||||||
new SearchConditionEmployee(idEmployee,
|
new SearchConditionEmployee(idEmployee,
|
||||||
null,
|
null,
|
||||||
@@ -77,29 +67,23 @@ public class UpdateEmployeeController {
|
|||||||
null,
|
null,
|
||||||
null));
|
null));
|
||||||
|
|
||||||
// DBに更新対象のデータがあるか
|
|
||||||
if (employeeInfoList.isEmpty()) {
|
if (employeeInfoList.isEmpty()) {
|
||||||
// ない場合はエラーメッセージをセットして検索画面に戻る
|
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR,
|
||||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(UPDATE_TARGET_ID_NOT_FOUND));
|
new MessageForm(UPDATE_TARGET_ID_NOT_FOUND));
|
||||||
return "forward:" + TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_INFO;
|
return "forward:" + TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_INFO;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新画面に遷移
|
model.addAttribute(PageReturnAttributeKeyword.UPDATE_EMPLOYEE_INFO_FORM,
|
||||||
model.addAttribute(PageReturnAttributeKeyword.UPDATE_EMPLOYEE_INFO_FORM, UpdateEmployeeInfoForm.convertFrom(employeeInfoList.get(0)));
|
UpdateEmployeeInfoForm.convertFrom(employeeInfoList.get(0)));
|
||||||
|
|
||||||
// Update画面に遷移
|
|
||||||
return TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_INPUT_HTML;
|
return TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_INPUT_HTML;
|
||||||
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} 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;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,18 @@
|
|||||||
package com.example.rhizome.app.presentation.controller;
|
package com.example.rhizome.app.presentation.controller;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
|
||||||
import com.example.rhizome.aop.aspect.PermissionCheck;
|
import com.example.rhizome.aop.aspect.PermissionCheck;
|
||||||
import com.example.rhizome.aop.aspect.SessionCheck;
|
import com.example.rhizome.aop.aspect.SessionCheck;
|
||||||
@@ -15,28 +28,11 @@ import com.example.rhizome.app.presentation.form.DepartmentForm;
|
|||||||
import com.example.rhizome.app.presentation.form.LoginUserForm;
|
import com.example.rhizome.app.presentation.form.LoginUserForm;
|
||||||
import com.example.rhizome.app.presentation.form.MessageForm;
|
import com.example.rhizome.app.presentation.form.MessageForm;
|
||||||
import com.example.rhizome.app.presentation.form.UpdateEmployeeInfoForm;
|
import com.example.rhizome.app.presentation.form.UpdateEmployeeInfoForm;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.ui.Model;
|
|
||||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpSession;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* employee を更新して結果を返す為のコントローラ
|
|
||||||
*/
|
|
||||||
@Controller
|
@Controller
|
||||||
public class UpdateEmployeeResultController {
|
public class UpdateEmployeeResultController {
|
||||||
|
|
||||||
// ログ出力用インスタンス
|
|
||||||
private final static Logger LOGGER = Logger.getLogger(UpdateEmployeeController.class.getName());
|
private final static Logger LOGGER = Logger.getLogger(UpdateEmployeeController.class.getName());
|
||||||
// エラーメッセージ用の定数フィールド
|
|
||||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||||
|
|
||||||
HttpSession httpSession;
|
HttpSession httpSession;
|
||||||
@@ -45,36 +41,22 @@ public class UpdateEmployeeResultController {
|
|||||||
UpdateEmployee updateEmployee;
|
UpdateEmployee updateEmployee;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public UpdateEmployeeResultController(HttpSession httpSession, SearchDepartment searchDepartment, SearchEmployee searchEmployee, UpdateEmployee updateEmployee) {
|
public UpdateEmployeeResultController(HttpSession httpSession, SearchDepartment searchDepartment,
|
||||||
|
SearchEmployee searchEmployee, UpdateEmployee updateEmployee) {
|
||||||
this.httpSession = httpSession;
|
this.httpSession = httpSession;
|
||||||
this.searchDepartment = searchDepartment;
|
this.searchDepartment = searchDepartment;
|
||||||
this.searchEmployee = searchEmployee;
|
this.searchEmployee = searchEmployee;
|
||||||
this.updateEmployee = updateEmployee;
|
this.updateEmployee = updateEmployee;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private static boolean checkDuplicateMailAddress(List<Employee> employeeList,
|
||||||
* メールアドレスの重複チェック
|
UpdateEmployeeInfoForm updateEmployeeInfoForm) {
|
||||||
*
|
|
||||||
* @param employeeList 元の employeeList
|
|
||||||
* @param updateEmployeeInfoForm 更新対象のデータ
|
|
||||||
* @return true:重複無し false:重複あり
|
|
||||||
*/
|
|
||||||
private static boolean checkDuplicateMailAddress(List<Employee> employeeList, UpdateEmployeeInfoForm updateEmployeeInfoForm) {
|
|
||||||
// メールアドレスが既に使われていた場合
|
|
||||||
if (!employeeList.isEmpty()) {
|
if (!employeeList.isEmpty()) {
|
||||||
// 重複が有った場合に、同一人物のものであれば上書きOKとする
|
|
||||||
return Objects.equals(employeeList.get(0).getIdEmployee(), updateEmployeeInfoForm.getIdEmployee());
|
return Objects.equals(employeeList.get(0).getIdEmployee(), updateEmployeeInfoForm.getIdEmployee());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新結果画面表示処理
|
|
||||||
*
|
|
||||||
* @param updateEmployeeInfoForm 更新画面のフォーム
|
|
||||||
* @param model ビューにデータを渡すためのコンテナ
|
|
||||||
* @return 遷移先の画面
|
|
||||||
*/
|
|
||||||
@PermissionCheck
|
@PermissionCheck
|
||||||
@SessionCheck
|
@SessionCheck
|
||||||
@RequestMapping(value = TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_RESULT, method = RequestMethod.POST)
|
@RequestMapping(value = TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_RESULT, method = RequestMethod.POST)
|
||||||
@@ -87,51 +69,39 @@ public class UpdateEmployeeResultController {
|
|||||||
|
|
||||||
final String UPDATE_COMPLETE = "更新が完了しました。";
|
final String UPDATE_COMPLETE = "更新が完了しました。";
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// 部署一覧取得
|
model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||||
model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, DepartmentForm.convertFrom(searchDepartment.selectAll()));
|
DepartmentForm.convertFrom(searchDepartment.selectAll()));
|
||||||
|
|
||||||
// パスワードが仕様を満たしているか確認
|
|
||||||
String error = UpdateEmployeeInfoForm.validatePassword(
|
String error = UpdateEmployeeInfoForm.validatePassword(
|
||||||
updateEmployeeInfoForm.getPassword(),
|
updateEmployeeInfoForm.getPassword(),
|
||||||
updateEmployeeInfoForm.getPasswordConfirm()
|
updateEmployeeInfoForm.getPasswordConfirm());
|
||||||
);
|
|
||||||
|
|
||||||
// エラーが存在するか
|
|
||||||
if (!error.isBlank()) {
|
if (!error.isBlank()) {
|
||||||
// エラーが存在する場合、更新画面に遷移
|
|
||||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(error));
|
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(error));
|
||||||
model.addAttribute(PageReturnAttributeKeyword.UPDATE_EMPLOYEE_INFO_FORM, updateEmployeeInfoForm);
|
model.addAttribute(PageReturnAttributeKeyword.UPDATE_EMPLOYEE_INFO_FORM, updateEmployeeInfoForm);
|
||||||
|
|
||||||
return TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_INPUT_HTML;
|
return TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_INPUT_HTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
// メールアドレスを元に検索
|
|
||||||
List<Employee> employeeList = searchEmployee.searchEmployee(updateEmployeeInfoForm.getMailAddress());
|
List<Employee> employeeList = searchEmployee.searchEmployee(updateEmployeeInfoForm.getMailAddress());
|
||||||
|
|
||||||
// 既に登録済みのメールアドレスが存在するか
|
|
||||||
if (!checkDuplicateMailAddress(employeeList, updateEmployeeInfoForm)) {
|
if (!checkDuplicateMailAddress(employeeList, updateEmployeeInfoForm)) {
|
||||||
// 存在する場合はエラーメッセージを設定して更新入力画面に遷移
|
|
||||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DUPLICATION));
|
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DUPLICATION));
|
||||||
model.addAttribute(PageReturnAttributeKeyword.UPDATE_EMPLOYEE_INFO_FORM, updateEmployeeInfoForm);
|
model.addAttribute(PageReturnAttributeKeyword.UPDATE_EMPLOYEE_INFO_FORM, updateEmployeeInfoForm);
|
||||||
|
|
||||||
return TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_INPUT_HTML;
|
return TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_INPUT_HTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
// session 情報からログイン者の情報を取得
|
|
||||||
LoginUserForm loginUserForm = (LoginUserForm) httpSession.getAttribute(SessionKeyword.LOGIN_USER);
|
LoginUserForm loginUserForm = (LoginUserForm) httpSession.getAttribute(SessionKeyword.LOGIN_USER);
|
||||||
|
|
||||||
// ログイン者が更新対象で、権限を管理者権限から一般権限に変更しようとしているかチェック
|
|
||||||
if (isUpdateTargetLoginUserAdminToNormal(updateEmployeeInfoForm, loginUserForm)) {
|
if (isUpdateTargetLoginUserAdminToNormal(updateEmployeeInfoForm, loginUserForm)) {
|
||||||
// 存在する場合はエラーメッセージを設定して更新入力画面に遷移
|
|
||||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(ADMIN_USER));
|
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(ADMIN_USER));
|
||||||
model.addAttribute(PageReturnAttributeKeyword.UPDATE_EMPLOYEE_INFO_FORM, updateEmployeeInfoForm);
|
model.addAttribute(PageReturnAttributeKeyword.UPDATE_EMPLOYEE_INFO_FORM, updateEmployeeInfoForm);
|
||||||
return TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_INPUT_HTML;
|
return TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_INPUT_HTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 画面から渡ってきた値が必須を満たしているか
|
|
||||||
if (!UpdateEmployeeInfoForm.hasErrorParameter(updateEmployeeInfoForm)) {
|
if (!UpdateEmployeeInfoForm.hasErrorParameter(updateEmployeeInfoForm)) {
|
||||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(NOTHING));
|
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(NOTHING));
|
||||||
model.addAttribute(PageReturnAttributeKeyword.UPDATE_EMPLOYEE_INFO_FORM, updateEmployeeInfoForm);
|
model.addAttribute(PageReturnAttributeKeyword.UPDATE_EMPLOYEE_INFO_FORM, updateEmployeeInfoForm);
|
||||||
@@ -139,7 +109,6 @@ public class UpdateEmployeeResultController {
|
|||||||
return TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_INPUT_HTML;
|
return TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_INPUT_HTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新前のデータを取得
|
|
||||||
Employee beforeEmployee = searchEmployee.searchEmployeeByIdEmployee(updateEmployeeInfoForm.getIdEmployee());
|
Employee beforeEmployee = searchEmployee.searchEmployeeByIdEmployee(updateEmployeeInfoForm.getIdEmployee());
|
||||||
if (beforeEmployee.getIdEmployee() == null) {
|
if (beforeEmployee.getIdEmployee() == null) {
|
||||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(NO_TARGET));
|
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(NO_TARGET));
|
||||||
@@ -148,59 +117,37 @@ public class UpdateEmployeeResultController {
|
|||||||
return TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_INPUT_HTML;
|
return TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_INPUT_HTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 画面用の型からビジネスロジック用のモデルに変換し、Updateを実行
|
|
||||||
updateEmployee.updateEmployee(beforeEmployee, UpdateEmployeeInfoForm.convertTo(updateEmployeeInfoForm));
|
updateEmployee.updateEmployee(beforeEmployee, UpdateEmployeeInfoForm.convertTo(updateEmployeeInfoForm));
|
||||||
|
|
||||||
// Update後の情報を再取得
|
|
||||||
LoginUser updatedTargetEmployee = searchEmployee.searchLoginUser(updateEmployeeInfoForm.getMailAddress());
|
LoginUser updatedTargetEmployee = searchEmployee.searchLoginUser(updateEmployeeInfoForm.getMailAddress());
|
||||||
|
|
||||||
// ログイン者と更新した対象が同じアカウントだった場合、session情報を更新
|
|
||||||
if (Objects.equals(updatedTargetEmployee.getIdEmployee(), loginUserForm.getIdEmployee())) {
|
if (Objects.equals(updatedTargetEmployee.getIdEmployee(), loginUserForm.getIdEmployee())) {
|
||||||
// ログイン者の情報をセッション情報に格納
|
|
||||||
httpSession.setAttribute(SessionKeyword.LOGIN_USER, LoginUserForm.convertFrom(updatedTargetEmployee));
|
httpSession.setAttribute(SessionKeyword.LOGIN_USER, LoginUserForm.convertFrom(updatedTargetEmployee));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新結果のメッセージを画面にセットし一覧画面に遷移
|
|
||||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_INFO, new MessageForm(UPDATE_COMPLETE));
|
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_INFO, new MessageForm(UPDATE_COMPLETE));
|
||||||
|
|
||||||
// forward 先で不用意な動作をしないために UpdateEmployeeInfoForm をクリア
|
|
||||||
return "forward:" + TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_INFO_FORM_EMPTY;
|
return "forward:" + TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_INFO_FORM_EMPTY;
|
||||||
|
|
||||||
|
|
||||||
} 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private boolean isUpdateTargetLoginUserAdminToNormal(UpdateEmployeeInfoForm updateEmployeeInfoForm,
|
||||||
* ログイン者がログイン者自身を更新する際
|
LoginUserForm loginUserForm) {
|
||||||
* 管理者権限から一般権限に変更する内容も含まれているかチェックする
|
|
||||||
*
|
|
||||||
* @param updateEmployeeInfoForm 更新対象データ
|
|
||||||
* @param loginUserForm ログイン者情報
|
|
||||||
* @return true:ログイン者自身のデータをUpdate管理者→一般に権限変更しようとしている。
|
|
||||||
* false:Update対象者がログイン者自身ではない or 管理者権限 → 一般権限 への更新は含まれていない
|
|
||||||
*/
|
|
||||||
private boolean isUpdateTargetLoginUserAdminToNormal(UpdateEmployeeInfoForm updateEmployeeInfoForm, LoginUserForm loginUserForm) {
|
|
||||||
|
|
||||||
// ログイン者が今回の更新対象か
|
|
||||||
if (!Objects.equals(updateEmployeeInfoForm.getIdEmployee(), loginUserForm.getIdEmployee())) {
|
if (!Objects.equals(updateEmployeeInfoForm.getIdEmployee(), loginUserForm.getIdEmployee())) {
|
||||||
// 今回の対象者はログイン者ではない
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 管理者から一般権限への変更があるか
|
|
||||||
return updateEmployeeInfoForm.getAdminAuth().equals(0);
|
return updateEmployeeInfoForm.getAdminAuth().equals(0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,18 @@
|
|||||||
package com.example.rhizome.app.presentation.controller;
|
package com.example.rhizome.app.presentation.controller;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
|
||||||
import com.example.rhizome.aop.aspect.PermissionCheck;
|
import com.example.rhizome.aop.aspect.PermissionCheck;
|
||||||
import com.example.rhizome.aop.aspect.SessionCheck;
|
import com.example.rhizome.aop.aspect.SessionCheck;
|
||||||
@@ -12,29 +25,12 @@ import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTa
|
|||||||
import com.example.rhizome.app.presentation.form.LoginUserForm;
|
import com.example.rhizome.app.presentation.form.LoginUserForm;
|
||||||
import com.example.rhizome.app.presentation.form.MessageForm;
|
import com.example.rhizome.app.presentation.form.MessageForm;
|
||||||
import com.example.rhizome.app.presentation.form.UpdatePersonalUserForm;
|
import com.example.rhizome.app.presentation.form.UpdatePersonalUserForm;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.ui.Model;
|
|
||||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpSession;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 個人情報更新用コントローラ
|
|
||||||
*/
|
|
||||||
@Controller
|
@Controller
|
||||||
public class UpdatePersonalEmployeeResultController {
|
public class UpdatePersonalEmployeeResultController {
|
||||||
|
|
||||||
// ログ出力用インスタンス
|
|
||||||
private final static Logger LOGGER = Logger.getLogger(UpdatePersonalEmployeeResultController.class.getName());
|
private final static Logger LOGGER = Logger.getLogger(UpdatePersonalEmployeeResultController.class.getName());
|
||||||
|
|
||||||
// エラーメッセージ用の定数フィールド
|
|
||||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||||
|
|
||||||
HttpSession httpSession;
|
HttpSession httpSession;
|
||||||
@@ -42,23 +38,16 @@ public class UpdatePersonalEmployeeResultController {
|
|||||||
UpdateEmployee updateEmployee;
|
UpdateEmployee updateEmployee;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public UpdatePersonalEmployeeResultController(HttpSession httpSession, SearchEmployee searchEmployee, UpdateEmployee updateEmployee) {
|
public UpdatePersonalEmployeeResultController(HttpSession httpSession, SearchEmployee searchEmployee,
|
||||||
|
UpdateEmployee updateEmployee) {
|
||||||
this.httpSession = httpSession;
|
this.httpSession = httpSession;
|
||||||
this.searchEmployee = searchEmployee;
|
this.searchEmployee = searchEmployee;
|
||||||
this.updateEmployee = updateEmployee;
|
this.updateEmployee = updateEmployee;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private static boolean checkDuplicateMailAddress(List<Employee> employeeList,
|
||||||
* メールアドレスの重複チェック
|
UpdatePersonalUserForm updatePersonalUserForm) {
|
||||||
*
|
|
||||||
* @param employeeList 元の employeeList
|
|
||||||
* @param updatePersonalUserForm 更新対象のデータ
|
|
||||||
* @return true:重複無し false:重複あり
|
|
||||||
*/
|
|
||||||
private static boolean checkDuplicateMailAddress(List<Employee> employeeList, UpdatePersonalUserForm updatePersonalUserForm) {
|
|
||||||
// メールアドレスが既に使われていた場合
|
|
||||||
if (!employeeList.isEmpty()) {
|
if (!employeeList.isEmpty()) {
|
||||||
// 更新対象のデータと同じIDの場合は重複していないとみなす
|
|
||||||
return Objects.equals(employeeList.get(0).getIdEmployee(), updatePersonalUserForm.getIdEmployee());
|
return Objects.equals(employeeList.get(0).getIdEmployee(), updatePersonalUserForm.getIdEmployee());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -69,13 +58,6 @@ public class UpdatePersonalEmployeeResultController {
|
|||||||
return new UpdatePersonalUserForm();
|
return new UpdatePersonalUserForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 個人情報更新結果画面表示処理
|
|
||||||
*
|
|
||||||
* @param updatePersonalUserForm 個人情報更新画面のフォーム
|
|
||||||
* @param model ビューにデータを渡すためのコンテナ
|
|
||||||
* @return 遷移先の画面
|
|
||||||
*/
|
|
||||||
@PermissionCheck
|
@PermissionCheck
|
||||||
@SessionCheck
|
@SessionCheck
|
||||||
@RequestMapping(value = TransitionTargetPageNameKeyword.PERSONAL_UPDATE_RESULT, method = RequestMethod.POST)
|
@RequestMapping(value = TransitionTargetPageNameKeyword.PERSONAL_UPDATE_RESULT, method = RequestMethod.POST)
|
||||||
@@ -86,77 +68,59 @@ public class UpdatePersonalEmployeeResultController {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// 更新完了画面からの遷移の場合
|
|
||||||
if (updatePersonalUserForm.getIdEmployee() == null) {
|
if (updatePersonalUserForm.getIdEmployee() == null) {
|
||||||
// ログイン者の情報を取得
|
|
||||||
LoginUserForm loginUserForm = (LoginUserForm) httpSession.getAttribute(SessionKeyword.LOGIN_USER);
|
LoginUserForm loginUserForm = (LoginUserForm) httpSession.getAttribute(SessionKeyword.LOGIN_USER);
|
||||||
// ログイン者の情報を元に個人情報更新画面の初期表示用のインスタンスを作成
|
model.addAttribute(PageReturnAttributeKeyword.UPDATE_PERSONAL_EMPLOYEE_USER_FORM, UpdatePersonalUserForm
|
||||||
model.addAttribute(PageReturnAttributeKeyword.UPDATE_PERSONAL_EMPLOYEE_USER_FORM, UpdatePersonalUserForm.convertFrom(searchEmployee.searchLoginUser(loginUserForm.getMailAddress())));
|
.convertFrom(searchEmployee.searchLoginUser(loginUserForm.getMailAddress())));
|
||||||
|
|
||||||
return TransitionTargetPageNameKeyword.UPDATE_PERSONAL_EMPLOYEE_INPUT_HTML;
|
return TransitionTargetPageNameKeyword.UPDATE_PERSONAL_EMPLOYEE_INPUT_HTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
// パスワードが仕様を満たしているかチェック
|
|
||||||
String error = UpdatePersonalUserForm.validatePassword(
|
String error = UpdatePersonalUserForm.validatePassword(
|
||||||
updatePersonalUserForm.getPassword(),
|
updatePersonalUserForm.getPassword(),
|
||||||
updatePersonalUserForm.getPasswordConfirm()
|
updatePersonalUserForm.getPasswordConfirm());
|
||||||
);
|
|
||||||
|
|
||||||
// エラーがあるか
|
|
||||||
if (!error.isBlank()) {
|
if (!error.isBlank()) {
|
||||||
// エラーが有る場合メッセージをセットして個人情報更新入力画面に遷移
|
|
||||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(error));
|
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(error));
|
||||||
model.addAttribute(PageReturnAttributeKeyword.UPDATE_PERSONAL_EMPLOYEE_USER_FORM, updatePersonalUserForm);
|
model.addAttribute(PageReturnAttributeKeyword.UPDATE_PERSONAL_EMPLOYEE_USER_FORM,
|
||||||
|
updatePersonalUserForm);
|
||||||
|
|
||||||
return TransitionTargetPageNameKeyword.UPDATE_PERSONAL_EMPLOYEE_INPUT_HTML;
|
return TransitionTargetPageNameKeyword.UPDATE_PERSONAL_EMPLOYEE_INPUT_HTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 入力必須を満たしているか
|
|
||||||
if (!UpdatePersonalUserForm.hasErrorParameter(updatePersonalUserForm)) {
|
if (!UpdatePersonalUserForm.hasErrorParameter(updatePersonalUserForm)) {
|
||||||
// 満たしていない場合、メッセージをセットして個人情報更新入力画面に遷移
|
|
||||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(NOTHING));
|
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(NOTHING));
|
||||||
model.addAttribute(PageReturnAttributeKeyword.UPDATE_PERSONAL_EMPLOYEE_USER_FORM, updatePersonalUserForm);
|
model.addAttribute(PageReturnAttributeKeyword.UPDATE_PERSONAL_EMPLOYEE_USER_FORM,
|
||||||
|
updatePersonalUserForm);
|
||||||
|
|
||||||
return TransitionTargetPageNameKeyword.UPDATE_PERSONAL_EMPLOYEE_INPUT_HTML;
|
return TransitionTargetPageNameKeyword.UPDATE_PERSONAL_EMPLOYEE_INPUT_HTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
// メールアドレス重複チェック
|
|
||||||
if (!checkDuplicateMailAddress(
|
if (!checkDuplicateMailAddress(
|
||||||
searchEmployee.searchEmployee(updatePersonalUserForm.getMailAddress()),
|
searchEmployee.searchEmployee(updatePersonalUserForm.getMailAddress()),
|
||||||
updatePersonalUserForm)
|
updatePersonalUserForm)) {
|
||||||
) {
|
|
||||||
// メールアドレスが既に使われていた場合
|
|
||||||
// 個人情報更新ページに遷移
|
|
||||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DUPLICATION));
|
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DUPLICATION));
|
||||||
model.addAttribute(PageReturnAttributeKeyword.UPDATE_PERSONAL_EMPLOYEE_USER_FORM, updatePersonalUserForm);
|
model.addAttribute(PageReturnAttributeKeyword.UPDATE_PERSONAL_EMPLOYEE_USER_FORM,
|
||||||
|
updatePersonalUserForm);
|
||||||
|
|
||||||
return TransitionTargetPageNameKeyword.UPDATE_PERSONAL_EMPLOYEE_INPUT_HTML;
|
return TransitionTargetPageNameKeyword.UPDATE_PERSONAL_EMPLOYEE_INPUT_HTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
//更新前のEmployeeの情報を取得
|
|
||||||
// 画面用のインスタンスから更新用のインスタンスに変換し、Update実施
|
|
||||||
updateEmployee.updateEmployee(
|
updateEmployee.updateEmployee(
|
||||||
searchEmployee.searchEmployeeByIdEmployee(updatePersonalUserForm.getIdEmployee()),
|
searchEmployee.searchEmployeeByIdEmployee(updatePersonalUserForm.getIdEmployee()),
|
||||||
UpdatePersonalUserForm.convertTo(updatePersonalUserForm)
|
UpdatePersonalUserForm.convertTo(updatePersonalUserForm));
|
||||||
);
|
|
||||||
|
|
||||||
// ログイン者の情報をセッション情報に格納
|
|
||||||
httpSession.setAttribute(
|
httpSession.setAttribute(
|
||||||
SessionKeyword.LOGIN_USER,
|
SessionKeyword.LOGIN_USER,
|
||||||
LoginUserForm.convertFrom(
|
LoginUserForm.convertFrom(
|
||||||
searchEmployee.searchLoginUser(updatePersonalUserForm.getMailAddress()))
|
searchEmployee.searchLoginUser(updatePersonalUserForm.getMailAddress())));
|
||||||
);
|
|
||||||
|
|
||||||
// 更新結果画面に遷移
|
|
||||||
return TransitionTargetPageNameKeyword.UPDATE_PERSONAL_RESULT_HTML;
|
return TransitionTargetPageNameKeyword.UPDATE_PERSONAL_RESULT_HTML;
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// ログイン情報の破棄
|
|
||||||
httpSession.invalidate();
|
httpSession.invalidate();
|
||||||
|
|
||||||
// エラーログ出力
|
|
||||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||||
// エラー画面遷移
|
|
||||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
package com.example.rhizome.app.presentation.controller.pageproperty;
|
package com.example.rhizome.app.presentation.controller.pageproperty;
|
||||||
|
|
||||||
/**
|
|
||||||
* Sessionキーを管理する
|
|
||||||
*/
|
|
||||||
public class SessionKeyword {
|
public class SessionKeyword {
|
||||||
// SESSION情報として格納したいログイン者の情報
|
|
||||||
public static final String LOGIN_USER = "loginUser";
|
public static final String LOGIN_USER = "loginUser";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,46 +1,24 @@
|
|||||||
package com.example.rhizome.app.presentation.form;
|
package com.example.rhizome.app.presentation.form;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.example.rhizome.app.domain.model.Department;
|
import com.example.rhizome.app.domain.model.Department;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 画面の表示に使う部署コード管理用のクラス
|
|
||||||
*/
|
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class DepartmentForm {
|
public class DepartmentForm {
|
||||||
/**
|
|
||||||
* 部署ID
|
|
||||||
*/
|
|
||||||
private Integer idDepartment;
|
private Integer idDepartment;
|
||||||
/**
|
|
||||||
* 部署名
|
|
||||||
*/
|
|
||||||
private String nmDepartment;
|
private String nmDepartment;
|
||||||
|
|
||||||
/**
|
|
||||||
* business 層の Department クラスから画面用(presentation 層)の DepartmentForm に
|
|
||||||
* 変換します。
|
|
||||||
*
|
|
||||||
* @param department business 層の Department インスタンス
|
|
||||||
* @return 画面用(presentation 層)の DepartmentForm インスタンス
|
|
||||||
*/
|
|
||||||
public static DepartmentForm convertFrom(Department department) {
|
public static DepartmentForm convertFrom(Department department) {
|
||||||
return new DepartmentForm(department.getIdDepartment(), department.getNmDepartment());
|
return new DepartmentForm(department.getIdDepartment(), department.getNmDepartment());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* business 層の Department クラスから画面用(presentation 層)の DepartmentForm に
|
|
||||||
* 変換します。(リスト版)
|
|
||||||
*
|
|
||||||
* @param departmentList business 層の Department インスタンスのリスト
|
|
||||||
* @return 画面用(presentation 層)の DepartmentForm インスタンスのリスト
|
|
||||||
*/
|
|
||||||
public static List<DepartmentForm> convertFrom(List<Department> departmentList) {
|
public static List<DepartmentForm> convertFrom(List<Department> departmentList) {
|
||||||
return departmentList.stream().map(DepartmentForm::convertFrom).toList();
|
return departmentList.stream().map(DepartmentForm::convertFrom).toList();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,61 +1,27 @@
|
|||||||
package com.example.rhizome.app.presentation.form;
|
package com.example.rhizome.app.presentation.form;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.example.rhizome.app.domain.model.EmployeeInfo;
|
import com.example.rhizome.app.domain.model.EmployeeInfo;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 画面に表示するために employee と department を Join した構造を扱うクラス
|
|
||||||
*/
|
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class EmployeeInfoForm {
|
public class EmployeeInfoForm {
|
||||||
|
|
||||||
/**
|
|
||||||
* 社員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
|
|
||||||
*/
|
|
||||||
private Integer idDepartment;
|
private Integer idDepartment;
|
||||||
/**
|
|
||||||
* 部署名
|
|
||||||
*/
|
|
||||||
private String nmDepartment;
|
private String nmDepartment;
|
||||||
|
|
||||||
/**
|
|
||||||
* business 層の EmployeeInfo クラスから画面用(presentation 層)の EmployeeInfoForm に
|
|
||||||
* 変換します。
|
|
||||||
*
|
|
||||||
* @param employeeInfo business 層の EmployeeInfo インスタンス
|
|
||||||
* @return クラスから画面用(presentation 層)の EmployeeInfoForm インスタンス
|
|
||||||
*/
|
|
||||||
public static EmployeeInfoForm convertFrom(EmployeeInfo employeeInfo) {
|
public static EmployeeInfoForm convertFrom(EmployeeInfo employeeInfo) {
|
||||||
return new EmployeeInfoForm(
|
return new EmployeeInfoForm(
|
||||||
employeeInfo.getEmployee().getIdEmployee(),
|
employeeInfo.getEmployee().getIdEmployee(),
|
||||||
@@ -65,17 +31,9 @@ public class EmployeeInfoForm {
|
|||||||
employeeInfo.getEmployee().getPassword(),
|
employeeInfo.getEmployee().getPassword(),
|
||||||
employeeInfo.getEmployee().getAdminAuth(),
|
employeeInfo.getEmployee().getAdminAuth(),
|
||||||
employeeInfo.getDepartment().getIdDepartment(),
|
employeeInfo.getDepartment().getIdDepartment(),
|
||||||
employeeInfo.getDepartment().getNmDepartment()
|
employeeInfo.getDepartment().getNmDepartment());
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* business 層の EmployeeInfo クラスから画面用(presentation 層)の EmployeeInfoForm に
|
|
||||||
* 変換します。(リスト版)
|
|
||||||
*
|
|
||||||
* @param employeeInfoList business 層の EmployeeInfo インスタンスのリスト
|
|
||||||
* @return クラスから画面用(presentation 層)の EmployeeInfoForm インスタンスのリスト
|
|
||||||
*/
|
|
||||||
public static List<EmployeeInfoForm> convertFrom(List<EmployeeInfo> employeeInfoList) {
|
public static List<EmployeeInfoForm> convertFrom(List<EmployeeInfo> employeeInfoList) {
|
||||||
return employeeInfoList.stream().map(EmployeeInfoForm::convertFrom).toList();
|
return employeeInfoList.stream().map(EmployeeInfoForm::convertFrom).toList();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,64 +1,33 @@
|
|||||||
package com.example.rhizome.app.presentation.form;
|
package com.example.rhizome.app.presentation.form;
|
||||||
|
|
||||||
import com.example.rhizome.app.domain.model.Employee;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
import com.example.rhizome.app.domain.model.Employee;
|
||||||
* 画面から渡ってきた登録内容をまとめ、再度画面に表示する為のクラス
|
|
||||||
*/
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@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 Integer adminAuth;
|
private Integer adminAuth;
|
||||||
|
|
||||||
/**
|
|
||||||
* 部署ID
|
|
||||||
*/
|
|
||||||
private Integer idDepartment;
|
private Integer idDepartment;
|
||||||
|
|
||||||
/**
|
|
||||||
* パスワードのValidation
|
|
||||||
* チェック対象にエラーが有った場合エラーリストに文言を追加する
|
|
||||||
*
|
|
||||||
* @param password 登録対象のパスワード
|
|
||||||
* @param passwordConfirm 登録対象のパスワード再入力
|
|
||||||
* @param error エラーリスト
|
|
||||||
*/
|
|
||||||
private static void checkPassword(String password, String passwordConfirm, List<String> error) {
|
private static void checkPassword(String password, String passwordConfirm, List<String> error) {
|
||||||
final String PASSWORD_NULL_BLANK = "パスワード が未入力です。";
|
final String PASSWORD_NULL_BLANK = "パスワード が未入力です。";
|
||||||
final String PASSWORD_CONFIRM_NULL_BLANK = "パスワード確認用 が未入力です。";
|
final String PASSWORD_CONFIRM_NULL_BLANK = "パスワード確認用 が未入力です。";
|
||||||
@@ -78,12 +47,6 @@ public class InsertEmployeeForm {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 仮引数を null or 空 判定する
|
|
||||||
*
|
|
||||||
* @param str 判定対象の文字列
|
|
||||||
* @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;
|
||||||
@@ -92,12 +55,6 @@ public class InsertEmployeeForm {
|
|||||||
return str.isBlank();
|
return str.isBlank();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 画面から渡ってきた登録内容をまとめ、ビジネスモデルに変換
|
|
||||||
*
|
|
||||||
* @param insertEmployeeForm 画面から渡ってきた登録内容
|
|
||||||
* @return ビジネスモデルのインスタンス
|
|
||||||
*/
|
|
||||||
public static Employee convertTo(InsertEmployeeForm insertEmployeeForm) {
|
public static Employee convertTo(InsertEmployeeForm insertEmployeeForm) {
|
||||||
return new Employee(
|
return new Employee(
|
||||||
null,
|
null,
|
||||||
@@ -106,15 +63,9 @@ public class InsertEmployeeForm {
|
|||||||
insertEmployeeForm.getMailAddress(),
|
insertEmployeeForm.getMailAddress(),
|
||||||
insertEmployeeForm.getPassword(),
|
insertEmployeeForm.getPassword(),
|
||||||
insertEmployeeForm.getAdminAuth(),
|
insertEmployeeForm.getAdminAuth(),
|
||||||
insertEmployeeForm.getIdDepartment()
|
insertEmployeeForm.getIdDepartment());
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 登録データのValidationを行う
|
|
||||||
*
|
|
||||||
* @return エラーが有った場合はエラー文言、無ければ空のリストが返る
|
|
||||||
*/
|
|
||||||
public List<String> validateParameter() {
|
public List<String> validateParameter() {
|
||||||
final String EMPLOYEE_NAME_NULL_BLANK = "社員名";
|
final String EMPLOYEE_NAME_NULL_BLANK = "社員名";
|
||||||
final String EMPLOYEE_KANA_NULL_BLANK = "社員名フリガナ";
|
final String EMPLOYEE_KANA_NULL_BLANK = "社員名フリガナ";
|
||||||
@@ -134,7 +85,6 @@ public class InsertEmployeeForm {
|
|||||||
error.add(MAIL_ADDRESS_NULL_BLANK);
|
error.add(MAIL_ADDRESS_NULL_BLANK);
|
||||||
}
|
}
|
||||||
|
|
||||||
// パスワードが仕様を満たしているか確認
|
|
||||||
checkPassword(password, passwordConfirm, error);
|
checkPassword(password, passwordConfirm, error);
|
||||||
|
|
||||||
if (adminAuth == null) {
|
if (adminAuth == null) {
|
||||||
|
|||||||
@@ -4,20 +4,10 @@ import lombok.AllArgsConstructor;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
/**
|
|
||||||
* ログインを試みる人を表現するモデルクラスです
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class LoginInfoForm {
|
public class LoginInfoForm {
|
||||||
/**
|
|
||||||
* メールアドレス
|
|
||||||
*/
|
|
||||||
private String mailAddress;
|
private String mailAddress;
|
||||||
/**
|
|
||||||
* パスワード
|
|
||||||
*/
|
|
||||||
private String password;
|
private String password;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
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;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
@@ -10,44 +10,16 @@ import lombok.NoArgsConstructor;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class LoginUserForm {
|
public class LoginUserForm {
|
||||||
/**
|
|
||||||
* 社員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
|
|
||||||
*/
|
|
||||||
private Integer idDepartment;
|
private Integer idDepartment;
|
||||||
|
|
||||||
/**
|
|
||||||
* business 層の LoginUser クラスから画面用(presentation 層)の LoginUserForm に
|
|
||||||
* 変換します。
|
|
||||||
*
|
|
||||||
* @param loginUser business 層の LoginUser インスタンス
|
|
||||||
* @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(),
|
||||||
@@ -56,17 +28,9 @@ public class LoginUserForm {
|
|||||||
loginUser.getMailAddress(),
|
loginUser.getMailAddress(),
|
||||||
loginUser.getPassword(),
|
loginUser.getPassword(),
|
||||||
loginUser.getAdminAuth(),
|
loginUser.getAdminAuth(),
|
||||||
loginUser.getIdDepartment()
|
loginUser.getIdDepartment());
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 画面用(presentation 層)の LoginUserForm クラスから business 層の LoginUser クラスに
|
|
||||||
* 変換します。
|
|
||||||
*
|
|
||||||
* @param loginUserForm 画面用(presentation 層)の LoginUserForm インスタンス
|
|
||||||
* @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(),
|
||||||
@@ -75,16 +39,9 @@ public class LoginUserForm {
|
|||||||
loginUserForm.getMailAddress(),
|
loginUserForm.getMailAddress(),
|
||||||
loginUserForm.getPassword(),
|
loginUserForm.getPassword(),
|
||||||
loginUserForm.getAdminAuth(),
|
loginUserForm.getAdminAuth(),
|
||||||
loginUserForm.getIdDepartment()
|
loginUserForm.getIdDepartment());
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 画面から渡ってきた必須の値が仕様を満たしているか確認
|
|
||||||
*
|
|
||||||
* @param loginInfoForm 画面から渡ってきた mailAddress, password を格納しているインスタンス
|
|
||||||
* @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;
|
||||||
@@ -102,11 +59,6 @@ public class LoginUserForm {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 管理者権限を持っているか確認
|
|
||||||
*
|
|
||||||
* @return true:管理者権限を持っている , false:管理者権限を持っていない
|
|
||||||
*/
|
|
||||||
public boolean isAdminUser() {
|
public boolean isAdminUser() {
|
||||||
return getAdminAuth() == 1;
|
return getAdminAuth() == 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,6 @@ import lombok.AllArgsConstructor;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
/**
|
|
||||||
* 画面に表示するエラーメッセージを管理するクラスです。
|
|
||||||
*/
|
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
|
|||||||
@@ -1,70 +1,37 @@
|
|||||||
package com.example.rhizome.app.presentation.form;
|
package com.example.rhizome.app.presentation.form;
|
||||||
|
|
||||||
import com.example.rhizome.app.domain.model.SearchConditionEmployee;
|
import com.example.rhizome.app.domain.model.SearchConditionEmployee;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
/**
|
|
||||||
* 画面から渡ってきた検索条件をまとめ、再度画面に表示する為のクラス
|
|
||||||
*/
|
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class SearchConditionEmployeeForm {
|
public class SearchConditionEmployeeForm {
|
||||||
|
|
||||||
/**
|
|
||||||
* 社員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
|
|
||||||
*/
|
|
||||||
private Integer idDepartment;
|
private Integer idDepartment;
|
||||||
|
|
||||||
/**
|
|
||||||
* business 層の SearchConditionEmployee クラスから画面用(presentation 層)の SearchConditionEmployeeForm に
|
|
||||||
* 変換します。
|
|
||||||
*
|
|
||||||
* @param searchConditionEmployee business 層の SearchConditionEmployee インスタンス
|
|
||||||
* @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.getIdDepartment()
|
searchConditionEmployee.getIdDepartment());
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 画面用(presentation 層)の SearchConditionEmployeeForm クラスから business 層の SearchConditionEmployee クラスに
|
|
||||||
* 変換します。
|
|
||||||
*
|
|
||||||
* @param searchConditionEmployeeForm 画面用(presentation 層)の SearchConditionEmployeeForm インスタンス
|
|
||||||
* @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.getIdDepartment()
|
searchConditionEmployeeForm.getIdDepartment());
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,61 +1,28 @@
|
|||||||
package com.example.rhizome.app.presentation.form;
|
package com.example.rhizome.app.presentation.form;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.example.rhizome.app.domain.model.Employee;
|
import com.example.rhizome.app.domain.model.Employee;
|
||||||
import com.example.rhizome.app.domain.model.EmployeeInfo;
|
import com.example.rhizome.app.domain.model.EmployeeInfo;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 画面から渡ってきた更新内容をまとめ、再度画面に表示する為のクラス
|
|
||||||
*/
|
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class UpdateEmployeeInfoForm {
|
public class UpdateEmployeeInfoForm {
|
||||||
|
|
||||||
/**
|
|
||||||
* 社員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 Integer adminAuth;
|
private Integer adminAuth;
|
||||||
/**
|
|
||||||
* 部署ID
|
|
||||||
*/
|
|
||||||
private Integer idDepartment;
|
private Integer idDepartment;
|
||||||
|
|
||||||
/**
|
|
||||||
* business 層の EmployeeInfo クラスから画面用(presentation 層)の UpdateEmployeeInfoForm に
|
|
||||||
* 変換します。
|
|
||||||
*
|
|
||||||
* @param employeeInfo business 層の EmployeeInfo インスタンス
|
|
||||||
* @return 画面用(presentation 層)の UpdateEmployeeInfoForm インスタンス
|
|
||||||
*/
|
|
||||||
public static UpdateEmployeeInfoForm convertFrom(EmployeeInfo employeeInfo) {
|
public static UpdateEmployeeInfoForm convertFrom(EmployeeInfo employeeInfo) {
|
||||||
return new UpdateEmployeeInfoForm(
|
return new UpdateEmployeeInfoForm(
|
||||||
employeeInfo.getEmployee().getIdEmployee(),
|
employeeInfo.getEmployee().getIdEmployee(),
|
||||||
@@ -65,28 +32,13 @@ public class UpdateEmployeeInfoForm {
|
|||||||
employeeInfo.getEmployee().getPassword(),
|
employeeInfo.getEmployee().getPassword(),
|
||||||
null,
|
null,
|
||||||
employeeInfo.getEmployee().getAdminAuth(),
|
employeeInfo.getEmployee().getAdminAuth(),
|
||||||
employeeInfo.getDepartment().getIdDepartment()
|
employeeInfo.getDepartment().getIdDepartment());
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* business 層の EmployeeInfo クラスから画面用(presentation 層)の UpdateEmployeeInfoForm に
|
|
||||||
* 変換します。(リスト版)
|
|
||||||
*
|
|
||||||
* @param employeeInfoList business 層の EmployeeInfo インスタンスのリスト
|
|
||||||
* @return 画面用(presentation 層)の UpdateEmployeeInfoForm インスタンスのリスト
|
|
||||||
*/
|
|
||||||
public static List<UpdateEmployeeInfoForm> convertFrom(List<EmployeeInfo> employeeInfoList) {
|
public static List<UpdateEmployeeInfoForm> convertFrom(List<EmployeeInfo> employeeInfoList) {
|
||||||
return employeeInfoList.stream().map(UpdateEmployeeInfoForm::convertFrom).toList();
|
return employeeInfoList.stream().map(UpdateEmployeeInfoForm::convertFrom).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 画面用(presentation 層)の UpdateEmployeeInfoForm クラスから business 層の Employee クラスに
|
|
||||||
* 変換します。
|
|
||||||
*
|
|
||||||
* @param updateEmployeeInfoForm 画面用(presentation 層)の UpdateEmployeeInfoForm インスタンス
|
|
||||||
* @return business 層の Employee インスタンス
|
|
||||||
*/
|
|
||||||
public static Employee convertTo(UpdateEmployeeInfoForm updateEmployeeInfoForm) {
|
public static Employee convertTo(UpdateEmployeeInfoForm updateEmployeeInfoForm) {
|
||||||
return new Employee(
|
return new Employee(
|
||||||
updateEmployeeInfoForm.getIdEmployee(),
|
updateEmployeeInfoForm.getIdEmployee(),
|
||||||
@@ -95,16 +47,9 @@ public class UpdateEmployeeInfoForm {
|
|||||||
updateEmployeeInfoForm.getMailAddress(),
|
updateEmployeeInfoForm.getMailAddress(),
|
||||||
updateEmployeeInfoForm.getPassword(),
|
updateEmployeeInfoForm.getPassword(),
|
||||||
updateEmployeeInfoForm.getAdminAuth(),
|
updateEmployeeInfoForm.getAdminAuth(),
|
||||||
updateEmployeeInfoForm.getIdDepartment()
|
updateEmployeeInfoForm.getIdDepartment());
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 画面から渡ってきたパラメータのチェック
|
|
||||||
*
|
|
||||||
* @param updateEmployeeInfoForm 画面から渡ってきたパラメータ
|
|
||||||
* @return true: エラー無し false:エラーあり(必須を満たしていない)
|
|
||||||
*/
|
|
||||||
public static boolean hasErrorParameter(UpdateEmployeeInfoForm updateEmployeeInfoForm) {
|
public static boolean hasErrorParameter(UpdateEmployeeInfoForm updateEmployeeInfoForm) {
|
||||||
|
|
||||||
boolean errorFlag = !isNullOrBlank(updateEmployeeInfoForm.getNmEmployee());
|
boolean errorFlag = !isNullOrBlank(updateEmployeeInfoForm.getNmEmployee());
|
||||||
@@ -119,33 +64,21 @@ public class UpdateEmployeeInfoForm {
|
|||||||
errorFlag = true;
|
errorFlag = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return errorFlag;
|
return errorFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* パスワードの仕様チェック
|
|
||||||
* パスワードが仕様を満たしてないか確認
|
|
||||||
*
|
|
||||||
* @param password 更新対象のパスワード
|
|
||||||
* @param passwordConfirm 更新対象の確認用パスワード
|
|
||||||
* @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
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// どちらかが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;
|
||||||
}
|
}
|
||||||
@@ -153,12 +86,6 @@ public class UpdateEmployeeInfoForm {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 仮引数を null or 空 判定する
|
|
||||||
*
|
|
||||||
* @param str 判定対象の文字列
|
|
||||||
* @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;
|
||||||
@@ -166,25 +93,10 @@ public class UpdateEmployeeInfoForm {
|
|||||||
return str.isBlank();
|
return str.isBlank();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* パスワードが今回更新対象に含まれているかチェック
|
|
||||||
*
|
|
||||||
* @param password 更新対象のパスワード
|
|
||||||
* @param passwordConfirm 更新対象の確認用パスワード
|
|
||||||
* @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
|
|
||||||
*
|
|
||||||
* @param password 更新対象のパスワード
|
|
||||||
* @param passwordConfirm 更新対象の確認用パスワード
|
|
||||||
* @return true: 問題なし false:どちらかが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();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,50 +2,22 @@ package com.example.rhizome.app.presentation.form;
|
|||||||
|
|
||||||
import com.example.rhizome.app.domain.model.Employee;
|
import com.example.rhizome.app.domain.model.Employee;
|
||||||
import com.example.rhizome.app.domain.model.LoginUser;
|
import com.example.rhizome.app.domain.model.LoginUser;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
/**
|
|
||||||
* 個人情報更新画面のフォームクラスです。
|
|
||||||
*/
|
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class UpdatePersonalUserForm {
|
public class UpdatePersonalUserForm {
|
||||||
/**
|
|
||||||
* 社員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;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 画面用(presentation 層)の UpdatePersonalUserForm クラスから business 層の Employee クラスに
|
|
||||||
* 変換します。
|
|
||||||
*
|
|
||||||
* @param updatePersonalUserForm 画面用(presentation 層)の UpdatePersonalUserForm インスタンス
|
|
||||||
* @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(),
|
||||||
@@ -54,17 +26,9 @@ public class UpdatePersonalUserForm {
|
|||||||
updatePersonalUserForm.getMailAddress(),
|
updatePersonalUserForm.getMailAddress(),
|
||||||
updatePersonalUserForm.getPassword(),
|
updatePersonalUserForm.getPassword(),
|
||||||
null,
|
null,
|
||||||
null
|
null);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* business 層の Employee クラスから画面用(presentation 層)の UpdatePersonalUserForm に
|
|
||||||
* 変換します。(リスト版)
|
|
||||||
*
|
|
||||||
* @param employee business 層の employee インスタンスのリスト
|
|
||||||
* @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(),
|
||||||
@@ -72,17 +36,9 @@ public class UpdatePersonalUserForm {
|
|||||||
employee.getKnEmployee(),
|
employee.getKnEmployee(),
|
||||||
employee.getMailAddress(),
|
employee.getMailAddress(),
|
||||||
employee.getPassword(),
|
employee.getPassword(),
|
||||||
null
|
null);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* business 層の Employee クラスから画面用(presentation 層)の UpdatePersonalUserForm に
|
|
||||||
* 変換します。(リスト版)
|
|
||||||
*
|
|
||||||
* @param loginUser business 層の loginUser インスタンスのリスト
|
|
||||||
* @return クラスから画面用(presentation 層)の UpdatePersonalUserForm インスタンスのリスト
|
|
||||||
*/
|
|
||||||
public static UpdatePersonalUserForm convertFrom(LoginUser loginUser) {
|
public static UpdatePersonalUserForm convertFrom(LoginUser loginUser) {
|
||||||
return new UpdatePersonalUserForm(
|
return new UpdatePersonalUserForm(
|
||||||
loginUser.getIdEmployee(),
|
loginUser.getIdEmployee(),
|
||||||
@@ -90,16 +46,9 @@ public class UpdatePersonalUserForm {
|
|||||||
loginUser.getKnEmployee(),
|
loginUser.getKnEmployee(),
|
||||||
loginUser.getMailAddress(),
|
loginUser.getMailAddress(),
|
||||||
loginUser.getPassword(),
|
loginUser.getPassword(),
|
||||||
null
|
null);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 画面から渡ってきたパラメータのチェック
|
|
||||||
*
|
|
||||||
* @param updatePersonalUserForm 画面から渡ってきたパラメータ
|
|
||||||
* @return true: エラー無し false:エラーあり(必須を満たしていない)
|
|
||||||
*/
|
|
||||||
public static boolean hasErrorParameter(UpdatePersonalUserForm updatePersonalUserForm) {
|
public static boolean hasErrorParameter(UpdatePersonalUserForm updatePersonalUserForm) {
|
||||||
|
|
||||||
boolean errorFlag = !isNullOrBlank(updatePersonalUserForm.getNmEmployee());
|
boolean errorFlag = !isNullOrBlank(updatePersonalUserForm.getNmEmployee());
|
||||||
@@ -114,33 +63,21 @@ public class UpdatePersonalUserForm {
|
|||||||
errorFlag = true;
|
errorFlag = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return errorFlag;
|
return errorFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* パスワードの仕様チェック
|
|
||||||
* パスワードが仕様を満たしてないか確認
|
|
||||||
*
|
|
||||||
* @param password 更新対象のパスワード
|
|
||||||
* @param passwordConfirm 更新対象の確認用パスワード
|
|
||||||
* @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
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// どちらかが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;
|
||||||
}
|
}
|
||||||
@@ -148,12 +85,6 @@ public class UpdatePersonalUserForm {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 仮引数を null or 空 判定する
|
|
||||||
*
|
|
||||||
* @param str 判定対象の文字列
|
|
||||||
* @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;
|
||||||
@@ -161,24 +92,10 @@ public class UpdatePersonalUserForm {
|
|||||||
return str.isBlank();
|
return str.isBlank();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* パスワードが今回更新対象に含まれているかチェック
|
|
||||||
*
|
|
||||||
* @param password 更新対象のパスワード
|
|
||||||
* @param passwordConfirm 更新対象の確認用パスワード
|
|
||||||
* @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
|
|
||||||
*
|
|
||||||
* @param password 更新対象のパスワード
|
|
||||||
* @param passwordConfirm 更新対象の確認用パスワード
|
|
||||||
* @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();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,10 @@
|
|||||||
spring.datasource.url=jdbc:mysql://localhost:3306/rezodb
|
spring.datasource.url=jdbc:mysql://localhost:3306/springdb
|
||||||
spring.datasource.username=rezouser
|
spring.datasource.username=rezouser
|
||||||
spring.datasource.password=Rezo_0000
|
spring.datasource.password=Rezo_0000
|
||||||
|
|
||||||
|
spring.jpa.hibernate.ddl-auto=update
|
||||||
|
|
||||||
|
spring.jpa.properties.hibernate.format_sql=true
|
||||||
|
spring.jpa.show-sql=true
|
||||||
|
|
||||||
|
logging.level.org.hibernate.type.descriptor.sql=trace
|
||||||
|
|||||||
Reference in New Issue
Block a user