社員情報登録時のプルダウンの分割化の相談の参照用の一時プッシュ 追加分

This commit is contained in:
o-yamamoto
2026-09-28 14:14:12 +09:00
parent cd753bfe2c
commit 995fe03b73
40 changed files with 2567 additions and 89 deletions

View File

@@ -0,0 +1,20 @@
<!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>

View File

@@ -0,0 +1,86 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<!-- 外部のスクリプトファイルを読み込む -->
<script th:src="@{/js/common.js}"></script>
<!-- CSSの読み込み -->
<link rel="stylesheet" th:href="@{/css/all.css}">
<link rel=stylesheet th:href="@{/css/style.css}" type="text/css">
<title>登録内容確認</title>
</head>
<body>
<h1>登録内容確認   
<div class="rightSection">
<span class="loginInfo">ログイン者名:<span th:text="${session.loginUser.nmEmployee}"></span></span>
<button class="logoutButton" onclick="logoutSubmit()">ログアウト</button>
</div>
</h1>
<form action="insertDepartment"
id="insertForm"
method="post"
th:object="${insertDepartmentForm}">
<div class="msgBox error" th:if="${messageError != null}">
<span class="error" th:each="message : ${messageError.message}" th:text="${message}"></span>
</div>
<table>
<tr>
<th class="header">部署ID</th>
<td>
<label>
<input class="readOnly"
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>

View File

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

View File

@@ -0,0 +1,40 @@
<!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>

View File

@@ -0,0 +1,157 @@
<!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>

View File

@@ -0,0 +1,158 @@
<!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>

View File

@@ -0,0 +1,40 @@
<!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>

View File

@@ -0,0 +1,63 @@
<!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>

View File

@@ -0,0 +1,124 @@
<!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>

View File

@@ -0,0 +1,114 @@
<!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>

View File

@@ -0,0 +1,157 @@
<!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>

View File

@@ -0,0 +1,88 @@
<!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>

View File

@@ -0,0 +1,181 @@
<!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>

View File

@@ -0,0 +1,108 @@
<!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>

View File

@@ -0,0 +1,42 @@
<!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>

View File

@@ -0,0 +1,21 @@
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;
}

View File

@@ -0,0 +1,25 @@
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;
}

View File

@@ -0,0 +1,36 @@
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;
}

View File

@@ -0,0 +1,28 @@
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;
}

View File

@@ -0,0 +1,24 @@
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;
}

View File

@@ -19,6 +19,11 @@ public interface SearchDepartment {
SearchConditionDepartment searchDepartmentTable,
SearchConditionDepartment searchDivisionTable);
boolean searchAllDepartmentTable(
Integer idHeadquarters,
Integer idDepartment,
Integer idDivision);
List<Headquarters> searchByHeadquarters(SearchConditionDepartment searchConditionDepartment);
List<Department> searchByDepartment(SearchConditionDepartment searchConditionDepartment);

View File

@@ -0,0 +1,8 @@
package com.example.rhizome.app.domain.service;
import org.springframework.stereotype.Service;
@Service
public interface TenureCalc {
String tenureCalc(String hireDate);
}

View File

