Compare commits
2 Commits
o-yamamoto
...
9615afffa2
| Author | SHA1 | Date | |
|---|---|---|---|
| 9615afffa2 | |||
| cd78bee91f |
@@ -1,20 +0,0 @@
|
||||
<!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>エラーが発生しました。</h1>
|
||||
|
||||
<div>ログインからやり直してください。</div>
|
||||
<a href="login">ログイン</a>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,86 +0,0 @@
|
||||
<!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"
|
||||
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);
|
||||
|
||||
// フォームをDOMに追加
|
||||
document.body.appendChild(form);
|
||||
|
||||
form.submit();
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,66 +0,0 @@
|
||||
<!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>
|
||||
@@ -1,40 +0,0 @@
|
||||
<!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>
|
||||
<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');
|
||||
|
||||
// 動的送信用のHidden
|
||||
// 動的にFormを作成する場合は何かしら送信しないと、正しく動作しない
|
||||
const inputField = document.createElement("input");
|
||||
inputField.setAttribute("type", "hidden");
|
||||
inputField.setAttribute("value", "select");
|
||||
|
||||
form.appendChild(inputField);
|
||||
|
||||
// フォームをDOMに追加
|
||||
document.body.appendChild(form);
|
||||
|
||||
form.submit();
|
||||
}
|
||||
</script>
|
||||
</html>
|
||||
@@ -1,157 +0,0 @@
|
||||
<!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="insertEmployee"
|
||||
id="insertForm"
|
||||
method="post"
|
||||
th:object="${insertEmployeeForm}">
|
||||
|
||||
<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="empId"
|
||||
readonly="readonly"
|
||||
type="text"
|
||||
value="自動で設定されます"/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">社員名</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
name="nmEmployee"
|
||||
readonly="readonly"
|
||||
th:value="*{nmEmployee}"
|
||||
type="text"/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">社員名フリガナ</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
name="knEmployee"
|
||||
readonly="readonly"
|
||||
th:value="*{knEmployee}"
|
||||
type="text"/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">メールアドレス</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
name="mailAddress"
|
||||
readonly="readonly"
|
||||
th:value="*{mailAddress}"
|
||||
type="text"/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">パスワード</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
name="password"
|
||||
readonly="readonly"
|
||||
th:value="*{password}"
|
||||
type="password"/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">管理者権限</th>
|
||||
<td>
|
||||
<label>
|
||||
<input id="adminAuth1" name="adminAuth" onclick="return false;"
|
||||
th:checked="${insertEmployeeForm .adminAuth == 1}" type="radio"
|
||||
value="1"> 管理者権限
|
||||
</label>
|
||||
<label>
|
||||
<input id="adminAuth0" name="adminAuth" onclick="return false;"
|
||||
th:checked="${insertEmployeeForm.adminAuth == null or insertEmployeeForm.adminAuth == 0}"
|
||||
type="radio"
|
||||
value="0">
|
||||
一般権限
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">所属部署</th>
|
||||
<td>
|
||||
<label>
|
||||
<select name="idDepartment" required="required" th:field="*{idDepartment}">
|
||||
<th:block th:each="department : ${departmentFormList}">
|
||||
<th:block
|
||||
th:if="${insertEmployeeForm.idDepartment != null && department.idDepartment == insertEmployeeForm.idDepartment}">
|
||||
<option th:text="${department.nmDepartment}"
|
||||
th:value="${department.idDepartment}">
|
||||
</option>
|
||||
</th:block>
|
||||
</th:block>
|
||||
</select>
|
||||
</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', 'insertEmployeeInput');
|
||||
|
||||
// 確認画面から編集画面に戻ってきたときのフラグ(未使用)
|
||||
const inputField = document.createElement("input");
|
||||
inputField.setAttribute("type", "hidden");
|
||||
inputField.setAttribute("name", "backFlg");
|
||||
inputField.setAttribute("value", "edit");
|
||||
|
||||
form.appendChild(inputField);
|
||||
|
||||
// フォームをDOMに追加
|
||||
document.body.appendChild(form);
|
||||
|
||||
form.submit();
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,158 +0,0 @@
|
||||
<!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="insertEmployeeConfirm"
|
||||
method="post"
|
||||
th:object="${insertEmployeeForm}">
|
||||
|
||||
<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="*{nmEmployee}"
|
||||
type="text"
|
||||
/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">社員名フリガナ</th>
|
||||
<td>
|
||||
<label>
|
||||
<input maxlength="50"
|
||||
oninput="convertToKatakana(this)"
|
||||
placeholder="フリガナ"
|
||||
required="required"
|
||||
th:field="*{knEmployee}"
|
||||
type="text"
|
||||
/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">メールアドレス</th>
|
||||
<td>
|
||||
<label>
|
||||
<input maxlength="100"
|
||||
placeholder="メールアドレス"
|
||||
required="required"
|
||||
th:field="*{mailAddress}"
|
||||
type="email"
|
||||
/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">パスワード</th>
|
||||
<td>
|
||||
<label>
|
||||
<input pattern="^(?=.*?[a-zA-Z])(?=.*?\d)[a-zA-Z\d]{3,10}$"
|
||||
placeholder="パスワード"
|
||||
required="required"
|
||||
th:field="*{password}"
|
||||
type="password"
|
||||
/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- *** Chrome等のブラウザの場合自動でセットされる可能性があるので注意書きを外にも *** -->
|
||||
<tr>
|
||||
<th></th>
|
||||
<td><span
|
||||
style="font-size:8pt; font-weight:bold; color:red;">※半角英数字をそれぞれ1種類以上含む3-10文字</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">パスワード確認用</th>
|
||||
<td>
|
||||
<label>
|
||||
<input pattern="^(?=.*?[a-zA-Z])(?=.*?\d)[a-zA-Z\d]{3,10}$"
|
||||
placeholder="パスワード確認用"
|
||||
required="required"
|
||||
th:field="*{passwordConfirm}"
|
||||
type="password"
|
||||
/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">管理者権限</th>
|
||||
<td>
|
||||
<label>
|
||||
<input id="adminAuth1" name="adminAuth" th:checked="${insertEmployeeForm .adminAuth == 1}"
|
||||
type="radio"
|
||||
value="1"> 管理者権限
|
||||
</label>
|
||||
<label>
|
||||
<input id="adminAuth0" name="adminAuth"
|
||||
th:checked="${insertEmployeeForm.adminAuth == null or insertEmployeeForm.adminAuth == 0}"
|
||||
type="radio"
|
||||
value="0">
|
||||
一般権限
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th class="header">所属部署</th>
|
||||
<td>
|
||||
<label>
|
||||
<select required="required" th:field="*{idDepartment}">
|
||||
<option th:each="department : ${departmentFormList}"
|
||||
th:selected="${insertEmployeeForm.idDepartment != null && department.idDepartment == insertEmployeeForm.idDepartment}"
|
||||
th:text="${department.nmDepartment}"
|
||||
th:value="${department.idDepartment}">
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="btnArea" colspan="2">
|
||||
<input type="submit" value="登録確認"/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<a href="showMenu">メニューに戻る</a>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,40 +0,0 @@
|
||||
<!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>
|
||||
<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', 'insertEmployeeInput');
|
||||
|
||||
// 動的送信用のHidden
|
||||
// 動的にFormを作成する場合は何かしら送信しないと、正しく動作しない
|
||||
const inputField = document.createElement("input");
|
||||
inputField.setAttribute("type", "hidden");
|
||||
inputField.setAttribute("value", "select");
|
||||
|
||||
form.appendChild(inputField);
|
||||
|
||||
// フォームをDOMに追加
|
||||
document.body.appendChild(form);
|
||||
|
||||
form.submit();
|
||||
}
|
||||
</script>
|
||||
</html>
|
||||
@@ -1,63 +0,0 @@
|
||||
<!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>ログイン</h1>
|
||||
<form action="doLogin"
|
||||
method="post"
|
||||
th:object="${loginInfoForm}">
|
||||
|
||||
<div class="msgBox error" th:if="${messageError} != null">
|
||||
<span class="error" th:text="${messageError.message}"></span>
|
||||
</div>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th class="header">メールアドレス</th>
|
||||
<td style="width: 250px;">
|
||||
<input placeholder="メールアドレス"
|
||||
required="required"
|
||||
style="width: 100%;"
|
||||
th:field="*{mailAddress}"
|
||||
type="text"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th style="text-align: right;">パスワード</th>
|
||||
<td>
|
||||
<input placeholder="パスワード"
|
||||
required="required"
|
||||
style="width: 100%;"
|
||||
th:field="*{password}"
|
||||
type="password"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="btnArea" colspan="2">
|
||||
<input type="submit" value="ログイン"/>
|
||||
<button onclick="clearInput()">リセット</button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</body>
|
||||
<script type="text/javascript">
|
||||
|
||||
function clearInput() {
|
||||
document.getElementById('mailAddress').value = '';
|
||||
document.getElementById('password').value = '';
|
||||
}
|
||||
|
||||
</script>
|
||||
</html>
|
||||
@@ -1,124 +0,0 @@
|
||||
<!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>
|
||||
<table class="menuClass">
|
||||
|
||||
<tr>
|
||||
<td><a class="menuClass" href="javascript:selectEmployeeSubmit()"><i class="fas fa-search"></i> 社員検索 </a>
|
||||
</td>
|
||||
<td class="description">登録済みのユーザ一覧表示と</br>更新、削除を行います。</td>
|
||||
<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:insertEmployeeSubmit()"><i class="fas fa-plus"></i> 社員登録 </a></td>
|
||||
<td class="description">新規でユーザ追加を行います。</td>
|
||||
<td><a class="menuClass" href="javascript:insertDepartmentSubmit()"><i class="fas fa-plus"></i> 部署登録 </a>
|
||||
</td>
|
||||
<td class="description">新規で部署追加を行います。</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</body>
|
||||
|
||||
<script type="text/javascript">
|
||||
function selectEmployeeSubmit() {
|
||||
const form = document.createElement('form');
|
||||
form.setAttribute('method', 'post');
|
||||
form.setAttribute('action', 'selectEmployeeInfo');
|
||||
|
||||
// 動的送信用のHidden
|
||||
// 動的にFormを作成する場合は何かしら送信しないと、正しく動作しない
|
||||
const inputField = document.createElement("input");
|
||||
inputField.setAttribute("type", "hidden");
|
||||
inputField.setAttribute("value", "selectEmployeeInfo");
|
||||
|
||||
form.appendChild(inputField);
|
||||
|
||||
// フォームをDOMに追加
|
||||
document.body.appendChild(form);
|
||||
|
||||
form.submit();
|
||||
}
|
||||
|
||||
function selectDepartmentSubmit() {
|
||||
const form = document.createElement('form');
|
||||
form.setAttribute('method', 'post');
|
||||
form.setAttribute('action', 'selectDepartment');
|
||||
|
||||
// 動的送信用のHidden
|
||||
// 動的にFormを作成する場合は何かしら送信しないと、正しく動作しない
|
||||
const inputField = document.createElement("input");
|
||||
inputField.setAttribute("type", "hidden");
|
||||
inputField.setAttribute("value", "selectDepartment");
|
||||
|
||||
form.appendChild(inputField);
|
||||
|
||||
// フォームをDOMに追加
|
||||
document.body.appendChild(form);
|
||||
|
||||
form.submit();
|
||||
}
|
||||
|
||||
function insertEmployeeSubmit() {
|
||||
const form = document.createElement('form');
|
||||
form.setAttribute('method', 'post');
|
||||
form.setAttribute('action', 'insertEmployeeInput');
|
||||
|
||||
// 動的送信用のHidden
|
||||
// 動的にFormを作成する場合は何かしら送信しないと、正しく動作しない
|
||||
const inputField = document.createElement("input");
|
||||
inputField.setAttribute("type", "hidden");
|
||||
inputField.setAttribute("value", "insertEmployeeInput");
|
||||
|
||||
form.appendChild(inputField);
|
||||
|
||||
// フォームをDOMに追加
|
||||
document.body.appendChild(form);
|
||||
|
||||
form.submit();
|
||||
}
|
||||
|
||||
function insertDepartmentSubmit() {
|
||||
const form = document.createElement('form');
|
||||
form.setAttribute('method', 'post');
|
||||
form.setAttribute('action', 'insertDepartmentInput');
|
||||
|
||||
// 動的送信用のHidden
|
||||
// 動的にFormを作成する場合は何かしら送信しないと、正しく動作しない
|
||||
const inputField = document.createElement("input");
|
||||
inputField.setAttribute("type", "hidden");
|
||||
inputField.setAttribute("value", "insertDepartmentInput");
|
||||
|
||||
form.appendChild(inputField);
|
||||
|
||||
// フォームをDOMに追加
|
||||
document.body.appendChild(form);
|
||||
|
||||
form.submit();
|
||||
}
|
||||
</script>
|
||||
|
||||
</html>
|
||||
@@ -1,114 +0,0 @@
|
||||
<!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="half-table-grid table-striped table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 60px;">部署ID</th>
|
||||
<th style="width: 100px;">部署名</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>
|
||||
@@ -1,157 +0,0 @@
|
||||
<!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="selectEmployeeInfo"
|
||||
method="post"
|
||||
th:object="${searchConditionEmployeeForm}">
|
||||
|
||||
<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="*{idEmployee}"
|
||||
type="number"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">社員名</th>
|
||||
<td>
|
||||
<input placeholder="社員名"
|
||||
th:field="*{nmEmployee}"
|
||||
type="text"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">社員名フリガナ</th>
|
||||
<td>
|
||||
<input oninput="convertToKatakana(this)"
|
||||
placeholder="フリガナ"
|
||||
th:field="*{knEmployee}"
|
||||
type="text"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">メールアドレス</th>
|
||||
<td>
|
||||
<input placeholder="メールアドレス"
|
||||
th:field="*{mailAddress}"
|
||||
type="email"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">所属部署</th>
|
||||
<td>
|
||||
<select th:field="*{idDepartment}">
|
||||
<option value=""></option>
|
||||
<option th:each="department : ${departmentFormList}"
|
||||
th:selected="${searchConditionEmployeeForm.idDepartment != null && department.idDepartment == searchConditionEmployeeForm.idDepartment}"
|
||||
th:text="${department.nmDepartment}"
|
||||
th:value="${department.idDepartment}">
|
||||
</option>
|
||||
</select>
|
||||
</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="${employeeInfoFormList != null and employeeInfoFormList.size() > 0}">
|
||||
<!-- 検索結果が1件以上ある場合 -->
|
||||
<table class="table-grid table-striped table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 60px;">社員ID</th>
|
||||
<th style="width: 100px;">社員名</th>
|
||||
<th style="width: 150px;">フリガナ</th>
|
||||
<th style="width: 150px;">メールアドレス</th>
|
||||
<th style="width: 100px;">パスワード</th>
|
||||
<th style="width: 70px;">管理者フラグ</th>
|
||||
<th style="width: 150px;">所属部署</th>
|
||||
<th style="width: 150px;">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr th:each="employeeInfoForm : ${employeeInfoFormList}">
|
||||
<td th:text="${employeeInfoForm.idEmployee}"></td>
|
||||
<td th:text="${employeeInfoForm.nmEmployee}"></td>
|
||||
<td th:text="${employeeInfoForm.knEmployee}"></td>
|
||||
<td th:text="${employeeInfoForm.mailAddress}"></td>
|
||||
<td th:text="${employeeInfoForm.password}"></td>
|
||||
<td th:text="${employeeInfoForm.adminAuth}"></td>
|
||||
<td th:text="${employeeInfoForm.nmDepartment}"></td>
|
||||
<td>
|
||||
<!-- 更新フォーム -->
|
||||
<form action="showUpdateEmployee" method="post" style="display: inline;">
|
||||
<input name="idEmployee" th:value="${employeeInfoForm.idEmployee}" type="hidden">
|
||||
<input type="submit" value="更新">
|
||||
</form>
|
||||
<!-- 削除フォーム -->
|
||||
<form action="deleteEmployee" method="post" onsubmit="return confirm('本当に削除しますか?');"
|
||||
style="display: inline;">
|
||||
<input name="idEmployee" th:value="${employeeInfoForm.idEmployee}" type="hidden">
|
||||
<input type="submit" value="削除">
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</th:block>
|
||||
<th:block th:if="${employeeInfoFormList == null or employeeInfoFormList.size() == 0}">
|
||||
<!-- 検索結果が0件の場合 -->
|
||||
検索結果はありません。
|
||||
</th:block>
|
||||
|
||||
</body>
|
||||
<script type="text/javascript">
|
||||
|
||||
function clearInput() {
|
||||
document.getElementById('idEmployee').value = '';
|
||||
document.getElementById('nmEmployee').value = '';
|
||||
document.getElementById('knEmployee').value = '';
|
||||
document.getElementById('mailAddress').value = '';
|
||||
document.getElementById('idDepartment').selectedIndex = 0;
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
</html>
|
||||
@@ -1,88 +0,0 @@
|
||||
<!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="/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="10"
|
||||
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');
|
||||
|
||||
// 動的送信用のHidden
|
||||
// 動的にFormを作成する場合は何かしら送信しないと、正しく動作しない
|
||||
const inputField = document.createElement("input");
|
||||
inputField.setAttribute("type", "hidden");
|
||||
inputField.setAttribute("value", "selectDepartmentAll");
|
||||
|
||||
form.appendChild(inputField);
|
||||
|
||||
// フォームをDOMに追加
|
||||
document.body.appendChild(form);
|
||||
|
||||
form.submit();
|
||||
}
|
||||
|
||||
</script>
|
||||
</html>
|
||||
@@ -1,181 +0,0 @@
|
||||
<!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="/updateEmployeeResult"
|
||||
method="post"
|
||||
onsubmit="return confirm('本当によろしいですか?');"
|
||||
th:object="${updateEmployeeInfoForm}"
|
||||
>
|
||||
<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="*{idEmployee}"
|
||||
type="text"
|
||||
/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">社員名</th>
|
||||
<td>
|
||||
<label>
|
||||
<input maxlength="50"
|
||||
placeholder="社員名"
|
||||
required="required"
|
||||
th:field="*{nmEmployee}"
|
||||
type="text"
|
||||
/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">社員名フリガナ</th>
|
||||
<td>
|
||||
<label>
|
||||
<input maxlength="50"
|
||||
oninput="convertToKatakana(this)"
|
||||
placeholder="フリガナ"
|
||||
required="required"
|
||||
th:field="*{knEmployee}"
|
||||
type="text"
|
||||
/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">メールアドレス</th>
|
||||
<td>
|
||||
<label>
|
||||
<input maxlength="100"
|
||||
placeholder="メールアドレス"
|
||||
required="required"
|
||||
th:field="*{mailAddress}"
|
||||
type="email"
|
||||
/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">パスワード</th>
|
||||
<td>
|
||||
<label>
|
||||
<input pattern="^(?=.*?[a-zA-Z])(?=.*?\d)[a-zA-Z\d]{3,10}$"
|
||||
placeholder="パスワード"
|
||||
th:field="*{password}"
|
||||
type="password"
|
||||
/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- *** Chrome等のブラウザの場合自動でセットされる可能性があるので注意書きを外にも *** -->
|
||||
<tr>
|
||||
<th></th>
|
||||
<td>
|
||||
<span style="font-size:8pt;
|
||||
font-weight:bold;
|
||||
color:red;">
|
||||
※半角英数字をそれぞれ1種類以上含む3-10文字
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">パスワード確認用</th>
|
||||
<td>
|
||||
<label>
|
||||
<input pattern="^(?=.*?[a-zA-Z])(?=.*?\d)[a-zA-Z\d]{3,10}$"
|
||||
placeholder="パスワード確認用"
|
||||
th:field="*{passwordConfirm}"
|
||||
type="password"
|
||||
/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">管理者権限</th>
|
||||
<td>
|
||||
<label>
|
||||
<input id="adminAuth1" name="adminAuth" th:checked="${updateEmployeeInfoForm.adminAuth == 1}"
|
||||
type="radio"
|
||||
value="1"> 管理者権限
|
||||
</label>
|
||||
<label>
|
||||
<input id="adminAuth0" name="adminAuth"
|
||||
th:checked="${updateEmployeeInfoForm.adminAuth == null or updateEmployeeInfoForm.adminAuth == 0}"
|
||||
type="radio"
|
||||
value="0">
|
||||
一般権限
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">所属部署</th>
|
||||
<td>
|
||||
<label>
|
||||
<select required="required" th:field="*{idDepartment}">
|
||||
<option th:each="department : ${departmentFormList}"
|
||||
th:selected="${updateEmployeeInfoForm.idDepartment != null && department.idDepartment == updateEmployeeInfoForm.idDepartment}"
|
||||
th:text="${department.nmDepartment}"
|
||||
th:value="${department.idDepartment}">
|
||||
</option>
|
||||
</select>
|
||||
</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', 'selectAll');
|
||||
|
||||
// 動的送信用のHidden
|
||||
// 動的にFormを作成する場合は何かしら送信しないと、正しく動作しない
|
||||
const inputField = document.createElement("input");
|
||||
inputField.setAttribute("type", "hidden");
|
||||
inputField.setAttribute("value", "selectAll");
|
||||
|
||||
form.appendChild(inputField);
|
||||
|
||||
// フォームをDOMに追加
|
||||
document.body.appendChild(form);
|
||||
|
||||
form.submit();
|
||||
}
|
||||
|
||||
</script>
|
||||
</html>
|
||||
@@ -1,108 +0,0 @@
|
||||
<!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="updatePersonalEmployeeResult"
|
||||
method="post"
|
||||
th:object="${updatePersonalEmployeeUserForm}">
|
||||
|
||||
<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">社員名</th>
|
||||
<td>
|
||||
<input maxlength="50"
|
||||
placeholder="社員名"
|
||||
required
|
||||
th:name="nmEmployee"
|
||||
th:value="*{nmEmployee}"
|
||||
type="text"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">社員名フリガナ</th>
|
||||
<td>
|
||||
<input maxlength="50"
|
||||
name="knEmployee"
|
||||
oninput="convertToKatakana(this)"
|
||||
placeholder="フリガナ"
|
||||
required
|
||||
th:value="*{knEmployee}"
|
||||
type="text"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">メールアドレス</th>
|
||||
<td>
|
||||
<input maxlength="100"
|
||||
name="mailAddress"
|
||||
placeholder="メールアドレス"
|
||||
required
|
||||
th:value="*{mailAddress}"
|
||||
type="email"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">パスワード</th>
|
||||
<td>
|
||||
<input name="password"
|
||||
pattern="^(?=.*?[a-zA-Z])(?=.*?\d)[a-zA-Z\d]{3,10}$"
|
||||
placeholder="※更新する場合は入力"
|
||||
th:field="*{password}"
|
||||
type="password"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- *** Chrome等のブラウザの場合自動でセットされる可能性があるので注意書きを外にも *** -->
|
||||
<tr>
|
||||
<th></th>
|
||||
<td>
|
||||
<span style="font-size:8pt; font-weight:bold; color:red;">更新する場合は入力してください<br>
|
||||
※半角英数字をそれぞれ1種類以上含む3-10文字</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">パスワード確認</th>
|
||||
<td>
|
||||
<input name="passwordConfirm"
|
||||
pattern="^(?=.*?[a-zA-Z])(?=.*?\d)[a-zA-Z\d]{3,10}$"
|
||||
placeholder="※更新する場合は再入力"
|
||||
th:field="*{passwordConfirm}"
|
||||
type="password"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="btnArea" colspan="2">
|
||||
<input name="submit" type="submit" value="更新"/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<input name="idEmployee"
|
||||
th:value="*{idEmployee}"
|
||||
type="hidden"/>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,42 +0,0 @@
|
||||
<!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>
|
||||
<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', 'updatePersonalEmployeeResult');
|
||||
|
||||
// 動的送信用のHidden
|
||||
// 動的にFormを作成する場合は何かしら送信しないと、正しく動作しない
|
||||
const inputField = document.createElement("input");
|
||||
inputField.setAttribute("type", "hidden");
|
||||
inputField.setAttribute("value", "updatePersonalEmployeeResult");
|
||||
|
||||
form.appendChild(inputField);
|
||||
|
||||
// フォームをDOMに追加
|
||||
document.body.appendChild(form);
|
||||
|
||||
form.submit();
|
||||
}
|
||||
</script>
|
||||
|
||||
</html>
|
||||
@@ -57,13 +57,15 @@
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.30</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<!-- <scope>test</scope>-->
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.example.rhizome.app.domain.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class AllDepartmentInfo {
|
||||
/**
|
||||
* 課情報
|
||||
*/
|
||||
private final Division division;
|
||||
/**
|
||||
* 部情報
|
||||
*/
|
||||
private final Department department;
|
||||
/**
|
||||
* 本部情報
|
||||
*/
|
||||
private final Headquarters headquarters;
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.example.rhizome.app.domain.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 社員情報と全ての部署情報を表すモデルクラスです。
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class AllEmployeeInfo {
|
||||
/**
|
||||
* 社員情報
|
||||
*/
|
||||
private final Employee employee;
|
||||
/**
|
||||
* 課情報
|
||||
*/
|
||||
private final Division division;
|
||||
/**
|
||||
* 部情報
|
||||
*/
|
||||
private final Department department;
|
||||
/**
|
||||
* 本部情報
|
||||
*/
|
||||
private final Headquarters headquarters;
|
||||
}
|
||||
@@ -4,26 +4,18 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 部情報を表すモデルクラスです。
|
||||
* 部署情報の概念を表現するモデルクラスです。
|
||||
*/
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class Department {
|
||||
/**
|
||||
* 部ID
|
||||
*/
|
||||
private final Integer idDepartment;
|
||||
/**
|
||||
* 部名
|
||||
*/
|
||||
private final String nmDepartment;
|
||||
/**
|
||||
* 表示・非表示フラグ
|
||||
*/
|
||||
private final Integer isDisplay;
|
||||
/**
|
||||
* 部ID
|
||||
*/
|
||||
private final Integer idHeadquarters;
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
private final Integer idDepartment;
|
||||
/**
|
||||
* 部署名
|
||||
*/
|
||||
private final String nmDepartment;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
package com.example.rhizome.app.domain.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 部署情報の概念を表現するモデルクラスです。※部情報ではない
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class DepartmentInfo {
|
||||
/**
|
||||
* 本部ID
|
||||
*/
|
||||
private final Integer idHeadquarters;
|
||||
/**
|
||||
* 本部名
|
||||
*/
|
||||
private final String nmHeadquarters;
|
||||
/**
|
||||
* 部ID
|
||||
*/
|
||||
private final Integer idDepartment;
|
||||
/**
|
||||
* 部名
|
||||
*/
|
||||
private final String nmDepartment;
|
||||
/**
|
||||
* 課ID
|
||||
*/
|
||||
private final Integer idDivision;
|
||||
/**
|
||||
* 課名
|
||||
*/
|
||||
private final String nmDivision;
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.example.rhizome.app.domain.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 課を表現するモデルクラスです
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class Division {
|
||||
/**
|
||||
* 課ID
|
||||
*/
|
||||
private final Integer idDivision;
|
||||
/**
|
||||
* 課名
|
||||
*/
|
||||
private final String nmDivision;
|
||||
/**
|
||||
* 表示・非表示フラグ
|
||||
*/
|
||||
private final Integer isDisplay;
|
||||
/**
|
||||
* 部ID
|
||||
*/
|
||||
private final Integer idDepartment;
|
||||
}
|
||||
@@ -9,37 +9,33 @@ import lombok.Getter;
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class Employee {
|
||||
/**
|
||||
* 社員ID
|
||||
*/
|
||||
private final Integer idEmployee;
|
||||
/**
|
||||
* 社員名
|
||||
*/
|
||||
private final String nmEmployee;
|
||||
/**
|
||||
* 社員名カナ
|
||||
*/
|
||||
private final String knEmployee;
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
private final String mailAddress;
|
||||
/**
|
||||
* パスワード
|
||||
*/
|
||||
private final String password;
|
||||
/**
|
||||
* 入社年月日
|
||||
*/
|
||||
private final String hireDate;
|
||||
/**
|
||||
* 管理者権限
|
||||
*/
|
||||
private final Integer adminAuth;
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
private final Integer idDivision;
|
||||
/**
|
||||
* 社員ID
|
||||
*/
|
||||
private final Integer idEmployee;
|
||||
/**
|
||||
* 社員名
|
||||
*/
|
||||
private final String nmEmployee;
|
||||
/**
|
||||
* 社員名カナ
|
||||
*/
|
||||
private final String knEmployee;
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
private final String mailAddress;
|
||||
/**
|
||||
* パスワード
|
||||
*/
|
||||
private final String password;
|
||||
/**
|
||||
* 管理者権限
|
||||
*/
|
||||
private final Integer adminAuth;
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
private final Integer idDepartment;
|
||||
|
||||
}
|
||||
|
||||
@@ -16,13 +16,13 @@ import lombok.Getter;
|
||||
@AllArgsConstructor
|
||||
public class EmployeeInfo {
|
||||
|
||||
/**
|
||||
* 社員情報
|
||||
*/
|
||||
private final Employee employee;
|
||||
/**
|
||||
* 課情報
|
||||
*/
|
||||
private final Division division;
|
||||
/**
|
||||
* 社員情報
|
||||
*/
|
||||
private final Employee employee;
|
||||
/**
|
||||
* 部署名
|
||||
*/
|
||||
private final Department department;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.example.rhizome.app.domain.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 本部を表現するモデルクラスです
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class Headquarters {
|
||||
/**
|
||||
* 本部ID
|
||||
*/
|
||||
private final Integer idHeadquarters;
|
||||
/**
|
||||
* 本部名
|
||||
*/
|
||||
private final String nmHeadquarters;
|
||||
/**
|
||||
* 表示・非表示フラグ
|
||||
*/
|
||||
private final Integer isDisplay;
|
||||
}
|
||||
@@ -10,13 +10,13 @@ import lombok.Getter;
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class LoginInfo {
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
private String mailAddress;
|
||||
/**
|
||||
* パスワード
|
||||
*/
|
||||
private String password;
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
private String mailAddress;
|
||||
/**
|
||||
* パスワード
|
||||
*/
|
||||
private String password;
|
||||
|
||||
}
|
||||
|
||||
@@ -9,43 +9,43 @@ import lombok.Getter;
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class LoginUser {
|
||||
/**
|
||||
* 社員ID
|
||||
*/
|
||||
private final Integer idEmployee;
|
||||
/**
|
||||
* 社員名
|
||||
*/
|
||||
private final String nmEmployee;
|
||||
/**
|
||||
* 社員名カナ
|
||||
*/
|
||||
private final String knEmployee;
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
private final String mailAddress;
|
||||
/**
|
||||
* パスワード
|
||||
*/
|
||||
private final String password;
|
||||
/**
|
||||
* 社員ID
|
||||
*/
|
||||
private final Integer idEmployee;
|
||||
/**
|
||||
* 社員名
|
||||
*/
|
||||
private final String nmEmployee;
|
||||
/**
|
||||
* 社員名カナ
|
||||
*/
|
||||
private final String knEmployee;
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
private final String mailAddress;
|
||||
/**
|
||||
* パスワード
|
||||
*/
|
||||
private final String password;
|
||||
|
||||
/**
|
||||
* 管理者権限
|
||||
*/
|
||||
private final Integer adminAuth;
|
||||
/**
|
||||
* 管理者権限
|
||||
*/
|
||||
private final Integer adminAuth;
|
||||
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
private final Integer idDivision;
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
private final Integer idDepartment;
|
||||
|
||||
/**
|
||||
* ログインユーザが管理者か
|
||||
*
|
||||
* @return true:管理者 false:一般権限
|
||||
*/
|
||||
public boolean isAdminUser() {
|
||||
return getAdminAuth() == 1;
|
||||
}
|
||||
/**
|
||||
* ログインユーザが管理者か
|
||||
*
|
||||
* @return true:管理者 false:一般権限
|
||||
*/
|
||||
public boolean isAdminUser() {
|
||||
return getAdminAuth() == 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,13 +9,13 @@ import lombok.Getter;
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class SearchConditionDepartment {
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
private final Integer idDivision;
|
||||
/**
|
||||
* 名前
|
||||
*/
|
||||
private final String nmDivision;
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
private final Integer idDepartment;
|
||||
/**
|
||||
* 部署名
|
||||
*/
|
||||
private final String nmDepartment;
|
||||
|
||||
}
|
||||
|
||||
@@ -9,25 +9,25 @@ import lombok.Getter;
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class SearchConditionEmployee {
|
||||
/**
|
||||
* 社員ID
|
||||
*/
|
||||
private final Integer idEmployee;
|
||||
/**
|
||||
* 社員名
|
||||
*/
|
||||
private final String nmEmployee;
|
||||
/**
|
||||
* 社員名カナ
|
||||
*/
|
||||
private final String knEmployee;
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
private final String mailAddress;
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
private final Integer idDivision;
|
||||
/**
|
||||
* 社員ID
|
||||
*/
|
||||
private final Integer idEmployee;
|
||||
/**
|
||||
* 社員名
|
||||
*/
|
||||
private final String nmEmployee;
|
||||
/**
|
||||
* 社員名カナ
|
||||
*/
|
||||
private final String knEmployee;
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
private final String mailAddress;
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
private final Integer idDepartment;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.example.rhizome.app.domain.service;
|
||||
|
||||
public interface DeleteDepartment {
|
||||
void deleteDepartment(Integer idDivision);
|
||||
void deleteDepartment(Integer idDepartment);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.example.rhizome.app.domain.service;
|
||||
|
||||
public interface DeleteEmployee {
|
||||
void deleteEmployee(Integer idEmployee);
|
||||
void deleteEmployee(Integer idEmployee);
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.example.rhizome.app.domain.model.LoginInfo;
|
||||
import com.example.rhizome.app.domain.model.LoginUser;
|
||||
|
||||
public interface Login {
|
||||
LoginUser doLogin(LoginInfo loginInfo);
|
||||
LoginUser doLogin(LoginInfo loginInfo);
|
||||
|
||||
boolean canLogin(LoginInfo loginInfo);
|
||||
boolean canLogin(LoginInfo loginInfo);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.example.rhizome.app.domain.service;
|
||||
|
||||
import com.example.rhizome.app.infra.entity.DivisionEntity;
|
||||
import com.example.rhizome.app.domain.model.Department;
|
||||
|
||||
public interface RegisterDepartment {
|
||||
void registerDepartment(DivisionEntity divisionEntity);
|
||||
void registerDepartment(Department department);
|
||||
}
|
||||
|
||||
@@ -3,5 +3,5 @@ package com.example.rhizome.app.domain.service;
|
||||
import com.example.rhizome.app.domain.model.Employee;
|
||||
|
||||
public interface RegisterEmployee {
|
||||
void registerEmployee(Employee employee);
|
||||
void registerEmployee(Employee employee);
|
||||
}
|
||||
|
||||
@@ -1,43 +1,14 @@
|
||||
package com.example.rhizome.app.domain.service;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Department;
|
||||
import com.example.rhizome.app.domain.model.SearchConditionDepartment;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.example.rhizome.app.domain.model.AllDepartmentInfo;
|
||||
import com.example.rhizome.app.domain.model.Department;
|
||||
import com.example.rhizome.app.domain.model.Division;
|
||||
import com.example.rhizome.app.domain.model.Headquarters;
|
||||
import com.example.rhizome.app.domain.model.SearchConditionDepartment;
|
||||
|
||||
public interface SearchDepartment {
|
||||
List<Department> selectAll();
|
||||
|
||||
List<AllDepartmentInfo> searchAllDepartmentTable();
|
||||
|
||||
List<AllDepartmentInfo> searchAllDepartmentTable(SearchConditionDepartment searchConditionDepartment);
|
||||
|
||||
boolean searchAllDepartmentTable(
|
||||
SearchConditionDepartment searchHeadquartersTable,
|
||||
SearchConditionDepartment searchDepartmentTable,
|
||||
SearchConditionDepartment searchDivisionTable);
|
||||
|
||||
boolean searchAllDepartmentTable(
|
||||
Integer idHeadquarters,
|
||||
Integer idDepartment,
|
||||
Integer idDivision);
|
||||
|
||||
List<Headquarters> searchByHeadquarters(SearchConditionDepartment searchConditionDepartment);
|
||||
|
||||
List<Department> searchByDepartment(SearchConditionDepartment searchConditionDepartment);
|
||||
|
||||
List<Division> searchByDivision(SearchConditionDepartment searchConditionDepartment);
|
||||
|
||||
List<Department> searchByIdHeadquarters(Integer idHeadquarters);
|
||||
|
||||
List<Division> searchByIdDepartment(Integer idDepartment);
|
||||
|
||||
List<Headquarters> searchHeadquartersByIdHeadquarters(Integer idHeadquarters);
|
||||
|
||||
List<Department> searchDepartmentByIdDepartment(Integer idDepartment);
|
||||
|
||||
List<Division> searchDivisionByIdDivision(Integer idDivision);
|
||||
List<Department> searchBy(SearchConditionDepartment searchConditionDepartment);
|
||||
|
||||
List<Department> searchByWithLike(SearchConditionDepartment searchConditionDepartment);
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package com.example.rhizome.app.domain.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Employee;
|
||||
import com.example.rhizome.app.domain.model.LoginUser;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SearchEmployee {
|
||||
List<Employee> searchEmployee(String mailAddress);
|
||||
List<Employee> searchEmployee(String mailAddress);
|
||||
|
||||
List<Employee> searchEmployeeByIdDepartment(Integer idDivision);
|
||||
List<Employee> searchEmployeeByIdDepartment(Integer idDepartment);
|
||||
|
||||
LoginUser searchLoginUser(String mailAddress);
|
||||
LoginUser searchLoginUser(String mailAddress);
|
||||
|
||||
Employee searchEmployeeByIdEmployee(Integer idEmployee);
|
||||
Employee searchEmployeeByIdEmployee(Integer idEmployee);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.example.rhizome.app.domain.service;
|
||||
|
||||
import com.example.rhizome.app.domain.model.EmployeeInfo;
|
||||
import com.example.rhizome.app.domain.model.SearchConditionEmployee;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.example.rhizome.app.domain.model.AllEmployeeInfo;
|
||||
import com.example.rhizome.app.domain.model.SearchConditionEmployee;
|
||||
|
||||
public interface SearchEmployeeInfo {
|
||||
List<AllEmployeeInfo> selectAll();
|
||||
List<EmployeeInfo> selectAll();
|
||||
|
||||
List<AllEmployeeInfo> searchBy(SearchConditionEmployee searchConditionEmployee);
|
||||
List<EmployeeInfo> searchBy(SearchConditionEmployee searchConditionEmployee);
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
package com.example.rhizome.app.domain.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public interface TenureCalc {
|
||||
String tenureCalc(String hireDate);
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.example.rhizome.app.domain.service;
|
||||
|
||||
import com.example.rhizome.app.domain.model.DepartmentInfo;
|
||||
import com.example.rhizome.app.domain.model.Department;
|
||||
|
||||
public interface UpdateDepartment {
|
||||
void updateDepartment(DepartmentInfo departmentInfo);
|
||||
void updateDepartment(Department department);
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,6 @@ package com.example.rhizome.app.domain.service;
|
||||
import com.example.rhizome.app.domain.model.Employee;
|
||||
|
||||
public interface UpdateEmployee {
|
||||
void updateEmployee(Employee beforeEmployee, Employee updateEmployee);
|
||||
void updateEmployee(Employee beforeEmployee, Employee updateEmployee);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
package com.example.rhizome.app.domain.service.impl;
|
||||
|
||||
import com.example.rhizome.app.domain.service.DeleteDepartment;
|
||||
import com.example.rhizome.app.infra.repository.DepartmentRepository;
|
||||
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.DivisionRepository;
|
||||
|
||||
/**
|
||||
* Department レコード削除関連の機能を持つサービス
|
||||
*/
|
||||
@@ -14,26 +13,26 @@ import com.example.rhizome.app.infra.repository.DivisionRepository;
|
||||
@Transactional
|
||||
public class DeleteDepartmentImpl implements DeleteDepartment {
|
||||
|
||||
DivisionRepository divisionRepository;
|
||||
DepartmentRepository departmentRepository;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
*
|
||||
* @param divisionRepository DI対象
|
||||
* @param departmentRepository DI対象
|
||||
*/
|
||||
@Autowired
|
||||
public DeleteDepartmentImpl(DivisionRepository divisionRepository) {
|
||||
this.divisionRepository = divisionRepository;
|
||||
public DeleteDepartmentImpl(DepartmentRepository departmentRepository) {
|
||||
this.departmentRepository = departmentRepository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* idDivision を元に division データを削除するメソッド
|
||||
* idDepartment を元に department データを削除
|
||||
*
|
||||
* @param idDivision 削除対象のidDivision
|
||||
* @param idDepartment 削除対象のidDepartment
|
||||
*/
|
||||
public void deleteDepartment(Integer idDivision) {
|
||||
divisionRepository.deleteByIdDivision(idDivision);
|
||||
public void deleteDepartment(Integer idDepartment) {
|
||||
departmentRepository.deleteById(idDepartment);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
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.DeleteEmployee;
|
||||
import com.example.rhizome.app.infra.repository.EmployeeRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* Employee レコード削除関連の機能を持つサービス
|
||||
@@ -14,20 +13,21 @@ import com.example.rhizome.app.infra.repository.EmployeeRepository;
|
||||
@Transactional
|
||||
public class DeleteEmployeeImpl implements DeleteEmployee {
|
||||
|
||||
EmployeeRepository employeeRepository;
|
||||
EmployeeRepository employeeRepository;
|
||||
|
||||
@Autowired
|
||||
public DeleteEmployeeImpl(EmployeeRepository employeeRepository) {
|
||||
this.employeeRepository = employeeRepository;
|
||||
}
|
||||
@Autowired
|
||||
public DeleteEmployeeImpl(EmployeeRepository employeeRepository) {
|
||||
this.employeeRepository = employeeRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* idEmployee を元に employee データを削除するメソッド
|
||||
*
|
||||
* @param idEmployee 削除対象のidEmployee
|
||||
*/
|
||||
public void deleteEmployee(Integer idEmployee) {
|
||||
employeeRepository.deleteById(idEmployee);
|
||||
}
|
||||
|
||||
/**
|
||||
* idEmployee を元に employee データを削除
|
||||
*
|
||||
* @param idEmployee 削除対象のidEmployee
|
||||
*/
|
||||
public void deleteEmployee(Integer idEmployee) {
|
||||
employeeRepository.deleteById(idEmployee);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
package com.example.rhizome.app.domain.service.impl;
|
||||
|
||||
|
||||
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;
|
||||
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.RegisterDepartment;
|
||||
import com.example.rhizome.app.infra.entity.DepartmentEntity;
|
||||
import com.example.rhizome.app.infra.entity.DivisionEntity;
|
||||
import com.example.rhizome.app.infra.entity.HeadquartersEntity;
|
||||
import com.example.rhizome.app.infra.repository.DepartmentRepository;
|
||||
import com.example.rhizome.app.infra.repository.DivisionRepository;
|
||||
import com.example.rhizome.app.infra.repository.HeadquartersRepository;
|
||||
|
||||
/**
|
||||
* Department テーブルの登録系の機能を集約させるサービスクラスです。
|
||||
*/
|
||||
@@ -19,66 +16,24 @@ import com.example.rhizome.app.infra.repository.HeadquartersRepository;
|
||||
@Transactional
|
||||
public class RegisterDepartmentImpl implements RegisterDepartment {
|
||||
|
||||
DepartmentRepository departmentRepository;
|
||||
DivisionRepository divisionRepository;
|
||||
HeadquartersRepository headquartersRepository;
|
||||
DepartmentRepository departmentRepository;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
*
|
||||
* @param departmentRepository DI対象
|
||||
* @param divisionRepository DI対象
|
||||
* @param headquartersRepository DI対象
|
||||
*/
|
||||
@Autowired
|
||||
public RegisterDepartmentImpl(DepartmentRepository departmentRepository,
|
||||
DivisionRepository divisionRepository,
|
||||
HeadquartersRepository headquartersRepository) {
|
||||
this.departmentRepository = departmentRepository;
|
||||
this.divisionRepository = divisionRepository;
|
||||
this.headquartersRepository = headquartersRepository;
|
||||
}
|
||||
/**
|
||||
* コンストラクタ
|
||||
*
|
||||
* @param departmentRepository DI対象
|
||||
*/
|
||||
@Autowired
|
||||
public RegisterDepartmentImpl(DepartmentRepository departmentRepository) {
|
||||
this.departmentRepository = departmentRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* division,department,headquartersインスタンスの内容を登録する
|
||||
*
|
||||
* @param divisionEntity 登録対象のデータ
|
||||
* @param departmentEntity 登録対象のデータ
|
||||
* @param headquartersEntity 登録対象のデータ
|
||||
*/
|
||||
public void registerDepartment(DivisionEntity divisionEntity) {
|
||||
DepartmentEntity departmentEntity = divisionEntity.getDepartment();
|
||||
HeadquartersEntity headquartersEntity = divisionEntity.getDepartment().getHeadquarters();
|
||||
HeadquartersEntity originHeadquartersEntity = headquartersRepository.findByNmHeadquarters(
|
||||
divisionEntity.getDepartment().getHeadquarters().getNmHeadquarters());
|
||||
if (originHeadquartersEntity != null) {
|
||||
headquartersEntity = originHeadquartersEntity;
|
||||
} else {
|
||||
headquartersEntity = new HeadquartersEntity();
|
||||
headquartersEntity.setNmHeadquarters(
|
||||
divisionEntity.getDepartment()
|
||||
.getHeadquarters()
|
||||
.getNmHeadquarters());
|
||||
}
|
||||
|
||||
DepartmentEntity originDepartmentEntity = departmentRepository.findByHeadquartersAndNmDepartment(
|
||||
originHeadquartersEntity,
|
||||
divisionEntity.getDepartment().getNmDepartment());
|
||||
if (originDepartmentEntity != null) {
|
||||
departmentEntity = originDepartmentEntity;
|
||||
} else {
|
||||
departmentEntity = new DepartmentEntity();
|
||||
departmentEntity.setNmDepartment(
|
||||
divisionEntity.getDepartment()
|
||||
.getNmDepartment());
|
||||
}
|
||||
|
||||
divisionEntity.setIsDisplay(0);
|
||||
departmentEntity.setIsDisplay(0);
|
||||
headquartersEntity.setIsDisplay(0);
|
||||
|
||||
departmentEntity.setHeadquarters(headquartersEntity);
|
||||
divisionEntity.setDepartment(departmentEntity);
|
||||
divisionRepository.save(divisionEntity);
|
||||
}
|
||||
/**
|
||||
* department インスタンスの内容を登録する
|
||||
*
|
||||
* @param department 登録対象のデータ
|
||||
*/
|
||||
public void registerDepartment(Department department) {
|
||||
departmentRepository.save(DepartmentEntity.convertFrom(department));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
package com.example.rhizome.app.domain.service.impl;
|
||||
|
||||
|
||||
import com.example.rhizome.app.domain.model.Employee;
|
||||
import com.example.rhizome.app.domain.service.RegisterEmployee;
|
||||
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||
import com.example.rhizome.app.infra.repository.EmployeeRepository;
|
||||
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.Employee;
|
||||
import com.example.rhizome.app.domain.service.RegisterEmployee;
|
||||
import com.example.rhizome.app.infra.entity.InsertEmployeeEntity;
|
||||
import com.example.rhizome.app.infra.repository.EmployeeRepository;
|
||||
|
||||
/**
|
||||
* Employee テーブルの登録系の機能を集約させるサービスクラスです。
|
||||
*/
|
||||
@@ -30,6 +29,6 @@ public class RegisterEmployeeImpl implements RegisterEmployee {
|
||||
* @param employee 登録対象のデータ
|
||||
*/
|
||||
public void registerEmployee(Employee employee) {
|
||||
employeeRepository.save(InsertEmployeeEntity.convertFrom(employee));
|
||||
employeeRepository.save(EmployeeEntity.convertFrom(employee));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +1,17 @@
|
||||
package com.example.rhizome.app.domain.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Department;
|
||||
import com.example.rhizome.app.domain.model.SearchConditionDepartment;
|
||||
import com.example.rhizome.app.domain.service.SearchDepartment;
|
||||
import com.example.rhizome.app.infra.entity.DepartmentEntity;
|
||||
import com.example.rhizome.app.infra.repository.DepartmentRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.example.rhizome.app.domain.model.AllDepartmentInfo;
|
||||
import com.example.rhizome.app.domain.model.Department;
|
||||
import com.example.rhizome.app.domain.model.Division;
|
||||
import com.example.rhizome.app.domain.model.Headquarters;
|
||||
import com.example.rhizome.app.domain.model.SearchConditionDepartment;
|
||||
import com.example.rhizome.app.domain.service.SearchDepartment;
|
||||
import com.example.rhizome.app.infra.entity.DepartmentEntity;
|
||||
import com.example.rhizome.app.infra.entity.DepartmentInfoEntity;
|
||||
import com.example.rhizome.app.infra.entity.DivisionEntity;
|
||||
import com.example.rhizome.app.infra.entity.HeadquartersEntity;
|
||||
import com.example.rhizome.app.infra.repository.DepartmentInfoRepository;
|
||||
import com.example.rhizome.app.infra.repository.DepartmentRepository;
|
||||
import com.example.rhizome.app.infra.repository.DivisionRepository;
|
||||
import com.example.rhizome.app.infra.repository.HeadquartersRepository;
|
||||
import com.example.rhizome.app.infra.repository.RegisterDepartmentRepository;
|
||||
import com.example.rhizome.app.infra.repository.RegisterDivisionRepository;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 部署情報検索系の機能を集約させるサービスクラスです。
|
||||
@@ -30,218 +19,64 @@ import com.example.rhizome.app.infra.repository.RegisterDivisionRepository;
|
||||
@Service
|
||||
@Transactional
|
||||
public class SearchDepartmentImpl implements SearchDepartment {
|
||||
DivisionRepository divisionRepository;
|
||||
DepartmentRepository departmentRepository;
|
||||
HeadquartersRepository headquartersRepository;
|
||||
DepartmentInfoRepository departmentInfoRepository;
|
||||
RegisterDepartmentRepository registerDepartmentRepository;
|
||||
RegisterDivisionRepository registerDivisionRepository;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
*
|
||||
* @param divisionRepository DI対象
|
||||
* @param departmentRepository DI対象
|
||||
* @param headquartersRepository DI対象
|
||||
* @param departmentInfoRepository DI対象
|
||||
* @param RegisterDepartmentRepository DI対象
|
||||
* @param RegisterDivisionRepository DI対象
|
||||
*/
|
||||
@Autowired
|
||||
public SearchDepartmentImpl(
|
||||
DepartmentRepository departmentRepository, DivisionRepository divisionRepository,
|
||||
HeadquartersRepository headquartersRepository, DepartmentInfoRepository departmentInfoRepository,
|
||||
RegisterDepartmentRepository registerDepartmentRepository,
|
||||
RegisterDivisionRepository registerDivisionRepository) {
|
||||
this.departmentRepository = departmentRepository;
|
||||
this.divisionRepository = divisionRepository;
|
||||
this.headquartersRepository = headquartersRepository;
|
||||
this.departmentInfoRepository = departmentInfoRepository;
|
||||
this.registerDepartmentRepository = registerDepartmentRepository;
|
||||
this.registerDivisionRepository = registerDivisionRepository;
|
||||
}
|
||||
DepartmentRepository departmentRepository;
|
||||
|
||||
/**
|
||||
* 部署情報を全件取得する
|
||||
*
|
||||
* @return 取得した部署情報レコード全件
|
||||
*/
|
||||
public List<AllDepartmentInfo> searchAllDepartmentTable() {
|
||||
return DepartmentInfoEntity.createDepartmentInfoList(departmentInfoRepository.searchAllDepartmentTable());
|
||||
}
|
||||
/**
|
||||
* コンストラクタ
|
||||
*
|
||||
* @param departmentRepository DI対象
|
||||
*/
|
||||
@Autowired
|
||||
public SearchDepartmentImpl(DepartmentRepository departmentRepository) {
|
||||
this.departmentRepository = departmentRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* 課の条件を基に部署情報を全件取得する
|
||||
* @param SearchConditionDepartment 検索条件
|
||||
* @return 検索結果のレコード
|
||||
*/
|
||||
public List<AllDepartmentInfo> searchAllDepartmentTable(SearchConditionDepartment searchConditionDepartment) {
|
||||
return DepartmentInfoEntity.AfterSearchCreateDepartmentInfoList(
|
||||
departmentInfoRepository.findAll(Specification
|
||||
.where(DepartmentInfoRepository.idDivisionEqual(searchConditionDepartment.getIdDivision()))
|
||||
.and(DepartmentInfoRepository.nmDivisionEqual(searchConditionDepartment.getNmDivision()))));
|
||||
}
|
||||
/**
|
||||
* 部署情報を全件取得する
|
||||
*
|
||||
* @return 取得した部署情報レコード全件
|
||||
*/
|
||||
public List<Department> selectAll() {
|
||||
return DepartmentEntity.createDepartmentList(departmentRepository.findAll());
|
||||
}
|
||||
|
||||
/**
|
||||
* 三つの部署の名前を基に部署情報を取得する→重複チェック
|
||||
* @param SearchConditionDepartment searchHeadquartersTable 検索条件
|
||||
* @param SearchConditionDepartment searchDepartmentTable 検索条件
|
||||
* @param SearchConditionDepartment searchDivisionTable 検索条件
|
||||
* @return 重複があればtrue
|
||||
* @return 重複が無ければfalse
|
||||
*/
|
||||
public boolean searchAllDepartmentTable(
|
||||
SearchConditionDepartment searchHeadquartersTable,
|
||||
SearchConditionDepartment searchDepartmentTable,
|
||||
SearchConditionDepartment searchDivisionTable) {
|
||||
/**
|
||||
* searchConditionDepartment の情報を元に Department のレコードを取得
|
||||
*
|
||||
* @param searchConditionDepartment 検索条件
|
||||
* @return 検索結果のレコード
|
||||
*/
|
||||
public List<Department> searchBy(SearchConditionDepartment searchConditionDepartment) {
|
||||
// 動的に検索条件を絞り込む
|
||||
// Specification は Criteria API の Predicate をラップしたもの
|
||||
return DepartmentEntity
|
||||
.createDepartmentList(
|
||||
departmentRepository.findAll(Specification
|
||||
.where(DepartmentRepository.idDepartmentEqual(searchConditionDepartment.getIdDepartment()))
|
||||
.and(DepartmentRepository.nmDepartmentEqual(searchConditionDepartment.getNmDepartment()))
|
||||
)
|
||||
);
|
||||
|
||||
if (departmentInfoRepository.searchAllDepartmentTable(
|
||||
searchHeadquartersTable.getNmDivision(),
|
||||
searchDepartmentTable.getNmDivision(),
|
||||
searchDivisionTable.getNmDivision()).isEmpty()) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 三つの部署のIDを基に部署情報を取得する→重複チェック
|
||||
* @param Integer idHeadquarters 検索条件
|
||||
* @param Integer idDepartment 検索条件
|
||||
* @param Integer idDivision 検索条件
|
||||
* @return 重複があればtrue
|
||||
* @return 重複が無ければfalse
|
||||
*/
|
||||
public boolean searchAllDepartmentTable(
|
||||
Integer idHeadquarters,
|
||||
Integer idDepartment,
|
||||
Integer idDivision) {
|
||||
/**
|
||||
* searchConditionDepartment の情報を元に Department のレコードを取得
|
||||
* 部分一致検索
|
||||
*
|
||||
* @param searchConditionDepartment 検索条件
|
||||
* @return 検索結果のレコード
|
||||
*/
|
||||
public List<Department> searchByWithLike(SearchConditionDepartment searchConditionDepartment) {
|
||||
// 動的に検索条件を絞り込む
|
||||
// Specification は Criteria API の Predicate をラップしたもの
|
||||
return DepartmentEntity
|
||||
.createDepartmentList(
|
||||
departmentRepository.findAll(Specification
|
||||
.where(DepartmentRepository.idDepartmentEqual(searchConditionDepartment.getIdDepartment()))
|
||||
.and(DepartmentRepository.nmDepartmentLike(searchConditionDepartment.getNmDepartment()))
|
||||
)
|
||||
);
|
||||
|
||||
if (departmentInfoRepository.searchAllDepartmentTable(
|
||||
idHeadquarters,
|
||||
idDepartment,
|
||||
idDivision).isEmpty()) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* searchConditionDepartment の情報を元に Headquarters のレコードを取得
|
||||
*
|
||||
* @param searchConditionDepartment 検索条件
|
||||
* @return 検索結果のレコード
|
||||
*/
|
||||
public List<Headquarters> searchByHeadquarters(SearchConditionDepartment searchConditionDepartment) {
|
||||
|
||||
return HeadquartersEntity
|
||||
.createHeadquartersList(
|
||||
headquartersRepository.findAll(Specification
|
||||
.where(HeadquartersRepository
|
||||
.idHeadquartersEqual(searchConditionDepartment.getIdDivision()))
|
||||
.and(HeadquartersRepository
|
||||
.nmHeadquartersEqual(searchConditionDepartment.getNmDivision()))));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* searchConditionDepartment の情報を元に Department のレコードを取得
|
||||
*
|
||||
* @param searchConditionDepartment 検索条件
|
||||
* @return 検索結果のレコード
|
||||
*/
|
||||
public List<Department> searchByDepartment(SearchConditionDepartment searchConditionDepartment) {
|
||||
// 動的に検索条件を絞り込む
|
||||
// // Specification は Criteria API //の Predicate をラップしたもの
|
||||
return DepartmentEntity
|
||||
.createDepartmentList(
|
||||
departmentRepository.findAll(Specification
|
||||
.where(DepartmentRepository
|
||||
.idDepartmentEqual(searchConditionDepartment.getIdDivision()))
|
||||
.and(DepartmentRepository
|
||||
.nmDepartmentEqual(searchConditionDepartment.getNmDivision()))));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* searchConditionDepartment の情報を元に Division のレコードを取得
|
||||
*
|
||||
* @param searchConditionDepartment 検索条件
|
||||
* @return 検索結果のレコード
|
||||
*/
|
||||
public List<Division> searchByDivision(SearchConditionDepartment searchConditionDepartment) {
|
||||
// 動的に検索条件を絞り込む
|
||||
// // Specification は Criteria AP//I の Predicate をラップしたもの
|
||||
return DivisionEntity
|
||||
.createDivisionList(
|
||||
divisionRepository.findAll(Specification
|
||||
.where(DivisionRepository.idDivisionEqual(searchConditionDepartment.getIdDivision()))
|
||||
.and(DivisionRepository.nmDivisionEqual(searchConditionDepartment.getNmDivision()))));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* idHeadquarters の情報を元に Department のレコードを取得
|
||||
*
|
||||
* @param Integer idHeadquarters 検索条件
|
||||
* @return 検索結果のレコード
|
||||
*/
|
||||
public List<Department> searchByIdHeadquarters(Integer idHeadquarters) {
|
||||
registerDepartmentRepository.findAll(Specification
|
||||
.where(RegisterDepartmentRepository.idHeadquartersEqual(idHeadquarters)));
|
||||
|
||||
return DepartmentEntity
|
||||
.createDepartmentListBy(registerDepartmentRepository.findAll(Specification
|
||||
.where(RegisterDepartmentRepository.idHeadquartersEqual(idHeadquarters))));
|
||||
}
|
||||
|
||||
/**
|
||||
* idDepartment の情報を元に Division のレコードを取得
|
||||
*
|
||||
* @param Integer idDepartment 検索条件
|
||||
* @return 検索結果のレコード
|
||||
*/
|
||||
public List<Division> searchByIdDepartment(Integer idDepartment) {
|
||||
return DivisionEntity
|
||||
.createRegisterDivisionList(registerDivisionRepository.findAll(Specification
|
||||
.where(RegisterDivisionRepository.idDepartmentEqual(idDepartment))));
|
||||
}
|
||||
|
||||
/**
|
||||
* idHeadquarters の情報を元に Headquarters のレコードを取得
|
||||
*
|
||||
* @param Integer idHeadquarters 検索条件
|
||||
* @return 検索結果のレコード
|
||||
*/
|
||||
public List<Headquarters> searchHeadquartersByIdHeadquarters(Integer idHeadquarters) {
|
||||
return HeadquartersEntity
|
||||
.createHeadquartersList(headquartersRepository.findAll(Specification
|
||||
.where(HeadquartersRepository.idHeadquartersEqual(idHeadquarters))));
|
||||
}
|
||||
|
||||
/**
|
||||
* idDepartment の情報を元に Department のレコードを取得
|
||||
*
|
||||
* @param Integer idDepartment 検索条件
|
||||
* @return 検索結果のレコード
|
||||
*/
|
||||
public List<Department> searchDepartmentByIdDepartment(Integer idDepartment) {
|
||||
return DepartmentEntity
|
||||
.createDepartmentList(departmentRepository.findAll(Specification
|
||||
.where(DepartmentRepository.idDepartmentEqual(idDepartment))));
|
||||
}
|
||||
|
||||
/**
|
||||
* idDivision の情報を元に Division のレコードを取得
|
||||
*
|
||||
* @param Integer idDivision 検索条件
|
||||
* @return 検索結果のレコード
|
||||
*/
|
||||
public List<Division> searchDivisionByIdDivision(Integer idDivision) {
|
||||
return DivisionEntity
|
||||
.createDivisionList(divisionRepository.findAll(Specification
|
||||
.where(DivisionRepository.idDivisionEqual(idDivision))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
package com.example.rhizome.app.domain.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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.Employee;
|
||||
import com.example.rhizome.app.domain.model.LoginUser;
|
||||
import com.example.rhizome.app.domain.service.SearchEmployee;
|
||||
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||
import com.example.rhizome.app.infra.repository.EmployeeRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Employee テーブル検索系の機能を集約させるサービスクラスです。
|
||||
@@ -19,52 +18,53 @@ import com.example.rhizome.app.infra.repository.EmployeeRepository;
|
||||
@Transactional
|
||||
public class SearchEmployeeImpl implements SearchEmployee {
|
||||
|
||||
EmployeeRepository employeeRepository;
|
||||
EmployeeRepository employeeRepository;
|
||||
|
||||
@Autowired
|
||||
public SearchEmployeeImpl(EmployeeRepository employeeRepository) {
|
||||
this.employeeRepository = employeeRepository;
|
||||
}
|
||||
@Autowired
|
||||
public SearchEmployeeImpl(EmployeeRepository employeeRepository) {
|
||||
this.employeeRepository = employeeRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* mailAddress を元に Employee Table を検索します。
|
||||
*
|
||||
* @param mailAddress 検索対象の mailAddress
|
||||
* @return Table から取得したレコードの情報
|
||||
*/
|
||||
public List<Employee> searchEmployee(String mailAddress) {
|
||||
return EmployeeEntity.createEmployeeList(employeeRepository.findByMailAddress(mailAddress).stream().toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* mailAddress を元に ログイン者の情報 を検索します。
|
||||
*
|
||||
* @param mailAddress 検索対象の mailAddress
|
||||
* @return login者の情報
|
||||
*/
|
||||
public LoginUser searchLoginUser(String mailAddress) {
|
||||
return employeeRepository.findByMailAddress(mailAddress).orElse(new EmployeeEntity()).createLoginUser();
|
||||
}
|
||||
/**
|
||||
* mailAddress を元に Employee Table を検索します。
|
||||
*
|
||||
* @param mailAddress 検索対象の mailAddress
|
||||
* @return Table から取得したレコードの情報
|
||||
*/
|
||||
public List<Employee> searchEmployee(String mailAddress) {
|
||||
return EmployeeEntity.createEmployeeList(employeeRepository.findByMailAddress(mailAddress).stream().toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* idEmployee を元に Employee Table を検索します。
|
||||
*
|
||||
* @param idEmployee 検索対象の idEmployee
|
||||
* @return Table から取得したレコードの情報
|
||||
*/
|
||||
public Employee searchEmployeeByIdEmployee(Integer idEmployee) {
|
||||
return EmployeeEntity
|
||||
.createEmployee(employeeRepository.findByIdEmployee(idEmployee).orElse(new EmployeeEntity()));
|
||||
}
|
||||
/**
|
||||
* mailAddress を元に ログイン者の情報 を検索します。
|
||||
*
|
||||
* @param mailAddress 検索対象の mailAddress
|
||||
* @return login者の情報
|
||||
*/
|
||||
public LoginUser searchLoginUser(String mailAddress) {
|
||||
return employeeRepository.findByMailAddress(mailAddress).orElse(new EmployeeEntity()).createLoginUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* idDivision を元に Employee Table を検索します。
|
||||
*
|
||||
* @param idDivision 本部ID
|
||||
* @return Table から取得したレコードの情報
|
||||
*/
|
||||
@Override
|
||||
public List<Employee> searchEmployeeByIdDepartment(Integer idDivision) {
|
||||
return EmployeeEntity.createEmployeeList(employeeRepository.findByDivision_idDivision(idDivision));
|
||||
}
|
||||
/**
|
||||
* idEmployee を元に Employee Table を検索します。
|
||||
*
|
||||
* @param idEmployee 検索対象の idEmployee
|
||||
* @return Table から取得したレコードの情報
|
||||
*/
|
||||
public Employee searchEmployeeByIdEmployee(Integer idEmployee) {
|
||||
return EmployeeEntity.createEmployee(employeeRepository.findByIdEmployee(idEmployee).orElse(new EmployeeEntity()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* idDepartment を元に Employee Table を検索します。
|
||||
*
|
||||
* @param idDepartment 部署ID
|
||||
* @return Table から取得したレコードの情報
|
||||
*/
|
||||
@Override
|
||||
public List<Employee> searchEmployeeByIdDepartment(Integer idDepartment) {
|
||||
return EmployeeEntity.createEmployeeList(employeeRepository.findByIdDepartment(idDepartment));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
package com.example.rhizome.app.domain.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.example.rhizome.app.domain.model.EmployeeInfo;
|
||||
import com.example.rhizome.app.domain.model.SearchConditionEmployee;
|
||||
import com.example.rhizome.app.domain.service.SearchEmployeeInfo;
|
||||
import com.example.rhizome.app.infra.entity.EmployeeDepartmentEntity;
|
||||
import com.example.rhizome.app.infra.repository.EmployeeInfoRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.example.rhizome.app.domain.model.AllEmployeeInfo;
|
||||
import com.example.rhizome.app.domain.model.SearchConditionEmployee;
|
||||
import com.example.rhizome.app.domain.service.SearchEmployeeInfo;
|
||||
import com.example.rhizome.app.infra.entity.EmployeeDepartmentEntity;
|
||||
import com.example.rhizome.app.infra.repository.EmployeeInfoRepository;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* SearchEmployeeInfoImpl (employee join department) 検索系の機能を集約させるサービスクラスです
|
||||
@@ -20,44 +19,44 @@ import com.example.rhizome.app.infra.repository.EmployeeInfoRepository;
|
||||
@Transactional
|
||||
public class SearchEmployeeInfoImpl implements SearchEmployeeInfo {
|
||||
|
||||
EmployeeInfoRepository employeeInfoRepository;
|
||||
EmployeeInfoRepository employeeInfoRepository;
|
||||
|
||||
@Autowired
|
||||
public SearchEmployeeInfoImpl(EmployeeInfoRepository employeeInfoRepository) {
|
||||
this.employeeInfoRepository = employeeInfoRepository;
|
||||
}
|
||||
@Autowired
|
||||
public SearchEmployeeInfoImpl(EmployeeInfoRepository employeeInfoRepository) {
|
||||
this.employeeInfoRepository = employeeInfoRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* EmployeeInfo (employee join division join department join headquarters) のレコードを全件取得
|
||||
*
|
||||
* @return 取得したレコード全件
|
||||
*/
|
||||
public List<AllEmployeeInfo> selectAll() {
|
||||
|
||||
return EmployeeDepartmentEntity.createEmployeeInfoList(employeeInfoRepository.findAlltable());
|
||||
/**
|
||||
* EmployeeInfo (employee join department) のレコードを全件取得
|
||||
*
|
||||
* @return 取得したレコード全件
|
||||
*/
|
||||
public List<EmployeeInfo> selectAll() {
|
||||
|
||||
}
|
||||
return EmployeeDepartmentEntity.createEmployeeInfoList(employeeInfoRepository.findAll());
|
||||
|
||||
/**
|
||||
* SearchConditionEmployee の情報を元に
|
||||
* EmployeeInfo (employee join division join department join headquarters)
|
||||
* のレコードを取得
|
||||
*
|
||||
* @param searchConditionEmployee 検索条件
|
||||
* @return 検索結果のレコードリスト
|
||||
*/
|
||||
public List<AllEmployeeInfo> searchBy(SearchConditionEmployee searchConditionEmployee) {
|
||||
// 動的に検索条件を絞り込む
|
||||
// Specification は Criteria API の Predicate をラップしたもの
|
||||
}
|
||||
|
||||
return EmployeeDepartmentEntity
|
||||
.AfterSearchCreateEmployeeInfoList(
|
||||
employeeInfoRepository.findAll(Specification
|
||||
.where(EmployeeInfoRepository.idEmployeeEqual(searchConditionEmployee.getIdEmployee()))
|
||||
.and(EmployeeInfoRepository.nmEmployeeEqual(searchConditionEmployee.getNmEmployee()))
|
||||
.and(EmployeeInfoRepository.knEmployeeEqual(searchConditionEmployee.getKnEmployee()))
|
||||
.and(EmployeeInfoRepository.mailAddressEqual(searchConditionEmployee.getMailAddress()))
|
||||
.and(EmployeeInfoRepository.idDivisionEqual(searchConditionEmployee.getIdDivision()))));
|
||||
/**
|
||||
* SearchConditionEmployee の情報を元に EmployeeInfo (employee join department) のレコードを取得
|
||||
*
|
||||
* @param searchConditionEmployee 検索条件
|
||||
* @return 検索結果のレコードリスト
|
||||
*/
|
||||
public List<EmployeeInfo> searchBy(SearchConditionEmployee searchConditionEmployee) {
|
||||
// 動的に検索条件を絞り込む
|
||||
// Specification は Criteria API の Predicate をラップしたもの
|
||||
return EmployeeDepartmentEntity
|
||||
.createEmployeeInfoList(
|
||||
employeeInfoRepository.findAll(Specification
|
||||
.where(EmployeeInfoRepository.idEmployeeEqual(searchConditionEmployee.getIdEmployee()))
|
||||
.and(EmployeeInfoRepository.nmEmployeeEqual(searchConditionEmployee.getNmEmployee()))
|
||||
.and(EmployeeInfoRepository.knEmployeeEqual(searchConditionEmployee.getKnEmployee()))
|
||||
.and(EmployeeInfoRepository.mailAddressEqual(searchConditionEmployee.getMailAddress()))
|
||||
.and(EmployeeInfoRepository.idDepartmentEqual(searchConditionEmployee.getIdDepartment()))
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
package com.example.rhizome.app.domain.service.impl;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.Period;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.example.rhizome.app.domain.service.TenureCalc;
|
||||
|
||||
@Service
|
||||
public class TenureCalucImpl implements TenureCalc {
|
||||
/**
|
||||
* hireDate をもとに勤続年数を計算
|
||||
*
|
||||
* @param String hireDate
|
||||
* @return 計算結果の勤続年数
|
||||
*/
|
||||
public String tenureCalc(String hireDate) {
|
||||
String tenure;
|
||||
LocalDate hiredate = LocalDate.parse(hireDate);
|
||||
LocalDate today = LocalDate.now();
|
||||
Period period = Period.between(hiredate, today);
|
||||
|
||||
if (period.getYears() <= 0 && period.getMonths() <= 0) {
|
||||
tenure = "0年0ヶ月";
|
||||
return tenure;
|
||||
} else {
|
||||
tenure = period.getYears() + "年" + period.getMonths() + "ヶ月";
|
||||
return tenure;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,13 @@
|
||||
package com.example.rhizome.app.domain.service.impl;
|
||||
|
||||
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;
|
||||
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.DepartmentInfo;
|
||||
import com.example.rhizome.app.domain.service.UpdateDepartment;
|
||||
import com.example.rhizome.app.infra.entity.DepartmentEntity;
|
||||
import com.example.rhizome.app.infra.entity.DivisionEntity;
|
||||
import com.example.rhizome.app.infra.entity.HeadquartersEntity;
|
||||
import com.example.rhizome.app.infra.repository.DivisionRepository;
|
||||
|
||||
/**
|
||||
* department の更新系の機能を集約させるサービスクラスです。
|
||||
*/
|
||||
@@ -18,33 +15,21 @@ import com.example.rhizome.app.infra.repository.DivisionRepository;
|
||||
@Transactional
|
||||
public class UpdateDepartmentImpl implements UpdateDepartment {
|
||||
|
||||
DivisionRepository divisionRepository;
|
||||
DepartmentRepository departmentRepository;
|
||||
|
||||
@Autowired
|
||||
public UpdateDepartmentImpl(DivisionRepository divisionRepository) {
|
||||
this.divisionRepository = divisionRepository;
|
||||
}
|
||||
@Autowired
|
||||
public UpdateDepartmentImpl(DepartmentRepository departmentRepository) {
|
||||
this.departmentRepository = departmentRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* departmentInfo の情報を元に
|
||||
* division table(division join department join headquarters) のレコードを更新する
|
||||
*
|
||||
* @param departmentInfo 更新のデータ
|
||||
*/
|
||||
public void updateDepartment(DepartmentInfo departmentInfo) {
|
||||
DivisionEntity divisionEntity = DivisionEntity.convertFrom(departmentInfo);
|
||||
DepartmentEntity departmentEntity = divisionEntity.getDepartment();
|
||||
HeadquartersEntity headquartersEntity = divisionEntity.getDepartment().getHeadquarters();
|
||||
departmentEntity.setNmDepartment(
|
||||
divisionEntity.getDepartment()
|
||||
.getNmDepartment());
|
||||
headquartersEntity.setNmHeadquarters(
|
||||
divisionEntity.getDepartment()
|
||||
.getHeadquarters()
|
||||
.getNmHeadquarters());
|
||||
departmentEntity.setHeadquarters(headquartersEntity);
|
||||
divisionEntity.setDepartment(departmentEntity);
|
||||
divisionRepository.save(divisionEntity);
|
||||
}
|
||||
/**
|
||||
* department の情報を元に department table のレコードを更新する
|
||||
*
|
||||
* @param department 更新のデータ
|
||||
*/
|
||||
public void updateDepartment(Department department) {
|
||||
|
||||
departmentRepository.save(DepartmentEntity.convertFrom(department));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
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.Employee;
|
||||
import com.example.rhizome.app.domain.service.UpdateEmployee;
|
||||
import com.example.rhizome.app.infra.entity.InsertEmployeeEntity;
|
||||
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||
import com.example.rhizome.app.infra.repository.EmployeeRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* employee の更新系の機能を集約させるサービスクラスです。
|
||||
@@ -16,47 +15,46 @@ import com.example.rhizome.app.infra.repository.EmployeeRepository;
|
||||
@Transactional
|
||||
public class UpdateEmployeeImpl implements UpdateEmployee {
|
||||
|
||||
EmployeeRepository employeeRepository;
|
||||
EmployeeRepository employeeRepository;
|
||||
|
||||
@Autowired
|
||||
public UpdateEmployeeImpl(EmployeeRepository employeeRepository) {
|
||||
this.employeeRepository = employeeRepository;
|
||||
}
|
||||
@Autowired
|
||||
public UpdateEmployeeImpl(EmployeeRepository employeeRepository) {
|
||||
this.employeeRepository = employeeRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* employee の情報を元に employee table のレコードを更新する
|
||||
*
|
||||
* @param beforeEmployee 更新前のデータ
|
||||
* @param updateEmployee 更新後のデータ
|
||||
*/
|
||||
public void updateEmployee(Employee beforeEmployee, Employee updateEmployee) {
|
||||
/**
|
||||
* employee の情報を元に employee table のレコードを更新する
|
||||
*
|
||||
* @param beforeEmployee 更新前のデータ
|
||||
* @param updateEmployee 更新後のデータ
|
||||
*/
|
||||
public void updateEmployee(Employee beforeEmployee, Employee updateEmployee) {
|
||||
|
||||
employeeRepository.save(InsertEmployeeEntity.convertFrom(mergeEmployee(beforeEmployee, updateEmployee)));
|
||||
employeeRepository.save(EmployeeEntity.convertFrom(mergeEmployee(beforeEmployee, updateEmployee)));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新前のデータと更新対象のデータをマージする
|
||||
*
|
||||
* @param beforeEmployee 更新前のデータ
|
||||
* @param updateEmployee 更新対象のデータ
|
||||
* @return マージしたデータ
|
||||
*/
|
||||
private Employee mergeEmployee(Employee beforeEmployee, Employee updateEmployee) {
|
||||
// 更新対象のデータのパスワードが空文字の場合は、更新前のパスワードを使用する
|
||||
// 更新対象のデータの管理者権限が null の場合は、更新前の管理者権限を使用する
|
||||
// 更新対象のデータの部署IDが null の場合は、更新前の部署IDを使用する
|
||||
return new Employee(
|
||||
updateEmployee.getIdEmployee(),
|
||||
updateEmployee.getNmEmployee(),
|
||||
updateEmployee.getKnEmployee(),
|
||||
updateEmployee.getMailAddress(),
|
||||
updateEmployee.getPassword().isBlank() ? beforeEmployee.getPassword() : updateEmployee.getPassword(),
|
||||
updateEmployee.getHireDate(),
|
||||
updateEmployee.getAdminAuth() == null ? beforeEmployee.getAdminAuth() : updateEmployee.getAdminAuth(),
|
||||
updateEmployee.getIdDivision() == null ? beforeEmployee.getIdDivision()
|
||||
: updateEmployee.getIdDivision());
|
||||
/**
|
||||
* 更新前のデータと更新対象のデータをマージする
|
||||
*
|
||||
* @param beforeEmployee 更新前のデータ
|
||||
* @param updateEmployee 更新対象のデータ
|
||||
* @return マージしたデータ
|
||||
*/
|
||||
private Employee mergeEmployee(Employee beforeEmployee, Employee updateEmployee) {
|
||||
// 更新対象のデータのパスワードが空文字の場合は、更新前のパスワードを使用する
|
||||
// 更新対象のデータの管理者権限が null の場合は、更新前の管理者権限を使用する
|
||||
// 更新対象のデータの部署IDが null の場合は、更新前の部署IDを使用する
|
||||
return new Employee(
|
||||
updateEmployee.getIdEmployee(),
|
||||
updateEmployee.getNmEmployee(),
|
||||
updateEmployee.getKnEmployee(),
|
||||
updateEmployee.getMailAddress(),
|
||||
updateEmployee.getPassword().isBlank() ? beforeEmployee.getPassword() : updateEmployee.getPassword(),
|
||||
updateEmployee.getAdminAuth() == null ? beforeEmployee.getAdminAuth() : updateEmployee.getAdminAuth(),
|
||||
updateEmployee.getIdDepartment() == null ? beforeEmployee.getIdDepartment() : updateEmployee.getIdDepartment()
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,28 +6,15 @@
|
||||
*/
|
||||
package com.example.rhizome.app.infra.entity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.Fetch;
|
||||
import org.hibernate.annotations.FetchMode;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Department;
|
||||
import com.example.rhizome.app.domain.model.DepartmentInfo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Department テーブルの Entity
|
||||
*
|
||||
@@ -38,87 +25,48 @@ import lombok.NoArgsConstructor;
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
|
||||
public class DepartmentEntity {
|
||||
|
||||
/**
|
||||
* 部ID
|
||||
*/
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id_department", nullable = false)
|
||||
private Integer idDepartment;
|
||||
/**
|
||||
* 部名
|
||||
*/
|
||||
@Column(name = "nm_department", nullable = false)
|
||||
private String nmDepartment;
|
||||
/**
|
||||
* 表示・非表示フラグ
|
||||
*/
|
||||
@Column(name = "is_display", nullable = false)
|
||||
private Integer isDisplay;
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id_department", nullable = false)
|
||||
private Integer idDepartment;
|
||||
/**
|
||||
* 部署名
|
||||
*/
|
||||
@Column(name = "nm_department", nullable = false)
|
||||
private String nmDepartment;
|
||||
|
||||
@ManyToOne(cascade = CascadeType.ALL)
|
||||
@JoinColumn(name = "id_headquarters")
|
||||
@Fetch(FetchMode.JOIN)
|
||||
private HeadquartersEntity headquarters;
|
||||
/**
|
||||
* DepartmentEntity(DataAccess層依存)から Department(BusinessLogic層依存型)に変換します。
|
||||
*
|
||||
* @param departmentEntityList department Table のリスト
|
||||
* @return List<Department> リスト
|
||||
*/
|
||||
public static List<Department> createDepartmentList(List<DepartmentEntity> departmentEntityList) {
|
||||
|
||||
/**
|
||||
* DepartmentEntity(DataAccess層依存)から Department(BusinessLogic層依存型)に変換します。(リスト版)
|
||||
*
|
||||
* @param departmentEntityList department Table のリスト
|
||||
* @return List<Department> リスト
|
||||
*/
|
||||
public static List<Department> createDepartmentList(List<DepartmentEntity> departmentEntityList) {
|
||||
// Stream API を利用するとこうなります。
|
||||
return departmentEntityList
|
||||
.stream()
|
||||
.map(departmentEntity -> new Department(
|
||||
departmentEntity.getIdDepartment(),
|
||||
departmentEntity.getNmDepartment()
|
||||
)).toList();
|
||||
}
|
||||
|
||||
// Stream API を利用するとこうなります。
|
||||
return departmentEntityList
|
||||
.stream()
|
||||
.map(departmentEntity -> new Department(
|
||||
departmentEntity.getIdDepartment(),
|
||||
departmentEntity.getNmDepartment(),
|
||||
departmentEntity.getIsDisplay(),
|
||||
departmentEntity.getHeadquarters() == null ? null
|
||||
: departmentEntity.getHeadquarters().getIdHeadquarters()
|
||||
|
||||
)).toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* RegisterDepartmentEntity(DataAccess層依存)から Department(BusinessLogic層依存型)に変換します。(リスト版)
|
||||
*
|
||||
* @param departmentEntityList RegisterDepartmentEntity のリスト
|
||||
* @return Departmentのリスト
|
||||
*/
|
||||
public static List<Department> createDepartmentListBy(List<RegisterDepartmentEntity> departmentEntityList) {
|
||||
|
||||
// Stream API を利用するとこうなります。
|
||||
return departmentEntityList
|
||||
.stream()
|
||||
.map(departmentEntity -> new Department(
|
||||
departmentEntity.getIdDepartment(),
|
||||
departmentEntity.getNmDepartment(),
|
||||
departmentEntity.getIsDisplay(),
|
||||
departmentEntity.getIdHeadquarters() == null ? null : departmentEntity.getIdHeadquarters()
|
||||
|
||||
)).toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* DepartmentInfo から DepartmentEntity に変換します。
|
||||
*
|
||||
* @param departmentInfo DepartmentInfo
|
||||
* @return DepartmentEntity のインスタンス
|
||||
*/
|
||||
public static DepartmentEntity convertFrom(DepartmentInfo departmentInfo) {
|
||||
return new DepartmentEntity(
|
||||
departmentInfo.getIdDepartment(),
|
||||
departmentInfo.getNmDepartment(),
|
||||
(Integer) 0,
|
||||
new HeadquartersEntity(
|
||||
departmentInfo.getIdHeadquarters(),
|
||||
departmentInfo.getNmHeadquarters(),
|
||||
(Integer) 0));
|
||||
}
|
||||
/**
|
||||
* Department(BusinessLogic層依存型) から DepartmentEntity(DataAccess層依存)に変換します。
|
||||
*
|
||||
* @param department department モデルの値
|
||||
* @return DepartmentEntity に変換したインスタンス
|
||||
*/
|
||||
public static DepartmentEntity convertFrom(Department department) {
|
||||
return new DepartmentEntity(
|
||||
department.getIdDepartment(),
|
||||
department.getNmDepartment()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,165 +0,0 @@
|
||||
package com.example.rhizome.app.infra.entity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.NamedEntityGraph;
|
||||
|
||||
import com.example.rhizome.app.domain.model.AllDepartmentInfo;
|
||||
import com.example.rhizome.app.domain.model.Department;
|
||||
import com.example.rhizome.app.domain.model.DepartmentInfo;
|
||||
import com.example.rhizome.app.domain.model.Division;
|
||||
import com.example.rhizome.app.domain.model.Headquarters;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* Division join Department,Headquarters テーブルの Entity
|
||||
*
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@NamedEntityGraph(name = "division_with_department_with_headquarters", includeAllAttributes = true)
|
||||
public class DepartmentInfoEntity {
|
||||
|
||||
private DivisionEntity division;
|
||||
|
||||
private DepartmentEntity department;
|
||||
|
||||
private HeadquartersEntity headquarters;
|
||||
|
||||
/**
|
||||
* DepartmentInfo をDepartmentInfoEntityに変換します。
|
||||
*
|
||||
*@param departmentInfo DepartmentInfo のインスタンス
|
||||
*@return DepartmentInfoEntityのインスタンス
|
||||
*/
|
||||
public static DepartmentInfoEntity convertFrom(DepartmentInfo departmentInfo) {
|
||||
return new DepartmentInfoEntity(
|
||||
new DivisionEntity(
|
||||
departmentInfo.getIdDivision(),
|
||||
departmentInfo.getNmDivision(),
|
||||
0,
|
||||
new DepartmentEntity(
|
||||
departmentInfo.getIdDepartment(),
|
||||
departmentInfo.getNmDepartment(),
|
||||
0,
|
||||
new HeadquartersEntity(
|
||||
departmentInfo.getIdHeadquarters(),
|
||||
departmentInfo.getNmHeadquarters(),
|
||||
0))),
|
||||
new DepartmentEntity(
|
||||
departmentInfo.getIdDepartment(),
|
||||
departmentInfo.getNmDepartment(),
|
||||
0,
|
||||
new HeadquartersEntity(
|
||||
departmentInfo.getIdHeadquarters(),
|
||||
departmentInfo.getNmHeadquarters(),
|
||||
0)),
|
||||
new HeadquartersEntity(
|
||||
departmentInfo.getIdHeadquarters(),
|
||||
departmentInfo.getNmHeadquarters(),
|
||||
0)
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* DepartmentInfoEntity を AllDepartmentInfo に変換します。
|
||||
*
|
||||
* @param departmentInfoEntity DepartmentInfoEntity のインスタンス
|
||||
* @return AllDepartmentInfo のインスタンス
|
||||
*/
|
||||
public static AllDepartmentInfo createDepartmentInfo(DepartmentInfoEntity departmentInfoEntity) {
|
||||
|
||||
return new AllDepartmentInfo(
|
||||
new Division(
|
||||
departmentInfoEntity.getDivision() == null ? null
|
||||
: departmentInfoEntity.getDivision().getIdDivision(),
|
||||
departmentInfoEntity.getDivision() == null ? null
|
||||
: departmentInfoEntity.getDivision().getNmDivision(),
|
||||
departmentInfoEntity.getDivision() == null ? null
|
||||
: departmentInfoEntity.getDivision().getIsDisplay(),
|
||||
departmentInfoEntity.getDepartment() == null ? null
|
||||
: departmentInfoEntity.getDepartment().getIdDepartment()),
|
||||
new Department(
|
||||
departmentInfoEntity.getDepartment() == null ? null
|
||||
: departmentInfoEntity.getDepartment().getIdDepartment(),
|
||||
departmentInfoEntity.getDepartment() == null ? null
|
||||
: departmentInfoEntity.getDepartment().getNmDepartment(),
|
||||
departmentInfoEntity.getDepartment() == null ? null
|
||||
: departmentInfoEntity.getDepartment().getIsDisplay(),
|
||||
departmentInfoEntity.getHeadquarters() == null ? null
|
||||
: departmentInfoEntity.getHeadquarters().getIdHeadquarters()),
|
||||
new Headquarters(
|
||||
departmentInfoEntity.getHeadquarters() == null ? null
|
||||
: departmentInfoEntity.getHeadquarters().getIdHeadquarters(),
|
||||
departmentInfoEntity.getHeadquarters() == null ? null
|
||||
: departmentInfoEntity.getHeadquarters().getNmHeadquarters(),
|
||||
departmentInfoEntity.getHeadquarters() == null ? null
|
||||
: departmentInfoEntity.getHeadquarters().getIsDisplay()));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* DepartmentInfoEntity を AllDepartmentInfo に変換します。
|
||||
* (リスト版)
|
||||
*
|
||||
* @param departmentInfoEntity DepartmentInfoEntity インスタンスのリスト
|
||||
* @return AllDepartmentInfo インスタンスのリスト
|
||||
*/
|
||||
public static List<AllDepartmentInfo> createDepartmentInfoList(List<DepartmentInfoEntity> departmentInfoEntity) {
|
||||
|
||||
// StreamAPI を使うとこうなります。
|
||||
return departmentInfoEntity.stream().map(DepartmentInfoEntity::createDepartmentInfo).toList();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* DivisionEntity を AllDepartmentInfo に変換します。
|
||||
*
|
||||
* @param divisionEntity DivisionEntity インスタンス
|
||||
* @return AllDepartmentInfo インスタンス
|
||||
*/
|
||||
public static AllDepartmentInfo createDepartmentInfo(DivisionEntity divisionEntity) {
|
||||
|
||||
return new AllDepartmentInfo(
|
||||
new Division(
|
||||
divisionEntity.getIdDivision(),
|
||||
divisionEntity.getNmDivision(),
|
||||
divisionEntity.getIsDisplay(),
|
||||
divisionEntity.getDepartment().getIdDepartment()),
|
||||
new Department(
|
||||
divisionEntity.getDepartment() == null ? null
|
||||
: divisionEntity.getDepartment().getIdDepartment(),
|
||||
divisionEntity.getDepartment() == null ? null
|
||||
: divisionEntity.getDepartment().getNmDepartment(),
|
||||
divisionEntity.getDepartment() == null ? null : divisionEntity.getDepartment().getIsDisplay(),
|
||||
divisionEntity.getDepartment().getHeadquarters() == null ? null
|
||||
: divisionEntity.getDepartment().getHeadquarters().getIdHeadquarters()),
|
||||
new Headquarters(
|
||||
divisionEntity.getDepartment().getHeadquarters() == null ? null
|
||||
: divisionEntity.getDepartment().getHeadquarters().getIdHeadquarters(),
|
||||
divisionEntity.getDepartment().getHeadquarters() == null ? null
|
||||
: divisionEntity.getDepartment().getHeadquarters().getNmHeadquarters(),
|
||||
divisionEntity.getDepartment().getHeadquarters() == null ? null
|
||||
: divisionEntity.getDepartment().getHeadquarters().getIsDisplay()));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* DivisionEntity を AllDepartmentInfo に変換します。(リスト版)
|
||||
*
|
||||
* @param divisionEntity DivisionEntity インスタンスのリスト
|
||||
* @return AllDepartmentInfo インスタンスのリスト
|
||||
*/
|
||||
public static List<AllDepartmentInfo> AfterSearchCreateDepartmentInfoList(List<DivisionEntity> divisionEntity) {
|
||||
|
||||
// StreamAPI を使うとこうなります。
|
||||
return divisionEntity.stream().map(DepartmentInfoEntity::createDepartmentInfo).toList();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
package com.example.rhizome.app.infra.entity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.Fetch;
|
||||
import org.hibernate.annotations.FetchMode;
|
||||
|
||||
import com.example.rhizome.app.domain.model.DepartmentInfo;
|
||||
import com.example.rhizome.app.domain.model.Division;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
/**
|
||||
* Division テーブルの Entity
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "division")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DivisionEntity {
|
||||
/**
|
||||
* 課ID
|
||||
*/
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id_division", nullable = false)
|
||||
private Integer idDivision;
|
||||
/**
|
||||
* 課名
|
||||
*/
|
||||
@Column(name = "nm_division", nullable = false)
|
||||
private String nmDivision;
|
||||
/**
|
||||
* 表示・非表示フラグ
|
||||
*/
|
||||
@Column(name = "is_display", nullable = false)
|
||||
private Integer isDisplay;
|
||||
|
||||
@ManyToOne(cascade = CascadeType.ALL)
|
||||
@JoinColumn(name = "id_department")
|
||||
@Fetch(FetchMode.JOIN)
|
||||
private DepartmentEntity department;
|
||||
|
||||
/**
|
||||
* DepartmentInfo を DivisionEntity に変換します。
|
||||
*
|
||||
* @param departmentInfo DepartmentInfo のインスタンス
|
||||
* @return DivisionEntity join Department,Headquarters のインスタンス
|
||||
*/
|
||||
public static DivisionEntity convertFrom(DepartmentInfo departmentInfo) {
|
||||
return new DivisionEntity(
|
||||
departmentInfo.getIdDivision(),
|
||||
departmentInfo.getNmDivision(),
|
||||
(Integer) 0,
|
||||
new DepartmentEntity(
|
||||
departmentInfo.getIdDepartment(),
|
||||
departmentInfo.getNmDepartment(),
|
||||
(Integer) 0,
|
||||
new HeadquartersEntity(
|
||||
departmentInfo.getIdHeadquarters(),
|
||||
departmentInfo.getNmHeadquarters(),
|
||||
(Integer) 0)));
|
||||
}
|
||||
|
||||
/**
|
||||
* DivisionEntity を Divisionに変換します。
|
||||
*
|
||||
* @param divisionEntity DivisionEntity のインスタンス
|
||||
* @return Divisionのインスタンス
|
||||
*/
|
||||
public static Division createDivision(DivisionEntity divisionEntity) {
|
||||
// 値を既に持ったインスタンスの生成に、コンストラクタを使用するとこうなります。
|
||||
return new Division(
|
||||
divisionEntity.getIdDivision(),
|
||||
divisionEntity.getNmDivision(),
|
||||
divisionEntity.getIsDisplay(),
|
||||
divisionEntity.getDepartment().getIdDepartment()
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* DivisionEntity を Divisionに変換します。(リスト版)
|
||||
*
|
||||
* @param divisionEntity DivisionEntity のインスタンスのリスト
|
||||
* @return Divisionのインスタンスのリスト
|
||||
*/
|
||||
public static List<Division> createDivisionList(List<DivisionEntity> divisionEntityList) {
|
||||
|
||||
return divisionEntityList
|
||||
.stream()
|
||||
.map(DivisionEntity::createDivision).toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* RegisterDivisionEntity を Divisionに変換します。(リスト版)
|
||||
*
|
||||
* @param divisionEntityList RegisterDivisionEntity のインスタンスのリスト
|
||||
* @return Divisionのインスタンスのリスト
|
||||
*/
|
||||
public static List<Division> createRegisterDivisionList(List<RegisterDivisionEntity> divisionEntityList) {
|
||||
|
||||
return divisionEntityList
|
||||
.stream()
|
||||
.map(divisionEntity -> new Division(
|
||||
divisionEntity.getIdDivision(),
|
||||
divisionEntity.getNmDivision(),
|
||||
divisionEntity.getIsDisplay(),
|
||||
divisionEntity.getIdDepartment() == null ? null : divisionEntity.getIdDepartment()
|
||||
|
||||
)).toList();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,157 +1,118 @@
|
||||
package com.example.rhizome.app.infra.entity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.NamedEntityGraph;
|
||||
|
||||
import com.example.rhizome.app.domain.model.AllEmployeeInfo;
|
||||
import com.example.rhizome.app.domain.model.Department;
|
||||
import com.example.rhizome.app.domain.model.Division;
|
||||
import com.example.rhizome.app.domain.model.Employee;
|
||||
import com.example.rhizome.app.domain.model.Headquarters;
|
||||
|
||||
import com.example.rhizome.app.domain.model.EmployeeInfo;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.hibernate.annotations.Fetch;
|
||||
import org.hibernate.annotations.FetchMode;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Employee + Division + Department + Headquarters の Join 情報を保持するEntity
|
||||
* Employee + Department の Join 情報を保持するEntity
|
||||
*
|
||||
* @author IT-College
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "employee")
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@NamedEntityGraph(name = "employee_with_division_with_department_with_headquarters", includeAllAttributes = true)
|
||||
@NamedEntityGraph(
|
||||
name = "employee_with_department",
|
||||
includeAllAttributes = true
|
||||
)
|
||||
public class EmployeeDepartmentEntity {
|
||||
|
||||
private EmployeeEntity Employee;
|
||||
/**
|
||||
* 社員ID
|
||||
*/
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id_employee", nullable = false)
|
||||
private Integer idEmployee;
|
||||
|
||||
private DivisionEntity division;
|
||||
/**
|
||||
* 社員名
|
||||
*/
|
||||
@Column(name = "nm_employee", nullable = false)
|
||||
private String nmEmployee;
|
||||
|
||||
private DepartmentEntity department;
|
||||
/**
|
||||
* 社員名カナ
|
||||
*/
|
||||
@Column(name = "kn_employee", nullable = false)
|
||||
private String knEmployee;
|
||||
|
||||
private HeadquartersEntity headquarters;
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
@Column(name = "mail_address", nullable = false)
|
||||
private String mailAddress;
|
||||
|
||||
/**
|
||||
* EmployeeDepartmentEntity(DataAccess層依存) を AllEmployeeInfo(BusinessLogic層依存) に変換します。
|
||||
*
|
||||
* @param employeeDepartmentEntity EmployeeDepartmentEntity のインスタンス
|
||||
* @return AllEmployeeInfo のインスタンス
|
||||
*/
|
||||
public static AllEmployeeInfo createEmployeeInfo(EmployeeDepartmentEntity employeeDepartmentEntity) {
|
||||
/**
|
||||
* パスワード
|
||||
*/
|
||||
@Column(name = "password", nullable = false)
|
||||
private String password;
|
||||
|
||||
// コンストラクタを使って書くとSetterを使用するより簡略化出来ます。
|
||||
// 混乱してしまう人は落ち着いて EmployeeInfo のフィールドを見に行って、
|
||||
// どうしてこの書き方が出来るのかを理解できる様になりましょう。
|
||||
return new AllEmployeeInfo(
|
||||
new Employee(
|
||||
employeeDepartmentEntity.getEmployee().getIdEmployee(),
|
||||
employeeDepartmentEntity.getEmployee().getNmEmployee(),
|
||||
employeeDepartmentEntity.getEmployee().getKnEmployee(),
|
||||
employeeDepartmentEntity.getEmployee().getMailAddress(),
|
||||
employeeDepartmentEntity.getEmployee().getPassword(),
|
||||
employeeDepartmentEntity.getEmployee().getHireDate(),
|
||||
employeeDepartmentEntity.getEmployee().getAdminAuth(),
|
||||
employeeDepartmentEntity.getDivision() == null ? null
|
||||
: employeeDepartmentEntity.getDivision().getIdDivision()),
|
||||
new Division(
|
||||
employeeDepartmentEntity.getDivision() == null ? null
|
||||
: employeeDepartmentEntity.getDivision().getIdDivision(),
|
||||
employeeDepartmentEntity.getDivision() == null ? null
|
||||
: employeeDepartmentEntity.getDivision().getNmDivision(),
|
||||
employeeDepartmentEntity.getDivision() == null ? null
|
||||
: employeeDepartmentEntity.getDivision().getIsDisplay(),
|
||||
employeeDepartmentEntity.getDepartment() == null ? null
|
||||
: employeeDepartmentEntity.getDepartment().getIdDepartment()),
|
||||
new Department(
|
||||
employeeDepartmentEntity.getDepartment() == null ? null
|
||||
: employeeDepartmentEntity.getDepartment().getIdDepartment(),
|
||||
employeeDepartmentEntity.getDepartment() == null ? null
|
||||
: employeeDepartmentEntity.getDepartment().getNmDepartment(),
|
||||
employeeDepartmentEntity.getDepartment() == null ? null
|
||||
: employeeDepartmentEntity.getDepartment().getIsDisplay(),
|
||||
employeeDepartmentEntity.getHeadquarters() == null ? null
|
||||
: employeeDepartmentEntity.getHeadquarters().getIdHeadquarters()),
|
||||
new Headquarters(
|
||||
employeeDepartmentEntity.getHeadquarters() == null ? null
|
||||
: employeeDepartmentEntity.getHeadquarters().getIdHeadquarters(),
|
||||
employeeDepartmentEntity.getHeadquarters() == null ? null
|
||||
: employeeDepartmentEntity.getHeadquarters().getNmHeadquarters(),
|
||||
employeeDepartmentEntity.getHeadquarters() == null ? null
|
||||
: employeeDepartmentEntity.getHeadquarters().getIsDisplay()));
|
||||
/**
|
||||
* 管理者権限
|
||||
*/
|
||||
@Column(name = "admin_auth", nullable = false)
|
||||
private Integer adminAuth;
|
||||
|
||||
}
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "id_department", referencedColumnName = "id_department", insertable = false, updatable = false)
|
||||
@Fetch(FetchMode.JOIN)
|
||||
private DepartmentEntity department;
|
||||
|
||||
/**
|
||||
* EmployeeDepartmentEntity(DataAccess層依存) を AllEmployeeInfo(BusinessLogic層依存) に変換します。
|
||||
* (リスト版)
|
||||
*
|
||||
* @param employeeDepartmentEntityList EmployeeDepartmentEntity インスタンスのリスト
|
||||
* @return AllEmployeeInfo インスタンスのリスト
|
||||
*/
|
||||
public static List<AllEmployeeInfo> createEmployeeInfoList(
|
||||
List<EmployeeDepartmentEntity> employeeDepartmentEntityList) {
|
||||
/**
|
||||
* EmployeeDepartmentEntity(DataAccess層依存) を EmployeeInfo(BusinessLogic層依存) に変換します。
|
||||
*
|
||||
* @param employeeDepartmentEntity EmployeeDepartmentEntity のインスタンス
|
||||
* @return EmployeeInfo のインスタンス
|
||||
*/
|
||||
public static EmployeeInfo createEmployeeInfo(EmployeeDepartmentEntity employeeDepartmentEntity) {
|
||||
|
||||
// StreamAPI を使うとこうなります。
|
||||
return employeeDepartmentEntityList.stream().map(EmployeeDepartmentEntity::createEmployeeInfo).toList();
|
||||
// コンストラクタを使って書くとSetterを使用するより簡略化出来ます。
|
||||
// 混乱してしまう人は落ち着いて EmployeeInfo のフィールドを見に行って、
|
||||
// どうしてこの書き方が出来るのかを理解できる様になりましょう。
|
||||
return new EmployeeInfo(
|
||||
new Employee(
|
||||
employeeDepartmentEntity.getIdEmployee(),
|
||||
employeeDepartmentEntity.getNmEmployee(),
|
||||
employeeDepartmentEntity.getKnEmployee(),
|
||||
employeeDepartmentEntity.getMailAddress(),
|
||||
employeeDepartmentEntity.getPassword(),
|
||||
employeeDepartmentEntity.getAdminAuth(),
|
||||
employeeDepartmentEntity.getDepartment() == null ? null : employeeDepartmentEntity.getDepartment().getIdDepartment()
|
||||
),
|
||||
new Department(
|
||||
employeeDepartmentEntity.getDepartment() == null ? null : employeeDepartmentEntity.getDepartment().getIdDepartment(),
|
||||
employeeDepartmentEntity.getDepartment() == null ? null : employeeDepartmentEntity.getDepartment().getNmDepartment()
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* EmployeeEntity(DataAccess層依存) を AllEmployeeInfo(BusinessLogic層依存) に変換します。
|
||||
*
|
||||
* @param employeeEntity EmployeeEntity のインスタンス
|
||||
* @return AllEmployeeInfo のインスタンス
|
||||
*/
|
||||
public static AllEmployeeInfo createEmployeeInfo(EmployeeEntity employeeEntity) {
|
||||
/**
|
||||
* EmployeeDepartmentEntity(DataAccess層依存) を EmployeeInfo(BusinessLogic層依存) に変換します。
|
||||
* (リスト版)
|
||||
*
|
||||
* @param employeeDepartmentEntityList EmployeeDepartmentEntity インスタンスのリスト
|
||||
* @return EmployeeInfo インスタンスのリスト
|
||||
*/
|
||||
public static List<EmployeeInfo> createEmployeeInfoList(List<EmployeeDepartmentEntity> employeeDepartmentEntityList) {
|
||||
|
||||
return new AllEmployeeInfo(
|
||||
new Employee(
|
||||
employeeEntity.getIdEmployee(),
|
||||
employeeEntity.getNmEmployee(),
|
||||
employeeEntity.getKnEmployee(),
|
||||
employeeEntity.getMailAddress(),
|
||||
employeeEntity.getPassword(),
|
||||
employeeEntity.getHireDate(),
|
||||
employeeEntity.getAdminAuth(),
|
||||
employeeEntity.getDivision() == null ? null : employeeEntity.getDivision().getIdDivision()),
|
||||
new Division(
|
||||
employeeEntity.getDivision() == null ? null : employeeEntity.getDivision().getIdDivision(),
|
||||
employeeEntity.getDivision() == null ? null : employeeEntity.getDivision().getNmDivision(),
|
||||
employeeEntity.getDivision() == null ? null : employeeEntity.getDivision().getIsDisplay(),
|
||||
employeeEntity.getDivision().getDepartment() == null ? null
|
||||
: employeeEntity.getDivision().getDepartment().getIdDepartment()),
|
||||
new Department(
|
||||
employeeEntity.getDivision().getDepartment() == null ? null
|
||||
: employeeEntity.getDivision().getDepartment().getIdDepartment(),
|
||||
employeeEntity.getDivision().getDepartment() == null ? null
|
||||
: employeeEntity.getDivision().getDepartment().getNmDepartment(),
|
||||
employeeEntity.getDivision().getDepartment() == null ? null
|
||||
: employeeEntity.getDivision().getDepartment().getIsDisplay(),
|
||||
employeeEntity.getDivision().getDepartment().getHeadquarters() == null ? null
|
||||
: employeeEntity.getDivision().getDepartment().getHeadquarters().getIdHeadquarters()),
|
||||
new Headquarters(
|
||||
employeeEntity.getDivision().getDepartment().getHeadquarters() == null ? null
|
||||
: employeeEntity.getDivision().getDepartment().getHeadquarters().getIdHeadquarters(),
|
||||
employeeEntity.getDivision().getDepartment().getHeadquarters() == null ? null
|
||||
: employeeEntity.getDivision().getDepartment().getHeadquarters().getNmHeadquarters(),
|
||||
employeeEntity.getDivision().getDepartment().getHeadquarters() == null ? null
|
||||
: employeeEntity.getDivision().getDepartment().getHeadquarters().getIsDisplay()));
|
||||
// StreamAPI を使うとこうなります。
|
||||
return employeeDepartmentEntityList.stream().map(EmployeeDepartmentEntity::createEmployeeInfo).toList();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* EmployeeEntity(DataAccess層依存) を AllEmployeeInfo(BusinessLogic層依存) に変換します。(リスト版)
|
||||
*
|
||||
* @param employeeEntity EmployeeEntity のインスタンスのリスト
|
||||
* @return AllEmployeeInfo のインスタンスのリスト
|
||||
*/
|
||||
|
||||
public static List<AllEmployeeInfo> AfterSearchCreateEmployeeInfoList(List<EmployeeEntity> employeeEntityList) {
|
||||
|
||||
// StreamAPI を使うとこうなります。
|
||||
return employeeEntityList.stream().map(EmployeeDepartmentEntity::createEmployeeInfo).toList();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,32 +6,21 @@
|
||||
*/
|
||||
package com.example.rhizome.app.infra.entity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.Fetch;
|
||||
import org.hibernate.annotations.FetchMode;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Employee;
|
||||
import com.example.rhizome.app.domain.model.EmployeeInfo;
|
||||
import com.example.rhizome.app.domain.model.LoginUser;
|
||||
import com.example.rhizome.app.domain.model.SearchConditionEmployee;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* EmployeeテーブルのEntity
|
||||
*
|
||||
* @author IT-College
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "employee")
|
||||
@@ -40,153 +29,146 @@ import lombok.NoArgsConstructor;
|
||||
@AllArgsConstructor
|
||||
public class EmployeeEntity {
|
||||
|
||||
/**
|
||||
* 社員ID
|
||||
*/
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id_employee", nullable = false)
|
||||
private Integer idEmployee;
|
||||
/**
|
||||
* 社員ID
|
||||
*/
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id_employee", nullable = false)
|
||||
private Integer idEmployee;
|
||||
|
||||
/**
|
||||
* 社員名
|
||||
*/
|
||||
@Column(name = "nm_employee", nullable = false)
|
||||
private String nmEmployee;
|
||||
/**
|
||||
* 社員名
|
||||
*/
|
||||
@Column(name = "nm_employee", nullable = false)
|
||||
private String nmEmployee;
|
||||
|
||||
/**
|
||||
* 社員名カナ
|
||||
*/
|
||||
@Column(name = "kn_employee", nullable = false)
|
||||
private String knEmployee;
|
||||
/**
|
||||
* 社員名カナ
|
||||
*/
|
||||
@Column(name = "kn_employee", nullable = false)
|
||||
private String knEmployee;
|
||||
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
@Column(name = "mail_address", nullable = false)
|
||||
private String mailAddress;
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
@Column(name = "mail_address", nullable = false)
|
||||
private String mailAddress;
|
||||
|
||||
/**
|
||||
* パスワード
|
||||
*/
|
||||
@Column(name = "password", nullable = false)
|
||||
private String password;
|
||||
/**
|
||||
* パスワード
|
||||
*/
|
||||
@Column(name = "password", nullable = false)
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 入社年月日
|
||||
*/
|
||||
@Column(name = "hire_Date", nullable = false)
|
||||
private String hireDate;
|
||||
/**
|
||||
* 管理者権限
|
||||
*/
|
||||
@Column(name = "admin_auth", nullable = false)
|
||||
private Integer adminAuth;
|
||||
/**
|
||||
* 管理者権限
|
||||
*/
|
||||
@Column(name = "admin_auth", nullable = false)
|
||||
private Integer adminAuth;
|
||||
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "id_division")
|
||||
@Fetch(FetchMode.JOIN)
|
||||
private DivisionEntity division;
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
@Column(name = "id_department", nullable = false)
|
||||
private Integer idDepartment;
|
||||
|
||||
/**
|
||||
* EmployeeInfo(BusinessLogic 依存)を EmployeeEntity(DataAccess層依存)に変換します。
|
||||
*
|
||||
* @param employeeInfo EmployeeInfo Table の中身
|
||||
* @return EmployeeEntity のインスタンス(1レコード分)
|
||||
*/
|
||||
public static EmployeeEntity convertFrom(EmployeeInfo employeeInfo) {
|
||||
// 値を既に持ったインスタンスの生成に、コンストラクタを使用するとこうなります。
|
||||
return new EmployeeEntity(
|
||||
employeeInfo.getEmployee().getIdEmployee(),
|
||||
employeeInfo.getEmployee().getNmEmployee(),
|
||||
employeeInfo.getEmployee().getKnEmployee(),
|
||||
employeeInfo.getEmployee().getMailAddress(),
|
||||
employeeInfo.getEmployee().getPassword(),
|
||||
employeeInfo.getEmployee().getHireDate(),
|
||||
employeeInfo.getEmployee().getAdminAuth(),
|
||||
new DivisionEntity(
|
||||
employeeInfo.getDivision().getIdDivision(),
|
||||
employeeInfo.getDivision().getNmDivision(),
|
||||
employeeInfo.getDivision().getIsDisplay(),
|
||||
null));
|
||||
}
|
||||
|
||||
/**
|
||||
* SearchConditionEmployee(BusinessLogic 依存)を EmployeeEntity(DataAccess層依存)に変換します。
|
||||
* (コンストラクタを使用せず、Setterを利用したパターン)
|
||||
*
|
||||
* @param searchConditionEmployee 検索条件
|
||||
* @return EmployeeEntity のインスタンス(1レコード分)
|
||||
*/
|
||||
public static EmployeeEntity convertFrom(SearchConditionEmployee searchConditionEmployee) {
|
||||
EmployeeEntity employeeEntity = new EmployeeEntity();
|
||||
/**
|
||||
* Employee(BusinessLogic 依存)を EmployeeEntity(DataAccess層依存)に変換します。
|
||||
*
|
||||
* @param employee Employee Table の中身
|
||||
* @return EmployeeEntity のインスタンス(1レコード分)
|
||||
*/
|
||||
public static EmployeeEntity convertFrom(Employee employee) {
|
||||
// 値を既に持ったインスタンスの生成に、コンストラクタを使用するとこうなります。
|
||||
return new EmployeeEntity(
|
||||
employee.getIdEmployee(),
|
||||
employee.getNmEmployee(),
|
||||
employee.getKnEmployee(),
|
||||
employee.getMailAddress(),
|
||||
employee.getPassword(),
|
||||
employee.getAdminAuth(),
|
||||
employee.getIdDepartment()
|
||||
);
|
||||
}
|
||||
|
||||
employeeEntity.setIdEmployee(searchConditionEmployee.getIdEmployee());
|
||||
employeeEntity.setNmEmployee(searchConditionEmployee.getNmEmployee());
|
||||
employeeEntity.setKnEmployee(searchConditionEmployee.getKnEmployee());
|
||||
employeeEntity.setMailAddress(searchConditionEmployee.getMailAddress());
|
||||
/**
|
||||
* SearchConditionEmployee(BusinessLogic 依存)を EmployeeEntity(DataAccess層依存)に変換します。
|
||||
* (コンストラクタを使用せず、Setterを利用したパターン)
|
||||
*
|
||||
* @param searchConditionEmployee 検索条件
|
||||
* @return EmployeeEntity のインスタンス(1レコード分)
|
||||
*/
|
||||
public static EmployeeEntity convertFrom(SearchConditionEmployee searchConditionEmployee) {
|
||||
EmployeeEntity employeeEntity = new EmployeeEntity();
|
||||
|
||||
return employeeEntity;
|
||||
employeeEntity.setIdEmployee(searchConditionEmployee.getIdEmployee());
|
||||
employeeEntity.setNmEmployee(searchConditionEmployee.getNmEmployee());
|
||||
employeeEntity.setKnEmployee(searchConditionEmployee.getKnEmployee());
|
||||
employeeEntity.setMailAddress(searchConditionEmployee.getMailAddress());
|
||||
employeeEntity.setIdDepartment(searchConditionEmployee.getIdDepartment());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* EmployeeEntity(DataAccess層依存)から Employee (BusinessLogic層依存型)に変換します。
|
||||
*
|
||||
* @param employeeEntity Employee Table のインスタンス
|
||||
* @return employee インスタンス
|
||||
*/
|
||||
public static Employee createEmployee(EmployeeEntity employeeEntity) {
|
||||
// 値を既に持ったインスタンスの生成に、コンストラクタを使用するとこうなります。
|
||||
return new Employee(
|
||||
employeeEntity.getIdEmployee(),
|
||||
employeeEntity.getNmEmployee(),
|
||||
employeeEntity.getKnEmployee(),
|
||||
employeeEntity.getMailAddress(),
|
||||
employeeEntity.getPassword(),
|
||||
employeeEntity.getHireDate(),
|
||||
employeeEntity.getAdminAuth(),
|
||||
employeeEntity.getDivision().getIdDivision());
|
||||
}
|
||||
return employeeEntity;
|
||||
|
||||
/**
|
||||
* EmployeeEntity(DataAccess層依存) から Employee (BusinessLogic層依存型)に変換します。(リスト版)
|
||||
*
|
||||
* @param employeeEntityList EmployeeEntity インスタンスのリスト
|
||||
* @return Employee インスタンスのリスト
|
||||
*/
|
||||
public static List<Employee> createEmployeeList(List<EmployeeEntity> employeeEntityList) {
|
||||
/* 従来の書き方
|
||||
List<Employee> employeeList = new ArrayList<>();
|
||||
for(EmployeeEntity employeeEntity:employeeEntityList){
|
||||
Employee employee = EmployeeEntity.createEmployee(employeeEntity);
|
||||
employeeList.add(employee);
|
||||
}
|
||||
return employeeList;
|
||||
*/
|
||||
}
|
||||
|
||||
// Stream APIを使用すると1行で書けます。
|
||||
return employeeEntityList.stream().map(EmployeeEntity::createEmployee).toList();
|
||||
}
|
||||
/**
|
||||
* EmployeeEntity(DataAccess層依存)から Employee (BusinessLogic層依存型)に変換します。
|
||||
*
|
||||
* @param employeeEntity Employee Table のインスタンス
|
||||
* @return employee インスタンス
|
||||
*/
|
||||
public static Employee createEmployee(EmployeeEntity employeeEntity) {
|
||||
// 値を既に持ったインスタンスの生成に、コンストラクタを使用するとこうなります。
|
||||
return new Employee(
|
||||
employeeEntity.getIdEmployee(),
|
||||
employeeEntity.getNmEmployee(),
|
||||
employeeEntity.getKnEmployee(),
|
||||
employeeEntity.getMailAddress(),
|
||||
employeeEntity.getPassword(),
|
||||
employeeEntity.getAdminAuth(),
|
||||
employeeEntity.getIdDepartment()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* EmployeeEntity(DataAccess層依存) から LoginUser (BusinessLogic層依存型)情報を作成します。
|
||||
*
|
||||
* @return loginUser (ログイン者の情報) インスタンス
|
||||
*/
|
||||
public LoginUser createLoginUser() {
|
||||
// 値を既に持ったインスタンスの生成に、コンストラクタを使用するとこうなります。
|
||||
return new LoginUser(
|
||||
getIdEmployee(),
|
||||
getNmEmployee(),
|
||||
getKnEmployee(),
|
||||
getMailAddress(),
|
||||
getPassword(),
|
||||
getAdminAuth(),
|
||||
getDivision().getIdDivision());
|
||||
}
|
||||
/**
|
||||
* EmployeeEntity(DataAccess層依存) から Employee (BusinessLogic層依存型)に変換します。(リスト版)
|
||||
*
|
||||
* @param employeeEntityList EmployeeEntity インスタンスのリスト
|
||||
* @return Employee インスタンスのリスト
|
||||
*/
|
||||
public static List<Employee> createEmployeeList(List<EmployeeEntity> employeeEntityList) {
|
||||
/* 従来の書き方
|
||||
List<Employee> employeeList = new ArrayList<>();
|
||||
for(EmployeeEntity employeeEntity:employeeEntityList){
|
||||
Employee employee = EmployeeEntity.createEmployee(employeeEntity);
|
||||
employeeList.add(employee);
|
||||
}
|
||||
return employeeList;
|
||||
*/
|
||||
|
||||
// Stream APIを使用すると1行で書けます。
|
||||
return employeeEntityList.stream().map(EmployeeEntity::createEmployee).toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* EmployeeEntity(DataAccess層依存) から LoginUser (BusinessLogic層依存型)情報を作成します。
|
||||
*
|
||||
* @return loginUser (ログイン者の情報) インスタンス
|
||||
*/
|
||||
public LoginUser createLoginUser() {
|
||||
// 値を既に持ったインスタンスの生成に、コンストラクタを使用するとこうなります。
|
||||
return new LoginUser(
|
||||
getIdEmployee(),
|
||||
getNmEmployee(),
|
||||
getKnEmployee(),
|
||||
getMailAddress(),
|
||||
getPassword(),
|
||||
getAdminAuth(),
|
||||
getIdDepartment()
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
package com.example.rhizome.app.infra.entity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import com.example.rhizome.app.domain.model.DepartmentInfo;
|
||||
import com.example.rhizome.app.domain.model.Headquarters;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* HeadquartersテーブルのEntity
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "headquarters")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class HeadquartersEntity {
|
||||
/**
|
||||
* 本部ID
|
||||
*/
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id_headquarters", nullable = false)
|
||||
private Integer idHeadquarters;
|
||||
/**
|
||||
* 本部名
|
||||
*/
|
||||
@Column(name = "nm_headquarters", nullable = false)
|
||||
private String nmHeadquarters;
|
||||
/**
|
||||
* 表示・非表示フラグ
|
||||
*/
|
||||
@Column(name = "is_display", nullable = false)
|
||||
private Integer isDisplay;
|
||||
|
||||
public static Headquarters createHeadquarters(HeadquartersEntity headquartersEntity) {
|
||||
// 値を既に持ったインスタンスの生成に、コンストラクタを使用するとこうなります。
|
||||
return new Headquarters(
|
||||
headquartersEntity.getIdHeadquarters(),
|
||||
headquartersEntity.getNmHeadquarters(),
|
||||
headquartersEntity.getIsDisplay());
|
||||
}
|
||||
/**
|
||||
* DBから返ってきたHeadquartersEntityのリストをHeadquartersのリストに変換する
|
||||
*
|
||||
* @param HeadquartersEntityのリスト
|
||||
* @return headquartersのリスト
|
||||
*/
|
||||
public static List<Headquarters> createHeadquartersList(List<HeadquartersEntity> headquartersEntityList) {
|
||||
|
||||
return headquartersEntityList
|
||||
.stream()
|
||||
.map(HeadquartersEntity::createHeadquarters).toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 三つのテーブルがつながった部署情報であるDepartmentInfoから
|
||||
* 本部情報だけを引っ張ってきてHeadquartersEntityに入れる
|
||||
*
|
||||
* @param DepartmentInfo
|
||||
* @return 新しく作成されたHeadquartersEntity
|
||||
*
|
||||
*/
|
||||
public static HeadquartersEntity convertFrom(DepartmentInfo departmentInfo) {
|
||||
return new HeadquartersEntity(
|
||||
departmentInfo.getIdHeadquarters(),
|
||||
departmentInfo.getNmHeadquarters(),
|
||||
(Integer) 0);
|
||||
}
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
package com.example.rhizome.app.infra.entity;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Employee;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 社員情報登録用のEmployeeテーブルのEntity
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "employee")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
|
||||
public class InsertEmployeeEntity {
|
||||
|
||||
/**
|
||||
* 社員ID
|
||||
*/
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id_employee", nullable = false)
|
||||
private Integer idEmployee;
|
||||
|
||||
/**
|
||||
* 社員名
|
||||
*/
|
||||
@Column(name = "nm_employee", nullable = false)
|
||||
private String nmEmployee;
|
||||
|
||||
/**
|
||||
* 社員名カナ
|
||||
*/
|
||||
@Column(name = "kn_employee", nullable = false)
|
||||
private String knEmployee;
|
||||
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
@Column(name = "mail_address", nullable = false)
|
||||
private String mailAddress;
|
||||
|
||||
/**
|
||||
* パスワード
|
||||
*/
|
||||
@Column(name = "password", nullable = false)
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 入社年月日
|
||||
*/
|
||||
@Column(name = "hire_Date", nullable = false)
|
||||
private String hireDate;
|
||||
/**
|
||||
* 管理者権限
|
||||
*/
|
||||
@Column(name = "admin_auth", nullable = false)
|
||||
private Integer adminAuth;
|
||||
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
@Column(name = "id_division", nullable = false)
|
||||
private Integer idDivision;
|
||||
|
||||
/**
|
||||
* Employee(BusinessLogic 依存)を InsertEmployeeEntity(DataAccess層依存)に変換します。
|
||||
*
|
||||
* @param employee Employee Table の中身
|
||||
* @return InsertEmployeeEntity のインスタンス(1レコード分)
|
||||
*/
|
||||
public static InsertEmployeeEntity convertFrom(Employee employee) {
|
||||
// 値を既に持ったインスタンスの生成に、コンストラクタを使用するとこうなります。
|
||||
return new InsertEmployeeEntity(
|
||||
employee.getIdEmployee(),
|
||||
employee.getNmEmployee(),
|
||||
employee.getKnEmployee(),
|
||||
employee.getMailAddress(),
|
||||
employee.getPassword(),
|
||||
employee.getHireDate(),
|
||||
employee.getAdminAuth(),
|
||||
employee.getIdDivision());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package com.example.rhizome.app.infra.entity;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 社員情報登録用のDepartment テーブルの Entity
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "department")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
|
||||
public class RegisterDepartmentEntity {
|
||||
|
||||
/**
|
||||
* 部ID
|
||||
*/
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id_department", nullable = false)
|
||||
private Integer idDepartment;
|
||||
/**
|
||||
* 部名
|
||||
*/
|
||||
@Column(name = "nm_department", nullable = false)
|
||||
private String nmDepartment;
|
||||
/**
|
||||
* 表示・非表示フラグ
|
||||
*/
|
||||
@Column(name = "is_display", nullable = false)
|
||||
private Integer isDisplay;
|
||||
|
||||
@Column(name = "id_headquarters", nullable = false)
|
||||
private Integer idHeadquarters;
|
||||
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
package com.example.rhizome.app.infra.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.data.jpa.repository.EntityGraph;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.example.rhizome.app.infra.entity.DepartmentInfoEntity;
|
||||
import com.example.rhizome.app.infra.entity.DivisionEntity;
|
||||
|
||||
@Repository
|
||||
public interface DepartmentInfoRepository
|
||||
extends JpaRepository<DivisionEntity, Integer>, JpaSpecificationExecutor<DivisionEntity> {
|
||||
|
||||
static Specification<DivisionEntity> idDivisionEqual(Integer idDivision) {
|
||||
return idDivision == null ? null :
|
||||
// 戻り値の型 Specification<EmployeeDepartmentEntity> にキャスト
|
||||
(Specification<DivisionEntity>)
|
||||
// ラムダ式で記載しているが書いてあることは criteriaBuilder を使って Where句の後の "'idEmployee' = idEmployee(変数)"
|
||||
// を作成している
|
||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.equal(root.get("idDivision"), idDivision);
|
||||
}
|
||||
|
||||
static Specification<DivisionEntity> nmDivisionEqual(String nmDivision) {
|
||||
return (nmDivision == null || nmDivision.isEmpty()) ? null
|
||||
: (Specification<DivisionEntity>) (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder
|
||||
.equal(root.get("nmDivision"), nmDivision);
|
||||
}
|
||||
|
||||
static Specification<DivisionEntity> nmDepartmentEqual(String nmDepartment) {
|
||||
return (nmDepartment == null || nmDepartment.isEmpty()) ? null
|
||||
: (Specification<DivisionEntity>) (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder
|
||||
.equal(root.join("department").get("nmDepartment"), nmDepartment);
|
||||
}
|
||||
|
||||
static Specification<DivisionEntity> nmHeadquartersEqual(String nmHeadquarters) {
|
||||
return (nmHeadquarters == null || nmHeadquarters.isEmpty()) ? null
|
||||
: (Specification<DivisionEntity>) (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder
|
||||
.equal(root.join("department").join("headquarters").get("nmHeadquarters"), nmHeadquarters);
|
||||
}
|
||||
|
||||
@Query("SELECT DISTINCT new com.example.rhizome.app.infra.entity.DepartmentInfoEntity(di,de,h)FROM DivisionEntity di "
|
||||
+ "INNER JOIN di.department de "
|
||||
+ "INNER JOIN de.headquarters h ")
|
||||
List<DepartmentInfoEntity> searchAllDepartmentTable();
|
||||
|
||||
@EntityGraph(attributePaths = { "department", "department.headquarters" })
|
||||
List<DivisionEntity> findAll(@Nullable Specification<DivisionEntity> spec);
|
||||
|
||||
@EntityGraph(attributePaths = { "department", "department.headquarters" })
|
||||
void save(@Nullable Specification<DivisionEntity> spec);
|
||||
|
||||
@Query("SELECT DISTINCT new com.example.rhizome.app.infra.entity.DepartmentInfoEntity(di,de,h)FROM DivisionEntity di "
|
||||
+ "INNER JOIN di.department de "
|
||||
+ "INNER JOIN de.headquarters h "
|
||||
+ "WHERE di.nmDivision = :nmDivision "
|
||||
+ "AND de.nmDepartment = :nmDepartment "
|
||||
+ "AND h.nmHeadquarters = :nmHeadquarters"
|
||||
+ "")
|
||||
List<DepartmentInfoEntity> searchAllDepartmentTable(
|
||||
@Param("nmHeadquarters") String nmHeadquarters,
|
||||
@Param("nmDepartment") String nmDepartment,
|
||||
@Param("nmDivision") String nmDivision);
|
||||
|
||||
@Query("SELECT DISTINCT new com.example.rhizome.app.infra.entity.DepartmentInfoEntity(di,de,h)FROM DivisionEntity di "
|
||||
+ "INNER JOIN di.department de "
|
||||
+ "INNER JOIN de.headquarters h "
|
||||
+ "WHERE di.idDivision = :idDivision "
|
||||
+ "AND de.idDepartment = :idDepartment "
|
||||
+ "AND h.idHeadquarters = :idHeadquarters"
|
||||
+ "")
|
||||
List<DepartmentInfoEntity> searchAllDepartmentTable(
|
||||
@Param("idHeadquarters") Integer idHeadquarters,
|
||||
@Param("idDepartment") Integer idDepartment,
|
||||
@Param("idDivision") Integer idDivision);
|
||||
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
package com.example.rhizome.app.infra.repository;
|
||||
|
||||
import com.example.rhizome.app.infra.entity.DepartmentEntity;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.example.rhizome.app.infra.entity.DepartmentEntity;
|
||||
import com.example.rhizome.app.infra.entity.HeadquartersEntity;
|
||||
|
||||
/**
|
||||
* Specification:
|
||||
@@ -21,30 +20,31 @@ import com.example.rhizome.app.infra.entity.HeadquartersEntity;
|
||||
* 戻り値はクエリを格納しているPredicateオブジェクトとなります。
|
||||
*/
|
||||
@Repository
|
||||
public interface DepartmentRepository
|
||||
extends JpaRepository<DepartmentEntity, Integer>, JpaSpecificationExecutor<DepartmentEntity> {
|
||||
public interface DepartmentRepository extends JpaRepository<DepartmentEntity, Integer>, JpaSpecificationExecutor<DepartmentEntity> {
|
||||
|
||||
static Specification<DepartmentEntity> idDepartmentEqual(Integer idDepartment) {
|
||||
return idDepartment == null ? null :
|
||||
// 戻り値の型 Specification<DepartmentEntity> にキャスト
|
||||
(Specification<DepartmentEntity>)
|
||||
// ラムダ式で記載しているが書いてあることは criteriaBuilder を使って Where句の後の "'idDepartment' = idDepartment(変数)"
|
||||
// を作成している
|
||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.equal(root.get("idDepartment"), idDepartment);
|
||||
}
|
||||
|
||||
static Specification<DepartmentEntity> nmDepartmentEqual(String nmDepartment) {
|
||||
return (nmDepartment == null || nmDepartment.isEmpty()) ? null
|
||||
: (Specification<DepartmentEntity>) (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder
|
||||
.like(root.get("nmDepartment"), nmDepartment);
|
||||
}
|
||||
static Specification<DepartmentEntity> idDepartmentEqual(Integer idDepartment) {
|
||||
return idDepartment == null ?
|
||||
null :
|
||||
// 戻り値の型 Specification<DepartmentEntity> にキャスト
|
||||
(Specification<DepartmentEntity>)
|
||||
// ラムダ式で記載しているが書いてあることは criteriaBuilder を使って Where句の後の "'idDepartment' = idDepartment(変数)"
|
||||
// を作成している
|
||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.equal(root.get("idDepartment"), idDepartment);
|
||||
}
|
||||
|
||||
static Specification<DepartmentEntity> nmDepartmentLike(String nmDepartment) {
|
||||
return (nmDepartment == null || nmDepartment.isEmpty()) ? null
|
||||
: (Specification<DepartmentEntity>) (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder
|
||||
.like(root.get("nmDepartment"), "%" + nmDepartment + "%");
|
||||
}
|
||||
static Specification<DepartmentEntity> nmDepartmentEqual(String nmDepartment) {
|
||||
return (nmDepartment == null || nmDepartment.isEmpty()) ?
|
||||
null :
|
||||
(Specification<DepartmentEntity>)
|
||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.like(root.get("nmDepartment"), nmDepartment);
|
||||
}
|
||||
|
||||
DepartmentEntity findByHeadquartersAndNmDepartment(HeadquartersEntity headquartersEntity, String nmDepartment);
|
||||
|
||||
static Specification<DepartmentEntity> nmDepartmentLike(String nmDepartment) {
|
||||
return (nmDepartment == null || nmDepartment.isEmpty()) ?
|
||||
null :
|
||||
(Specification<DepartmentEntity>)
|
||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.like(root.get("nmDepartment"), "%" + nmDepartment + "%");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
package com.example.rhizome.app.infra.repository;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.example.rhizome.app.infra.entity.DivisionEntity;
|
||||
|
||||
@Repository
|
||||
public interface DivisionRepository
|
||||
extends JpaRepository<DivisionEntity, Integer>, JpaSpecificationExecutor<DivisionEntity> {
|
||||
|
||||
static Specification<DivisionEntity> idDivisionEqual(Integer idDivision) {
|
||||
return idDivision == null ? null :
|
||||
// 戻り値の型 Specification<DepartmentEntity> にキャスト
|
||||
(Specification<DivisionEntity>)
|
||||
// ラムダ式で記載しているが書いてあることは criteriaBuilder を使って Where句の後の "'idDepartment' = idDepartment(変数)"
|
||||
// を作成している
|
||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.equal(root.get("idDivision"), idDivision);
|
||||
}
|
||||
|
||||
static Specification<DivisionEntity> nmDivisionEqual(String nmDivision) {
|
||||
return (nmDivision == null || nmDivision.isEmpty()) ? null
|
||||
: (Specification<DivisionEntity>) (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder
|
||||
.like(root.get("nmDivision"), nmDivision);
|
||||
}
|
||||
|
||||
static Specification<DivisionEntity> idDepartmentEqual(Integer idDepartment) {
|
||||
return idDepartment == null ? null :
|
||||
// 戻り値の型 Specification<DepartmentEntity> にキャスト
|
||||
(Specification<DivisionEntity>)
|
||||
// ラムダ式で記載しているが書いてあることは criteriaBuilder を使って Where句の後の "'idDepartment' = idDepartment(変数)"
|
||||
// を作成している
|
||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.equal(root.get("idDepartment"), idDepartment);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Modifying
|
||||
@Query("DELETE FROM DivisionEntity di "
|
||||
+ "WHERE di.idDivision =:idDivision")
|
||||
|
||||
void deleteByIdDivision(Integer idDivision);
|
||||
}
|
||||
@@ -1,18 +1,11 @@
|
||||
package com.example.rhizome.app.infra.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.example.rhizome.app.infra.entity.EmployeeDepartmentEntity;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.data.jpa.repository.EntityGraph;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.example.rhizome.app.infra.entity.EmployeeDepartmentEntity;
|
||||
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||
|
||||
/**
|
||||
* ワンポイント情報(ここで登場する関数型インターフェース Specification について解説します)
|
||||
* Specification:
|
||||
@@ -27,48 +20,42 @@ import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||
* 戻り値はクエリを格納しているPredicateオブジェクトとなります。
|
||||
*/
|
||||
@Repository
|
||||
public interface EmployeeInfoRepository
|
||||
extends JpaRepository<EmployeeEntity, Integer>, JpaSpecificationExecutor<EmployeeEntity> {
|
||||
public interface EmployeeInfoRepository extends JpaRepository<EmployeeDepartmentEntity, Integer>, JpaSpecificationExecutor<EmployeeDepartmentEntity> {
|
||||
|
||||
static Specification<EmployeeEntity> idEmployeeEqual(Integer idEmployee) {
|
||||
return idEmployee == null ? null :
|
||||
// 戻り値の型 Specification<EmployeeDepartmentEntity> にキャスト
|
||||
(Specification<EmployeeEntity>)
|
||||
// ラムダ式で記載しているが書いてあることは criteriaBuilder を使って Where句の後の "'idEmployee' = idEmployee(変数)"
|
||||
// を作成している
|
||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.equal(root.get("idEmployee"), idEmployee);
|
||||
}
|
||||
static Specification<EmployeeDepartmentEntity> idEmployeeEqual(Integer idEmployee) {
|
||||
return idEmployee == null ?
|
||||
null :
|
||||
// 戻り値の型 Specification<EmployeeDepartmentEntity> にキャスト
|
||||
(Specification<EmployeeDepartmentEntity>)
|
||||
// ラムダ式で記載しているが書いてあることは criteriaBuilder を使って Where句の後の "'idEmployee' = idEmployee(変数)"
|
||||
// を作成している
|
||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.equal(root.get("idEmployee"), idEmployee);
|
||||
}
|
||||
|
||||
static Specification<EmployeeEntity> nmEmployeeEqual(String nmEmployee) {
|
||||
return (nmEmployee == null || nmEmployee.isEmpty()) ? null
|
||||
: (Specification<EmployeeEntity>) (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder
|
||||
.like(root.get("nmEmployee"), "%" + nmEmployee + "%");
|
||||
}
|
||||
static Specification<EmployeeDepartmentEntity> nmEmployeeEqual(String nmEmployee) {
|
||||
return (nmEmployee == null || nmEmployee.isEmpty()) ?
|
||||
null :
|
||||
(Specification<EmployeeDepartmentEntity>)
|
||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.like(root.get("nmEmployee"), "%" + nmEmployee + "%");
|
||||
}
|
||||
|
||||
static Specification<EmployeeEntity> knEmployeeEqual(String knEmployee) {
|
||||
return (knEmployee == null || knEmployee.isEmpty()) ? null
|
||||
: (Specification<EmployeeEntity>) (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder
|
||||
.like(root.get("knEmployee"), "%" + knEmployee + "%");
|
||||
}
|
||||
static Specification<EmployeeDepartmentEntity> knEmployeeEqual(String knEmployee) {
|
||||
return (knEmployee == null || knEmployee.isEmpty()) ?
|
||||
null :
|
||||
(Specification<EmployeeDepartmentEntity>)
|
||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.like(root.get("knEmployee"), "%" + knEmployee + "%");
|
||||
}
|
||||
|
||||
static Specification<EmployeeEntity> mailAddressEqual(String mailAddress) {
|
||||
return (mailAddress == null || mailAddress.isEmpty()) ? null
|
||||
: (Specification<EmployeeEntity>) (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder
|
||||
.like(root.get("mailAddress"), "%" + mailAddress + "%");
|
||||
}
|
||||
static Specification<EmployeeDepartmentEntity> mailAddressEqual(String mailAddress) {
|
||||
return (mailAddress == null || mailAddress.isEmpty()) ?
|
||||
null :
|
||||
(Specification<EmployeeDepartmentEntity>)
|
||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.like(root.get("mailAddress"), "%" + mailAddress + "%");
|
||||
}
|
||||
|
||||
static Specification<EmployeeEntity> idDivisionEqual(Integer idDivision) {
|
||||
return (root, query, criteriaBuilder) -> idDivision == null ? null
|
||||
: criteriaBuilder.equal(root.join("division").get("idDivision"), idDivision);
|
||||
}
|
||||
|
||||
@Query("SELECT DISTINCT new com.example.rhizome.app.infra.entity.EmployeeDepartmentEntity(e,di,de,h)FROM EmployeeEntity e "
|
||||
+ "INNER JOIN e.division di "
|
||||
+ "INNER JOIN di.department de "
|
||||
+ "INNER JOIN de.headquarters h ")
|
||||
List<EmployeeDepartmentEntity> findAlltable();
|
||||
|
||||
//全てのテーブルを結合してから検索
|
||||
@EntityGraph(attributePaths = { "division", "division.department", "division.department.headquarters" })
|
||||
List<EmployeeEntity> findAll(@Nullable Specification<EmployeeEntity> spec);
|
||||
static Specification<EmployeeDepartmentEntity> idDepartmentEqual(Integer idDepartment) {
|
||||
return (root, query, criteriaBuilder) ->
|
||||
idDepartment == null ? null :
|
||||
criteriaBuilder.equal(root.join("department").get("idDepartment"), idDepartment);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,32 +1,28 @@
|
||||
package com.example.rhizome.app.infra.repository;
|
||||
|
||||
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.example.rhizome.app.infra.entity.EmployeeEntity;
|
||||
import com.example.rhizome.app.infra.entity.InsertEmployeeEntity;
|
||||
|
||||
@Repository
|
||||
public interface EmployeeRepository extends JpaRepository<EmployeeEntity, Integer> {
|
||||
Optional<EmployeeEntity> findByMailAddressAndPassword(String mailAddress, String password);
|
||||
Optional<EmployeeEntity> findByMailAddressAndPassword(String mailAddress, String password);
|
||||
|
||||
/**
|
||||
* メールアドレスで検索
|
||||
**/
|
||||
Optional<EmployeeEntity> findByMailAddress(String mail);
|
||||
/**
|
||||
* メールアドレスで検索
|
||||
**/
|
||||
Optional<EmployeeEntity> findByMailAddress(String mail);
|
||||
|
||||
/**
|
||||
* IDで検索
|
||||
**/
|
||||
Optional<EmployeeEntity> findByIdEmployee(Integer idEmployee);
|
||||
/**
|
||||
* IDで検索
|
||||
**/
|
||||
Optional<EmployeeEntity> findByIdEmployee(Integer idEmployee);
|
||||
|
||||
/**
|
||||
* IDで検索
|
||||
**/
|
||||
List<EmployeeEntity> findByDivision_idDivision(Integer idDivision);
|
||||
|
||||
void save(InsertEmployeeEntity insertEmployeeEntity);
|
||||
/**
|
||||
* IDで検索
|
||||
**/
|
||||
List<EmployeeEntity> findByIdDepartment(Integer idDepartment);
|
||||
}
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
package com.example.rhizome.app.infra.repository;
|
||||
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.example.rhizome.app.infra.entity.HeadquartersEntity;
|
||||
|
||||
@Repository
|
||||
public interface HeadquartersRepository
|
||||
extends JpaRepository<HeadquartersEntity, Integer>, JpaSpecificationExecutor<HeadquartersEntity> {
|
||||
static Specification<HeadquartersEntity> idHeadquartersEqual(Integer idHeadquarters) {
|
||||
return idHeadquarters == null ? null :
|
||||
// 戻り値の型 Specification<DepartmentEntity> にキャスト
|
||||
(Specification<HeadquartersEntity>)
|
||||
// ラムダ式で記載しているが書いてあることは criteriaBuilder を使って Where句の後の "'idDepartment' = idDepartment(変数)"
|
||||
// を作成している
|
||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.equal(root.get("idHeadquarters"),
|
||||
idHeadquarters);
|
||||
}
|
||||
|
||||
static Specification<HeadquartersEntity> nmHeadquartersEqual(String nmHeadquarters) {
|
||||
return (nmHeadquarters == null || nmHeadquarters.isEmpty()) ? null
|
||||
: (Specification<HeadquartersEntity>) (root, criteriaQuery, criteriaBuilder) -> criteriaBuilder
|
||||
.like(root.get("nmHeadquarters"), nmHeadquarters);
|
||||
}
|
||||
|
||||
HeadquartersEntity findByNmHeadquarters(String nmHeadquarters);
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package com.example.rhizome.app.infra.repository;
|
||||
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.example.rhizome.app.infra.entity.RegisterDepartmentEntity;
|
||||
|
||||
@Repository
|
||||
public interface RegisterDepartmentRepository
|
||||
extends JpaRepository<RegisterDepartmentEntity, Integer>, JpaSpecificationExecutor<RegisterDepartmentEntity> {
|
||||
static Specification<RegisterDepartmentEntity> idHeadquartersEqual(Integer idHeadquarters) {
|
||||
|
||||
return idHeadquarters == null ? null :
|
||||
//戻り値の型 Specification<DepartmentEntity> にキャスト
|
||||
(Specification<RegisterDepartmentEntity>)
|
||||
|
||||
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.equal(root.get("idHeadquarters"),
|
||||
idHeadquarters);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,18 +1,5 @@
|
||||
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.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;
|
||||
@@ -23,6 +10,18 @@ import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAt
|
||||
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;
|
||||
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 javax.servlet.http.HttpSession;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.DELETE_DEPARTMENT;
|
||||
|
||||
/**
|
||||
* 削除処理のコントロータ
|
||||
@@ -30,95 +29,96 @@ 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 Logger LOGGER = Logger.getLogger(DeleteDepartmentController.class.getName());
|
||||
|
||||
// エラーメッセージ用の定数フィールド
|
||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||
// エラーメッセージ用の定数フィールド
|
||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||
|
||||
HttpSession httpSession;
|
||||
DeleteDepartment deleteDepartment;
|
||||
SearchDepartment searchDepartment;
|
||||
SearchEmployee searchEmployee;
|
||||
HttpSession httpSession;
|
||||
DeleteDepartment deleteDepartment;
|
||||
SearchDepartment searchDepartment;
|
||||
SearchEmployee searchEmployee;
|
||||
|
||||
@Autowired
|
||||
public DeleteDepartmentController(
|
||||
DeleteDepartment deleteDepartment,
|
||||
SearchDepartment searchDepartment,
|
||||
SearchEmployee searchEmployee,
|
||||
HttpSession httpSession) {
|
||||
this.httpSession = httpSession;
|
||||
this.deleteDepartment = deleteDepartment;
|
||||
this.searchDepartment = searchDepartment;
|
||||
this.searchEmployee = searchEmployee;
|
||||
}
|
||||
@Autowired
|
||||
public DeleteDepartmentController(
|
||||
DeleteDepartment deleteDepartment,
|
||||
SearchDepartment searchDepartment,
|
||||
SearchEmployee searchEmployee,
|
||||
HttpSession httpSession
|
||||
) {
|
||||
this.httpSession = httpSession;
|
||||
this.deleteDepartment = deleteDepartment;
|
||||
this.searchDepartment = searchDepartment;
|
||||
this.searchEmployee = searchEmployee;
|
||||
}
|
||||
|
||||
/**
|
||||
* 削除処理のコントローラ
|
||||
*
|
||||
* @param idDivision 削除対象のidDivision
|
||||
* @param model ビューにデータを渡すためのコンテナ
|
||||
* @return 遷移先の画面
|
||||
*/
|
||||
@PermissionCheck
|
||||
@SessionCheck
|
||||
@RequestMapping(value = DELETE_DEPARTMENT, method = RequestMethod.POST)
|
||||
public String deleteEmployee(@RequestParam("idDivision") Integer idDivision, Model model) {
|
||||
/**
|
||||
* 削除処理のコントローラ
|
||||
*
|
||||
* @param idDepartment 削除対象のidDepartment
|
||||
* @param model ビューにデータを渡すためのコンテナ
|
||||
* @return 遷移先の画面
|
||||
*/
|
||||
@PermissionCheck
|
||||
@SessionCheck
|
||||
@RequestMapping(value = DELETE_DEPARTMENT, method = RequestMethod.POST)
|
||||
public String deleteEmployee(@RequestParam("idDepartment") Integer idDepartment, Model model) {
|
||||
|
||||
try {
|
||||
try {
|
||||
|
||||
// 削除処理実施
|
||||
deleteExec(model, idDivision);
|
||||
// 削除処理実施
|
||||
deleteExec(model, idDepartment);
|
||||
|
||||
// 部署一覧を取得し、画面に返す用のクラスに詰め替える
|
||||
// 作成した部署一覧をセット
|
||||
model.addAttribute(
|
||||
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||
DepartmentForm.convertFrom(
|
||||
searchDepartment.searchAllDepartmentTable()));
|
||||
// 部署一覧を取得し、画面に返す用のクラスに詰め替える
|
||||
// 作成した部署一覧をセット
|
||||
model.addAttribute(
|
||||
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||
DepartmentForm.convertFrom(searchDepartment.selectAll())
|
||||
);
|
||||
|
||||
// 検索画面に遷移
|
||||
return "forward:" + TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_ALL;
|
||||
// 検索画面に遷移
|
||||
return "forward:" + TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_ALL;
|
||||
|
||||
} catch (Exception e) {
|
||||
// ログイン情報の破棄
|
||||
httpSession.invalidate();
|
||||
} catch (Exception e) {
|
||||
// ログイン情報の破棄
|
||||
httpSession.invalidate();
|
||||
|
||||
e.printStackTrace();
|
||||
// エラーログ出力
|
||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||
// エラー画面遷移
|
||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||
}
|
||||
}
|
||||
e.printStackTrace();
|
||||
// エラーログ出力
|
||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||
// エラー画面遷移
|
||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 削除処理実施
|
||||
*
|
||||
* @param model ビューにデータを渡すためのコンテナ
|
||||
* @param idDepartment 削除対象のidDepartment
|
||||
*/
|
||||
private void deleteExec(Model model, Integer idDivision) {
|
||||
/**
|
||||
* 削除処理実施
|
||||
*
|
||||
* @param model ビューにデータを渡すためのコンテナ
|
||||
* @param idDepartment 削除対象のidDepartment
|
||||
*/
|
||||
private void deleteExec(Model model, Integer idDepartment) {
|
||||
|
||||
final String DELETE_TARGET_ID_CAN_NOT_DELETE = "1名以上が所属している部署は削除出来ません。";
|
||||
final String DELETE_COMPLETE = "削除しました。";
|
||||
final String DELETE_TARGET_ID_CAN_NOT_DELETE = "1名以上が所属している部署は削除出来ません。";
|
||||
final String DELETE_COMPLETE = "削除しました。";
|
||||
|
||||
// 1名上所属している人が居れば削除不可
|
||||
if (!searchEmployee.searchEmployeeByIdDepartment(idDivision).isEmpty()) {
|
||||
// 削除対象だった場合
|
||||
// エラーメッセージをセット
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR,
|
||||
new MessageForm(DELETE_TARGET_ID_CAN_NOT_DELETE));
|
||||
// 検索画面に遷移
|
||||
return;
|
||||
}
|
||||
// 1名上所属している人が居れば削除不可
|
||||
if (!searchEmployee.searchEmployeeByIdDepartment(idDepartment).isEmpty()) {
|
||||
// 削除対象だった場合
|
||||
// エラーメッセージをセット
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DELETE_TARGET_ID_CAN_NOT_DELETE));
|
||||
// 検索画面に遷移
|
||||
return;
|
||||
}
|
||||
|
||||
// 削除を実施
|
||||
deleteDepartment.deleteDepartment(idDivision);
|
||||
// 削除を実施
|
||||
deleteDepartment.deleteDepartment(idDepartment);
|
||||
|
||||
// 削除完了したメッセージをセット
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_INFO, new MessageForm(DELETE_COMPLETE));
|
||||
// 削除完了したメッセージをセット
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_INFO, new MessageForm(DELETE_COMPLETE));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,21 +1,6 @@
|
||||
package com.example.rhizome.app.presentation.controller;
|
||||
|
||||
|
||||
import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.*;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import com.example.rhizome.aop.aspect.PermissionCheck;
|
||||
import com.example.rhizome.aop.aspect.SessionCheck;
|
||||
import com.example.rhizome.app.domain.model.LoginUser;
|
||||
@@ -27,6 +12,19 @@ import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTa
|
||||
import com.example.rhizome.app.presentation.form.DepartmentForm;
|
||||
import com.example.rhizome.app.presentation.form.LoginUserForm;
|
||||
import com.example.rhizome.app.presentation.form.MessageForm;
|
||||
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 javax.servlet.http.HttpSession;
|
||||
import java.util.Objects;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.DELETE_EMPLOYEE;
|
||||
|
||||
/**
|
||||
* 削除処理のコントロータ
|
||||
@@ -68,16 +66,14 @@ public class DeleteEmployeeController {
|
||||
// 作成した部署一覧をセット
|
||||
model.addAttribute(
|
||||
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||
DepartmentForm.convertFrom(
|
||||
searchDepartment.searchAllDepartmentTable())
|
||||
DepartmentForm.convertFrom(searchDepartment.selectAll())
|
||||
);
|
||||
|
||||
// 削除処理実施
|
||||
deleteExec(
|
||||
model,
|
||||
idEmployee,
|
||||
LoginUserForm.convertTo(
|
||||
(LoginUserForm) httpSession.getAttribute(SessionKeyword.LOGIN_USER)));
|
||||
LoginUserForm.convertTo((LoginUserForm) httpSession.getAttribute(SessionKeyword.LOGIN_USER)));
|
||||
|
||||
// 検索画面に遷移
|
||||
return "forward:" + TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_INFO_FORM_EMPTY;
|
||||
|
||||
@@ -1,51 +1,50 @@
|
||||
package com.example.rhizome.app.presentation.controller;
|
||||
|
||||
import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.*;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import com.example.rhizome.app.domain.service.impl.LoginImpl;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
|
||||
import com.example.rhizome.app.presentation.form.LoginUserForm;
|
||||
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 com.example.rhizome.app.domain.service.impl.LoginImpl;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
|
||||
import com.example.rhizome.app.presentation.form.LoginUserForm;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.*;
|
||||
|
||||
@Controller
|
||||
public class IndexController {
|
||||
|
||||
HttpSession httpSession;
|
||||
HttpSession httpSession;
|
||||
|
||||
@Autowired
|
||||
public IndexController(HttpSession httpSession, LoginImpl loginImpl) {
|
||||
this.httpSession = httpSession;
|
||||
}
|
||||
@Autowired
|
||||
public IndexController(HttpSession httpSession, LoginImpl loginImpl) {
|
||||
this.httpSession = httpSession;
|
||||
}
|
||||
|
||||
@ModelAttribute
|
||||
public LoginUserForm loginUserForm() {
|
||||
return new LoginUserForm();
|
||||
}
|
||||
@ModelAttribute
|
||||
public LoginUserForm loginUserForm() {
|
||||
return new LoginUserForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* ログイン画面表示処理
|
||||
*
|
||||
* @param model ビューにデータを渡すためのコンテナ
|
||||
* @return 遷移先の画面
|
||||
*/
|
||||
@RequestMapping(value = { INDEX_BLANK, INDEX_SLASH, INDEX_LOGIN })
|
||||
public String index(Model model) {
|
||||
// セッション情報を破棄
|
||||
if (httpSession != null) {
|
||||
httpSession.invalidate();
|
||||
}
|
||||
/**
|
||||
* ログイン画面表示処理
|
||||
*
|
||||
* @param model ビューにデータを渡すためのコンテナ
|
||||
* @return 遷移先の画面
|
||||
*/
|
||||
@RequestMapping(value = {INDEX_BLANK, INDEX_SLASH, INDEX_LOGIN})
|
||||
public String index(Model model) {
|
||||
// セッション情報を破棄
|
||||
if (httpSession != null) {
|
||||
httpSession.invalidate();
|
||||
}
|
||||
|
||||
// 空のFormをSessionに用意
|
||||
model.addAttribute(PageReturnAttributeKeyword.LOGIN_INFO_FORM, loginUserForm());
|
||||
// 空のFormをSessionに用意
|
||||
model.addAttribute(PageReturnAttributeKeyword.LOGIN_INFO_FORM, loginUserForm());
|
||||
|
||||
// ログイン画面に遷移
|
||||
return LOGIN_HTML;
|
||||
}
|
||||
// ログイン画面に遷移
|
||||
return LOGIN_HTML;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,5 @@
|
||||
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.model.SearchConditionDepartment;
|
||||
@@ -21,9 +7,21 @@ 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.DepartmentForm;
|
||||
import com.example.rhizome.app.presentation.form.InsertDepartmentForm;
|
||||
import com.example.rhizome.app.presentation.form.MessageForm;
|
||||
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 javax.servlet.http.HttpSession;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_CONFIRM;
|
||||
import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_INPUT_HTML;
|
||||
|
||||
/**
|
||||
* 新規部署情報チェック用のコントローラ
|
||||
@@ -31,98 +29,89 @@ import com.example.rhizome.app.presentation.form.MessageForm;
|
||||
@Controller
|
||||
public class InsertDepartmentConfirmController {
|
||||
|
||||
// ログ出力用インスタンス
|
||||
private final static Logger LOGGER = Logger.getLogger(InsertDepartmentConfirmController.class.getName());
|
||||
// ログ出力用インスタンス
|
||||
private final static Logger LOGGER = Logger.getLogger(InsertDepartmentConfirmController.class.getName());
|
||||
|
||||
// エラーメッセージ用の定数フィールド
|
||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||
// エラーメッセージ用の定数フィールド
|
||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||
|
||||
HttpSession httpSession;
|
||||
SearchDepartment searchDepartment;
|
||||
HttpSession httpSession;
|
||||
SearchDepartment searchDepartment;
|
||||
|
||||
@Autowired
|
||||
public InsertDepartmentConfirmController(
|
||||
HttpSession httpSession,
|
||||
SearchDepartmentImpl searchDepartment) {
|
||||
this.httpSession = httpSession;
|
||||
this.searchDepartment = searchDepartment;
|
||||
}
|
||||
@Autowired
|
||||
public InsertDepartmentConfirmController(
|
||||
HttpSession httpSession,
|
||||
SearchDepartmentImpl searchDepartment
|
||||
) {
|
||||
this.httpSession = httpSession;
|
||||
this.searchDepartment = searchDepartment;
|
||||
}
|
||||
|
||||
@ModelAttribute
|
||||
public InsertDepartmentForm insertDepartmentForm() {
|
||||
return new InsertDepartmentForm();
|
||||
}
|
||||
@ModelAttribute
|
||||
public InsertDepartmentForm insertDepartmentForm() {
|
||||
return new InsertDepartmentForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* 登録情報のチェックを行う
|
||||
*
|
||||
* @param insertDepartmentForm 登録情報
|
||||
* @param model ビューにデータを渡すためのコンテナ
|
||||
* @return 遷移先の画面
|
||||
*/
|
||||
@PermissionCheck
|
||||
@SessionCheck
|
||||
@RequestMapping(value = INSERT_DEPARTMENT_CONFIRM, method = RequestMethod.POST)
|
||||
public String insertDepartmentConfirm(InsertDepartmentForm insertDepartmentForm, Model model) {
|
||||
/**
|
||||
* 登録情報のチェックを行う
|
||||
*
|
||||
* @param insertDepartmentForm 登録情報
|
||||
* @param model ビューにデータを渡すためのコンテナ
|
||||
* @return 遷移先の画面
|
||||
*/
|
||||
@PermissionCheck
|
||||
@SessionCheck
|
||||
@RequestMapping(value = INSERT_DEPARTMENT_CONFIRM, method = RequestMethod.POST)
|
||||
public String insertDepartmentConfirm(InsertDepartmentForm insertDepartmentForm, Model model) {
|
||||
|
||||
final String DUPLICATION = "既に同名の本部名または部または課が存在します。";
|
||||
final String IRREGULARITY = "本部名または部または課が不正です。";
|
||||
final String DUPLICATION = "既に同名の部署が存在します。";
|
||||
final String IRREGULARITY = "部署名が不正です。";
|
||||
|
||||
try {
|
||||
model.addAttribute(
|
||||
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||
DepartmentForm.convertFrom(
|
||||
searchDepartment.searchAllDepartmentTable()));
|
||||
try {
|
||||
|
||||
// 入力内容に誤りがあるか
|
||||
if (insertDepartmentForm.haveNmDepartment()) {
|
||||
// 誤りがあった場合
|
||||
// 誤りがあった箇所のエラーメッセージを表示
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(IRREGULARITY));
|
||||
// 画面に返す為の登録情報をセット
|
||||
model.addAttribute(PageReturnAttributeKeyword.INSERT_DEPARTMENT_FORM, insertDepartmentForm);
|
||||
// 登録画面に遷移
|
||||
return INSERT_DEPARTMENT_INPUT_HTML;
|
||||
}
|
||||
//重複のチェック用の各部署のSearchConditionDeopartmentを用意
|
||||
SearchConditionDepartment searchHeadquartersTable = new SearchConditionDepartment(
|
||||
null,
|
||||
insertDepartmentForm.getNmHeadquarters());
|
||||
SearchConditionDepartment searchDepartmentTable = new SearchConditionDepartment(
|
||||
null,
|
||||
insertDepartmentForm.getNmDepartment());
|
||||
SearchConditionDepartment searchDivisionTable = new SearchConditionDepartment(
|
||||
null,
|
||||
insertDepartmentForm.getNmDivision());
|
||||
// 入力内容に誤りがあるか
|
||||
if (insertDepartmentForm.haveNmDepartment()) {
|
||||
// 誤りがあった場合
|
||||
// 誤りがあった箇所のエラーメッセージを表示
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(IRREGULARITY));
|
||||
// 画面に返す為の登録情報をセット
|
||||
model.addAttribute(PageReturnAttributeKeyword.INSERT_DEPARTMENT_FORM, insertDepartmentForm);
|
||||
// 登録画面に遷移
|
||||
return INSERT_DEPARTMENT_INPUT_HTML;
|
||||
}
|
||||
// 部署名で重複が無いかチェック
|
||||
if (!searchDepartment.searchBy(
|
||||
new SearchConditionDepartment(
|
||||
null,
|
||||
insertDepartmentForm.getNmDepartment())).isEmpty()) {
|
||||
|
||||
// 部署の組み合わせで重複が無いかチェック
|
||||
if (searchDepartment.searchAllDepartmentTable(
|
||||
searchHeadquartersTable,
|
||||
searchDepartmentTable,
|
||||
searchDivisionTable)) {
|
||||
|
||||
// 存在する場合はエラーメッセージを設定して更新入力画面に遷移
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DUPLICATION));
|
||||
model.addAttribute(PageReturnAttributeKeyword.INSERT_DEPARTMENT_FORM, insertDepartmentForm);
|
||||
// 存在する場合はエラーメッセージを設定して更新入力画面に遷移
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DUPLICATION));
|
||||
model.addAttribute(PageReturnAttributeKeyword.INSERT_DEPARTMENT_FORM, insertDepartmentForm);
|
||||
|
||||
return TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_INPUT_HTML;
|
||||
}
|
||||
return TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_INPUT_HTML;
|
||||
}
|
||||
|
||||
// 登録確認ページに遷移
|
||||
model.addAttribute(PageReturnAttributeKeyword.INSERT_DEPARTMENT_FORM, insertDepartmentForm);
|
||||
// 登録確認画面に遷移
|
||||
return TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_CONFIRM_HTML;
|
||||
// 登録確認ページに遷移
|
||||
model.addAttribute(PageReturnAttributeKeyword.INSERT_DEPARTMENT_FORM, insertDepartmentForm);
|
||||
// 登録確認画面に遷移
|
||||
return TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_CONFIRM_HTML;
|
||||
|
||||
} catch (Exception e) {
|
||||
// ログイン情報の破棄
|
||||
httpSession.invalidate();
|
||||
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
// ログイン情報の破棄
|
||||
httpSession.invalidate();
|
||||
|
||||
// エラーログ出力
|
||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||
// エラー画面遷移
|
||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||
}
|
||||
}
|
||||
e.printStackTrace();
|
||||
|
||||
// エラーログ出力
|
||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||
// エラー画面遷移
|
||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
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 com.example.rhizome.aop.aspect.PermissionCheck;
|
||||
import com.example.rhizome.aop.aspect.SessionCheck;
|
||||
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.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.InsertDepartmentForm;
|
||||
import com.example.rhizome.app.presentation.form.MessageForm;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
@@ -14,19 +17,12 @@ 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.DepartmentInfo;
|
||||
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.SearchDepartmentImpl;
|
||||
import com.example.rhizome.app.infra.entity.DivisionEntity;
|
||||
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.InsertDepartmentForm;
|
||||
import com.example.rhizome.app.presentation.form.MessageForm;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.INSERT_DEPARTMENT;
|
||||
import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_INPUT_HTML;
|
||||
|
||||
/**
|
||||
* 新規登録用のコントローラ
|
||||
@@ -34,104 +30,94 @@ import com.example.rhizome.app.presentation.form.MessageForm;
|
||||
@Controller
|
||||
public class InsertDepartmentController {
|
||||
|
||||
private final SearchDepartmentImpl searchDepartmentImpl;
|
||||
// ログ出力用インスタンス
|
||||
private final static Logger LOGGER = Logger.getLogger(InsertDepartmentController.class.getName());
|
||||
|
||||
// ログ出力用インスタンス
|
||||
private final static Logger LOGGER = Logger.getLogger(InsertDepartmentController.class.getName());
|
||||
// エラーメッセージ用の定数フィールド
|
||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||
|
||||
// エラーメッセージ用の定数フィールド
|
||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||
HttpSession httpSession;
|
||||
RegisterDepartment registerDepartment;
|
||||
SearchDepartment searchDepartment;
|
||||
|
||||
HttpSession httpSession;
|
||||
RegisterDepartment registerDepartment;
|
||||
SearchDepartment searchDepartment;
|
||||
@Autowired
|
||||
public InsertDepartmentController(HttpSession httpSession, RegisterDepartment registerDepartment, SearchDepartment searchDepartment) {
|
||||
this.httpSession = httpSession;
|
||||
this.registerDepartment = registerDepartment;
|
||||
this.searchDepartment = searchDepartment;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public InsertDepartmentController(HttpSession httpSession, RegisterDepartment registerDepartment,
|
||||
SearchDepartment searchDepartment, SearchDepartmentImpl searchDepartmentImpl) {
|
||||
this.httpSession = httpSession;
|
||||
this.registerDepartment = registerDepartment;
|
||||
this.searchDepartment = searchDepartment;
|
||||
this.searchDepartmentImpl = searchDepartmentImpl;
|
||||
}
|
||||
@ModelAttribute
|
||||
public InsertDepartmentForm insertDepartmentForm() {
|
||||
return new InsertDepartmentForm();
|
||||
}
|
||||
|
||||
@ModelAttribute
|
||||
public InsertDepartmentForm insertDepartmentForm() {
|
||||
return new InsertDepartmentForm();
|
||||
}
|
||||
/**
|
||||
* 新規登録画面表示処理
|
||||
*
|
||||
* @param insertDepartmentForm 登録情報
|
||||
* @param model ビューにデータを渡すためのコンテナ
|
||||
* @return 遷移先の画面
|
||||
*/
|
||||
@PermissionCheck
|
||||
@SessionCheck
|
||||
@RequestMapping(value = INSERT_DEPARTMENT, method = RequestMethod.POST)
|
||||
public String insertDepartment(InsertDepartmentForm insertDepartmentForm, Model model) {
|
||||
|
||||
/**
|
||||
* 新規登録画面表示処理
|
||||
*
|
||||
* @param insertDepartmentForm 登録情報
|
||||
* @param model ビューにデータを渡すためのコンテナ
|
||||
* @return 遷移先の画面
|
||||
*/
|
||||
@PermissionCheck
|
||||
@SessionCheck
|
||||
@RequestMapping(value = INSERT_DEPARTMENT, method = RequestMethod.POST)
|
||||
public String insertDepartment(InsertDepartmentForm insertDepartmentForm, Model model) {
|
||||
final String DUPLICATION = "既に同名の部署が存在します。";
|
||||
final String IRREGULARITY = "部署名が不正です。";
|
||||
|
||||
final String DUPLICATION = "既に同名の部署が存在します。";
|
||||
final String IRREGULARITY = "部署名が不正です。";
|
||||
try {
|
||||
// 部署一覧を取得し、画面に返す用のクラスに詰め替える
|
||||
// 作成した部署一覧をセット
|
||||
model.addAttribute(
|
||||
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||
DepartmentForm.convertFrom(
|
||||
searchDepartment.selectAll()
|
||||
));
|
||||
|
||||
try {
|
||||
// 部署一覧を取得し、画面に返す用のクラスに詰め替える
|
||||
// 作成した部署一覧をセット
|
||||
model.addAttribute(
|
||||
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||
DepartmentForm.convertFrom(
|
||||
searchDepartment.searchAllDepartmentTable()));
|
||||
// 入力内容に誤りがあるか
|
||||
if (insertDepartmentForm.haveNmDepartment()) {
|
||||
// 誤りがあった場合
|
||||
// 誤りがあった箇所のエラーメッセージを表示
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(IRREGULARITY));
|
||||
// 画面に返す為の登録情報をセット
|
||||
model.addAttribute(PageReturnAttributeKeyword.INSERT_DEPARTMENT_FORM, insertDepartmentForm);
|
||||
// 登録画面に遷移
|
||||
return INSERT_DEPARTMENT_INPUT_HTML;
|
||||
}
|
||||
// 部署名で重複が無いかチェック
|
||||
if (!searchDepartment.searchBy(
|
||||
new SearchConditionDepartment(
|
||||
null,
|
||||
insertDepartmentForm.getNmDepartment())).isEmpty()) {
|
||||
|
||||
// 入力内容に誤りがあるか
|
||||
if (insertDepartmentForm.haveNmDepartment()) {
|
||||
// 誤りがあった場合
|
||||
// 誤りがあった箇所のエラーメッセージを表示
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(IRREGULARITY));
|
||||
// 画面に返す為の登録情報をセット
|
||||
model.addAttribute(PageReturnAttributeKeyword.INSERT_DEPARTMENT_FORM, insertDepartmentForm);
|
||||
// 登録画面に遷移
|
||||
return INSERT_DEPARTMENT_INPUT_HTML;
|
||||
}
|
||||
|
||||
// 部署の組み合わせで重複が無いかチェック
|
||||
if (searchDepartment.searchAllDepartmentTable(
|
||||
new SearchConditionDepartment(
|
||||
insertDepartmentForm.getIdHeadquarters(),
|
||||
insertDepartmentForm.getNmHeadquarters()),
|
||||
new SearchConditionDepartment(
|
||||
insertDepartmentForm.getIdDepartment(),
|
||||
insertDepartmentForm.getNmDepartment()),
|
||||
new SearchConditionDepartment(
|
||||
insertDepartmentForm.getIdDivision(),
|
||||
insertDepartmentForm.getNmDivision()))) {
|
||||
// 存在する場合はエラーメッセージを設定して更新入力画面に遷移
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DUPLICATION));
|
||||
model.addAttribute(PageReturnAttributeKeyword.INSERT_DEPARTMENT_FORM, insertDepartmentForm);
|
||||
|
||||
// 存在する場合はエラーメッセージを設定して更新入力画面に遷移
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DUPLICATION));
|
||||
model.addAttribute(PageReturnAttributeKeyword.INSERT_DEPARTMENT_FORM, insertDepartmentForm);
|
||||
return TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_INPUT_HTML;
|
||||
}
|
||||
|
||||
return TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_INPUT_HTML;
|
||||
}
|
||||
//divisionEntityにinsertDepartmentFormで画面から渡ってきた値を入れる
|
||||
DepartmentInfo departmentInfo = InsertDepartmentForm.convertTo(insertDepartmentForm);
|
||||
DivisionEntity divisionEntity = DivisionEntity.convertFrom(departmentInfo);
|
||||
// 登録処理
|
||||
registerDepartment.registerDepartment(InsertDepartmentForm.convertTo(insertDepartmentForm));
|
||||
// 登録結果画面に遷移
|
||||
return TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_RESULT_HTML;
|
||||
|
||||
// 登録処理
|
||||
registerDepartment.registerDepartment(divisionEntity);
|
||||
} catch (Exception e) {
|
||||
// ログイン情報の破棄
|
||||
httpSession.invalidate();
|
||||
|
||||
// 登録結果画面に遷移
|
||||
return TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_RESULT_HTML;
|
||||
e.printStackTrace();
|
||||
|
||||
} catch (Exception e) {
|
||||
// ログイン情報の破棄
|
||||
httpSession.invalidate();
|
||||
|
||||
e.printStackTrace();
|
||||
|
||||
// エラーログ出力
|
||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||
// エラー画面遷移
|
||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||
}
|
||||
}
|
||||
// エラーログ出力
|
||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||
// エラー画面遷移
|
||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package com.example.rhizome.app.presentation.controller;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import com.example.rhizome.aop.aspect.PermissionCheck;
|
||||
import com.example.rhizome.aop.aspect.SessionCheck;
|
||||
import com.example.rhizome.app.domain.service.SearchDepartment;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
||||
import com.example.rhizome.app.presentation.form.InsertDepartmentForm;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
@@ -12,15 +13,9 @@ import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
import com.example.rhizome.aop.aspect.PermissionCheck;
|
||||
import com.example.rhizome.aop.aspect.SessionCheck;
|
||||
import com.example.rhizome.app.domain.service.SearchDepartment;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
||||
import com.example.rhizome.app.presentation.form.DepartmentInfoForm;
|
||||
import com.example.rhizome.app.presentation.form.DivisionInfoForm;
|
||||
import com.example.rhizome.app.presentation.form.HeadquartersInfoForm;
|
||||
import com.example.rhizome.app.presentation.form.InsertDepartmentForm;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* 登録画面表示用コントローラ
|
||||
@@ -28,70 +23,62 @@ 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 Logger LOGGER = Logger.getLogger(InsertDepartmentInputController.class.getName());
|
||||
|
||||
// エラーメッセージ用の定数フィールド
|
||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||
// エラーメッセージ用の定数フィールド
|
||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||
|
||||
HttpSession httpSession;
|
||||
SearchDepartment searchDepartment;
|
||||
HttpSession httpSession;
|
||||
SearchDepartment searchDepartment;
|
||||
|
||||
@Autowired
|
||||
public InsertDepartmentInputController(
|
||||
HttpSession httpSession,
|
||||
SearchDepartment searchDepartment) {
|
||||
this.httpSession = httpSession;
|
||||
this.searchDepartment = searchDepartment;
|
||||
}
|
||||
@Autowired
|
||||
public InsertDepartmentInputController(
|
||||
HttpSession httpSession,
|
||||
SearchDepartment searchDepartment
|
||||
) {
|
||||
this.httpSession = httpSession;
|
||||
this.searchDepartment = searchDepartment;
|
||||
}
|
||||
|
||||
@ModelAttribute
|
||||
public InsertDepartmentForm insertDepartmentForm() {
|
||||
return new InsertDepartmentForm();
|
||||
}
|
||||
@ModelAttribute
|
||||
public InsertDepartmentForm insertDepartmentForm() {
|
||||
return new InsertDepartmentForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* 部署登録画面表示処理
|
||||
*
|
||||
* @param insertDepartmentForm 登録画面のフォーム
|
||||
* @param model ビューにデータを渡すためのコンテナ
|
||||
* @return 遷移先の画面
|
||||
*/
|
||||
@SessionCheck
|
||||
@PermissionCheck
|
||||
@RequestMapping(value = TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_INPUT, method = RequestMethod.POST)
|
||||
public String insertInput(InsertDepartmentForm insertDepartmentForm, Model model) {
|
||||
|
||||
try {
|
||||
//各部署情報を重複魚消して表示するために別々に画面へ送る
|
||||
model.addAttribute(
|
||||
PageReturnAttributeKeyword.HEADQUARTERS_FORM_LIST,
|
||||
HeadquartersInfoForm.convertFrom(
|
||||
searchDepartment.searchAllDepartmentTable()));
|
||||
model.addAttribute(
|
||||
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||
DepartmentInfoForm.convertFromTo(
|
||||
searchDepartment.searchAllDepartmentTable()));
|
||||
model.addAttribute(
|
||||
PageReturnAttributeKeyword.DIVISION_FORM_LIST,
|
||||
DivisionInfoForm.convertFromTo(
|
||||
searchDepartment.searchAllDepartmentTable()));
|
||||
// パラメータをセット
|
||||
model.addAttribute(PageReturnAttributeKeyword.INSERT_DEPARTMENT_FORM, insertDepartmentForm);
|
||||
/**
|
||||
* 部署登録画面表示処理
|
||||
*
|
||||
* @param insertDepartmentForm 登録画面のフォーム
|
||||
* @param model ビューにデータを渡すためのコンテナ
|
||||
* @return 遷移先の画面
|
||||
*/
|
||||
@SessionCheck
|
||||
@PermissionCheck
|
||||
@RequestMapping(value = TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_INPUT, method = RequestMethod.POST)
|
||||
public String insertInput(InsertDepartmentForm insertDepartmentForm, Model model) {
|
||||
|
||||
// 登録画面に遷移
|
||||
return TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_INPUT_HTML;
|
||||
try {
|
||||
// パラメータをセット
|
||||
model.addAttribute(PageReturnAttributeKeyword.INSERT_DEPARTMENT_FORM, insertDepartmentForm);
|
||||
|
||||
} catch (Exception e) {
|
||||
// ログイン情報の破棄
|
||||
httpSession.invalidate();
|
||||
// 登録画面に遷移
|
||||
return TransitionTargetPageNameKeyword.INSERT_DEPARTMENT_INPUT_HTML;
|
||||
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
// ログイン情報の破棄
|
||||
httpSession.invalidate();
|
||||
|
||||
// エラーログ出力
|
||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||
// エラー画面遷移
|
||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||
}
|
||||
}
|
||||
e.printStackTrace();
|
||||
|
||||
// エラーログ出力
|
||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||
// エラー画面遷移
|
||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,20 +1,5 @@
|
||||
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.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.Employee;
|
||||
@@ -27,6 +12,19 @@ import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTa
|
||||
import com.example.rhizome.app.presentation.form.DepartmentForm;
|
||||
import com.example.rhizome.app.presentation.form.InsertEmployeeForm;
|
||||
import com.example.rhizome.app.presentation.form.MessageForm;
|
||||
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 javax.servlet.http.HttpSession;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_CONFIRM;
|
||||
|
||||
/**
|
||||
* 新規登録者情報チェック用のコントローラ
|
||||
@@ -34,97 +32,102 @@ import com.example.rhizome.app.presentation.form.MessageForm;
|
||||
@Controller
|
||||
public class InsertEmployeeConfirmController {
|
||||
|
||||
// ログ出力用インスタンス
|
||||
private final static Logger LOGGER = Logger.getLogger(InsertEmployeeConfirmController.class.getName());
|
||||
// ログ出力用インスタンス
|
||||
private final static Logger LOGGER = Logger.getLogger(InsertEmployeeConfirmController.class.getName());
|
||||
|
||||
// エラーメッセージ用の定数フィールド
|
||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||
// エラーメッセージ用の定数フィールド
|
||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||
|
||||
HttpSession httpSession;
|
||||
SearchDepartment searchDepartment;
|
||||
SearchEmployee searchEmployee;
|
||||
HttpSession httpSession;
|
||||
SearchDepartment searchDepartment;
|
||||
SearchEmployee searchEmployee;
|
||||
|
||||
@Autowired
|
||||
public InsertEmployeeConfirmController(
|
||||
HttpSession httpSession,
|
||||
SearchDepartmentImpl searchDepartment,
|
||||
SearchEmployeeImpl searchEmployee) {
|
||||
this.httpSession = httpSession;
|
||||
this.searchDepartment = searchDepartment;
|
||||
this.searchEmployee = searchEmployee;
|
||||
}
|
||||
@Autowired
|
||||
public InsertEmployeeConfirmController(
|
||||
HttpSession httpSession,
|
||||
SearchDepartmentImpl searchDepartment,
|
||||
SearchEmployeeImpl searchEmployee
|
||||
) {
|
||||
this.httpSession = httpSession;
|
||||
this.searchDepartment = searchDepartment;
|
||||
this.searchEmployee = searchEmployee;
|
||||
}
|
||||
|
||||
@ModelAttribute
|
||||
public InsertEmployeeForm insertEmployeeForm() {
|
||||
return new InsertEmployeeForm();
|
||||
}
|
||||
@ModelAttribute
|
||||
public InsertEmployeeForm insertEmployeeForm() {
|
||||
return new InsertEmployeeForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* 登録情報のチェックを行う
|
||||
*
|
||||
* @param insertEmployeeForm 登録情報
|
||||
* @param model ビューにデータを渡すためのコンテナ
|
||||
* @return 遷移先の画面
|
||||
*/
|
||||
@PermissionCheck
|
||||
@SessionCheck
|
||||
@RequestMapping(value = INSERT_EMPLOYEE_CONFIRM, method = RequestMethod.POST)
|
||||
public String insertEmployeeConfirm(InsertEmployeeForm insertEmployeeForm, Model model) {
|
||||
/**
|
||||
* 登録情報のチェックを行う
|
||||
*
|
||||
* @param insertEmployeeForm 登録情報
|
||||
* @param model ビューにデータを渡すためのコンテナ
|
||||
* @return 遷移先の画面
|
||||
*/
|
||||
@PermissionCheck
|
||||
@SessionCheck
|
||||
@RequestMapping(value = INSERT_EMPLOYEE_CONFIRM, method = RequestMethod.POST)
|
||||
public String insertEmployeeConfirm(InsertEmployeeForm insertEmployeeForm, Model model) {
|
||||
|
||||
try {
|
||||
// 部署一覧を取得し、画面に返す用のクラスに詰め替える
|
||||
// 作成した部署一覧をセット
|
||||
model.addAttribute(
|
||||
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||
DepartmentForm.convertFrom(
|
||||
searchDepartment.searchAllDepartmentTable()));
|
||||
try {
|
||||
// 部署一覧を取得し、画面に返す用のクラスに詰め替える
|
||||
// 作成した部署一覧をセット
|
||||
model.addAttribute(
|
||||
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||
DepartmentForm.convertFrom(
|
||||
searchDepartment.selectAll()
|
||||
));
|
||||
|
||||
// 登録用パラメータチェック
|
||||
List<String> error = insertEmployeeForm.validateParameter();
|
||||
// 登録用パラメータチェック
|
||||
List<String> error = insertEmployeeForm.validateParameter();
|
||||
|
||||
// 入力内容に誤りがあるか
|
||||
if (!error.isEmpty()) {
|
||||
// 誤りがあった場合
|
||||
// 誤りがあった箇所のエラーメッセージを表示
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR,
|
||||
new MessageForm(String.join(", ", error) + "が不正です。"));
|
||||
// 画面に返す為の登録情報をセット
|
||||
model.addAttribute(PageReturnAttributeKeyword.INSERT_EMPLOYEE_FORM, insertEmployeeForm);
|
||||
// 登録画面に遷移
|
||||
return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML;
|
||||
}
|
||||
// 入力内容に誤りがあるか
|
||||
if (!error.isEmpty()) {
|
||||
// 誤りがあった場合
|
||||
// 誤りがあった箇所のエラーメッセージを表示
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(String.join(", ", error) + "が不正です。"));
|
||||
// 画面に返す為の登録情報をセット
|
||||
model.addAttribute(PageReturnAttributeKeyword.INSERT_EMPLOYEE_FORM, insertEmployeeForm);
|
||||
// 登録画面に遷移
|
||||
return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML;
|
||||
}
|
||||
|
||||
final String DUPLICATION = "既に登録済みのメールアドレスです。";
|
||||
final String DUPLICATION = "既に登録済みのメールアドレスです。";
|
||||
|
||||
// 登録対象のメールアドレスを元に検索
|
||||
List<Employee> employeeList = searchEmployee.searchEmployee(insertEmployeeForm.getMailAddress());
|
||||
// 登録対象のメールアドレスを元に検索
|
||||
List<Employee> employeeList = searchEmployee.searchEmployee(insertEmployeeForm.getMailAddress());
|
||||
|
||||
// 検索結果があるか
|
||||
if (!employeeList.isEmpty()) {
|
||||
// 検索した結果0件ではない場合
|
||||
// 重複を許さないため、エラー処理
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DUPLICATION));
|
||||
// 画面に返す為の登録情報をセット
|
||||
model.addAttribute(PageReturnAttributeKeyword.INSERT_EMPLOYEE_FORM, insertEmployeeForm);
|
||||
// 登録画面に遷移
|
||||
return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML;
|
||||
}
|
||||
// 検索結果があるか
|
||||
if (!employeeList.isEmpty()) {
|
||||
// 検索した結果0件ではない場合
|
||||
// 重複を許さないため、エラー処理
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DUPLICATION));
|
||||
// 画面に返す為の登録情報をセット
|
||||
model.addAttribute(PageReturnAttributeKeyword.INSERT_EMPLOYEE_FORM, insertEmployeeForm);
|
||||
// 登録画面に遷移
|
||||
return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML;
|
||||
}
|
||||
|
||||
// 登録確認ページに遷移
|
||||
model.addAttribute(PageReturnAttributeKeyword.INSERT_EMPLOYEE_FORM, insertEmployeeForm);
|
||||
// 登録確認画面に遷移
|
||||
return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_CONFIRM_HTML;
|
||||
// 登録確認ページに遷移
|
||||
model.addAttribute(PageReturnAttributeKeyword.INSERT_EMPLOYEE_FORM, insertEmployeeForm);
|
||||
// 登録確認画面に遷移
|
||||
return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_CONFIRM_HTML;
|
||||
|
||||
} catch (Exception e) {
|
||||
// ログイン情報の破棄
|
||||
httpSession.invalidate();
|
||||
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
// ログイン情報の破棄
|
||||
httpSession.invalidate();
|
||||
|
||||
// エラーログ出力
|
||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||
// エラー画面遷移
|
||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||
}
|
||||
}
|
||||
e.printStackTrace();
|
||||
|
||||
// エラーログ出力
|
||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||
// エラー画面遷移
|
||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,21 +1,5 @@
|
||||
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.service.RegisterEmployee;
|
||||
@@ -27,6 +11,20 @@ import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTa
|
||||
import com.example.rhizome.app.presentation.form.DepartmentForm;
|
||||
import com.example.rhizome.app.presentation.form.InsertEmployeeForm;
|
||||
import com.example.rhizome.app.presentation.form.MessageForm;
|
||||
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 javax.servlet.http.HttpSession;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.INSERT_EMPLOYEE;
|
||||
|
||||
/**
|
||||
* 新規登録用のコントローラ
|
||||
@@ -34,171 +32,167 @@ import com.example.rhizome.app.presentation.form.MessageForm;
|
||||
@Controller
|
||||
public class InsertEmployeeController {
|
||||
|
||||
// ログ出力用インスタンス
|
||||
private final static Logger LOGGER = Logger.getLogger(InsertEmployeeController.class.getName());
|
||||
// ログ出力用インスタンス
|
||||
private final static Logger LOGGER = Logger.getLogger(InsertEmployeeController.class.getName());
|
||||
|
||||
// エラーメッセージ用の定数フィールド
|
||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||
// エラーメッセージ用の定数フィールド
|
||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||
|
||||
HttpSession httpSession;
|
||||
RegisterEmployee registerEmployee;
|
||||
SearchDepartment searchDepartment;
|
||||
HttpSession httpSession;
|
||||
RegisterEmployee registerEmployee;
|
||||
SearchDepartment searchDepartment;
|
||||
|
||||
@Autowired
|
||||
public InsertEmployeeController(HttpSession httpSession, RegisterEmployeeImpl registerEmployee,
|
||||
SearchDepartmentImpl searchDepartment) {
|
||||
this.httpSession = httpSession;
|
||||
this.registerEmployee = registerEmployee;
|
||||
this.searchDepartment = searchDepartment;
|
||||
}
|
||||
@Autowired
|
||||
public InsertEmployeeController(HttpSession httpSession, RegisterEmployeeImpl registerEmployee, SearchDepartmentImpl searchDepartment) {
|
||||
this.httpSession = httpSession;
|
||||
this.registerEmployee = registerEmployee;
|
||||
this.searchDepartment = searchDepartment;
|
||||
}
|
||||
|
||||
@ModelAttribute
|
||||
public InsertEmployeeForm insertEmployeeForm() {
|
||||
return new InsertEmployeeForm();
|
||||
}
|
||||
@ModelAttribute
|
||||
public InsertEmployeeForm insertEmployeeForm() {
|
||||
return new InsertEmployeeForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* 新規登録画面表示処理
|
||||
*
|
||||
* @param insertEmployeeForm 登録情報
|
||||
* @param model ビューにデータを渡すためのコンテナ
|
||||
* @return 遷移先の画面
|
||||
*/
|
||||
@PermissionCheck
|
||||
@SessionCheck
|
||||
@RequestMapping(value = INSERT_EMPLOYEE, method = RequestMethod.POST)
|
||||
public String insertEmployee(InsertEmployeeForm insertEmployeeForm, Model model) {
|
||||
/**
|
||||
* 新規登録画面表示処理
|
||||
*
|
||||
* @param insertEmployeeForm 登録情報
|
||||
* @param model ビューにデータを渡すためのコンテナ
|
||||
* @return 遷移先の画面
|
||||
*/
|
||||
@PermissionCheck
|
||||
@SessionCheck
|
||||
@RequestMapping(value = INSERT_EMPLOYEE, method = RequestMethod.POST)
|
||||
public String insertEmployee(InsertEmployeeForm insertEmployeeForm, Model model) {
|
||||
|
||||
try {
|
||||
// 部署一覧を取得し、画面に返す用のクラスに詰め替える
|
||||
// 作成した部署一覧をセット
|
||||
model.addAttribute(
|
||||
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||
DepartmentForm.convertFrom(
|
||||
searchDepartment.searchAllDepartmentTable()));
|
||||
try {
|
||||
// 部署一覧を取得し、画面に返す用のクラスに詰め替える
|
||||
// 作成した部署一覧をセット
|
||||
model.addAttribute(
|
||||
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||
DepartmentForm.convertFrom(
|
||||
searchDepartment.selectAll()
|
||||
));
|
||||
|
||||
// Confirm画面から渡ってきた値をチェック
|
||||
List<String> error = validateParameter(
|
||||
insertEmployeeForm.getNmEmployee(),
|
||||
insertEmployeeForm.getKnEmployee(),
|
||||
insertEmployeeForm.getMailAddress(),
|
||||
insertEmployeeForm.getPassword(),
|
||||
insertEmployeeForm.getHireDate(),
|
||||
insertEmployeeForm.getAdminAuth(),
|
||||
insertEmployeeForm.getIdDivision());
|
||||
// Confirm画面から渡ってきた値をチェック
|
||||
List<String> error = validateParameter(
|
||||
insertEmployeeForm.getNmEmployee(),
|
||||
insertEmployeeForm.getKnEmployee(),
|
||||
insertEmployeeForm.getMailAddress(),
|
||||
insertEmployeeForm.getPassword(),
|
||||
insertEmployeeForm.getAdminAuth(),
|
||||
insertEmployeeForm.getIdDepartment()
|
||||
);
|
||||
|
||||
// エラーが1件以上有る場合
|
||||
if (!error.isEmpty()) {
|
||||
// エラー内容を画面に表示
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR,
|
||||
new MessageForm(String.join(", ", error) + "が不正です。"));
|
||||
// 登録画面に遷移
|
||||
return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML;
|
||||
}
|
||||
// エラーが1件以上有る場合
|
||||
if (!error.isEmpty()) {
|
||||
// エラー内容を画面に表示
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(String.join(", ", error) + "が不正です。"));
|
||||
// 登録画面に遷移
|
||||
return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML;
|
||||
}
|
||||
|
||||
// 登録処理
|
||||
registerEmployee.registerEmployee(InsertEmployeeForm.convertTo(insertEmployeeForm));
|
||||
// 登録結果画面に遷移
|
||||
return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_RESULT_HTML;
|
||||
// 登録処理
|
||||
registerEmployee.registerEmployee(InsertEmployeeForm.convertTo(insertEmployeeForm));
|
||||
// 登録結果画面に遷移
|
||||
return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_RESULT_HTML;
|
||||
|
||||
} catch (Exception e) {
|
||||
// ログイン情報の破棄
|
||||
httpSession.invalidate();
|
||||
} catch (Exception e) {
|
||||
// ログイン情報の破棄
|
||||
httpSession.invalidate();
|
||||
|
||||
e.printStackTrace();
|
||||
e.printStackTrace();
|
||||
|
||||
// エラーログ出力
|
||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||
// エラー画面遷移
|
||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||
}
|
||||
}
|
||||
// エラーログ出力
|
||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||
// エラー画面遷移
|
||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param employeeName 登録対象の名前
|
||||
* @param employeeKana 登録対象のカナ
|
||||
* @param mailAddress 登録対象のメールアドレス
|
||||
* @param password 登録対象のパスワード
|
||||
* @param management システム権限
|
||||
* @param departmentId 部署ID
|
||||
* @return エラーが有った場合はエラー文言、無ければ空のリストが返る
|
||||
*/
|
||||
private List<String> validateParameter(
|
||||
String employeeName,
|
||||
String employeeKana,
|
||||
String mailAddress,
|
||||
String password,
|
||||
String hireDate,
|
||||
Integer management,
|
||||
Integer departmentId) {
|
||||
/**
|
||||
* @param employeeName 登録対象の名前
|
||||
* @param employeeKana 登録対象のカナ
|
||||
* @param mailAddress 登録対象のメールアドレス
|
||||
* @param password 登録対象のパスワード
|
||||
* @param management システム権限
|
||||
* @param departmentId 部署ID
|
||||
* @return エラーが有った場合はエラー文言、無ければ空のリストが返る
|
||||
*/
|
||||
private List<String> validateParameter(
|
||||
String employeeName,
|
||||
String employeeKana,
|
||||
String mailAddress,
|
||||
String password,
|
||||
Integer management,
|
||||
Integer departmentId
|
||||
) {
|
||||
|
||||
final String EMPLOYEE_NAME_NULL_BLANK = "社員名";
|
||||
final String EMPLOYEE_KANA_NULL_BLANK = "社員名フリガナ";
|
||||
final String MAIL_ADDRESS_NULL_BLANK = "メールアドレス";
|
||||
final String PASSWORD_NULL_BLANK = "パスワード";
|
||||
final String HIREDATE_NULL_BLANK = "入社年月日";
|
||||
final String MANAGEMENT_ERROR = "管理者権限指定";
|
||||
final String DEPARTMENT_ID_NULL_BLANK = "所属部署";
|
||||
final String EMPLOYEE_NAME_NULL_BLANK = "社員名";
|
||||
final String EMPLOYEE_KANA_NULL_BLANK = "社員名フリガナ";
|
||||
final String MAIL_ADDRESS_NULL_BLANK = "メールアドレス";
|
||||
final String PASSWORD_NULL_BLANK = "パスワード";
|
||||
final String MANAGEMENT_ERROR = "管理者権限指定";
|
||||
final String DEPARTMENT_ID_NULL_BLANK = "所属部署";
|
||||
|
||||
List<String> error = new ArrayList<>();
|
||||
List<String> error = new ArrayList<>();
|
||||
|
||||
// null or 空文字判定
|
||||
if (isNullOrBlank(employeeName)) {
|
||||
// エラー内容を追加
|
||||
error.add(EMPLOYEE_NAME_NULL_BLANK);
|
||||
}
|
||||
// null or 空文字判定
|
||||
if (isNullOrBlank(employeeName)) {
|
||||
// エラー内容を追加
|
||||
error.add(EMPLOYEE_NAME_NULL_BLANK);
|
||||
}
|
||||
|
||||
// null or 空文字判定
|
||||
if (isNullOrBlank(employeeKana)) {
|
||||
// エラー内容を追加
|
||||
error.add(EMPLOYEE_KANA_NULL_BLANK);
|
||||
}
|
||||
// null or 空文字判定
|
||||
if (isNullOrBlank(employeeKana)) {
|
||||
// エラー内容を追加
|
||||
error.add(EMPLOYEE_KANA_NULL_BLANK);
|
||||
}
|
||||
|
||||
// null or 空文字判定
|
||||
if (isNullOrBlank(mailAddress)) {
|
||||
// エラー内容を追加
|
||||
error.add(MAIL_ADDRESS_NULL_BLANK);
|
||||
}
|
||||
// null or 空文字判定
|
||||
if (isNullOrBlank(mailAddress)) {
|
||||
// エラー内容を追加
|
||||
error.add(MAIL_ADDRESS_NULL_BLANK);
|
||||
}
|
||||
|
||||
// null or 空文字判定
|
||||
if (isNullOrBlank(password)) {
|
||||
// エラー内容を追加
|
||||
error.add(PASSWORD_NULL_BLANK);
|
||||
}
|
||||
// null or 空文字判定
|
||||
if (isNullOrBlank(hireDate)) {
|
||||
// エラー内容を追加
|
||||
error.add(HIREDATE_NULL_BLANK);
|
||||
}
|
||||
// null or 空文字判定
|
||||
if (isNullOrBlank(password)) {
|
||||
// エラー内容を追加
|
||||
error.add(PASSWORD_NULL_BLANK);
|
||||
}
|
||||
|
||||
// 管理者権限の値が不正か
|
||||
if (management == null) {
|
||||
// エラー内容を追加
|
||||
error.add(MANAGEMENT_ERROR);
|
||||
}
|
||||
// 管理者権限の値が不正か
|
||||
if (management == null) {
|
||||
// エラー内容を追加
|
||||
error.add(MANAGEMENT_ERROR);
|
||||
}
|
||||
|
||||
// 所属部署の値が不正か
|
||||
if (departmentId == null) {
|
||||
// エラー内容を追加
|
||||
error.add(DEPARTMENT_ID_NULL_BLANK);
|
||||
}
|
||||
// 所属部署の値が不正か
|
||||
if (departmentId == null) {
|
||||
// エラー内容を追加
|
||||
error.add(DEPARTMENT_ID_NULL_BLANK);
|
||||
}
|
||||
|
||||
return error;
|
||||
return error;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 仮引数を null or 空 判定する
|
||||
*
|
||||
* @param str 判定対象の文字列
|
||||
* @return true:null or 空 false:null or 空 では無い
|
||||
*/
|
||||
private static boolean isNullOrBlank(String str) {
|
||||
if (null == str) {
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* 仮引数を null or 空 判定する
|
||||
*
|
||||
* @param str 判定対象の文字列
|
||||
* @return true:null or 空 false:null or 空 では無い
|
||||
*/
|
||||
private static boolean isNullOrBlank(String str) {
|
||||
if (null == str) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return str.isBlank();
|
||||
}
|
||||
return str.isBlank();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,33 +1,25 @@
|
||||
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.GetMapping;
|
||||
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 org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.example.rhizome.aop.aspect.PermissionCheck;
|
||||
import com.example.rhizome.aop.aspect.SessionCheck;
|
||||
import com.example.rhizome.app.domain.service.RegisterEmployee;
|
||||
import com.example.rhizome.app.domain.service.SearchDepartment;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
||||
import com.example.rhizome.app.presentation.form.DepartmentInfoForm;
|
||||
import com.example.rhizome.app.presentation.form.DivisionInfoForm;
|
||||
import com.example.rhizome.app.presentation.form.HeadquartersInfoForm;
|
||||
import com.example.rhizome.app.presentation.form.DepartmentForm;
|
||||
import com.example.rhizome.app.presentation.form.InsertEmployeeForm;
|
||||
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 javax.servlet.http.HttpSession;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT;
|
||||
|
||||
/**
|
||||
* 登録画面表示用コントローラ
|
||||
@@ -35,109 +27,64 @@ import com.example.rhizome.app.presentation.form.InsertEmployeeForm;
|
||||
@Controller
|
||||
public class InsertEmployeeInputController {
|
||||
|
||||
// ログ出力用インスタンス
|
||||
private final static Logger LOGGER = Logger.getLogger(InsertEmployeeInputController.class.getName());
|
||||
// ログ出力用インスタンス
|
||||
private final static Logger LOGGER = Logger.getLogger(InsertEmployeeInputController.class.getName());
|
||||
|
||||
// エラーメッセージ用の定数フィールド
|
||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||
// エラーメッセージ用の定数フィールド
|
||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||
|
||||
HttpSession httpSession;
|
||||
RegisterEmployee registerEmployee;
|
||||
SearchDepartment searchDepartment;
|
||||
HttpSession httpSession;
|
||||
RegisterEmployee registerEmployee;
|
||||
SearchDepartment searchDepartment;
|
||||
|
||||
@Autowired
|
||||
public InsertEmployeeInputController(HttpSession httpSession, RegisterEmployee registerEmployee,
|
||||
SearchDepartment searchDepartment) {
|
||||
this.httpSession = httpSession;
|
||||
this.registerEmployee = registerEmployee;
|
||||
this.searchDepartment = searchDepartment;
|
||||
}
|
||||
@Autowired
|
||||
public InsertEmployeeInputController(HttpSession httpSession, RegisterEmployee registerEmployee, SearchDepartment searchDepartment) {
|
||||
this.httpSession = httpSession;
|
||||
this.registerEmployee = registerEmployee;
|
||||
this.searchDepartment = searchDepartment;
|
||||
}
|
||||
|
||||
@ModelAttribute
|
||||
public InsertEmployeeForm insertEmployeeForm() {
|
||||
return new InsertEmployeeForm();
|
||||
}
|
||||
@ModelAttribute
|
||||
public InsertEmployeeForm insertEmployeeForm() {
|
||||
return new InsertEmployeeForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* 社員情報登録画面の表示を行う
|
||||
*
|
||||
* @param InsertEmployeeFormを保持したインスタンス
|
||||
* @param model ビューにデータを渡すためのコンテナ
|
||||
* @return 遷移先の画面
|
||||
*/
|
||||
@SessionCheck
|
||||
@PermissionCheck
|
||||
@RequestMapping(value = INSERT_EMPLOYEE_INPUT, method = RequestMethod.POST)
|
||||
public String insertInput(InsertEmployeeForm insertEmployeeForm, Model model) {
|
||||
|
||||
try {
|
||||
/**
|
||||
* 登録画面表示処理
|
||||
*
|
||||
* @param insertEmployeeForm 登録画面のフォーム
|
||||
* @param model ビューにデータを渡すためのコンテナ
|
||||
* @return 遷移先の画面
|
||||
*/
|
||||
@SessionCheck
|
||||
@PermissionCheck
|
||||
@RequestMapping(value = INSERT_EMPLOYEE_INPUT, method = RequestMethod.POST)
|
||||
public String insertInput(InsertEmployeeForm insertEmployeeForm, Model model) {
|
||||
|
||||
// 部署コードリストを作成し、画面に返す値としてセット
|
||||
model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, HeadquartersInfoForm.convertFrom(
|
||||
searchDepartment.searchAllDepartmentTable()));
|
||||
try {
|
||||
// 部署コードリストを作成し、画面に返す値としてセット
|
||||
model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, DepartmentForm.convertFrom(searchDepartment.selectAll()));
|
||||
|
||||
// パラメータをセット
|
||||
model.addAttribute(PageReturnAttributeKeyword.INSERT_EMPLOYEE_FORM, insertEmployeeForm);
|
||||
// パラメータをセット
|
||||
model.addAttribute(PageReturnAttributeKeyword.INSERT_EMPLOYEE_FORM, insertEmployeeForm);
|
||||
|
||||
// 登録画面に遷移
|
||||
return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML;
|
||||
// 登録画面に遷移
|
||||
return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML;
|
||||
|
||||
} catch (Exception e) {
|
||||
// ログイン情報の破棄
|
||||
httpSession.invalidate();
|
||||
} catch (Exception e) {
|
||||
// ログイン情報の破棄
|
||||
httpSession.invalidate();
|
||||
|
||||
e.printStackTrace();
|
||||
e.printStackTrace();
|
||||
|
||||
// エラーログ出力
|
||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||
// エラー画面遷移
|
||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 社員情報登録画面の部情報のプルダウンの表示を行う
|
||||
*
|
||||
* @param idHeadquarters
|
||||
* @return 遷移先の画面
|
||||
*/
|
||||
//画面で本部のプルダウンが選択された時にJSでこのメソッドに飛ぶ
|
||||
@GetMapping("insertEmployeeInput/searchDepartment")
|
||||
@ResponseBody
|
||||
public List<DepartmentInfoForm> departmentsByHeadquarters(
|
||||
@RequestParam("id_headquarters") Integer idHeadquarters) {
|
||||
List<DepartmentInfoForm> departmentByHeadquarters = DepartmentInfoForm.convertFrom(
|
||||
searchDepartment.searchByIdHeadquarters(idHeadquarters));
|
||||
return departmentByHeadquarters
|
||||
.stream()
|
||||
.map(DepartmentInfoForm -> new DepartmentInfoForm(
|
||||
DepartmentInfoForm.getIdDepartment(),
|
||||
DepartmentInfoForm.getNmDepartment()))
|
||||
.distinct()
|
||||
.toList();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 社員情報登録画面の課情報のプルダウンの表示を行う
|
||||
*
|
||||
* @param idDepartment
|
||||
* @return 遷移先の画面
|
||||
*/
|
||||
//画面で部のプルダウンが選択された時にJSでこのメソッドに飛ぶ
|
||||
@GetMapping("/insertEmployeeInput/searchDepartment/searchDivision")
|
||||
@ResponseBody
|
||||
public List<DivisionInfoForm> divisionBydepartment(
|
||||
@RequestParam("id_department") Integer idDepartment) {
|
||||
List<DivisionInfoForm> divisionByDepartment = DivisionInfoForm.convertFrom(
|
||||
searchDepartment.searchByIdDepartment(idDepartment));
|
||||
return divisionByDepartment
|
||||
.stream()
|
||||
.map(DivisionInfoForm -> new DivisionInfoForm(
|
||||
DivisionInfoForm.getIdDivision(),
|
||||
DivisionInfoForm.getNmDivision()))
|
||||
.distinct()
|
||||
.toList();
|
||||
|
||||
}
|
||||
// エラーログ出力
|
||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||
// エラー画面遷移
|
||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,18 +1,5 @@
|
||||
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.app.domain.model.LoginInfo;
|
||||
import com.example.rhizome.app.domain.model.LoginUser;
|
||||
@@ -24,6 +11,18 @@ import com.example.rhizome.app.presentation.form.LoginInfoForm;
|
||||
import com.example.rhizome.app.presentation.form.LoginUserForm;
|
||||
import com.example.rhizome.app.presentation.form.MessageForm;
|
||||
import com.example.rhizome.app.presentation.form.UpdatePersonalUserForm;
|
||||
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 javax.servlet.http.HttpSession;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.DO_LOGIN;
|
||||
|
||||
/**
|
||||
* ログイン関連のコントローラ
|
||||
@@ -31,120 +30,119 @@ import com.example.rhizome.app.presentation.form.UpdatePersonalUserForm;
|
||||
@Controller
|
||||
public class LoginController {
|
||||
|
||||
// ログ出力用インスタンス
|
||||
private final static Logger LOGGER = Logger.getLogger(LoginController.class.getName());
|
||||
// ログ出力用インスタンス
|
||||
private final static Logger LOGGER = Logger.getLogger(LoginController.class.getName());
|
||||
|
||||
// エラーメッセージ用の定数フィールド
|
||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||
// エラーメッセージ用の定数フィールド
|
||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||
|
||||
HttpSession httpSession;
|
||||
Login login;
|
||||
HttpSession httpSession;
|
||||
Login login;
|
||||
|
||||
@Autowired
|
||||
public LoginController(HttpSession httpSession, Login login) {
|
||||
this.httpSession = httpSession;
|
||||
this.login = login;
|
||||
}
|
||||
@Autowired
|
||||
public LoginController(HttpSession httpSession, Login login) {
|
||||
this.httpSession = httpSession;
|
||||
this.login = login;
|
||||
}
|
||||
|
||||
@ModelAttribute
|
||||
public LoginUserForm loginUserForm() {
|
||||
return new LoginUserForm();
|
||||
}
|
||||
@ModelAttribute
|
||||
public LoginUserForm loginUserForm() {
|
||||
return new LoginUserForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* 画面から渡ってきたパラメータのチェックを行う
|
||||
*
|
||||
* @param loginInfoForm mailAddress, password を保持したインスタンス
|
||||
* @param model ビューにデータを渡すためのコンテナ
|
||||
* @return 遷移先の画面
|
||||
*/
|
||||
@RequestMapping(value = DO_LOGIN, method = RequestMethod.POST)
|
||||
public String doLogin(LoginInfoForm loginInfoForm, Model model) {
|
||||
/**
|
||||
* 画面から渡ってきたパラメータのチェックを行う
|
||||
*
|
||||
* @param loginInfoForm mailAddress, password を保持したインスタンス
|
||||
* @param model ビューにデータを渡すためのコンテナ
|
||||
* @return 遷移先の画面
|
||||
*/
|
||||
@RequestMapping(value = DO_LOGIN, method = RequestMethod.POST)
|
||||
public String doLogin(LoginInfoForm loginInfoForm, Model model) {
|
||||
|
||||
// ログに出力する
|
||||
final String MAIL_ADDRESS_PASSWORD_ERROR = "メールアドレス、パスワードの入力内容に誤りがあります";
|
||||
// 発生しうるErrorに対するメッセージ
|
||||
final String LOGIN_ERROR = "IDまたはパスワードが間違っています";
|
||||
// ログに出力する
|
||||
final String MAIL_ADDRESS_PASSWORD_ERROR = "メールアドレス、パスワードの入力内容に誤りがあります";
|
||||
// 発生しうるErrorに対するメッセージ
|
||||
final String LOGIN_ERROR = "IDまたはパスワードが間違っています";
|
||||
|
||||
try {
|
||||
// mailAddress, password の入力に誤りがあるかチェック
|
||||
if (!LoginUserForm.checkParameter(loginInfoForm)) {
|
||||
try {
|
||||
// mailAddress, password の入力に誤りがあるかチェック
|
||||
if (!LoginUserForm.checkParameter(loginInfoForm)) {
|
||||
|
||||
// mail,passwordが仕様を満たしていない場合
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR,
|
||||
new MessageForm(MAIL_ADDRESS_PASSWORD_ERROR));
|
||||
// mail,passwordが仕様を満たしていない場合
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(MAIL_ADDRESS_PASSWORD_ERROR));
|
||||
|
||||
// エラーだった場合に login.html に処理を戻す。mailAddress, password を login.htmlに表示するために
|
||||
// ここで addAttribute する
|
||||
model.addAttribute(PageReturnAttributeKeyword.LOGIN_INFO_FORM, loginInfoForm);
|
||||
// login.html に遷移する様に設定
|
||||
return TransitionTargetPageNameKeyword.LOGIN_HTML;
|
||||
}
|
||||
// エラーだった場合に login.html に処理を戻す。mailAddress, password を login.htmlに表示するために
|
||||
// ここで addAttribute する
|
||||
model.addAttribute(PageReturnAttributeKeyword.LOGIN_INFO_FORM, loginInfoForm);
|
||||
// login.html に遷移する様に設定
|
||||
return TransitionTargetPageNameKeyword.LOGIN_HTML;
|
||||
}
|
||||
|
||||
// Login者情報インスタンスを作成
|
||||
LoginInfo loginInfo = createLoginInfo(httpSession, loginInfoForm);
|
||||
// Login者情報インスタンスを作成
|
||||
LoginInfo loginInfo = createLoginInfo(httpSession, loginInfoForm);
|
||||
|
||||
// login 可能かチェック
|
||||
if (!login.canLogin(loginInfo)) {
|
||||
// ログイン不可の場合、エラーメッセージをセットして入力された値とともに login.html を再表示
|
||||
// 画面に表示するエラーメッセージをセット
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(LOGIN_ERROR));
|
||||
// 画面に表示する mailAddress, password をセット
|
||||
model.addAttribute(PageReturnAttributeKeyword.LOGIN_INFO_FORM, loginInfoForm);
|
||||
// login.html に遷移
|
||||
return TransitionTargetPageNameKeyword.LOGIN_HTML;
|
||||
}
|
||||
// login 可能かチェック
|
||||
if (!login.canLogin(loginInfo)) {
|
||||
// ログイン不可の場合、エラーメッセージをセットして入力された値とともに login.html を再表示
|
||||
// 画面に表示するエラーメッセージをセット
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(LOGIN_ERROR));
|
||||
// 画面に表示する mailAddress, password をセット
|
||||
model.addAttribute(PageReturnAttributeKeyword.LOGIN_INFO_FORM, loginInfoForm);
|
||||
// login.html に遷移
|
||||
return TransitionTargetPageNameKeyword.LOGIN_HTML;
|
||||
}
|
||||
|
||||
// ログイン(インスタンス作成)
|
||||
LoginUser loginUser = login.doLogin(loginInfo);
|
||||
// ログイン(インスタンス作成)
|
||||
LoginUser loginUser = login.doLogin(loginInfo);
|
||||
|
||||
// ログイン者の情報をセッション情報に格納
|
||||
// セッションに loginUser 情報を保持し続ける = ログイン中として扱う
|
||||
httpSession.setAttribute(SessionKeyword.LOGIN_USER, LoginUserForm.convertFrom(loginUser));
|
||||
// ログイン者の情報をセッション情報に格納
|
||||
// セッションに loginUser 情報を保持し続ける = ログイン中として扱う
|
||||
httpSession.setAttribute(SessionKeyword.LOGIN_USER, LoginUserForm.convertFrom(loginUser));
|
||||
|
||||
// 管理者かチェック
|
||||
if (!loginUser.isAdminUser()) {
|
||||
// 管理者ではない場合直で自分の情報を更新するページに遷移する
|
||||
// 編集対象のログイン者の情報を画面に渡す値にセット
|
||||
model.addAttribute(PageReturnAttributeKeyword.UPDATE_PERSONAL_EMPLOYEE_USER_FORM,
|
||||
UpdatePersonalUserForm.convertFrom(loginUser));
|
||||
// 個人の情報更新ページに遷移
|
||||
return TransitionTargetPageNameKeyword.UPDATE_PERSONAL_EMPLOYEE_INPUT_HTML;
|
||||
}
|
||||
// 管理者かチェック
|
||||
if (!loginUser.isAdminUser()) {
|
||||
// 管理者ではない場合直で自分の情報を更新するページに遷移する
|
||||
// 編集対象のログイン者の情報を画面に渡す値にセット
|
||||
model.addAttribute(PageReturnAttributeKeyword.UPDATE_PERSONAL_EMPLOYEE_USER_FORM, UpdatePersonalUserForm.convertFrom(loginUser));
|
||||
// 個人の情報更新ページに遷移
|
||||
return TransitionTargetPageNameKeyword.UPDATE_PERSONAL_EMPLOYEE_INPUT_HTML;
|
||||
}
|
||||
|
||||
// メニュー画面に遷移
|
||||
return TransitionTargetPageNameKeyword.MENU_HTML;
|
||||
// メニュー画面に遷移
|
||||
return TransitionTargetPageNameKeyword.MENU_HTML;
|
||||
|
||||
} catch (Exception e) {
|
||||
// ログイン情報の破棄
|
||||
httpSession.invalidate();
|
||||
e.printStackTrace();
|
||||
// エラーログ出力
|
||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||
// エラー画面に遷移
|
||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// ログイン情報の破棄
|
||||
httpSession.invalidate();
|
||||
e.printStackTrace();
|
||||
// エラーログ出力
|
||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||
// エラー画面に遷移
|
||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ログイン者情報のインスタンスを作成
|
||||
*
|
||||
* @param httpSession セッション情報
|
||||
* @param loginInfoForm mailAddress, password を保持したインスタンス
|
||||
*/
|
||||
private static LoginInfo createLoginInfo(HttpSession httpSession, LoginInfoForm loginInfoForm) {
|
||||
// セッションからログイン者情報を取得
|
||||
LoginUserForm loginUserForm = (LoginUserForm) httpSession.getAttribute(SessionKeyword.LOGIN_USER);
|
||||
/**
|
||||
* ログイン者情報のインスタンスを作成
|
||||
*
|
||||
* @param httpSession セッション情報
|
||||
* @param loginInfoForm mailAddress, password を保持したインスタンス
|
||||
*/
|
||||
private static LoginInfo createLoginInfo(HttpSession httpSession, LoginInfoForm loginInfoForm) {
|
||||
// セッションからログイン者情報を取得
|
||||
LoginUserForm loginUserForm = (LoginUserForm) httpSession.getAttribute(SessionKeyword.LOGIN_USER);
|
||||
|
||||
// セッションにログイン者情報があるか
|
||||
if (loginUserForm != null) {
|
||||
// セッションにログイン者情報がある場合
|
||||
return new LoginInfo(loginUserForm.getMailAddress(), loginUserForm.getPassword());
|
||||
}
|
||||
// セッションにログイン者情報があるか
|
||||
if (loginUserForm != null) {
|
||||
// セッションにログイン者情報がある場合
|
||||
return new LoginInfo(loginUserForm.getMailAddress(), loginUserForm.getPassword());
|
||||
}
|
||||
|
||||
// セッションにない場合は画面からの input 値 を取得
|
||||
return new LoginInfo(
|
||||
loginInfoForm.getMailAddress(),
|
||||
loginInfoForm.getPassword());
|
||||
}
|
||||
// セッションにない場合は画面からの input 値 を取得
|
||||
return new LoginInfo(
|
||||
loginInfoForm.getMailAddress(),
|
||||
loginInfoForm.getPassword()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
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 com.example.rhizome.aop.aspect.PermissionCheck;
|
||||
import com.example.rhizome.aop.aspect.SessionCheck;
|
||||
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 org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
@@ -14,11 +12,11 @@ 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.presentation.controller.pageproperty.PageReturnAttributeKeyword;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
||||
import com.example.rhizome.app.presentation.form.LoginUserForm;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.LOGOUT;
|
||||
|
||||
/**
|
||||
* ログアウト処理のコントローラ
|
||||
@@ -26,50 +24,50 @@ import com.example.rhizome.app.presentation.form.LoginUserForm;
|
||||
@Controller
|
||||
public class LogoutController {
|
||||
|
||||
// ログ出力用インスタンス
|
||||
private final static Logger LOGGER = Logger.getLogger(LogoutController.class.getName());
|
||||
// エラーメッセージ用の定数フィールド
|
||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||
// ログ出力用インスタンス
|
||||
private final static Logger LOGGER = Logger.getLogger(LogoutController.class.getName());
|
||||
// エラーメッセージ用の定数フィールド
|
||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||
|
||||
HttpSession httpSession;
|
||||
HttpSession httpSession;
|
||||
|
||||
@Autowired
|
||||
public LogoutController(HttpSession httpSession) {
|
||||
this.httpSession = httpSession;
|
||||
}
|
||||
@Autowired
|
||||
public LogoutController(HttpSession httpSession) {
|
||||
this.httpSession = httpSession;
|
||||
}
|
||||
|
||||
@ModelAttribute
|
||||
public LoginUserForm loginUserForm() {
|
||||
return new LoginUserForm();
|
||||
}
|
||||
@ModelAttribute
|
||||
public LoginUserForm loginUserForm() {
|
||||
return new LoginUserForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* ログアウト処理
|
||||
*
|
||||
* @param model ビューにデータを渡すためのコンテナ
|
||||
* @return 遷移先の画面
|
||||
*/
|
||||
@PermissionCheck
|
||||
@SessionCheck
|
||||
@RequestMapping(value = LOGOUT, method = RequestMethod.POST)
|
||||
public String doLogout(Model model) {
|
||||
try {
|
||||
// セッション情報の破棄
|
||||
httpSession.invalidate();
|
||||
/**
|
||||
* ログアウト処理
|
||||
*
|
||||
* @param model ビューにデータを渡すためのコンテナ
|
||||
* @return 遷移先の画面
|
||||
*/
|
||||
@PermissionCheck
|
||||
@SessionCheck
|
||||
@RequestMapping(value = LOGOUT, method = RequestMethod.POST)
|
||||
public String doLogout(Model model) {
|
||||
try {
|
||||
// セッション情報の破棄
|
||||
httpSession.invalidate();
|
||||
|
||||
// ログイン画面に遷移するための情報を設定
|
||||
model.addAttribute(PageReturnAttributeKeyword.LOGIN_INFO_FORM, loginUserForm());
|
||||
// login.html に遷移
|
||||
return TransitionTargetPageNameKeyword.LOGIN_HTML;
|
||||
// ログイン画面に遷移するための情報を設定
|
||||
model.addAttribute(PageReturnAttributeKeyword.LOGIN_INFO_FORM, loginUserForm());
|
||||
// login.html に遷移
|
||||
return TransitionTargetPageNameKeyword.LOGIN_HTML;
|
||||
|
||||
} catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
|
||||
// エラーログ出力
|
||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||
// エラーページに遷移
|
||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||
}
|
||||
// エラーログ出力
|
||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||
// エラーページに遷移
|
||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package com.example.rhizome.app.presentation.controller;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import com.example.rhizome.aop.aspect.PermissionCheck;
|
||||
import com.example.rhizome.aop.aspect.SessionCheck;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
||||
import com.example.rhizome.app.presentation.form.MessageForm;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
/**
|
||||
* メニュー画面表示用コントローラ
|
||||
@@ -15,20 +14,20 @@ import com.example.rhizome.app.presentation.form.MessageForm;
|
||||
@Controller
|
||||
public class MenuController {
|
||||
|
||||
@ModelAttribute
|
||||
public MessageForm messageForm() {
|
||||
return new MessageForm();
|
||||
}
|
||||
@ModelAttribute
|
||||
public MessageForm messageForm() {
|
||||
return new MessageForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* メニュー画面に遷移
|
||||
*/
|
||||
@PermissionCheck
|
||||
@SessionCheck
|
||||
@RequestMapping(value = TransitionTargetPageNameKeyword.SHOW_MENU)
|
||||
public String showMenu() {
|
||||
// メニュー画面遷移
|
||||
return TransitionTargetPageNameKeyword.MENU_HTML;
|
||||
}
|
||||
/**
|
||||
* メニュー画面に遷移
|
||||
*/
|
||||
@PermissionCheck
|
||||
@SessionCheck
|
||||
@RequestMapping(value = TransitionTargetPageNameKeyword.SHOW_MENU)
|
||||
public String showMenu() {
|
||||
// メニュー画面遷移
|
||||
return TransitionTargetPageNameKeyword.MENU_HTML;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,17 +1,5 @@
|
||||
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;
|
||||
@@ -19,6 +7,16 @@ import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAt
|
||||
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;
|
||||
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 javax.servlet.http.HttpSession;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* 部署検索画面用コントローラ リスト全件表示、検索表示、更新、削除が可能
|
||||
@@ -26,98 +24,96 @@ 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 = "エラーが発生しました!";
|
||||
// ログ出力用インスタンス
|
||||
private final static Logger LOGGER = Logger.getLogger(SelectDepartmentController.class.getName());
|
||||
// エラーメッセージ用の定数フィールド
|
||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||
|
||||
HttpSession httpSession;
|
||||
SearchDepartment searchDepartment;
|
||||
HttpSession httpSession;
|
||||
SearchDepartment searchDepartment;
|
||||
|
||||
@Autowired
|
||||
public SelectDepartmentController(HttpSession httpSession, SearchDepartment searchDepartment) {
|
||||
this.httpSession = httpSession;
|
||||
this.searchDepartment = searchDepartment;
|
||||
}
|
||||
@Autowired
|
||||
public SelectDepartmentController(HttpSession httpSession, SearchDepartment searchDepartment) {
|
||||
this.httpSession = httpSession;
|
||||
this.searchDepartment = searchDepartment;
|
||||
}
|
||||
|
||||
@ModelAttribute
|
||||
public SearchConditionDepartmentForm searchConditionDepartmentForm() {
|
||||
return new SearchConditionDepartmentForm();
|
||||
}
|
||||
@ModelAttribute
|
||||
public SearchConditionDepartmentForm searchConditionDepartmentForm() {
|
||||
return new SearchConditionDepartmentForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* 部署検索画面表示処理コントローラ
|
||||
*
|
||||
* @param model ビューにデータを渡すためのコンテナ
|
||||
* @return 遷移先の画面
|
||||
*/
|
||||
@PermissionCheck
|
||||
@SessionCheck
|
||||
@RequestMapping(value = TransitionTargetPageNameKeyword.SELECT_DEPARTMENT, method = RequestMethod.POST)
|
||||
public String select(SearchConditionDepartmentForm searchConditionDepartmentForm, Model model) {
|
||||
/**
|
||||
* 部署検索画面表示処理コントローラ
|
||||
*
|
||||
* @param model ビューにデータを渡すためのコンテナ
|
||||
* @return 遷移先の画面
|
||||
*/
|
||||
@PermissionCheck
|
||||
@SessionCheck
|
||||
@RequestMapping(value = TransitionTargetPageNameKeyword.SELECT_DEPARTMENT, method = RequestMethod.POST)
|
||||
public String select(SearchConditionDepartmentForm searchConditionDepartmentForm, Model model) {
|
||||
|
||||
try {
|
||||
try {
|
||||
|
||||
// 部署一覧を取得し、画面に返す用のクラスに詰め替える
|
||||
// 作成した部署一覧をセット
|
||||
model.addAttribute(
|
||||
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||
DepartmentForm.convertFrom(
|
||||
searchDepartment.searchAllDepartmentTable(
|
||||
SearchConditionDepartmentForm.convertTo(searchConditionDepartmentForm))
|
||||
// 部署一覧を取得し、画面に返す用のクラスに詰め替える
|
||||
// 作成した部署一覧をセット
|
||||
model.addAttribute(
|
||||
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||
DepartmentForm.convertFrom(searchDepartment.searchByWithLike(SearchConditionDepartmentForm.convertTo(searchConditionDepartmentForm)))
|
||||
);
|
||||
|
||||
));
|
||||
// 検索ページに遷移
|
||||
return TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_HTML;
|
||||
|
||||
// 検索ページに遷移
|
||||
return TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_HTML;
|
||||
} catch (Exception e) {
|
||||
// ログイン情報の破棄
|
||||
httpSession.invalidate();
|
||||
|
||||
} catch (Exception e) {
|
||||
// ログイン情報の破棄
|
||||
httpSession.invalidate();
|
||||
e.printStackTrace();
|
||||
|
||||
e.printStackTrace();
|
||||
// エラーログ出力
|
||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||
// エラー画面遷移
|
||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||
}
|
||||
|
||||
// エラーログ出力
|
||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||
// エラー画面遷移
|
||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* 部署検索画面表示処理コントローラ
|
||||
*
|
||||
* @param model ビューにデータを渡すためのコンテナ
|
||||
* @return 遷移先の画面
|
||||
*/
|
||||
@PermissionCheck
|
||||
@SessionCheck
|
||||
@RequestMapping(value = TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_ALL, method = RequestMethod.POST)
|
||||
public String selectAll(Model model) {
|
||||
|
||||
/**
|
||||
* 部署検索画面表示処理コントローラ
|
||||
*
|
||||
* @param model ビューにデータを渡すためのコンテナ
|
||||
* @return 遷移先の画面
|
||||
*/
|
||||
@PermissionCheck
|
||||
@SessionCheck
|
||||
@RequestMapping(value = TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_ALL, method = RequestMethod.POST)
|
||||
public String selectAll(Model model) {
|
||||
try {
|
||||
|
||||
try {
|
||||
// 部署一覧を取得し、画面に返す用のクラスに詰め替える
|
||||
// 作成した部署一覧をセット
|
||||
model.addAttribute(
|
||||
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||
DepartmentForm.convertFrom(
|
||||
searchDepartment.searchAllDepartmentTable()));
|
||||
// 部署一覧を取得し、画面に返す用のクラスに詰め替える
|
||||
// 作成した部署一覧をセット
|
||||
model.addAttribute(
|
||||
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||
DepartmentForm.convertFrom(searchDepartment.selectAll())
|
||||
);
|
||||
|
||||
// 検索ページに遷移
|
||||
return TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_HTML;
|
||||
// 検索ページに遷移
|
||||
return TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_HTML;
|
||||
|
||||
} catch (Exception e) {
|
||||
// ログイン情報の破棄
|
||||
httpSession.invalidate();
|
||||
} catch (Exception e) {
|
||||
// ログイン情報の破棄
|
||||
httpSession.invalidate();
|
||||
|
||||
e.printStackTrace();
|
||||
e.printStackTrace();
|
||||
|
||||
// エラーログ出力
|
||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||
// エラー画面遷移
|
||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||
}
|
||||
// エラーログ出力
|
||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||
// エラー画面遷移
|
||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
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 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.EmployeeInfoForm;
|
||||
import com.example.rhizome.app.presentation.form.SearchConditionEmployeeForm;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
@@ -13,16 +16,9 @@ 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.domain.service.TenureCalc;
|
||||
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.EmployeeInfoForm;
|
||||
import com.example.rhizome.app.presentation.form.SearchConditionEmployeeForm;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* 社員検索画面用コントローラ リスト全件表示、検索表示、更新、削除が可能
|
||||
@@ -38,13 +34,12 @@ public class SelectEmployeeController {
|
||||
HttpSession httpSession;
|
||||
SearchDepartment searchDepartment;
|
||||
SearchEmployeeInfo searchEmployeeInfo;
|
||||
TenureCalc tenureCalc;
|
||||
|
||||
@Autowired
|
||||
public SelectEmployeeController(HttpSession httpSession, SearchDepartment searchDepartment, SearchEmployeeInfo searchEmployeeInfo ,TenureCalc tenureCalc) {
|
||||
public SelectEmployeeController(HttpSession httpSession, SearchDepartment searchDepartment, SearchEmployeeInfo searchEmployeeInfo) {
|
||||
this.httpSession = httpSession;
|
||||
this.searchDepartment = searchDepartment;
|
||||
this.searchEmployeeInfo = searchEmployeeInfo;
|
||||
this.tenureCalc = tenureCalc;
|
||||
}
|
||||
|
||||
@ModelAttribute
|
||||
@@ -65,28 +60,18 @@ public class SelectEmployeeController {
|
||||
public String select(SearchConditionEmployeeForm searchConditionEmployeeForm, Model model) {
|
||||
|
||||
try {
|
||||
|
||||
|
||||
// 部署一覧を取得し、画面に返す用のクラスに詰め替える
|
||||
// 作成した部署一覧をセット
|
||||
model.addAttribute(
|
||||
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||
DepartmentForm.convertFrom(
|
||||
searchDepartment.searchAllDepartmentTable())
|
||||
DepartmentForm.convertFrom(searchDepartment.selectAll())
|
||||
);
|
||||
|
||||
// 検索条件を元に検索を実施
|
||||
// 取得した EmployeeInfo( employee + department )の情報を画面に返す用の型に詰め替えてセット
|
||||
//プラスで勤続年数を計算してformにセット
|
||||
|
||||
List<EmployeeInfoForm>employeeInfoForm = EmployeeInfoForm.convertFrom(
|
||||
searchEmployeeInfo.searchBy(
|
||||
SearchConditionEmployeeForm.convertTo(searchConditionEmployeeForm)));
|
||||
for(EmployeeInfoForm form:employeeInfoForm) {
|
||||
String tenure = tenureCalc.tenureCalc(form.getHireDate());
|
||||
form.setTenure(tenure);
|
||||
}
|
||||
model.addAttribute(PageReturnAttributeKeyword.EMPLOYEE_INFO_FORM_LIST, employeeInfoForm);
|
||||
model.addAttribute(PageReturnAttributeKeyword.EMPLOYEE_INFO_FORM_LIST, EmployeeInfoForm.convertFrom(searchEmployeeInfo.searchBy(SearchConditionEmployeeForm.convertTo(searchConditionEmployeeForm))));
|
||||
// 検索ページに遷移
|
||||
|
||||
return TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_HTML;
|
||||
|
||||
|
||||
@@ -120,19 +105,15 @@ public class SelectEmployeeController {
|
||||
// 作成した部署一覧をセット
|
||||
model.addAttribute(
|
||||
PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST,
|
||||
DepartmentForm.convertFrom(
|
||||
searchDepartment.searchAllDepartmentTable())
|
||||
DepartmentForm.convertFrom(searchDepartment.selectAll())
|
||||
);
|
||||
|
||||
// 検索条件を元に検索を実施
|
||||
List<EmployeeInfoForm>employeeInfoForm =EmployeeInfoForm.convertFrom(
|
||||
searchEmployeeInfo.selectAll());
|
||||
for(EmployeeInfoForm form:employeeInfoForm) {
|
||||
String tenure = tenureCalc.tenureCalc(form.getHireDate());
|
||||
form.setTenure(tenure);
|
||||
}
|
||||
|
||||
model.addAttribute(PageReturnAttributeKeyword.EMPLOYEE_INFO_FORM_LIST,employeeInfoForm);
|
||||
model.addAttribute(PageReturnAttributeKeyword.EMPLOYEE_INFO_FORM_LIST,
|
||||
EmployeeInfoForm.convertFrom(
|
||||
searchEmployeeInfo.searchBy(
|
||||
SearchConditionEmployeeForm.convertTo(searchConditionEmployeeForm())
|
||||
)));
|
||||
|
||||
// 検索ページに遷移
|
||||
return TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_HTML;
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
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 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.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.SearchConditionEmployeeForm;
|
||||
import com.example.rhizome.app.presentation.form.UpdateDepartmentForm;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
@@ -14,16 +18,10 @@ 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.AllDepartmentInfo;
|
||||
import com.example.rhizome.app.domain.model.SearchConditionDepartment;
|
||||
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.SearchConditionEmployeeForm;
|
||||
import com.example.rhizome.app.presentation.form.UpdateDepartmentForm;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* 更新対象の Department が存在するか確認する為のコントローラ
|
||||
@@ -61,24 +59,24 @@ public class UpdateDepartmentController {
|
||||
@PermissionCheck
|
||||
@SessionCheck
|
||||
@RequestMapping(value = TransitionTargetPageNameKeyword.SHOW_UPDATE_DEPARTMENT, method = RequestMethod.POST)
|
||||
public String showUpdateEmployee(@RequestParam("idDivision") Integer idDivision, Model model) {
|
||||
public String showUpdateEmployee(@RequestParam("idDepartment") Integer idDepartment, Model model) {
|
||||
final String UPDATE_TARGET_ID_NOT_FOUND = "更新対象のデータが見つかりません。";
|
||||
|
||||
try {
|
||||
// id を条件に更新対象のレコードを検索、取得する
|
||||
List<AllDepartmentInfo>divisionList = searchDepartment.searchAllDepartmentTable(
|
||||
new SearchConditionDepartment(idDivision,
|
||||
List<Department> departmentList = searchDepartment.searchBy(
|
||||
new SearchConditionDepartment(idDepartment,
|
||||
null));
|
||||
|
||||
|
||||
// DBに更新対象のデータがあるか
|
||||
if (divisionList.isEmpty()) {
|
||||
if (departmentList.isEmpty()) {
|
||||
// ない場合はエラーメッセージをセットして検索画面に戻る
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(UPDATE_TARGET_ID_NOT_FOUND));
|
||||
return "forward:" + TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_HTML;
|
||||
}
|
||||
|
||||
// 更新画面に表示する値をセット
|
||||
model.addAttribute(PageReturnAttributeKeyword.UPDATE_DEPARTMENT_FORM, UpdateDepartmentForm.convertFrom(divisionList.get(0)));
|
||||
model.addAttribute(PageReturnAttributeKeyword.UPDATE_DEPARTMENT_FORM, UpdateDepartmentForm.convertFrom(departmentList.get(0)));
|
||||
|
||||
// Update画面に遷移
|
||||
return TransitionTargetPageNameKeyword.UPDATE_DEPARTMENT_INPUT_HTML;
|
||||
|
||||
@@ -1,23 +1,8 @@
|
||||
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 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.Division;
|
||||
import com.example.rhizome.app.domain.model.Headquarters;
|
||||
import com.example.rhizome.app.domain.model.SearchConditionDepartment;
|
||||
import com.example.rhizome.app.domain.service.SearchDepartment;
|
||||
import com.example.rhizome.app.domain.service.UpdateDepartment;
|
||||
@@ -26,6 +11,16 @@ import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTa
|
||||
import com.example.rhizome.app.presentation.form.DepartmentForm;
|
||||
import com.example.rhizome.app.presentation.form.MessageForm;
|
||||
import com.example.rhizome.app.presentation.form.UpdateDepartmentForm;
|
||||
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 javax.servlet.http.HttpSession;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* department を更新して結果を返す為のコントローラ
|
||||
@@ -33,139 +28,81 @@ import com.example.rhizome.app.presentation.form.UpdateDepartmentForm;
|
||||
@Controller
|
||||
public class UpdateDepartmentResultController {
|
||||
|
||||
// ログ出力用インスタンス
|
||||
private final static Logger LOGGER = Logger.getLogger(UpdateEmployeeController.class.getName());
|
||||
// エラーメッセージ用の定数フィールド
|
||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||
// ログ出力用インスタンス
|
||||
private final static Logger LOGGER = Logger.getLogger(UpdateEmployeeController.class.getName());
|
||||
// エラーメッセージ用の定数フィールド
|
||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||
|
||||
HttpSession httpSession;
|
||||
SearchDepartment searchDepartment;
|
||||
UpdateDepartment updateDepartment;
|
||||
HttpSession httpSession;
|
||||
SearchDepartment searchDepartment;
|
||||
UpdateDepartment updateDepartment;
|
||||
|
||||
@Autowired
|
||||
public UpdateDepartmentResultController(HttpSession httpSession, SearchDepartment searchDepartment,
|
||||
UpdateDepartment updateDepartment) {
|
||||
this.httpSession = httpSession;
|
||||
this.searchDepartment = searchDepartment;
|
||||
this.updateDepartment = updateDepartment;
|
||||
}
|
||||
@Autowired
|
||||
public UpdateDepartmentResultController(HttpSession httpSession, SearchDepartment searchDepartment, UpdateDepartment updateDepartment) {
|
||||
this.httpSession = httpSession;
|
||||
this.searchDepartment = searchDepartment;
|
||||
this.updateDepartment = updateDepartment;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新結果画面表示処理
|
||||
*
|
||||
* @param updateDepartmentForm 更新画面のフォーム
|
||||
* @param model ビューにデータを渡すためのコンテナ
|
||||
* @return 遷移先の画面
|
||||
*/
|
||||
@PermissionCheck
|
||||
@SessionCheck
|
||||
@RequestMapping(value = TransitionTargetPageNameKeyword.UPDATE_DEPARTMENT_RESULT, method = RequestMethod.POST)
|
||||
public String updateEmployeeResult(@ModelAttribute UpdateDepartmentForm updateDepartmentForm, Model model) {
|
||||
/**
|
||||
* 更新結果画面表示処理
|
||||
*
|
||||
* @param updateDepartmentForm 更新画面のフォーム
|
||||
* @param model ビューにデータを渡すためのコンテナ
|
||||
* @return 遷移先の画面
|
||||
*/
|
||||
@PermissionCheck
|
||||
@SessionCheck
|
||||
@RequestMapping(value = TransitionTargetPageNameKeyword.UPDATE_DEPARTMENT_RESULT, method = RequestMethod.POST)
|
||||
public String updateEmployeeResult(@ModelAttribute UpdateDepartmentForm updateDepartmentForm, Model model) {
|
||||
|
||||
final String NOTHING = "項目が空欄です。";
|
||||
final String DUPLICATION = "既に同名の部署が存在するか、値が変更されていません。";
|
||||
final String UPDATE_COMPLETE = "更新が完了しました。";
|
||||
final String NOTHING = "項目が空欄です。";
|
||||
final String DUPLICATION = "既に同名の部署が存在するか、値が変更されていません。";
|
||||
final String UPDATE_COMPLETE = "更新が完了しました。";
|
||||
|
||||
try {
|
||||
// 更新対象の部署データがない
|
||||
if (updateDepartmentForm.getNmHeadquarters().isBlank() ||
|
||||
updateDepartmentForm.getNmDepartment().isBlank() ||
|
||||
updateDepartmentForm.getNmDivision().isBlank()) {
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(NOTHING));
|
||||
model.addAttribute(PageReturnAttributeKeyword.UPDATE_DEPARTMENT_FORM, updateDepartmentForm);
|
||||
try {
|
||||
// 更新対象の部署データがない
|
||||
if (updateDepartmentForm.getNmDepartment().isBlank()) {
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(NOTHING));
|
||||
model.addAttribute(PageReturnAttributeKeyword.UPDATE_DEPARTMENT_FORM, updateDepartmentForm);
|
||||
|
||||
return TransitionTargetPageNameKeyword.UPDATE_DEPARTMENT_INPUT_HTML;
|
||||
}
|
||||
// 部署名で重複が無いかチェック
|
||||
List<Headquarters> beforeHeadquartersList = searchDepartment
|
||||
.searchHeadquartersByIdHeadquarters(updateDepartmentForm.getIdHeadquarters());
|
||||
List<Department> beforeDepartmentList = searchDepartment
|
||||
.searchDepartmentByIdDepartment(updateDepartmentForm.getIdDepartment());
|
||||
List<Division> beforeDivisionList = searchDepartment
|
||||
.searchDivisionByIdDivision(updateDepartmentForm.getIdDivision());
|
||||
return TransitionTargetPageNameKeyword.UPDATE_DEPARTMENT_INPUT_HTML;
|
||||
}
|
||||
|
||||
Headquarters beforeHeadquarters = beforeHeadquartersList.get(0);
|
||||
Department beforeDepartment = beforeDepartmentList.get(0);
|
||||
Division beforeDivision = beforeDivisionList.get(0);
|
||||
// 部署名で重複が無いかチェック
|
||||
if (!searchDepartment.searchBy(
|
||||
new SearchConditionDepartment(
|
||||
null,
|
||||
updateDepartmentForm.getNmDepartment())).isEmpty()) {
|
||||
// 存在する場合はエラーメッセージを設定して更新入力画面に遷移
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DUPLICATION));
|
||||
model.addAttribute(PageReturnAttributeKeyword.UPDATE_DEPARTMENT_FORM, updateDepartmentForm);
|
||||
|
||||
Headquarters afterHeadquarters = new Headquarters(
|
||||
updateDepartmentForm.getIdHeadquarters(),
|
||||
updateDepartmentForm.getNmHeadquarters(),
|
||||
null);
|
||||
Department afterDepartment = new Department(
|
||||
updateDepartmentForm.getIdDepartment(),
|
||||
updateDepartmentForm.getNmDepartment(),
|
||||
null,
|
||||
updateDepartmentForm.getIdHeadquarters());
|
||||
Division afterDivision = new Division(
|
||||
updateDepartmentForm.getIdDivision(),
|
||||
updateDepartmentForm.getNmDivision(),
|
||||
null,
|
||||
updateDepartmentForm.getIdDepartment());
|
||||
return TransitionTargetPageNameKeyword.UPDATE_DEPARTMENT_INPUT_HTML;
|
||||
}
|
||||
|
||||
if (searchDepartment.searchAllDepartmentTable(
|
||||
new SearchConditionDepartment(
|
||||
updateDepartmentForm.getIdHeadquarters(),
|
||||
updateDepartmentForm.getNmHeadquarters()),
|
||||
new SearchConditionDepartment(
|
||||
updateDepartmentForm.getIdDepartment(),
|
||||
updateDepartmentForm.getNmDepartment()),
|
||||
new SearchConditionDepartment(
|
||||
updateDepartmentForm.getIdDivision(),
|
||||
updateDepartmentForm.getNmDivision()))
|
||||
// 部署情報更新
|
||||
updateDepartment.updateDepartment(UpdateDepartmentForm.convertTo(updateDepartmentForm));
|
||||
|
||||
|| (!beforeHeadquarters.getNmHeadquarters().equals(afterHeadquarters.getNmHeadquarters())
|
||||
&&
|
||||
!searchDepartment.searchByHeadquarters(
|
||||
new SearchConditionDepartment(
|
||||
null,
|
||||
updateDepartmentForm.getNmHeadquarters()))
|
||||
.isEmpty())
|
||||
|| (!beforeDepartment.getNmDepartment().equals(afterDepartment.getNmDepartment())
|
||||
&&
|
||||
!searchDepartment.searchByDepartment(
|
||||
new SearchConditionDepartment(
|
||||
null,
|
||||
updateDepartmentForm.getNmDepartment()))
|
||||
.isEmpty())
|
||||
|| (!beforeDivision.getNmDivision().equals(afterDivision.getNmDivision())
|
||||
&&
|
||||
!searchDepartment.searchByDivision(
|
||||
new SearchConditionDepartment(
|
||||
null,
|
||||
updateDepartmentForm.getNmDivision()))
|
||||
.isEmpty())
|
||||
// 部署一覧取得
|
||||
model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, DepartmentForm.convertFrom(searchDepartment.selectAll()));
|
||||
// 更新結果のメッセージを画面にセットし一覧画面に遷移
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_INFO, new MessageForm(UPDATE_COMPLETE));
|
||||
|
||||
) {
|
||||
// 存在する場合はエラーメッセージを設定して更新入力画面に遷移
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DUPLICATION));
|
||||
model.addAttribute(PageReturnAttributeKeyword.UPDATE_DEPARTMENT_FORM, updateDepartmentForm);
|
||||
// forward 先で不用意な動作をしないために UpdateEmployeeInfoForm をクリア
|
||||
return "forward:" + TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_ALL;
|
||||
|
||||
return TransitionTargetPageNameKeyword.UPDATE_DEPARTMENT_INPUT_HTML;
|
||||
}
|
||||
|
||||
// 部署情報更新
|
||||
updateDepartment.updateDepartment(UpdateDepartmentForm.convertTo(updateDepartmentForm));
|
||||
} catch (Exception e) {
|
||||
// ログイン情報の破棄
|
||||
httpSession.invalidate();
|
||||
|
||||
// 部署一覧取得
|
||||
model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, DepartmentForm.convertFrom(
|
||||
searchDepartment.searchAllDepartmentTable()));
|
||||
// 更新結果のメッセージを画面にセットし一覧画面に遷移
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_INFO, new MessageForm(UPDATE_COMPLETE));
|
||||
e.printStackTrace();
|
||||
// エラーログ出力
|
||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||
// エラー画面遷移
|
||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||
}
|
||||
|
||||
// forward 先で不用意な動作をしないために UpdateEmployeeInfoForm をクリア
|
||||
return "forward:" + TransitionTargetPageNameKeyword.SELECT_DEPARTMENT_ALL;
|
||||
|
||||
} catch (Exception e) {
|
||||
// ログイン情報の破棄
|
||||
httpSession.invalidate();
|
||||
|
||||
e.printStackTrace();
|
||||
// エラーログ出力
|
||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||
// エラー画面遷移
|
||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,38 +1,29 @@
|
||||
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.GetMapping;
|
||||
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 org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.example.rhizome.aop.aspect.PermissionCheck;
|
||||
import com.example.rhizome.aop.aspect.SessionCheck;
|
||||
import com.example.rhizome.app.domain.model.AllDepartmentInfo;
|
||||
import com.example.rhizome.app.domain.model.AllEmployeeInfo;
|
||||
import com.example.rhizome.app.domain.model.SearchConditionDepartment;
|
||||
import com.example.rhizome.app.domain.model.EmployeeInfo;
|
||||
import com.example.rhizome.app.domain.model.SearchConditionEmployee;
|
||||
import com.example.rhizome.app.domain.service.RegisterEmployee;
|
||||
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.DepartmentInfoForm;
|
||||
import com.example.rhizome.app.presentation.form.DivisionInfoForm;
|
||||
import com.example.rhizome.app.presentation.form.HeadquartersInfoForm;
|
||||
import com.example.rhizome.app.presentation.form.DepartmentForm;
|
||||
import com.example.rhizome.app.presentation.form.MessageForm;
|
||||
import com.example.rhizome.app.presentation.form.SearchConditionEmployeeForm;
|
||||
import com.example.rhizome.app.presentation.form.UpdateEmployeeInfoForm;
|
||||
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 javax.servlet.http.HttpSession;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* 更新対象の employee が存在するか確認する為のコントローラ
|
||||
@@ -40,135 +31,77 @@ import com.example.rhizome.app.presentation.form.UpdateEmployeeInfoForm;
|
||||
@Controller
|
||||
public class UpdateEmployeeController {
|
||||
|
||||
// ログ出力用インスタンス
|
||||
private final static Logger LOGGER = Logger.getLogger(UpdateEmployeeController.class.getName());
|
||||
// エラーメッセージ用の定数フィールド
|
||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||
// ログ出力用インスタンス
|
||||
private final static Logger LOGGER = Logger.getLogger(UpdateEmployeeController.class.getName());
|
||||
// エラーメッセージ用の定数フィールド
|
||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||
|
||||
HttpSession httpSession;
|
||||
SearchDepartment searchDepartment;
|
||||
SearchEmployeeInfo searchEmployeeInfo;
|
||||
RegisterEmployee registerEmployee;
|
||||
HttpSession httpSession;
|
||||
SearchDepartment searchDepartment;
|
||||
SearchEmployeeInfo searchEmployeeInfo;
|
||||
|
||||
@Autowired
|
||||
public UpdateEmployeeController(HttpSession httpSession, SearchDepartment searchDepartment,
|
||||
SearchEmployeeInfo searchEmployeeInfo, RegisterEmployee registerEmployee) {
|
||||
this.httpSession = httpSession;
|
||||
this.searchDepartment = searchDepartment;
|
||||
this.searchEmployeeInfo = searchEmployeeInfo;
|
||||
this.registerEmployee = registerEmployee;
|
||||
}
|
||||
@Autowired
|
||||
public UpdateEmployeeController(HttpSession httpSession, SearchDepartment searchDepartment, SearchEmployeeInfo searchEmployeeInfo) {
|
||||
this.httpSession = httpSession;
|
||||
this.searchDepartment = searchDepartment;
|
||||
this.searchEmployeeInfo = searchEmployeeInfo;
|
||||
}
|
||||
|
||||
@ModelAttribute
|
||||
public SearchConditionEmployeeForm searchConditionEmployeeForm() {
|
||||
return new SearchConditionEmployeeForm();
|
||||
}
|
||||
@ModelAttribute
|
||||
public SearchConditionEmployeeForm searchConditionEmployeeForm() {
|
||||
return new SearchConditionEmployeeForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新対象の employee が存在するか確認する為のコントローラ
|
||||
*
|
||||
* @param idEmployee 更新対象の employee の id
|
||||
* @param model ビューにデータを渡すためのコンテナ
|
||||
* @return 遷移先の画面
|
||||
*/
|
||||
@PermissionCheck
|
||||
@SessionCheck
|
||||
@RequestMapping(value = TransitionTargetPageNameKeyword.SHOW_UPDATE_EMPLOYEE, method = RequestMethod.POST)
|
||||
public String showUpdateEmployee(@RequestParam("idEmployee") Integer idEmployee, Model model) {
|
||||
final String UPDATE_TARGET_ID_NOT_FOUND = "更新対象のデータが見つかりません。";
|
||||
/**
|
||||
* 更新対象の employee が存在するか確認する為のコントローラ
|
||||
*
|
||||
* @param idEmployee 更新対象の employee の id
|
||||
* @param model ビューにデータを渡すためのコンテナ
|
||||
* @return 遷移先の画面
|
||||
*/
|
||||
@PermissionCheck
|
||||
@SessionCheck
|
||||
@RequestMapping(value = TransitionTargetPageNameKeyword.SHOW_UPDATE_EMPLOYEE, method = RequestMethod.POST)
|
||||
public String showUpdateEmployee(@RequestParam("idEmployee") Integer idEmployee, Model model) {
|
||||
final String UPDATE_TARGET_ID_NOT_FOUND = "更新対象のデータが見つかりません。";
|
||||
|
||||
try {
|
||||
// 部署コードリストを作成し、画面に返す値としてセット
|
||||
model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, HeadquartersInfoForm.convertFrom(
|
||||
searchDepartment.searchAllDepartmentTable()));
|
||||
// id を条件に更新対象のレコードを検索、取得する
|
||||
List<AllEmployeeInfo> employeeInfoList = searchEmployeeInfo.searchBy(
|
||||
new SearchConditionEmployee(idEmployee,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null));
|
||||
try {
|
||||
// 部署一覧を取得し画面に返す値としてセット
|
||||
model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, DepartmentForm.convertFrom(searchDepartment.selectAll()));
|
||||
|
||||
// DBに更新対象のデータがあるか
|
||||
if (employeeInfoList.isEmpty()) {
|
||||
// ない場合はエラーメッセージをセットして検索画面に戻る
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR,
|
||||
new MessageForm(UPDATE_TARGET_ID_NOT_FOUND));
|
||||
return "forward:" + TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_INFO;
|
||||
}
|
||||
//idDivisionからidHeadquartersを調べてUpdateEmployeeInfoFormに入れる
|
||||
UpdateEmployeeInfoForm updateInfo = UpdateEmployeeInfoForm.convertFrom(employeeInfoList.get(0));
|
||||
SearchConditionDepartment beforeUpdate = new SearchConditionDepartment(
|
||||
updateInfo.getIdDivision(),
|
||||
null);
|
||||
List<AllDepartmentInfo> afterSearchDepartment = searchDepartment.searchAllDepartmentTable(beforeUpdate);
|
||||
// id を条件に更新対象のレコードを検索、取得する
|
||||
List<EmployeeInfo> employeeInfoList = searchEmployeeInfo.searchBy(
|
||||
new SearchConditionEmployee(idEmployee,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null));
|
||||
|
||||
updateInfo.setIdHeadquarters(afterSearchDepartment.get(0).getHeadquarters().getIdHeadquarters());
|
||||
// DBに更新対象のデータがあるか
|
||||
if (employeeInfoList.isEmpty()) {
|
||||
// ない場合はエラーメッセージをセットして検索画面に戻る
|
||||
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(UPDATE_TARGET_ID_NOT_FOUND));
|
||||
return "forward:" + TransitionTargetPageNameKeyword.SELECT_EMPLOYEE_INFO;
|
||||
}
|
||||
|
||||
// 更新画面に遷移
|
||||
model.addAttribute(PageReturnAttributeKeyword.UPDATE_EMPLOYEE_INFO_FORM,
|
||||
updateInfo);
|
||||
// 更新画面に遷移
|
||||
model.addAttribute(PageReturnAttributeKeyword.UPDATE_EMPLOYEE_INFO_FORM, UpdateEmployeeInfoForm.convertFrom(employeeInfoList.get(0)));
|
||||
|
||||
// Update画面に遷移
|
||||
return TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_INPUT_HTML;
|
||||
// Update画面に遷移
|
||||
return TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_INPUT_HTML;
|
||||
|
||||
} catch (Exception e) {
|
||||
// ログイン情報の破棄
|
||||
httpSession.invalidate();
|
||||
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
// ログイン情報の破棄
|
||||
httpSession.invalidate();
|
||||
|
||||
// エラーログ出力
|
||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||
// エラー画面遷移
|
||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
}
|
||||
// エラーログ出力
|
||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||
// エラー画面遷移
|
||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||
|
||||
/**
|
||||
* 社員情報更新画面の部情報のプルダウンの表示を行う
|
||||
*
|
||||
* @param idHeadquarters
|
||||
* @return 遷移先の画面
|
||||
*/
|
||||
//画面で本部のプルダウンが選択された時にJSでこのメソッドに飛ぶ
|
||||
@GetMapping("updateEmployeeInput/searchDepartment")
|
||||
@ResponseBody
|
||||
public List<DepartmentInfoForm> departmentsByHeadquarters(
|
||||
@RequestParam("id_headquarters") Integer idHeadquarters) {
|
||||
List<DepartmentInfoForm> departmentByHeadquarters = DepartmentInfoForm.convertFrom(
|
||||
searchDepartment.searchByIdHeadquarters(idHeadquarters));
|
||||
return departmentByHeadquarters
|
||||
.stream()
|
||||
.map(DepartmentInfoForm -> new DepartmentInfoForm(
|
||||
DepartmentInfoForm.getIdDepartment(),
|
||||
DepartmentInfoForm.getNmDepartment()))
|
||||
.distinct()
|
||||
.toList();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 社員情報更新画面の課情報のプルダウンの表示を行う
|
||||
*
|
||||
* @param idDepartment
|
||||
* @return 遷移先の画面
|
||||
*/
|
||||
//画面で部のプルダウンが選択された時にJSでこのメソッドに飛ぶ
|
||||
@GetMapping("/updateEmployeeInput/searchDepartment/searchDivision")
|
||||
@ResponseBody
|
||||
public List<DivisionInfoForm> divisionBydepartment(
|
||||
@RequestParam("id_department") Integer idDepartment) {
|
||||
List<DivisionInfoForm> divisionByDepartment = DivisionInfoForm.convertFrom(
|
||||
searchDepartment.searchByIdDepartment(idDepartment));
|
||||
return divisionByDepartment
|
||||
.stream()
|
||||
.map(DivisionInfoForm -> new DivisionInfoForm(
|
||||
DivisionInfoForm.getIdDivision(),
|
||||
DivisionInfoForm.getNmDivision()))
|
||||
.distinct()
|
||||
.toList();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,6 @@
|
||||
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.Employee;
|
||||
@@ -29,6 +15,18 @@ import com.example.rhizome.app.presentation.form.DepartmentForm;
|
||||
import com.example.rhizome.app.presentation.form.LoginUserForm;
|
||||
import com.example.rhizome.app.presentation.form.MessageForm;
|
||||
import com.example.rhizome.app.presentation.form.UpdateEmployeeInfoForm;
|
||||
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 javax.servlet.http.HttpSession;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* employee を更新して結果を返す為のコントローラ
|
||||
@@ -93,8 +91,7 @@ public class UpdateEmployeeResultController {
|
||||
try {
|
||||
|
||||
// 部署一覧取得
|
||||
model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, DepartmentForm.convertFrom(
|
||||
searchDepartment.searchAllDepartmentTable()));
|
||||
model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST, DepartmentForm.convertFrom(searchDepartment.selectAll()));
|
||||
|
||||
// パスワードが仕様を満たしているか確認
|
||||
String error = UpdateEmployeeInfoForm.validatePassword(
|
||||
@@ -150,12 +147,8 @@ public class UpdateEmployeeResultController {
|
||||
|
||||
return TransitionTargetPageNameKeyword.UPDATE_EMPLOYEE_INPUT_HTML;
|
||||
}
|
||||
|
||||
//勤続年数は更新対象ではないのでそのまま移し替える
|
||||
updateEmployeeInfoForm.setHireDate(beforeEmployee.getHireDate());
|
||||
|
||||
// 画面用の型からビジネスロジック用のモデルに変換し、Updateを実行
|
||||
|
||||
updateEmployee.updateEmployee(beforeEmployee, UpdateEmployeeInfoForm.convertTo(updateEmployeeInfoForm));
|
||||
|
||||
// Update後の情報を再取得
|
||||
|
||||
@@ -1,20 +1,6 @@
|
||||
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.Employee;
|
||||
@@ -26,6 +12,18 @@ import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTa
|
||||
import com.example.rhizome.app.presentation.form.LoginUserForm;
|
||||
import com.example.rhizome.app.presentation.form.MessageForm;
|
||||
import com.example.rhizome.app.presentation.form.UpdatePersonalUserForm;
|
||||
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 javax.servlet.http.HttpSession;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* 個人情報更新用コントローラ
|
||||
@@ -136,15 +134,11 @@ public class UpdatePersonalEmployeeResultController {
|
||||
}
|
||||
|
||||
//更新前のEmployeeの情報を取得
|
||||
Employee beforeEmployee =searchEmployee.searchEmployeeByIdEmployee(updatePersonalUserForm.getIdEmployee());
|
||||
|
||||
updatePersonalUserForm.setHireDate(beforeEmployee.getHireDate());
|
||||
|
||||
// 画面用のインスタンスから更新用のインスタンスに変換し、Update実施
|
||||
updateEmployee.updateEmployee(
|
||||
beforeEmployee,
|
||||
UpdatePersonalUserForm.convertTo(updatePersonalUserForm))
|
||||
;
|
||||
searchEmployee.searchEmployeeByIdEmployee(updatePersonalUserForm.getIdEmployee()),
|
||||
UpdatePersonalUserForm.convertTo(updatePersonalUserForm)
|
||||
);
|
||||
|
||||
// ログイン者の情報をセッション情報に格納
|
||||
httpSession.setAttribute(
|
||||
|
||||
@@ -16,7 +16,5 @@ public class PageReturnAttributeKeyword {
|
||||
public static final String LOGIN_INFO_FORM = "loginInfoForm";
|
||||
public static final String UPDATE_PERSONAL_EMPLOYEE_USER_FORM = "updatePersonalEmployeeUserForm";
|
||||
public static final String EMPLOYEE_INFO_FORM_LIST = "employeeInfoFormList";
|
||||
public static final String HEADQUARTERS_FORM_LIST = "headquartersFormList";
|
||||
public static final String DIVISION_FORM_LIST = "divisionFormList";
|
||||
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package com.example.rhizome.app.presentation.form;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.example.rhizome.app.domain.model.AllDepartmentInfo;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Department;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 画面の表示に使う部署コード管理用のクラス
|
||||
*/
|
||||
@@ -16,29 +15,14 @@ import lombok.NoArgsConstructor;
|
||||
@NoArgsConstructor
|
||||
public class DepartmentForm {
|
||||
/**
|
||||
* 本部ID
|
||||
*/
|
||||
private Integer idHeadquarters;
|
||||
/**
|
||||
* 本部名
|
||||
*/
|
||||
private String nmHeadquarters;
|
||||
/**
|
||||
* 部ID
|
||||
* 部署ID
|
||||
*/
|
||||
private Integer idDepartment;
|
||||
/**
|
||||
* 部名
|
||||
* 部署名
|
||||
*/
|
||||
private String nmDepartment;
|
||||
/**
|
||||
* 課ID
|
||||
*/
|
||||
private Integer idDivision;
|
||||
/**
|
||||
* 課名
|
||||
*/
|
||||
private String nmDivision;
|
||||
|
||||
/**
|
||||
* business 層の Department クラスから画面用(presentation 層)の DepartmentForm に
|
||||
* 変換します。
|
||||
@@ -46,15 +30,8 @@ public class DepartmentForm {
|
||||
* @param department business 層の Department インスタンス
|
||||
* @return 画面用(presentation 層)の DepartmentForm インスタンス
|
||||
*/
|
||||
public static DepartmentForm convertFrom(AllDepartmentInfo allDepartmentInfo) {
|
||||
return new DepartmentForm(
|
||||
allDepartmentInfo.getHeadquarters().getIdHeadquarters(),
|
||||
allDepartmentInfo.getHeadquarters().getNmHeadquarters(),
|
||||
allDepartmentInfo.getDepartment().getIdDepartment(),
|
||||
allDepartmentInfo.getDepartment().getNmDepartment(),
|
||||
allDepartmentInfo.getDivision().getIdDivision(),
|
||||
allDepartmentInfo.getDivision().getNmDivision()
|
||||
);
|
||||
public static DepartmentForm convertFrom(Department department) {
|
||||
return new DepartmentForm(department.getIdDepartment(), department.getNmDepartment());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,8 +41,7 @@ public class DepartmentForm {
|
||||
* @param departmentList business 層の Department インスタンスのリスト
|
||||
* @return 画面用(presentation 層)の DepartmentForm インスタンスのリスト
|
||||
*/
|
||||
public static List<DepartmentForm> convertFrom(List<AllDepartmentInfo>allDepartmentInfoList
|
||||
) {
|
||||
return allDepartmentInfoList.stream().map(DepartmentForm::convertFrom).distinct().toList();
|
||||
public static List<DepartmentForm> convertFrom(List<Department> departmentList) {
|
||||
return departmentList.stream().map(DepartmentForm::convertFrom).toList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
package com.example.rhizome.app.presentation.form;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.example.rhizome.app.domain.model.AllDepartmentInfo;
|
||||
import com.example.rhizome.app.domain.model.Department;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DepartmentInfoForm {
|
||||
/**
|
||||
* 部ID
|
||||
*/
|
||||
|
||||
private Integer idDepartment;
|
||||
/**
|
||||
* 部名
|
||||
*/
|
||||
|
||||
private String nmDepartment;
|
||||
|
||||
|
||||
public static DepartmentInfoForm convertFrom(Department department) {
|
||||
return new DepartmentInfoForm(
|
||||
department.getIdDepartment(),
|
||||
department.getNmDepartment()
|
||||
);
|
||||
}
|
||||
public static List<DepartmentInfoForm> convertFrom(List<Department>DepartmentList
|
||||
) {
|
||||
return DepartmentList.stream().map(DepartmentInfoForm::convertFrom).toList();
|
||||
}
|
||||
public static DepartmentInfoForm convertFrom(AllDepartmentInfo allDepartmentInfo) {
|
||||
return new DepartmentInfoForm(
|
||||
allDepartmentInfo.getDepartment().getIdDepartment(),
|
||||
allDepartmentInfo.getDepartment().getNmDepartment()
|
||||
);
|
||||
}
|
||||
public static List<DepartmentInfoForm> convertFromTo(List<AllDepartmentInfo>AllDepartmentInfoList
|
||||
) {
|
||||
return AllDepartmentInfoList.stream().map(DepartmentInfoForm::convertFrom).distinct().toList();
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package com.example.rhizome.app.presentation.form;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.example.rhizome.app.domain.model.AllDepartmentInfo;
|
||||
import com.example.rhizome.app.domain.model.Division;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DivisionInfoForm {
|
||||
/**
|
||||
* 課ID
|
||||
*/
|
||||
private Integer idDivision;
|
||||
/**
|
||||
* 課名
|
||||
*/
|
||||
private String nmDivision;
|
||||
|
||||
|
||||
public static DivisionInfoForm convertFrom(Division division) {
|
||||
return new DivisionInfoForm(
|
||||
division.getIdDivision(),
|
||||
division.getNmDivision()
|
||||
);
|
||||
}
|
||||
public static List<DivisionInfoForm> convertFrom(List<Division>divisionList
|
||||
) {
|
||||
return divisionList.stream().map(DivisionInfoForm::convertFrom).toList();
|
||||
}
|
||||
public static DivisionInfoForm convertFrom(AllDepartmentInfo allDepartmentInfo) {
|
||||
return new DivisionInfoForm(
|
||||
allDepartmentInfo.getDivision().getIdDivision(),
|
||||
allDepartmentInfo.getDivision().getNmDivision()
|
||||
);
|
||||
}
|
||||
public static List<DivisionInfoForm> convertFromTo(List<AllDepartmentInfo>AllDepartmentInfoList
|
||||
) {
|
||||
return AllDepartmentInfoList.stream().map(DivisionInfoForm::convertFrom).distinct().toList();
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.example.rhizome.app.presentation.form;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.example.rhizome.app.domain.model.AllEmployeeInfo;
|
||||
|
||||
import com.example.rhizome.app.domain.model.EmployeeInfo;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 画面に表示するために employee と department を Join した構造を扱うクラス
|
||||
*/
|
||||
@@ -16,94 +16,67 @@ import lombok.NoArgsConstructor;
|
||||
@NoArgsConstructor
|
||||
public class EmployeeInfoForm {
|
||||
|
||||
/**
|
||||
* 社員ID
|
||||
*/
|
||||
private Integer idEmployee;
|
||||
/**
|
||||
* 社員名
|
||||
*/
|
||||
private String nmEmployee;
|
||||
/**
|
||||
* 社員名カナ
|
||||
*/
|
||||
private String knEmployee;
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
private String mailAddress;
|
||||
/**
|
||||
* パスワード
|
||||
*/
|
||||
private String password;
|
||||
/**
|
||||
* 入社年月日
|
||||
*/
|
||||
private String hireDate;
|
||||
/**
|
||||
* 勤続年数
|
||||
*/
|
||||
private String tenure;
|
||||
/**
|
||||
* 管理者権限
|
||||
*/
|
||||
private Integer adminAuth;
|
||||
/**
|
||||
* 本部ID
|
||||
*/
|
||||
private Integer idHeadquarters;
|
||||
/**
|
||||
* 本部名
|
||||
*/
|
||||
private String nmHeadquarters;
|
||||
/**
|
||||
* 部ID
|
||||
*/
|
||||
private Integer idDepartment;
|
||||
/**
|
||||
* 部名
|
||||
*/
|
||||
private String nmDepartment;
|
||||
/**
|
||||
* 課ID
|
||||
*/
|
||||
private Integer idDivision;
|
||||
/**
|
||||
* 課名
|
||||
*/
|
||||
private String nmDivision;
|
||||
/**
|
||||
* 社員ID
|
||||
*/
|
||||
private Integer idEmployee;
|
||||
/**
|
||||
* 社員名
|
||||
*/
|
||||
private String nmEmployee;
|
||||
/**
|
||||
* 社員名カナ
|
||||
*/
|
||||
private String knEmployee;
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
private String mailAddress;
|
||||
/**
|
||||
* パスワード
|
||||
*/
|
||||
private String password;
|
||||
/**
|
||||
* パスワード
|
||||
*/
|
||||
private Integer adminAuth;
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
private Integer idDepartment;
|
||||
/**
|
||||
* 部署名
|
||||
*/
|
||||
private String nmDepartment;
|
||||
|
||||
/**
|
||||
* AllEmployeeInfo からEmployeeInfoForm に変換します。
|
||||
*
|
||||
* @param allEmployeeInfo AllEmployeeInfo インスタンス
|
||||
* @return EmployeeInfoForm インスタンス
|
||||
*/
|
||||
public static EmployeeInfoForm convertFrom(AllEmployeeInfo allEmployeeInfo) {
|
||||
return new EmployeeInfoForm(
|
||||
allEmployeeInfo.getEmployee().getIdEmployee(),
|
||||
allEmployeeInfo.getEmployee().getNmEmployee(),
|
||||
allEmployeeInfo.getEmployee().getKnEmployee(),
|
||||
allEmployeeInfo.getEmployee().getMailAddress(),
|
||||
allEmployeeInfo.getEmployee().getPassword(),
|
||||
allEmployeeInfo.getEmployee().getHireDate(),
|
||||
null,
|
||||
allEmployeeInfo.getEmployee().getAdminAuth(),
|
||||
allEmployeeInfo.getHeadquarters().getIdHeadquarters(),
|
||||
allEmployeeInfo.getHeadquarters().getNmHeadquarters(),
|
||||
allEmployeeInfo.getDepartment().getIdDepartment(),
|
||||
allEmployeeInfo.getDepartment().getNmDepartment(),
|
||||
allEmployeeInfo.getDivision().getIdDivision(),
|
||||
allEmployeeInfo.getDivision().getNmDivision());
|
||||
}
|
||||
/**
|
||||
* business 層の EmployeeInfo クラスから画面用(presentation 層)の EmployeeInfoForm に
|
||||
* 変換します。
|
||||
*
|
||||
* @param employeeInfo business 層の EmployeeInfo インスタンス
|
||||
* @return クラスから画面用(presentation 層)の EmployeeInfoForm インスタンス
|
||||
*/
|
||||
public static EmployeeInfoForm convertFrom(EmployeeInfo employeeInfo) {
|
||||
return new EmployeeInfoForm(
|
||||
employeeInfo.getEmployee().getIdEmployee(),
|
||||
employeeInfo.getEmployee().getNmEmployee(),
|
||||
employeeInfo.getEmployee().getKnEmployee(),
|
||||
employeeInfo.getEmployee().getMailAddress(),
|
||||
employeeInfo.getEmployee().getPassword(),
|
||||
employeeInfo.getEmployee().getAdminAuth(),
|
||||
employeeInfo.getDepartment().getIdDepartment(),
|
||||
employeeInfo.getDepartment().getNmDepartment()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* AllEmployeeInfo からEmployeeInfoForm に変換します。(リスト版)
|
||||
*
|
||||
* @param allEmployeeInfo AllEmployeeInfo インスタンスのリスト
|
||||
* @return EmployeeInfoForm インスタンスのリスト
|
||||
*/
|
||||
public static List<EmployeeInfoForm> convertFrom(List<AllEmployeeInfo> allEmployeeInfoList) {
|
||||
return allEmployeeInfoList.stream().map(EmployeeInfoForm::convertFrom).toList();
|
||||
}
|
||||
/**
|
||||
* business 層の EmployeeInfo クラスから画面用(presentation 層)の EmployeeInfoForm に
|
||||
* 変換します。(リスト版)
|
||||
*
|
||||
* @param employeeInfoList business 層の EmployeeInfo インスタンスのリスト
|
||||
* @return クラスから画面用(presentation 層)の EmployeeInfoForm インスタンスのリスト
|
||||
*/
|
||||
public static List<EmployeeInfoForm> convertFrom(List<EmployeeInfo> employeeInfoList) {
|
||||
return employeeInfoList.stream().map(EmployeeInfoForm::convertFrom).toList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
package com.example.rhizome.app.presentation.form;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.example.rhizome.app.domain.model.AllDepartmentInfo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class HeadquartersInfoForm {
|
||||
/**
|
||||
* 本部ID
|
||||
*/
|
||||
private Integer idHeadquarters;
|
||||
/**
|
||||
* 本部名
|
||||
*/
|
||||
private String nmHeadquarters;
|
||||
|
||||
/**
|
||||
* AllDepartmentInfoから HeadquartersInfoFormに変換します。
|
||||
*
|
||||
* @param allDepartmentInfo AllDepartmentInfo インスタンス
|
||||
* @return HeadquartersInfoForm インスタンス
|
||||
*/
|
||||
|
||||
public static HeadquartersInfoForm convertFrom(AllDepartmentInfo allDepartmentInfo) {
|
||||
return new HeadquartersInfoForm(
|
||||
allDepartmentInfo.getHeadquarters().getIdHeadquarters(),
|
||||
allDepartmentInfo.getHeadquarters().getNmHeadquarters());
|
||||
}
|
||||
|
||||
/**
|
||||
* AllDepartmentInfoから HeadquartersInfoFormに変換します。(リスト版)
|
||||
*
|
||||
* @param allDepartmentInfo AllDepartmentInfo インスタンスのリスト
|
||||
* @return HeadquartersInfoForm インスタンスのリスト
|
||||
*/
|
||||
public static List<HeadquartersInfoForm> convertFrom(List<AllDepartmentInfo> allDepartmentInfoList) {
|
||||
return allDepartmentInfoList.stream().map(HeadquartersInfoForm::convertFrom).distinct().toList();
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.example.rhizome.app.presentation.form;
|
||||
|
||||
import com.example.rhizome.app.domain.model.DepartmentInfo;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Department;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -13,63 +12,29 @@ import lombok.NoArgsConstructor;
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class InsertDepartmentForm {
|
||||
/**
|
||||
* 本部ID
|
||||
*/
|
||||
private Integer idHeadquarters;
|
||||
/**
|
||||
* 本部名
|
||||
*/
|
||||
private String nmHeadquarters;
|
||||
/**
|
||||
* 部ID
|
||||
*/
|
||||
private Integer idDepartment;
|
||||
/**
|
||||
* 部名
|
||||
*/
|
||||
private String nmDepartment;
|
||||
|
||||
/**
|
||||
* 課ID
|
||||
*/
|
||||
private Integer idDivision;
|
||||
/**
|
||||
* 課名
|
||||
*/
|
||||
private String nmDivision;
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
private Integer idDepartment;
|
||||
/**
|
||||
* 部署名
|
||||
*/
|
||||
private String nmDepartment;
|
||||
|
||||
/**
|
||||
* 画面用(presentation 層)の InsertDepartmentForm クラス を Business 層の DepartmentInfo クラスに変換
|
||||
*
|
||||
* @param insertDepartmentForm presentation 層用のクラス
|
||||
* @return DepartmentFormのインスタンス
|
||||
*/
|
||||
public static DepartmentInfo convertTo(InsertDepartmentForm insertDepartmentForm) {
|
||||
return new DepartmentInfo(insertDepartmentForm.getIdHeadquarters(),
|
||||
insertDepartmentForm.getNmHeadquarters(),
|
||||
insertDepartmentForm.getIdDepartment(),
|
||||
insertDepartmentForm.getNmDepartment(),
|
||||
insertDepartmentForm.getIdDivision(),
|
||||
insertDepartmentForm.getNmDivision());
|
||||
}
|
||||
/**
|
||||
* 画面用(presentation 層)の InsertDepartmentForm クラス を Business 層の Department クラスに変換
|
||||
*
|
||||
* @param insertDepartmentForm presentation 層用のクラス
|
||||
* @return Business 層用のモデル
|
||||
*/
|
||||
public static Department convertTo(InsertDepartmentForm insertDepartmentForm) {
|
||||
return new Department(insertDepartmentForm.getIdDepartment(), insertDepartmentForm.getNmDepartment());
|
||||
}
|
||||
|
||||
public boolean haveNmDepartment() {
|
||||
|
||||
if (idHeadquarters == null && nmHeadquarters.isBlank()) {
|
||||
|
||||
return true;
|
||||
}
|
||||
if (idDepartment == null && nmDepartment.isBlank()) {
|
||||
|
||||
return true;
|
||||
}
|
||||
if (idDivision == null && nmDivision.isBlank()) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
public boolean haveNmDepartment() {
|
||||
return nmDepartment.isBlank();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
package com.example.rhizome.app.presentation.form;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Employee;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 画面から渡ってきた登録内容をまとめ、再度画面に表示する為のクラス
|
||||
*/
|
||||
@@ -17,155 +16,137 @@ import lombok.NoArgsConstructor;
|
||||
@NoArgsConstructor
|
||||
public class InsertEmployeeForm {
|
||||
|
||||
/**
|
||||
* 社員名
|
||||
*/
|
||||
private String nmEmployee;
|
||||
/**
|
||||
* 社員名
|
||||
*/
|
||||
private String nmEmployee;
|
||||
|
||||
/**
|
||||
* 社員名カナ
|
||||
*/
|
||||
private String knEmployee;
|
||||
/**
|
||||
* 社員名カナ
|
||||
*/
|
||||
private String knEmployee;
|
||||
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
private String mailAddress;
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
private String mailAddress;
|
||||
|
||||
/**
|
||||
* パスワード
|
||||
*/
|
||||
private String password;
|
||||
/**
|
||||
* パスワード
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 確認用パスワード
|
||||
*/
|
||||
private String passwordConfirm;
|
||||
/**
|
||||
* 入社年月日
|
||||
*/
|
||||
private String hireDate;
|
||||
/**
|
||||
* 確認用パスワード
|
||||
*/
|
||||
private String passwordConfirm;
|
||||
|
||||
/**
|
||||
* 管理者権限
|
||||
*/
|
||||
private Integer adminAuth;
|
||||
/**
|
||||
* 管理者権限
|
||||
*/
|
||||
private Integer adminAuth;
|
||||
|
||||
/**
|
||||
* 本部ID
|
||||
*/
|
||||
private Integer idHeadquarters;
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
private Integer idDepartment;
|
||||
|
||||
/**
|
||||
* 部ID
|
||||
*/
|
||||
private Integer idDepartment;
|
||||
/**
|
||||
* パスワードのValidation
|
||||
* チェック対象にエラーが有った場合エラーリストに文言を追加する
|
||||
*
|
||||
* @param password 登録対象のパスワード
|
||||
* @param passwordConfirm 登録対象のパスワード再入力
|
||||
* @param error エラーリスト
|
||||
*/
|
||||
private static void checkPassword(String password, String passwordConfirm, List<String> error) {
|
||||
final String PASSWORD_NULL_BLANK = "パスワード が未入力です。";
|
||||
final String PASSWORD_CONFIRM_NULL_BLANK = "パスワード確認用 が未入力です。";
|
||||
final String PASSWORD_MISMATCH = "パスワード と パスワード確認用 が一致しません。";
|
||||
|
||||
/**
|
||||
* 課ID
|
||||
*/
|
||||
private Integer idDivision;
|
||||
if (isNullOrBlank(password)) {
|
||||
error.add(PASSWORD_NULL_BLANK);
|
||||
return;
|
||||
}
|
||||
if (isNullOrBlank(passwordConfirm)) {
|
||||
error.add(PASSWORD_CONFIRM_NULL_BLANK);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* パスワードのValidation
|
||||
* チェック対象にエラーが有った場合エラーリストに文言を追加する
|
||||
*
|
||||
* @param password 登録対象のパスワード
|
||||
* @param passwordConfirm 登録対象のパスワード再入力
|
||||
* @param error エラーリスト
|
||||
*/
|
||||
private static void checkPassword(String password, String passwordConfirm, List<String> error) {
|
||||
final String PASSWORD_NULL_BLANK = "パスワード が未入力です。";
|
||||
final String PASSWORD_CONFIRM_NULL_BLANK = "パスワード確認用 が未入力です。";
|
||||
final String PASSWORD_MISMATCH = "パスワード と パスワード確認用 が一致しません。";
|
||||
if (!password.equals(passwordConfirm)) {
|
||||
error.add(PASSWORD_MISMATCH);
|
||||
}
|
||||
}
|
||||
|
||||
if (isNullOrBlank(password)) {
|
||||
error.add(PASSWORD_NULL_BLANK);
|
||||
return;
|
||||
}
|
||||
if (isNullOrBlank(passwordConfirm)) {
|
||||
error.add(PASSWORD_CONFIRM_NULL_BLANK);
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* 仮引数を null or 空 判定する
|
||||
*
|
||||
* @param str 判定対象の文字列
|
||||
* @return true:null or 空 false:null or 空 では無い
|
||||
*/
|
||||
private static boolean isNullOrBlank(String str) {
|
||||
if (null == str) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!password.equals(passwordConfirm)) {
|
||||
error.add(PASSWORD_MISMATCH);
|
||||
}
|
||||
}
|
||||
return str.isBlank();
|
||||
}
|
||||
|
||||
/**
|
||||
* 仮引数を null or 空 判定する
|
||||
*
|
||||
* @param str 判定対象の文字列
|
||||
* @return true:null or 空 false:null or 空 では無い
|
||||
*/
|
||||
private static boolean isNullOrBlank(String str) {
|
||||
if (null == str) {
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* 画面から渡ってきた登録内容をまとめ、ビジネスモデルに変換
|
||||
*
|
||||
* @param insertEmployeeForm 画面から渡ってきた登録内容
|
||||
* @return ビジネスモデルのインスタンス
|
||||
*/
|
||||
public static Employee convertTo(InsertEmployeeForm insertEmployeeForm) {
|
||||
return new Employee(
|
||||
null,
|
||||
insertEmployeeForm.getNmEmployee(),
|
||||
insertEmployeeForm.getKnEmployee(),
|
||||
insertEmployeeForm.getMailAddress(),
|
||||
insertEmployeeForm.getPassword(),
|
||||
insertEmployeeForm.getAdminAuth(),
|
||||
insertEmployeeForm.getIdDepartment()
|
||||
);
|
||||
}
|
||||
|
||||
return str.isBlank();
|
||||
}
|
||||
/**
|
||||
* 登録データのValidationを行う
|
||||
*
|
||||
* @return エラーが有った場合はエラー文言、無ければ空のリストが返る
|
||||
*/
|
||||
public List<String> validateParameter() {
|
||||
final String EMPLOYEE_NAME_NULL_BLANK = "社員名";
|
||||
final String EMPLOYEE_KANA_NULL_BLANK = "社員名フリガナ";
|
||||
final String MAIL_ADDRESS_NULL_BLANK = "メールアドレス";
|
||||
final String MANAGEMENT_ERROR = "管理者権限指定";
|
||||
final String DEPARTMENT_ID_NULL_BLANK = "所属部署";
|
||||
|
||||
/**
|
||||
* 画面から渡ってきた登録内容をまとめ、ビジネスモデルに変換
|
||||
*
|
||||
* @param insertEmployeeForm 画面から渡ってきた登録内容
|
||||
* @return ビジネスモデルのインスタンス
|
||||
*/
|
||||
public static Employee convertTo(InsertEmployeeForm insertEmployeeForm) {
|
||||
return new Employee(
|
||||
null,
|
||||
insertEmployeeForm.getNmEmployee(),
|
||||
insertEmployeeForm.getKnEmployee(),
|
||||
insertEmployeeForm.getMailAddress(),
|
||||
insertEmployeeForm.getPassword(),
|
||||
insertEmployeeForm.getHireDate(),
|
||||
insertEmployeeForm.getAdminAuth(),
|
||||
insertEmployeeForm.getIdDivision());
|
||||
}
|
||||
List<String> error = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 登録データのValidationを行う
|
||||
*
|
||||
* @return エラーが有った場合はエラー文言、無ければ空のリストが返る
|
||||
*/
|
||||
public List<String> validateParameter() {
|
||||
final String EMPLOYEE_NAME_NULL_BLANK = "社員名";
|
||||
final String EMPLOYEE_KANA_NULL_BLANK = "社員名フリガナ";
|
||||
final String MAIL_ADDRESS_NULL_BLANK = "メールアドレス";
|
||||
final String MANAGEMENT_ERROR = "管理者権限指定";
|
||||
final String DEPARTMENT_ID_NULL_BLANK = "所属部署";
|
||||
final String HIREDATE_NULL_BLANK = "入社年月日";
|
||||
if (isNullOrBlank(nmEmployee)) {
|
||||
error.add(EMPLOYEE_NAME_NULL_BLANK);
|
||||
}
|
||||
if (isNullOrBlank(knEmployee)) {
|
||||
error.add(EMPLOYEE_KANA_NULL_BLANK);
|
||||
}
|
||||
if (isNullOrBlank(mailAddress)) {
|
||||
error.add(MAIL_ADDRESS_NULL_BLANK);
|
||||
}
|
||||
|
||||
List<String> error = new ArrayList<>();
|
||||
// パスワードが仕様を満たしているか確認
|
||||
checkPassword(password, passwordConfirm, error);
|
||||
|
||||
if (isNullOrBlank(nmEmployee)) {
|
||||
error.add(EMPLOYEE_NAME_NULL_BLANK);
|
||||
}
|
||||
if (isNullOrBlank(knEmployee)) {
|
||||
error.add(EMPLOYEE_KANA_NULL_BLANK);
|
||||
}
|
||||
if (isNullOrBlank(mailAddress)) {
|
||||
error.add(MAIL_ADDRESS_NULL_BLANK);
|
||||
}
|
||||
if (adminAuth == null) {
|
||||
error.add(MANAGEMENT_ERROR);
|
||||
}
|
||||
|
||||
// パスワードが仕様を満たしているか確認
|
||||
checkPassword(password, passwordConfirm, error);
|
||||
if (idDepartment == null) {
|
||||
error.add(DEPARTMENT_ID_NULL_BLANK);
|
||||
}
|
||||
|
||||
if (adminAuth == null) {
|
||||
error.add(MANAGEMENT_ERROR);
|
||||
}
|
||||
return error;
|
||||
|
||||
if (idDivision == null) {
|
||||
error.add(DEPARTMENT_ID_NULL_BLANK);
|
||||
}
|
||||
if (isNullOrBlank(hireDate)) {
|
||||
error.add(HIREDATE_NULL_BLANK);
|
||||
}
|
||||
|
||||
return error;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,12 +12,12 @@ import lombok.NoArgsConstructor;
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class LoginInfoForm {
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
private String mailAddress;
|
||||
/**
|
||||
* パスワード
|
||||
*/
|
||||
private String password;
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
private String mailAddress;
|
||||
/**
|
||||
* パスワード
|
||||
*/
|
||||
private String password;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.example.rhizome.app.presentation.form;
|
||||
|
||||
import com.example.rhizome.app.domain.model.LoginUser;
|
||||
|
||||
import com.example.rhizome.app.domain.model.LoginUser;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -10,102 +10,104 @@ import lombok.NoArgsConstructor;
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class LoginUserForm {
|
||||
/**
|
||||
* 社員ID
|
||||
*/
|
||||
private Integer idEmployee;
|
||||
/**
|
||||
* 社員名
|
||||
*/
|
||||
private String nmEmployee;
|
||||
/**
|
||||
* 社員名カナ
|
||||
*/
|
||||
private String knEmployee;
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
private String mailAddress;
|
||||
/**
|
||||
* パスワード
|
||||
*/
|
||||
private String password;
|
||||
/**
|
||||
* 社員ID
|
||||
*/
|
||||
private Integer idEmployee;
|
||||
/**
|
||||
* 社員名
|
||||
*/
|
||||
private String nmEmployee;
|
||||
/**
|
||||
* 社員名カナ
|
||||
*/
|
||||
private String knEmployee;
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
private String mailAddress;
|
||||
/**
|
||||
* パスワード
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 管理者権限
|
||||
*/
|
||||
private Integer adminAuth;
|
||||
/**
|
||||
* 管理者権限
|
||||
*/
|
||||
private Integer adminAuth;
|
||||
|
||||
/**
|
||||
* 課ID
|
||||
*/
|
||||
private Integer idDepartment;
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
private Integer idDepartment;
|
||||
|
||||
/**
|
||||
* business 層の LoginUser クラスから画面用(presentation 層)の LoginUserForm に
|
||||
* 変換します。
|
||||
*
|
||||
* @param loginUser business 層の LoginUser インスタンス
|
||||
* @return クラスから画面用(presentation 層)の LoginUserForm
|
||||
*/
|
||||
public static LoginUserForm convertFrom(LoginUser loginUser) {
|
||||
return new LoginUserForm(
|
||||
loginUser.getIdEmployee(),
|
||||
loginUser.getNmEmployee(),
|
||||
loginUser.getKnEmployee(),
|
||||
loginUser.getMailAddress(),
|
||||
loginUser.getPassword(),
|
||||
loginUser.getAdminAuth(),
|
||||
loginUser.getIdDivision());
|
||||
}
|
||||
/**
|
||||
* business 層の LoginUser クラスから画面用(presentation 層)の LoginUserForm に
|
||||
* 変換します。
|
||||
*
|
||||
* @param loginUser business 層の LoginUser インスタンス
|
||||
* @return クラスから画面用(presentation 層)の LoginUserForm
|
||||
*/
|
||||
public static LoginUserForm convertFrom(LoginUser loginUser) {
|
||||
return new LoginUserForm(
|
||||
loginUser.getIdEmployee(),
|
||||
loginUser.getNmEmployee(),
|
||||
loginUser.getKnEmployee(),
|
||||
loginUser.getMailAddress(),
|
||||
loginUser.getPassword(),
|
||||
loginUser.getAdminAuth(),
|
||||
loginUser.getIdDepartment()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 画面用(presentation 層)の LoginUserForm クラスから business 層の LoginUser クラスに
|
||||
* 変換します。
|
||||
*
|
||||
* @param loginUserForm 画面用(presentation 層)の LoginUserForm インスタンス
|
||||
* @return business 層の LoginUser インスタンス
|
||||
*/
|
||||
public static LoginUser convertTo(LoginUserForm loginUserForm) {
|
||||
return new LoginUser(
|
||||
loginUserForm.getIdEmployee(),
|
||||
loginUserForm.getNmEmployee(),
|
||||
loginUserForm.getKnEmployee(),
|
||||
loginUserForm.getMailAddress(),
|
||||
loginUserForm.getPassword(),
|
||||
loginUserForm.getAdminAuth(),
|
||||
loginUserForm.getIdDepartment());
|
||||
}
|
||||
/**
|
||||
* 画面用(presentation 層)の LoginUserForm クラスから business 層の LoginUser クラスに
|
||||
* 変換します。
|
||||
*
|
||||
* @param loginUserForm 画面用(presentation 層)の LoginUserForm インスタンス
|
||||
* @return business 層の LoginUser インスタンス
|
||||
*/
|
||||
public static LoginUser convertTo(LoginUserForm loginUserForm) {
|
||||
return new LoginUser(
|
||||
loginUserForm.getIdEmployee(),
|
||||
loginUserForm.getNmEmployee(),
|
||||
loginUserForm.getKnEmployee(),
|
||||
loginUserForm.getMailAddress(),
|
||||
loginUserForm.getPassword(),
|
||||
loginUserForm.getAdminAuth(),
|
||||
loginUserForm.getIdDepartment()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 画面から渡ってきた必須の値が仕様を満たしているか確認
|
||||
*
|
||||
* @param loginInfoForm 画面から渡ってきた mailAddress, password を格納しているインスタンス
|
||||
* @return true:仕様を満たしている , false:仕様を満たしていない
|
||||
*/
|
||||
public static boolean checkParameter(LoginInfoForm loginInfoForm) {
|
||||
if (null == loginInfoForm.getMailAddress()) {
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* 画面から渡ってきた必須の値が仕様を満たしているか確認
|
||||
*
|
||||
* @param loginInfoForm 画面から渡ってきた mailAddress, password を格納しているインスタンス
|
||||
* @return true:仕様を満たしている , false:仕様を満たしていない
|
||||
*/
|
||||
public static boolean checkParameter(LoginInfoForm loginInfoForm) {
|
||||
if (null == loginInfoForm.getMailAddress()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (loginInfoForm.getMailAddress().isBlank()) {
|
||||
return false;
|
||||
}
|
||||
if (loginInfoForm.getMailAddress().isBlank()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (null == loginInfoForm.getPassword()) {
|
||||
return false;
|
||||
}
|
||||
if (null == loginInfoForm.getPassword()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !loginInfoForm.getPassword().isBlank();
|
||||
return !loginInfoForm.getPassword().isBlank();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理者権限を持っているか確認
|
||||
*
|
||||
* @return true:管理者権限を持っている , false:管理者権限を持っていない
|
||||
*/
|
||||
public boolean isAdminUser() {
|
||||
return getAdminAuth() == 1;
|
||||
}
|
||||
/**
|
||||
* 管理者権限を持っているか確認
|
||||
*
|
||||
* @return true:管理者権限を持っている , false:管理者権限を持っていない
|
||||
*/
|
||||
public boolean isAdminUser() {
|
||||
return getAdminAuth() == 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,5 +11,5 @@ import lombok.NoArgsConstructor;
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class MessageForm {
|
||||
private String message;
|
||||
private String message;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
package com.example.rhizome.app.presentation.form;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Department;
|
||||
import com.example.rhizome.app.domain.model.SearchConditionDepartment;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 画面から渡ってきた検索条件をまとめ、再度画面に表示する為のクラス
|
||||
*/
|
||||
@@ -16,48 +15,49 @@ import lombok.NoArgsConstructor;
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class SearchConditionDepartmentForm {
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
private Integer idDivision;
|
||||
/**
|
||||
* 部署名
|
||||
*/
|
||||
private String nmDivision;
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
private Integer idDepartment;
|
||||
/**
|
||||
* 部署名
|
||||
*/
|
||||
private String nmDepartment;
|
||||
|
||||
/**
|
||||
* business 層の Department クラスから画面用(presentation 層)の SearchConditionDepartmentForm に
|
||||
* 変換します。
|
||||
*
|
||||
* @param department business 層の Department インスタンス
|
||||
* @return 画面用(presentation 層)の SearchConditionDepartmentForm インスタンス
|
||||
*/
|
||||
public static SearchConditionDepartmentForm convertFrom(Department department) {
|
||||
return new SearchConditionDepartmentForm(department.getIdDepartment(), department.getNmDepartment());
|
||||
}
|
||||
/**
|
||||
* business 層の Department クラスから画面用(presentation 層)の SearchConditionDepartmentForm に
|
||||
* 変換します。
|
||||
*
|
||||
* @param department business 層の Department インスタンス
|
||||
* @return 画面用(presentation 層)の SearchConditionDepartmentForm インスタンス
|
||||
*/
|
||||
public static SearchConditionDepartmentForm convertFrom(Department department) {
|
||||
return new SearchConditionDepartmentForm(department.getIdDepartment(), department.getNmDepartment());
|
||||
}
|
||||
|
||||
/**
|
||||
* business 層の Department クラスから画面用(presentation 層)の SearchConditionDepartmentForm に
|
||||
* 変換します。(リスト版)
|
||||
*
|
||||
* @param departmentList business 層の Department インスタンスのリスト
|
||||
* @return 画面用(presentation 層)の SearchConditionDepartmentForm インスタンスのリスト
|
||||
*/
|
||||
public static List<SearchConditionDepartmentForm> convertFrom(List<Department> departmentList) {
|
||||
return departmentList.stream().map(SearchConditionDepartmentForm::convertFrom).toList();
|
||||
}
|
||||
/**
|
||||
* business 層の Department クラスから画面用(presentation 層)の SearchConditionDepartmentForm に
|
||||
* 変換します。(リスト版)
|
||||
*
|
||||
* @param departmentList business 層の Department インスタンスのリスト
|
||||
* @return 画面用(presentation 層)の SearchConditionDepartmentForm インスタンスのリスト
|
||||
*/
|
||||
public static List<SearchConditionDepartmentForm> convertFrom(List<Department> departmentList) {
|
||||
return departmentList.stream().map(SearchConditionDepartmentForm::convertFrom).toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* presentation 層の SearchConditionDepartmentForm クラスから画面用(Business 層)の SearchConditionDepartment に
|
||||
* 変換します。(リスト版)
|
||||
*
|
||||
* @param searchConditionDepartmentForm 検索画面の情報
|
||||
* @return 画面用(Business 層)の SearchConditionDepartment インスタンスのリスト
|
||||
*/
|
||||
public static SearchConditionDepartment convertTo(SearchConditionDepartmentForm searchConditionDepartmentForm) {
|
||||
return new SearchConditionDepartment(
|
||||
searchConditionDepartmentForm.getIdDivision(),
|
||||
searchConditionDepartmentForm.nmDivision);
|
||||
/**
|
||||
* presentation 層の SearchConditionDepartmentForm クラスから画面用(Business 層)の SearchConditionDepartment に
|
||||
* 変換します。(リスト版)
|
||||
*
|
||||
* @param searchConditionDepartmentForm 検索画面の情報
|
||||
* @return 画面用(Business 層)の SearchConditionDepartment インスタンスのリスト
|
||||
*/
|
||||
public static SearchConditionDepartment convertTo(SearchConditionDepartmentForm searchConditionDepartmentForm) {
|
||||
return new SearchConditionDepartment(
|
||||
searchConditionDepartmentForm.getIdDepartment(),
|
||||
searchConditionDepartmentForm.nmDepartment
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.example.rhizome.app.presentation.form;
|
||||
|
||||
import com.example.rhizome.app.domain.model.SearchConditionEmployee;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -14,56 +13,58 @@ import lombok.NoArgsConstructor;
|
||||
@NoArgsConstructor
|
||||
public class SearchConditionEmployeeForm {
|
||||
|
||||
/**
|
||||
* 社員ID
|
||||
*/
|
||||
private Integer idEmployee;
|
||||
/**
|
||||
* 社員名
|
||||
*/
|
||||
private String nmEmployee;
|
||||
/**
|
||||
* 社員名カナ
|
||||
*/
|
||||
private String knEmployee;
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
private String mailAddress;
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
private Integer idDivision;
|
||||
/**
|
||||
* 社員ID
|
||||
*/
|
||||
private Integer idEmployee;
|
||||
/**
|
||||
* 社員名
|
||||
*/
|
||||
private String nmEmployee;
|
||||
/**
|
||||
* 社員名カナ
|
||||
*/
|
||||
private String knEmployee;
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
private String mailAddress;
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
private Integer idDepartment;
|
||||
|
||||
/**
|
||||
* business 層の SearchConditionEmployee クラスから画面用(presentation 層)の SearchConditionEmployeeForm に
|
||||
* 変換します。
|
||||
*
|
||||
* @param searchConditionEmployee business 層の SearchConditionEmployee インスタンス
|
||||
* @return 画面用(presentation 層)の SearchConditionEmployeeForm インスタンス
|
||||
*/
|
||||
public static SearchConditionEmployeeForm convertFrom(SearchConditionEmployee searchConditionEmployee) {
|
||||
return new SearchConditionEmployeeForm(
|
||||
searchConditionEmployee.getIdEmployee(),
|
||||
searchConditionEmployee.getNmEmployee(),
|
||||
searchConditionEmployee.getKnEmployee(),
|
||||
searchConditionEmployee.getMailAddress(),
|
||||
searchConditionEmployee.getIdDivision());
|
||||
}
|
||||
/**
|
||||
* business 層の SearchConditionEmployee クラスから画面用(presentation 層)の SearchConditionEmployeeForm に
|
||||
* 変換します。
|
||||
*
|
||||
* @param searchConditionEmployee business 層の SearchConditionEmployee インスタンス
|
||||
* @return 画面用(presentation 層)の SearchConditionEmployeeForm インスタンス
|
||||
*/
|
||||
public static SearchConditionEmployeeForm convertFrom(SearchConditionEmployee searchConditionEmployee) {
|
||||
return new SearchConditionEmployeeForm(
|
||||
searchConditionEmployee.getIdEmployee(),
|
||||
searchConditionEmployee.getNmEmployee(),
|
||||
searchConditionEmployee.getKnEmployee(),
|
||||
searchConditionEmployee.getMailAddress(),
|
||||
searchConditionEmployee.getIdDepartment()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 画面用(presentation 層)の SearchConditionEmployeeForm クラスから business 層の SearchConditionEmployee クラスに
|
||||
* 変換します。
|
||||
*
|
||||
* @param searchConditionEmployeeForm 画面用(presentation 層)の SearchConditionEmployeeForm インスタンス
|
||||
* @return business 層の SearchConditionEmployee インスタンス
|
||||
*/
|
||||
public static SearchConditionEmployee convertTo(SearchConditionEmployeeForm searchConditionEmployeeForm) {
|
||||
return new SearchConditionEmployee(
|
||||
searchConditionEmployeeForm.getIdEmployee(),
|
||||
searchConditionEmployeeForm.getNmEmployee(),
|
||||
searchConditionEmployeeForm.getKnEmployee(),
|
||||
searchConditionEmployeeForm.getMailAddress(),
|
||||
searchConditionEmployeeForm.getIdDivision());
|
||||
}
|
||||
/**
|
||||
* 画面用(presentation 層)の SearchConditionEmployeeForm クラスから business 層の SearchConditionEmployee クラスに
|
||||
* 変換します。
|
||||
*
|
||||
* @param searchConditionEmployeeForm 画面用(presentation 層)の SearchConditionEmployeeForm インスタンス
|
||||
* @return business 層の SearchConditionEmployee インスタンス
|
||||
*/
|
||||
public static SearchConditionEmployee convertTo(SearchConditionEmployeeForm searchConditionEmployeeForm) {
|
||||
return new SearchConditionEmployee(
|
||||
searchConditionEmployeeForm.getIdEmployee(),
|
||||
searchConditionEmployeeForm.getNmEmployee(),
|
||||
searchConditionEmployeeForm.getKnEmployee(),
|
||||
searchConditionEmployeeForm.getMailAddress(),
|
||||
searchConditionEmployeeForm.getIdDepartment()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,74 +1,61 @@
|
||||
package com.example.rhizome.app.presentation.form;
|
||||
|
||||
import com.example.rhizome.app.domain.model.AllDepartmentInfo;
|
||||
import com.example.rhizome.app.domain.model.DepartmentInfo;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Department;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 画面の表示に使う部署コード管理用のクラス
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
|
||||
@NoArgsConstructor
|
||||
public class UpdateDepartmentForm {
|
||||
/**
|
||||
* 本部ID
|
||||
*/
|
||||
private Integer idHeadquarters;
|
||||
/**
|
||||
* 本部名
|
||||
*/
|
||||
private String nmHeadquarters;
|
||||
/**
|
||||
* 部ID
|
||||
*/
|
||||
private Integer idDepartment;
|
||||
/**
|
||||
* 部名
|
||||
*/
|
||||
private String nmDepartment;
|
||||
/**
|
||||
* 課ID
|
||||
*/
|
||||
private Integer idDivision;
|
||||
/**
|
||||
* 課名
|
||||
*/
|
||||
private String nmDivision;
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
private Integer idDepartment;
|
||||
/**
|
||||
* 部署名
|
||||
*/
|
||||
private String nmDepartment;
|
||||
|
||||
/**
|
||||
* AllDepartmentInfoクラスから UpdateDepartmentForm に変換します。
|
||||
*
|
||||
* @param allDepartmentInfo AllDepartmentInfo インスタンス
|
||||
* @return 画面用(presentation 層)の UpdateDepartmentForm インスタンス
|
||||
*/
|
||||
public static UpdateDepartmentForm convertFrom(AllDepartmentInfo allDepartmentInfo) {
|
||||
return new UpdateDepartmentForm(
|
||||
allDepartmentInfo.getHeadquarters().getIdHeadquarters(),
|
||||
allDepartmentInfo.getHeadquarters().getNmHeadquarters(),
|
||||
allDepartmentInfo.getDepartment().getIdDepartment(),
|
||||
allDepartmentInfo.getDepartment().getNmDepartment(),
|
||||
allDepartmentInfo.getDivision().getIdDivision(),
|
||||
allDepartmentInfo.getDivision().getNmDivision());
|
||||
}
|
||||
/**
|
||||
* business 層の Department クラスから画面用(presentation 層)の UpdateDepartmentForm に
|
||||
* 変換します。
|
||||
*
|
||||
* @param department business 層の Department インスタンス
|
||||
* @return 画面用(presentation 層)の UpdateDepartmentForm インスタンス
|
||||
*/
|
||||
public static UpdateDepartmentForm convertFrom(Department department) {
|
||||
return new UpdateDepartmentForm(department.getIdDepartment(), department.getNmDepartment());
|
||||
}
|
||||
|
||||
/**
|
||||
* UpdateDepartmentFormから DepartmentInfo に変換します。
|
||||
*
|
||||
* @param updateDepartmentForm UpdateDepartmentFormインスタンス
|
||||
* @return DepartmentInfo インスタンス
|
||||
*/
|
||||
public static DepartmentInfo convertTo(UpdateDepartmentForm updateDepartmentForm) {
|
||||
return new DepartmentInfo(
|
||||
updateDepartmentForm.getIdHeadquarters(),
|
||||
updateDepartmentForm.getNmHeadquarters(),
|
||||
updateDepartmentForm.getIdDepartment(),
|
||||
updateDepartmentForm.getNmDepartment(),
|
||||
updateDepartmentForm.getIdDivision(),
|
||||
updateDepartmentForm.getNmDivision()
|
||||
/**
|
||||
* business 層の Department クラスから画面用(presentation 層)の UpdateDepartmentForm に
|
||||
* 変換します。(リスト版)
|
||||
*
|
||||
* @param departmentList business 層の Department インスタンスのリスト
|
||||
* @return 画面用(presentation 層)の UpdateDepartmentForm インスタンスのリスト
|
||||
*/
|
||||
public static List<UpdateDepartmentForm> convertFrom(List<Department> departmentList) {
|
||||
return departmentList.stream().map(UpdateDepartmentForm::convertFrom).toList();
|
||||
}
|
||||
|
||||
);
|
||||
}
|
||||
/**
|
||||
* presentation 層の UpdateDepartmentForm クラスから Business 層の Department クラスに
|
||||
* 変換します。
|
||||
*
|
||||
* @param updateDepartmentForm presentation 層のインスタンス
|
||||
* @return Business 層の Department インスタンス
|
||||
*/
|
||||
public static Department convertTo(UpdateDepartmentForm updateDepartmentForm) {
|
||||
return new Department(
|
||||
updateDepartmentForm.getIdDepartment(),
|
||||
updateDepartmentForm.getNmDepartment()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
package com.example.rhizome.app.presentation.form;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.example.rhizome.app.domain.model.AllEmployeeInfo;
|
||||
import com.example.rhizome.app.domain.model.Employee;
|
||||
|
||||
import com.example.rhizome.app.domain.model.EmployeeInfo;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 画面から渡ってきた更新内容をまとめ、再度画面に表示する為のクラス
|
||||
*/
|
||||
@@ -17,184 +16,177 @@ import lombok.NoArgsConstructor;
|
||||
@NoArgsConstructor
|
||||
public class UpdateEmployeeInfoForm {
|
||||
|
||||
/**
|
||||
* 社員ID
|
||||
*/
|
||||
private Integer idEmployee;
|
||||
/**
|
||||
* 社員名
|
||||
*/
|
||||
private String nmEmployee;
|
||||
/**
|
||||
* 社員名カナ
|
||||
*/
|
||||
private String knEmployee;
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
private String mailAddress;
|
||||
/**
|
||||
* パスワード
|
||||
*/
|
||||
private String password;
|
||||
/**
|
||||
* パスワード確認用
|
||||
*/
|
||||
private String passwordConfirm;
|
||||
/**
|
||||
* 入社年月日
|
||||
*/
|
||||
private String hireDate;
|
||||
/**
|
||||
* 管理者権限
|
||||
*/
|
||||
private Integer adminAuth;
|
||||
/**
|
||||
* 部ID
|
||||
*/
|
||||
private Integer idDivision;
|
||||
/**
|
||||
* 本部ID
|
||||
*/
|
||||
private Integer idHeadquarters;
|
||||
/**
|
||||
* 社員ID
|
||||
*/
|
||||
private Integer idEmployee;
|
||||
/**
|
||||
* 社員名
|
||||
*/
|
||||
private String nmEmployee;
|
||||
/**
|
||||
* 社員名カナ
|
||||
*/
|
||||
private String knEmployee;
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
private String mailAddress;
|
||||
/**
|
||||
* パスワード
|
||||
*/
|
||||
private String password;
|
||||
/**
|
||||
* パスワード確認用
|
||||
*/
|
||||
private String passwordConfirm;
|
||||
/**
|
||||
* 管理者権限
|
||||
*/
|
||||
private Integer adminAuth;
|
||||
/**
|
||||
* 部署ID
|
||||
*/
|
||||
private Integer idDepartment;
|
||||
|
||||
/**
|
||||
* AllEmployeeInfo クラスからUpdateEmployeeInfoForm に変換します。
|
||||
*
|
||||
* @param allemployeeInfo AllEmployeeInfo インスタンス
|
||||
* @return 画面用(presentation 層)の UpdateEmployeeInfoForm インスタンス
|
||||
*/
|
||||
public static UpdateEmployeeInfoForm convertFrom(AllEmployeeInfo allemployeeInfo) {
|
||||
return new UpdateEmployeeInfoForm(
|
||||
allemployeeInfo.getEmployee().getIdEmployee(),
|
||||
allemployeeInfo.getEmployee().getNmEmployee(),
|
||||
allemployeeInfo.getEmployee().getKnEmployee(),
|
||||
allemployeeInfo.getEmployee().getMailAddress(),
|
||||
allemployeeInfo.getEmployee().getPassword(),
|
||||
null,
|
||||
allemployeeInfo.getEmployee().getHireDate(),
|
||||
allemployeeInfo.getEmployee().getAdminAuth(),
|
||||
allemployeeInfo.getDivision().getIdDivision(),
|
||||
allemployeeInfo.getHeadquarters().getIdHeadquarters());
|
||||
/**
|
||||
* business 層の EmployeeInfo クラスから画面用(presentation 層)の UpdateEmployeeInfoForm に
|
||||
* 変換します。
|
||||
*
|
||||
* @param employeeInfo business 層の EmployeeInfo インスタンス
|
||||
* @return 画面用(presentation 層)の UpdateEmployeeInfoForm インスタンス
|
||||
*/
|
||||
public static UpdateEmployeeInfoForm convertFrom(EmployeeInfo employeeInfo) {
|
||||
return new UpdateEmployeeInfoForm(
|
||||
employeeInfo.getEmployee().getIdEmployee(),
|
||||
employeeInfo.getEmployee().getNmEmployee(),
|
||||
employeeInfo.getEmployee().getKnEmployee(),
|
||||
employeeInfo.getEmployee().getMailAddress(),
|
||||
employeeInfo.getEmployee().getPassword(),
|
||||
null,
|
||||
employeeInfo.getEmployee().getAdminAuth(),
|
||||
employeeInfo.getDepartment().getIdDepartment()
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* business 層の EmployeeInfo クラスから画面用(presentation 層)の UpdateEmployeeInfoForm に
|
||||
* 変換します。(リスト版)
|
||||
*
|
||||
* @param employeeInfoList business 層の EmployeeInfo インスタンスのリスト
|
||||
* @return 画面用(presentation 層)の UpdateEmployeeInfoForm インスタンスのリスト
|
||||
*/
|
||||
public static List<UpdateEmployeeInfoForm> convertFrom(List<EmployeeInfo> employeeInfoList) {
|
||||
return employeeInfoList.stream().map(UpdateEmployeeInfoForm::convertFrom).toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* AllEmployeeInfo クラスから画面用 UpdateEmployeeInfoForm に変換します。(リスト版)
|
||||
*
|
||||
* @param allemployeeInfoList business 層の AllEmployeeInfo インスタンスのリスト
|
||||
* @return 画面用(presentation 層)の UpdateEmployeeInfoForm インスタンスのリスト
|
||||
*/
|
||||
public static List<UpdateEmployeeInfoForm> convertFrom(List<AllEmployeeInfo> allemployeeInfoList) {
|
||||
return allemployeeInfoList.stream().map(UpdateEmployeeInfoForm::convertFrom).toList();
|
||||
}
|
||||
/**
|
||||
* 画面用(presentation 層)の UpdateEmployeeInfoForm クラスから business 層の Employee クラスに
|
||||
* 変換します。
|
||||
*
|
||||
* @param updateEmployeeInfoForm 画面用(presentation 層)の UpdateEmployeeInfoForm インスタンス
|
||||
* @return business 層の Employee インスタンス
|
||||
*/
|
||||
public static Employee convertTo(UpdateEmployeeInfoForm updateEmployeeInfoForm) {
|
||||
return new Employee(
|
||||
updateEmployeeInfoForm.getIdEmployee(),
|
||||
updateEmployeeInfoForm.getNmEmployee(),
|
||||
updateEmployeeInfoForm.getKnEmployee(),
|
||||
updateEmployeeInfoForm.getMailAddress(),
|
||||
updateEmployeeInfoForm.getPassword(),
|
||||
updateEmployeeInfoForm.getAdminAuth(),
|
||||
updateEmployeeInfoForm.getIdDepartment()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 画面用(presentation 層)の UpdateEmployeeInfoForm クラスから business 層の Employee クラスに
|
||||
* 変換します。
|
||||
*
|
||||
* @param updateEmployeeInfoForm 画面用(presentation 層)の UpdateEmployeeInfoForm インスタンス
|
||||
* @return business 層の Employee インスタンス
|
||||
*/
|
||||
public static Employee convertTo(UpdateEmployeeInfoForm updateEmployeeInfoForm) {
|
||||
return new Employee(
|
||||
updateEmployeeInfoForm.getIdEmployee(),
|
||||
updateEmployeeInfoForm.getNmEmployee(),
|
||||
updateEmployeeInfoForm.getKnEmployee(),
|
||||
updateEmployeeInfoForm.getMailAddress(),
|
||||
updateEmployeeInfoForm.getPassword(),
|
||||
updateEmployeeInfoForm.getHireDate(),
|
||||
updateEmployeeInfoForm.getAdminAuth(),
|
||||
updateEmployeeInfoForm.getIdDivision());
|
||||
}
|
||||
/**
|
||||
* 画面から渡ってきたパラメータのチェック
|
||||
*
|
||||
* @param updateEmployeeInfoForm 画面から渡ってきたパラメータ
|
||||
* @return true: エラー無し false:エラーあり(必須を満たしていない)
|
||||
*/
|
||||
public static boolean hasErrorParameter(UpdateEmployeeInfoForm updateEmployeeInfoForm) {
|
||||
|
||||
/**
|
||||
* 画面から渡ってきたパラメータのチェック
|
||||
*
|
||||
* @param updateEmployeeInfoForm 画面から渡ってきたパラメータ
|
||||
* @return true: エラー無し false:エラーあり(必須を満たしていない)
|
||||
*/
|
||||
public static boolean hasErrorParameter(UpdateEmployeeInfoForm updateEmployeeInfoForm) {
|
||||
boolean errorFlag = !isNullOrBlank(updateEmployeeInfoForm.getNmEmployee());
|
||||
|
||||
boolean errorFlag = !isNullOrBlank(updateEmployeeInfoForm.getNmEmployee());
|
||||
if (!isNullOrBlank(updateEmployeeInfoForm.getKnEmployee())) {
|
||||
errorFlag = true;
|
||||
}
|
||||
if (!isNullOrBlank(updateEmployeeInfoForm.getMailAddress())) {
|
||||
errorFlag = true;
|
||||
}
|
||||
if (!isNullOrBlank(updateEmployeeInfoForm.getPassword())) {
|
||||
errorFlag = true;
|
||||
}
|
||||
|
||||
if (!isNullOrBlank(updateEmployeeInfoForm.getKnEmployee())) {
|
||||
errorFlag = true;
|
||||
}
|
||||
if (!isNullOrBlank(updateEmployeeInfoForm.getMailAddress())) {
|
||||
errorFlag = true;
|
||||
}
|
||||
if (!isNullOrBlank(updateEmployeeInfoForm.getPassword())) {
|
||||
errorFlag = true;
|
||||
}
|
||||
|
||||
return errorFlag;
|
||||
}
|
||||
return errorFlag;
|
||||
}
|
||||
|
||||
/**
|
||||
* パスワードの仕様チェック
|
||||
* パスワードが仕様を満たしてないか確認
|
||||
*
|
||||
* @param password 更新対象のパスワード
|
||||
* @param passwordConfirm 更新対象の確認用パスワード
|
||||
* @return 空文字: エラー無し それ以外:エラー内容
|
||||
*/
|
||||
public static String validatePassword(String password, String passwordConfirm) {
|
||||
/**
|
||||
* パスワードの仕様チェック
|
||||
* パスワードが仕様を満たしてないか確認
|
||||
*
|
||||
* @param password 更新対象のパスワード
|
||||
* @param passwordConfirm 更新対象の確認用パスワード
|
||||
* @return 空文字: エラー無し それ以外:エラー内容
|
||||
*/
|
||||
public static String validatePassword(String password, String passwordConfirm) {
|
||||
|
||||
final String ERROR = "パスワードが一致していません";
|
||||
final String ERROR = "パスワードが一致していません";
|
||||
|
||||
if (areBothBlank(password, passwordConfirm)) {
|
||||
// どちらもnullまたは空白の場合はOK
|
||||
return "";
|
||||
}
|
||||
if (areBothBlank(password, passwordConfirm)) {
|
||||
// どちらもnullまたは空白の場合はOK
|
||||
return "";
|
||||
}
|
||||
|
||||
// どちらかがnullまたは空白の場合のエラーハンドリング
|
||||
if (isEitherBlank(password, passwordConfirm)) {
|
||||
return ERROR;
|
||||
}
|
||||
// どちらかがnullまたは空白の場合のエラーハンドリング
|
||||
if (isEitherBlank(password, passwordConfirm)) {
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
// 値が異なった場合はエラーハンドリング
|
||||
if (!password.equals(passwordConfirm)) {
|
||||
return ERROR;
|
||||
}
|
||||
return "";
|
||||
// 値が異なった場合はエラーハンドリング
|
||||
if (!password.equals(passwordConfirm)) {
|
||||
return ERROR;
|
||||
}
|
||||
return "";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 仮引数を null or 空 判定する
|
||||
*
|
||||
* @param str 判定対象の文字列
|
||||
* @return true:null or 空 false:null or 空 では無い
|
||||
*/
|
||||
private static boolean isNullOrBlank(String str) {
|
||||
if (null == str) {
|
||||
return true;
|
||||
}
|
||||
return str.isBlank();
|
||||
}
|
||||
/**
|
||||
* 仮引数を null or 空 判定する
|
||||
*
|
||||
* @param str 判定対象の文字列
|
||||
* @return true:null or 空 false:null or 空 では無い
|
||||
*/
|
||||
private static boolean isNullOrBlank(String str) {
|
||||
if (null == str) {
|
||||
return true;
|
||||
}
|
||||
return str.isBlank();
|
||||
}
|
||||
|
||||
/**
|
||||
* パスワードが今回更新対象に含まれているかチェック
|
||||
*
|
||||
* @param password 更新対象のパスワード
|
||||
* @param passwordConfirm 更新対象の確認用パスワード
|
||||
* @return true:どちらもnullまたは空白の場合 false:それ以外
|
||||
*/
|
||||
private static boolean areBothBlank(String password, String passwordConfirm) {
|
||||
return (password == null || password.isBlank()) && (passwordConfirm == null || passwordConfirm.isBlank());
|
||||
}
|
||||
/**
|
||||
* パスワードが今回更新対象に含まれているかチェック
|
||||
*
|
||||
* @param password 更新対象のパスワード
|
||||
* @param passwordConfirm 更新対象の確認用パスワード
|
||||
* @return true:どちらもnullまたは空白の場合 false:それ以外
|
||||
*/
|
||||
private static boolean areBothBlank(String password, String passwordConfirm) {
|
||||
return (password == null || password.isBlank()) && (passwordConfirm == null || passwordConfirm.isBlank());
|
||||
}
|
||||
|
||||
/**
|
||||
* パスワードが今回更新対象に含まれているかチェック その2
|
||||
*
|
||||
* @param password 更新対象のパスワード
|
||||
* @param passwordConfirm 更新対象の確認用パスワード
|
||||
* @return true: 問題なし false:どちらかがnullまたは空白の場合
|
||||
*/
|
||||
// どちらかがnullまたは空白の場合のエラーハンドリング
|
||||
private static boolean isEitherBlank(String password, String passwordConfirm) {
|
||||
return password == null || password.isBlank() || passwordConfirm == null || passwordConfirm.isBlank();
|
||||
}
|
||||
/**
|
||||
* パスワードが今回更新対象に含まれているかチェック その2
|
||||
*
|
||||
* @param password 更新対象のパスワード
|
||||
* @param passwordConfirm 更新対象の確認用パスワード
|
||||
* @return true: 問題なし false:どちらかがnullまたは空白の場合
|
||||
*/
|
||||
// どちらかがnullまたは空白の場合のエラーハンドリング
|
||||
private static boolean isEitherBlank(String password, String passwordConfirm) {
|
||||
return password == null || password.isBlank() || passwordConfirm == null || passwordConfirm.isBlank();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.example.rhizome.app.presentation.form;
|
||||
|
||||
import com.example.rhizome.app.domain.model.Employee;
|
||||
import com.example.rhizome.app.domain.model.LoginUser;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -14,177 +13,173 @@ import lombok.NoArgsConstructor;
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class UpdatePersonalUserForm {
|
||||
/**
|
||||
* 社員ID
|
||||
*/
|
||||
private Integer idEmployee;
|
||||
/**
|
||||
* 社員名
|
||||
*/
|
||||
private String nmEmployee;
|
||||
/**
|
||||
* 社員名カナ
|
||||
*/
|
||||
private String knEmployee;
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
private String mailAddress;
|
||||
/**
|
||||
* パスワード
|
||||
*/
|
||||
private String password;
|
||||
/**
|
||||
* パスワード確認用
|
||||
*/
|
||||
private String passwordConfirm;
|
||||
/**
|
||||
* 入社年月日
|
||||
*/
|
||||
private String hireDate;
|
||||
/**
|
||||
* 社員ID
|
||||
*/
|
||||
private Integer idEmployee;
|
||||
/**
|
||||
* 社員名
|
||||
*/
|
||||
private String nmEmployee;
|
||||
/**
|
||||
* 社員名カナ
|
||||
*/
|
||||
private String knEmployee;
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
private String mailAddress;
|
||||
/**
|
||||
* パスワード
|
||||
*/
|
||||
private String password;
|
||||
/**
|
||||
* パスワード確認用
|
||||
*/
|
||||
private String passwordConfirm;
|
||||
|
||||
/**
|
||||
* 画面用(presentation 層)の UpdatePersonalUserForm クラスから business 層の Employee クラスに
|
||||
* 変換します。
|
||||
*
|
||||
* @param updatePersonalUserForm 画面用(presentation 層)の UpdatePersonalUserForm インスタンス
|
||||
* @return business 層の Employee インスタンス
|
||||
*/
|
||||
public static Employee convertTo(UpdatePersonalUserForm updatePersonalUserForm) {
|
||||
return new Employee(
|
||||
updatePersonalUserForm.getIdEmployee(),
|
||||
updatePersonalUserForm.getNmEmployee(),
|
||||
updatePersonalUserForm.getKnEmployee(),
|
||||
updatePersonalUserForm.getMailAddress(),
|
||||
updatePersonalUserForm.getPassword(),
|
||||
updatePersonalUserForm.getHireDate(),
|
||||
null,
|
||||
null);
|
||||
}
|
||||
|
||||
/**
|
||||
* business 層の Employee クラスから画面用(presentation 層)の UpdatePersonalUserForm に
|
||||
* 変換します。(リスト版)
|
||||
*
|
||||
* @param employee business 層の employee インスタンスのリスト
|
||||
* @return クラスから画面用(presentation 層)の UpdatePersonalUserForm インスタンスのリスト
|
||||
*/
|
||||
public static UpdatePersonalUserForm convertFrom(Employee employee) {
|
||||
return new UpdatePersonalUserForm(
|
||||
employee.getIdEmployee(),
|
||||
employee.getNmEmployee(),
|
||||
employee.getKnEmployee(),
|
||||
employee.getMailAddress(),
|
||||
employee.getPassword(),
|
||||
null,
|
||||
employee.getHireDate()
|
||||
/**
|
||||
* 画面用(presentation 層)の UpdatePersonalUserForm クラスから business 層の Employee クラスに
|
||||
* 変換します。
|
||||
*
|
||||
* @param updatePersonalUserForm 画面用(presentation 層)の UpdatePersonalUserForm インスタンス
|
||||
* @return business 層の Employee インスタンス
|
||||
*/
|
||||
public static Employee convertTo(UpdatePersonalUserForm updatePersonalUserForm) {
|
||||
return new Employee(
|
||||
updatePersonalUserForm.getIdEmployee(),
|
||||
updatePersonalUserForm.getNmEmployee(),
|
||||
updatePersonalUserForm.getKnEmployee(),
|
||||
updatePersonalUserForm.getMailAddress(),
|
||||
updatePersonalUserForm.getPassword(),
|
||||
null,
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
);
|
||||
}
|
||||
/**
|
||||
* business 層の Employee クラスから画面用(presentation 層)の UpdatePersonalUserForm に
|
||||
* 変換します。(リスト版)
|
||||
*
|
||||
* @param employee business 層の employee インスタンスのリスト
|
||||
* @return クラスから画面用(presentation 層)の UpdatePersonalUserForm インスタンスのリスト
|
||||
*/
|
||||
public static UpdatePersonalUserForm convertFrom(Employee employee) {
|
||||
return new UpdatePersonalUserForm(
|
||||
employee.getIdEmployee(),
|
||||
employee.getNmEmployee(),
|
||||
employee.getKnEmployee(),
|
||||
employee.getMailAddress(),
|
||||
employee.getPassword(),
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* business 層の Employee クラスから画面用(presentation 層)の UpdatePersonalUserForm に
|
||||
* 変換します。(リスト版)
|
||||
*
|
||||
* @param loginUser business 層の loginUser インスタンスのリスト
|
||||
* @return クラスから画面用(presentation 層)の UpdatePersonalUserForm インスタンスのリスト
|
||||
*/
|
||||
public static UpdatePersonalUserForm convertFrom(LoginUser loginUser) {
|
||||
return new UpdatePersonalUserForm(
|
||||
loginUser.getIdEmployee(),
|
||||
loginUser.getNmEmployee(),
|
||||
loginUser.getKnEmployee(),
|
||||
loginUser.getMailAddress(),
|
||||
loginUser.getPassword(),
|
||||
null,
|
||||
null);
|
||||
}
|
||||
/**
|
||||
* business 層の Employee クラスから画面用(presentation 層)の UpdatePersonalUserForm に
|
||||
* 変換します。(リスト版)
|
||||
*
|
||||
* @param loginUser business 層の loginUser インスタンスのリスト
|
||||
* @return クラスから画面用(presentation 層)の UpdatePersonalUserForm インスタンスのリスト
|
||||
*/
|
||||
public static UpdatePersonalUserForm convertFrom(LoginUser loginUser) {
|
||||
return new UpdatePersonalUserForm(
|
||||
loginUser.getIdEmployee(),
|
||||
loginUser.getNmEmployee(),
|
||||
loginUser.getKnEmployee(),
|
||||
loginUser.getMailAddress(),
|
||||
loginUser.getPassword(),
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 画面から渡ってきたパラメータのチェック
|
||||
*
|
||||
* @param updatePersonalUserForm 画面から渡ってきたパラメータ
|
||||
* @return true: エラー無し false:エラーあり(必須を満たしていない)
|
||||
*/
|
||||
public static boolean hasErrorParameter(UpdatePersonalUserForm updatePersonalUserForm) {
|
||||
/**
|
||||
* 画面から渡ってきたパラメータのチェック
|
||||
*
|
||||
* @param updatePersonalUserForm 画面から渡ってきたパラメータ
|
||||
* @return true: エラー無し false:エラーあり(必須を満たしていない)
|
||||
*/
|
||||
public static boolean hasErrorParameter(UpdatePersonalUserForm updatePersonalUserForm) {
|
||||
|
||||
boolean errorFlag = !isNullOrBlank(updatePersonalUserForm.getNmEmployee());
|
||||
boolean errorFlag = !isNullOrBlank(updatePersonalUserForm.getNmEmployee());
|
||||
|
||||
if (!isNullOrBlank(updatePersonalUserForm.getKnEmployee())) {
|
||||
errorFlag = true;
|
||||
}
|
||||
if (!isNullOrBlank(updatePersonalUserForm.getMailAddress())) {
|
||||
errorFlag = true;
|
||||
}
|
||||
if (!isNullOrBlank(updatePersonalUserForm.getPassword())) {
|
||||
errorFlag = true;
|
||||
}
|
||||
if (!isNullOrBlank(updatePersonalUserForm.getKnEmployee())) {
|
||||
errorFlag = true;
|
||||
}
|
||||
if (!isNullOrBlank(updatePersonalUserForm.getMailAddress())) {
|
||||
errorFlag = true;
|
||||
}
|
||||
if (!isNullOrBlank(updatePersonalUserForm.getPassword())) {
|
||||
errorFlag = true;
|
||||
}
|
||||
|
||||
return errorFlag;
|
||||
}
|
||||
|
||||
/**
|
||||
* パスワードの仕様チェック
|
||||
* パスワードが仕様を満たしてないか確認
|
||||
*
|
||||
* @param password 更新対象のパスワード
|
||||
* @param passwordConfirm 更新対象の確認用パスワード
|
||||
* @return 空文字: エラー無し それ以外:エラー内容
|
||||
*/
|
||||
public static String validatePassword(String password, String passwordConfirm) {
|
||||
return errorFlag;
|
||||
}
|
||||
|
||||
final String ERROR = "パスワードが一致していません";
|
||||
/**
|
||||
* パスワードの仕様チェック
|
||||
* パスワードが仕様を満たしてないか確認
|
||||
*
|
||||
* @param password 更新対象のパスワード
|
||||
* @param passwordConfirm 更新対象の確認用パスワード
|
||||
* @return 空文字: エラー無し それ以外:エラー内容
|
||||
*/
|
||||
public static String validatePassword(String password, String passwordConfirm) {
|
||||
|
||||
if (areBothBlank(password, passwordConfirm)) {
|
||||
// どちらもnullまたは空白の場合はOK
|
||||
return "";
|
||||
}
|
||||
final String ERROR = "パスワードが一致していません";
|
||||
|
||||
// どちらかがnullまたは空白の場合のエラーハンドリング
|
||||
if (isEitherBlank(password, passwordConfirm)) {
|
||||
return ERROR;
|
||||
}
|
||||
if (areBothBlank(password, passwordConfirm)) {
|
||||
// どちらもnullまたは空白の場合はOK
|
||||
return "";
|
||||
}
|
||||
|
||||
// 値が異なった場合はエラーハンドリング
|
||||
if (!password.equals(passwordConfirm)) {
|
||||
return ERROR;
|
||||
}
|
||||
return "";
|
||||
// どちらかがnullまたは空白の場合のエラーハンドリング
|
||||
if (isEitherBlank(password, passwordConfirm)) {
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
}
|
||||
// 値が異なった場合はエラーハンドリング
|
||||
if (!password.equals(passwordConfirm)) {
|
||||
return ERROR;
|
||||
}
|
||||
return "";
|
||||
|
||||
/**
|
||||
* 仮引数を null or 空 判定する
|
||||
*
|
||||
* @param str 判定対象の文字列
|
||||
* @return true:null or 空 false:null or 空 では無い
|
||||
*/
|
||||
private static boolean isNullOrBlank(String str) {
|
||||
if (null == str) {
|
||||
return true;
|
||||
}
|
||||
return str.isBlank();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* パスワードが今回更新対象に含まれているかチェック
|
||||
*
|
||||
* @param password 更新対象のパスワード
|
||||
* @param passwordConfirm 更新対象の確認用パスワード
|
||||
* @return true:どちらもnullまたは空白の場合 false:それ以外
|
||||
*/
|
||||
private static boolean areBothBlank(String password, String passwordConfirm) {
|
||||
return (password == null || password.isBlank()) && (passwordConfirm == null || passwordConfirm.isBlank());
|
||||
}
|
||||
/**
|
||||
* 仮引数を null or 空 判定する
|
||||
*
|
||||
* @param str 判定対象の文字列
|
||||
* @return true:null or 空 false:null or 空 では無い
|
||||
*/
|
||||
private static boolean isNullOrBlank(String str) {
|
||||
if (null == str) {
|
||||
return true;
|
||||
}
|
||||
return str.isBlank();
|
||||
}
|
||||
|
||||
/**
|
||||
* パスワードが今回更新対象に含まれているかチェック その2
|
||||
*
|
||||
* @param password 更新対象のパスワード
|
||||
* @param passwordConfirm 更新対象の確認用パスワード
|
||||
* @return true: 問題なし false:どちらかがnullまたは空白の場合
|
||||
*/
|
||||
private static boolean isEitherBlank(String password, String passwordConfirm) {
|
||||
return password == null || password.isBlank() || passwordConfirm == null || passwordConfirm.isBlank();
|
||||
}
|
||||
/**
|
||||
* パスワードが今回更新対象に含まれているかチェック
|
||||
*
|
||||
* @param password 更新対象のパスワード
|
||||
* @param passwordConfirm 更新対象の確認用パスワード
|
||||
* @return true:どちらもnullまたは空白の場合 false:それ以外
|
||||
*/
|
||||
private static boolean areBothBlank(String password, String passwordConfirm) {
|
||||
return (password == null || password.isBlank()) && (passwordConfirm == null || passwordConfirm.isBlank());
|
||||
}
|
||||
|
||||
/**
|
||||
* パスワードが今回更新対象に含まれているかチェック その2
|
||||
*
|
||||
* @param password 更新対象のパスワード
|
||||
* @param passwordConfirm 更新対象の確認用パスワード
|
||||
* @return true: 問題なし false:どちらかがnullまたは空白の場合
|
||||
*/
|
||||
private static boolean isEitherBlank(String password, String passwordConfirm) {
|
||||
return password == null || password.isBlank() || passwordConfirm == null || passwordConfirm.isBlank();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
</div>
|
||||
<table>
|
||||
<tr>
|
||||
<th class="header"> 本部ID</th>
|
||||
<th class="header">部署ID</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
@@ -39,67 +39,19 @@
|
||||
value="自動で設定されます"/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">本部名</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
name="nmHeadquarters"
|
||||
readonly="readonly"
|
||||
th:value="*{nmHeadquarters}"
|
||||
type="text"/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<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 class="readOnly"
|
||||
name="nmDepartment"
|
||||
readonly="readonly"
|
||||
th:value="*{nmDepartment}"
|
||||
type="text"/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<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 class="readOnly"
|
||||
name="nmDivision"
|
||||
readonly="readonly"
|
||||
th:value="*{nmDivision}"
|
||||
type="text"/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
</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="登録"/>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user