diff --git a/.classpath b/.classpath
new file mode 100644
index 0000000..3122b27
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..0f63015
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+/target/
+/bin/
diff --git a/.project b/.project
new file mode 100644
index 0000000..ce8bde7
--- /dev/null
+++ b/.project
@@ -0,0 +1,37 @@
+
+
+ EM-Spring
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.wst.common.project.facet.core.builder
+
+
+
+
+ org.eclipse.m2e.core.maven2Builder
+
+
+
+
+ org.eclipse.wst.validation.validationbuilder
+
+
+
+
+
+ org.eclipse.jem.workbench.JavaEMFNature
+ org.eclipse.wst.common.modulecore.ModuleCoreNature
+ org.eclipse.jdt.core.javanature
+ org.eclipse.m2e.core.maven2Nature
+ org.eclipse.wst.common.project.facet.core.nature
+ org.eclipse.wst.jsdt.core.jsNature
+
+
diff --git a/.settings/.jsdtscope b/.settings/.jsdtscope
new file mode 100644
index 0000000..1ef54ab
--- /dev/null
+++ b/.settings/.jsdtscope
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000..29abf99
--- /dev/null
+++ b/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,6 @@
+eclipse.preferences.version=1
+encoding//src/main/java=UTF-8
+encoding//src/main/resources=UTF-8
+encoding//src/test/java=UTF-8
+encoding//src/test/resources=UTF-8
+encoding/=UTF-8
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..f9e3458
--- /dev/null
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,11 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.methodParameters=generate
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
+org.eclipse.jdt.core.compiler.compliance=17
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
+org.eclipse.jdt.core.compiler.release=enabled
+org.eclipse.jdt.core.compiler.source=17
diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component
new file mode 100644
index 0000000..36e6ccc
--- /dev/null
+++ b/.settings/org.eclipse.wst.common.component
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml
new file mode 100644
index 0000000..36d3a1f
--- /dev/null
+++ b/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/.settings/org.eclipse.wst.jsdt.ui.superType.container b/.settings/org.eclipse.wst.jsdt.ui.superType.container
new file mode 100644
index 0000000..3bd5d0a
--- /dev/null
+++ b/.settings/org.eclipse.wst.jsdt.ui.superType.container
@@ -0,0 +1 @@
+org.eclipse.wst.jsdt.launching.baseBrowserLibrary
\ No newline at end of file
diff --git a/.settings/org.eclipse.wst.jsdt.ui.superType.name b/.settings/org.eclipse.wst.jsdt.ui.superType.name
new file mode 100644
index 0000000..05bd71b
--- /dev/null
+++ b/.settings/org.eclipse.wst.jsdt.ui.superType.name
@@ -0,0 +1 @@
+Window
\ No newline at end of file
diff --git a/.settings/org.eclipse.wst.validation.prefs b/.settings/org.eclipse.wst.validation.prefs
new file mode 100644
index 0000000..04cad8c
--- /dev/null
+++ b/.settings/org.eclipse.wst.validation.prefs
@@ -0,0 +1,2 @@
+disabled=06target
+eclipse.preferences.version=1
diff --git a/pom.xml b/pom.xml
index 24be8c6..2d0b73e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -15,8 +15,9 @@
war
EM-Spring
Demo project for Spring Boot
-
+
17
+ 1.18.34
diff --git a/src/main/java/com/example/rhizome/app/domain/model/SearchConditionDepartment.java b/src/main/java/com/example/rhizome/app/domain/model/SearchConditionDepartment.java
index 1e365eb..ac3333f 100644
--- a/src/main/java/com/example/rhizome/app/domain/model/SearchConditionDepartment.java
+++ b/src/main/java/com/example/rhizome/app/domain/model/SearchConditionDepartment.java
@@ -5,6 +5,7 @@ import lombok.Getter;
/**
* 部署情報の検索要件を表現するモデルクラスです。
+ *画面の検索条件を受け取る
*/
@Getter
@AllArgsConstructor
diff --git a/src/main/java/com/example/rhizome/app/domain/service/DeleteDepartment.java b/src/main/java/com/example/rhizome/app/domain/service/DeleteDepartment.java
new file mode 100644
index 0000000..19081e4
--- /dev/null
+++ b/src/main/java/com/example/rhizome/app/domain/service/DeleteDepartment.java
@@ -0,0 +1,6 @@
+package com.example.rhizome.app.domain.service;
+
+public interface DeleteDepartment {
+ void deleteDepartment(Integer idDepartment);
+
+}
diff --git a/src/main/java/com/example/rhizome/app/domain/service/SearchDepartment.java b/src/main/java/com/example/rhizome/app/domain/service/SearchDepartment.java
index 572dcee..807c699 100644
--- a/src/main/java/com/example/rhizome/app/domain/service/SearchDepartment.java
+++ b/src/main/java/com/example/rhizome/app/domain/service/SearchDepartment.java
@@ -1,14 +1,21 @@
+//サービス
+
package com.example.rhizome.app.domain.service;
+import java.util.List;
+
import com.example.rhizome.app.domain.model.Department;
import com.example.rhizome.app.domain.model.SearchConditionDepartment;
-import java.util.List;
-
public interface SearchDepartment {
- List selectAll();
-
+ List selectAll(); //DBから全取得
+
List searchBy(SearchConditionDepartment searchConditionDepartment);
- List searchByWithLike(SearchConditionDepartment searchConditionDepartment);
+ List searchByWithLike(SearchConditionDepartment searchConditionDepartment); //条件検索
+
+
}
+
+
+//controller→SeachDepartment→Repository→DB
\ No newline at end of file
diff --git a/src/main/java/com/example/rhizome/app/domain/service/impl/DeleteDepartmentImpl.java b/src/main/java/com/example/rhizome/app/domain/service/impl/DeleteDepartmentImpl.java
new file mode 100644
index 0000000..5e1d84d
--- /dev/null
+++ b/src/main/java/com/example/rhizome/app/domain/service/impl/DeleteDepartmentImpl.java
@@ -0,0 +1,34 @@
+package com.example.rhizome.app.domain.service.impl;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.example.rhizome.app.domain.service.DeleteDepartment;
+import com.example.rhizome.app.infra.repository.DepartmentRepository;
+
+/**
+ * Employee レコード削除関連の機能を持つサービス
+ */
+@Service
+@Transactional
+public class DeleteDepartmentImpl implements DeleteDepartment {
+
+ DepartmentRepository departmentRepository;
+
+ @Autowired
+ public DeleteDepartmentImpl(DepartmentRepository departmentRepository) {
+ this.departmentRepository = departmentRepository;
+ }
+
+
+ /**
+ * idEmployee を元に employee データを削除
+ *
+ * @param idEmployee 削除対象のidEmployee
+ */
+ public void deleteDepartment(Integer idDepartment) {
+ departmentRepository.deleteById(idDepartment);
+ }
+
+}
diff --git a/src/main/java/com/example/rhizome/app/domain/service/impl/RegisterDepartmentImpl.java b/src/main/java/com/example/rhizome/app/domain/service/impl/RegisterDepartmentImpl.java
new file mode 100644
index 0000000..088da0a
--- /dev/null
+++ b/src/main/java/com/example/rhizome/app/domain/service/impl/RegisterDepartmentImpl.java
@@ -0,0 +1,35 @@
+package com.example.rhizome.app.domain.service.impl;
+
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.example.rhizome.app.domain.model.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;
+
+/**
+ * Employee テーブルの登録系の機能を集約させるサービスクラスです。
+ */
+@Service
+@Transactional
+public class RegisterDepartmentImpl implements RegisterDepartment {
+
+ DepartmentRepository departmentRepository;
+
+ @Autowired
+ public RegisterDepartmentImpl(DepartmentRepository DepartmentRepository) {
+ this.departmentRepository = DepartmentRepository;
+ }
+
+ /**
+ * employee インスタンスの内容を登録する
+ *
+ * @param employee 登録対象のデータ
+ */
+ public void registerDepartment(Department department) {
+ departmentRepository.save(DepartmentEntity.convertFrom(department));
+ }
+}
diff --git a/src/main/java/com/example/rhizome/app/domain/service/impl/SearchDepartmentImpl.java b/src/main/java/com/example/rhizome/app/domain/service/impl/SearchDepartmentImpl.java
index feb6b37..02572d8 100644
--- a/src/main/java/com/example/rhizome/app/domain/service/impl/SearchDepartmentImpl.java
+++ b/src/main/java/com/example/rhizome/app/domain/service/impl/SearchDepartmentImpl.java
@@ -1,17 +1,18 @@
package com.example.rhizome.app.domain.service.impl;
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.jpa.domain.Specification;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
import com.example.rhizome.app.domain.model.Department;
import com.example.rhizome.app.domain.model.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 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;
/**
* 部署情報検索系の機能を集約させるサービスクラスです。
@@ -42,6 +43,7 @@ public class SearchDepartmentImpl implements SearchDepartment {
}
/**
+ *seachBy完全一致検索用メソッド
* searchConditionDepartment の情報を元に Department のレコードを取得
*
* @param searchConditionDepartment 検索条件
diff --git a/src/main/java/com/example/rhizome/app/presentation/controller/DeleteDepartmentController.java b/src/main/java/com/example/rhizome/app/presentation/controller/DeleteDepartmentController.java
new file mode 100644
index 0000000..ab2798e
--- /dev/null
+++ b/src/main/java/com/example/rhizome/app/presentation/controller/DeleteDepartmentController.java
@@ -0,0 +1,123 @@
+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;
+import com.example.rhizome.app.domain.service.DeleteDepartment;
+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.SessionKeyword;
+import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
+import com.example.rhizome.app.presentation.form.DepartmentForm;
+import com.example.rhizome.app.presentation.form.LoginUserForm;
+import com.example.rhizome.app.presentation.form.MessageForm;
+
+/**
+ * 削除処理のコントロータ
+ */
+@Controller
+public class DeleteDepartmentController {
+
+ // ログ出力用インスタンス
+ private final static Logger LOGGER = Logger.getLogger(DeleteDepartmentController.class.getName());
+
+ // エラーメッセージ用の定数フィールド
+ private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
+
+ HttpSession httpSession;
+ DeleteDepartment deleteDepartment;
+ SearchDepartment searchDepartment;
+
+ @Autowired
+ public DeleteDepartmentController(DeleteDepartment deleteDepartment, SearchDepartment searchDepartment, HttpSession httpSession) {
+ this.httpSession = httpSession;
+ this.deleteDepartment = deleteDepartment;
+ this.searchDepartment = searchDepartment;
+ }
+
+ /**
+ * 削除処理のコントローラ
+ *
+ * @param idEmployee 削除対象のemployeeId
+ * @param model ビューにデータを渡すためのコンテナ
+ * @return 遷移先の画面
+ */
+ @PermissionCheck
+ @SessionCheck
+ @RequestMapping(value = DELETE_DEPARTMENT, method = RequestMethod.POST)
+ public String deleteDepartment(@RequestParam("idDepartment") Integer idDepartment, Model model) {
+
+ try {
+ // 部署一覧を取得し、画面に返す用のクラスに詰め替える
+ // 作成した部署一覧をセット
+ model.addAttribute(
+ PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
+ DepartmentForm.convertFrom(searchDepartment.selectAll())
+ );
+
+ // 削除処理実施
+ deleteExec(
+ model,
+ idDepartment,
+ LoginUserForm.convertTo((LoginUserForm) httpSession.getAttribute(SessionKeyword.LOGIN_USER)));
+
+ // 検索画面に遷移
+ return "forward:" + TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_INFO_FORM_EMPTY;
+
+ } catch (Exception e) {
+ // ログイン情報の破棄
+ httpSession.invalidate();
+
+ e.printStackTrace();
+ // エラーログ出力
+ LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
+ // エラー画面遷移
+ return TransitionTargetPageNameKeyword.ERROR_HTML;
+ }
+ }
+
+ /**
+ * 削除処理実施
+ *
+ * @param model ビューにデータを渡すためのコンテナ
+ * @param idEmployee 削除対象のemployeeId
+ * @param loginUser ログインユーザー情報
+ */
+ private void deleteExec(Model model, Integer idDepartment, LoginUser loginUser) {
+
+ final String DELETE_TARGET_ID_CAN_NOT_DELETE = "ログイン者自身は削除出来ません。";
+ final String DELETE_COMPLETE = "削除しました。";
+
+ // ログインしている人が、削除対象かチェック
+ if (Objects.equals(loginUser.getIdDepartment(), idDepartment)) {
+ // 削除対象だった場合
+ // エラーメッセージをセット
+ model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DELETE_TARGET_ID_CAN_NOT_DELETE));
+ // 検索画面に遷移
+ return;
+ }
+
+ // 削除を実施
+ deleteDepartment.deleteDepartment(idDepartment);
+
+ // 削除完了したメッセージをセット
+ model.addAttribute(PageReturnAttributeKeyword.MESSAGE_INFO, new MessageForm(DELETE_COMPLETE));
+
+ }
+}
diff --git a/src/main/java/com/example/rhizome/app/presentation/controller/InsertDepartmentInputController.java b/src/main/java/com/example/rhizome/app/presentation/controller/InsertDepartmentInputController.java
new file mode 100644
index 0000000..cb6cdf5
--- /dev/null
+++ b/src/main/java/com/example/rhizome/app/presentation/controller/InsertDepartmentInputController.java
@@ -0,0 +1,92 @@
+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.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.InsertDepartmentForm;
+
+/**
+ * 登録画面表示用コントローラ
+ * 部署登録画面を表示するだけ
+ */
+@Controller
+public class InsertDepartmentInputController {
+
+ // ログ出力用インスタンス
+ private final static Logger LOGGER = Logger.getLogger(InsertDepartmentInputController.class.getName());
+
+ // エラーメッセージ用の定数フィールド
+ private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
+
+ HttpSession httpSession;
+ RegisterDepartment registerDepartment;
+ SearchDepartment searchDepartment;
+
+ @Autowired
+ public InsertDepartmentInputController(HttpSession httpSession, RegisterDepartment registerDepartment, SearchDepartment searchDepartment) {
+ this.httpSession = httpSession;
+ this.registerDepartment = registerDepartment;
+ this.searchDepartment = searchDepartment;
+ }
+
+ @ModelAttribute
+ public InsertDepartmentForm insertDepartmentForm() {
+ return new InsertDepartmentForm();
+ }
+
+
+ /**
+ * 登録画面表示処理
+ *
+ * @param insertDepartmentForm 登録画面のフォーム
+ * @param model ビューにデータを渡すためのコンテナ
+ * @return 遷移先の画面
+ */
+ @SessionCheck
+ @PermissionCheck
+ @RequestMapping(value = INSERT_DEPARTMENT_INPUT, method = RequestMethod.POST)
+ public String insertInput(InsertDepartmentForm insertDepartmentForm, Model model) {
+
+ try {
+ // 部署コードリストを作成し、画面に返す値としてセット
+ //model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, DepartmentForm.convertFrom(searchDepartment.selectAll()));
+
+ // パラメータをセット
+ model.addAttribute(PageReturnAttributeKeyword.INSERT_DEPARTMENT_FORM, insertDepartmentForm);
+
+ // 登録画面に遷移
+ return TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_INPUT_HTML;
+
+ } catch (Exception e) {
+ // ログイン情報の破棄
+ httpSession.invalidate();
+
+ e.printStackTrace();
+
+ // エラーログ出力
+ LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
+ // エラー画面遷移
+ return TransitionTargetPageNameKeyword.ERROR_HTML;
+ }
+ }
+}
+
+
+
diff --git a/src/main/java/com/example/rhizome/app/presentation/controller/SelectDepartmentController.java b/src/main/java/com/example/rhizome/app/presentation/controller/SelectDepartmentController.java
new file mode 100644
index 0000000..43b8ff7
--- /dev/null
+++ b/src/main/java/com/example/rhizome/app/presentation/controller/SelectDepartmentController.java
@@ -0,0 +1,136 @@
+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.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.SearchConditionDepartmentForm;
+
+/**
+ * 部署検索画面用コントローラ リスト全件表示、検索表示、更新、削除が可能
+ */
+@Controller
+public class SelectDepartmentController {
+
+ // ログ出力用インスタンス
+ private final static Logger LOGGER = Logger.getLogger(SelectDepartmentController.class.getName());
+ // エラーメッセージ用の定数フィールド
+ private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
+
+ HttpSession httpSession;
+ SearchDepartment searchDepartment;
+
+
+ @Autowired
+ public SelectDepartmentController(HttpSession httpSession, SearchDepartment searchDepartment) {
+ this.httpSession = httpSession;
+ this.searchDepartment = searchDepartment;
+ }
+
+ @ModelAttribute
+ public SearchConditionDepartmentForm searchConditionDepartmentForm() {
+ return new SearchConditionDepartmentForm();
+ }
+
+ /**
+ * 部署検索画面表示処理コントローラ
+ *
+ * @param searchConditionDepartmentForm 検索画面のフォーム
+ * @param model ビューにデータを渡すためのコンテナ
+ * @return 遷移先の画面
+ */
+ @PermissionCheck
+ @SessionCheck
+ @RequestMapping(value = TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_INFO, method = RequestMethod.POST)
+ public String select(SearchConditionDepartmentForm searchConditionDepartmentForm, Model model) {
+
+ try {
+
+ // 部署一覧を取得し、画面に返す用のクラスに詰め替える
+ // 作成した部署一覧をセット
+ model.addAttribute(
+ PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
+ DepartmentForm.convertFrom(searchDepartment.selectAll()) //部署一覧をDBから取得→List
+ //DepartmentをDepartmentFormという型に変換
+ //model.Attributet(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,変換した部署一覧)
+ //DBから部署一覧を取得して
+ //画面表示用のDepartmentFormに変換して
+ //departmentFormListという名前で画面に渡す
+ );
+
+ // 検索条件を元に検索を実施
+ // 取得した EmployeeInfo( employee + department )の情報を画面に返す用の型に詰め替えてセット
+ model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_INFO_FORM_LIST,
+ DepartmentForm.convertFrom(
+ searchDepartment.searchByWithLike(
+ SearchConditionDepartmentForm.convertTo(searchConditionDepartmentForm))));
+ //SearchConditionDepartmentForm…画面から送られた検索条件
+ //model.Attributet(PageReturnAttributeKeyword.DEPARTMENT_INFO_FORM_LIST,変換済み検索結果)
+ //画面で入力された検索条件を検索用オブジェクトに変換して
+ //その条件で部署を検索して
+ //検索結果を画面表示用のDepartmentFormに変換して、
+ //departmentInfoFormListという名前でHTMLに渡している
+
+ // 検索ページに遷移
+ return TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_HTML;
+
+
+ } catch (Exception e) {
+ // ログイン情報の破棄
+ httpSession.invalidate();
+
+ e.printStackTrace();
+
+ // エラーログ出力
+ LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
+ // エラー画面遷移
+ return TransitionTargetPageNameKeyword.ERROR_HTML;
+ }
+
+ }
+
+ /**
+ * 社員検索画面表示処理コントローラ
+ * 検索条件無しの状態を作るため、空の検索条件で検索した結果を画面に返す
+ *
+ * @param model ビューにデータを渡すためのコンテナ
+ * @return 遷移先の画面
+ */
+ @PermissionCheck
+ @SessionCheck
+ @RequestMapping(value = TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_INFO_FORM_EMPTY, method = RequestMethod.POST)
+ public String select(Model model) {
+
+ // 部署一覧を取得し、画面に返す用のクラスに詰め替える
+ // 作成した部署一覧をセット
+ model.addAttribute(
+ PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
+ DepartmentForm.convertFrom(searchDepartment.selectAll())
+ );
+
+ // 検索条件を元に検索を実施
+ model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_INFO_FORM_LIST,DepartmentForm.convertFrom(
+ searchDepartment.searchByWithLike(
+ SearchConditionDepartmentForm.convertTo(searchConditionDepartmentForm()
+
+
+ ))));
+
+ // 検索ページに遷移
+ return TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_HTML;
+ }
+}
diff --git a/src/main/java/com/example/rhizome/app/presentation/controller/pageproperty/PageReturnAttributeKeyword.java b/src/main/java/com/example/rhizome/app/presentation/controller/pageproperty/PageReturnAttributeKeyword.java
index 5e9ec04..601d969 100644
--- a/src/main/java/com/example/rhizome/app/presentation/controller/pageproperty/PageReturnAttributeKeyword.java
+++ b/src/main/java/com/example/rhizome/app/presentation/controller/pageproperty/PageReturnAttributeKeyword.java
@@ -2,6 +2,7 @@ package com.example.rhizome.app.presentation.controller.pageproperty;
/**
* Servlet から Servlet に返却する際に使用する文字列を管理するクラス
+ * モデルに渡すキー名を定数化
*/
public class PageReturnAttributeKeyword {
@@ -9,10 +10,14 @@ public class PageReturnAttributeKeyword {
public static final String MESSAGE_INFO = "messageInfo";
public static final String DEPARTMENT_FORM_LIST = "departmentFormList";
+ public static final String DEPARTMENT_INFO_FORM_LIST = "departmentInfoFormList";
public static final String UPDATE_EMPLOYEE_INFO_FORM = "updateEmployeeInfoForm";
public static final String INSERT_EMPLOYEE_FORM = "insertEmployeeForm";
public static final String LOGIN_INFO_FORM = "loginInfoForm";
public static final String UPDATE_PERSONAL_EMPLOYEE_USER_FORM = "updatePersonalEmployeeUserForm";
public static final String EMPLOYEE_INFO_FORM_LIST = "employeeInfoFormList";
+ public static final String INSERT_DEPARTMENT_INPUT = "insertDepartmentInput";
+ public static final String INSERT_DEPARTMENT_FORM = "insertDepartmentForm";
+ public static final String INSERT_DEPARTMENT_INPUT_HTML = "insertDepartmentInputHtml";
}
diff --git a/src/main/java/com/example/rhizome/app/presentation/controller/pageproperty/TransitionTargetPageNameKeyword.java b/src/main/java/com/example/rhizome/app/presentation/controller/pageproperty/TransitionTargetPageNameKeyword.java
index 90ded96..27f179e 100644
--- a/src/main/java/com/example/rhizome/app/presentation/controller/pageproperty/TransitionTargetPageNameKeyword.java
+++ b/src/main/java/com/example/rhizome/app/presentation/controller/pageproperty/TransitionTargetPageNameKeyword.java
@@ -4,6 +4,7 @@ import java.util.Set;
/**
* システムで利用しているJSPのリスト
+ * 画面用(URL)用の定数、行き先管理
*/
public class TransitionTargetPageNameKeyword {
@@ -14,13 +15,16 @@ public class TransitionTargetPageNameKeyword {
public static final String UPDATE_PERSONAL_EMPLOYEE_INPUT_HTML = "updatePersonalEmployeeInput";
public static final String UPDATE_PERSONAL_RESULT_HTML = "updatePersonalEmployeeResult";
- // 管理者向け
+ // 管理者向け(View名)
public static final String MENU_HTML = "menu";
public static final String SELECT_EMPLOYEE_HTML = "selectEmployee";
+ public static final String SELECT_DEPARTMENT_HTML = "selectDepartment";
public static final String INSERT_EMPLOYEE_INPUT_HTML = "insertEmployeeInput";
public static final String INSERT_EMPLOYEE_CONFIRM_HTML = "insertEmployeeConfirm";
public static final String INSERT_EMPLOYEE_RESULT_HTML = "insertEmployeeResult";
public static final String UPDATE_EMPLOYEE_INPUT_HTML = "updateEmployeeInput";
+ public static final String INSERT_DEPARTMENT_INPUT_HTML = "insertDepartmentInput";
+ public static final String DELET_DEPARTMENT_HTML = "deleteDepartment";
public static final String ERROR_HTML = "error";
@@ -34,17 +38,21 @@ public class TransitionTargetPageNameKeyword {
// 一般向け(Controller)
public static final String PERSONAL_UPDATE_RESULT = "/updatePersonalEmployeeResult";
- // 管理者向け(Controller)
+ // 管理者向け(Controller)(ブラウザから呼ばれるURL)
public static final String DELETE_EMPLOYEE = "/deleteEmployee";
public static final String INSERT_EMPLOYEE_INPUT = "/insertEmployeeInput";
public static final String INSERT_EMPLOYEE_CONFIRM = "/insertEmployeeConfirm";
public static final String INSERT_EMPLOYEE = "/insertEmployee";
public static final String SHOW_MENU = "/showMenu";
public static final String SELECT_EMPLOYEE_INFO = "/selectEmployeeInfo";
+ public static final String SELECT_DEPARTMENT_INFO = "/selectDepartmentInfo";
public static final String SELECT_EMPLOYEE_INFO_FORM_EMPTY = "/selectAll";
+ public static final String SELECT_DEPARTMENT_INFO_FORM_EMPTY = "/selectDepartmentAll";
public static final String SHOW_UPDATE_EMPLOYEE = "/showUpdateEmployee";
public static final String UPDATE_EMPLOYEE_RESULT = "/updateEmployeeResult";
-
+ public static final String INSERT_DEPARTMENT_INPUT = "/insertDepartmentInput";
+ public static final String DELETE_DEPARTMENT = "/deleteDepartment";
+
// Department
// HTML
// Controller
@@ -63,6 +71,7 @@ public class TransitionTargetPageNameKeyword {
LOGOUT,
DO_LOGIN,
DELETE_EMPLOYEE,
+ DELETE_DEPARTMENT,
INSERT_EMPLOYEE_INPUT,
INSERT_EMPLOYEE_CONFIRM,
INSERT_EMPLOYEE,
@@ -70,7 +79,11 @@ public class TransitionTargetPageNameKeyword {
SELECT_EMPLOYEE_INFO,
SELECT_EMPLOYEE_INFO_FORM_EMPTY,
SHOW_UPDATE_EMPLOYEE,
- UPDATE_EMPLOYEE_RESULT
+ UPDATE_EMPLOYEE_RESULT,
+ SELECT_DEPARTMENT_INFO,
+ SELECT_DEPARTMENT_INFO_FORM_EMPTY,
+ INSERT_DEPARTMENT_INPUT
+
);
}
diff --git a/src/main/java/com/example/rhizome/app/presentation/form/InsertDepartmentForm.java b/src/main/java/com/example/rhizome/app/presentation/form/InsertDepartmentForm.java
new file mode 100644
index 0000000..7c2d95e
--- /dev/null
+++ b/src/main/java/com/example/rhizome/app/presentation/form/InsertDepartmentForm.java
@@ -0,0 +1,110 @@
+package com.example.rhizome.app.presentation.form;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.example.rhizome.app.domain.model.Department;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 画面から渡ってきた登録内容をまとめ、再度画面に表示する為のクラス
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class InsertDepartmentForm {
+
+ /**
+ * 部署ID
+ */
+ private Integer idDepartment;
+
+ /**
+ * 部署名
+ */
+ private String nmDepartment;
+
+
+ /**
+ * パスワードのValidation
+ * チェック対象にエラーが有った場合エラーリストに文言を追加する
+ *
+ * @param password 登録対象のパスワード
+ * @param passwordConfirm 登録対象のパスワード再入力
+ * @param error エラーリスト
+ */
+ private static void checkPassword(String password, String passwordConfirm, List error) {
+ final String PASSWORD_NULL_BLANK = "パスワード が未入力です。";
+ final String PASSWORD_CONFIRM_NULL_BLANK = "パスワード確認用 が未入力です。";
+ final String PASSWORD_MISMATCH = "パスワード と パスワード確認用 が一致しません。";
+
+ if (isNullOrBlank(password)) {
+ error.add(PASSWORD_NULL_BLANK);
+ return;
+ }
+ if (isNullOrBlank(passwordConfirm)) {
+ error.add(PASSWORD_CONFIRM_NULL_BLANK);
+ return;
+ }
+
+ if (!password.equals(passwordConfirm)) {
+ error.add(PASSWORD_MISMATCH);
+ }
+ }
+
+ /**
+ * 仮引数を null or 空 判定する
+ *
+ * @param str 判定対象の文字列
+ * @return true:null or 空 false:null or 空 では無い
+ */
+ private static boolean isNullOrBlank(String str) {
+ if (null == str) {
+ return true;
+ }
+
+ return str.isBlank();
+ }
+
+ /**
+ * 画面から渡ってきた登録内容をまとめ、ビジネスモデルに変換
+ *
+ * @param insertEmployeeForm 画面から渡ってきた登録内容
+ * @return ビジネスモデルのインスタンス
+ */
+ public static Department convertTo(InsertDepartmentForm insertDepartmentForm) {
+ return new Department(
+
+ insertDepartmentForm.getIdDepartment(),
+ insertDepartmentForm.getNmDepartment()
+ );
+ }
+
+ /**
+ * 登録データのValidationを行う
+ *
+ * @return エラーが有った場合はエラー文言、無ければ空のリストが返る
+ */
+ public List validateParameter() {
+ final String DEPARTMENT_NAME_NULL_BLANK = "部署名"; //入力エラーになったときに返す項目
+ final String DEPARTMENT_ID_NULL_BLANK = "所属部署";
+
+ List error = new ArrayList<>();
+
+ if (isNullOrBlank(nmDepartment)) {
+ error.add(DEPARTMENT_NAME_NULL_BLANK);
+ }
+
+
+ if (idDepartment == null) {
+ error.add(DEPARTMENT_ID_NULL_BLANK);
+ }
+
+ return error;
+
+ }
+
+}
diff --git a/src/main/java/com/example/rhizome/app/presentation/form/SearchConditionDepartmentForm.java b/src/main/java/com/example/rhizome/app/presentation/form/SearchConditionDepartmentForm.java
new file mode 100644
index 0000000..96eed52
--- /dev/null
+++ b/src/main/java/com/example/rhizome/app/presentation/form/SearchConditionDepartmentForm.java
@@ -0,0 +1,53 @@
+package com.example.rhizome.app.presentation.form;
+
+import com.example.rhizome.app.domain.model.SearchConditionDepartment;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 画面から渡ってきた検索条件をまとめ、再度画面に表示する為のクラス
+ */
+@Data
+@AllArgsConstructor //全フィールドを初期化するコンストラクタ生成
+@NoArgsConstructor //デフォルトコントラスタを自動生成
+public class SearchConditionDepartmentForm {
+
+ /**
+ * 部署ID
+ */
+ private Integer idDepartment;
+ /**
+ * 部署名
+ */
+ private String nmDepartment;
+
+ /**
+ * business (サービス)層の SearchConditionEmployee クラスから画面用(presentation 層)の SearchConditionEmployeeForm に
+ * 変換します。
+ *
+ * @param searchConditionEmployee business 層の SearchConditionEmployee インスタンス
+ * @return 画面用(presentation 層)の SearchConditionEmployeeForm インスタンス
+ */
+ public static SearchConditionDepartmentForm convertFrom(SearchConditionDepartment searchConditionDepartment) {
+ return new SearchConditionDepartmentForm(
+ searchConditionDepartment.getIdDepartment(),
+ searchConditionDepartment.getNmDepartment()
+ );
+ }
+
+ /**
+ * 画面用(presentation 層)の SearchConditionEmployeeForm クラスから business 層の SearchConditionEmployee クラスに
+ * 変換します。
+ *
+ * @param searchConditionEmployeeForm 画面用(presentation 層)の SearchConditionEmployeeForm インスタンス
+ * @return business 層の SearchConditionEmployee インスタンス
+ */
+ public static SearchConditionDepartment convertTo(SearchConditionDepartmentForm searchConditionDepartmentForm) {
+ return new SearchConditionDepartment(
+ searchConditionDepartmentForm.getIdDepartment(),
+ searchConditionDepartmentForm.getNmDepartment()
+ );
+ }
+}
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index 88b15aa..6eca8cd 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -1,3 +1,3 @@
-spring.datasource.url=jdbc:mysql://localhost:3306/rezodb
+spring.datasource.url=jdbc:mysql://localhost:3306/springdb
spring.datasource.username=rezouser
spring.datasource.password=Rezo_0000
diff --git a/src/main/resources/templates/insertDepartmentInput.html b/src/main/resources/templates/insertDepartmentInput.html
new file mode 100644
index 0000000..f9a6b0d
--- /dev/null
+++ b/src/main/resources/templates/insertDepartmentInput.html
@@ -0,0 +1,67 @@
+
+
+
+
+
+
+
+
+
+
+
+ 部署登録
+
+
+
+
+ 部署登録
+
+ ログイン者名:
+
+
+
+
+メニューに戻る
+
+
\ No newline at end of file
diff --git a/src/main/resources/templates/menu.html b/src/main/resources/templates/menu.html
index 6d0ee4a..1983d82 100644
--- a/src/main/resources/templates/menu.html
+++ b/src/main/resources/templates/menu.html
@@ -27,6 +27,17 @@
登録済みのユーザ一覧表示と更新、削除を行います。 |
+
+ |
+ |
+ 登録済みの部署一覧表示と更新、削除を行います。 |
+
+
+
+ |
+ |
+ 部署の新規登録を行います。 |
+
|
@@ -59,13 +70,13 @@
function selectDepartmentSubmit() {
const form = document.createElement('form');
form.setAttribute('method', 'post');
- form.setAttribute('action', 'selectDepartment');
+ form.setAttribute('action', 'selectDepartmentInfo');
// 動的送信用のHidden
// 動的にFormを作成する場合は何かしら送信しないと、正しく動作しない
const inputField = document.createElement("input");
inputField.setAttribute("type", "hidden");
- inputField.setAttribute("value", "selectDepartment");
+ inputField.setAttribute("value", "selectDepartmentInfo");
form.appendChild(inputField);
diff --git a/src/main/resources/templates/selectDepartment.html b/src/main/resources/templates/selectDepartment.html
new file mode 100644
index 0000000..5358cea
--- /dev/null
+++ b/src/main/resources/templates/selectDepartment.html
@@ -0,0 +1,114 @@
+
+
+
+
+
+
+
+
+
+
+
+ 検索
+
+
+
+
+ 検索条件入力
+
+ ログイン者名:
+
+
+
+
+
+メニューに戻る
+
+検索結果
+
+
+
+
+
+
+
+
+
+
+ | 部署ID |
+ 部署名 |
+ 操作 |
+
+
+
+
+ |
+ |
+
+
+
+
+
+ |
+
+
+
+
+
+
+ 検索結果はありません。
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/webapp/NewFile.html b/src/main/webapp/NewFile.html
new file mode 100644
index 0000000..2571001
--- /dev/null
+++ b/src/main/webapp/NewFile.html
@@ -0,0 +1,10 @@
+
+
+
+
+Insert title here
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/webapp/insertDepartmentInput.html b/src/main/webapp/insertDepartmentInput.html
new file mode 100644
index 0000000..2571001
--- /dev/null
+++ b/src/main/webapp/insertDepartmentInput.html
@@ -0,0 +1,10 @@
+
+
+
+
+Insert title here
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/webapp/selectDepartment.html b/src/main/webapp/selectDepartment.html
new file mode 100644
index 0000000..5358cea
--- /dev/null
+++ b/src/main/webapp/selectDepartment.html
@@ -0,0 +1,114 @@
+
+
+
+
+
+
+
+
+
+
+
+ 検索
+
+
+
+
+ 検索条件入力
+
+ ログイン者名:
+
+
+
+
+
+メニューに戻る
+
+検索結果
+
+
+
+
+
+
+
+
+
+
+ | 部署ID |
+ 部署名 |
+ 操作 |
+
+
+
+
+ |
+ |
+
+
+
+
+
+ |
+
+
+
+
+
+
+ 検索結果はありません。
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/webapp/selectDepartment2.html b/src/main/webapp/selectDepartment2.html
new file mode 100644
index 0000000..2571001
--- /dev/null
+++ b/src/main/webapp/selectDepartment2.html
@@ -0,0 +1,10 @@
+
+
+
+
+Insert title here
+
+
+
+
+
\ No newline at end of file
diff --git a/テスト仕様書/~$単体テスト仕様書.xlsx b/テスト仕様書/~$単体テスト仕様書.xlsx
new file mode 100644
index 0000000..48e6e0d
Binary files /dev/null and b/テスト仕様書/~$単体テスト仕様書.xlsx differ
diff --git a/設計書/~$【管理者】メニュー機能-詳細設計書.xlsx b/設計書/~$【管理者】メニュー機能-詳細設計書.xlsx
new file mode 100644
index 0000000..48e6e0d
Binary files /dev/null and b/設計書/~$【管理者】メニュー機能-詳細設計書.xlsx differ
diff --git a/設計書/~$【管理者】社員情報登録機能-詳細設計書.xlsx b/設計書/~$【管理者】社員情報登録機能-詳細設計書.xlsx
new file mode 100644
index 0000000..48e6e0d
Binary files /dev/null and b/設計書/~$【管理者】社員情報登録機能-詳細設計書.xlsx differ
diff --git a/設計書/~$【管理者】部署情報検索更新削除機能-詳細設計書.xlsx b/設計書/~$【管理者】部署情報検索更新削除機能-詳細設計書.xlsx
new file mode 100644
index 0000000..48e6e0d
Binary files /dev/null and b/設計書/~$【管理者】部署情報検索更新削除機能-詳細設計書.xlsx differ
diff --git a/設計書/~$テーブル定義書.xlsm b/設計書/~$テーブル定義書.xlsm
new file mode 100644
index 0000000..48e6e0d
Binary files /dev/null and b/設計書/~$テーブル定義書.xlsm differ
diff --git a/設計書/~$基本設計書.xlsx b/設計書/~$基本設計書.xlsx
new file mode 100644
index 0000000..48e6e0d
Binary files /dev/null and b/設計書/~$基本設計書.xlsx differ
diff --git a/設計書/基本設計書.xlsx b/設計書/基本設計書.xlsx
index 1a921a7..6eef10d 100644
Binary files a/設計書/基本設計書.xlsx and b/設計書/基本設計書.xlsx differ