[edit] Contorollerを編集

This commit is contained in:
kkazuya
2026-09-10 16:07:31 +09:00
parent e243b7e81c
commit b04a448ceb
4 changed files with 9 additions and 8 deletions

View File

@@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import com.example.rhizome.aop.aspect.PermissionCheck;
import com.example.rhizome.aop.aspect.SessionCheck;
import com.example.rhizome.app.domain.model.Department;
import com.example.rhizome.app.domain.model.SearchConditionDepartment;
import com.example.rhizome.app.domain.service.SearchDepartment;
import com.example.rhizome.app.domain.service.impl.SearchDepartmentImpl;
import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
@@ -82,7 +83,7 @@ public class InsertDepartmentConfirmController {
final String DUPLICATION = "既に登録済みの部署名です。";
// 登録対象の部署名を元に検索
List<Department> departmentList = searchDepartment.searchDepartment(insertDepartmentForm.getNmDepartment());
List<Department> departmentList = searchDepartment.searchBy(new SearchConditionDepartment(null, insertDepartmentForm.getNmDepartment()));
// 検索結果があるか
if (!departmentList.isEmpty()) {

View File

@@ -52,7 +52,7 @@ class SelectDepartmentController {
*/
@PermissionCheck
@SessionCheck
@RequestMapping(value = TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_INFO, method = RequestMethod.POST)
@RequestMapping(value = TransitionTargetPageNameKeyword.SELECT_DEPARTMENT, method = RequestMethod.POST)
public String select(SearchConditionDepartmentForm searchConditionDepartmentForm, Model model) {
try {

View File

@@ -63,18 +63,17 @@ public class UpdateDepartmentController {
final String UPDATE_TARGET_ID_NOT_FOUND = "更新対象のデータが見つかりません。";
try {
List<Department> departmentList = searchDepartment.searchBy(
new SearchConditionDepartment(idDepartment, null)
);
List<Department> departmentList = searchDepartment.searchBy(new SearchConditionDepartment(idDepartment, null));
if (departmentList.isEmpty()) {
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(UPDATE_TARGET_ID_NOT_FOUND));
return "forward:" + TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_INFO;
return "forward:" + TransitionTargetPageNameKeyword.SELECT_DEPARTMENT;
}
model.addAttribute(PageReturnAttributeKeyword.UPDATE_DEPARTMENT_FORM, UpdateDepartmentForm.convertFrom(departmentList.get(0)));
return TransitionTargetPageNameKeyword.UPDATE_DEPARTMENT_INPUT_HTML;
} catch (Exception e) {
httpSession.invalidate();

View File

@@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import com.example.rhizome.aop.aspect.PermissionCheck;
import com.example.rhizome.aop.aspect.SessionCheck;
import com.example.rhizome.app.domain.model.Department;
import com.example.rhizome.app.domain.model.SearchConditionDepartment;
import com.example.rhizome.app.domain.service.SearchDepartment;
import com.example.rhizome.app.domain.service.UpdateDepartment;
import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
@@ -61,7 +62,7 @@ public class UpdateDepartmentResultController {
final String UPDATE_COMPLETE = "更新が完了しました。";
try {
List<Department> departmentList = searchDepartment.searchDepartment(updateDepartmentForm.getNmDepartment());
List<Department> departmentList = searchDepartment.searchBy(new SearchConditionDepartment(null, updateDepartmentForm.getNmDepartment()));
if (!checkDuplicateNmDepartment(departmentList, updateDepartmentForm)) {
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DUPLICATION));
@@ -77,7 +78,7 @@ public class UpdateDepartmentResultController {
return TransitionTargetPageNameKeyword.UPDATE_DEPARTMENT_INPUT_HTML;
}
Department beforeDepartment = searchDepartment.searchDepartmentById(updateDepartmentForm.getIdDepartment()).get(0);
Department beforeDepartment = searchDepartment.searchDepartmentById(updateDepartmentForm.getIdDepartment());
if (beforeDepartment.getIdDepartment() == null) {
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(NO_TARGET));
model.addAttribute(PageReturnAttributeKeyword.UPDATE_DEPARTMENT_FORM, updateDepartmentForm);