コメントの修正
社員のものからコピーしたままになっていたので部署に合うように変更
This commit is contained in:
@@ -8,7 +8,7 @@ import com.example.rhizome.app.domain.service.DeleteDepartment;
|
|||||||
import com.example.rhizome.app.infra.repository.DepartmentRepository;
|
import com.example.rhizome.app.infra.repository.DepartmentRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Employee レコード削除関連の機能を持つサービス
|
* Department レコード削除関連の機能を持つサービス
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@Transactional
|
@Transactional
|
||||||
@@ -22,9 +22,9 @@ public class DeleteDepartmentImpl implements DeleteDepartment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* idEmployee を元に employee データを削除
|
* idDepartment を元に department データを削除
|
||||||
*
|
*
|
||||||
* @param idEmployee 削除対象のidEmployee
|
* @param idDepartment 削除対象のidDepartment
|
||||||
*/
|
*/
|
||||||
public void deleteDepartment(Integer idDepartment) {
|
public void deleteDepartment(Integer idDepartment) {
|
||||||
departmentRepository.deleteById(idDepartment);
|
departmentRepository.deleteById(idDepartment);
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ public class SearchDepartmentImpl implements SearchDepartment {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//idDepartmentに合致するレコード取得
|
||||||
public Department searchDepartmentByIdDepartment(Integer idDepartment) {
|
public Department searchDepartmentByIdDepartment(Integer idDepartment) {
|
||||||
return DepartmentEntity
|
return DepartmentEntity
|
||||||
.createDepartment(departmentRepository.findByIdDepartment(idDepartment).orElse(new DepartmentEntity()));
|
.createDepartment(departmentRepository.findByIdDepartment(idDepartment).orElse(new DepartmentEntity()));
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import com.example.rhizome.app.infra.entity.DepartmentEntity;
|
|||||||
import com.example.rhizome.app.infra.repository.DepartmentRepository;
|
import com.example.rhizome.app.infra.repository.DepartmentRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* employee の更新系の機能を集約させるサービスクラスです。
|
* department の更新系の機能を集約させるサービスクラスです。
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@Transactional
|
@Transactional
|
||||||
@@ -24,10 +24,10 @@ public class UpdateDepartmentImpl implements UpdateDepartment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* employee の情報を元に employee table のレコードを更新する
|
* department の情報を元に department table のレコードを更新する
|
||||||
*
|
*
|
||||||
* @param beforeEmployee 更新前のデータ
|
* @param beforeDepartment 更新前のデータ
|
||||||
* @param updateEmployee 更新後のデータ
|
* @param updateDepartment 更新後のデータ
|
||||||
*/
|
*/
|
||||||
public void updateDepartment(Department beforeDepartment, Department updateDepartment) {
|
public void updateDepartment(Department beforeDepartment, Department updateDepartment) {
|
||||||
// TODO 自動生成されたメソッド・スタブ
|
// TODO 自動生成されたメソッド・スタブ
|
||||||
@@ -38,15 +38,12 @@ public class UpdateDepartmentImpl implements UpdateDepartment {
|
|||||||
/**
|
/**
|
||||||
* 更新前のデータと更新対象のデータをマージする
|
* 更新前のデータと更新対象のデータをマージする
|
||||||
*
|
*
|
||||||
* @param beforeEmployee 更新前のデータ
|
* @param beforeDepartment 更新前のデータ
|
||||||
* @param updateEmployee 更新対象のデータ
|
* @param updateDepartment 更新対象のデータ
|
||||||
* @return マージしたデータ
|
* @return マージしたデータ
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private Department mergeDepartment(Department beforeDepartment, Department updateDepartment) {
|
private Department mergeDepartment(Department beforeDepartment, Department updateDepartment) {
|
||||||
// 更新対象のデータのパスワードが空文字の場合は、更新前のパスワードを使用する
|
|
||||||
// 更新対象のデータの管理者権限が null の場合は、更新前の管理者権限を使用する
|
|
||||||
// 更新対象のデータの部署IDが null の場合は、更新前の部署IDを使用する
|
|
||||||
return new Department(
|
return new Department(
|
||||||
updateDepartment.getIdDepartment(),
|
updateDepartment.getIdDepartment(),
|
||||||
updateDepartment.getNmDepartment());
|
updateDepartment.getNmDepartment());
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ public interface DepartmentRepository
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//idで検索
|
||||||
Optional<DepartmentEntity> findByIdDepartment(Integer idDepartment);
|
Optional<DepartmentEntity> findByIdDepartment(Integer idDepartment);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import com.example.rhizome.app.presentation.form.LoginUserForm;
|
|||||||
import com.example.rhizome.app.presentation.form.MessageForm;
|
import com.example.rhizome.app.presentation.form.MessageForm;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 削除処理のコントロータ
|
* 削除処理のコントローラ
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
public class DeleteDepartmentController {
|
public class DeleteDepartmentController {
|
||||||
@@ -55,7 +55,7 @@ public class DeleteDepartmentController {
|
|||||||
/**
|
/**
|
||||||
* 削除処理のコントローラ
|
* 削除処理のコントローラ
|
||||||
*
|
*
|
||||||
* @param idEmployee 削除対象のemployeeId
|
* @param idDepartment 削除対象のdepartmentId
|
||||||
* @param model ビューにデータを渡すためのコンテナ
|
* @param model ビューにデータを渡すためのコンテナ
|
||||||
* @return 遷移先の画面
|
* @return 遷移先の画面
|
||||||
*/
|
*/
|
||||||
@@ -95,7 +95,7 @@ public class DeleteDepartmentController {
|
|||||||
* 削除処理実施
|
* 削除処理実施
|
||||||
*
|
*
|
||||||
* @param model ビューにデータを渡すためのコンテナ
|
* @param model ビューにデータを渡すためのコンテナ
|
||||||
* @param idEmployee 削除対象のemployeeId
|
* @param idDepartment 削除対象のdepartmentId
|
||||||
* @param loginUser ログインユーザー情報
|
* @param loginUser ログインユーザー情報
|
||||||
*/
|
*/
|
||||||
private void deleteExec(Model model, Integer idDepartment, LoginUser loginUser) {
|
private void deleteExec(Model model, Integer idDepartment, LoginUser loginUser) {
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class SelectDepartmentController {
|
|||||||
/**
|
/**
|
||||||
* 社員検索画面表示処理コントローラ
|
* 社員検索画面表示処理コントローラ
|
||||||
*
|
*
|
||||||
* @param searchConditionEmployeeForm 検索画面のフォーム
|
* @param searchConditionDepartmentForm 検索画面のフォーム
|
||||||
* @param model ビューにデータを渡すためのコンテナ
|
* @param model ビューにデータを渡すためのコンテナ
|
||||||
* @return 遷移先の画面
|
* @return 遷移先の画面
|
||||||
*/
|
*/
|
||||||
@@ -69,9 +69,6 @@ public class SelectDepartmentController {
|
|||||||
DepartmentForm.convertFrom(searchDepartment.selectAll()));
|
DepartmentForm.convertFrom(searchDepartment.selectAll()));
|
||||||
|
|
||||||
// 検索条件を元に検索を実施
|
// 検索条件を元に検索を実施
|
||||||
//取得した EmployeeInfo( employee + department )の情報を画面に返す用の型に詰め替えてセット
|
|
||||||
// model.addAttribute(PageReturnAttributeKeyword.EMPLOYEE_INFO_FORM_LIST, EmployeeInfoForm.convertFrom(
|
|
||||||
// searchEmployeeInfo.searchBy(SearchConditionEmployeeForm.convertTo(searchConditionEmployeeForm)));
|
|
||||||
model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, DepartmentForm.convertFrom(
|
model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, DepartmentForm.convertFrom(
|
||||||
searchDepartment
|
searchDepartment
|
||||||
.searchByWithLike(SearchConditionDepartmentForm.convertTo(searchConditionDepartmentForm))));
|
.searchByWithLike(SearchConditionDepartmentForm.convertTo(searchConditionDepartmentForm))));
|
||||||
@@ -93,7 +90,7 @@ public class SelectDepartmentController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 社員検索画面表示処理コントローラ
|
* 部署検索画面表示処理コントローラ
|
||||||
* 検索条件無しの状態を作るため、空の検索条件で検索した結果を画面に返す
|
* 検索条件無しの状態を作るため、空の検索条件で検索した結果を画面に返す
|
||||||
*
|
*
|
||||||
* @param model ビューにデータを渡すためのコンテナ
|
* @param model ビューにデータを渡すためのコンテナ
|
||||||
@@ -110,12 +107,6 @@ public class SelectDepartmentController {
|
|||||||
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||||
DepartmentForm.convertFrom(searchDepartment.selectAll()));
|
DepartmentForm.convertFrom(searchDepartment.selectAll()));
|
||||||
|
|
||||||
// 検索条件を元に検索を実施
|
|
||||||
// model.addAttribute(PageReturnAttributeKeyword.EMPLOYEE_INFO_FORM_LIST,
|
|
||||||
// EmployeeInfoForm.convertFrom(
|
|
||||||
// searchEmployeeInfo.searchBy(
|
|
||||||
// SearchConditionEmployeeForm.convertTo(searchConditionEmployeeForm()))));
|
|
||||||
|
|
||||||
// 検索ページに遷移
|
// 検索ページに遷移
|
||||||
return TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_HTML;
|
return TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_HTML;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import com.example.rhizome.app.presentation.form.DepartmentForm;
|
|||||||
import com.example.rhizome.app.presentation.form.SearchConditionEmployeeForm;
|
import com.example.rhizome.app.presentation.form.SearchConditionEmployeeForm;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新対象の employee が存在するか確認する為のコントローラ
|
* 更新対象の Department が存在するか確認する為のコントローラ
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller
|
||||||
public class UpdateDepartmentController {
|
public class UpdateDepartmentController {
|
||||||
@@ -51,9 +51,9 @@ public class UpdateDepartmentController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新対象の employee が存在するか確認する為のコントローラ
|
* 更新対象の department が存在するか確認する為のコントローラ
|
||||||
*
|
*
|
||||||
* @param idEmployee 更新対象の employee の id
|
* @param idDepartment 更新対象の employee の id
|
||||||
* @param model ビューにデータを渡すためのコンテナ
|
* @param model ビューにデータを渡すためのコンテナ
|
||||||
* @return 遷移先の画面
|
* @return 遷移先の画面
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class UpdateDepartmentResultController {
|
|||||||
/**
|
/**
|
||||||
* 更新結果画面表示処理
|
* 更新結果画面表示処理
|
||||||
*
|
*
|
||||||
* @param updateEmployeeInfoForm 更新画面のフォーム
|
* @param updateDepartmentInfoForm 更新画面のフォーム
|
||||||
* @param model ビューにデータを渡すためのコンテナ
|
* @param model ビューにデータを渡すためのコンテナ
|
||||||
* @return 遷移先の画面
|
* @return 遷移先の画面
|
||||||
*/
|
*/
|
||||||
@@ -85,7 +85,7 @@ public class UpdateDepartmentResultController {
|
|||||||
|
|
||||||
return TransitionTargetPageNameKeyword.UPDATE_DEPARTMENT_INPUT_HTML;
|
return TransitionTargetPageNameKeyword.UPDATE_DEPARTMENT_INPUT_HTML;
|
||||||
}
|
}
|
||||||
// 画面から渡ってきた値が必須を満たしているか
|
// 画面から渡ってきた値が必須を満たしているか(空白チェック)
|
||||||
if (!UpdateDepartmentInfoForm.hasErrorParameter(updateDepartmentInfoForm)) {
|
if (!UpdateDepartmentInfoForm.hasErrorParameter(updateDepartmentInfoForm)) {
|
||||||
System.out.println("部署必須否");
|
System.out.println("部署必須否");
|
||||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(NOTHING));
|
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(NOTHING));
|
||||||
@@ -111,7 +111,7 @@ public class UpdateDepartmentResultController {
|
|||||||
// 更新結果のメッセージを画面にセットし一覧画面に遷移
|
// 更新結果のメッセージを画面にセットし一覧画面に遷移
|
||||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_INFO, new MessageForm(UPDATE_COMPLETE));
|
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_INFO, new MessageForm(UPDATE_COMPLETE));
|
||||||
|
|
||||||
// forward 先で不用意な動作をしないために UpdateEmployeeInfoForm をクリア
|
// forward 先で不用意な動作をしないために updateDepartmentInfoForm をクリア
|
||||||
return "forward:" + TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_INFO_FORM_EMPTY;
|
return "forward:" + TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_INFO_FORM_EMPTY;
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -53,9 +53,9 @@ public class TransitionTargetPageNameKeyword {
|
|||||||
public static final String SELECT_DEPARTMENT_INFO = "/selectDepartmentInfo";
|
public static final String SELECT_DEPARTMENT_INFO = "/selectDepartmentInfo";
|
||||||
public static final String SELECT_DEPARTMENT_INFO_FORM_EMPTY = "/departmentAll";
|
public static final String SELECT_DEPARTMENT_INFO_FORM_EMPTY = "/departmentAll";
|
||||||
public static final String DELETE_DEPARTMENT = "/deleteDepartment";
|
public static final String DELETE_DEPARTMENT = "/deleteDepartment";
|
||||||
public static final String INSERT_DEPARTMENT_INPUT = "i";
|
public static final String INSERT_DEPARTMENT_INPUT = "/";
|
||||||
public static final String INSERT_DEPARTMENT_CONFIRM = "u";
|
public static final String INSERT_DEPARTMENT_CONFIRM = "/";
|
||||||
public static final String INSERT_DEPARTMENT = "e";
|
public static final String INSERT_DEPARTMENT = "/";
|
||||||
public static final String SHOW_UPDATE_DAPERTMENT = "/showUpdateDepartment";
|
public static final String SHOW_UPDATE_DAPERTMENT = "/showUpdateDepartment";
|
||||||
public static final String UPDATE_DEPARTMENT_RESULT = "/updateDepartmentResult";
|
public static final String UPDATE_DEPARTMENT_RESULT = "/updateDepartmentResult";
|
||||||
|
|
||||||
|
|||||||
@@ -24,11 +24,11 @@ public class SearchConditionDepartmentForm {
|
|||||||
private String nmDepartment;
|
private String nmDepartment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* business 層の SearchConditionEmployee クラスから画面用(presentation 層)の SearchConditionEmployeeForm に
|
* business 層の SearchConditionDepartment クラスから画面用(presentation 層)の SearchConditionDepartmentForm に
|
||||||
* 変換します。
|
* 変換します。
|
||||||
*
|
*
|
||||||
* @param searchConditionEmployee business 層の SearchConditionEmployee インスタンス
|
* @param searchConditionDepartment business 層の SearchConditionDepartment インスタンス
|
||||||
* @return 画面用(presentation 層)の SearchConditionEmployeeForm インスタンス
|
* @return 画面用(presentation 層)の SearchConditionDepartmentForm インスタンス
|
||||||
*/
|
*/
|
||||||
public static SearchConditionDepartmentForm convertFrom(SearchConditionDepartment searchConditionDepartment) {
|
public static SearchConditionDepartmentForm convertFrom(SearchConditionDepartment searchConditionDepartment) {
|
||||||
return new SearchConditionDepartmentForm(
|
return new SearchConditionDepartmentForm(
|
||||||
@@ -37,11 +37,11 @@ public class SearchConditionDepartmentForm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 画面用(presentation 層)の SearchConditionEmployeeForm クラスから business 層の SearchConditionEmployee クラスに
|
* 画面用(presentation 層)の SearchConditionDepartmentForm クラスから business 層の SearchConditionDepartment クラスに
|
||||||
* 変換します。
|
* 変換します。
|
||||||
*
|
*
|
||||||
* @param searchConditionEmployeeForm 画面用(presentation 層)の SearchConditionEmployeeForm インスタンス
|
* @param searchConditionDepartmentForm 画面用(presentation 層)の SearchConditionDepartmentForm インスタンス
|
||||||
* @return business 層の SearchConditionEmployee インスタンス
|
* @return business 層の SearchConditionDepartment インスタンス
|
||||||
*/
|
*/
|
||||||
public static SearchConditionDepartment convertTo(SearchConditionDepartmentForm searchConditionDepartmentForm) {
|
public static SearchConditionDepartment convertTo(SearchConditionDepartmentForm searchConditionDepartmentForm) {
|
||||||
return new SearchConditionDepartment(
|
return new SearchConditionDepartment(
|
||||||
|
|||||||
@@ -17,20 +17,20 @@ import lombok.NoArgsConstructor;
|
|||||||
public class UpdateDepartmentInfoForm {
|
public class UpdateDepartmentInfoForm {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DepartmentID
|
* 部署ID
|
||||||
*/
|
*/
|
||||||
private Integer idDepartment;
|
private Integer idDepartment;
|
||||||
/**
|
/**
|
||||||
* 社員Department名
|
* 部署名
|
||||||
*/
|
*/
|
||||||
private String nmDepartment;
|
private String nmDepartment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* business 層の EmployeeInfo クラスから画面用(presentation 層)の UpdateEmployeeInfoForm に
|
* business 層の Department クラスから画面用(presentation 層)の UpdateDepartmentInfoForm に
|
||||||
* 変換します。
|
* 変換します。
|
||||||
*
|
*
|
||||||
* @param employeeInfo business 層の EmployeeInfo インスタンス
|
* @param department business 層の Department インスタンス
|
||||||
* @return 画面用(presentation 層)の UpdateEmployeeInfoForm インスタンス
|
* @return 画面用(presentation 層)の UpdateDepartmentInfoForm インスタンス
|
||||||
*/
|
*/
|
||||||
public static UpdateDepartmentInfoForm convertFrom(Department department) {
|
public static UpdateDepartmentInfoForm convertFrom(Department department) {
|
||||||
return new UpdateDepartmentInfoForm(
|
return new UpdateDepartmentInfoForm(
|
||||||
@@ -39,22 +39,22 @@ public class UpdateDepartmentInfoForm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* business 層の EmployeeInfo クラスから画面用(presentation 層)の UpdateEmployeeInfoForm に
|
* business 層の Department クラスから画面用(presentation 層)の UpdateDepartmentInfoForm に
|
||||||
* 変換します。(リスト版)
|
* 変換します。(リスト版)
|
||||||
*
|
*
|
||||||
* @param employeeInfoList business 層の EmployeeInfo インスタンスのリスト
|
* @param departmentList business 層の Department インスタンスのリスト
|
||||||
* @return 画面用(presentation 層)の UpdateEmployeeInfoForm インスタンスのリスト
|
* @return 画面用(presentation 層)の UpdateDepartmentInfoForm インスタンスのリスト
|
||||||
*/
|
*/
|
||||||
public static List<UpdateDepartmentInfoForm> convertFrom(List<Department> departmentList) {
|
public static List<UpdateDepartmentInfoForm> convertFrom(List<Department> departmentList) {
|
||||||
return departmentList.stream().map(UpdateDepartmentInfoForm::convertFrom).toList();
|
return departmentList.stream().map(UpdateDepartmentInfoForm::convertFrom).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 画面用(presentation 層)の UpdateEmployeeInfoForm クラスから business 層の Employee クラスに
|
* 画面用(presentation 層)の UpdateDepartmentInfoForm クラスから business 層の Department クラスに
|
||||||
* 変換します。
|
* 変換します。
|
||||||
*
|
*
|
||||||
* @param updateEmployeeInfoForm 画面用(presentation 層)の UpdateEmployeeInfoForm インスタンス
|
* @param updateDepartmentInfoForm 画面用(presentation 層)の UpdateDepartmentInfoForm インスタンス
|
||||||
* @return business 層の Employee インスタンス
|
* @return business 層の Department インスタンス
|
||||||
*/
|
*/
|
||||||
public static Department convertTo(UpdateDepartmentInfoForm updateDepartmentInfoForm) {
|
public static Department convertTo(UpdateDepartmentInfoForm updateDepartmentInfoForm) {
|
||||||
return new Department(
|
return new Department(
|
||||||
@@ -65,7 +65,7 @@ public class UpdateDepartmentInfoForm {
|
|||||||
/**
|
/**
|
||||||
* 画面から渡ってきたパラメータのチェック
|
* 画面から渡ってきたパラメータのチェック
|
||||||
*
|
*
|
||||||
* @param updateEmployeeInfoForm 画面から渡ってきたパラメータ
|
* @param updateDepartmentInfoForm 画面から渡ってきたパラメータ
|
||||||
* @return true: エラー無し false:エラーあり(必須を満たしていない)
|
* @return true: エラー無し false:エラーあり(必須を満たしていない)
|
||||||
*/
|
*/
|
||||||
public static boolean hasErrorParameter(UpdateDepartmentInfoForm updateDepartmentInfoForm) {
|
public static boolean hasErrorParameter(UpdateDepartmentInfoForm updateDepartmentInfoForm) {
|
||||||
|
|||||||
Reference in New Issue
Block a user