Compare commits
17 Commits
95e1bbb06c
...
s-choi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cc6ea925a9 | ||
|
|
2507dec220 | ||
|
|
6a60c5a85f | ||
|
|
4cdad5c24e | ||
|
|
b1e9792842 | ||
|
|
82e4c68633 | ||
|
|
e1c6067548 | ||
|
|
8ff67fbf02 | ||
|
|
5d50d91701 | ||
|
|
c2d108194c | ||
|
|
ced8c9d154 | ||
|
|
378e446ae2 | ||
|
|
c4acd83194 | ||
|
|
9500eac50f | ||
|
|
fc84fc3fda | ||
|
|
71b8503c07 | ||
|
|
c743d3dfde |
@@ -1,25 +1,22 @@
|
|||||||
package com.example.rhizome.aop.Handler;
|
package com.example.rhizome.aop.Handler;
|
||||||
|
|
||||||
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
import static com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword.*;
|
||||||
import com.example.rhizome.app.presentation.form.LoginInfoForm;
|
|
||||||
import com.example.rhizome.app.presentation.form.MessageForm;
|
import java.util.logging.Level;
|
||||||
import com.example.rhizome.exception.InsufficientPermissionException;
|
import java.util.logging.Logger;
|
||||||
import com.example.rhizome.exception.NoSessionException;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
|
|
||||||
import java.util.logging.Level;
|
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
||||||
import java.util.logging.Logger;
|
import com.example.rhizome.app.presentation.form.LoginInfoForm;
|
||||||
|
import com.example.rhizome.app.presentation.form.MessageForm;
|
||||||
|
import com.example.rhizome.exception.InsufficientPermissionException;
|
||||||
|
import com.example.rhizome.exception.NoSessionException;
|
||||||
|
|
||||||
import static com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword.LOGIN_INFO_FORM;
|
|
||||||
import static com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword.MESSAGE_ERROR;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 例外処理用のコントローラ
|
|
||||||
*/
|
|
||||||
@ControllerAdvice
|
@ControllerAdvice
|
||||||
public class GlobalExceptionHandler {
|
public class GlobalExceptionHandler {
|
||||||
|
|
||||||
@@ -28,12 +25,6 @@ public class GlobalExceptionHandler {
|
|||||||
private final String SEVERE_ERROR_MESSAGE_ILLEGAL_TRANSITION = "不正な遷移です。";
|
private final String SEVERE_ERROR_MESSAGE_ILLEGAL_TRANSITION = "不正な遷移です。";
|
||||||
private final String SEVERE_ERROR_MESSAGE_BAD_REQUEST = "不正なリクエストです。";
|
private final String SEVERE_ERROR_MESSAGE_BAD_REQUEST = "不正なリクエストです。";
|
||||||
|
|
||||||
/**
|
|
||||||
* セッションが切れている場合の例外処理
|
|
||||||
*
|
|
||||||
* @param model ビューにデータを渡すためのコンテナ
|
|
||||||
* @return 遷移先の画面
|
|
||||||
*/
|
|
||||||
@ExceptionHandler(NoSessionException.class)
|
@ExceptionHandler(NoSessionException.class)
|
||||||
public String handleNoSessionException(Model model, Exception e) {
|
public String handleNoSessionException(Model model, Exception e) {
|
||||||
|
|
||||||
@@ -42,18 +33,11 @@ public class GlobalExceptionHandler {
|
|||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
// エラーログ出力
|
|
||||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE_ILLEGAL_TRANSITION, e);
|
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE_ILLEGAL_TRANSITION, e);
|
||||||
|
|
||||||
return TransitionTargetPageNameKeyword.LOGIN_HTML;
|
return TransitionTargetPageNameKeyword.LOGIN_HTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 権限がない場合の例外処理
|
|
||||||
*
|
|
||||||
* @param model ビューにデータを渡すためのコンテナ
|
|
||||||
* @return 遷移先の画面
|
|
||||||
*/
|
|
||||||
@ExceptionHandler(InsufficientPermissionException.class)
|
@ExceptionHandler(InsufficientPermissionException.class)
|
||||||
public String handleInsufficientPermissionException(Model model, Exception e) {
|
public String handleInsufficientPermissionException(Model model, Exception e) {
|
||||||
|
|
||||||
@@ -62,50 +46,32 @@ public class GlobalExceptionHandler {
|
|||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
// エラーログ出力
|
|
||||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE_ILLEGAL_TRANSITION, e);
|
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE_ILLEGAL_TRANSITION, e);
|
||||||
|
|
||||||
return TransitionTargetPageNameKeyword.LOGIN_HTML;
|
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* リクエストメソッドが不正な場合の例外処理
|
|
||||||
*
|
|
||||||
* @param model ビューにデータを渡すためのコンテナ
|
|
||||||
* @return 遷移先の画面
|
|
||||||
*/
|
|
||||||
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
|
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
|
||||||
public String handleBadRequestException(Model model, Exception e) {
|
public String handleBadRequestException(Model model, Exception e) {
|
||||||
// エラーメッセージやその他の情報をモデルに追加する
|
|
||||||
model.addAttribute("error", SEVERE_ERROR_MESSAGE_BAD_REQUEST);
|
model.addAttribute("error", SEVERE_ERROR_MESSAGE_BAD_REQUEST);
|
||||||
model.addAttribute("status", HttpStatus.BAD_REQUEST.value());
|
model.addAttribute("status", HttpStatus.BAD_REQUEST.value());
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
// エラーログ出力
|
|
||||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE_ILLEGAL_TRANSITION, e);
|
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE_ILLEGAL_TRANSITION, e);
|
||||||
|
|
||||||
// カスタムエラーページにリダイレクト
|
|
||||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* その他の例外処理
|
|
||||||
*
|
|
||||||
* @param model ビューにデータを渡すためのコンテナ
|
|
||||||
* @return 遷移先の画面
|
|
||||||
*/
|
|
||||||
@ExceptionHandler(Exception.class)
|
@ExceptionHandler(Exception.class)
|
||||||
public String AllException(Model model, Exception e) {
|
public String AllException(Model model, Exception e) {
|
||||||
// エラーメッセージやその他の情報をモデルに追加する
|
|
||||||
model.addAttribute("error", SEVERE_ERROR_MESSAGE_BAD_REQUEST);
|
model.addAttribute("error", SEVERE_ERROR_MESSAGE_BAD_REQUEST);
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE_ILLEGAL_TRANSITION, e);
|
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE_ILLEGAL_TRANSITION, e);
|
||||||
|
|
||||||
// カスタムエラーページにリダイレクト
|
|
||||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,10 +5,6 @@ import java.lang.annotation.Retention;
|
|||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
/**
|
|
||||||
* SessionCheckアノテーション
|
|
||||||
* セッションチェックを行うメソッドに付与する
|
|
||||||
*/
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target(ElementType.METHOD)
|
@Target(ElementType.METHOD)
|
||||||
public @interface PermissionCheck {
|
public @interface PermissionCheck {
|
||||||
|
|||||||
@@ -1,20 +1,18 @@
|
|||||||
package com.example.rhizome.aop.aspect;
|
package com.example.rhizome.aop.aspect;
|
||||||
|
|
||||||
import com.example.rhizome.app.presentation.controller.pageproperty.SessionKeyword;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
|
||||||
import com.example.rhizome.app.presentation.form.LoginUserForm;
|
|
||||||
import com.example.rhizome.exception.InsufficientPermissionException;
|
|
||||||
import org.aspectj.lang.annotation.Aspect;
|
import org.aspectj.lang.annotation.Aspect;
|
||||||
import org.aspectj.lang.annotation.Before;
|
import org.aspectj.lang.annotation.Before;
|
||||||
import org.aspectj.lang.annotation.Pointcut;
|
import org.aspectj.lang.annotation.Pointcut;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
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.LoginUserForm;
|
||||||
|
import com.example.rhizome.exception.InsufficientPermissionException;
|
||||||
|
|
||||||
/**
|
|
||||||
* 権限チェック用のAOP
|
|
||||||
*/
|
|
||||||
@Aspect
|
@Aspect
|
||||||
@Component
|
@Component
|
||||||
public class PermissionCheckAspect {
|
public class PermissionCheckAspect {
|
||||||
@@ -26,65 +24,39 @@ public class PermissionCheckAspect {
|
|||||||
this.request = request;
|
this.request = request;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Aspectのフックを定義(今回はPermissionCheckアノテーションが定義されているメソッドが動作するタイミング)
|
|
||||||
@Pointcut("@annotation(com.example.rhizome.aop.aspect.PermissionCheck)")
|
@Pointcut("@annotation(com.example.rhizome.aop.aspect.PermissionCheck)")
|
||||||
public void permissionCheckMethod() {
|
public void permissionCheckMethod() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 権限チェック
|
|
||||||
*/
|
|
||||||
@Before("permissionCheckMethod()")
|
@Before("permissionCheckMethod()")
|
||||||
public void checkPermission() {
|
public void checkPermission() {
|
||||||
// ログインユーザの取得
|
|
||||||
LoginUserForm loginUserForm = (LoginUserForm) request.getSession().getAttribute(SessionKeyword.LOGIN_USER);
|
LoginUserForm loginUserForm = (LoginUserForm) request.getSession().getAttribute(SessionKeyword.LOGIN_USER);
|
||||||
|
|
||||||
// ログインユーザが取得できない場合、または権限がない場合はエラー画面に遷移
|
|
||||||
if (loginUserForm == null || !hasRequiredPermission(request.getRequestURI(), loginUserForm)) {
|
if (loginUserForm == null || !hasRequiredPermission(request.getRequestURI(), loginUserForm)) {
|
||||||
throw new InsufficientPermissionException("不正な遷移です");
|
throw new InsufficientPermissionException("不正な遷移です");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 遷移先のURLとログインユーザの権限から、遷移可否を判定する
|
|
||||||
*
|
|
||||||
* @param targetURL 遷移したいURL
|
|
||||||
* @param loginUserForm リクエスト元のユーザ
|
|
||||||
* @return true:遷移可 false:遷移不可
|
|
||||||
*/
|
|
||||||
private boolean hasRequiredPermission(String targetURL, LoginUserForm loginUserForm) {
|
private boolean hasRequiredPermission(String targetURL, LoginUserForm loginUserForm) {
|
||||||
|
|
||||||
// 管理者権限
|
|
||||||
if (isAdminTransition(targetURL, loginUserForm)) {
|
if (isAdminTransition(targetURL, loginUserForm)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 一般権限
|
|
||||||
if (isUserTransition(targetURL, loginUserForm)) {
|
if (isUserTransition(targetURL, loginUserForm)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// アクセス不許可の場合の処理(不正アクセス画面に遷移)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 管理者用のアカウントで管理者向けのページアクセスか
|
|
||||||
*
|
|
||||||
* @param targetURL 遷移したいURL
|
|
||||||
* @param loginUserForm リクエスト元のユーザ
|
|
||||||
* @return true:遷移可 false:遷移不可
|
|
||||||
*/
|
|
||||||
private boolean isAdminTransition(String targetURL, LoginUserForm loginUserForm) {
|
private boolean isAdminTransition(String targetURL, LoginUserForm loginUserForm) {
|
||||||
|
|
||||||
// 管理者か
|
|
||||||
if (!loginUserForm.isAdminUser()) {
|
if (!loginUserForm.isAdminUser()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 管理者向けのページ遷移か
|
|
||||||
if (!TransitionTargetPageNameKeyword.getAdminPageList().contains(targetURL)) {
|
if (!TransitionTargetPageNameKeyword.getAdminPageList().contains(targetURL)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -92,23 +64,13 @@ public class PermissionCheckAspect {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 一般ユーザ用のアカウントで一般ユーザ向けのページアクセスか
|
|
||||||
*
|
|
||||||
* @param targetURL 遷移したいURL
|
|
||||||
* @param loginUserForm リクエスト元のユーザ
|
|
||||||
* @return true:遷移可 false:遷移不可
|
|
||||||
*/
|
|
||||||
private boolean isUserTransition(String targetURL, LoginUserForm loginUserForm) {
|
private boolean isUserTransition(String targetURL, LoginUserForm loginUserForm) {
|
||||||
|
|
||||||
// 管理者か
|
|
||||||
if (loginUserForm.isAdminUser()) {
|
if (loginUserForm.isAdminUser()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 一般ユーザ向けのページ遷移か
|
|
||||||
return TransitionTargetPageNameKeyword.getUserPageList().contains(targetURL);
|
return TransitionTargetPageNameKeyword.getUserPageList().contains(targetURL);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,10 +5,6 @@ import java.lang.annotation.Retention;
|
|||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
/**
|
|
||||||
* SessionCheckアノテーション
|
|
||||||
* セッションチェックを行うメソッドに付与する
|
|
||||||
*/
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target(ElementType.METHOD)
|
@Target(ElementType.METHOD)
|
||||||
public @interface SessionCheck {
|
public @interface SessionCheck {
|
||||||
|
|||||||
@@ -1,19 +1,17 @@
|
|||||||
package com.example.rhizome.aop.aspect;
|
package com.example.rhizome.aop.aspect;
|
||||||
|
|
||||||
import com.example.rhizome.app.presentation.controller.pageproperty.SessionKeyword;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import com.example.rhizome.exception.NoSessionException;
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
import org.aspectj.lang.annotation.Aspect;
|
import org.aspectj.lang.annotation.Aspect;
|
||||||
import org.aspectj.lang.annotation.Before;
|
import org.aspectj.lang.annotation.Before;
|
||||||
import org.aspectj.lang.annotation.Pointcut;
|
import org.aspectj.lang.annotation.Pointcut;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import com.example.rhizome.app.presentation.controller.pageproperty.SessionKeyword;
|
||||||
import javax.servlet.http.HttpSession;
|
import com.example.rhizome.exception.NoSessionException;
|
||||||
|
|
||||||
/**
|
|
||||||
* セッションチェック用のAOP
|
|
||||||
*/
|
|
||||||
@Aspect
|
@Aspect
|
||||||
@Component
|
@Component
|
||||||
public class SessionCheckAspect {
|
public class SessionCheckAspect {
|
||||||
@@ -29,15 +27,10 @@ public class SessionCheckAspect {
|
|||||||
public void sessionCheckMethod() {
|
public void sessionCheckMethod() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* セッションチェック
|
|
||||||
*/
|
|
||||||
@Before("sessionCheckMethod()")
|
@Before("sessionCheckMethod()")
|
||||||
public void checkSession() {
|
public void checkSession() {
|
||||||
// セッションの取得
|
|
||||||
HttpSession session = request.getSession(false);
|
HttpSession session = request.getSession(false);
|
||||||
|
|
||||||
// セッションが取得できない場合はエラー画面に遷移
|
|
||||||
if (session == null || session.getAttribute(SessionKeyword.LOGIN_USER) == null) {
|
if (session == null || session.getAttribute(SessionKeyword.LOGIN_USER) == null) {
|
||||||
throw new NoSessionException("不正なログインです");
|
throw new NoSessionException("不正なログインです");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package com.example.rhizome.app.domain.service;
|
||||||
|
|
||||||
|
public interface DeleteDepartment {
|
||||||
|
void deleteDepartment(Integer idDepartment);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,14 +1,19 @@
|
|||||||
package com.example.rhizome.app.domain.service;
|
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.Department;
|
||||||
import com.example.rhizome.app.domain.model.SearchConditionDepartment;
|
import com.example.rhizome.app.domain.model.SearchConditionDepartment;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface SearchDepartment {
|
public interface SearchDepartment {
|
||||||
List<Department> selectAll();
|
List<Department> selectAll();
|
||||||
|
|
||||||
List<Department> searchBy(SearchConditionDepartment searchConditionDepartment);
|
List<Department> searchBy(SearchConditionDepartment searchConditionDepartment);
|
||||||
|
|
||||||
List<Department> searchByWithLike(SearchConditionDepartment searchConditionDepartment);
|
List<Department> searchByWithLike(SearchConditionDepartment searchConditionDepartment);
|
||||||
|
|
||||||
|
List<Department> searchByDepartmentName(SearchConditionDepartment searchConditionDepartment);
|
||||||
|
|
||||||
|
List<Department> searchByDepartmentId(SearchConditionDepartment searchConditionDepartment);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
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.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.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;
|
||||||
|
SearchEmployeeInfo searchEmployeeInfo;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public SelectDepartmentController(HttpSession httpSession, SearchDepartment searchDepartment,
|
||||||
|
SearchEmployeeInfo searchEmployeeInfo) {
|
||||||
|
this.httpSession = httpSession;
|
||||||
|
this.searchDepartment = searchDepartment;
|
||||||
|
this.searchEmployeeInfo = searchEmployeeInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ModelAttribute
|
||||||
|
public SearchConditionDepartmentForm searchConditionDepartmentForm() {
|
||||||
|
return new SearchConditionDepartmentForm();
|
||||||
|
}
|
||||||
|
|
||||||
|
@SessionCheck
|
||||||
|
@PermissionCheck
|
||||||
|
@RequestMapping(value = TransitionTargetPageNameKeyword.SELECT_DEPARTMENT, method = RequestMethod.POST)
|
||||||
|
public String select(SearchConditionDepartmentForm searchConditionDepartmentForm, Model model) {
|
||||||
|
try {
|
||||||
|
|
||||||
|
model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, DepartmentForm.convertFrom(
|
||||||
|
searchDepartment
|
||||||
|
.searchByWithLike(SearchConditionDepartmentForm.convertTo(searchConditionDepartmentForm))));
|
||||||
|
|
||||||
|
return TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_HTML;
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
httpSession.invalidate();
|
||||||
|
|
||||||
|
e.printStackTrace();
|
||||||
|
|
||||||
|
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||||
|
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@SessionCheck
|
||||||
|
@PermissionCheck
|
||||||
|
@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.searchBy(SearchConditionDepartmentForm.convertTo(searchConditionDepartmentForm()))));
|
||||||
|
|
||||||
|
return TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_HTML;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,18 +1,17 @@
|
|||||||
package com.example.rhizome.app.presentation.controller.pageproperty;
|
package com.example.rhizome.app.presentation.controller.pageproperty;
|
||||||
|
|
||||||
/**
|
|
||||||
* Servlet から Servlet に返却する際に使用する文字列を管理するクラス
|
|
||||||
*/
|
|
||||||
public class PageReturnAttributeKeyword {
|
public class PageReturnAttributeKeyword {
|
||||||
|
|
||||||
public static final String MESSAGE_ERROR = "messageError";
|
public static final String MESSAGE_ERROR = "messageError";
|
||||||
public static final String MESSAGE_INFO = "messageInfo";
|
public static final String MESSAGE_INFO = "messageInfo";
|
||||||
|
|
||||||
public static final String DEPARTMENT_FORM_LIST = "departmentFormList";
|
|
||||||
public static final String UPDATE_EMPLOYEE_INFO_FORM = "updateEmployeeInfoForm";
|
public static final String UPDATE_EMPLOYEE_INFO_FORM = "updateEmployeeInfoForm";
|
||||||
public static final String INSERT_EMPLOYEE_FORM = "insertEmployeeForm";
|
public static final String INSERT_EMPLOYEE_FORM = "insertEmployeeForm";
|
||||||
public static final String LOGIN_INFO_FORM = "loginInfoForm";
|
public static final String LOGIN_INFO_FORM = "loginInfoForm";
|
||||||
public static final String UPDATE_PERSONAL_EMPLOYEE_USER_FORM = "updatePersonalEmployeeUserForm";
|
public static final String UPDATE_PERSONAL_EMPLOYEE_USER_FORM = "updatePersonalEmployeeUserForm";
|
||||||
public static final String EMPLOYEE_INFO_FORM_LIST = "employeeInfoFormList";
|
public static final String EMPLOYEE_INFO_FORM_LIST = "employeeInfoFormList";
|
||||||
|
|
||||||
|
public static final String DEPARTMENT_FORM_LIST = "departmentFormList";
|
||||||
|
public static final String INSERT_DEPARTMENT_FORM = "insertDepartmentForm";
|
||||||
|
public static final String UPDATE_DEPARTMENT_FORM = "updateDepartmentForm";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,19 +2,13 @@ package com.example.rhizome.app.presentation.controller.pageproperty;
|
|||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
|
||||||
* システムで利用しているJSPのリスト
|
|
||||||
*/
|
|
||||||
public class TransitionTargetPageNameKeyword {
|
public class TransitionTargetPageNameKeyword {
|
||||||
|
|
||||||
// 共通
|
|
||||||
public static final String LOGIN_HTML = "login";
|
public static final String LOGIN_HTML = "login";
|
||||||
|
|
||||||
// 一般向け
|
|
||||||
public static final String UPDATE_PERSONAL_EMPLOYEE_INPUT_HTML = "updatePersonalEmployeeInput";
|
public static final String UPDATE_PERSONAL_EMPLOYEE_INPUT_HTML = "updatePersonalEmployeeInput";
|
||||||
public static final String UPDATE_PERSONAL_RESULT_HTML = "updatePersonalEmployeeResult";
|
public static final String UPDATE_PERSONAL_RESULT_HTML = "updatePersonalEmployeeResult";
|
||||||
|
|
||||||
// 管理者向け
|
|
||||||
public static final String MENU_HTML = "menu";
|
public static final String MENU_HTML = "menu";
|
||||||
public static final String SELECT_EMPLOYEE_HTML = "selectEmployee";
|
public static final String SELECT_EMPLOYEE_HTML = "selectEmployee";
|
||||||
public static final String INSERT_EMPLOYEE_INPUT_HTML = "insertEmployeeInput";
|
public static final String INSERT_EMPLOYEE_INPUT_HTML = "insertEmployeeInput";
|
||||||
@@ -22,19 +16,18 @@ public class TransitionTargetPageNameKeyword {
|
|||||||
public static final String INSERT_EMPLOYEE_RESULT_HTML = "insertEmployeeResult";
|
public static final String INSERT_EMPLOYEE_RESULT_HTML = "insertEmployeeResult";
|
||||||
public static final String UPDATE_EMPLOYEE_INPUT_HTML = "updateEmployeeInput";
|
public static final String UPDATE_EMPLOYEE_INPUT_HTML = "updateEmployeeInput";
|
||||||
|
|
||||||
|
public static final String SELECT_DEPARTMENT_HTML = "selectDepartment";
|
||||||
|
|
||||||
public static final String ERROR_HTML = "error";
|
public static final String ERROR_HTML = "error";
|
||||||
|
|
||||||
// 共通(Controller)
|
|
||||||
public static final String INDEX_BLANK = "";
|
public static final String INDEX_BLANK = "";
|
||||||
public static final String INDEX_SLASH = "/";
|
public static final String INDEX_SLASH = "/";
|
||||||
public static final String INDEX_LOGIN = "/login";
|
public static final String INDEX_LOGIN = "/login";
|
||||||
public static final String LOGOUT = "/logout";
|
public static final String LOGOUT = "/logout";
|
||||||
public static final String DO_LOGIN = "/doLogin";
|
public static final String DO_LOGIN = "/doLogin";
|
||||||
|
|
||||||
// 一般向け(Controller)
|
|
||||||
public static final String PERSONAL_UPDATE_RESULT = "/updatePersonalEmployeeResult";
|
public static final String PERSONAL_UPDATE_RESULT = "/updatePersonalEmployeeResult";
|
||||||
|
|
||||||
// 管理者向け(Controller)
|
|
||||||
public static final String DELETE_EMPLOYEE = "/deleteEmployee";
|
public static final String DELETE_EMPLOYEE = "/deleteEmployee";
|
||||||
public static final String INSERT_EMPLOYEE_INPUT = "/insertEmployeeInput";
|
public static final String INSERT_EMPLOYEE_INPUT = "/insertEmployeeInput";
|
||||||
public static final String INSERT_EMPLOYEE_CONFIRM = "/insertEmployeeConfirm";
|
public static final String INSERT_EMPLOYEE_CONFIRM = "/insertEmployeeConfirm";
|
||||||
@@ -45,15 +38,21 @@ public class TransitionTargetPageNameKeyword {
|
|||||||
public static final String SHOW_UPDATE_EMPLOYEE = "/showUpdateEmployee";
|
public static final String SHOW_UPDATE_EMPLOYEE = "/showUpdateEmployee";
|
||||||
public static final String UPDATE_EMPLOYEE_RESULT = "/updateEmployeeResult";
|
public static final String UPDATE_EMPLOYEE_RESULT = "/updateEmployeeResult";
|
||||||
|
|
||||||
// Department
|
public static final String SELECT_DEPARTMENT = "/selectDepartment";
|
||||||
// HTML
|
public static final String SELECT_DEPARTMENT_INFO_FORM_EMPTY = "/selectDepartmentAll";
|
||||||
// Controller
|
public static final String INSERT_DEPARTMENT_INPUT = "/insertDepartmentInput";
|
||||||
|
public static final String INSERT_DEPARTMENT_CONFIRM = "/insertDepartmentConfirm";
|
||||||
|
public static final String INSERT_DEPARTMENT = "/insertDepartment";
|
||||||
|
public static final String DELETE_DEPARTMENT = "/deleteDepartment";
|
||||||
|
public static final String SHOW_UPDATE_DEPARTMENT = "/showUpdateDepartment";
|
||||||
|
public static final String UPDATE_DEPARTMENT_RESULT = "/updateDepartmentResult";
|
||||||
|
|
||||||
|
public static final String INSERT_DEPARTMENT_INPUT_HTML = "insertDepartmentInput";
|
||||||
|
public static final String INSERT_DEPARTMENT_CONFIRM_HTML = "insertDepartmentConfirm";
|
||||||
|
public static final String INSERT_DEPARTMENT_RESULT_HTML = "insertDepartmentResult";
|
||||||
|
|
||||||
|
public static final String UPDATE_DEPARTMENT_INPUT_HTML = "updateDepartmentInput";
|
||||||
|
|
||||||
/**
|
|
||||||
* 管理者向けのページリストを返す
|
|
||||||
*
|
|
||||||
* @return 管理者向けのページリスト
|
|
||||||
*/
|
|
||||||
public static Set<String> getAdminPageList() {
|
public static Set<String> getAdminPageList() {
|
||||||
|
|
||||||
return Set.of(
|
return Set.of(
|
||||||
@@ -70,15 +69,17 @@ public class TransitionTargetPageNameKeyword {
|
|||||||
SELECT_EMPLOYEE_INFO,
|
SELECT_EMPLOYEE_INFO,
|
||||||
SELECT_EMPLOYEE_INFO_FORM_EMPTY,
|
SELECT_EMPLOYEE_INFO_FORM_EMPTY,
|
||||||
SHOW_UPDATE_EMPLOYEE,
|
SHOW_UPDATE_EMPLOYEE,
|
||||||
UPDATE_EMPLOYEE_RESULT
|
UPDATE_EMPLOYEE_RESULT,
|
||||||
);
|
SELECT_DEPARTMENT,
|
||||||
|
SELECT_DEPARTMENT_INFO_FORM_EMPTY,
|
||||||
|
INSERT_DEPARTMENT_INPUT,
|
||||||
|
INSERT_DEPARTMENT_CONFIRM,
|
||||||
|
INSERT_DEPARTMENT,
|
||||||
|
DELETE_DEPARTMENT,
|
||||||
|
SHOW_UPDATE_DEPARTMENT,
|
||||||
|
UPDATE_DEPARTMENT_RESULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 一般向けのページリストを返す
|
|
||||||
*
|
|
||||||
* @return 一般向けのページリスト
|
|
||||||
*/
|
|
||||||
public static Set<String> getUserPageList() {
|
public static Set<String> getUserPageList() {
|
||||||
return Set.of(
|
return Set.of(
|
||||||
INDEX_BLANK,
|
INDEX_BLANK,
|
||||||
@@ -86,8 +87,7 @@ public class TransitionTargetPageNameKeyword {
|
|||||||
INDEX_LOGIN,
|
INDEX_LOGIN,
|
||||||
LOGOUT,
|
LOGOUT,
|
||||||
DO_LOGIN,
|
DO_LOGIN,
|
||||||
PERSONAL_UPDATE_RESULT
|
PERSONAL_UPDATE_RESULT);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
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
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class SearchConditionDepartmentForm {
|
||||||
|
|
||||||
|
private Integer idDepartment;
|
||||||
|
private String nmDepartment;
|
||||||
|
|
||||||
|
public static SearchConditionDepartmentForm convertFrom(SearchConditionDepartment searchConditionDepartment) {
|
||||||
|
return new SearchConditionDepartmentForm(
|
||||||
|
searchConditionDepartment.getIdDepartment(),
|
||||||
|
searchConditionDepartment.getNmDepartment());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SearchConditionDepartment convertTo(SearchConditionDepartmentForm searchConditionDepartmentForm) {
|
||||||
|
return new SearchConditionDepartment(
|
||||||
|
searchConditionDepartmentForm.getIdDepartment(),
|
||||||
|
searchConditionDepartmentForm.getNmDepartment());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,8 +1,5 @@
|
|||||||
package com.example.rhizome.exception;
|
package com.example.rhizome.exception;
|
||||||
|
|
||||||
/**
|
|
||||||
* 権限不足の例外を表現するクラスです。
|
|
||||||
*/
|
|
||||||
public class InsufficientPermissionException extends RuntimeException {
|
public class InsufficientPermissionException extends RuntimeException {
|
||||||
|
|
||||||
public InsufficientPermissionException(String message) {
|
public InsufficientPermissionException(String message) {
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
package com.example.rhizome.exception;
|
package com.example.rhizome.exception;
|
||||||
|
|
||||||
/**
|
|
||||||
* 権限不足の例外を表現するクラスです。
|
|
||||||
*/
|
|
||||||
public class NoSessionException extends RuntimeException {
|
public class NoSessionException extends RuntimeException {
|
||||||
|
|
||||||
public NoSessionException(String message) {
|
public NoSessionException(String message) {
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
86
src/main/resources/templates/insertDepartmentConfirm.html
Normal file
86
src/main/resources/templates/insertDepartmentConfirm.html
Normal 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>
|
||||||
67
src/main/resources/templates/insertDepartmentInput.html
Normal file
67
src/main/resources/templates/insertDepartmentInput.html
Normal 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>
|
||||||
35
src/main/resources/templates/insertDepartmentResult.html
Normal file
35
src/main/resources/templates/insertDepartmentResult.html
Normal 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>
|
||||||
@@ -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();
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
115
src/main/resources/templates/selectDepartment.html
Normal file
115
src/main/resources/templates/selectDepartment.html
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
<!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="selectDepartment"
|
||||||
|
method="post"
|
||||||
|
th:object="${searchConditionDepartmentForm}">
|
||||||
|
|
||||||
|
<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>
|
||||||
|
<input placeholder="部署ID"
|
||||||
|
th:field="*{idDepartment}"
|
||||||
|
type="number"/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th class="header">部署名</th>
|
||||||
|
<td>
|
||||||
|
<input placeholder="部署名"
|
||||||
|
th:field="*{nmDepartment}"
|
||||||
|
type="text"/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="btnArea" colspan="2">
|
||||||
|
<input type="submit" value="検索"/>
|
||||||
|
</td>
|
||||||
|
<td class="btnArea" colspan="2">
|
||||||
|
<button onclick="clearInput()">クリア</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
<div class="header-spacing"></div>
|
||||||
|
<a href="showMenu">メニューに戻る</a>
|
||||||
|
<div class="header-spacing"></div>
|
||||||
|
<h1><span>検索結果</span></h1>
|
||||||
|
<div class="header-spacing"></div>
|
||||||
|
<th:block th:if="${messageInfo != null}">
|
||||||
|
<script th:inline="javascript">
|
||||||
|
alert([[${messageInfo.message}]]);
|
||||||
|
</script>
|
||||||
|
</th:block>
|
||||||
|
<div class="header-spacing"></div>
|
||||||
|
<th:block th:if="${departmentFormList != null and departmentFormList.size() > 0}">
|
||||||
|
<!-- 検索結果が1件以上ある場合 -->
|
||||||
|
<table class="table-grid table-striped table-hover">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th style="width: 100px;">部署ID</th>
|
||||||
|
<th style="width: 150px;">部署名</th>
|
||||||
|
<th style="width: 150px;">操作</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr th:each="departmentForm : ${departmentFormList}">
|
||||||
|
<td th:text="${departmentForm.idDepartment}"></td>
|
||||||
|
<td th:text="${departmentForm.nmDepartment}"></td>
|
||||||
|
<td>
|
||||||
|
<!-- 更新フォーム -->
|
||||||
|
<form action="showUpdateDepartment" method="post" style="display: inline;">
|
||||||
|
<input name="idDepartment" th:value="${departmentForm.idDepartment}" type="hidden">
|
||||||
|
<input type="submit" value="更新">
|
||||||
|
</form>
|
||||||
|
<!-- 削除フォーム -->
|
||||||
|
<form action="deleteDepartment" method="post" onsubmit="return confirm('本当に削除しますか?');"
|
||||||
|
style="display: inline;">
|
||||||
|
<input name="idDepartment" th:value="${departmentForm.idDepartment}" type="hidden">
|
||||||
|
<input type="submit" value="削除">
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</th:block>
|
||||||
|
<th:block th:if="${departmentFormList == null or departmentFormList.size() == 0}">
|
||||||
|
<!-- 検索結果が0件の場合 -->
|
||||||
|
検索結果はありません。
|
||||||
|
</th:block>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
function clearInput() {
|
||||||
|
document.getElementById('idDepartment').value = '';
|
||||||
|
document.getElementById('nmDepartment').value = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</html>
|
||||||
83
src/main/resources/templates/updateDepartmentInput.html
Normal file
83
src/main/resources/templates/updateDepartmentInput.html
Normal 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>
|
||||||
@@ -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();
|
||||||
|
|||||||
@@ -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>
|
||||||
@@ -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();
|
||||||
|
|||||||
Reference in New Issue
Block a user