9 Commits

28 changed files with 1094 additions and 69 deletions

View File

@@ -0,0 +1,6 @@
package com.example.rhizome.app.domain.service;
public interface DeleteDepartment {
void deleteDepartment(Integer idDepartment);
}

View File

@@ -1,6 +1,6 @@
package com.example.rhizome.app.domain.service; package com.example.rhizome.app.domain.service;
public interface DeleteEmployee { public interface DeleteEmployee {
void deleteEmployee(Integer idEmployee); void deleteEmployee(Integer idEmployee);
} }

View File

@@ -0,0 +1,8 @@
package com.example.rhizome.app.domain.service;
import com.example.rhizome.app.domain.model.Department;
public interface UpdateDepartment {
void updateDepartment(Department beforeDepartment, Department updateDepartment);
}

View File

@@ -0,0 +1,26 @@
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;
@Service
@Transactional
public class DeleteDepartmentImpl implements DeleteDepartment {
DepartmentRepository departmentRepository;
@Autowired
public DeleteDepartmentImpl(DepartmentRepository departmentRepository) {
this.departmentRepository = departmentRepository;
}
@Override
public void deleteDepartment(Integer idDepartment) {
departmentRepository.deleteById(idDepartment);
}
}

View File

@@ -0,0 +1,27 @@
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;
@Service
@Transactional
public class RegisterDepartmentImpl implements RegisterDepartment {
DepartmentRepository departmentRepository;
@Autowired
public RegisterDepartmentImpl(DepartmentRepository departmentRepository) {
this.departmentRepository = departmentRepository;
}
@Override
public void registerDepartment(Department department) {
departmentRepository.save(DepartmentEntity.convertFrom(department));
}
}

View File

@@ -0,0 +1,37 @@
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.UpdateDepartment;
import com.example.rhizome.app.infra.entity.DepartmentEntity;
import com.example.rhizome.app.infra.repository.DepartmentRepository;
@Service
@Transactional
public class UpdateDepartmentImpl implements UpdateDepartment {
DepartmentRepository departmentRepository;
@Autowired
public UpdateDepartmentImpl(DepartmentRepository departmentRepository) {
this.departmentRepository = departmentRepository;
}
@Override
public void updateDepartment(Department beforeDepartment, Department updateDepartment) {
departmentRepository.save(DepartmentEntity.convertFrom(mergeDepartment(beforeDepartment, updateDepartment)));
}
private Department mergeDepartment(Department beforeDepartment, Department updateDepartment) {
return new Department(
updateDepartment.getIdDepartment(),
updateDepartment.getNmDepartment());
}
}

View File

@@ -0,0 +1,100 @@
package com.example.rhizome.app.presentation.controller;
import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.*;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.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.Employee;
import com.example.rhizome.app.domain.model.SearchConditionDepartment;
import com.example.rhizome.app.domain.service.DeleteDepartment;
import com.example.rhizome.app.domain.service.SearchDepartment;
import com.example.rhizome.app.domain.service.SearchEmployee;
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.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;
SearchEmployee searchEmployee;
@Autowired
public DeleteDepartmentController(DeleteDepartment deleteDepartment, HttpSession httpSession,
SearchDepartment searchDepartment, SearchEmployee searchEmployee) {
this.httpSession = httpSession;
this.deleteDepartment = deleteDepartment;
this.searchDepartment = searchDepartment;
this.searchEmployee = searchEmployee;
}
@PermissionCheck
@SessionCheck
@RequestMapping(value = DELETE_DEPARTMENT, method = RequestMethod.POST)
public String deleteD(@RequestParam("idDepartment") Integer idDepartment, Model model) {
try {
List<DepartmentForm> list = DepartmentForm.convertFrom(
searchDepartment.searchByDepartmentId(new SearchConditionDepartment(idDepartment, null)));
deleteExec(
model,
idDepartment,
list);
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;
}
}
private void deleteExec(Model model, Integer idDepartment, List<DepartmentForm> list) {
final String DELETE_ID_NOT_EXISTS = "削除対象のIDが不明です。";
final String DELETE_TARGET_ID_CAN_NOT_DELETE = "1名以上が所属している部署は削除出来ません。";
final String DELETE_COMPLETE = "削除しました。";
if (list.isEmpty()) {
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DELETE_ID_NOT_EXISTS));
}
List<Employee> employee = searchEmployee.searchEmployeeByIdDepartment(list.get(0).getIdDepartment());
if (!employee.isEmpty()) {
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));
}
}

View File

