社員情報登録時のプルダウンの分割化の相談の参照用の一時プッシュ
This commit is contained in:
@@ -24,6 +24,10 @@ public interface SearchDepartment {
|
|||||||
List<Department> searchByDepartment(SearchConditionDepartment searchConditionDepartment);
|
List<Department> searchByDepartment(SearchConditionDepartment searchConditionDepartment);
|
||||||
|
|
||||||
List<Division> searchByDivision(SearchConditionDepartment searchConditionDepartment);
|
List<Division> searchByDivision(SearchConditionDepartment searchConditionDepartment);
|
||||||
|
|
||||||
|
List<Department>searchByIdHeadquarters(Integer idHeadquarters);
|
||||||
|
|
||||||
|
List<Division>searchByIdDepartment(Integer idDepartment);
|
||||||
|
|
||||||
// List<DepartmentInfo> searchByWithLike(SearchConditionDepartment searchConditionDepartment);
|
// List<DepartmentInfo> searchByWithLike(SearchConditionDepartment searchConditionDepartment);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,26 +45,39 @@ public class RegisterDepartmentImpl implements RegisterDepartment {
|
|||||||
public void registerDepartment(DivisionEntity divisionEntity) {
|
public void registerDepartment(DivisionEntity divisionEntity) {
|
||||||
DepartmentEntity departmentEntity = divisionEntity.getDepartment();
|
DepartmentEntity departmentEntity = divisionEntity.getDepartment();
|
||||||
HeadquartersEntity headquartersEntity = divisionEntity.getDepartment().getHeadquarters();
|
HeadquartersEntity headquartersEntity = divisionEntity.getDepartment().getHeadquarters();
|
||||||
|
HeadquartersEntity originHeadquartersEntity =
|
||||||
if(departmentEntity.getIdDepartment()==null) {
|
headquartersRepository.findByNmHeadquarters(
|
||||||
departmentEntity = new DepartmentEntity();
|
divisionEntity.getDepartment().getHeadquarters().getNmHeadquarters());
|
||||||
}
|
if(originHeadquartersEntity!=null){
|
||||||
if(headquartersEntity.getIdHeadquarters()==null) {
|
headquartersEntity=originHeadquartersEntity;
|
||||||
|
}else {
|
||||||
headquartersEntity = new HeadquartersEntity();
|
headquartersEntity = new HeadquartersEntity();
|
||||||
|
headquartersEntity.setNmHeadquarters(
|
||||||
|
divisionEntity.getDepartment()
|
||||||
|
.getHeadquarters()
|
||||||
|
.getNmHeadquarters()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DepartmentEntity originDepartmentEntity =
|
||||||
|
departmentRepository.findByHeadquartersAndNmDepartment(
|
||||||
|
headquartersEntity,
|
||||||
|
divisionEntity.getDepartment().getNmDepartment());
|
||||||
|
if(originDepartmentEntity!=null) {
|
||||||
|
departmentEntity=originDepartmentEntity;
|
||||||
|
}else {
|
||||||
|
departmentEntity = new DepartmentEntity();
|
||||||
|
departmentEntity.setNmDepartment(
|
||||||
|
divisionEntity.getDepartment()
|
||||||
|
.getNmDepartment()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
divisionEntity.setIsDisplay(0);
|
divisionEntity.setIsDisplay(0);
|
||||||
departmentEntity.setIsDisplay(0);
|
departmentEntity.setIsDisplay(0);
|
||||||
headquartersEntity.setIsDisplay(0);
|
headquartersEntity.setIsDisplay(0);
|
||||||
|
|
||||||
departmentEntity.setNmDepartment(
|
|
||||||
divisionEntity.getDepartment()
|
|
||||||
.getNmDepartment()
|
|
||||||
);
|
|
||||||
headquartersEntity.setNmHeadquarters(
|
|
||||||
divisionEntity.getDepartment()
|
|
||||||
.getHeadquarters()
|
|
||||||
.getNmHeadquarters()
|
|
||||||
);
|
|
||||||
departmentEntity.setHeadquarters(headquartersEntity);
|
departmentEntity.setHeadquarters(headquartersEntity);
|
||||||
divisionEntity.setDepartment(departmentEntity);
|
divisionEntity.setDepartment(departmentEntity);
|
||||||
divisionRepository.save(divisionEntity);
|
divisionRepository.save(divisionEntity);
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import com.example.rhizome.app.infra.repository.DepartmentInfoRepository;
|
|||||||
import com.example.rhizome.app.infra.repository.DepartmentRepository;
|
import com.example.rhizome.app.infra.repository.DepartmentRepository;
|
||||||
import com.example.rhizome.app.infra.repository.DivisionRepository;
|
import com.example.rhizome.app.infra.repository.DivisionRepository;
|
||||||
import com.example.rhizome.app.infra.repository.HeadquartersRepository;
|
import com.example.rhizome.app.infra.repository.HeadquartersRepository;
|
||||||
|
import com.example.rhizome.app.infra.repository.RegisterDepartmentRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部署情報検索系の機能を集約させるサービスクラスです。
|
* 部署情報検索系の機能を集約させるサービスクラスです。
|
||||||
@@ -33,6 +34,7 @@ public class SearchDepartmentImpl implements SearchDepartment {
|
|||||||
DepartmentRepository departmentRepository;
|
DepartmentRepository departmentRepository;
|
||||||
HeadquartersRepository headquartersRepository;
|
HeadquartersRepository headquartersRepository;
|
||||||
DepartmentInfoRepository departmentInfoRepository;
|
DepartmentInfoRepository departmentInfoRepository;
|
||||||
|
RegisterDepartmentRepository registerDepartmentRepository;
|
||||||
/**
|
/**
|
||||||
* コンストラクタ
|
* コンストラクタ
|
||||||
*
|
*
|
||||||
@@ -43,11 +45,13 @@ public class SearchDepartmentImpl implements SearchDepartment {
|
|||||||
DepartmentRepository departmentRepository
|
DepartmentRepository departmentRepository
|
||||||
,DivisionRepository divisionRepository
|
,DivisionRepository divisionRepository
|
||||||
,HeadquartersRepository headquartersRepository
|
,HeadquartersRepository headquartersRepository
|
||||||
,DepartmentInfoRepository departmentInfoRepository) {
|
,DepartmentInfoRepository departmentInfoRepository
|
||||||
|
,RegisterDepartmentRepository registerDepartmentRepository) {
|
||||||
this.departmentRepository = departmentRepository;
|
this.departmentRepository = departmentRepository;
|
||||||
this.divisionRepository = divisionRepository;
|
this.divisionRepository = divisionRepository;
|
||||||
this.headquartersRepository = headquartersRepository;
|
this.headquartersRepository = headquartersRepository;
|
||||||
this.departmentInfoRepository = departmentInfoRepository;
|
this.departmentInfoRepository = departmentInfoRepository;
|
||||||
|
this.registerDepartmentRepository = registerDepartmentRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -126,26 +130,20 @@ public class SearchDepartmentImpl implements SearchDepartment {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Department>searchByIdHeadquarters(Integer idHeadquarters){
|
||||||
|
System.out.println("3");
|
||||||
|
registerDepartmentRepository.findAll(Specification
|
||||||
// /**
|
.where(RegisterDepartmentRepository.idHeadquartersEqual(idHeadquarters)));
|
||||||
// * searchConditionDepartment の情報を元に Department のレコードを取得
|
|
||||||
// * 部分一致検索
|
System.out.println("SearchDepartmentImpl=>4");
|
||||||
// *
|
|
||||||
// * @param searchConditionDepartment 検索条件
|
return DepartmentEntity
|
||||||
// * @return 検索結果のレコード
|
.createDepartmentListBy(registerDepartmentRepository.findAll(Specification
|
||||||
// */
|
.where(RegisterDepartmentRepository.idHeadquartersEqual(idHeadquarters))));
|
||||||
// public List<DepartmentInfo> searchByWithLike(SearchConditionDepartment searchConditionDepartment) {
|
}
|
||||||
// // 動的に検索条件を絞り込む
|
public List<Division>searchByIdDepartment(Integer idDepartment){
|
||||||
// // Specification は Criteria API の Predicate をラップしたもの
|
return DivisionEntity
|
||||||
// return DepartmentEntity
|
.createDivisionList(divisionRepository.findAll(Specification
|
||||||
// .createDepartmentList(
|
.where(DivisionRepository.idDepartmentEqual(idDepartment))));
|
||||||
// departmentRepository.findAll(Specification
|
}
|
||||||
// .where(DepartmentRepository.idDepartmentEqual(searchConditionDepartment.getIdDepartment()))
|
|
||||||
// .and(DepartmentRepository.nmDepartmentLike(searchConditionDepartment.getNmDepartment()))
|
|
||||||
// )
|
|
||||||
// );
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,10 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
|
|
||||||
import com.example.rhizome.app.domain.model.DepartmentInfo;
|
import com.example.rhizome.app.domain.model.DepartmentInfo;
|
||||||
import com.example.rhizome.app.domain.service.UpdateDepartment;
|
import com.example.rhizome.app.domain.service.UpdateDepartment;
|
||||||
import com.example.rhizome.app.infra.entity.DepartmentInfoEntity;
|
import com.example.rhizome.app.infra.entity.DepartmentEntity;
|
||||||
import com.example.rhizome.app.infra.repository.DepartmentInfoRepository;
|
import com.example.rhizome.app.infra.entity.DivisionEntity;
|
||||||
|
import com.example.rhizome.app.infra.entity.HeadquartersEntity;
|
||||||
|
import com.example.rhizome.app.infra.repository.DivisionRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* department の更新系の機能を集約させるサービスクラスです。
|
* department の更新系の機能を集約させるサービスクラスです。
|
||||||
@@ -17,12 +19,12 @@ import com.example.rhizome.app.infra.repository.DepartmentInfoRepository;
|
|||||||
public class UpdateDepartmentImpl implements UpdateDepartment {
|
public class UpdateDepartmentImpl implements UpdateDepartment {
|
||||||
|
|
||||||
|
|
||||||
DepartmentInfoRepository departmentInfoRepository;
|
DivisionRepository divisionRepository;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public UpdateDepartmentImpl(DepartmentInfoRepository departmentInfoRepository
|
public UpdateDepartmentImpl(DivisionRepository divisionRepository
|
||||||
) {
|
) {
|
||||||
this.departmentInfoRepository = departmentInfoRepository;
|
this.divisionRepository = divisionRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -31,9 +33,21 @@ public class UpdateDepartmentImpl implements UpdateDepartment {
|
|||||||
* @param department 更新のデータ
|
* @param department 更新のデータ
|
||||||
*/
|
*/
|
||||||
public void updateDepartment(DepartmentInfo departmentInfo) {
|
public void updateDepartment(DepartmentInfo departmentInfo) {
|
||||||
System.out.println(departmentInfo.getIdDivision());
|
DivisionEntity divisionEntity = DivisionEntity.convertFrom(departmentInfo);
|
||||||
departmentInfoRepository.save(DepartmentInfoEntity.convertFrom(departmentInfo));
|
DepartmentEntity departmentEntity = divisionEntity.getDepartment();
|
||||||
|
HeadquartersEntity headquartersEntity = divisionEntity.getDepartment().getHeadquarters();
|
||||||
|
departmentEntity.setNmDepartment(
|
||||||
|
divisionEntity.getDepartment()
|
||||||
|
.getNmDepartment()
|
||||||
|
);
|
||||||
|
headquartersEntity.setNmHeadquarters(
|
||||||
|
divisionEntity.getDepartment()
|
||||||
|
.getHeadquarters()
|
||||||
|
.getNmHeadquarters()
|
||||||
|
);
|
||||||
|
departmentEntity.setHeadquarters(headquartersEntity);
|
||||||
|
divisionEntity.setDepartment(departmentEntity);
|
||||||
|
divisionRepository.save(divisionEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,10 @@ import lombok.NoArgsConstructor;
|
|||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
//@NamedEntityGraph(
|
||||||
|
// name = "department_with_headquarters",
|
||||||
|
// includeAllAttributes = true
|
||||||
|
//)
|
||||||
public class DepartmentEntity {
|
public class DepartmentEntity {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -58,6 +62,7 @@ public class DepartmentEntity {
|
|||||||
*/
|
*/
|
||||||
@Column(name = "is_display", nullable = false)
|
@Column(name = "is_display", nullable = false)
|
||||||
private Integer isDisplay;
|
private Integer isDisplay;
|
||||||
|
|
||||||
@ManyToOne(cascade = CascadeType.ALL)
|
@ManyToOne(cascade = CascadeType.ALL)
|
||||||
@JoinColumn(name = "id_headquarters")
|
@JoinColumn(name = "id_headquarters")
|
||||||
@Fetch(FetchMode.JOIN)
|
@Fetch(FetchMode.JOIN)
|
||||||
@@ -83,6 +88,20 @@ public class DepartmentEntity {
|
|||||||
)).toList();
|
)).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<Department> createDepartmentListBy(List<RegisterDepartmentEntity> departmentEntityList) {
|
||||||
|
|
||||||
|
// Stream API を利用するとこうなります。
|
||||||
|
return departmentEntityList
|
||||||
|
.stream()
|
||||||
|
.map(departmentEntity -> new Department(
|
||||||
|
departmentEntity.getIdDepartment(),
|
||||||
|
departmentEntity.getNmDepartment(),
|
||||||
|
departmentEntity.getIsDisplay(),
|
||||||
|
departmentEntity.getIdHeadquarters() == null ? null : departmentEntity.getIdHeadquarters()
|
||||||
|
|
||||||
|
)).toList();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Department(BusinessLogic層依存型) から DepartmentEntity(DataAccess層依存)に変換します。
|
* Department(BusinessLogic層依存型) から DepartmentEntity(DataAccess層依存)に変換します。
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
|||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import com.example.rhizome.app.infra.entity.DepartmentEntity;
|
import com.example.rhizome.app.infra.entity.DepartmentEntity;
|
||||||
|
import com.example.rhizome.app.infra.entity.HeadquartersEntity;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -48,10 +49,14 @@ public interface DepartmentRepository extends JpaRepository<DepartmentEntity, In
|
|||||||
(Specification<DepartmentEntity>)
|
(Specification<DepartmentEntity>)
|
||||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.like(root.get("nmDepartment"), "%" + nmDepartment + "%");
|
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.like(root.get("nmDepartment"), "%" + nmDepartment + "%");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DepartmentEntity findByHeadquartersAndNmDepartment(HeadquartersEntity headquartersEntity,String nmDepartment);
|
||||||
|
|
||||||
|
// @Query("SELECT DISTINCT new com.example.rhizome.app.infra.entity.DepartmentEntity(de,h)FROM DepartmentEntity de "
|
||||||
|
// + "INNER JOIN de.headquarters h "
|
||||||
|
// + "WHERE h.idHeadquarters =:idHeadquarters")
|
||||||
|
// List<DepartmentEntity> searchDepartmentByIdHeadquarters(
|
||||||
|
// @Param("idHeadquarters") Integer IdHeadquarters);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import com.example.rhizome.app.domain.model.DepartmentInfo;
|
|||||||
import com.example.rhizome.app.domain.model.SearchConditionDepartment;
|
import com.example.rhizome.app.domain.model.SearchConditionDepartment;
|
||||||
import com.example.rhizome.app.domain.service.RegisterDepartment;
|
import com.example.rhizome.app.domain.service.RegisterDepartment;
|
||||||
import com.example.rhizome.app.domain.service.SearchDepartment;
|
import com.example.rhizome.app.domain.service.SearchDepartment;
|
||||||
|
import com.example.rhizome.app.domain.service.impl.SearchDepartmentImpl;
|
||||||
import com.example.rhizome.app.infra.entity.DivisionEntity;
|
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.PageReturnAttributeKeyword;
|
||||||
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
||||||
@@ -33,7 +34,9 @@ import com.example.rhizome.app.presentation.form.MessageForm;
|
|||||||
@Controller
|
@Controller
|
||||||
public class InsertDepartmentController {
|
public class InsertDepartmentController {
|
||||||
|
|
||||||
// ログ出力用インスタンス
|
private final SearchDepartmentImpl searchDepartmentImpl;
|
||||||
|
|
||||||
|
// ログ出力用インスタンス
|
||||||
private final static Logger LOGGER = Logger.getLogger(InsertDepartmentController.class.getName());
|
private final static Logger LOGGER = Logger.getLogger(InsertDepartmentController.class.getName());
|
||||||
|
|
||||||
// エラーメッセージ用の定数フィールド
|
// エラーメッセージ用の定数フィールド
|
||||||
@@ -44,10 +47,11 @@ public class InsertDepartmentController {
|
|||||||
SearchDepartment searchDepartment;
|
SearchDepartment searchDepartment;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public InsertDepartmentController(HttpSession httpSession, RegisterDepartment registerDepartment, SearchDepartment searchDepartment) {
|
public InsertDepartmentController(HttpSession httpSession, RegisterDepartment registerDepartment, SearchDepartment searchDepartment, SearchDepartmentImpl searchDepartmentImpl) {
|
||||||
this.httpSession = httpSession;
|
this.httpSession = httpSession;
|
||||||
this.registerDepartment = registerDepartment;
|
this.registerDepartment = registerDepartment;
|
||||||
this.searchDepartment = searchDepartment;
|
this.searchDepartment = searchDepartment;
|
||||||
|
this.searchDepartmentImpl = searchDepartmentImpl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ModelAttribute
|
@ModelAttribute
|
||||||
@@ -89,19 +93,19 @@ public class InsertDepartmentController {
|
|||||||
// 登録画面に遷移
|
// 登録画面に遷移
|
||||||
return INSERT_DEPARTMENT_INPUT_HTML;
|
return INSERT_DEPARTMENT_INPUT_HTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 部署名で重複が無いかチェック
|
// 部署名で重複が無いかチェック
|
||||||
if (!searchDepartment.searchByHeadquarters(
|
if (searchDepartment.searchAllDepartmentTable(
|
||||||
new SearchConditionDepartment(
|
new SearchConditionDepartment(
|
||||||
null,
|
insertDepartmentForm.getIdHeadquarters(),
|
||||||
insertDepartmentForm.getNmHeadquarters())).isEmpty()
|
insertDepartmentForm.getNmHeadquarters()),
|
||||||
&&!searchDepartment.searchByDepartment(
|
new SearchConditionDepartment(
|
||||||
new SearchConditionDepartment(
|
insertDepartmentForm.getIdDepartment(),
|
||||||
null,
|
insertDepartmentForm.getNmDepartment()),
|
||||||
insertDepartmentForm.getNmDepartment())).isEmpty()
|
new SearchConditionDepartment(
|
||||||
&&!searchDepartment.searchByDivision(
|
insertDepartmentForm.getIdDivision(),
|
||||||
new SearchConditionDepartment(
|
insertDepartmentForm.getNmDivision()))) {
|
||||||
null,
|
|
||||||
insertDepartmentForm.getNmDivision())).isEmpty()) {
|
|
||||||
|
|
||||||
|
|
||||||
// 存在する場合はエラーメッセージを設定して更新入力画面に遷移
|
// 存在する場合はエラーメッセージを設定して更新入力画面に遷移
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.example.rhizome.app.presentation.controller;
|
|||||||
|
|
||||||
import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.*;
|
import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -10,9 +11,12 @@ import javax.servlet.http.HttpSession;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
import com.example.rhizome.aop.aspect.PermissionCheck;
|
import com.example.rhizome.aop.aspect.PermissionCheck;
|
||||||
import com.example.rhizome.aop.aspect.SessionCheck;
|
import com.example.rhizome.aop.aspect.SessionCheck;
|
||||||
@@ -20,7 +24,9 @@ import com.example.rhizome.app.domain.service.RegisterEmployee;
|
|||||||
import com.example.rhizome.app.domain.service.SearchDepartment;
|
import com.example.rhizome.app.domain.service.SearchDepartment;
|
||||||
import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
|
import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
|
||||||
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
||||||
import com.example.rhizome.app.presentation.form.DepartmentForm;
|
import com.example.rhizome.app.presentation.form.DepartmentInfoForm;
|
||||||
|
import com.example.rhizome.app.presentation.form.DivisionInfoForm;
|
||||||
|
import com.example.rhizome.app.presentation.form.HeadquartersInfoForm;
|
||||||
import com.example.rhizome.app.presentation.form.InsertEmployeeForm;
|
import com.example.rhizome.app.presentation.form.InsertEmployeeForm;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -67,7 +73,7 @@ public class InsertEmployeeInputController {
|
|||||||
try {
|
try {
|
||||||
// 部署コードリストを作成し、画面に返す値としてセット
|
// 部署コードリストを作成し、画面に返す値としてセット
|
||||||
model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST
|
model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST
|
||||||
, DepartmentForm.convertFrom(
|
,HeadquartersInfoForm.convertFrom(
|
||||||
searchDepartment.searchAllDepartmentTable()));
|
searchDepartment.searchAllDepartmentTable()));
|
||||||
|
|
||||||
// パラメータをセット
|
// パラメータをセット
|
||||||
@@ -88,6 +94,45 @@ public class InsertEmployeeInputController {
|
|||||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("insertEmployeeInput/searchDepartment" )
|
||||||
|
@ResponseBody
|
||||||
|
public List<DepartmentInfoForm>departmentsByHeadquarters(
|
||||||
|
@RequestParam("id_headquarters")Integer idHeadquarters){
|
||||||
|
System.out.println("koko");
|
||||||
|
|
||||||
|
List<DepartmentInfoForm> departmentByHeadquarters=
|
||||||
|
DepartmentInfoForm.convertFrom(
|
||||||
|
searchDepartment.searchByIdHeadquarters(idHeadquarters));
|
||||||
|
System.out.println("2");
|
||||||
|
return departmentByHeadquarters
|
||||||
|
.stream()
|
||||||
|
.map(DepartmentInfoForm-> new DepartmentInfoForm(
|
||||||
|
DepartmentInfoForm.getIdDepartment(),
|
||||||
|
DepartmentInfoForm.getNmDepartment()))
|
||||||
|
.distinct()
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
@GetMapping("/insertEmployeeInput/searchDepartment/searchDivision")
|
||||||
|
@ResponseBody
|
||||||
|
public List<DivisionInfoForm>divisionBydepartment(
|
||||||
|
@RequestParam("idDepartment")Integer idDepartment){
|
||||||
|
List<DivisionInfoForm> divisionBydepartment=
|
||||||
|
DivisionInfoForm.convertFrom(
|
||||||
|
searchDepartment.searchByIdDepartment(idDepartment));
|
||||||
|
|
||||||
|
return divisionBydepartment
|
||||||
|
.stream()
|
||||||
|
.map(DivisionInfoForm-> new DivisionInfoForm(
|
||||||
|
DivisionInfoForm.getIdDivision(),
|
||||||
|
DivisionInfoForm.getNmDivision()))
|
||||||
|
.distinct()
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -75,18 +75,16 @@ public class UpdateDepartmentResultController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 部署名で重複が無いかチェック
|
// 部署名で重複が無いかチェック
|
||||||
if (!searchDepartment.searchByHeadquarters(
|
if (searchDepartment.searchAllDepartmentTable(
|
||||||
new SearchConditionDepartment(
|
new SearchConditionDepartment(
|
||||||
null,
|
updateDepartmentForm.getIdHeadquarters(),
|
||||||
updateDepartmentForm.getNmHeadquarters())).isEmpty()||
|
updateDepartmentForm.getNmHeadquarters()),
|
||||||
!searchDepartment.searchByDepartment(
|
new SearchConditionDepartment(
|
||||||
new SearchConditionDepartment(
|
updateDepartmentForm.getIdDepartment(),
|
||||||
null,
|
updateDepartmentForm.getNmDepartment()),
|
||||||
updateDepartmentForm.getNmDepartment())).isEmpty()||
|
new SearchConditionDepartment(
|
||||||
!searchDepartment.searchByDivision(
|
updateDepartmentForm.getIdDivision(),
|
||||||
new SearchConditionDepartment(
|
updateDepartmentForm.getNmDivision()))) {
|
||||||
null,
|
|
||||||
updateDepartmentForm.getNmDivision())).isEmpty()) {
|
|
||||||
// 存在する場合はエラーメッセージを設定して更新入力画面に遷移
|
// 存在する場合はエラーメッセージを設定して更新入力画面に遷移
|
||||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DUPLICATION));
|
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DUPLICATION));
|
||||||
model.addAttribute(PageReturnAttributeKeyword.UPDATE_DEPARTMENT_FORM, updateDepartmentForm);
|
model.addAttribute(PageReturnAttributeKeyword.UPDATE_DEPARTMENT_FORM, updateDepartmentForm);
|
||||||
|
|||||||
@@ -52,7 +52,17 @@ public class InsertEmployeeForm {
|
|||||||
private Integer adminAuth;
|
private Integer adminAuth;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部署ID
|
* 本部ID
|
||||||
|
*/
|
||||||
|
private Integer idHeadquarters;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部ID
|
||||||
|
*/
|
||||||
|
private Integer idDepartment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 課ID
|
||||||
*/
|
*/
|
||||||
private Integer idDivision;
|
private Integer idDivision;
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
<button class="logoutButton" onclick="logoutSubmit()">ログアウト</button>
|
<button class="logoutButton" onclick="logoutSubmit()">ログアウト</button>
|
||||||
</div>
|
</div>
|
||||||
</h1>
|
</h1>
|
||||||
<form action="insertDepartmentConfirm" method="post" th:object="${insertDepartmentForm}">
|
<form action="insertDepartmentConfirm" method="post" th:object="${insertDepartmentForm}" id="insertDepartmentForm">
|
||||||
|
|
||||||
<div class="msgBox error" th:if="${messageError} != null">
|
<div class="msgBox error" th:if="${messageError} != null">
|
||||||
<span class="error" th:text="${messageError.message}"></span>
|
<span class="error" th:text="${messageError.message}"></span>
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
<th class="header">本部名</th>
|
<th class="header">本部名</th>
|
||||||
<td>
|
<td>
|
||||||
<label>
|
<label>
|
||||||
<input maxlength="50" placeholder="本部名" th:field="*{nmHeadquarters}" type="text" />
|
<input maxlength="50" placeholder="本部名" th:field="*{nmHeadquarters}" type="text"id= "nmHeadquarters1" />
|
||||||
</label>
|
</label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -47,12 +47,13 @@
|
|||||||
<th class="header"></th>
|
<th class="header"></th>
|
||||||
<td>
|
<td>
|
||||||
<label>
|
<label>
|
||||||
<select th:field="*{nmHeadquarters}">
|
<select th:field="*{nmHeadquarters}"id= "nmHeadquarters2">
|
||||||
<option value="">本部を選択</option>
|
<option value="">本部を選択</option>
|
||||||
<option
|
<option
|
||||||
th:each="headquarters : ${departmentFormList}"
|
th:each="headquarters : ${departmentFormList}"
|
||||||
th:selected="${insertDepartmentForm.idHeadquarters != null && headquarters.idHeadquarters == insertDepartmentForm.idHeadquarters}"
|
th:selected="${insertDepartmentForm.idHeadquarters != null && headquarters.idHeadquarters == insertDepartmentForm.idHeadquarters}"
|
||||||
th:text="${headquarters.nmHeadquarters}" th:value="${headquarters.nmHeadquarters}">
|
th:text="${headquarters.nmHeadquarters}" th:value="${headquarters.nmHeadquarters}"
|
||||||
|
>
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
@@ -70,7 +71,7 @@
|
|||||||
<th class="header">部名</th>
|
<th class="header">部名</th>
|
||||||
<td>
|
<td>
|
||||||
<label>
|
<label>
|
||||||
<input maxlength="50" placeholder="部名" th:field="*{nmDepartment}" type="text" />
|
<input maxlength="50" placeholder="部名" th:field="*{nmDepartment}" type="text" id="nmDepartment1"/>
|
||||||
</label>
|
</label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -78,7 +79,7 @@
|
|||||||
<th class="header"></th>
|
<th class="header"></th>
|
||||||
<td>
|
<td>
|
||||||
<label>
|
<label>
|
||||||
<select th:field="*{nmDepartment}">
|
<select th:field="*{nmDepartment}"id="nmDepartment2">
|
||||||
<option value="">部を選択</option>
|
<option value="">部を選択</option>
|
||||||
<option
|
<option
|
||||||
th:each="department : ${departmentFormList}"
|
th:each="department : ${departmentFormList}"
|
||||||
@@ -103,7 +104,7 @@
|
|||||||
<th class="header">課名</th>
|
<th class="header">課名</th>
|
||||||
<td>
|
<td>
|
||||||
<label>
|
<label>
|
||||||
<input maxlength="50" placeholder="課名" th:field="*{nmDivision}" type="text" />
|
<input maxlength="50" placeholder="課名" th:field="*{nmDivision}" type="text" id="nmDivision1"/>
|
||||||
</label>
|
</label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -114,7 +115,7 @@
|
|||||||
<th class="header"></th>
|
<th class="header"></th>
|
||||||
<td>
|
<td>
|
||||||
<label>
|
<label>
|
||||||
<select th:field="*{nmDivision}">
|
<select th:field="*{nmDivision}"id="nmDivision2">
|
||||||
<option value="">課を選択</option>
|
<option value="">課を選択</option>
|
||||||
<option th:each="division : ${departmentFormList}"
|
<option th:each="division : ${departmentFormList}"
|
||||||
th:selected="${insertDepartmentForm.idDivision != null && division.idDivision == insertDepartmentForm.idDivision}"
|
th:selected="${insertDepartmentForm.idDivision != null && division.idDivision == insertDepartmentForm.idDivision}"
|
||||||
@@ -136,5 +137,26 @@
|
|||||||
</form>
|
</form>
|
||||||
<a href="showMenu">メニューに戻る</a>
|
<a href="showMenu">メニューに戻る</a>
|
||||||
</body>
|
</body>
|
||||||
|
<script type="text/javascript">
|
||||||
|
document.getElementById('insertDepartmentForm').addEventListener('submit',function(e){
|
||||||
|
if(document.getElementById('nmHeadquarters1').value!==""){
|
||||||
|
document.getElementById('nmHeadquarters2').removeAttribute('name');
|
||||||
|
}else if(document.getElementById('nmHeadquarters2').value!==""){
|
||||||
|
document.getElementById('nmHeadquarters1').removeAttribute('name');
|
||||||
|
}
|
||||||
|
if(document.getElementById('nmDepartment1').value!==""){
|
||||||
|
document.getElementById('nmDepartment2').removeAttribute('name');
|
||||||
|
}else if(document.getElementById('nmDepartment2').value!==""){
|
||||||
|
document.getElementById('nmDepartment1').removeAttribute('name');
|
||||||
|
}
|
||||||
|
if(document.getElementById('nmDivision1').value!==""){
|
||||||
|
document.getElementById('nmDivision2').removeAttribute('name');
|
||||||
|
}else if(document.getElementById('nmDivision2').value!==""){
|
||||||
|
document.getElementById('nmDivision1').removeAttribute('name');
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
@@ -119,24 +119,52 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="header">所属部署</th>
|
<th class="header" style="vertical-align: top;">所属部署</th>
|
||||||
<td>
|
<td>
|
||||||
<label>
|
<label>
|
||||||
<select name="idDivision" required="required" th:field="*{idDivision}">
|
<select name="idHeadquarters" required="required" th:field="*{idHeadquarters}">
|
||||||
<th:block th:each="division : ${departmentFormList}">
|
<th:block th:each="headquarters : ${departmentFormList}">
|
||||||
<th:block
|
<th:block
|
||||||
th:if="${insertEmployeeForm.idDivision != null && division.idDivision == insertEmployeeForm.idDivision}">
|
th:if="${insertEmployeeForm.idHeadquarters != null && headquarters.idHeadquarters == insertEmployeeForm.idHeadquarters}">>
|
||||||
<option
|
<option
|
||||||
th:utext="
|
th:utext="
|
||||||
${division.nmHeadquarters}+' '+
|
${headquarters.nmHeadquarters}"
|
||||||
${division.nmDepartment}+' '+
|
th:value="${headquarters.idHeadquarters}">
|
||||||
${division.nmDivision}"
|
</option>
|
||||||
th:value="${division.idDivision}">
|
|
||||||
</option>
|
|
||||||
</th:block>
|
</th:block>
|
||||||
</th:block>
|
</th:block>
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
|
<br>
|
||||||
|
<label>
|
||||||
|
<select name="idDepartment" required="required" th:field="*{idDepartment}">
|
||||||
|
<th:block th:each="department : ${departmentFormList}">
|
||||||
|
<th:block
|
||||||
|
th:if="${insertEmployeeForm.idDepartment != null && department.idDepartment == insertEmployeeForm.idDepartment}">>
|
||||||
|
<option
|
||||||
|
th:utext="
|
||||||
|
${department.nmDepartment}"
|
||||||
|
th:value="${department.idDepartment}">
|
||||||
|
</option>
|
||||||
|
</th:block>
|
||||||
|
</th:block>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<br>
|
||||||
|
<label>
|
||||||
|
<select name="idDivision" required="required" th:field="*{idDivision}">
|
||||||
|
<th:block th:each="division : ${departmentFormList}">
|
||||||
|
<th:block
|
||||||
|
th:if="${insertEmployeeForm.idDivision != null && division.idDivision == insertEmployeeForm.idDivision}">
|
||||||
|
<option
|
||||||
|
th:utext="
|
||||||
|
${division.nmDivision}"
|
||||||
|
th:value="${division.idDivision}">
|
||||||
|
</option>
|
||||||
|
</th:block>
|
||||||
|
</th:block>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
@@ -145,24 +145,46 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th class="header">所属部署</th>
|
|
||||||
<td>
|
<th class="header" >所属本部</th>
|
||||||
<label>
|
<td>
|
||||||
<select required="required" th:field="*{idDivision}">
|
|
||||||
<option value="">所属部署を選択</option>
|
<label>
|
||||||
<option th:each="division : ${departmentFormList}"
|
<select id="headquartersSelect" required="required" th:field="*{idHeadquarters}">
|
||||||
th:selected="${insertEmployeeForm.idDivision != null && division.idDivision == insertEmployeeForm.idDivision}"
|
|
||||||
th:utext="
|
<option th:each="headquarters : ${departmentFormList}"
|
||||||
${division.nmHeadquarters}+' '+
|
th:utext="
|
||||||
${division.nmDepartment}+' '+
|
${headquarters.nmHeadquarters}"
|
||||||
${division.nmDivision}"
|
th:value="${headquarters.idHeadquarters}">
|
||||||
th:value="${division.idDivision}">
|
</option>
|
||||||
</option>
|
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th class="header" >所属部</th>
|
||||||
|
<td>
|
||||||
|
<label>
|
||||||
|
<select id="departmentSelect" required="required" th:field="*{idDepartment}">
|
||||||
|
<option value="">先に本部を選択してください</option>
|
||||||
|
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th class="header" >所属課</th>
|
||||||
|
<td>
|
||||||
|
<label>
|
||||||
|
<select id="divisionSelect" required="required" th:field="*{idDivision}">
|
||||||
|
<option value="">先に部を選択してください</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="btnArea" colspan="2">
|
<td class="btnArea" colspan="2">
|
||||||
<input type="submit" value="登録確認"/>
|
<input type="submit" value="登録確認"/>
|
||||||
@@ -172,4 +194,46 @@
|
|||||||
</form>
|
</form>
|
||||||
<a href="showMenu">メニューに戻る</a>
|
<a href="showMenu">メニューに戻る</a>
|
||||||
</body>
|
</body>
|
||||||
|
<script>
|
||||||
|
const headquartersSelect = document.getElementById('headquartersSelect');
|
||||||
|
const departmentSelect = document.getElementById('departmentSelect');
|
||||||
|
const divisionSelect = document.getElementById('divisionSelect');
|
||||||
|
|
||||||
|
headquartersSelect.addEventListener('change', function() {
|
||||||
|
const id_headquarters = this.value;
|
||||||
|
|
||||||
|
departmentSelect.disabled = true;
|
||||||
|
divisionSelect.disabled = true;
|
||||||
|
departmentSelect.innerHTML = '<option value="">-- 部を選択 --</option>';
|
||||||
|
divisionSelect.innerHTML = '<option value="">-- 先に部を選択してください --</option>';
|
||||||
|
console.log("koko");
|
||||||
|
if (!id_headquarters) return;
|
||||||
|
fetch(`insertEmployeeInput/searchDepartment?id_headquarters=${id_headquarters}`,{
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
'Accept': 'application/json'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
.then(res => {
|
||||||
|
return res.json();
|
||||||
|
})
|
||||||
|
.then(list => {
|
||||||
|
console.log("koko");
|
||||||
|
departmentSelect.disabled = false;
|
||||||
|
list.forEach(form => {
|
||||||
|
const opt = document.createElement('option');
|
||||||
|
opt.value = form.idDepartment;
|
||||||
|
opt.textContent = form.nmDepartment;
|
||||||
|
departmentSelect.appendChild(opt);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
</html>
|
</html>
|
||||||
@@ -134,24 +134,46 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="header">所属部署</th>
|
|
||||||
<td>
|
<th class="header" style="vertical-align: top;">所属部署</th>
|
||||||
|
<td>
|
||||||
|
|
||||||
<label>
|
<label>
|
||||||
<select required="required" th:field="*{idDivision}">
|
<select required="required" >
|
||||||
|
|
||||||
<option th:each="division : ${departmentFormList}"
|
<option th:each="headquarters : ${departmentFormList}"
|
||||||
th:selected="${updateEmployeeInfoForm.idDivision != null && division.idDivision == updateEmployeeInfoForm.idDivision}"
|
|
||||||
th:utext="
|
th:utext="
|
||||||
${division.nmHeadquarters}+' '+
|
${headquarters.nmHeadquarters}"
|
||||||
${division.nmDepartment}+' '+
|
th:value="${headquarters.idHeadquarters}">
|
||||||
${division.nmDivision}"
|
|
||||||
th:value="${division.idDivision}">
|
|
||||||
</option>
|
</option>
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
</td>
|
<br>
|
||||||
</tr>
|
<label>
|
||||||
|
<select required="required" >
|
||||||
|
<option th:each="department : ${departmentFormList}"
|
||||||
|
|
||||||
|
th:utext="
|
||||||
|
${department.nmDepartment}"
|
||||||
|
th:value="${department.idDepartment}">
|
||||||
|
</option>
|
||||||
|
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<br>
|
||||||
|
<label>
|
||||||
|
<select required="required" th:field="*{idDivision}">
|
||||||
|
<option th:each="division : ${departmentFormList}"
|
||||||
|
th:utext="
|
||||||
|
${division.nmDivision}"
|
||||||
|
th:value="${division.idDivision}">
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="btnArea" colspan="2">
|
<td class="btnArea" colspan="2">
|
||||||
<input type="submit" value="更新"/>
|
<input type="submit" value="更新"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user