@@ -88,6 +88,21 @@ public class SearchDepartmentImpl implements SearchDepartment {
return true;
}
}
public boolean searchAllDepartmentTable(
Integer idHeadquarters,
Integer idDepartment,
Integer idDivision){
if(departmentInfoRepository.searchAllDepartmentTable(
idHeadquarters,
idDepartment,
idDivision).isEmpty()) {
return false;
}else{
return true;
}
}
/**
* searchConditionDepartment の情報を元に Department のレコードを取得
*

View File

@@ -0,0 +1,26 @@
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 {
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;
}
}
}

View File

@@ -0,0 +1,168 @@
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;
@Data
@AllArgsConstructor
@NoArgsConstructor
@NamedEntityGraph(
name = "division_with_department_with_headquarters",
includeAllAttributes = true
)
public class DepartmentInfoEntity {
private DivisionEntity division;
private DepartmentEntity department;
private HeadquartersEntity headquarters;
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
)
);
}
/**
* EmployeeDepartmentEntity(DataAccess層依存) を EmployeeInfo(BusinessLogic層依存) に変換します。
*
* @param employeeDepartmentEntity  EmployeeDepartmentEntity のインスタンス
* @return EmployeeInfo のインスタンス
*/
public static AllDepartmentInfo createDepartmentInfo(DepartmentInfoEntity departmentInfoEntity) {
// コンストラクタを使って書くとSetterを使用するより簡略化出来ます。
// 混乱してしまう人は落ち着いて EmployeeInfo のフィールドを見に行って、
// どうしてこの書き方が出来るのかを理解できる様になりましょう。
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()
)
);
}
/**
* EmployeeDepartmentEntity(DataAccess層依存) を EmployeeInfo(BusinessLogic層依存) に変換します。
* (リスト版)
*
* @param employeeDepartmentEntityList EmployeeDepartmentEntity インスタンスのリスト
* @return EmployeeInfo インスタンスのリスト
*/
public static List<AllDepartmentInfo> createDepartmentInfoList(List<DepartmentInfoEntity> departmentInfoEntity) {
// StreamAPI を使うとこうなります。
return departmentInfoEntity.stream().map(DepartmentInfoEntity::createDepartmentInfo).toList();
}
public static AllDepartmentInfo createDepartmentInfo(DivisionEntity divisionEntity) {
// コンストラクタを使って書くとSetterを使用するより簡略化出来ます。
// 混乱してしまう人は落ち着いて EmployeeInfo のフィールドを見に行って、
// どうしてこの書き方が出来るのかを理解できる様になりましょう。
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()
)
);
}
public static List<AllDepartmentInfo> AfterSearchCreateDepartmentInfoList(List<DivisionEntity> divisionEntity) {
// StreamAPI を使うとこうなります。
return divisionEntity.stream().map(DepartmentInfoEntity::createDepartmentInfo).toList();
}
}

View File

@@ -0,0 +1,102 @@
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;
@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;
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
)
)
);
}
public static Division createDivision(DivisionEntity divisionEntity) {
// 値を既に持ったインスタンスの生成に、コンストラクタを使用するとこうなります。
return new Division(
divisionEntity.getIdDivision(),
divisionEntity.getNmDivision(),
divisionEntity.getIsDisplay(),
divisionEntity.getDepartment().getIdDepartment()
);
}
public static List<Division> createDivisionList(List<DivisionEntity> divisionEntityList) {
return divisionEntityList
.stream()
.map(DivisionEntity ::createDivision ).toList();
}
}

View File

@@ -0,0 +1,70 @@
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;
@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()
);
}
public static List<Headquarters> createHeadquartersList(List<HeadquartersEntity> headquartersEntityList) {
return headquartersEntityList
.stream()
.map(HeadquartersEntity ::createHeadquarters ).toList();
}
public static HeadquartersEntity convertFrom(DepartmentInfo departmentInfo) {
return new HeadquartersEntity(
departmentInfo.getIdHeadquarters(),
departmentInfo.getNmHeadquarters(),
(Integer)0
);
}
}

View File

@@ -0,0 +1,100 @@
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
*
* @author IT-College
*/
@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 依存)を EmployeeEntity(DataAccess層依存)に変換します。
*
* @param employee Employee Table の中身
* @return EmployeeEntity のインスタンス(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()
);
}
}

View File

@@ -0,0 +1,51 @@
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
*
* @author IT-College
*/
@Entity
@Table(name = "department")
@Data
@NoArgsConstructor
@AllArgsConstructor
//@NamedEntityGraph(
// name = "department_with_headquarters",
// includeAllAttributes = true
//)
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;
}

View File

@@ -0,0 +1,86 @@
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);
}

View File

@@ -0,0 +1,39 @@
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.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);
}
}

View File