@@ -0,0 +1,66 @@
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.SearchDepartment;
import com.example.rhizome.app.domain.service.impl.SearchDepartmentImpl;
import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
import com.example.rhizome.app.presentation.form.InsertDepartmentForm;
@Controller
public class InsertDepartmentConfirmController {
private final static Logger LOGGER = Logger.getLogger(InsertDepartmentConfirmController.class.getName());
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
HttpSession httpSession;
SearchDepartment searchDepartment;
@Autowired
public InsertDepartmentConfirmController(
HttpSession httpSession,
SearchDepartmentImpl searchDepartment) {
this.httpSession = httpSession;
this.searchDepartment = searchDepartment;
}
@ModelAttribute
public InsertDepartmentForm insertDepartmentForm() {
return new InsertDepartmentForm();
}
@PermissionCheck
@SessionCheck
@RequestMapping(value = INSERT_DEPARTMENT_CONFIRM, method = RequestMethod.POST)
public String insertDepartmentConfirm(InsertDepartmentForm insertDepartmentForm, Model model) {
try {
model.addAttribute(PageReturnAttributeKeyword.INSERT_DEPARTMENT_FORM, insertDepartmentForm);
return TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_CONFIRM_HTML;
} catch (Exception e) {
httpSession.invalidate();
e.printStackTrace();
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
return TransitionTargetPageNameKeyword.ERROR_HTML;
}
}
}

View File

@@ -0,0 +1,120 @@
package com.example.rhizome.app.presentation.controller;
import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.*;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.example.rhizome.aop.aspect.PermissionCheck;
import com.example.rhizome.aop.aspect.SessionCheck;
import com.example.rhizome.app.domain.model.Department;
import com.example.rhizome.app.domain.model.SearchConditionDepartment;
import com.example.rhizome.app.domain.service.RegisterDepartment;
import com.example.rhizome.app.domain.service.SearchDepartment;
import com.example.rhizome.app.domain.service.impl.RegisterDepartmentImpl;
import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
import com.example.rhizome.app.presentation.form.InsertDepartmentForm;
import com.example.rhizome.app.presentation.form.MessageForm;
@Controller
public class InsertDepartmentController {
private final static Logger LOGGER = Logger.getLogger(InsertDepartmentController.class.getName());
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
HttpSession httpSession;
RegisterDepartment registerDepartment;
SearchDepartment searchDepartment;
@Autowired
public InsertDepartmentController(HttpSession httpSession, RegisterDepartmentImpl registerEmployee,
SearchDepartment searchDepartment) {
this.httpSession = httpSession;
this.registerDepartment = registerEmployee;
this.searchDepartment = searchDepartment;
}
@ModelAttribute
public InsertDepartmentForm insertDepartmentForm() {
return new InsertDepartmentForm();
}
@PermissionCheck
@SessionCheck
@RequestMapping(value = INSERT_DEPARTMENT, method = RequestMethod.POST)
public String insertDepartment(InsertDepartmentForm insertDepartmentForm, Model model) {
try {
List<String> error = validateParameter(
insertDepartmentForm.getNmDepartment());
if (!error.isEmpty()) {
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR,
new MessageForm(String.join(", ", error) + "が不正です。"));
model.addAttribute(PageReturnAttributeKeyword.INSERT_DEPARTMENT_FORM, insertDepartmentForm);
return TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_INPUT_HTML;
}
final String DUPLICATION = "既に同名の部署が存在します。";
SearchConditionDepartment searchConditionDepartment = new SearchConditionDepartment(null,
insertDepartmentForm.getNmDepartment());
List<Department> departmentList = searchDepartment.searchByDepartmentName(searchConditionDepartment);
if (!departmentList.isEmpty()) {
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DUPLICATION));
model.addAttribute(PageReturnAttributeKeyword.INSERT_DEPARTMENT_FORM, insertDepartmentForm);
return TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_INPUT_HTML;
}
registerDepartment.registerDepartment(InsertDepartmentForm.convertTo(insertDepartmentForm));
return TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_RESULT_HTML;
} catch (Exception e) {
httpSession.invalidate();
e.printStackTrace();
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
return TransitionTargetPageNameKeyword.ERROR_HTML;
}
}
private List<String> validateParameter(
String departmentName) {
final String DEPARTMENT_NAME_NULL_BLANK = "部署名";
List<String> error = new ArrayList<>();
if (isNullOrBlank(departmentName)) {
error.add(DEPARTMENT_NAME_NULL_BLANK);
}
return error;
}
private static boolean isNullOrBlank(String str) {
if (null == str) {
return true;
}
return str.isBlank();
}
}

View File

@@ -0,0 +1,64 @@
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.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;
@Autowired
public InsertDepartmentInputController(HttpSession httpSession, RegisterDepartment registerDepartment) {
this.httpSession = httpSession;
this.registerDepartment = registerDepartment;
}
@ModelAttribute
public InsertDepartmentForm insertDepartmentForm() {
return new InsertDepartmentForm();
}
@SessionCheck
@PermissionCheck
@RequestMapping(value = INSERT_DEPARTMENT_INPUT, method = RequestMethod.POST)
public String insertInput(InsertDepartmentForm insertDepartmentForm, Model model) {
try {
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;
}
}
}

View File

