社員情報の更新などで使うプルダウンの確認のためのひとまずプッシュ
This commit is contained in:
@@ -3,19 +3,23 @@ package com.example.rhizome.app.domain.model;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 部署情報の概念を表現するモデルクラスです。
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class Department {
|
||||
/**
|
||||
* 部署ID
|
||||
/**
|
||||
* 部ID
|
||||
*/
|
||||
private final Integer idDepartment;
|
||||
/**
|
||||
* 部署名
|
||||
* 部名
|
||||
*/
|
||||
private final String nmDepartment;
|
||||
|
||||
/**
|
||||
* 表示・非表示フラグ
|
||||
*/
|
||||
private final Integer isDisplay;
|
||||
/**
|
||||
* 部ID
|
||||
*/
|
||||
private final Integer idHeadquarters;
|
||||
}
|
||||
|
||||
@@ -40,6 +40,6 @@ public class Employee {
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
private final Integer idDepartment;
|
||||
private final Integer idDivision;
|
||||
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ public class EmployeeInfo {
|
||||
*/
|
||||
private final Employee employee;
|
||||
/**
|
||||
* 部署名
|
||||
* 課情報
|
||||
*/
|
||||
private final Department department;
|
||||
|
||||
private final Division division;
|
||||
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class LoginUser {
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
private final Integer idDepartment;
|
||||
private final Integer idDivision;
|
||||
|
||||
/**
|
||||
* ログインユーザが管理者か
|
||||
|
||||
@@ -10,12 +10,12 @@ import lombok.Getter;
|
||||
@AllArgsConstructor
|
||||
public class SearchConditionDepartment {
|
||||
/**
|
||||
* 部署ID
|
||||
* ID
|
||||
*/
|
||||
private final Integer idDepartment;
|
||||
private final Integer idDivision;
|
||||
/**
|
||||
* 部署名
|
||||
* 名前
|
||||
*/
|
||||
private final String nmDepartment;
|
||||
private final String nmDivision;
|
||||
|
||||
}
|
||||
|
||||
@@ -28,6 +28,6 @@ public class SearchConditionEmployee {
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
private final Integer idDepartment;
|
||||
private final Integer idDivision;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.example.rhizome.app.domain.service;
|
||||
|
||||
public interface DeleteDepartment {
|
||||
void deleteDepartment(Integer idDepartment);
|
||||
void deleteDepartment(Integer idDivision);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.example.rhizome.app.domain.service;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Department;
|
||||
import com.example.rhizome.app.infra.entity.DivisionEntity;
|
||||
|
||||
public interface RegisterDepartment {
|
||||
void registerDepartment(Department department);
|
||||
void registerDepartment(DivisionEntity divisionEntity);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,29 @@
|
||||
package com.example.rhizome.app.domain.service;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Department;
|
||||
import com.example.rhizome.app.domain.model.SearchConditionDepartment;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.example.rhizome.app.domain.model.AllDepartmentInfo;
|
||||
import com.example.rhizome.app.domain.model.Department;
|
||||
import com.example.rhizome.app.domain.model.Division;
|
||||
import com.example.rhizome.app.domain.model.Headquarters;
|
||||
import com.example.rhizome.app.domain.model.SearchConditionDepartment;
|
||||
|
||||
public interface SearchDepartment {
|
||||
List<Department> selectAll();
|
||||
|
||||
List<AllDepartmentInfo> searchAllDepartmentTable();
|
||||
|
||||
List<AllDepartmentInfo> searchAllDepartmentTable(SearchConditionDepartment searchConditionDepartment);
|
||||
|
||||
boolean searchAllDepartmentTable(
|
||||
SearchConditionDepartment searchHeadquartersTable,
|
||||
SearchConditionDepartment searchDepartmentTable,
|
||||
SearchConditionDepartment searchDivisionTable);
|
||||
|
||||
List<Department> searchBy(SearchConditionDepartment searchConditionDepartment);
|
||||
List<Headquarters> searchByHeadquarters(SearchConditionDepartment searchConditionDepartment);
|
||||
|
||||
List<Department> searchByWithLike(SearchConditionDepartment searchConditionDepartment);
|
||||
List<Department> searchByDepartment(SearchConditionDepartment searchConditionDepartment);
|
||||
|
||||
List<Division> searchByDivision(SearchConditionDepartment searchConditionDepartment);
|
||||
|
||||
// List<DepartmentInfo> searchByWithLike(SearchConditionDepartment searchConditionDepartment);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package com.example.rhizome.app.domain.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Employee;
|
||||
import com.example.rhizome.app.domain.model.LoginUser;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SearchEmployee {
|
||||
List<Employee> searchEmployee(String mailAddress);
|
||||
|
||||
List<Employee> searchEmployeeByIdDepartment(Integer idDepartment);
|
||||
List<Employee> searchEmployeeByIdDepartment(Integer idDivision);
|
||||
|
||||
LoginUser searchLoginUser(String mailAddress);
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.example.rhizome.app.domain.service;
|
||||
|
||||
import com.example.rhizome.app.domain.model.EmployeeInfo;
|
||||
import com.example.rhizome.app.domain.model.SearchConditionEmployee;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SearchEmployeeInfo {
|
||||
List<EmployeeInfo> selectAll();
|
||||
import com.example.rhizome.app.domain.model.AllEmployeeInfo;
|
||||
import com.example.rhizome.app.domain.model.SearchConditionEmployee;
|
||||
|
||||
List<EmployeeInfo> searchBy(SearchConditionEmployee searchConditionEmployee);
|
||||
public interface SearchEmployeeInfo {
|
||||
List<AllEmployeeInfo> selectAll();
|
||||
|
||||
List<AllEmployeeInfo> searchBy(SearchConditionEmployee searchConditionEmployee);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.example.rhizome.app.domain.service;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Department;
|
||||
import com.example.rhizome.app.domain.model.DepartmentInfo;
|
||||
|
||||
public interface UpdateDepartment {
|
||||
void updateDepartment(Department department);
|
||||
void updateDepartment(DepartmentInfo departmentInfo);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package com.example.rhizome.app.domain.service.impl;
|
||||
|
||||
import com.example.rhizome.app.domain.service.DeleteDepartment;
|
||||
import com.example.rhizome.app.infra.repository.DepartmentRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.example.rhizome.app.domain.service.DeleteDepartment;
|
||||
import com.example.rhizome.app.infra.repository.DivisionRepository;
|
||||
|
||||
/**
|
||||
* Department レコード削除関連の機能を持つサービス
|
||||
*/
|
||||
@@ -13,7 +14,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
@Transactional
|
||||
public class DeleteDepartmentImpl implements DeleteDepartment {
|
||||
|
||||
DepartmentRepository departmentRepository;
|
||||
DivisionRepository divisionRepository;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
@@ -21,8 +22,8 @@ public class DeleteDepartmentImpl implements DeleteDepartment {
|
||||
* @param departmentRepository DI対象
|
||||
*/
|
||||
@Autowired
|
||||
public DeleteDepartmentImpl(DepartmentRepository departmentRepository) {
|
||||
this.departmentRepository = departmentRepository;
|
||||
public DeleteDepartmentImpl(DivisionRepository divisionRepository) {
|
||||
this.divisionRepository = divisionRepository;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +33,7 @@ public class DeleteDepartmentImpl implements DeleteDepartment {
|
||||
* @param idDepartment 削除対象のidDepartment
|
||||
*/
|
||||
public void deleteDepartment(Integer idDepartment) {
|
||||
departmentRepository.deleteById(idDepartment);
|
||||
divisionRepository.deleteById(idDepartment);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
package com.example.rhizome.app.domain.service.impl;
|
||||
|
||||
|
||||
import com.example.rhizome.app.domain.model.Department;
|
||||
import com.example.rhizome.app.domain.service.RegisterDepartment;
|
||||
import com.example.rhizome.app.infra.entity.DepartmentEntity;
|
||||
import com.example.rhizome.app.infra.repository.DepartmentRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.example.rhizome.app.domain.service.RegisterDepartment;
|
||||
import com.example.rhizome.app.infra.entity.DepartmentEntity;
|
||||
import com.example.rhizome.app.infra.entity.DivisionEntity;
|
||||
import com.example.rhizome.app.infra.entity.HeadquartersEntity;
|
||||
import com.example.rhizome.app.infra.repository.DepartmentRepository;
|
||||
import com.example.rhizome.app.infra.repository.DivisionRepository;
|
||||
import com.example.rhizome.app.infra.repository.HeadquartersRepository;
|
||||
|
||||
/**
|
||||
* Department テーブルの登録系の機能を集約させるサービスクラスです。
|
||||
*/
|
||||
@@ -17,15 +21,20 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
public class RegisterDepartmentImpl implements RegisterDepartment {
|
||||
|
||||
DepartmentRepository departmentRepository;
|
||||
|
||||
DivisionRepository divisionRepository;
|
||||
HeadquartersRepository headquartersRepository;
|
||||
/**
|
||||
* コンストラクタ
|
||||
*
|
||||
* @param departmentRepository DI対象
|
||||
*/
|
||||
@Autowired
|
||||
public RegisterDepartmentImpl(DepartmentRepository departmentRepository) {
|
||||
public RegisterDepartmentImpl(DepartmentRepository departmentRepository,
|
||||
DivisionRepository divisionRepository,
|
||||
HeadquartersRepository headquartersRepository) {
|
||||
this.departmentRepository = departmentRepository;
|
||||
this.divisionRepository = divisionRepository;
|
||||
this.headquartersRepository = headquartersRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -33,7 +42,31 @@ public class RegisterDepartmentImpl implements RegisterDepartment {
|
||||
*
|
||||
* @param department 登録対象のデータ
|
||||
*/
|
||||
public void registerDepartment(Department department) {
|
||||
departmentRepository.save(DepartmentEntity.convertFrom(department));
|
||||
public void registerDepartment(DivisionEntity divisionEntity) {
|
||||
DepartmentEntity departmentEntity = divisionEntity.getDepartment();
|
||||
HeadquartersEntity headquartersEntity = divisionEntity.getDepartment().getHeadquarters();
|
||||
|
||||
if(departmentEntity.getIdDepartment()==null) {
|
||||
departmentEntity = new DepartmentEntity();
|
||||
}
|
||||
if(headquartersEntity.getIdHeadquarters()==null) {
|
||||
headquartersEntity = new HeadquartersEntity();
|
||||
}
|
||||
divisionEntity.setIsDisplay(0);
|
||||
departmentEntity.setIsDisplay(0);
|
||||
headquartersEntity.setIsDisplay(0);
|
||||
|
||||
departmentEntity.setNmDepartment(
|
||||
divisionEntity.getDepartment()
|
||||
.getNmDepartment()
|
||||
);
|
||||
headquartersEntity.setNmHeadquarters(
|
||||
divisionEntity.getDepartment()
|
||||
.getHeadquarters()
|
||||
.getNmHeadquarters()
|
||||
);
|
||||
departmentEntity.setHeadquarters(headquartersEntity);
|
||||
divisionEntity.setDepartment(departmentEntity);
|
||||
divisionRepository.save(divisionEntity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
package com.example.rhizome.app.domain.service.impl;
|
||||
|
||||
|
||||
import com.example.rhizome.app.domain.model.Employee;
|
||||
import com.example.rhizome.app.domain.service.RegisterEmployee;
|
||||
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||
import com.example.rhizome.app.infra.repository.EmployeeRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Employee;
|
||||
import com.example.rhizome.app.domain.service.RegisterEmployee;
|
||||
import com.example.rhizome.app.infra.entity.InsertEmployeeEntity;
|
||||
import com.example.rhizome.app.infra.repository.EmployeeRepository;
|
||||
|
||||
/**
|
||||
* Employee テーブルの登録系の機能を集約させるサービスクラスです。
|
||||
*/
|
||||
@@ -29,6 +30,6 @@ public class RegisterEmployeeImpl implements RegisterEmployee {
|
||||
* @param employee 登録対象のデータ
|
||||
*/
|
||||
public void registerEmployee(Employee employee) {
|
||||
employeeRepository.save(EmployeeEntity.convertFrom(employee));
|
||||
employeeRepository.save(InsertEmployeeEntity.convertFrom(employee));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,27 @@
|
||||
package com.example.rhizome.app.domain.service.impl;
|
||||
|
||||
|
||||
import com.example.rhizome.app.domain.model.Department;
|
||||
import com.example.rhizome.app.domain.model.SearchConditionDepartment;
|
||||
import com.example.rhizome.app.domain.service.SearchDepartment;
|
||||
import com.example.rhizome.app.infra.entity.DepartmentEntity;
|
||||
import com.example.rhizome.app.infra.repository.DepartmentRepository;
|
||||
import 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 java.util.List;
|
||||
import com.example.rhizome.app.domain.model.AllDepartmentInfo;
|
||||
import com.example.rhizome.app.domain.model.Department;
|
||||
import com.example.rhizome.app.domain.model.Division;
|
||||
import com.example.rhizome.app.domain.model.Headquarters;
|
||||
import com.example.rhizome.app.domain.model.SearchConditionDepartment;
|
||||
import com.example.rhizome.app.domain.service.SearchDepartment;
|
||||
import com.example.rhizome.app.infra.entity.DepartmentEntity;
|
||||
import com.example.rhizome.app.infra.entity.DepartmentInfoEntity;
|
||||
import com.example.rhizome.app.infra.entity.DivisionEntity;
|
||||
import com.example.rhizome.app.infra.entity.HeadquartersEntity;
|
||||
import com.example.rhizome.app.infra.repository.DepartmentInfoRepository;
|
||||
import com.example.rhizome.app.infra.repository.DepartmentRepository;
|
||||
import com.example.rhizome.app.infra.repository.DivisionRepository;
|
||||
import com.example.rhizome.app.infra.repository.HeadquartersRepository;
|
||||
|
||||
/**
|
||||
* 部署情報検索系の機能を集約させるサービスクラスです。
|
||||
@@ -19,64 +29,123 @@ import java.util.List;
|
||||
@Service
|
||||
@Transactional
|
||||
public class SearchDepartmentImpl implements SearchDepartment {
|
||||
|
||||
DivisionRepository divisionRepository;
|
||||
DepartmentRepository departmentRepository;
|
||||
|
||||
HeadquartersRepository headquartersRepository;
|
||||
DepartmentInfoRepository departmentInfoRepository;
|
||||
/**
|
||||
* コンストラクタ
|
||||
*
|
||||
* @param departmentRepository DI対象
|
||||
*/
|
||||
@Autowired
|
||||
public SearchDepartmentImpl(DepartmentRepository departmentRepository) {
|
||||
public SearchDepartmentImpl(
|
||||
DepartmentRepository departmentRepository
|
||||
,DivisionRepository divisionRepository
|
||||
,HeadquartersRepository headquartersRepository
|
||||
,DepartmentInfoRepository departmentInfoRepository) {
|
||||
this.departmentRepository = departmentRepository;
|
||||
this.divisionRepository = divisionRepository;
|
||||
this.headquartersRepository = headquartersRepository;
|
||||
this.departmentInfoRepository = departmentInfoRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* 部署情報を全件取得する
|
||||
*
|
||||
* @return 取得した部署情報レコード全件
|
||||
* @return 取得した本部情報レコード全件
|
||||
*/
|
||||
public List<Department> selectAll() {
|
||||
return DepartmentEntity.createDepartmentList(departmentRepository.findAll());
|
||||
public List<AllDepartmentInfo>searchAllDepartmentTable(){
|
||||
return DepartmentInfoEntity.createDepartmentInfoList(departmentInfoRepository.searchAllDepartmentTable());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public List<AllDepartmentInfo>searchAllDepartmentTable(SearchConditionDepartment searchConditionDepartment){
|
||||
return DepartmentInfoEntity.AfterSearchCreateDepartmentInfoList(
|
||||
departmentInfoRepository.findAll(Specification
|
||||
.where(DepartmentInfoRepository.idDivisionEqual(searchConditionDepartment.getIdDivision()))
|
||||
.and(DepartmentInfoRepository.nmDivisionEqual(searchConditionDepartment.getNmDivision()))
|
||||
)
|
||||
);
|
||||
}
|
||||
public boolean searchAllDepartmentTable(
|
||||
SearchConditionDepartment searchHeadquartersTable,
|
||||
SearchConditionDepartment searchDepartmentTable,
|
||||
SearchConditionDepartment searchDivisionTable){
|
||||
|
||||
if(departmentInfoRepository.searchAllDepartmentTable(
|
||||
searchHeadquartersTable.getNmDivision(),
|
||||
searchDepartmentTable.getNmDivision(),
|
||||
searchDivisionTable.getNmDivision()).isEmpty()) {
|
||||
return false;
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* searchConditionDepartment の情報を元に Department のレコードを取得
|
||||
*
|
||||
* @param searchConditionDepartment 検索条件
|
||||
* @return 検索結果のレコード
|
||||
*/
|
||||
public List<Department> searchBy(SearchConditionDepartment searchConditionDepartment) {
|
||||
// 動的に検索条件を絞り込む
|
||||
// Specification は Criteria API の Predicate をラップしたもの
|
||||
return DepartmentEntity
|
||||
.createDepartmentList(
|
||||
departmentRepository.findAll(Specification
|
||||
.where(DepartmentRepository.idDepartmentEqual(searchConditionDepartment.getIdDepartment()))
|
||||
.and(DepartmentRepository.nmDepartmentEqual(searchConditionDepartment.getNmDepartment()))
|
||||
public List<Headquarters> searchByHeadquarters(SearchConditionDepartment searchConditionDepartment) {
|
||||
|
||||
return HeadquartersEntity
|
||||
.createHeadquartersList(
|
||||
headquartersRepository.findAll(Specification
|
||||
.where(HeadquartersRepository.idHeadquartersEqual(searchConditionDepartment.getIdDivision()))
|
||||
.and(HeadquartersRepository.nmHeadquartersEqual(searchConditionDepartment.getNmDivision()))
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* searchConditionDepartment の情報を元に Department のレコードを取得
|
||||
* 部分一致検索
|
||||
*
|
||||
* @param searchConditionDepartment 検索条件
|
||||
* @return 検索結果のレコード
|
||||
*/
|
||||
public List<Department> searchByWithLike(SearchConditionDepartment searchConditionDepartment) {
|
||||
public List<Department> searchByDepartment(SearchConditionDepartment searchConditionDepartment) {
|
||||
// 動的に検索条件を絞り込む
|
||||
// Specification は Criteria API の Predicate をラップしたもの
|
||||
// // Specification は Criteria API //の Predicate をラップしたもの
|
||||
return DepartmentEntity
|
||||
.createDepartmentList(
|
||||
departmentRepository.findAll(Specification
|
||||
.where(DepartmentRepository.idDepartmentEqual(searchConditionDepartment.getIdDepartment()))
|
||||
.and(DepartmentRepository.nmDepartmentLike(searchConditionDepartment.getNmDepartment()))
|
||||
departmentRepository.findAll(Specification
|
||||
.where(DepartmentRepository.idDepartmentEqual(searchConditionDepartment.getIdDivision()))
|
||||
.and(DepartmentRepository.nmDepartmentEqual(searchConditionDepartment.getNmDivision()))
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
public List<Division> searchByDivision(SearchConditionDepartment searchConditionDepartment) {
|
||||
// 動的に検索条件を絞り込む
|
||||
// // Specification は Criteria AP//I の Predicate をラップしたもの
|
||||
return DivisionEntity
|
||||
.createDivisionList(
|
||||
divisionRepository.findAll(Specification
|
||||
.where(DivisionRepository.idDivisionEqual(searchConditionDepartment.getIdDivision()))
|
||||
.and(DivisionRepository.nmDivisionEqual(searchConditionDepartment.getNmDivision()))
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// /**
|
||||
// * searchConditionDepartment の情報を元に Department のレコードを取得
|
||||
// * 部分一致検索
|
||||
// *
|
||||
// * @param searchConditionDepartment 検索条件
|
||||
// * @return 検索結果のレコード
|
||||
// */
|
||||
// public List<DepartmentInfo> searchByWithLike(SearchConditionDepartment searchConditionDepartment) {
|
||||
// // 動的に検索条件を絞り込む
|
||||
// // Specification は Criteria API の Predicate をラップしたもの
|
||||
// return DepartmentEntity
|
||||
// .createDepartmentList(
|
||||
// departmentRepository.findAll(Specification
|
||||
// .where(DepartmentRepository.idDepartmentEqual(searchConditionDepartment.getIdDepartment()))
|
||||
// .and(DepartmentRepository.nmDepartmentLike(searchConditionDepartment.getNmDepartment()))
|
||||
// )
|
||||
// );
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
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.LoginUser;
|
||||
import com.example.rhizome.app.domain.service.SearchEmployee;
|
||||
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||
import com.example.rhizome.app.infra.repository.EmployeeRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Employee テーブル検索系の機能を集約させるサービスクラスです。
|
||||
@@ -64,7 +65,7 @@ public class SearchEmployeeImpl implements SearchEmployee {
|
||||
* @return Table から取得したレコードの情報
|
||||
*/
|
||||
@Override
|
||||
public List<Employee> searchEmployeeByIdDepartment(Integer idDepartment) {
|
||||
return EmployeeEntity.createEmployeeList(employeeRepository.findByIdDepartment(idDepartment));
|
||||
public List<Employee> searchEmployeeByIdDepartment(Integer idDivision) {
|
||||
return EmployeeEntity.createEmployeeList(employeeRepository.findByDivision_idDivision(idDivision));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
package com.example.rhizome.app.domain.service.impl;
|
||||
|
||||
import com.example.rhizome.app.domain.model.EmployeeInfo;
|
||||
import com.example.rhizome.app.domain.model.SearchConditionEmployee;
|
||||
import com.example.rhizome.app.domain.service.SearchEmployeeInfo;
|
||||
import com.example.rhizome.app.infra.entity.EmployeeDepartmentEntity;
|
||||
import com.example.rhizome.app.infra.repository.EmployeeInfoRepository;
|
||||
import 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 java.util.List;
|
||||
import com.example.rhizome.app.domain.model.AllEmployeeInfo;
|
||||
import com.example.rhizome.app.domain.model.SearchConditionEmployee;
|
||||
import com.example.rhizome.app.domain.service.SearchEmployeeInfo;
|
||||
import com.example.rhizome.app.infra.entity.EmployeeDepartmentEntity;
|
||||
import com.example.rhizome.app.infra.repository.EmployeeInfoRepository;
|
||||
|
||||
/**
|
||||
* SearchEmployeeInfoImpl (employee join department) 検索系の機能を集約させるサービスクラスです
|
||||
@@ -32,9 +33,9 @@ public class SearchEmployeeInfoImpl implements SearchEmployeeInfo {
|
||||
*
|
||||
* @return 取得したレコード全件
|
||||
*/
|
||||
public List<EmployeeInfo> selectAll() {
|
||||
public List<AllEmployeeInfo> selectAll() {
|
||||
|
||||
return EmployeeDepartmentEntity.createEmployeeInfoList(employeeInfoRepository.findAll());
|
||||
return EmployeeDepartmentEntity.createEmployeeInfoList(employeeInfoRepository.findAlltable());
|
||||
|
||||
}
|
||||
|
||||
@@ -44,17 +45,18 @@ public class SearchEmployeeInfoImpl implements SearchEmployeeInfo {
|
||||
* @param searchConditionEmployee 検索条件
|
||||
* @return 検索結果のレコードリスト
|
||||
*/
|
||||
public List<EmployeeInfo> searchBy(SearchConditionEmployee searchConditionEmployee) {
|
||||
public List<AllEmployeeInfo> searchBy(SearchConditionEmployee searchConditionEmployee) {
|
||||
// 動的に検索条件を絞り込む
|
||||
// Specification は Criteria API の Predicate をラップしたもの
|
||||
|
||||
return EmployeeDepartmentEntity
|
||||
.createEmployeeInfoList(
|
||||
.AfterSearchCreateEmployeeInfoList(
|
||||
employeeInfoRepository.findAll(Specification
|
||||
.where(EmployeeInfoRepository.idEmployeeEqual(searchConditionEmployee.getIdEmployee()))
|
||||
.and(EmployeeInfoRepository.nmEmployeeEqual(searchConditionEmployee.getNmEmployee()))
|
||||
.and(EmployeeInfoRepository.knEmployeeEqual(searchConditionEmployee.getKnEmployee()))
|
||||
.and(EmployeeInfoRepository.mailAddressEqual(searchConditionEmployee.getMailAddress()))
|
||||
.and(EmployeeInfoRepository.idDepartmentEqual(searchConditionEmployee.getIdDepartment()))
|
||||
.and(EmployeeInfoRepository.idDivisionEqual(searchConditionEmployee.getIdDivision()))
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
package com.example.rhizome.app.domain.service.impl;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Department;
|
||||
import com.example.rhizome.app.domain.service.UpdateDepartment;
|
||||
import com.example.rhizome.app.infra.entity.DepartmentEntity;
|
||||
import com.example.rhizome.app.infra.repository.DepartmentRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.example.rhizome.app.domain.model.DepartmentInfo;
|
||||
import com.example.rhizome.app.domain.service.UpdateDepartment;
|
||||
import com.example.rhizome.app.infra.entity.DepartmentInfoEntity;
|
||||
import com.example.rhizome.app.infra.repository.DepartmentInfoRepository;
|
||||
|
||||
/**
|
||||
* department の更新系の機能を集約させるサービスクラスです。
|
||||
*/
|
||||
@@ -15,11 +16,13 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
@Transactional
|
||||
public class UpdateDepartmentImpl implements UpdateDepartment {
|
||||
|
||||
DepartmentRepository departmentRepository;
|
||||
|
||||
|
||||
DepartmentInfoRepository departmentInfoRepository;
|
||||
|
||||
@Autowired
|
||||
public UpdateDepartmentImpl(DepartmentRepository departmentRepository) {
|
||||
this.departmentRepository = departmentRepository;
|
||||
public UpdateDepartmentImpl(DepartmentInfoRepository departmentInfoRepository
|
||||
) {
|
||||
this.departmentInfoRepository = departmentInfoRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -27,9 +30,12 @@ public class UpdateDepartmentImpl implements UpdateDepartment {
|
||||
*
|
||||
* @param department 更新のデータ
|
||||
*/
|
||||
public void updateDepartment(Department department) {
|
||||
|
||||
departmentRepository.save(DepartmentEntity.convertFrom(department));
|
||||
|
||||
public void updateDepartment(DepartmentInfo departmentInfo) {
|
||||
System.out.println(departmentInfo.getIdDivision());
|
||||
departmentInfoRepository.save(DepartmentInfoEntity.convertFrom(departmentInfo));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Employee;
|
||||
import com.example.rhizome.app.domain.service.UpdateEmployee;
|
||||
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||
import com.example.rhizome.app.infra.entity.InsertEmployeeEntity;
|
||||
import com.example.rhizome.app.infra.repository.EmployeeRepository;
|
||||
|
||||
/**
|
||||
@@ -31,7 +31,7 @@ public class UpdateEmployeeImpl implements UpdateEmployee {
|
||||
*/
|
||||
public void updateEmployee(Employee beforeEmployee, Employee updateEmployee) {
|
||||
|
||||
employeeRepository.save(EmployeeEntity.convertFrom(mergeEmployee(beforeEmployee, updateEmployee)));
|
||||
employeeRepository.save(InsertEmployeeEntity.convertFrom(mergeEmployee(beforeEmployee, updateEmployee)));
|
||||
|
||||
}
|
||||
|
||||
@@ -52,9 +52,9 @@ public class UpdateEmployeeImpl implements UpdateEmployee {
|
||||
updateEmployee.getKnEmployee(),
|
||||
updateEmployee.getMailAddress(),
|
||||
updateEmployee.getPassword().isBlank() ? beforeEmployee.getPassword() : updateEmployee.getPassword(),
|
||||
updateEmployee.getHireDate(),
|
||||
updateEmployee.getHireDate(),
|
||||
updateEmployee.getAdminAuth() == null ? beforeEmployee.getAdminAuth() : updateEmployee.getAdminAuth(),
|
||||
updateEmployee.getIdDepartment() == null ? beforeEmployee.getIdDepartment() : updateEmployee.getIdDepartment()
|
||||
updateEmployee.getIdDivision() == null ? beforeEmployee.getIdDivision() : updateEmployee.getIdDivision()
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@@ -7,14 +7,28 @@
|
||||
package com.example.rhizome.app.infra.entity;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
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.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.DepartmentInfo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Department テーブルの Entity
|
||||
*
|
||||
@@ -28,18 +42,27 @@ import java.util.List;
|
||||
public class DepartmentEntity {
|
||||
|
||||
/**
|
||||
* 部署ID
|
||||
* 部ID
|
||||
*/
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id_department", nullable = false)
|
||||
private Integer idDepartment;
|
||||
/**
|
||||
* 部署名
|
||||
* 部名
|
||||
*/
|
||||
@Column(name = "nm_department", nullable = false)
|
||||
private String nmDepartment;
|
||||
|
||||
/**
|
||||
* 表示・非表示フラグ
|
||||
*/
|
||||
@Column(name = "is_display", nullable = false)
|
||||
private Integer isDisplay;
|
||||
@ManyToOne(cascade = CascadeType.ALL)
|
||||
@JoinColumn(name = "id_headquarters")
|
||||
@Fetch(FetchMode.JOIN)
|
||||
private HeadquartersEntity headquarters;
|
||||
|
||||
/**
|
||||
* DepartmentEntity(DataAccess層依存)から Department(BusinessLogic層依存型)に変換します。
|
||||
*
|
||||
@@ -53,7 +76,10 @@ public class DepartmentEntity {
|
||||
.stream()
|
||||
.map(departmentEntity -> new Department(
|
||||
departmentEntity.getIdDepartment(),
|
||||
departmentEntity.getNmDepartment()
|
||||
departmentEntity.getNmDepartment(),
|
||||
departmentEntity.getIsDisplay(),
|
||||
departmentEntity.getHeadquarters() == null ? null : departmentEntity.getHeadquarters().getIdHeadquarters()
|
||||
|
||||
)).toList();
|
||||
}
|
||||
|
||||
@@ -63,10 +89,16 @@ public class DepartmentEntity {
|
||||
* @param department department モデルの値
|
||||
* @return DepartmentEntity に変換したインスタンス
|
||||
*/
|
||||
public static DepartmentEntity convertFrom(Department department) {
|
||||
return new DepartmentEntity(
|
||||
department.getIdDepartment(),
|
||||
department.getNmDepartment()
|
||||
);
|
||||
}
|
||||
public static DepartmentEntity convertFrom(DepartmentInfo departmentInfo) {
|
||||
return new DepartmentEntity(
|
||||
departmentInfo.getIdDepartment(),
|
||||
departmentInfo.getNmDepartment(),
|
||||
(Integer)0,
|
||||
new HeadquartersEntity(
|
||||
departmentInfo.getIdHeadquarters(),
|
||||
departmentInfo.getNmHeadquarters(),
|
||||
(Integer)0
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,22 +2,13 @@ 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.AllEmployeeInfo;
|
||||
import com.example.rhizome.app.domain.model.Department;
|
||||
import com.example.rhizome.app.domain.model.Division;
|
||||
import com.example.rhizome.app.domain.model.Employee;
|
||||
import com.example.rhizome.app.domain.model.EmployeeInfo;
|
||||
import com.example.rhizome.app.domain.model.Headquarters;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@@ -28,92 +19,74 @@ import lombok.NoArgsConstructor;
|
||||
*
|
||||
* @author IT-College
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "employee")
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@NamedEntityGraph(
|
||||
name = "employee_with_department",
|
||||
name = "employee_with_division_with_department_with_headquarters",
|
||||
includeAllAttributes = true
|
||||
)
|
||||
public class EmployeeDepartmentEntity {
|
||||
|
||||
/**
|
||||
* 社員ID
|
||||
*/
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id_employee", nullable = false)
|
||||
private Integer idEmployee;
|
||||
private EmployeeEntity Employee;
|
||||
|
||||
/**
|
||||
* 社員名
|
||||
*/
|
||||
@Column(name = "nm_employee", nullable = false)
|
||||
private String nmEmployee;
|
||||
private DivisionEntity division;
|
||||
|
||||
/**
|
||||
* 社員名カナ
|
||||
*/
|
||||
@Column(name = "kn_employee", nullable = false)
|
||||
private String knEmployee;
|
||||
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
@Column(name = "mail_address", nullable = false)
|
||||
private String mailAddress;
|
||||
|
||||
/**
|
||||
* パスワード
|
||||
*/
|
||||
@Column(name = "password", nullable = false)
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 入社年月日
|
||||
*/
|
||||
@Column(name = "hire_date", nullable = false)
|
||||
private String hireDate;
|
||||
|
||||
/**
|
||||
* 管理者権限
|
||||
*/
|
||||
@Column(name = "admin_auth", nullable = false)
|
||||
private Integer adminAuth;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "id_department", referencedColumnName = "id_department", insertable = false, updatable = false)
|
||||
@Fetch(FetchMode.JOIN)
|
||||
private DepartmentEntity department;
|
||||
|
||||
|
||||
private HeadquartersEntity headquarters;
|
||||
|
||||
|
||||
/**
|
||||
* EmployeeDepartmentEntity(DataAccess層依存) を EmployeeInfo(BusinessLogic層依存) に変換します。
|
||||
*
|
||||
* @param employeeDepartmentEntity EmployeeDepartmentEntity のインスタンス
|
||||
* @return EmployeeInfo のインスタンス
|
||||
*/
|
||||
public static EmployeeInfo createEmployeeInfo(EmployeeDepartmentEntity employeeDepartmentEntity) {
|
||||
public static AllEmployeeInfo createEmployeeInfo(EmployeeDepartmentEntity employeeDepartmentEntity) {
|
||||
|
||||
// コンストラクタを使って書くとSetterを使用するより簡略化出来ます。
|
||||
// 混乱してしまう人は落ち着いて EmployeeInfo のフィールドを見に行って、
|
||||
// どうしてこの書き方が出来るのかを理解できる様になりましょう。
|
||||
return new EmployeeInfo(
|
||||
return new AllEmployeeInfo(
|
||||
new Employee(
|
||||
employeeDepartmentEntity.getIdEmployee(),
|
||||
employeeDepartmentEntity.getNmEmployee(),
|
||||
employeeDepartmentEntity.getKnEmployee(),
|
||||
employeeDepartmentEntity.getMailAddress(),
|
||||
employeeDepartmentEntity.getPassword(),
|
||||
employeeDepartmentEntity.getHireDate(),
|
||||
employeeDepartmentEntity.getAdminAuth(),
|
||||
employeeDepartmentEntity.getDepartment() == null ? null : employeeDepartmentEntity.getDepartment().getIdDepartment() ),
|
||||
employeeDepartmentEntity.getEmployee().getIdEmployee(),
|
||||
employeeDepartmentEntity.getEmployee().getNmEmployee(),
|
||||
employeeDepartmentEntity.getEmployee().getKnEmployee(),
|
||||
employeeDepartmentEntity.getEmployee().getMailAddress(),
|
||||
employeeDepartmentEntity.getEmployee().getPassword(),
|
||||
employeeDepartmentEntity.getEmployee().getHireDate(),
|
||||
employeeDepartmentEntity.getEmployee().getAdminAuth(),
|
||||
employeeDepartmentEntity.getDivision()
|
||||
== null ? null : employeeDepartmentEntity.getDivision().getIdDivision()),
|
||||
new Division(
|
||||
employeeDepartmentEntity.getDivision()
|
||||
== null ? null : employeeDepartmentEntity.getDivision().getIdDivision(),
|
||||
employeeDepartmentEntity.getDivision()
|
||||
== null ? null : employeeDepartmentEntity.getDivision().getNmDivision(),
|
||||
employeeDepartmentEntity.getDivision()
|
||||
== null ? null : employeeDepartmentEntity.getDivision().getIsDisplay(),
|
||||
employeeDepartmentEntity.getDepartment()
|
||||
== null ? null : employeeDepartmentEntity.getDepartment().getIdDepartment()
|
||||
),
|
||||
new Department(
|
||||
employeeDepartmentEntity.getDepartment() == null ? null : employeeDepartmentEntity.getDepartment().getIdDepartment(),
|
||||
employeeDepartmentEntity.getDepartment() == null ? null : employeeDepartmentEntity.getDepartment().getNmDepartment()
|
||||
)
|
||||
employeeDepartmentEntity.getDepartment()
|
||||
== null ? null : employeeDepartmentEntity.getDepartment().getIdDepartment(),
|
||||
employeeDepartmentEntity.getDepartment()
|
||||
== null ? null : employeeDepartmentEntity.getDepartment().getNmDepartment(),
|
||||
employeeDepartmentEntity.getDepartment()
|
||||
== null ? null : employeeDepartmentEntity.getDepartment().getIsDisplay(),
|
||||
employeeDepartmentEntity.getHeadquarters()
|
||||
== null ? null : employeeDepartmentEntity.getHeadquarters().getIdHeadquarters()
|
||||
),
|
||||
new Headquarters(
|
||||
employeeDepartmentEntity.getHeadquarters()
|
||||
== null ? null : employeeDepartmentEntity.getHeadquarters().getIdHeadquarters(),
|
||||
employeeDepartmentEntity.getHeadquarters()
|
||||
== null ? null : employeeDepartmentEntity.getHeadquarters().getNmHeadquarters(),
|
||||
employeeDepartmentEntity.getHeadquarters()
|
||||
== null ? null : employeeDepartmentEntity.getHeadquarters().getIsDisplay()
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
@@ -125,12 +98,66 @@ public class EmployeeDepartmentEntity {
|
||||
* @param employeeDepartmentEntityList EmployeeDepartmentEntity インスタンスのリスト
|
||||
* @return EmployeeInfo インスタンスのリスト
|
||||
*/
|
||||
public static List<EmployeeInfo> createEmployeeInfoList(List<EmployeeDepartmentEntity> employeeDepartmentEntityList) {
|
||||
public static List<AllEmployeeInfo> createEmployeeInfoList(List<EmployeeDepartmentEntity> employeeDepartmentEntityList) {
|
||||
|
||||
// StreamAPI を使うとこうなります。
|
||||
return employeeDepartmentEntityList.stream().map(EmployeeDepartmentEntity::createEmployeeInfo).toList();
|
||||
|
||||
}
|
||||
|
||||
public static AllEmployeeInfo createEmployeeInfo(EmployeeEntity employeeEntity) {
|
||||
|
||||
// コンストラクタを使って書くとSetterを使用するより簡略化出来ます。
|
||||
// 混乱してしまう人は落ち着いて EmployeeInfo のフィールドを見に行って、
|
||||
// どうしてこの書き方が出来るのかを理解できる様になりましょう。
|
||||
return new AllEmployeeInfo(
|
||||
new Employee(
|
||||
employeeEntity.getIdEmployee(),
|
||||
employeeEntity.getNmEmployee(),
|
||||
employeeEntity.getKnEmployee(),
|
||||
employeeEntity.getMailAddress(),
|
||||
employeeEntity.getPassword(),
|
||||
employeeEntity.getHireDate(),
|
||||
employeeEntity.getAdminAuth(),
|
||||
employeeEntity.getDivision()
|
||||
== null ? null : employeeEntity.getDivision().getIdDivision()),
|
||||
new Division(
|
||||
employeeEntity.getDivision()
|
||||
== null ? null : employeeEntity.getDivision().getIdDivision(),
|
||||
employeeEntity.getDivision()
|
||||
== null ? null : employeeEntity.getDivision().getNmDivision(),
|
||||
employeeEntity.getDivision()
|
||||
== null ? null : employeeEntity.getDivision().getIsDisplay(),
|
||||
employeeEntity.getDivision().getDepartment()
|
||||
== null ? null : employeeEntity.getDivision().getDepartment().getIdDepartment()
|
||||
),
|
||||
new Department(
|
||||
employeeEntity.getDivision().getDepartment()
|
||||
== null ? null : employeeEntity.getDivision().getDepartment().getIdDepartment(),
|
||||
employeeEntity.getDivision().getDepartment()
|
||||
== null ? null : employeeEntity.getDivision().getDepartment().getNmDepartment(),
|
||||
employeeEntity.getDivision().getDepartment()
|
||||
== null ? null : employeeEntity.getDivision().getDepartment().getIsDisplay(),
|
||||
employeeEntity.getDivision().getDepartment().getHeadquarters()
|
||||
== null ? null : employeeEntity.getDivision().getDepartment().getHeadquarters().getIdHeadquarters()
|
||||
),
|
||||
new Headquarters(
|
||||
employeeEntity.getDivision().getDepartment().getHeadquarters()
|
||||
== null ? null : employeeEntity.getDivision().getDepartment().getHeadquarters().getIdHeadquarters(),
|
||||
employeeEntity.getDivision().getDepartment().getHeadquarters()
|
||||
== null ? null : employeeEntity.getDivision().getDepartment().getHeadquarters().getNmHeadquarters(),
|
||||
employeeEntity.getDivision().getDepartment().getHeadquarters()
|
||||
== null ? null : employeeEntity.getDivision().getDepartment().getHeadquarters().getIsDisplay()
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static List<AllEmployeeInfo> AfterSearchCreateEmployeeInfoList(List<EmployeeEntity> employeeEntityList) {
|
||||
|
||||
// StreamAPI を使うとこうなります。
|
||||
return employeeEntityList.stream().map(EmployeeDepartmentEntity::createEmployeeInfo).toList();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,9 +14,15 @@ 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.Table;
|
||||
|
||||
import org.hibernate.annotations.Fetch;
|
||||
import org.hibernate.annotations.FetchMode;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Employee;
|
||||
import com.example.rhizome.app.domain.model.EmployeeInfo;
|
||||
import com.example.rhizome.app.domain.model.LoginUser;
|
||||
import com.example.rhizome.app.domain.model.SearchConditionEmployee;
|
||||
|
||||
@@ -82,9 +88,10 @@ public class EmployeeEntity {
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
@Column(name = "id_department", nullable = false)
|
||||
private Integer idDepartment;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "id_division")
|
||||
@Fetch(FetchMode.JOIN)
|
||||
private DivisionEntity division;
|
||||
|
||||
|
||||
/**
|
||||
@@ -93,17 +100,21 @@ public class EmployeeEntity {
|
||||
* @param employee Employee Table の中身
|
||||
* @return EmployeeEntity のインスタンス(1レコード分)
|
||||
*/
|
||||
public static EmployeeEntity convertFrom(Employee employee) {
|
||||
public static EmployeeEntity convertFrom(EmployeeInfo employeeInfo) {
|
||||
// 値を既に持ったインスタンスの生成に、コンストラクタを使用するとこうなります。
|
||||
return new EmployeeEntity(
|
||||
employee.getIdEmployee(),
|
||||
employee.getNmEmployee(),
|
||||
employee.getKnEmployee(),
|
||||
employee.getMailAddress(),
|
||||
employee.getPassword(),
|
||||
employee.getHireDate(),
|
||||
employee.getAdminAuth(),
|
||||
employee.getIdDepartment()
|
||||
employeeInfo.getEmployee().getIdEmployee(),
|
||||
employeeInfo.getEmployee().getNmEmployee(),
|
||||
employeeInfo.getEmployee().getKnEmployee(),
|
||||
employeeInfo.getEmployee().getMailAddress(),
|
||||
employeeInfo.getEmployee().getPassword(),
|
||||
employeeInfo.getEmployee().getHireDate(),
|
||||
employeeInfo.getEmployee().getAdminAuth(),
|
||||
new DivisionEntity(
|
||||
employeeInfo.getDivision().getIdDivision(),
|
||||
employeeInfo.getDivision().getNmDivision(),
|
||||
employeeInfo.getDivision().getIsDisplay(),
|
||||
null)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -121,9 +132,7 @@ public class EmployeeEntity {
|
||||
employeeEntity.setNmEmployee(searchConditionEmployee.getNmEmployee());
|
||||
employeeEntity.setKnEmployee(searchConditionEmployee.getKnEmployee());
|
||||
employeeEntity.setMailAddress(searchConditionEmployee.getMailAddress());
|
||||
employeeEntity.setIdDepartment(searchConditionEmployee.getIdDepartment());
|
||||
|
||||
|
||||
|
||||
return employeeEntity;
|
||||
|
||||
}
|
||||
@@ -144,7 +153,7 @@ public class EmployeeEntity {
|
||||
employeeEntity.getPassword(),
|
||||
employeeEntity.getHireDate(),
|
||||
employeeEntity.getAdminAuth(),
|
||||
employeeEntity.getIdDepartment()
|
||||
employeeEntity.getDivision().getIdDivision()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -182,8 +191,10 @@ public class EmployeeEntity {
|
||||
getMailAddress(),
|
||||
getPassword(),
|
||||
getAdminAuth(),
|
||||
getIdDepartment()
|
||||
getDivision().getIdDivision()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package com.example.rhizome.app.infra.repository;
|
||||
|
||||
import com.example.rhizome.app.infra.entity.DepartmentEntity;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.example.rhizome.app.infra.entity.DepartmentEntity;
|
||||
|
||||
|
||||
/**
|
||||
* Specification:
|
||||
@@ -47,4 +48,10 @@ public interface DepartmentRepository extends JpaRepository<DepartmentEntity, In
|
||||
(Specification<DepartmentEntity>)
|
||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.like(root.get("nmDepartment"), "%" + nmDepartment + "%");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,18 @@
|
||||
package com.example.rhizome.app.infra.repository;
|
||||
|
||||
import com.example.rhizome.app.infra.entity.EmployeeDepartmentEntity;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.data.jpa.repository.EntityGraph;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.example.rhizome.app.infra.entity.EmployeeDepartmentEntity;
|
||||
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||
|
||||
/**
|
||||
* ワンポイント情報(ここで登場する関数型インターフェース Specification について解説します)
|
||||
* Specification:
|
||||
@@ -20,42 +27,59 @@ import org.springframework.stereotype.Repository;
|
||||
* 戻り値はクエリを格納しているPredicateオブジェクトとなります。
|
||||
*/
|
||||
@Repository
|
||||
public interface EmployeeInfoRepository extends JpaRepository<EmployeeDepartmentEntity, Integer>, JpaSpecificationExecutor<EmployeeDepartmentEntity> {
|
||||
public interface EmployeeInfoRepository extends JpaRepository<EmployeeEntity, Integer>, JpaSpecificationExecutor<EmployeeEntity> {
|
||||
|
||||
static Specification<EmployeeDepartmentEntity> idEmployeeEqual(Integer idEmployee) {
|
||||
static Specification<EmployeeEntity> idEmployeeEqual(Integer idEmployee) {
|
||||
return idEmployee == null ?
|
||||
null :
|
||||
// 戻り値の型 Specification<EmployeeDepartmentEntity> にキャスト
|
||||
(Specification<EmployeeDepartmentEntity>)
|
||||
(Specification<EmployeeEntity>)
|
||||
// ラムダ式で記載しているが書いてあることは criteriaBuilder を使って Where句の後の "'idEmployee' = idEmployee(変数)"
|
||||
// を作成している
|
||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.equal(root.get("idEmployee"), idEmployee);
|
||||
}
|
||||
|
||||
static Specification<EmployeeDepartmentEntity> nmEmployeeEqual(String nmEmployee) {
|
||||
static Specification<EmployeeEntity> nmEmployeeEqual(String nmEmployee) {
|
||||
return (nmEmployee == null || nmEmployee.isEmpty()) ?
|
||||
null :
|
||||
(Specification<EmployeeDepartmentEntity>)
|
||||
(Specification<EmployeeEntity>)
|
||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.like(root.get("nmEmployee"), "%" + nmEmployee + "%");
|
||||
}
|
||||
|
||||
static Specification<EmployeeDepartmentEntity> knEmployeeEqual(String knEmployee) {
|
||||
static Specification<EmployeeEntity> knEmployeeEqual(String knEmployee) {
|
||||
return (knEmployee == null || knEmployee.isEmpty()) ?
|
||||
null :
|
||||
(Specification<EmployeeDepartmentEntity>)
|
||||
(Specification<EmployeeEntity>)
|
||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.like(root.get("knEmployee"), "%" + knEmployee + "%");
|
||||
}
|
||||
|
||||
static Specification<EmployeeDepartmentEntity> mailAddressEqual(String mailAddress) {
|
||||
static Specification<EmployeeEntity> mailAddressEqual(String mailAddress) {
|
||||
return (mailAddress == null || mailAddress.isEmpty()) ?
|
||||
null :
|
||||
(Specification<EmployeeDepartmentEntity>)
|
||||
(Specification<EmployeeEntity>)
|
||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.like(root.get("mailAddress"), "%" + mailAddress + "%");
|
||||
}
|
||||
|
||||
static Specification<EmployeeDepartmentEntity> idDepartmentEqual(Integer idDepartment) {
|
||||
static Specification<EmployeeEntity> idDivisionEqual(Integer idDivision) {
|
||||
return (root, query, criteriaBuilder) ->
|
||||
idDepartment == null ? null :
|
||||
criteriaBuilder.equal(root.join("department").get("idDepartment"), idDepartment);
|
||||
idDivision == null ? null :
|
||||
criteriaBuilder.equal(root.join("division").get("idDivision"), idDivision);
|
||||
}
|
||||
@Query("SELECT DISTINCT new com.example.rhizome.app.infra.entity.EmployeeDepartmentEntity(e,di,de,h)FROM EmployeeEntity e "
|
||||
+ "INNER JOIN e.division di "
|
||||
+ "INNER JOIN di.department de "
|
||||
+ "INNER JOIN de.headquarters h ")
|
||||
List<EmployeeDepartmentEntity> findAlltable();
|
||||
|
||||
// @Query("SELECT DISTINCT new com.example.rhizome.app.infra.entity.EmployeeDepartmentEntity(e,di,de,h)FROM EmployeeEntity e "
|
||||
// + "INNER JOIN e.division di "
|
||||
// + "INNER JOIN di.department de "
|
||||
// + "INNER JOIN de.headquarters h "
|
||||
// + "WHERE (:idEmployee IS NULL OR e.idEmployee = idEmployee) "
|
||||
// + "AND (:nmEmployee IS NULL OR e.nmEmployee LIKE %nmEmployee%) "
|
||||
// + "AND(:knEmployee IS NULL OR e.knEmployee LIKE %knEmployee%) "
|
||||
// + "AND(:mailAddress IS NULL OR e.mailAddress Like %mailAddress%) "
|
||||
// +"AND(:idDivision IS NULL OR e.idDivision LIKE %idDivision%)")
|
||||
@EntityGraph(attributePaths = {"division", "division.department", "division.department.headquarters"})
|
||||
List<EmployeeEntity> findAll(@Nullable Specification<EmployeeEntity> spec);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
package com.example.rhizome.app.infra.repository;
|
||||
|
||||
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||
import com.example.rhizome.app.infra.entity.InsertEmployeeEntity;
|
||||
|
||||
@Repository
|
||||
public interface EmployeeRepository extends JpaRepository<EmployeeEntity, Integer> {
|
||||
Optional<EmployeeEntity> findByMailAddressAndPassword(String mailAddress, String password);
|
||||
@@ -24,5 +26,7 @@ public interface EmployeeRepository extends JpaRepository<EmployeeEntity, Intege
|
||||
/**
|
||||
* IDで検索
|
||||
**/
|
||||
List<EmployeeEntity> findByIdDepartment(Integer idDepartment);
|
||||
List<EmployeeEntity> findByDivision_idDivision(Integer idDivision);
|
||||
|
||||
void save(InsertEmployeeEntity insertEmployeeEntity);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,20 @@
|
||||
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.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.SessionCheck;
|
||||
import com.example.rhizome.app.domain.service.DeleteDepartment;
|
||||
@@ -10,18 +24,6 @@ import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAt
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
||||
import com.example.rhizome.app.presentation.form.DepartmentForm;
|
||||
import com.example.rhizome.app.presentation.form.MessageForm;
|
||||
import 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.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.DELETE_DEPARTMENT;
|
||||
|
||||
/**
|
||||
* 削除処理のコントロータ
|
||||
@@ -63,18 +65,20 @@ public class DeleteDepartmentController {
|
||||
@PermissionCheck
|
||||
@SessionCheck
|
||||
@RequestMapping(value = DELETE_DEPARTMENT, method = RequestMethod.POST)
|
||||
public String deleteEmployee(@RequestParam("idDepartment") Integer idDepartment, Model model) {
|
||||
public String deleteEmployee(@RequestParam("idDivision") Integer idDivision, Model model) {
|
||||
|
||||
try {
|
||||
|
||||
// 削除処理実施
|
||||
deleteExec(model, idDepartment);
|
||||
deleteExec(model, idDivision);
|
||||
|
||||
// 部署一覧を取得し、画面に返す用のクラスに詰め替える
|
||||
// 作成した部署一覧をセット
|
||||
model.addAttribute(
|
||||
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||
DepartmentForm.convertFrom(searchDepartment.selectAll())
|
||||
DepartmentForm.convertFrom(
|
||||
searchDepartment.searchAllDepartmentTable()
|
||||
)
|
||||
);
|
||||
|
||||
// 検索画面に遷移
|
||||
@@ -98,13 +102,13 @@ public class DeleteDepartmentController {
|
||||
* @param model ビューにデータを渡すためのコンテナ
|
||||
* @param idDepartment 削除対象のidDepartment
|
||||
*/
|
||||
private void deleteExec(Model model, Integer idDepartment) {
|
||||
private void deleteExec(Model model, Integer idDivision) {
|
||||
|
||||
final String DELETE_TARGET_ID_CAN_NOT_DELETE = "1名以上が所属している部署は削除出来ません。";
|
||||
final String DELETE_COMPLETE = "削除しました。";
|
||||
|
||||
// 1名上所属している人が居れば削除不可
|
||||
if (!searchEmployee.searchEmployeeByIdDepartment(idDepartment).isEmpty()) {
|
||||
if (!searchEmployee.searchEmployeeByIdDepartment(idDivision).isEmpty()) {
|
||||
// 削除対象だった場合
|
||||
// エラーメッセージをセット
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DELETE_TARGET_ID_CAN_NOT_DELETE));
|
||||
@@ -113,7 +117,7 @@ public class DeleteDepartmentController {
|
||||
}
|
||||
|
||||
// 削除を実施
|
||||
deleteDepartment.deleteDepartment(idDepartment);
|
||||
deleteDepartment.deleteDepartment(idDivision);
|
||||
|
||||
// 削除完了したメッセージをセット
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_INFO, new MessageForm(DELETE_COMPLETE));
|
||||
|
||||
@@ -1,6 +1,21 @@
|
||||
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.SessionCheck;
|
||||
import com.example.rhizome.app.domain.model.LoginUser;
|
||||
@@ -12,19 +27,6 @@ import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTa
|
||||
import com.example.rhizome.app.presentation.form.DepartmentForm;
|
||||
import com.example.rhizome.app.presentation.form.LoginUserForm;
|
||||
import com.example.rhizome.app.presentation.form.MessageForm;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.util.Objects;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.DELETE_EMPLOYEE;
|
||||
|
||||
/**
|
||||
* 削除処理のコントロータ
|
||||
@@ -66,7 +68,8 @@ public class DeleteEmployeeController {
|
||||
// 作成した部署一覧をセット
|
||||
model.addAttribute(
|
||||
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||
DepartmentForm.convertFrom(searchDepartment.selectAll())
|
||||
DepartmentForm.convertFrom(
|
||||
searchDepartment.searchAllDepartmentTable())
|
||||
);
|
||||
|
||||
// 削除処理実施
|
||||
|
||||
@@ -1,5 +1,19 @@
|
||||
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.SessionCheck;
|
||||
import com.example.rhizome.app.domain.model.SearchConditionDepartment;
|
||||
@@ -7,21 +21,9 @@ import com.example.rhizome.app.domain.service.SearchDepartment;
|
||||
import com.example.rhizome.app.domain.service.impl.SearchDepartmentImpl;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
||||
import com.example.rhizome.app.presentation.form.DepartmentForm;
|
||||
import com.example.rhizome.app.presentation.form.InsertDepartmentForm;
|
||||
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.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_CONFIRM;
|
||||
import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_INPUT_HTML;
|
||||
|
||||
/**
|
||||
* 新規部署情報チェック用のコントローラ
|
||||
@@ -64,11 +66,16 @@ public class InsertDepartmentConfirmController {
|
||||
@RequestMapping(value = INSERT_DEPARTMENT_CONFIRM, method = RequestMethod.POST)
|
||||
public String insertDepartmentConfirm(InsertDepartmentForm insertDepartmentForm, Model model) {
|
||||
|
||||
final String DUPLICATION = "既に同名の部署が存在します。";
|
||||
final String IRREGULARITY = "部署名が不正です。";
|
||||
final String DUPLICATION = "既に同名の本部名または部または課が存在します。";
|
||||
final String IRREGULARITY = "本部名または部または課が不正です。";
|
||||
|
||||
try {
|
||||
|
||||
model.addAttribute(
|
||||
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||
DepartmentForm.convertFrom(
|
||||
searchDepartment.searchAllDepartmentTable())
|
||||
);
|
||||
|
||||
// 入力内容に誤りがあるか
|
||||
if (insertDepartmentForm.haveNmDepartment()) {
|
||||
// 誤りがあった場合
|
||||
@@ -79,12 +86,22 @@ public class InsertDepartmentConfirmController {
|
||||
// 登録画面に遷移
|
||||
return INSERT_DEPARTMENT_INPUT_HTML;
|
||||
}
|
||||
|
||||
SearchConditionDepartment searchHeadquartersTable =new SearchConditionDepartment(
|
||||
null,
|
||||
insertDepartmentForm.getNmHeadquarters());
|
||||
SearchConditionDepartment searchDepartmentTable = new SearchConditionDepartment(
|
||||
null,
|
||||
insertDepartmentForm.getNmDepartment());
|
||||
SearchConditionDepartment searchDivisionTable = new SearchConditionDepartment(
|
||||
null,
|
||||
insertDepartmentForm.getNmDivision());
|
||||
|
||||
// 部署名で重複が無いかチェック
|
||||
if (!searchDepartment.searchBy(
|
||||
new SearchConditionDepartment(
|
||||
null,
|
||||
insertDepartmentForm.getNmDepartment())).isEmpty()) {
|
||||
|
||||
if (searchDepartment.searchAllDepartmentTable(
|
||||
searchHeadquartersTable,
|
||||
searchDepartmentTable,
|
||||
searchDivisionTable)){
|
||||
|
||||
// 存在する場合はエラーメッセージを設定して更新入力画面に遷移
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DUPLICATION));
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
package com.example.rhizome.app.presentation.controller;
|
||||
|
||||
import com.example.rhizome.aop.aspect.PermissionCheck;
|
||||
import com.example.rhizome.aop.aspect.SessionCheck;
|
||||
import com.example.rhizome.app.domain.model.SearchConditionDepartment;
|
||||
import com.example.rhizome.app.domain.service.RegisterDepartment;
|
||||
import com.example.rhizome.app.domain.service.SearchDepartment;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
||||
import com.example.rhizome.app.presentation.form.DepartmentForm;
|
||||
import com.example.rhizome.app.presentation.form.InsertDepartmentForm;
|
||||
import com.example.rhizome.app.presentation.form.MessageForm;
|
||||
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;
|
||||
@@ -17,12 +14,18 @@ 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_DEPARTMENT;
|
||||
import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_INPUT_HTML;
|
||||
import com.example.rhizome.aop.aspect.PermissionCheck;
|
||||
import com.example.rhizome.aop.aspect.SessionCheck;
|
||||
import com.example.rhizome.app.domain.model.DepartmentInfo;
|
||||
import com.example.rhizome.app.domain.model.SearchConditionDepartment;
|
||||
import com.example.rhizome.app.domain.service.RegisterDepartment;
|
||||
import com.example.rhizome.app.domain.service.SearchDepartment;
|
||||
import com.example.rhizome.app.infra.entity.DivisionEntity;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
||||
import com.example.rhizome.app.presentation.form.DepartmentForm;
|
||||
import com.example.rhizome.app.presentation.form.InsertDepartmentForm;
|
||||
import com.example.rhizome.app.presentation.form.MessageForm;
|
||||
|
||||
/**
|
||||
* 新規登録用のコントローラ
|
||||
@@ -73,7 +76,7 @@ public class InsertDepartmentController {
|
||||
model.addAttribute(
|
||||
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||
DepartmentForm.convertFrom(
|
||||
searchDepartment.selectAll()
|
||||
searchDepartment.searchAllDepartmentTable()
|
||||
));
|
||||
|
||||
// 入力内容に誤りがあるか
|
||||
@@ -87,10 +90,18 @@ public class InsertDepartmentController {
|
||||
return INSERT_DEPARTMENT_INPUT_HTML;
|
||||
}
|
||||
// 部署名で重複が無いかチェック
|
||||
if (!searchDepartment.searchBy(
|
||||
if (!searchDepartment.searchByHeadquarters(
|
||||
new SearchConditionDepartment(
|
||||
null,
|
||||
insertDepartmentForm.getNmDepartment())).isEmpty()) {
|
||||
insertDepartmentForm.getNmHeadquarters())).isEmpty()
|
||||
&&!searchDepartment.searchByDepartment(
|
||||
new SearchConditionDepartment(
|
||||
null,
|
||||
insertDepartmentForm.getNmDepartment())).isEmpty()
|
||||
&&!searchDepartment.searchByDivision(
|
||||
new SearchConditionDepartment(
|
||||
null,
|
||||
insertDepartmentForm.getNmDivision())).isEmpty()) {
|
||||
|
||||
|
||||
// 存在する場合はエラーメッセージを設定して更新入力画面に遷移
|
||||
@@ -99,9 +110,14 @@ public class InsertDepartmentController {
|
||||
|
||||
return TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_INPUT_HTML;
|
||||
}
|
||||
|
||||
DepartmentInfo departmentInfo = InsertDepartmentForm.convertTo(insertDepartmentForm);
|
||||
|
||||
DivisionEntity divisionEntity = DivisionEntity.convertFrom(departmentInfo);
|
||||
|
||||
System.out.println(divisionEntity);
|
||||
// 登録処理
|
||||
registerDepartment.registerDepartment(InsertDepartmentForm.convertTo(insertDepartmentForm));
|
||||
registerDepartment.registerDepartment(divisionEntity);
|
||||
|
||||
// 登録結果画面に遷移
|
||||
return TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_RESULT_HTML;
|
||||
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package com.example.rhizome.app.presentation.controller;
|
||||
|
||||
import com.example.rhizome.aop.aspect.PermissionCheck;
|
||||
import com.example.rhizome.aop.aspect.SessionCheck;
|
||||
import com.example.rhizome.app.domain.service.SearchDepartment;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
||||
import com.example.rhizome.app.presentation.form.InsertDepartmentForm;
|
||||
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;
|
||||
@@ -13,9 +12,13 @@ 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 com.example.rhizome.aop.aspect.PermissionCheck;
|
||||
import com.example.rhizome.aop.aspect.SessionCheck;
|
||||
import com.example.rhizome.app.domain.service.SearchDepartment;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
||||
import com.example.rhizome.app.presentation.form.DepartmentForm;
|
||||
import com.example.rhizome.app.presentation.form.InsertDepartmentForm;
|
||||
|
||||
/**
|
||||
* 登録画面表示用コントローラ
|
||||
@@ -60,6 +63,11 @@ public class InsertDepartmentInputController {
|
||||
public String insertInput(InsertDepartmentForm insertDepartmentForm, Model model) {
|
||||
|
||||
try {
|
||||
model.addAttribute(
|
||||
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||
DepartmentForm.convertFrom(
|
||||
searchDepartment.searchAllDepartmentTable())
|
||||
);
|
||||
// パラメータをセット
|
||||
model.addAttribute(PageReturnAttributeKeyword.INSERT_DEPARTMENT_FORM, insertDepartmentForm);
|
||||
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
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.SessionCheck;
|
||||
import com.example.rhizome.app.domain.model.Employee;
|
||||
@@ -12,19 +27,6 @@ import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTa
|
||||
import com.example.rhizome.app.presentation.form.DepartmentForm;
|
||||
import com.example.rhizome.app.presentation.form.InsertEmployeeForm;
|
||||
import com.example.rhizome.app.presentation.form.MessageForm;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_CONFIRM;
|
||||
|
||||
/**
|
||||
* 新規登録者情報チェック用のコントローラ
|
||||
@@ -76,7 +78,7 @@ public class InsertEmployeeConfirmController {
|
||||
model.addAttribute(
|
||||
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||
DepartmentForm.convertFrom(
|
||||
searchDepartment.selectAll()
|
||||
searchDepartment.searchAllDepartmentTable()
|
||||
));
|
||||
|
||||
// 登録用パラメータチェック
|
||||
|
||||
@@ -74,7 +74,7 @@ public class InsertEmployeeController {
|
||||
model.addAttribute(
|
||||
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||
DepartmentForm.convertFrom(
|
||||
searchDepartment.selectAll()
|
||||
searchDepartment.searchAllDepartmentTable()
|
||||
));
|
||||
|
||||
// Confirm画面から渡ってきた値をチェック
|
||||
@@ -85,7 +85,7 @@ public class InsertEmployeeController {
|
||||
insertEmployeeForm.getPassword(),
|
||||
insertEmployeeForm.getHireDate(),
|
||||
insertEmployeeForm.getAdminAuth(),
|
||||
insertEmployeeForm.getIdDepartment()
|
||||
insertEmployeeForm.getIdDivision()
|
||||
);
|
||||
|
||||
// エラーが1件以上有る場合
|
||||
|
||||
@@ -1,5 +1,19 @@
|
||||
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.SessionCheck;
|
||||
import com.example.rhizome.app.domain.service.RegisterEmployee;
|
||||
@@ -8,18 +22,6 @@ import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAt
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
||||
import com.example.rhizome.app.presentation.form.DepartmentForm;
|
||||
import com.example.rhizome.app.presentation.form.InsertEmployeeForm;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT;
|
||||
|
||||
/**
|
||||
* 登録画面表示用コントローラ
|
||||
@@ -64,7 +66,9 @@ public class InsertEmployeeInputController {
|
||||
|
||||
try {
|
||||
// 部署コードリストを作成し、画面に返す値としてセット
|
||||
model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, DepartmentForm.convertFrom(searchDepartment.selectAll()));
|
||||
model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST
|
||||
, DepartmentForm.convertFrom(
|
||||
searchDepartment.searchAllDepartmentTable()));
|
||||
|
||||
// パラメータをセット
|
||||
model.addAttribute(PageReturnAttributeKeyword.INSERT_EMPLOYEE_FORM, insertEmployeeForm);
|
||||
|
||||
@@ -62,8 +62,10 @@ public class SelectDepartmentController {
|
||||
// 作成した部署一覧をセット
|
||||
model.addAttribute(
|
||||
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||
DepartmentForm.convertFrom(searchDepartment.searchBy(SearchConditionDepartmentForm.convertTo(searchConditionDepartmentForm)))
|
||||
);
|
||||
DepartmentForm.convertFrom(
|
||||
searchDepartment.searchAllDepartmentTable(SearchConditionDepartmentForm.convertTo(searchConditionDepartmentForm))
|
||||
|
||||
));
|
||||
|
||||
// 検索ページに遷移
|
||||
return TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_HTML;
|
||||
@@ -94,12 +96,13 @@ public class SelectDepartmentController {
|
||||
public String selectAll(Model model) {
|
||||
|
||||
try {
|
||||
|
||||
// 部署一覧を取得し、画面に返す用のクラスに詰め替える
|
||||
// 作成した部署一覧をセット
|
||||
model.addAttribute(
|
||||
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||
DepartmentForm.convertFrom(searchDepartment.selectAll())
|
||||
DepartmentForm.convertFrom(
|
||||
searchDepartment.searchAllDepartmentTable()
|
||||
)
|
||||
);
|
||||
|
||||
// 検索ページに遷移
|
||||
|
||||
@@ -65,25 +65,26 @@ public class SelectEmployeeController {
|
||||
public String select(SearchConditionEmployeeForm searchConditionEmployeeForm, Model model) {
|
||||
|
||||
try {
|
||||
|
||||
|
||||
// 部署一覧を取得し、画面に返す用のクラスに詰め替える
|
||||
// 作成した部署一覧をセット
|
||||
model.addAttribute(
|
||||
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||
DepartmentForm.convertFrom(searchDepartment.selectAll())
|
||||
DepartmentForm.convertFrom(
|
||||
searchDepartment.searchAllDepartmentTable())
|
||||
);
|
||||
|
||||
// 検索条件を元に検索を実施
|
||||
// 取得した EmployeeInfo( employee + department )の情報を画面に返す用の型に詰め替えてセット
|
||||
|
||||
|
||||
List<EmployeeInfoForm>employeeInfoForm = EmployeeInfoForm.convertFrom(searchEmployeeInfo.searchBy(SearchConditionEmployeeForm.convertTo(searchConditionEmployeeForm)));
|
||||
for(EmployeeInfoForm form:employeeInfoForm) {
|
||||
String tenure = tenureCalc.tenureCalc(form.getHireDate());
|
||||
form.setTenure(tenure);
|
||||
}
|
||||
|
||||
model.addAttribute(PageReturnAttributeKeyword.EMPLOYEE_INFO_FORM_LIST, employeeInfoForm);
|
||||
// 検索ページに遷移
|
||||
|
||||
return TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_HTML;
|
||||
|
||||
|
||||
@@ -117,14 +118,13 @@ public class SelectEmployeeController {
|
||||
// 作成した部署一覧をセット
|
||||
model.addAttribute(
|
||||
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||
DepartmentForm.convertFrom(searchDepartment.selectAll())
|
||||
DepartmentForm.convertFrom(
|
||||
searchDepartment.searchAllDepartmentTable())
|
||||
);
|
||||
|
||||
// 検索条件を元に検索を実施
|
||||
List<EmployeeInfoForm>employeeInfoForm =EmployeeInfoForm.convertFrom(
|
||||
searchEmployeeInfo.searchBy(
|
||||
SearchConditionEmployeeForm.convertTo(searchConditionEmployeeForm())
|
||||
));
|
||||
searchEmployeeInfo.selectAll());
|
||||
for(EmployeeInfoForm form:employeeInfoForm) {
|
||||
String tenure = tenureCalc.tenureCalc(form.getHireDate());
|
||||
form.setTenure(tenure);
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
package com.example.rhizome.app.presentation.controller;
|
||||
|
||||
import com.example.rhizome.aop.aspect.PermissionCheck;
|
||||
import com.example.rhizome.aop.aspect.SessionCheck;
|
||||
import com.example.rhizome.app.domain.model.Department;
|
||||
import com.example.rhizome.app.domain.model.SearchConditionDepartment;
|
||||
import com.example.rhizome.app.domain.service.SearchEmployeeInfo;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
||||
import com.example.rhizome.app.presentation.form.MessageForm;
|
||||
import com.example.rhizome.app.presentation.form.SearchConditionEmployeeForm;
|
||||
import com.example.rhizome.app.presentation.form.UpdateDepartmentForm;
|
||||
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;
|
||||
@@ -18,10 +14,16 @@ 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;
|
||||
import com.example.rhizome.aop.aspect.PermissionCheck;
|
||||
import com.example.rhizome.aop.aspect.SessionCheck;
|
||||
import com.example.rhizome.app.domain.model.AllDepartmentInfo;
|
||||
import com.example.rhizome.app.domain.model.SearchConditionDepartment;
|
||||
import com.example.rhizome.app.domain.service.SearchEmployeeInfo;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
||||
import com.example.rhizome.app.presentation.form.MessageForm;
|
||||
import com.example.rhizome.app.presentation.form.SearchConditionEmployeeForm;
|
||||
import com.example.rhizome.app.presentation.form.UpdateDepartmentForm;
|
||||
|
||||
/**
|
||||
* 更新対象の Department が存在するか確認する為のコントローラ
|
||||
@@ -59,24 +61,24 @@ public class UpdateDepartmentController {
|
||||
@PermissionCheck
|
||||
@SessionCheck
|
||||
@RequestMapping(value = TransitionTargetPageNameKeyword.SHOW_UPDATE_DEPARTMENT, method = RequestMethod.POST)
|
||||
public String showUpdateEmployee(@RequestParam("idDepartment") Integer idDepartment, Model model) {
|
||||
public String showUpdateEmployee(@RequestParam("idDivision") Integer idDivision, Model model) {
|
||||
final String UPDATE_TARGET_ID_NOT_FOUND = "更新対象のデータが見つかりません。";
|
||||
|
||||
try {
|
||||
// id を条件に更新対象のレコードを検索、取得する
|
||||
List<Department> departmentList = searchDepartment.searchBy(
|
||||
new SearchConditionDepartment(idDepartment,
|
||||
List<AllDepartmentInfo>divisionList = searchDepartment.searchAllDepartmentTable(
|
||||
new SearchConditionDepartment(idDivision,
|
||||
null));
|
||||
|
||||
|
||||
// DBに更新対象のデータがあるか
|
||||
if (departmentList.isEmpty()) {
|
||||
if (divisionList.isEmpty()) {
|
||||
// ない場合はエラーメッセージをセットして検索画面に戻る
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(UPDATE_TARGET_ID_NOT_FOUND));
|
||||
return "forward:" + TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_HTML;
|
||||
}
|
||||
|
||||
// 更新画面に表示する値をセット
|
||||
model.addAttribute(PageReturnAttributeKeyword.UPDATE_DEPARTMENT_FORM, UpdateDepartmentForm.convertFrom(departmentList.get(0)));
|
||||
model.addAttribute(PageReturnAttributeKeyword.UPDATE_DEPARTMENT_FORM, UpdateDepartmentForm.convertFrom(divisionList.get(0)));
|
||||
|
||||
// Update画面に遷移
|
||||
return TransitionTargetPageNameKeyword.UPDATE_DEPARTMENT_INPUT_HTML;
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
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.SessionCheck;
|
||||
import com.example.rhizome.app.domain.model.SearchConditionDepartment;
|
||||
@@ -11,16 +23,6 @@ import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTa
|
||||
import com.example.rhizome.app.presentation.form.DepartmentForm;
|
||||
import com.example.rhizome.app.presentation.form.MessageForm;
|
||||
import com.example.rhizome.app.presentation.form.UpdateDepartmentForm;
|
||||
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;
|
||||
|
||||
/**
|
||||
* department を更新して結果を返す為のコントローラ
|
||||
@@ -36,6 +38,7 @@ public class UpdateDepartmentResultController {
|
||||
HttpSession httpSession;
|
||||
SearchDepartment searchDepartment;
|
||||
UpdateDepartment updateDepartment;
|
||||
|
||||
|
||||
@Autowired
|
||||
public UpdateDepartmentResultController(HttpSession httpSession, SearchDepartment searchDepartment, UpdateDepartment updateDepartment) {
|
||||
@@ -43,7 +46,7 @@ public class UpdateDepartmentResultController {
|
||||
this.searchDepartment = searchDepartment;
|
||||
this.updateDepartment = updateDepartment;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新結果画面表示処理
|
||||
*
|
||||
@@ -62,7 +65,9 @@ public class UpdateDepartmentResultController {
|
||||
|
||||
try {
|
||||
// 更新対象の部署データがない
|
||||
if (updateDepartmentForm.getNmDepartment().isBlank()) {
|
||||
if (updateDepartmentForm.getNmHeadquarters().isBlank()||
|
||||
updateDepartmentForm.getNmDepartment().isBlank()||
|
||||
updateDepartmentForm.getNmDivision().isBlank()) {
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(NOTHING));
|
||||
model.addAttribute(PageReturnAttributeKeyword.UPDATE_DEPARTMENT_FORM, updateDepartmentForm);
|
||||
|
||||
@@ -70,10 +75,18 @@ public class UpdateDepartmentResultController {
|
||||
}
|
||||
|
||||
// 部署名で重複が無いかチェック
|
||||
if (!searchDepartment.searchBy(
|
||||
if (!searchDepartment.searchByHeadquarters(
|
||||
new SearchConditionDepartment(
|
||||
null,
|
||||
updateDepartmentForm.getNmDepartment())).isEmpty()) {
|
||||
updateDepartmentForm.getNmHeadquarters())).isEmpty()||
|
||||
!searchDepartment.searchByDepartment(
|
||||
new SearchConditionDepartment(
|
||||
null,
|
||||
updateDepartmentForm.getNmDepartment())).isEmpty()||
|
||||
!searchDepartment.searchByDivision(
|
||||
new SearchConditionDepartment(
|
||||
null,
|
||||
updateDepartmentForm.getNmDivision())).isEmpty()) {
|
||||
// 存在する場合はエラーメッセージを設定して更新入力画面に遷移
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DUPLICATION));
|
||||
model.addAttribute(PageReturnAttributeKeyword.UPDATE_DEPARTMENT_FORM, updateDepartmentForm);
|
||||
@@ -85,7 +98,9 @@ public class UpdateDepartmentResultController {
|
||||
updateDepartment.updateDepartment(UpdateDepartmentForm.convertTo(updateDepartmentForm));
|
||||
|
||||
// 部署一覧取得
|
||||
model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, DepartmentForm.convertFrom(searchDepartment.selectAll()));
|
||||
model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, DepartmentForm.convertFrom(
|
||||
searchDepartment.searchAllDepartmentTable())
|
||||
);
|
||||
// 更新結果のメッセージを画面にセットし一覧画面に遷移
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_INFO, new MessageForm(UPDATE_COMPLETE));
|
||||
|
||||
|
||||
@@ -1,8 +1,22 @@
|
||||
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.SessionCheck;
|
||||
import com.example.rhizome.app.domain.model.EmployeeInfo;
|
||||
import com.example.rhizome.app.domain.model.AllEmployeeInfo;
|
||||
import com.example.rhizome.app.domain.model.SearchConditionEmployee;
|
||||
import com.example.rhizome.app.domain.service.SearchDepartment;
|
||||
import com.example.rhizome.app.domain.service.SearchEmployeeInfo;
|
||||
@@ -12,18 +26,6 @@ import com.example.rhizome.app.presentation.form.DepartmentForm;
|
||||
import com.example.rhizome.app.presentation.form.MessageForm;
|
||||
import com.example.rhizome.app.presentation.form.SearchConditionEmployeeForm;
|
||||
import com.example.rhizome.app.presentation.form.UpdateEmployeeInfoForm;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* 更新対象の employee が存在するか確認する為のコントローラ
|
||||
@@ -67,10 +69,11 @@ public class UpdateEmployeeController {
|
||||
|
||||
try {
|
||||
// 部署一覧を取得し画面に返す値としてセット
|
||||
model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, DepartmentForm.convertFrom(searchDepartment.selectAll()));
|
||||
model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, DepartmentForm.convertFrom(
|
||||
searchDepartment.searchAllDepartmentTable()));
|
||||
|
||||
// id を条件に更新対象のレコードを検索、取得する
|
||||
List<EmployeeInfo> employeeInfoList = searchEmployeeInfo.searchBy(
|
||||
List<AllEmployeeInfo> employeeInfoList = searchEmployeeInfo.searchBy(
|
||||
new SearchConditionEmployee(idEmployee,
|
||||
null,
|
||||
null,
|
||||
|
||||
@@ -93,7 +93,8 @@ public class UpdateEmployeeResultController {
|
||||
try {
|
||||
|
||||
// 部署一覧取得
|
||||
model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, DepartmentForm.convertFrom(searchDepartment.selectAll()));
|
||||
model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, DepartmentForm.convertFrom(
|
||||
searchDepartment.searchAllDepartmentTable()));
|
||||
|
||||
// パスワードが仕様を満たしているか確認
|
||||
String error = UpdateEmployeeInfoForm.validatePassword(
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package com.example.rhizome.app.presentation.form;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Department;
|
||||
import java.util.List;
|
||||
|
||||
import com.example.rhizome.app.domain.model.AllDepartmentInfo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 画面の表示に使う部署コード管理用のクラス
|
||||
*/
|
||||
@@ -15,14 +16,29 @@ import java.util.List;
|
||||
@NoArgsConstructor
|
||||
public class DepartmentForm {
|
||||
/**
|
||||
* 部署ID
|
||||
* 本部ID
|
||||
*/
|
||||
private Integer idHeadquarters;
|
||||
/**
|
||||
* 本部名
|
||||
*/
|
||||
private String nmHeadquarters;
|
||||
/**
|
||||
* 部ID
|
||||
*/
|
||||
private Integer idDepartment;
|
||||
/**
|
||||
* 部署名
|
||||
* 部名
|
||||
*/
|
||||
private String nmDepartment;
|
||||
|
||||
/**
|
||||
* 課ID
|
||||
*/
|
||||
private Integer idDivision;
|
||||
/**
|
||||
* 課名
|
||||
*/
|
||||
private String nmDivision;
|
||||
/**
|
||||
* business 層の Department クラスから画面用(presentation 層)の DepartmentForm に
|
||||
* 変換します。
|
||||
@@ -30,8 +46,15 @@ public class DepartmentForm {
|
||||
* @param department business 層の Department インスタンス
|
||||
* @return 画面用(presentation 層)の DepartmentForm インスタンス
|
||||
*/
|
||||
public static DepartmentForm convertFrom(Department department) {
|
||||
return new DepartmentForm(department.getIdDepartment(), department.getNmDepartment());
|
||||
public static DepartmentForm convertFrom(AllDepartmentInfo allDepartmentInfo) {
|
||||
return new DepartmentForm(
|
||||
allDepartmentInfo.getHeadquarters().getIdHeadquarters(),
|
||||
allDepartmentInfo.getHeadquarters().getNmHeadquarters(),
|
||||
allDepartmentInfo.getDepartment().getIdDepartment(),
|
||||
allDepartmentInfo.getDepartment().getNmDepartment(),
|
||||
allDepartmentInfo.getDivision().getIdDivision(),
|
||||
allDepartmentInfo.getDivision().getNmDivision()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -41,7 +64,8 @@ public class DepartmentForm {
|
||||
* @param departmentList business 層の Department インスタンスのリスト
|
||||
* @return 画面用(presentation 層)の DepartmentForm インスタンスのリスト
|
||||
*/
|
||||
public static List<DepartmentForm> convertFrom(List<Department> departmentList) {
|
||||
return departmentList.stream().map(DepartmentForm::convertFrom).toList();
|
||||
public static List<DepartmentForm> convertFrom(List<AllDepartmentInfo>allDepartmentInfoList
|
||||
) {
|
||||
return allDepartmentInfoList.stream().map(DepartmentForm::convertFrom).toList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ 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.AllEmployeeInfo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@@ -50,13 +50,29 @@ public class EmployeeInfoForm {
|
||||
*/
|
||||
private Integer adminAuth;
|
||||
/**
|
||||
* 部署ID
|
||||
* 本部ID
|
||||
*/
|
||||
private Integer idHeadquarters;
|
||||
/**
|
||||
* 本部名
|
||||
*/
|
||||
private String nmHeadquarters;
|
||||
/**
|
||||
* 部ID
|
||||
*/
|
||||
private Integer idDepartment;
|
||||
/**
|
||||
* 部署名
|
||||
* 部名
|
||||
*/
|
||||
private String nmDepartment;
|
||||
/**
|
||||
* 課ID
|
||||
*/
|
||||
private Integer idDivision;
|
||||
/**
|
||||
* 課名
|
||||
*/
|
||||
private String nmDivision;
|
||||
|
||||
/**
|
||||
* business 層の EmployeeInfo クラスから画面用(presentation 層)の EmployeeInfoForm に
|
||||
@@ -65,18 +81,22 @@ public class EmployeeInfoForm {
|
||||
* @param employeeInfo business 層の EmployeeInfo インスタンス
|
||||
* @return クラスから画面用(presentation 層)の EmployeeInfoForm インスタンス
|
||||
*/
|
||||
public static EmployeeInfoForm convertFrom(EmployeeInfo employeeInfo) {
|
||||
public static EmployeeInfoForm convertFrom(AllEmployeeInfo allEmployeeInfo) {
|
||||
return new EmployeeInfoForm(
|
||||
employeeInfo.getEmployee().getIdEmployee(),
|
||||
employeeInfo.getEmployee().getNmEmployee(),
|
||||
employeeInfo.getEmployee().getKnEmployee(),
|
||||
employeeInfo.getEmployee().getMailAddress(),
|
||||
employeeInfo.getEmployee().getPassword(),
|
||||
employeeInfo.getEmployee().getHireDate(),
|
||||
allEmployeeInfo.getEmployee().getIdEmployee(),
|
||||
allEmployeeInfo.getEmployee().getNmEmployee(),
|
||||
allEmployeeInfo.getEmployee().getKnEmployee(),
|
||||
allEmployeeInfo.getEmployee().getMailAddress(),
|
||||
allEmployeeInfo.getEmployee().getPassword(),
|
||||
allEmployeeInfo.getEmployee().getHireDate(),
|
||||
null,
|
||||
employeeInfo.getEmployee().getAdminAuth(),
|
||||
employeeInfo.getDepartment().getIdDepartment(),
|
||||
employeeInfo.getDepartment().getNmDepartment()
|
||||
allEmployeeInfo.getEmployee().getAdminAuth(),
|
||||
allEmployeeInfo.getHeadquarters().getIdHeadquarters(),
|
||||
allEmployeeInfo.getHeadquarters().getNmHeadquarters(),
|
||||
allEmployeeInfo.getDepartment().getIdDepartment(),
|
||||
allEmployeeInfo.getDepartment().getNmDepartment(),
|
||||
allEmployeeInfo.getDivision().getIdDivision(),
|
||||
allEmployeeInfo.getDivision().getNmDivision()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -87,7 +107,7 @@ public class EmployeeInfoForm {
|
||||
* @param employeeInfoList business 層の EmployeeInfo インスタンスのリスト
|
||||
* @return クラスから画面用(presentation 層)の EmployeeInfoForm インスタンスのリスト
|
||||
*/
|
||||
public static List<EmployeeInfoForm> convertFrom(List<EmployeeInfo> employeeInfoList) {
|
||||
return employeeInfoList.stream().map(EmployeeInfoForm::convertFrom).toList();
|
||||
public static List<EmployeeInfoForm> convertFrom(List<AllEmployeeInfo> allEmployeeInfoList) {
|
||||
return allEmployeeInfoList.stream().map(EmployeeInfoForm::convertFrom).toList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.example.rhizome.app.presentation.form;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Department;
|
||||
import com.example.rhizome.app.domain.model.DepartmentInfo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -12,29 +13,63 @@ import lombok.NoArgsConstructor;
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class InsertDepartmentForm {
|
||||
/**
|
||||
* 本部ID
|
||||
*/
|
||||
private Integer idHeadquarters;
|
||||
/**
|
||||
* 本部名
|
||||
*/
|
||||
private String nmHeadquarters;
|
||||
/**
|
||||
* 部ID
|
||||
*/
|
||||
private Integer idDepartment;
|
||||
/**
|
||||
* 部名
|
||||
*/
|
||||
private String nmDepartment;
|
||||
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
private Integer idDepartment;
|
||||
/**
|
||||
* 部署名
|
||||
*/
|
||||
private String nmDepartment;
|
||||
/**
|
||||
* 課ID
|
||||
*/
|
||||
private Integer idDivision;
|
||||
/**
|
||||
* 課名
|
||||
*/
|
||||
private String nmDivision;
|
||||
|
||||
/**
|
||||
* 画面用(presentation 層)の InsertDepartmentForm クラス を Business 層の Department クラスに変換
|
||||
*
|
||||
* @param insertDepartmentForm presentation 層用のクラス
|
||||
* @return Business 層用のモデル
|
||||
*/
|
||||
public static Department convertTo(InsertDepartmentForm insertDepartmentForm) {
|
||||
return new Department(insertDepartmentForm.getIdDepartment(), insertDepartmentForm.getNmDepartment());
|
||||
}
|
||||
/**
|
||||
* 画面用(presentation 層)の InsertDepartmentForm クラス を Business 層の Department クラスに変換
|
||||
*
|
||||
* @param insertDepartmentForm presentation 層用のクラス
|
||||
* @return Business 層用のモデル
|
||||
*/
|
||||
public static DepartmentInfo convertTo(InsertDepartmentForm insertDepartmentForm) {
|
||||
return new DepartmentInfo(insertDepartmentForm.getIdHeadquarters(),
|
||||
insertDepartmentForm.getNmHeadquarters(),
|
||||
insertDepartmentForm.getIdDepartment(),
|
||||
insertDepartmentForm.getNmDepartment(),
|
||||
insertDepartmentForm.getIdDivision(),
|
||||
insertDepartmentForm.getNmDivision());
|
||||
}
|
||||
|
||||
public boolean haveNmDepartment() {
|
||||
|
||||
public boolean haveNmDepartment() {
|
||||
return nmDepartment.isBlank();
|
||||
}
|
||||
if (idHeadquarters == null && nmHeadquarters.isBlank()) {
|
||||
|
||||
return true;
|
||||
}
|
||||
if (idDepartment == null && nmDepartment.isBlank()) {
|
||||
|
||||
return true;
|
||||
}
|
||||
if (idDivision == null && nmDivision.isBlank()) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class InsertEmployeeForm {
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
private Integer idDepartment;
|
||||
private Integer idDivision;
|
||||
|
||||
|
||||
/**
|
||||
@@ -113,7 +113,7 @@ public class InsertEmployeeForm {
|
||||
insertEmployeeForm.getPassword(),
|
||||
insertEmployeeForm.getHireDate(),
|
||||
insertEmployeeForm.getAdminAuth(),
|
||||
insertEmployeeForm.getIdDepartment()
|
||||
insertEmployeeForm.getIdDivision()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ public class InsertEmployeeForm {
|
||||
error.add(MANAGEMENT_ERROR);
|
||||
}
|
||||
|
||||
if (idDepartment == null) {
|
||||
if (idDivision == null) {
|
||||
error.add(DEPARTMENT_ID_NULL_BLANK);
|
||||
}
|
||||
if(isNullOrBlank(hireDate)) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.example.rhizome.app.presentation.form;
|
||||
|
||||
|
||||
import com.example.rhizome.app.domain.model.LoginUser;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -37,7 +38,7 @@ public class LoginUserForm {
|
||||
private Integer adminAuth;
|
||||
|
||||
/**
|
||||
* 部署ID
|
||||
* 課ID
|
||||
*/
|
||||
private Integer idDepartment;
|
||||
|
||||
@@ -56,7 +57,7 @@ public class LoginUserForm {
|
||||
loginUser.getMailAddress(),
|
||||
loginUser.getPassword(),
|
||||
loginUser.getAdminAuth(),
|
||||
loginUser.getIdDepartment()
|
||||
loginUser.getIdDivision()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
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.SearchConditionDepartment;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 画面から渡ってきた検索条件をまとめ、再度画面に表示する為のクラス
|
||||
*/
|
||||
@@ -18,11 +19,11 @@ public class SearchConditionDepartmentForm {
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
private Integer idDepartment;
|
||||
private Integer idDivision;
|
||||
/**
|
||||
* 部署名
|
||||
*/
|
||||
private String nmDepartment;
|
||||
private String nmDivision;
|
||||
|
||||
/**
|
||||
* business 層の Department クラスから画面用(presentation 層)の SearchConditionDepartmentForm に
|
||||
@@ -55,8 +56,8 @@ public class SearchConditionDepartmentForm {
|
||||
*/
|
||||
public static SearchConditionDepartment convertTo(SearchConditionDepartmentForm searchConditionDepartmentForm) {
|
||||
return new SearchConditionDepartment(
|
||||
searchConditionDepartmentForm.getIdDepartment(),
|
||||
searchConditionDepartmentForm.nmDepartment
|
||||
searchConditionDepartmentForm.getIdDivision(),
|
||||
searchConditionDepartmentForm.nmDivision
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.example.rhizome.app.presentation.form;
|
||||
|
||||
import com.example.rhizome.app.domain.model.SearchConditionEmployee;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -32,7 +33,7 @@ public class SearchConditionEmployeeForm {
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
private Integer idDepartment;
|
||||
private Integer idDivision;
|
||||
|
||||
/**
|
||||
* business 層の SearchConditionEmployee クラスから画面用(presentation 層)の SearchConditionEmployeeForm に
|
||||
@@ -47,7 +48,7 @@ public class SearchConditionEmployeeForm {
|
||||
searchConditionEmployee.getNmEmployee(),
|
||||
searchConditionEmployee.getKnEmployee(),
|
||||
searchConditionEmployee.getMailAddress(),
|
||||
searchConditionEmployee.getIdDepartment()
|
||||
searchConditionEmployee.getIdDivision()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -64,7 +65,7 @@ public class SearchConditionEmployeeForm {
|
||||
searchConditionEmployeeForm.getNmEmployee(),
|
||||
searchConditionEmployeeForm.getKnEmployee(),
|
||||
searchConditionEmployeeForm.getMailAddress(),
|
||||
searchConditionEmployeeForm.getIdDepartment()
|
||||
searchConditionEmployeeForm.getIdDivision()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +1,42 @@
|
||||
package com.example.rhizome.app.presentation.form;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Department;
|
||||
import com.example.rhizome.app.domain.model.AllDepartmentInfo;
|
||||
import com.example.rhizome.app.domain.model.DepartmentInfo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 画面の表示に使う部署コード管理用のクラス
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
|
||||
public class UpdateDepartmentForm {
|
||||
/**
|
||||
* 部署ID
|
||||
* 本部ID
|
||||
*/
|
||||
private Integer idHeadquarters;
|
||||
/**
|
||||
* 本部名
|
||||
*/
|
||||
private String nmHeadquarters;
|
||||
/**
|
||||
* 部ID
|
||||
*/
|
||||
private Integer idDepartment;
|
||||
/**
|
||||
* 部署名
|
||||
* 部名
|
||||
*/
|
||||
private String nmDepartment;
|
||||
|
||||
/**
|
||||
* 課ID
|
||||
*/
|
||||
private Integer idDivision;
|
||||
/**
|
||||
* 課名
|
||||
*/
|
||||
private String nmDivision;
|
||||
/**
|
||||
* business 層の Department クラスから画面用(presentation 層)の UpdateDepartmentForm に
|
||||
* 変換します。
|
||||
@@ -30,8 +44,14 @@ public class UpdateDepartmentForm {
|
||||
* @param department business 層の Department インスタンス
|
||||
* @return 画面用(presentation 層)の UpdateDepartmentForm インスタンス
|
||||
*/
|
||||
public static UpdateDepartmentForm convertFrom(Department department) {
|
||||
return new UpdateDepartmentForm(department.getIdDepartment(), department.getNmDepartment());
|
||||
public static UpdateDepartmentForm convertFrom(AllDepartmentInfo allDepartmentInfo) {
|
||||
return new UpdateDepartmentForm(
|
||||
allDepartmentInfo.getHeadquarters().getIdHeadquarters(),
|
||||
allDepartmentInfo.getHeadquarters().getNmHeadquarters(),
|
||||
allDepartmentInfo.getDepartment().getIdDepartment(),
|
||||
allDepartmentInfo.getDepartment().getNmDepartment(),
|
||||
allDepartmentInfo.getDivision().getIdDivision(),
|
||||
allDepartmentInfo.getDivision().getNmDivision());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -41,9 +61,9 @@ public class UpdateDepartmentForm {
|
||||
* @param departmentList business 層の Department インスタンスのリスト
|
||||
* @return 画面用(presentation 層)の UpdateDepartmentForm インスタンスのリスト
|
||||
*/
|
||||
public static List<UpdateDepartmentForm> convertFrom(List<Department> departmentList) {
|
||||
return departmentList.stream().map(UpdateDepartmentForm::convertFrom).toList();
|
||||
}
|
||||
// public static List<UpdateDepartmentForm> convertFrom(List<Department> departmentList) {
|
||||
// return departmentList.stream().map(UpdateDepartmentForm::convertFrom).toList();
|
||||
// }
|
||||
|
||||
/**
|
||||
* presentation 層の UpdateDepartmentForm クラスから Business 層の Department クラスに
|
||||
@@ -52,10 +72,24 @@ public class UpdateDepartmentForm {
|
||||
* @param updateDepartmentForm presentation 層のインスタンス
|
||||
* @return Business 層の Department インスタンス
|
||||
*/
|
||||
public static Department convertTo(UpdateDepartmentForm updateDepartmentForm) {
|
||||
return new Department(
|
||||
// public static Department convertTo(UpdateDepartmentForm updateDepartmentForm) {
|
||||
// return new Department(
|
||||
// updateDepartmentForm.getIdDepartment(),
|
||||
// updateDepartmentForm.getNmDepartment(),
|
||||
// (Integer)0,
|
||||
// updateDepartmentForm.getIdHeadquarters()
|
||||
//
|
||||
// );
|
||||
// }
|
||||
public static DepartmentInfo convertTo(UpdateDepartmentForm updateDepartmentForm) {
|
||||
return new DepartmentInfo(
|
||||
updateDepartmentForm.getIdHeadquarters(),
|
||||
updateDepartmentForm.getNmHeadquarters(),
|
||||
updateDepartmentForm.getIdDepartment(),
|
||||
updateDepartmentForm.getNmDepartment()
|
||||
updateDepartmentForm.getNmDepartment(),
|
||||
updateDepartmentForm.getIdDivision(),
|
||||
updateDepartmentForm.getNmDivision()
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@ package com.example.rhizome.app.presentation.form;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.example.rhizome.app.domain.model.AllEmployeeInfo;
|
||||
import com.example.rhizome.app.domain.model.Employee;
|
||||
import com.example.rhizome.app.domain.model.EmployeeInfo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@@ -52,7 +52,7 @@ public class UpdateEmployeeInfoForm {
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
private Integer idDepartment;
|
||||
private Integer idDivision;
|
||||
|
||||
/**
|
||||
* business 層の EmployeeInfo クラスから画面用(presentation 層)の UpdateEmployeeInfoForm に
|
||||
@@ -61,17 +61,17 @@ public class UpdateEmployeeInfoForm {
|
||||
* @param employeeInfo business 層の EmployeeInfo インスタンス
|
||||
* @return 画面用(presentation 層)の UpdateEmployeeInfoForm インスタンス
|
||||
*/
|
||||
public static UpdateEmployeeInfoForm convertFrom(EmployeeInfo employeeInfo) {
|
||||
public static UpdateEmployeeInfoForm convertFrom(AllEmployeeInfo allemployeeInfo) {
|
||||
return new UpdateEmployeeInfoForm(
|
||||
employeeInfo.getEmployee().getIdEmployee(),
|
||||
employeeInfo.getEmployee().getNmEmployee(),
|
||||
employeeInfo.getEmployee().getKnEmployee(),
|
||||
employeeInfo.getEmployee().getMailAddress(),
|
||||
employeeInfo.getEmployee().getPassword(),
|
||||
allemployeeInfo.getEmployee().getIdEmployee(),
|
||||
allemployeeInfo.getEmployee().getNmEmployee(),
|
||||
allemployeeInfo.getEmployee().getKnEmployee(),
|
||||
allemployeeInfo.getEmployee().getMailAddress(),
|
||||
allemployeeInfo.getEmployee().getPassword(),
|
||||
null,
|
||||
employeeInfo.getEmployee().getHireDate(),
|
||||
employeeInfo.getEmployee().getAdminAuth(),
|
||||
employeeInfo.getDepartment().getIdDepartment()
|
||||
allemployeeInfo.getEmployee().getHireDate(),
|
||||
allemployeeInfo.getEmployee().getAdminAuth(),
|
||||
allemployeeInfo.getDivision().getIdDivision()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -82,8 +82,8 @@ public class UpdateEmployeeInfoForm {
|
||||
* @param employeeInfoList business 層の EmployeeInfo インスタンスのリスト
|
||||
* @return 画面用(presentation 層)の UpdateEmployeeInfoForm インスタンスのリスト
|
||||
*/
|
||||
public static List<UpdateEmployeeInfoForm> convertFrom(List<EmployeeInfo> employeeInfoList) {
|
||||
return employeeInfoList.stream().map(UpdateEmployeeInfoForm::convertFrom).toList();
|
||||
public static List<UpdateEmployeeInfoForm> convertFrom(List<AllEmployeeInfo> allemployeeInfoList) {
|
||||
return allemployeeInfoList.stream().map(UpdateEmployeeInfoForm::convertFrom).toList();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,7 +102,7 @@ public class UpdateEmployeeInfoForm {
|
||||
updateEmployeeInfoForm.getPassword(),
|
||||
updateEmployeeInfoForm.getHireDate(),
|
||||
updateEmployeeInfoForm.getAdminAuth(),
|
||||
updateEmployeeInfoForm.getIdDepartment()
|
||||
updateEmployeeInfoForm.getIdDivision()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
</div>
|
||||
<table>
|
||||
<tr>
|
||||
<th class="header">部署ID</th>
|
||||
<th class="header"> 本部ID</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
@@ -39,19 +39,67 @@
|
||||
value="自動で設定されます"/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">部署名</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
name="nmDepartment"
|
||||
readonly="readonly"
|
||||
th:value="*{nmDepartment}"
|
||||
type="text"/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">本部名</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
name="nmHeadquarters"
|
||||
readonly="readonly"
|
||||
th:value="*{nmHeadquarters}"
|
||||
type="text"/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">部ID</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
readonly="readonly"
|
||||
type="text"
|
||||
value="自動で設定されます"/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">部名</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
name="nmDepartment"
|
||||
readonly="readonly"
|
||||
th:value="*{nmDepartment}"
|
||||
type="text"/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">課ID</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
readonly="readonly"
|
||||
type="text"
|
||||
value="自動で設定されます"/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<th class="header">課名</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
name="nmDivision"
|
||||
readonly="readonly"
|
||||
th:value="*{nmDivision}"
|
||||
type="text"/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="btnArea" colspan="2">
|
||||
<input type="submit" value="登録"/>
|
||||
|
||||
@@ -3,64 +3,138 @@
|
||||
|
||||
<head>
|
||||
|
||||
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
|
||||
<!-- 外部のスクリプトファイルを読み込む -->
|
||||
<script th:src="@{/js/common.js}"></script>
|
||||
<!-- CSSの読み込み -->
|
||||
<link rel="stylesheet" th:href="@{/css/all.css}">
|
||||
<link rel=stylesheet th:href="@{/css/style.css}" type="text/css">
|
||||
<title>部署登録</title>
|
||||
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
|
||||
<!-- 外部のスクリプトファイルを読み込む -->
|
||||
<script th:src="@{/js/common.js}"></script>
|
||||
<!-- CSSの読み込み -->
|
||||
<link rel="stylesheet" th:href="@{/css/all.css}">
|
||||
<link rel=stylesheet th:href="@{/css/style.css}" type="text/css">
|
||||
<title>部署登録</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>
|
||||
部署登録
|
||||
<div class="rightSection">
|
||||
<span class="loginInfo">ログイン者名:<span th:text="${session.loginUser.nmEmployee}"></span></span>
|
||||
<button class="logoutButton" onclick="logoutSubmit()">ログアウト</button>
|
||||
</div>
|
||||
</h1>
|
||||
<form action="insertDepartmentConfirm"
|
||||
method="post"
|
||||
th:object="${insertDepartmentForm}">
|
||||
<h1>
|
||||
部署登録
|
||||
<div class="rightSection">
|
||||
<span class="loginInfo">ログイン者名:<span th:text="${session.loginUser.nmEmployee}"></span></span>
|
||||
<button class="logoutButton" onclick="logoutSubmit()">ログアウト</button>
|
||||
</div>
|
||||
</h1>
|
||||
<form action="insertDepartmentConfirm" method="post" th:object="${insertDepartmentForm}">
|
||||
|
||||
<div class="msgBox error" th:if="${messageError} != null">
|
||||
<span class="error" th:text="${messageError.message}"></span>
|
||||
</div>
|
||||
<div class="msgBox error" th:if="${messageError} != null">
|
||||
<span class="error" th:text="${messageError.message}"></span>
|
||||
</div>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th class="header">部署ID</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
readonly="readonly"
|
||||
type="text"
|
||||
value="自動で設定されます"
|
||||
/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">部署名</th>
|
||||
<td>
|
||||
<label>
|
||||
<input maxlength="50"
|
||||
placeholder="部署名"
|
||||
required="required"
|
||||
th:field="*{nmDepartment}"
|
||||
type="text"
|
||||
/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="btnArea" colspan="2">
|
||||
<input type="submit" value="登録確認"/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<a href="showMenu">メニューに戻る</a>
|
||||
<table>
|
||||
<tr>
|
||||
<th class="header">本部ID</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly" readonly="readonly" type="text" value="自動で設定されます" />
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">本部名</th>
|
||||
<td>
|
||||
<label>
|
||||
<input maxlength="50" placeholder="本部名" th:field="*{nmHeadquarters}" type="text" />
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header"></th>
|
||||
<td>
|
||||
<label>
|
||||
<select th:field="*{nmHeadquarters}">
|
||||
<option value="">本部を選択</option>
|
||||
<option
|
||||
th:each="headquarters : ${departmentFormList}"
|
||||
th:selected="${insertDepartmentForm.idHeadquarters != null && headquarters.idHeadquarters == insertDepartmentForm.idHeadquarters}"
|
||||
th:text="${headquarters.nmHeadquarters}" th:value="${headquarters.nmHeadquarters}">
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">部ID</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly" readonly="readonly" type="text" value="自動で設定されます" />
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">部名</th>
|
||||
<td>
|
||||
<label>
|
||||
<input maxlength="50" placeholder="部名" th:field="*{nmDepartment}" type="text" />
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header"></th>
|
||||
<td>
|
||||
<label>
|
||||
<select th:field="*{nmDepartment}">
|
||||
<option value="">部を選択</option>
|
||||
<option
|
||||
th:each="department : ${departmentFormList}"
|
||||
th:selected="${insertDepartmentForm.idDepartment != null && department.idDepartment == insertDepartmentForm.idDepartment}"
|
||||
th:text="${department.nmDepartment}" th:value="${department.nmDepartment}">
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">課ID</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly" readonly="readonly" type="text" value="自動で設定されます" />
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<th class="header">課名</th>
|
||||
<td>
|
||||
<label>
|
||||
<input maxlength="50" placeholder="課名" th:field="*{nmDivision}" type="text" />
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<tr>
|
||||
<th class="header"></th>
|
||||
<td>
|
||||
<label>
|
||||
<select th:field="*{nmDivision}">
|
||||
<option value="">課を選択</option>
|
||||
<option th:each="division : ${departmentFormList}"
|
||||
th:selected="${insertDepartmentForm.idDivision != null && division.idDivision == insertDepartmentForm.idDivision}"
|
||||
th:text="${division.nmDivision}" th:value="${division.nmDivision}">
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="btnArea" colspan="2">
|
||||
<input type="submit" value="登録確認" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<a href="showMenu">メニューに戻る</a>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -122,13 +122,17 @@
|
||||
<th class="header">所属部署</th>
|
||||
<td>
|
||||
<label>
|
||||
<select name="idDepartment" required="required" th:field="*{idDepartment}">
|
||||
<th:block th:each="department : ${departmentFormList}">
|
||||
<select name="idDivision" required="required" th:field="*{idDivision}">
|
||||
<th:block th:each="division : ${departmentFormList}">
|
||||
<th:block
|
||||
th:if="${insertEmployeeForm.idDepartment != null && department.idDepartment == insertEmployeeForm.idDepartment}">
|
||||
<option th:text="${department.nmDepartment}"
|
||||
th:value="${department.idDepartment}">
|
||||
</option>
|
||||
th:if="${insertEmployeeForm.idDivision != null && division.idDivision == insertEmployeeForm.idDivision}">
|
||||
<option
|
||||
th:utext="
|
||||
${division.nmHeadquarters}+' '+
|
||||
${division.nmDepartment}+' '+
|
||||
${division.nmDivision}"
|
||||
th:value="${division.idDivision}">
|
||||
</option>
|
||||
</th:block>
|
||||
</th:block>
|
||||
</select>
|
||||
|
||||
@@ -149,13 +149,17 @@
|
||||
<th class="header">所属部署</th>
|
||||
<td>
|
||||
<label>
|
||||
<select required="required" th:field="*{idDepartment}">
|
||||
<option th:each="department : ${departmentFormList}"
|
||||
th:selected="${insertEmployeeForm.idDepartment != null && department.idDepartment == insertEmployeeForm.idDepartment}"
|
||||
th:text="${department.nmDepartment}"
|
||||
th:value="${department.idDepartment}">
|
||||
</option>
|
||||
</select>
|
||||
<select required="required" th:field="*{idDivision}">
|
||||
<option value="">所属部署を選択</option>
|
||||
<option th:each="division : ${departmentFormList}"
|
||||
th:selected="${insertEmployeeForm.idDivision != null && division.idDivision == insertEmployeeForm.idDivision}"
|
||||
th:utext="
|
||||
${division.nmHeadquarters}+' '+
|
||||
${division.nmDepartment}+' '+
|
||||
${division.nmDivision}"
|
||||
th:value="${division.idDivision}">
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
<th class="header">部署ID</th>
|
||||
<td>
|
||||
<input placeholder="部署ID"
|
||||
th:field="*{idDepartment}"
|
||||
th:field="*{idDivision}"
|
||||
type="number"/>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -40,7 +40,7 @@
|
||||
<th class="header">部署名</th>
|
||||
<td>
|
||||
<input placeholder="部署名"
|
||||
th:field="*{nmDepartment}"
|
||||
th:field="*{nmDivision}"
|
||||
type="text"/>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -70,25 +70,33 @@
|
||||
<table class="half-table-grid table-striped table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 60px;">部署ID</th>
|
||||
<th style="width: 100px;">部署名</th>
|
||||
<th style="width: 60px;">本部ID</th>
|
||||
<th style="width: 100px;">本部名</th>
|
||||
<th style="width: 60px;">部ID</th>
|
||||
<th style="width: 100px;">部名</th>
|
||||
<th style="width: 60px;">課ID</th>
|
||||
<th style="width: 100px;">課名</th>
|
||||
<th style="width: 150px;">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr th:each="departmentForm : ${departmentFormList}">
|
||||
<td th:text="${departmentForm.idDepartment}"></td>
|
||||
<td th:text="${departmentForm.nmDepartment}"></td>
|
||||
<td th:text="${departmentForm.idHeadquarters}"></td>
|
||||
<td th:text="${departmentForm.nmHeadquarters}"></td>
|
||||
<td th:text="${departmentForm.idDepartment}"></td>
|
||||
<td th:text="${departmentForm.nmDepartment}"></td>
|
||||
<td th:text="${departmentForm.idDivision}"></td>
|
||||
<td th:text="${departmentForm.nmDivision}"></td>
|
||||
<td>
|
||||
<!-- 更新フォーム -->
|
||||
<form action="showUpdateDepartment" method="post" style="display: inline;">
|
||||
<input name="idDepartment" th:value="${departmentForm.idDepartment}" type="hidden">
|
||||
<input name="idDivision" th:value="${departmentForm.idDivision}" type="hidden">
|
||||
<input type="submit" value="更新">
|
||||
</form>
|
||||
<!-- 削除フォーム -->
|
||||
<form action="deleteDepartment" method="post" onsubmit="return confirm('本当に削除しますか?');"
|
||||
style="display: inline;">
|
||||
<input name="idDepartment" th:value="${departmentForm.idDepartment}" type="hidden">
|
||||
<input name="idDivision" th:value="${departmentForm.idDivision}" type="hidden">
|
||||
<input type="submit" value="削除">
|
||||
</form>
|
||||
</td>
|
||||
@@ -105,8 +113,8 @@
|
||||
<script type="text/javascript">
|
||||
|
||||
function clearInput() {
|
||||
document.getElementById('idDepartment').value = '';
|
||||
document.getElementById('nmDepartment').value = '';
|
||||
document.getElementById('idDivision').value = '';
|
||||
document.getElementById('nmDivision').value = '';
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -64,12 +64,12 @@
|
||||
<tr>
|
||||
<th class="header">所属部署</th>
|
||||
<td>
|
||||
<select th:field="*{idDepartment}">
|
||||
<select th:field="*{idDivision}">
|
||||
<option value=""></option>
|
||||
<option th:each="department : ${departmentFormList}"
|
||||
th:selected="${searchConditionEmployeeForm.idDepartment != null && department.idDepartment == searchConditionEmployeeForm.idDepartment}"
|
||||
th:text="${department.nmDepartment}"
|
||||
th:value="${department.idDepartment}">
|
||||
<option th:each="division : ${departmentFormList}"
|
||||
th:selected="${searchConditionEmployeeForm.idDivision != null && division.idDivision == searchConditionEmployeeForm.idDivision}"
|
||||
th:text="${division.nmDivision}"
|
||||
th:value="${division.idDivision}">
|
||||
</option>
|
||||
</select>
|
||||
</td>
|
||||
@@ -122,7 +122,10 @@
|
||||
<td th:text="${employeeInfoForm.hireDate}"></td>
|
||||
<td th:text="${employeeInfoForm.tenure}"></td>
|
||||
<td th:text="${employeeInfoForm.adminAuth}"></td>
|
||||
<td th:text="${employeeInfoForm.nmDepartment}"></td>
|
||||
<td th:utext="${employeeInfoForm.nmHeadquarters}+'<br/>・'+
|
||||
${employeeInfoForm.nmDepartment}+'<br/>・'+
|
||||
${employeeInfoForm.nmDivision}"
|
||||
></td>
|
||||
<td>
|
||||
<!-- 更新フォーム -->
|
||||
<form action="showUpdateEmployee" method="post" style="display: inline;">
|
||||
@@ -153,7 +156,7 @@
|
||||
document.getElementById('nmEmployee').value = '';
|
||||
document.getElementById('knEmployee').value = '';
|
||||
document.getElementById('mailAddress').value = '';
|
||||
document.getElementById('idDepartment').selectedIndex = 0;
|
||||
document.getElementById('idDivision').selectedIndex = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -29,31 +29,81 @@
|
||||
<span class="error" th:each="message : ${messageError.message}" th:text="${message}"></span>
|
||||
</div>
|
||||
<table>
|
||||
<tr>
|
||||
<th class="header">部署ID</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
readonly="readonly"
|
||||
th:field="*{idDepartment}"
|
||||
type="text"
|
||||
/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">部署名</th>
|
||||
<td>
|
||||
<label>
|
||||
<input maxlength="10"
|
||||
placeholder="部署名"
|
||||
required="required"
|
||||
th:field="*{nmDepartment}"
|
||||
type="text"
|
||||
/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">本部ID</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
readonly="readonly"
|
||||
th:field="*{idHeadquarters}"
|
||||
type="text"
|
||||
/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">本部名</th>
|
||||
<td>
|
||||
<label>
|
||||
<input maxlength="10"
|
||||
placeholder="本部名"
|
||||
required="required"
|
||||
th:field="*{nmHeadquarters}"
|
||||
type="text"
|
||||
/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">部ID</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
readonly="readonly"
|
||||
th:field="*{idDepartment}"
|
||||
type="text"
|
||||
/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">部名</th>
|
||||
<td>
|
||||
<label>
|
||||
<input maxlength="10"
|
||||
placeholder="部名"
|
||||
required="required"
|
||||
th:field="*{nmDepartment}"
|
||||
type="text"
|
||||
/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">課ID</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
readonly="readonly"
|
||||
th:field="*{idDivision}"
|
||||
type="text"
|
||||
/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">課名</th>
|
||||
<td>
|
||||
<label>
|
||||
<input maxlength="10"
|
||||
placeholder="課名"
|
||||
required="required"
|
||||
th:field="*{nmDivision}"
|
||||
type="text"
|
||||
/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="btnArea" colspan="2">
|
||||
<input type="submit" value="更新"/>
|
||||
|
||||
@@ -137,12 +137,17 @@
|
||||
<th class="header">所属部署</th>
|
||||
<td>
|
||||
<label>
|
||||
<select required="required" th:field="*{idDepartment}">
|
||||
<option th:each="department : ${departmentFormList}"
|
||||
th:selected="${updateEmployeeInfoForm.idDepartment != null && department.idDepartment == updateEmployeeInfoForm.idDepartment}"
|
||||
th:text="${department.nmDepartment}"
|
||||
th:value="${department.idDepartment}">
|
||||
</option>
|
||||
<select required="required" th:field="*{idDivision}">
|
||||
|
||||
<option th:each="division : ${departmentFormList}"
|
||||
th:selected="${updateEmployeeInfoForm.idDivision != null && division.idDivision == updateEmployeeInfoForm.idDivision}"
|
||||
th:utext="
|
||||
${division.nmHeadquarters}+' '+
|
||||
${division.nmDepartment}+' '+
|
||||
${division.nmDivision}"
|
||||
th:value="${division.idDivision}">
|
||||
</option>
|
||||
|
||||
</select>
|
||||
</label>
|
||||
</td>
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
-- DB と User作成 関連
|
||||
-- 必要であればコメント外してください
|
||||
-- CREATE DATABASE rezodb;
|
||||
-- CREATE USER 'rezouser'@'localhost' IDENTIFIED BY 'Rezo_0000';
|
||||
-- GRANT ALL ON rezodb.* TO 'rezouser'@'localhost';
|
||||
|
||||
|
||||
-- employeeテーブルの作成
|
||||
@@ -80,7 +85,7 @@ INSERT INTO department (nm_department,id_headquarters,is_display) VALUES ('シ
|
||||
INSERT INTO department (nm_department,id_headquarters,is_display) VALUES ('教育事業部',104,0);
|
||||
INSERT INTO department (nm_department,id_headquarters,is_display) VALUES ('営業企画部',105,0);
|
||||
|
||||
-- 部テーブルのデータ
|
||||
-- 課テーブルのデータ
|
||||
INSERT INTO division (nm_division,id_department,is_display) VALUES ('役員',200,0);
|
||||
INSERT INTO division (nm_division,id_department,is_display) VALUES ('人事・総務課',201,0);
|
||||
INSERT INTO division (nm_division,id_department,is_display) VALUES ('経理課',202,0);
|
||||
|
||||
Reference in New Issue
Block a user