@@ -0,0 +1,31 @@
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);
}

View File

@@ -0,0 +1,23 @@
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) {
System.out.println("RegisterDepartmentRepository=>5");
return idHeadquarters == null ?
null :
//戻り値の型 Specification<DepartmentEntity> にキャスト
(Specification<RegisterDepartmentEntity>)
(root, criteriaQuery, criteriaBuilder) -> criteriaBuilder.equal(root.get("idHeadquarters"), idHeadquarters);
}
}

View File

@@ -111,6 +111,17 @@ public class InsertEmployeeConfirmController {
return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML;
}
final String DEPARTMENT_VALID ="部署情報の組み合わせが違います。";
if(!searchDepartment.searchAllDepartmentTable(
insertEmployeeForm.getIdHeadquarters()
,insertEmployeeForm.getIdDepartment()
,insertEmployeeForm.getIdDivision())) {
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DEPARTMENT_VALID));
model.addAttribute(PageReturnAttributeKeyword.INSERT_EMPLOYEE_FORM, insertEmployeeForm);
return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML;
}
// 登録確認ページに遷移
model.addAttribute(PageReturnAttributeKeyword.INSERT_EMPLOYEE_FORM, insertEmployeeForm);
// 登録確認画面に遷移

View File

@@ -96,6 +96,16 @@ public class InsertEmployeeController {
return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML;
}
final String DEPARTMENT_VALID ="部署情報の組み合わせが違います。";
if(!searchDepartment.searchAllDepartmentTable(
insertEmployeeForm.getIdHeadquarters()
,insertEmployeeForm.getIdDepartment()
,insertEmployeeForm.getIdDivision())) {
model.addAttribute(PageReturnAttributeKeyword.MESSAGE_ERROR, new MessageForm(DEPARTMENT_VALID));
model.addAttribute(PageReturnAttributeKeyword.INSERT_EMPLOYEE_FORM, insertEmployeeForm);
return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML;
}
// 登録処理
registerEmployee.registerEmployee(InsertEmployeeForm.convertTo(insertEmployeeForm));
// 登録結果画面に遷移

View File