@@ -0,0 +1,83 @@
package com.example.rhizome.app.presentation.controller;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import com.example.rhizome.aop.aspect.PermissionCheck;
import com.example.rhizome.aop.aspect.SessionCheck;
import com.example.rhizome.app.domain.model.Department;
import com.example.rhizome.app.domain.model.SearchConditionDepartment;
import com.example.rhizome.app.domain.service.SearchDepartment;
import com.example.rhizome.app.domain.service.SearchEmployeeInfo;
import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
import com.example.rhizome.app.presentation.form.MessageForm;
import com.example.rhizome.app.presentation.form.SearchConditionDepartmentForm;
import com.example.rhizome.app.presentation.form.UpdateDepartmentForm;
@Controller
public class UpdateDepartmentController {
private final static Logger LOGGER = Logger.getLogger(UpdateDepartmentController.class.getName());
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
HttpSession httpSession;
SearchDepartment searchDepartment;
SearchEmployeeInfo searchEmployeeInfo;
@Autowired
public UpdateDepartmentController(HttpSession httpSession, SearchDepartment searchDepartment) {
this.httpSession = httpSession;
this.searchDepartment = searchDepartment;
}
@ModelAttribute
public SearchConditionDepartmentForm searchConditionDepartmentForm() {
return new SearchConditionDepartmentForm();
}
@PermissionCheck
@SessionCheck
@RequestMapping(value = TransitionTargetPageNameKeyword.SHOW_UPDATE_DEPARTMENT, method = RequestMethod.POST)
public String showUpdateDepartment(@RequestParam("idDepartment") Integer idDepartment, Model model) {
LOGGER.info("showUpdateDepartment 실행");
final String NO_TARGET = "更新対象のデータが見つかりません。";
try {
List<Department> departmentList = searchDepartment.searchByDepartmentId(
new SearchConditionDepartment(idDepartment,
null));
if (departmentList.isEmpty()) {
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(NO_TARGET));
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();
e.printStackTrace();
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
return TransitionTargetPageNameKeyword.ERROR_HTML;
}
}
}

View File

@@ -0,0 +1,116 @@
package com.example.rhizome.app.presentation.controller;
import java.util.List;
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.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.example.rhizome.aop.aspect.PermissionCheck;
import com.example.rhizome.aop.aspect.SessionCheck;
import com.example.rhizome.app.domain.model.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;
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
import com.example.rhizome.app.presentation.form.LoginUserForm;
import com.example.rhizome.app.presentation.form.MessageForm;
import com.example.rhizome.app.presentation.form.UpdateDepartmentForm;
import com.example.rhizome.app.presentation.form.UpdateEmployeeInfoForm;
@Controller
public class UpdateDepartmentResultController {
private final static Logger LOGGER = Logger.getLogger(UpdateEmployeeController.class.getName());
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
HttpSession httpSession;
SearchDepartment searchDepartment;
UpdateDepartment updateDepartment;
@Autowired
public UpdateDepartmentResultController(HttpSession httpSession, SearchDepartment searchDepartment,
UpdateDepartment updateDepartment) {
this.httpSession = httpSession;
this.searchDepartment = searchDepartment;
this.updateDepartment = updateDepartment;
}
private static boolean checkDuplicateDepartmentName(List<Department> departmentList,
UpdateDepartmentForm updateDepartmentForm) {
if (!departmentList.isEmpty()) {
return Objects.equals(departmentList.get(0).getNmDepartment(), updateDepartmentForm.getNmDepartment());
}
return true;
}
@PermissionCheck
@SessionCheck
@RequestMapping(value = TransitionTargetPageNameKeyword.UPDATE_DEPARTMENT_RESULT, method = RequestMethod.POST)
public String departmentUpdateResult(@ModelAttribute UpdateDepartmentForm updateDepartmentForm, Model model) {
final String DUPLICATION = "既に同名の部署が存在するか、値が変更されていません。";
final String NOTHING = "項目が空欄です。";
final String UPDATE_COMPLETE = "更新が完了しました。";
try {
List<Department> departmentList = searchDepartment
.searchByDepartmentId(new SearchConditionDepartment(updateDepartmentForm.getIdDepartment(), null));
if (checkDuplicateDepartmentName(departmentList, updateDepartmentForm)) {
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DUPLICATION));
model.addAttribute(PageReturnAttributeKeyword.UPDATE_DEPARTMENT_FORM, updateDepartmentForm);
return TransitionTargetPageNameKeyword.UPDATE_DEPARTMENT_INPUT_HTML;
}
if (!UpdateDepartmentForm.hasErrorParameter(updateDepartmentForm)) {
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(NOTHING));
model.addAttribute(PageReturnAttributeKeyword.UPDATE_DEPARTMENT_FORM, updateDepartmentForm);
return TransitionTargetPageNameKeyword.UPDATE_DEPARTMENT_INPUT_HTML;
}
List<Department> beforeDepartment = searchDepartment
.searchByDepartmentId(new SearchConditionDepartment(updateDepartmentForm.getIdDepartment(), null));
updateDepartment.updateDepartment(beforeDepartment.get(0),
UpdateDepartmentForm.convertTo(updateDepartmentForm));
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_INFO, new MessageForm(UPDATE_COMPLETE));
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;
}
}
private boolean isUpdateTargetLoginUserAdminToNormal(UpdateEmployeeInfoForm updateEmployeeInfoForm,
LoginUserForm loginUserForm) {
if (!Objects.equals(updateEmployeeInfoForm.getIdEmployee(), loginUserForm.getIdEmployee())) {
return false;
}
return updateEmployeeInfoForm.getAdminAuth().equals(0);
}
}

View File