@@ -2,7 +2,6 @@ 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;
@@ -11,12 +10,9 @@ 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;
@@ -24,9 +20,7 @@ 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;
/**
@@ -73,7 +67,7 @@ public class InsertEmployeeInputController {
try {
// 部署コードリストを作成し、画面に返す値としてセット
model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST
,HeadquartersInfoForm.convertFrom(
,DepartmentForm.convertFrom(
searchDepartment.searchAllDepartmentTable()));
// パラメータをセット
@@ -94,45 +88,75 @@ public class InsertEmployeeInputController {
return TransitionTargetPageNameKeyword.ERROR_HTML;
}
}
//プルダウン絞り込み実装用
// @SessionCheck
// @PermissionCheck
// @RequestMapping(value = INSERT_EMPLOYEE_INPUT, method = RequestMethod.POST)
// public String insertInput(InsertEmployeeForm insertEmployeeForm, Model model) {
//
// try {
// // 部署コードリストを作成し、画面に返す値としてセット
// model.addAttribute(PageReturnAttributeKeyword.DEPARTMENT_FORM_LIST
// ,HeadquartersInfoForm.convertFrom(
// searchDepartment.searchAllDepartmentTable()));
//
// // パラメータをセット
// model.addAttribute(PageReturnAttributeKeyword.INSERT_EMPLOYEE_FORM, insertEmployeeForm);
//
// // 登録画面に遷移
// return TransitionTargetPageNameKeyword.INSERT_EMPLOYEE_INPUT_HTML;
//
// } catch (Exception e) {
// // ログイン情報の破棄
// httpSession.invalidate();
//
// e.printStackTrace();
//
// // エラーログ出力
// LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
// // エラー画面遷移
// return TransitionTargetPageNameKeyword.ERROR_HTML;
// }
// }
@GetMapping("insertEmployeeInput/searchDepartment" )
@ResponseBody
public List<DepartmentInfoForm>departmentsByHeadquarters(
@RequestParam("id_headquarters")Integer idHeadquarters){
System.out.println("koko");
List<DepartmentInfoForm> departmentByHeadquarters=
DepartmentInfoForm.convertFrom(
searchDepartment.searchByIdHeadquarters(idHeadquarters));
System.out.println("2");
return departmentByHeadquarters
.stream()
.map(DepartmentInfoForm-> new DepartmentInfoForm(
DepartmentInfoForm.getIdDepartment(),
DepartmentInfoForm.getNmDepartment()))
.distinct()
.toList();
}
@GetMapping("/insertEmployeeInput/searchDepartment/searchDivision")
@ResponseBody
public List<DivisionInfoForm>divisionBydepartment(
@RequestParam("idDepartment")Integer idDepartment){
List<DivisionInfoForm> divisionBydepartment=
DivisionInfoForm.convertFrom(
searchDepartment.searchByIdDepartment(idDepartment));
return divisionBydepartment
.stream()
.map(DivisionInfoForm-> new DivisionInfoForm(
DivisionInfoForm.getIdDivision(),
DivisionInfoForm.getNmDivision()))
.distinct()
.toList();
}
// @GetMapping("insertEmployeeInput/searchDepartment" )
// @ResponseBody
// public List<DepartmentInfoForm>departmentsByHeadquarters(
// @RequestParam("id_headquarters")Integer idHeadquarters){
// System.out.println("koko");
//
// List<DepartmentInfoForm> departmentByHeadquarters=
// DepartmentInfoForm.convertFrom(
// searchDepartment.searchByIdHeadquarters(idHeadquarters));
// System.out.println("2");
// return departmentByHeadquarters
// .stream()
// .map(DepartmentInfoForm-> new DepartmentInfoForm(
// DepartmentInfoForm.getIdDepartment(),
// DepartmentInfoForm.getNmDepartment()))
// .distinct()
// .toList();
//
//
// }
// @GetMapping("/insertEmployeeInput/searchDepartment/searchDivision")
// @ResponseBody
// public List<DivisionInfoForm>divisionBydepartment(
// @RequestParam("idDepartment")Integer idDepartment){
// List<DivisionInfoForm> divisionBydepartment=
// DivisionInfoForm.convertFrom(
// searchDepartment.searchByIdDepartment(idDepartment));
//
// return divisionBydepartment
// .stream()
// .map(DivisionInfoForm-> new DivisionInfoForm(
// DivisionInfoForm.getIdDivision(),
// DivisionInfoForm.getNmDivision()))
// .distinct()
// .toList();
//
//
// }
}

View File

@@ -0,0 +1,37 @@
package com.example.rhizome.app.presentation.form;
import java.util.List;
import com.example.rhizome.app.domain.model.Department;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class 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();
}
}

View File

@@ -0,0 +1,35 @@
package com.example.rhizome.app.presentation.form;
import java.util.List;
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();
}
}

View File

@@ -0,0 +1,36 @@
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;
public static HeadquartersInfoForm convertFrom(AllDepartmentInfo allDepartmentInfo) {
return new HeadquartersInfoForm(
allDepartmentInfo.getHeadquarters().getIdHeadquarters(),
allDepartmentInfo.getHeadquarters().getNmHeadquarters()
);
}
public static List<HeadquartersInfoForm> convertFrom(List<AllDepartmentInfo>allDepartmentInfoList
) {
return allDepartmentInfoList.stream().map(HeadquartersInfoForm::convertFrom).toList();
}
}

View File

@@ -166,22 +166,44 @@
<tr>
<th class="header" >所属部</th>
<td>
<label>
<select id="departmentSelect" required="required" th:field="*{idDepartment}">
<option value="">先に本部を選択してください</option>
<!-- プルダウン絞り込み実装用-->
<!-- <label>-->
<!-- <select id="departmentSelect" required="required" th:field="*{idDepartment}"> -->
<!-- <option value="">先に本部を選択してください</option>-->
</select>
</label>
<!-- </select>-->
<!-- </label>-->
<label>
<select id="departmentSelect" required="required" th:field="*{idDepartment}">
<option th:each="department : ${departmentFormList}"
th:utext="
${department.nmDepartment}"
th:value="${department.idDepartment}">
</option>
</select>
</label>
</td>
</tr>
<tr>
<th class="header" >所属課</th>
<td>
<label>
<select id="divisionSelect" required="required" th:field="*{idDivision}">
<option value="">先に部を選択してください</option>
</select>
</label>
<label>
<select id="divisionSelect" required="required" th:field="*{idDivision}">
<option th:each="division : ${departmentFormList}"
th:utext="
${division.nmDivision}"
th:value="${division.idDivision}">
</option>
</select>
</label>
<!-- プルダウン絞り込み実装用-->
<!-- <label>-->
<!-- <select id="divisionSelect" required="required" th:field="*{idDivision}">-->
<!-- <option value="">先に部を選択してください</option>-->
<!-- </select>-->
<!-- </label>-->
</td>
</tr>
@@ -194,46 +216,47 @@
</form>
<a href="showMenu">メニューに戻る</a>
</body>
<script>
const headquartersSelect = document.getElementById('headquartersSelect');
const departmentSelect = document.getElementById('departmentSelect');
const divisionSelect = document.getElementById('divisionSelect');
<!--プルダウン絞り込み実装用(途中)-->
<!--<script>-->
<!--const headquartersSelect = document.getElementById('headquartersSelect');-->
<!--const departmentSelect = document.getElementById('departmentSelect');-->
<!--const divisionSelect = document.getElementById('divisionSelect');-->
headquartersSelect.addEventListener('change', function() {
const id_headquarters = this.value;
<!--headquartersSelect.addEventListener('change', function() {-->
<!-- const id_headquarters = this.value; -->
departmentSelect.disabled = true;
divisionSelect.disabled = true;
departmentSelect.innerHTML = '<option value="">-- 部を選択 --</option>';
divisionSelect.innerHTML = '<option value="">-- 先に部を選択してください --</option>';
console.log("koko");
if (!id_headquarters) return;
fetch(`insertEmployeeInput/searchDepartment?id_headquarters=${id_headquarters}`,{
method: 'GET',
headers: {
'Accept': 'application/json'
}
})
<!-- departmentSelect.disabled = true;-->
<!-- divisionSelect.disabled = true;-->
<!-- departmentSelect.innerHTML = '<option value="">-- 部を選択 --</option>';-->
<!-- divisionSelect.innerHTML = '<option value="">-- 先に部を選択してください --</option>';-->
<!-- console.log("koko");-->
<!-- if (!id_headquarters) return;-->
<!-- fetch(`insertEmployeeInput/searchDepartment?id_headquarters=${id_headquarters}`,{ -->
<!-- method: 'GET',-->
<!-- headers: {-->
<!-- 'Accept': 'application/json' -->
<!-- }-->
<!-- })-->
.then(res => {
return res.json();
})
.then(list => {
console.log("koko");
departmentSelect.disabled = false;
list.forEach(form => {
const opt = document.createElement('option');
opt.value = form.idDepartment;
opt.textContent = form.nmDepartment;
departmentSelect.appendChild(opt);
});
})
<!-- .then(res => {-->
<!-- console.log("koko");-->
<!-- return res.json();-->
<!-- })-->
<!-- .then(list => {-->
<!-- departmentSelect.disabled = false; -->
<!-- list.forEach(form => {-->
<!-- const opt = document.createElement('option');-->
<!-- opt.value = form.idDepartment; -->
<!-- opt.textContent = form.nmDepartment; -->
<!-- departmentSelect.appendChild(opt);-->
<!-- });-->
<!-- })-->
});
<!--});-->
</script>
<!--</script>-->
</html>