@@ -0,0 +1,46 @@
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 {
private String nmDepartment;
private static boolean isNullOrBlank(String str) {
if (null == str) {
return true;
}
return str.isBlank();
}
public static Department convertTo(InsertDepartmentForm insertDepartmentForm) {
return new Department(
null,
insertDepartmentForm.getNmDepartment());
}
public List<String> validateParameter() {
final String DEPARTMENT_NAME_NULL_BLANK = "部署名";
List<String> error = new ArrayList<>();
if (isNullOrBlank(nmDepartment)) {
error.add(DEPARTMENT_NAME_NULL_BLANK);
}
return error;
}
}

View File

@@ -0,0 +1,53 @@
package com.example.rhizome.app.presentation.form;
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 UpdateDepartmentForm {
private Integer idDepartment;
private String nmDepartment;
public static UpdateDepartmentForm convertFrom(Department department) {
return new UpdateDepartmentForm(
department.getIdDepartment(),
department.getNmDepartment());
}
public static List<UpdateDepartmentForm> convertFrom(List<Department> departmentList) {
return departmentList.stream().map(UpdateDepartmentForm::convertFrom).toList();
}
public static Department convertTo(UpdateDepartmentForm updateDepartmentForm) {
return new Department(
updateDepartmentForm.getIdDepartment(),
updateDepartmentForm.getNmDepartment());
}
public static boolean hasErrorParameter(UpdateDepartmentForm updateDepartmentForm) {
boolean errorFlag = !isNullOrBlank(updateDepartmentForm.getNmDepartment());
if (!isNullOrBlank(updateDepartmentForm.getNmDepartment())) {
errorFlag = true;
}
return errorFlag;
}
private static boolean isNullOrBlank(String str) {
if (null == str) {
return true;
}
return str.isBlank();
}
}

View File

@@ -14,25 +14,21 @@ h1 {
min-width: 640px; min-width: 640px;
font-size: 15pt; font-size: 15pt;
font-weight: bold; font-weight: bold;
display: flex; /* フレックスボックスを使う */ display: flex;
justify-content: space-between; /* 左右の要素を端に寄せる */ justify-content: space-between;
align-items: center; /* 上下中央に配置 */ align-items: center;
} }
.rightSection { .rightSection {
display: flex; /* フレックスボックスを使う */ display: flex;
align-items: center; /* 上下中央に配置 */ align-items: center;
} }
/* 入力フォーム */
input, button, select { input, button, select {
padding: 5px 15px 5px 15px; padding: 5px 15px 5px 15px;
margin: 3px; margin: 3px;
/* border-radius: 5px; /* CSS3草案 */
/* -webkit-border-radius: 5px; /* Safari,Google Chrome用 */
/* -moz-border-radius: 5px; /* Firefox用 */
} }
input.readOnly { input.readOnly {
@@ -40,7 +36,6 @@ input.readOnly {
color: #ffffff; color: #ffffff;
} }
/* メッセージボックスデザイン */
.msgBox { .msgBox {
font-weight: bold; font-weight: bold;
@@ -64,7 +59,6 @@ input.readOnly {
color: #000000; color: #000000;
} }
/* 個別デザイン */
th.header { th.header {
width: 150px; width: 150px;
@@ -74,7 +68,7 @@ th.header {
.loginInfo { .loginInfo {
font-size: 9pt; font-size: 9pt;
color: #008080; color: #008080;
margin-right: 10px; /* ログアウトボタンとの間隔 */ margin-right: 10px;
} }
.logoutButton { .logoutButton {
@@ -91,10 +85,9 @@ td.btnArea {
} }
.header-spacing { .header-spacing {
margin-top: 20px; /* 上部に20ピクセルのマージン */ margin-top: 20px;
} }
/* グリッドラインの追加 */
.table-grid { .table-grid {
width: 100%; width: 100%;
border-collapse: collapse; border-collapse: collapse;
@@ -110,17 +103,14 @@ td.btnArea {
background-color: #f2f2f2; background-color: #f2f2f2;
} }
/* ストライプ効果(奇数行と偶数行で色を交互に) */
.table-striped tbody tr:nth-child(odd) { .table-striped tbody tr:nth-child(odd) {
background-color: #f2f2f2; background-color: #f2f2f2;
} }
/* ホバー効果(マウスオーバー時に行の色を変更) */
.table-hover tbody tr:hover { .table-hover tbody tr:hover {
background-color: #ccffcc; /* パステルグリーンの背景色 */ background-color: #ccffcc;
} }
/* レスポンシブデザイン(小さい画面でスクロール) */
.table-responsive { .table-responsive {
overflow-x: auto; overflow-x: auto;
display: block; display: block;
@@ -155,17 +145,17 @@ table.menuClass td.description {
} }
input[type="submit"], input[type="reset"], button { input[type="submit"], input[type="reset"], button {
color: #008080; /* ターコイズ色 */ color: #008080;
text-decoration: none; /* 下線をなくす */ text-decoration: none;
padding: 10px 20px; /* パディングを追加 */ padding: 10px 20px;
border: 1px solid #008080; /* 枠線を追加 */ border: 1px solid #008080;
border-radius: 5px; /* 角を丸くする */ border-radius: 5px;
background-color: transparent; /* 背景色を透明に */ background-color: transparent;
cursor: pointer; /* カーソルをポインターに */ cursor: pointer;
transition: 0.3s; /* アニメーション効果 */ transition: 0.3s;
} }
input[type="submit"]:hover, input[type="reset"]:hover, button:hover { input[type="submit"]:hover, input[type="reset"]:hover, button:hover {
background-color: #008080; /* マウスオーバー時の背景色 */ background-color: #008080;
color: #ffffff; /* マウスオーバー時の文字色 */ color: #ffffff;
} }

View File

@@ -1,8 +1,6 @@
function convertToKatakana(input) { function convertToKatakana(input) {
// 漢字とローマ字を削除
const valueWithoutKanjiAndRomaji = input.value.replace(/[\u4E00-\u9FFF\u0041-\u009F]/g, ''); const valueWithoutKanjiAndRomaji = input.value.replace(/[\u4E00-\u9FFF\u0041-\u009F]/g, '');
// ひらがなをカタカナに変換
const katakanaValue = valueWithoutKanjiAndRomaji.replace(/[\u3041-\u3096]/g, function (match) { const katakanaValue = valueWithoutKanjiAndRomaji.replace(/[\u3041-\u3096]/g, function (match) {
const chr = match.charCodeAt(0) + 0x60; const chr = match.charCodeAt(0) + 0x60;
return String.fromCharCode(chr); return String.fromCharCode(chr);
@@ -16,15 +14,12 @@ function logoutSubmit() {
form.setAttribute('method', 'post'); form.setAttribute('method', 'post');
form.setAttribute('action', 'logout'); form.setAttribute('action', 'logout');
// 動的送信用のHidden
// 動的にFormを作成する場合は何かしら送信しないと、正しく動作しない
const inputField = document.createElement("input"); const inputField = document.createElement("input");
inputField.setAttribute("type", "hidden"); inputField.setAttribute("type", "hidden");
inputField.setAttribute("value", "logout"); inputField.setAttribute("value", "logout");
form.appendChild(inputField); form.appendChild(inputField);
// フォームをDOMに追加
document.body.appendChild(form); document.body.appendChild(form);
form.submit(); form.submit();

View File

@@ -15,6 +15,11 @@
<h1>エラーが発生しました。</h1> <h1>エラーが発生しました。</h1>
<div>ログインからやり直してください。</div> <div>ログインからやり直してください。</div>
<div class="msgBox error" th:if="${messageError} != null">
<span class="error" th:text="${messageError.message}"></span>
</div>
<a href="login">ログイン</a> <a href="login">ログイン</a>
</body> </body>
</html> </html>

View File

@@ -0,0 +1,86 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<!-- 外部のスクリプトファイルを読み込む -->
<script th:src="@{/js/common.js}"></script>
<!-- CSSの読み込み -->
<link rel="stylesheet" th:href="@{/css/all.css}">
<link rel=stylesheet th:href="@{/css/style.css}" type="text/css">
<title>登録内容確認</title>
</head>
<body>
<h1>登録内容確認   
<div class="rightSection">
<span class="loginInfo">ログイン者名:<span th:text="${session.loginUser.nmEmployee}"></span></span>
<button class="logoutButton" onclick="logoutSubmit()">ログアウト</button>
</div>
</h1>
<form action="insertDepartment"
id="insertForm"
method="post"
th:object="${insertDepartmentForm}">
<div class="msgBox error" th:if="${messageError != null}">
<span class="error" th:each="message : ${messageError.message}" th:text="${message}"></span>
</div>
<table>
<tr>
<th class="header">部署ID</th>
<td>
<label>
<input class="readOnly"
name="dptId"
readonly="readonly"
type="text"
value="自動で設定されます"/>
</label>
</td>
</tr>
<tr>
<th class="header">部署名</th>
<td>
<label>
<input class="readOnly"
name="nmDepartment"
readonly="readonly"
th:value="*{nmDepartment}"
type="text"/>
</label>
</td>
</tr>
<tr>
<td class="btnArea" colspan="2">
<input type="submit" value="登録"/>
</td>
</tr>
</table>
<a href="javascript:onClickEdit()">登録内容の編集</a> | <a href="showMenu">メニューに戻る</a>
</form>
<script type="text/javascript">
function onClickEdit() {
const form = document.getElementById('insertForm');
form.setAttribute('method', 'post');
form.setAttribute('action', 'insertDepartmentInput');
const inputField = document.createElement("input");
inputField.setAttribute("type", "hidden");
inputField.setAttribute("name", "backFlg");
inputField.setAttribute("value", "edit");
form.appendChild(inputField);
document.body.appendChild(form);
form.submit();
}
</script>
</body>
</html>

View File

@@ -0,0 +1,67 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<!-- 外部のスクリプトファイルを読み込む -->
<script th:src="@{/js/common.js}"></script>
<!-- CSSの読み込み -->
<link rel="stylesheet" th:href="@{/css/all.css}">
<link rel=stylesheet th:href="@{/css/style.css}" type="text/css">
<title>部署登録</title>
</head>
<body>
<h1>
部署登録   
<div class="rightSection">
<span class="loginInfo">ログイン者名:<span th:text="${session.loginUser.nmEmployee}"></span></span>
<button class="logoutButton" onclick="logoutSubmit()">ログアウト</button>
</div>
</h1>
<form action="insertDepartmentConfirm"
method="post"
th:object="${insertDepartmentForm}">
<div class="msgBox error" th:if="${messageError} != null">
<span class="error" th:text="${messageError.message}"></span>
</div>
<table>
<tr>
<th class="header">部署ID</th>
<td>
<label>
<input class="readOnly"
readonly="readonly"
type="text"
value="自動で設定されます"
/>
</label>
</td>
</tr>
<tr>
<th class="header">部署名</th>
<td>
<label>
<input maxlength="50"
placeholder="社員名"
required="required"
th:field="*{nmDepartment}"
type="text"
/>
</label>
</td>
</tr>
<tr>
<td class="btnArea" colspan="2">
<input type="submit" value="登録確認"/>
</td>
</tr>
</table>
</form>
<a href="showMenu">メニューに戻る</a>
</body>
</html>

View File

@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<script th:src="@{/js/common.js}"></script>
<link rel="stylesheet" th:href="@{/css/all.css}">
<link rel=stylesheet th:href="@{/css/style.css}" type="text/css">
<title>社員登録完了</title>
</head>
<body>
<h2>社員登録が完了しました</h2>
<br/>
<a href="javascript:insertSubmit()">続けて登録する</a> | <a href="showMenu">メニューに戻る</a>
</body>
<script type="text/javascript">
function insertSubmit() {
const form = document.createElement('form');
form.setAttribute('method', 'post');
form.setAttribute('action', 'insertDepartmentInput');
const inputField = document.createElement("input");
inputField.setAttribute("type", "hidden");
inputField.setAttribute("value", "select");
form.appendChild(inputField);
document.body.appendChild(form);
form.submit();
}
</script>
</html>

View File

@@ -4,9 +4,7 @@
<head> <head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"> <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<!-- 外部のスクリプトファイルを読み込む -->
<script th:src="@{/js/common.js}"></script> <script th:src="@{/js/common.js}"></script>
<!-- CSSの読み込み -->
<link rel="stylesheet" th:href="@{/css/all.css}"> <link rel="stylesheet" th:href="@{/css/all.css}">
<link rel=stylesheet th:href="@{/css/style.css}" type="text/css"> <link rel=stylesheet th:href="@{/css/style.css}" type="text/css">
<title>登録内容確認</title> <title>登録内容確認</title>
@@ -138,7 +136,6 @@
form.setAttribute('method', 'post'); form.setAttribute('method', 'post');
form.setAttribute('action', 'insertEmployeeInput'); form.setAttribute('action', 'insertEmployeeInput');
// 確認画面から編集画面に戻ってきたときのフラグ(未使用)
const inputField = document.createElement("input"); const inputField = document.createElement("input");
inputField.setAttribute("type", "hidden"); inputField.setAttribute("type", "hidden");
inputField.setAttribute("name", "backFlg"); inputField.setAttribute("name", "backFlg");
@@ -146,7 +143,6 @@
form.appendChild(inputField); form.appendChild(inputField);
// フォームをDOMに追加
document.body.appendChild(form); document.body.appendChild(form);
form.submit(); form.submit();

View File

@@ -4,9 +4,7 @@
<head> <head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"> <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<!-- 外部のスクリプトファイルを読み込む -->
<script th:src="@{/js/common.js}"></script> <script th:src="@{/js/common.js}"></script>
<!-- CSSの読み込み -->
<link rel="stylesheet" th:href="@{/css/all.css}"> <link rel="stylesheet" th:href="@{/css/all.css}">
<link rel=stylesheet th:href="@{/css/style.css}" type="text/css"> <link rel=stylesheet th:href="@{/css/style.css}" type="text/css">
<title>社員登録完了</title> <title>社員登録完了</title>
@@ -23,15 +21,12 @@
form.setAttribute('method', 'post'); form.setAttribute('method', 'post');
form.setAttribute('action', 'insertEmployeeInput'); form.setAttribute('action', 'insertEmployeeInput');
// 動的送信用のHidden
// 動的にFormを作成する場合は何かしら送信しないと、正しく動作しない
const inputField = document.createElement("input"); const inputField = document.createElement("input");
inputField.setAttribute("type", "hidden"); inputField.setAttribute("type", "hidden");
inputField.setAttribute("value", "select"); inputField.setAttribute("value", "select");
form.appendChild(inputField); form.appendChild(inputField);
// フォームをDOMに追加
document.body.appendChild(form); document.body.appendChild(form);
form.submit(); form.submit();

View File

@@ -30,7 +30,7 @@
required="required" required="required"
style="width: 100%;" style="width: 100%;"
th:field="*{mailAddress}" th:field="*{mailAddress}"
type="text"/> type="email"/>
</td> </td>
</tr> </tr>
<tr> <tr>

View File

@@ -4,9 +4,7 @@
<head> <head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"> <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<!-- 外部のスクリプトファイルを読み込む -->
<script th:src="@{/js/common.js}"></script> <script th:src="@{/js/common.js}"></script>
<!-- CSSの読み込み -->
<link rel="stylesheet" th:href="@{/css/all.css}"> <link rel="stylesheet" th:href="@{/css/all.css}">
<link rel=stylesheet th:href="@{/css/style.css}" type="text/css"> <link rel=stylesheet th:href="@{/css/style.css}" type="text/css">
<title>メニュー</title> <title>メニュー</title>
@@ -32,6 +30,15 @@
<td><a class="menuClass" href="javascript:insertEmployeeSubmit()"><i class="fas fa-plus"></i> 社員登録 </a></td> <td><a class="menuClass" href="javascript:insertEmployeeSubmit()"><i class="fas fa-plus"></i> 社員登録 </a></td>
<td class="description">新規でユーザ追加を行います。</td> <td class="description">新規でユーザ追加を行います。</td>
</tr> </tr>
<tr>
<td><a class="menuClass" href="javascript:selectDepartmentSubmit()"><i class="fas fa-search"></i> 部署検索 </a>
</td>
<td class="description">登録済みの部署覧表示と</br>更新、削除を行います。</td>
</tr>
<tr>
<td><a class="menuClass" href="javascript:insertDepartmentSubmit()"><i class="fas fa-plus"></i> 部署登録 </a></td>
<td class="description">新規で部署追加を行います。</td>
</tr>
</table> </table>
</body> </body>
@@ -42,15 +49,12 @@
form.setAttribute('method', 'post'); form.setAttribute('method', 'post');
form.setAttribute('action', 'selectEmployeeInfo'); form.setAttribute('action', 'selectEmployeeInfo');
// 動的送信用のHidden
// 動的にFormを作成する場合は何かしら送信しないと、正しく動作しない
const inputField = document.createElement("input"); const inputField = document.createElement("input");
inputField.setAttribute("type", "hidden"); inputField.setAttribute("type", "hidden");
inputField.setAttribute("value", "selectEmployeeInfo"); inputField.setAttribute("value", "selectEmployeeInfo");
form.appendChild(inputField); form.appendChild(inputField);
// フォームをDOMに追加
document.body.appendChild(form); document.body.appendChild(form);
form.submit(); form.submit();
@@ -61,15 +65,12 @@
form.setAttribute('method', 'post'); form.setAttribute('method', 'post');
form.setAttribute('action', 'selectDepartment'); form.setAttribute('action', 'selectDepartment');
// 動的送信用のHidden
// 動的にFormを作成する場合は何かしら送信しないと、正しく動作しない
const inputField = document.createElement("input"); const inputField = document.createElement("input");
inputField.setAttribute("type", "hidden"); inputField.setAttribute("type", "hidden");
inputField.setAttribute("value", "selectDepartment"); inputField.setAttribute("value", "selectDepartment");
form.appendChild(inputField); form.appendChild(inputField);
// フォームをDOMに追加
document.body.appendChild(form); document.body.appendChild(form);
form.submit(); form.submit();
@@ -80,15 +81,12 @@
form.setAttribute('method', 'post'); form.setAttribute('method', 'post');
form.setAttribute('action', 'insertEmployeeInput'); form.setAttribute('action', 'insertEmployeeInput');
// 動的送信用のHidden
// 動的にFormを作成する場合は何かしら送信しないと、正しく動作しない
const inputField = document.createElement("input"); const inputField = document.createElement("input");
inputField.setAttribute("type", "hidden"); inputField.setAttribute("type", "hidden");
inputField.setAttribute("value", "insertEmployeeInput"); inputField.setAttribute("value", "insertEmployeeInput");
form.appendChild(inputField); form.appendChild(inputField);
// フォームをDOMに追加
document.body.appendChild(form); document.body.appendChild(form);
form.submit(); form.submit();
@@ -99,15 +97,12 @@
form.setAttribute('method', 'post'); form.setAttribute('method', 'post');
form.setAttribute('action', 'insertDepartmentInput'); form.setAttribute('action', 'insertDepartmentInput');
// 動的送信用のHidden
// 動的にFormを作成する場合は何かしら送信しないと、正しく動作しない
const inputField = document.createElement("input"); const inputField = document.createElement("input");
inputField.setAttribute("type", "hidden"); inputField.setAttribute("type", "hidden");
inputField.setAttribute("value", "insertDepartmentInput"); inputField.setAttribute("value", "insertDepartmentInput");
form.appendChild(inputField); form.appendChild(inputField);
// フォームをDOMに追加
document.body.appendChild(form); document.body.appendChild(form);
form.submit(); form.submit();

View File

@@ -0,0 +1,83 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<script th:src="@{/js/common.js}"></script>
<link rel="stylesheet" th:href="@{/css/all.css}">
<link rel=stylesheet th:href="@{/css/style.css}" type="text/css">
<title>部署情報更新</title>
</head>
<body>
<h1>
部署情報更新   
<div class="rightSection">
<span class="loginInfo">ログイン者名:<span th:text="${session.loginUser.nmEmployee}"></span></span>
<button class="logoutButton" onclick="logoutSubmit()">ログアウト</button>
</div>
</h1>
<form action="/updateDepartmentResult"
method="post"
onsubmit="return confirm('本当によろしいですか?');"
th:object="${updateDepartmentForm}"
>
<div class="msgBox error" th:if="${messageError != null}">
<span class="error" th:each="message : ${messageError.message}" th:text="${message}"></span>
</div>
<table>
<tr>
<th class="header">部署ID</th>
<td>
<label>
<input class="readOnly"
readonly="readonly"
th:field="*{idDepartment}"
type="text"
/>
</label>
</td>
</tr>
<tr>
<th class="header">部署名</th>
<td>
<label>
<input maxlength="50"
placeholder="部署名"
required="required"
th:field="*{nmDepartment}"
type="text"
/>
</label>
</td>
</tr>
<tr>
<td class="btnArea" colspan="2">
<input type="submit" value="更新"/>
</td>
</tr>
</table>
</form>
<a href="javascript:selectSubmit()">一覧に戻る</a>
</body>
<script>
function selectSubmit() {
const form = document.createElement('form');
form.setAttribute('method', 'post');
form.setAttribute('action', 'selectDepartmentAll');
const inputField = document.createElement("input");
inputField.setAttribute("type", "hidden");
inputField.setAttribute("value", "selectDepartmentAll");
form.appendChild(inputField);
document.body.appendChild(form);
form.submit();
}
</script>
</html>

View File

@@ -4,9 +4,7 @@
<head> <head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"> <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<!-- 外部のスクリプトファイルを読み込む -->
<script th:src="@{/js/common.js}"></script> <script th:src="@{/js/common.js}"></script>
<!-- CSSの読み込み -->
<link rel="stylesheet" th:href="@{/css/all.css}"> <link rel="stylesheet" th:href="@{/css/all.css}">
<link rel=stylesheet th:href="@{/css/style.css}" type="text/css"> <link rel=stylesheet th:href="@{/css/style.css}" type="text/css">
<title>社員情報更新</title> <title>社員情報更新</title>
@@ -93,7 +91,6 @@
</label> </label>
</td> </td>
</tr> </tr>
<!-- *** Chrome等のブラウザの場合自動でセットされる可能性があるので注意書きを外にも *** -->
<tr> <tr>
<th></th> <th></th>
<td> <td>
@@ -163,15 +160,12 @@
form.setAttribute('method', 'post'); form.setAttribute('method', 'post');
form.setAttribute('action', 'selectAll'); form.setAttribute('action', 'selectAll');
// 動的送信用のHidden
// 動的にFormを作成する場合は何かしら送信しないと、正しく動作しない
const inputField = document.createElement("input"); const inputField = document.createElement("input");
inputField.setAttribute("type", "hidden"); inputField.setAttribute("type", "hidden");
inputField.setAttribute("value", "selectAll"); inputField.setAttribute("value", "selectAll");
form.appendChild(inputField); form.appendChild(inputField);
// フォームをDOMに追加
document.body.appendChild(form); document.body.appendChild(form);
form.submit(); form.submit();

View File

@@ -0,0 +1,37 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<script th:src="@{/js/common.js}"></script>
<link rel="stylesheet" th:href="@{/css/all.css}">
<link rel=stylesheet th:href="@{/css/style.css}" type="text/css">
<title>更新完了</title>
</head>
<body>
<h2>更新が完了しました</h2>
<br/>
<a href="javascript:backSubmit()">戻る</a>
</body>
<script type="text/javascript">
function backSubmit() {
const form = document.createElement('form');
form.setAttribute('method', 'post');
form.setAttribute('action', 'updatePersonalDepartmentResult');
const inputField = document.createElement("input");
inputField.setAttribute("type", "hidden");
inputField.setAttribute("value", "updatePersonalDepartmentResult");
form.appendChild(inputField);
document.body.appendChild(form);
form.submit();
}
</script>
</html>

View File

@@ -4,9 +4,7 @@
<head> <head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"> <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<!-- 外部のスクリプトファイルを読み込む -->
<script th:src="@{/js/common.js}"></script> <script th:src="@{/js/common.js}"></script>
<!-- CSSの読み込み -->
<link rel="stylesheet" th:href="@{/css/all.css}"> <link rel="stylesheet" th:href="@{/css/all.css}">
<link rel=stylesheet th:href="@{/css/style.css}" type="text/css"> <link rel=stylesheet th:href="@{/css/style.css}" type="text/css">
<title>更新完了</title> <title>更新完了</title>
@@ -24,15 +22,12 @@
form.setAttribute('method', 'post'); form.setAttribute('method', 'post');
form.setAttribute('action', 'updatePersonalEmployeeResult'); form.setAttribute('action', 'updatePersonalEmployeeResult');
// 動的送信用のHidden
// 動的にFormを作成する場合は何かしら送信しないと、正しく動作しない
const inputField = document.createElement("input"); const inputField = document.createElement("input");
inputField.setAttribute("type", "hidden"); inputField.setAttribute("type", "hidden");
inputField.setAttribute("value", "updatePersonalEmployeeResult"); inputField.setAttribute("value", "updatePersonalEmployeeResult");
form.appendChild(inputField); form.appendChild(inputField);
// フォームをDOMに追加
document.body.appendChild(form); document.body.appendChild(form);
form.submit(); form.submit();