최초 커밋!

This commit is contained in:
kangsunlee
2025-05-27 16:34:20 +09:00
parent 3b8247ecd9
commit 5a66c0542b
1445 changed files with 65703 additions and 65 deletions

View File

@@ -0,0 +1,266 @@
<!DOCTYPE html>
<html layout:decorate="~{layout/layout}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:th="http://www.thymeleaf.org">
<section layout:fragment="content">
<style type="text/css">
table, td {
border: 1px solid
}
table {
width: 60%;
height: 100px;
text-align: center;
}
</style>
<form autocomplete="off" method="get" name="reqForm" th:action="@{/board/articles}"
th:object="${reqVO}">
<!-- hidden parameters -->
<input name="sort" th:field="*{sort}" type="hidden"/>
<input name="page" th:field="*{page}" type="hidden"/>
<div class="row p-2 mb-2 border-secondary border-top border-bottom border-1">
<div class="col-5">
<label class="col-sm-2 col-form-label" for="searchField">검색필드</label>
<select class="form-select d-inline w-25" id="searchField"
th:field="*{searchField}">
<option selected value="">선택</option>
<option value="title">제목</option>
<option value="updatedBy">작성자</option>
</select> <label>
<input class="form-control d-inline" placeholder="검색어를 입력하세요."
style="width: 250px;" th:field="*{searchValue}"
type="text">
</label>
</div>
<div class="col">
<label class="col-sm-3 col-form-label" for="searchOpen">공개여부</label>
<select class="form-select d-inline w-25" id="searchOpen"
th:field="*{searchOpen}">
<option selected value="">전체</option>
<option value="true">Y</option>
<option value="false">N</option>
</select>
</div>
<div class="col text-end">
<button class="btn btn-outline-secondary" onclick="goSearch();"
type="button">
<!--<i class="bi bi-search"></i>-->
검색
</button>
<button class="btn btn-outline-secondary" onclick="goInit();" type="button">
초기화
</button>
</div>
</div>
<div class="row">
<div class="col text-start">
<div class="fw-bolder text-muted">
TOTAL. <span id="totalElements"></span>
</div>
</div>
<div class="col text-end">
<i class="bi bi-list-ol"></i> <label>
<select
class="form-select form-select-sm" id="pageSize" name="size"
onchange="goSearch()"
th:field="*{size}">
<option
th:each="item : ${pageRows}"
th:text="${item.codeText}" th:value="${item.codeValue}"></option>
</select>
</label>
</div>
</div>
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col" style="width:40px;"><label>
<input class="form-check-input"
onchange="toggleCheckbox(this);" type="checkbox"/></label>
</th>
<th scope="col" style="width:60px;"></th>
<th scope="col">
<a class="order-able" data-sort-field="title"
href="#">제목</a>
</th>
<th scope="col">
<a class="order-able text-center d-inline-block w-100" data-sort-field="visible"
href="#">공개여부</a></th>
<th scope="col">
<a class="order-able" data-sort-field="startDate"
href="#">게시일</a></th>
<th scope="col">
<a class="order-able" data-sort-field="endDate"
href="#">종료일</a></th>
<th scope="col">
<a class="order-able" data-sort-field="updatedBy"
href="#">최근 수정자</a></th>
<th scope="col">
<a class="order-able" data-sort-field="updatedAt"
href="#">최근 수정일</a></th>
<th scope="col">
<a class="order-able" data-sort-field="orderNo"
href="#">정렬번호</a></th>
</tr>
</thead>
<tbody class="sortable" id="listTBody">
</tbody>
</table>
</form>
<div class="row paging"></div>
<!--
<div class="row">
<div class="col text-start">
<button type="button" class="btn btn-outline-secondary" onclick="goExcel();">
<i class="bi bi-file-earmark-spreadsheet"></i> 엑셀 다운로드
</button>
</div>-->
<div class="col text-end">
<button class="btn btn-outline-secondary" onclick="goSave();"
type="button">
<i class="bi bi-save2"></i> 등록
</button>
</div>
</section>
<section layout:fragment="script">
<script>
const INIT_SORT = 'orderNo,DESC';
const getArticles = (pageNo) => {
const f = document.reqForm;
f.page.value = pageNo;
let dataOj = $(f).serializeObject();
$.ajax({
method: 'GET',
url: '/api/board/articles',
data: dataOj,
success(response) {
console.log(response);
$('#totalElements').text(response.totalElements);
// List 구성하기
const tbody = $('#listTBody');
tbody.empty();
$(response.content).each((idx, ct) => {
tbody.append(
`
<tr data-order-no="${ct.orderNo}"
data-id="${ct.id}">
<th
scope="row">${idx + (pageNo * f.size.value) + 1}</th>
<td><label>
<input class="form-check-input"
name="selectIds" type="checkbox" value="${ct.id}"/></label></td>
<td><img
src="${ct.uploadFile ? ct.uploadFile.referURL
: '/static/ui/img/default-img.jpg'}"
style="width: 25px;"
class="img-thumbnail"/></td>
<td><a href="javascript:goUpdate(${ct.id})">${ct.title}</a></td>
<td class="text-secondary text-center">${ct.visible ? 'Y' : 'N'}</td>
<td>${uiUtil.isoStrToReadable(ct.startDate)}</td>
<td>${uiUtil.isoStrToReadable(ct.endDate)}</td>
<td>${ct.updatedBy}</td>
<td>${uiUtil.isoStrToReadable(ct.updatedAt)}</td>
<td class="text-center">${ct.orderNo} <i
class="bi bi-distribute-vertical handle float-end fw-bold"
style="cursor: move"></i></td>
</tr>
`
);
});
if (!$(response.content).length) {
tbody.append(`
<tr>
<td colspan="10" class="text-center text-muted">게시물이 존재하지 않습니다.</td>
</tr>
`);
}
// Pagination 구성하기
const paging = $('.paging');
paging.empty();
paging.append(
uiUtil.getPagingUI(pageNo, f.size.value, response.totalPages,
(movePageNo) => {
f.page.value = movePageNo;
goSearch();
}));
// 리스트 상단 정렬 notation 및 갱신 기능 적용
uiUtil.addSortNotation(f.sort.value, (targetPage, targetSort) => {
f.page.value = targetPage;
f.sort.value = targetSort;
goSearch();
});
}
})
}
// 최초 리스트 로드
getArticles(document.reqForm.page.value);
</script>
<script th:inline="javascript">
const goSearch = () => {
const f = document.reqForm;
f.method = 'GET';
f.submit();
}
// 초기화
function goInit() {
const f = document.reqForm;
f.searchField.value = '';
f.searchValue.value = '';
f.searchOpen.value = '';
}
// 저장페이지 이동
function goSave() {
location.href = '/board/articles/create';
}
// 수정페이지 이동
function goUpdate(itemId) {
location.href = '/board/articles/' + itemId;
}
function goExcel() {
const f = document.reqForm;
const data = $(f).serializeObject();
// size 를 제거하면 전체 목록을 가져온다.
delete data.size;
location.href = '/api/board/articles/excel?' + new URLSearchParams(data).toString();
}
// 체크박스 선택/해제
function toggleCheckbox(oj) {
$('input[name=selectIds]').prop("checked", oj.checked);
}
</script>
</section>
</html>

View File

@@ -0,0 +1,202 @@
<!DOCTYPE html>
<html layout:decorate="~{layout/layout}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:th="http://www.thymeleaf.org">
<section layout:fragment="content">
<style>
.content {
margin-bottom: 20px;
}
.content label {
font-weight: bold;
display: block;
margin-bottom: 5px;
}
.content div {
padding: 8px 0;
}
.tox-tinymce {
border: none;
}
.invalid-feedback {
display: none;
font-size: 12px;
font-weight: bold;
}
.is-invalid + .invalid-feedback {
display: block;
}
textarea.is-invalid ~ .invalid-feedback {
display: block;
}
</style>
<form
class="fw-bold"
method="post" name="reqForm" th:action="@{/board/articles/create}">
<div class="content">
<label>제목 *</label>
<div>
<input class="form-control unescapeText" id="title" name="title"/>
<div class="invalid-feedback">
에러 메세지
</div>
</div>
</div>
<div class="content">
<label class="form-label" for="boardStartDate">게시일 *</label>
<div class="input-row">
<div class="input-group">
<input class="form-control flatpickr" id="boardStartDate" name="startDate"
placeholder="게시일을 선택하세요" type="text"/>
<div class="invalid-feedback">
에러 메세지
</div>
</div>
<div class="input-group">
<input class="form-control flatpickr" id="boardEndDate" name="endDate"
placeholder="종료일을 선택하세요" type="text"/>
<div class="invalid-feedback">
에러 메세지
</div>
</div>
</div>
</div>
<div class="content">
<label>공개여부</label>
<div>
<select class="form-select" id="open" name="visible">
<option value="true">Y</option>
<option value="false">N</option>
</select>
</div>
</div>
<div class="content" style="max-width: 60rem;">
<label for="content">내용 *</label>
<div>
<textarea class="form-control" id="content" name="content" rows="10"></textarea>
<div class="invalid-feedback">
에러 메세지
</div>
</div>
</div>
<div class="content">
<label for="representImgFile">대표 이미지</label>
<div class="input-group">
<input accept="image/*" class="form-control"
id="representImgFile"
name="representImgFile"
onchange="uiUtil.uploadFile('EXAMPLE_REP', this);"
type="file">
<div class="invalid-feedback fw-bold">
에러 메세지
</div>
</div>
</div>
<div class="content publicFileInputs">
<label class="form-label d-block" for="formFile1">다건 파일 첨부</label>
<button class="btn btn-outline-secondary d-inline-block align-top mb-2" onclick="addFileInput();"
type="button"><i class="bi bi-plus-circle"></i> 파일 추가
</button>
</div>
</form>
<button onclick="gotoList();">목록</button>
<button onclick="goSave();">저장</button>
</section>
<section layout:fragment="script">
<!-- web editor - tinymce -->
<script referrerpolicy="origin" src="/static/library/tinymce/6.0.3/tinymce.min.js"></script>
<script src="/static/ui/editorImageUpload.js"></script>
<script>
const goSave = () => {
const f = document.reqForm;
// tinymce 는 사용자 입력을 받는 순간 몇몇 문자(&)를 escaping 한다.
// xss 방지를 위한 html escape 는 필터를 통해 자동처리되니 전달시에는 원문 그대로를 던진다.
f.content.value = uiUtil.unescapeHtml(tinymce.get('content').getContent());
const obj = $(f).serializeObject();
// 기존 에러 메세지 초기화
$('.is-invalid').removeClass('is-invalid');
$.ajax({
traditional: true,
method: 'POST',
url: '/api/front/board/articles/create',
data: obj,
success: (res) => {
alert(`'${f.title.value}' 게시물이 생성되었습니다.\n이전 화면으로 이동합니다.`);
history.back();
},
statusCode: {
// error
400: function (res) {
const resJson = res.responseJSON;
alert(resJson.message);
},
// validation fail
422: function (res) {
$(res.responseJSON).each((idx, oj) => {
let target = $(f).find('[name=' + oj.field + ']');
target.addClass('is-invalid');
target.parent().find('.invalid-feedback').text(oj.defaultMessage);
});
}
}
});
}
</script>
<script>
function gotoList() {
location.href = '/board/articles';
}
function addFileInput() {
const inputGroup = $(`
<div class="input-group w-50">
<input class="form-control mb-2" type="file" name="multipartAttachments"
onchange="uiUtil.uploadFile('EXAMPLE_PUBLIC', this);">
<div class="invalid-feedback fw-bold">
에러 메세지
</div>
</div>
`);
$('.publicFileInputs').append(inputGroup);
return inputGroup;
}
</script>
<script>
// date time picker
$(".flatpickr").flatpickr({
dateFormat: "Y-m-d\\TH:i",
// altInput: true,
// altFormat: "Y-m-d H:i",
monthSelectorType: 'static',
enableTime: true,
time_24hr: true
});
</script>
<script th:inline="javascript">
// init tinymce editor
initEditor('#content');
</script>
</section>
</html>

View File

@@ -0,0 +1,251 @@
<!DOCTYPE html>
<html layout:decorate="~{layout/layout}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:th="http://www.thymeleaf.org">
<section layout:fragment="content">
<style>
.content {
margin-bottom: 20px;
}
.content label {
font-weight: bold;
display: block;
margin-bottom: 5px;
}
.content div {
padding: 8px 0;
}
.tox-tinymce {
border: none;
}
.invalid-feedback {
display: none;
font-size: 12px;
font-weight: bold;
}
.is-invalid + .invalid-feedback {
display: block;
}
textarea.is-invalid ~ .invalid-feedback {
display: block;
}
</style>
<form method="post" name="reqForm">
<input name="id" th:value="${id}" type="hidden">
<input name="orderNo" type="hidden">
<div class="content">
<label>제목 *</label>
<div>
<input class="form-control unescapeText" id="title" name="title"/>
<div class="invalid-feedback">
에러 메세지
</div>
</div>
</div>
<div class="content">
<label class="form-label" for="boardStartDate">게시일 *</label>
<div class="input-row">
<div class="input-group">
<input class="form-control flatpickr" id="boardStartDate" name="startDate"
placeholder="게시일을 선택하세요" type="text"/>
<div class="invalid-feedback">
에러 메세지
</div>
</div>
<div class="input-group">
<input class="form-control flatpickr" id="boardEndDate" name="endDate"
placeholder="종료일을 선택하세요" type="text"/>
<div class="invalid-feedback">
에러 메세지
</div>
</div>
</div>
</div>
<div class="content">
<label>공개여부</label>
<div>
<select class="form-select" id="open" name="visible">
<option value="true">Y</option>
<option value="false">N</option>
</select>
</div>
</div>
<div class="content" style="max-width: 60rem;">
<label for="content">내용 *</label>
<div>
<textarea class="form-control" id="content" name="content" rows="10"></textarea>
<div class="invalid-feedback">
에러 메세지
</div>
</div>
</div>
<div class="content">
<label for="representImgFile">대표 이미지</label>
<div class="input-group">
<input accept="image/*" class="form-control"
id="representImgFile"
name="representImgFile"
onchange="uiUtil.uploadFile('EXAMPLE_REP', this);"
type="file">
<div class="invalid-feedback fw-bold">
에러 메세지
</div>
</div>
</div>
<div class="content publicFileInputs">
<label class="form-label d-block" for="formFile1">다건 파일 첨부</label>
<button class="btn btn-outline-secondary d-inline-block align-top mb-2" onclick="addFileInput();"
type="button"><i class="bi bi-plus-circle"></i> 파일 추가
</button>
</div>
</form>
<button onclick="gotoList();">목록</button>
<button onclick="goSave();">저장</button>
</section>
<section layout:fragment="script">
<!-- web editor - tinymce -->
<script referrerpolicy="origin" src="/static/library/tinymce/6.0.3/tinymce.min.js"></script>
<script src="/static/ui/editorImageUpload.js"></script>
<script>
function gotoList() {
location.href = '/board/articles';
}
function addFileInput() {
const inputGroup = $(`
<div class="input-group w-50">
<input class="form-control mb-2" type="file" name="multipartAttachments"
onchange="uiUtil.uploadFile('EXAMPLE_PUBLIC', this);">
<div class="invalid-feedback fw-bold">
에러 메세지
</div>
</div>
`);
$('.publicFileInputs').append(inputGroup);
return inputGroup;
}
</script>
<script th:inline="javascript">
// date time picker
$(".flatpickr").flatpickr({
enableTime: true,
dateFormat: "Y-m-d\\TH:i",
monthSelectorType: 'static',
time_24hr: true
});
</script>
<script>
const getArticle = () => {
const f = document.reqForm;
$.ajax({
method: 'GET',
url: '/api/front/board/articles/' + f.id.value,
success(res) {
console.log(res);
initEditor('#content', (editor) => {
editor.on('init', function () {
setTimeout(() => {
tinymce.get('content').setContent(uiUtil.unescapeHtml(res.content));
}, 0);
});
});
f.title.value = uiUtil.unescapeHtml(res.title);
f.startDate.value = res.startDate.substring(0, 16);
f.endDate.value = res.endDate.substring(0, 16);
f.visible.value = res.visible;
f.orderNo.value = res.orderNo;
res.uploadFiles.forEach((uploadFile) => {
switch (uploadFile.type.name) {
// 대표 이미지
case 'EXAMPLE_REP':
const input = $(f.representImgFile);
input.parent().append(
`<input type="hidden" name="fileMappingId" value="${uploadFile.id}"/>`);
uiUtil.showFileInfo(input, uploadFile, true);
break;
// 다건 첨부 파일
case 'EXAMPLE_PUBLIC':
let inputGroup = addFileInput();
inputGroup.append(
`<input type="hidden" name="fileMappingId" value="${uploadFile.id}"/>`);
uiUtil.showFileInfo(inputGroup.find('input[type=file]'), uploadFile, false);
break;
}
});
}
});
}
// 상세정보 얻기
getArticle();
</script>
<script>
const goSave = () => {
const f = document.reqForm;
// tinymce 는 사용자 입력을 받는 순간 몇몇 문자(&)를 escaping 한다.
// xss 방지를 위한 html escape 는 필터를 통해 자동처리되니 전달시에는 원문 그대로를 던진다.
f.content.value = uiUtil.unescapeHtml(tinymce.get('content').getContent());
const obj = $(f).serializeObject();
// 기존 에러 메세지 초기화
$('.is-invalid').removeClass('is-invalid');
$.ajax({
traditional: true,
method: 'PUT',
url: '/api/front/board/articles/update',
data: obj,
beforeSend: function (xhr) {
xhr.setRequestHeader(
$("meta[name='_csrf_header']").attr("content"),
$("meta[name='_csrf']").attr("content"));
},
success: (res) => {
if (confirm(`'${uiUtil.unescapeHtml(res.title)}' 게시물이 수정되었습니다.`)) {
location.href = '/board/articles/' + res.id;
}
},
statusCode: {
// error
400: function (res) {
const resJson = res.responseJSON;
alert(resJson.message);
},
// validation fail
422: function (res) {
$(res.responseJSON).each((idx, oj) => {
let target = $(f).find('[name=' + oj.field + ']');
target.addClass('is-invalid');
target.parent().find('.invalid-feedback').text(oj.defaultMessage);
});
}
}
});
}
</script>
</section>
</html>

View File

@@ -0,0 +1,427 @@
<!DOCTYPE html>
<html layout:decorate="~{layout/layout}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:th="http://www.thymeleaf.org">
<section layout:fragment="content">
<style>
.content {
margin-bottom: 20px;
}
.content label {
font-weight: bold;
display: block;
margin-bottom: 5px;
}
.content div {
padding: 8px 0;
}
.comment-info {
display: flex;
align-items: center;
gap: 10px;
}
.comment-actions {
display: flex;
gap: 5px;
}
</style>
<form class="fw-bold" name="reqForm">
<input name="articleId" th:value="${id}" type="hidden">
<!-- pageable parameters -->
<input name="page" type="hidden"/>
<div class="content">
<label>제목</label>
<div id="title" name="title"></div>
</div>
<div class="content">
<label>게시일</label>
<div id="postDate" name="postDate"></div>
</div>
<div class="content">
<label>공개여부</label>
<div id="visible" name="visible"></div>
</div>
<div class="content">
<label>내용</label>
<div id="content" name="content"></div>
</div>
<div class="content uploadFile representImgFile">
<label for="representImgFile">대표 이미지</label>
<div class="input-group">
<div id="representImgFile" name="representImgFile"></div>
</div>
</div>
<div class="content uploadFile publicFileInputs">
<label>다건 파일</label>
</div>
<div class="button-group" style="margin-bottom: 50px;">
<button onclick="gotoList();" type="button">목록</button>
<button onclick="goUpdate();" th:if="${isAuthor}" type="button">수정</button>
<button onclick="goRemove();" th:if="${isAuthor}" type="button">삭제</button>
</div>
<!-- 댓글 -->
<div class="comment-section" style="margin-bottom: 50px;">
<div class="comment-form">
<label>댓글</label>
<div class="input-group">
<input id="newCommentInput" name="commentContent" placeholder="댓글을 입력하세요" type="text">
<button onclick="saveComment()" type="button">등록</button>
</div>
</div>
<!-- 댓글 리스트 -->
<div id="commentList"></div>
<button id="moreBtn" onclick="moreCommentBtn();" style="display: none;" type="button">
더보기
</button>
</div>
</form>
</section>
<section layout:fragment="script">
<script>
function gotoList() {
location.href = '/board/articles';
}
function goUpdate() {
const f = document.reqForm;
location.href = '/board/articles/update/' + f.articleId.value;
}
function addFileInput() {
const inputGroup = $(`
<div class="input-group">
<div class="multiFile"></div>
</div>
`);
$('.publicFileInputs').append(inputGroup);
return inputGroup;
}
</script>
<script>
// 게시물 데이터 조회
const getArticle = () => {
const f = document.reqForm;
$.ajax({
method: 'GET',
url: '/api/front/board/articles/' + f.articleId.value,
success(res) {
console.log("data : ", res);
$('#title').text(uiUtil.unescapeHtml(res.title));
$('#postDate').text(
res.startDate.substring(0, 10) + ' - ' + res.endDate.substring(0, 10));
$('#visible').text(res.visible ? 'Y' : 'N');
$('#content').html(uiUtil.unescapeHtml(res.content));
$('#orderNo').val(res.orderNo);
$('.uploadFile').hide();
res.uploadFiles.forEach((uploadFile) => {
switch (uploadFile.type.name) {
// 대표 이미지
case 'EXAMPLE_REP':
const input = $("#representImgFile");
input.parent().append(
`<input type="hidden" name="fileMappingId" value="${uploadFile.id}"/>`);
uiUtil.showFrontFileInfo(input, uploadFile, true);
$('.representImgFile').show();
break;
// 다건 첨부 파일
case 'EXAMPLE_PUBLIC':
let inputGroup = addFileInput();
inputGroup.append(
`<input type="hidden" name="fileMappingId" value="${uploadFile.id}"/>`);
uiUtil.showFrontFileInfo(inputGroup.find('.multiFile'), uploadFile, false);
$('.publicFileInputs').show();
break;
}
});
}
});
}
getArticle();
</script>
<script th:inline="javascript">
const goRemove = () => {
if (confirm(/*[[#{operation.board.article.remove.ask}]]*/)) {
const f = document.reqForm;
const obj = $(f).serializeObject();
$.ajax({
'method': 'DELETE',
'url': '/api/front/board/articles/remove',
'data': {
'selectIds': obj.articleId
},
beforeSend: function (xhr) {
xhr.setRequestHeader(
$("meta[name='_csrf_header']").attr("content"),
$("meta[name='_csrf']").attr("content"));
},
success(res) {
alert('게시물이 삭제되었습니다.');
gotoList();
},
statusCode: {
// error
400: function (response) {
const resJson = response.responseJSON;
alert(resJson.message);
}
}
});
}
}
</script>
<script>
// 댓글 데이터 조회
const getArticleComments = () => {
const f = document.reqForm;
const obj = $(f).serializeObject();
$.ajax({
method: 'GET',
url: '/api/front/board/articles/comments',
data: obj,
success(res) {
// 댓글 렌더링
res.content.forEach((comment) => {
const commentElement = createCommentElement(comment);
$('#commentList').append(commentElement);
});
// 더보기 버튼 표시/숨김 처리
f.page.value = res.number;
const currentPage = parseInt(f.page.value);
const pageSize = parseInt(res.size);
const totalPages = Math.ceil(res.totalElements / pageSize);
if (currentPage >= totalPages - 1) {
$('#moreBtn').hide();
} else {
$('#moreBtn').show();
}
}
});
};
// 초기 로드 호출
getArticleComments();
</script>
<script>
// 댓글 더보기 버튼
function moreCommentBtn() {
const f = document.reqForm;
const pageInput = $(f).find('input[name="page"]');
// 현재 페이지 증가
pageInput.val(parseInt(pageInput.val()) + 1);
getArticleComments();
}
</script>
<script th:inline="javascript">
// 댓글 추가 html
function createCommentElement(data) {
return $(`
<div class="comment" data-comment-id="${data.id}">
<div class="comment-header">
<div class="comment-info">
<label class="author">${data.createdBy}</label>
<span class="date">${formatDate(data.updatedAt)}</span>
<div class="comment-actions">
${data.isAuthor == null || data.isAuthor ? `
<button type="button" onclick="editComment(this)">수정</button>
<button type="button" onclick="removeComment(this)">삭제</button>
` : ''}
</div>
</div>
</div>
<div class="comment-body">
<div class="content">${data.content}</div>
<div class="edit-form" style="display: none;">
<input type="text" class="edit-input" value="${data.content}">
<button type="button" onclick="saveEdit(this)">저장</button>
<button type="button" onclick="cancelEdit(this)">취소</button>
</div>
</div>
</div>
`);
}
// 댓글 저장
function saveComment() {
const f = document.reqForm;
const obj = $(f).serializeObject();
$.ajax({
method: 'POST',
url: '/api/front/board/articles/comment/create',
data: obj,
beforeSend: function (xhr) {
xhr.setRequestHeader(
$("meta[name='_csrf_header']").attr("content"),
$("meta[name='_csrf']").attr("content"));
},
success: (res) => {
const commentElement = createCommentElement(res);
$('#commentList').prepend(commentElement);
$('#newCommentInput').val('');
},
statusCode: {
// error
400: function (res) {
const resJson = res.responseJSON;
alert(resJson.message);
},
// validation fail
422: function (res) {
$(res.responseJSON).each((idx, oj) => {
alert(oj.defaultMessage);
});
}
}
});
}
// 댓글 수정 모드로 전환
function editComment(button) {
const comment = $(button).closest('.comment');
const content = comment.find('.content');
const editForm = comment.find('.edit-form');
const editInput = comment.find('.edit-input');
const commentActions = comment.find('.comment-actions');
commentActions.hide();
content.hide();
editForm.show();
editInput.val(content.text()).focus();
}
// 댓글 수정 저장
function saveEdit(button) {
const f = document.reqForm;
const comment = $(button).closest('.comment');
const commentId = comment.data('comment-id');
const editInput = comment.find('.edit-input');
const commentContent = editInput.val();
$.ajax({
method: 'PUT',
url: '/api/front/board/articles/comment/update',
data: {
commentId: commentId,
commentContent: commentContent,
articleId: f.articleId.value
},
beforeSend: function (xhr) {
xhr.setRequestHeader(
$("meta[name='_csrf_header']").attr("content"),
$("meta[name='_csrf']").attr("content"));
},
success: (res) => {
const content = comment.find('.content');
const editForm = comment.find('.edit-form');
const commentActions = comment.find('.comment-actions');
content.text(res.content).show();
editForm.hide();
commentActions.show();
},
statusCode: {
// error
400: function (res) {
const resJson = res.responseJSON;
alert(resJson.message);
},
// validation fail
422: function (res) {
$(res.responseJSON).each((idx, oj) => {
alert(oj.defaultMessage);
});
}
}
});
}
// 댓글 수정 취소
function cancelEdit(button) {
const comment = $(button).closest('.comment');
const content = comment.find('.content');
const editForm = comment.find('.edit-form');
const commentActions = comment.find('.comment-actions');
content.show();
editForm.hide();
commentActions.show();
}
// 댓글 삭제
function removeComment(button) {
const comment = $(button).closest('.comment');
const commentId = comment.data('comment-id');
if (confirm(/*[[#{operation.board.article.comment.remove.ask}]]*/)) {
$.ajax({
'method': 'DELETE',
'url': '/api/front/board/articles/comment/remove',
'data': {
'removeId': commentId
},
beforeSend: function (xhr) {
xhr.setRequestHeader(
$("meta[name='_csrf_header']").attr("content"),
$("meta[name='_csrf']").attr("content"));
},
success(res) {
$(button).closest('.comment').remove();
},
statusCode: {
// error
400: function (response) {
const resJson = response.responseJSON;
alert(resJson.message);
}
}
});
}
}
</script>
<script>
function formatDate(isoString) {
const date = new Date(isoString);
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');
const seconds = String(date.getSeconds()).padStart(2, '0');
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}
</script>
</section>
</html>

View File

@@ -0,0 +1,138 @@
<!DOCTYPE html>
<html layout:decorate="~{layout/layout}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:th="http://www.thymeleaf.org">
<section layout:fragment="content">
<form enctype="multipart/form-data"
method="post"
name="updateForm" th:action="@{/board/exampleBoard/} + ${formDto.editMode ? 'update' : 'create'}"
th:object="${formDto}">
<input name="editMode" th:value="${formDto.editMode}" type="hidden"/>
<input name="id" th:if="${formDto.editMode}" th:value="${formDto.id}" type="hidden"/>
<div>
<h1 th:text="${formDto.title}">
</h1>
<div>
<label>게시일 *</label>
<div>
<span th:text="${formDto.boardStartDate}"></span> ~ <span
th:text="${formDto.boardEndDate}"></span>
</div>
</div>
<div>
<label>공개여부</label>
<div th:text="${formDto.visible}">
</div>
<div th:utext="${formDto.content}">
</div>
<div th:if="${formDto.editMode}">
<label for="content" style="padding-top: 0;">public 파일</label>
<div>
<div th:each="item, status : ${formDto.uploadedFiles}">
<a th:attr="data-file-seq=${item.seq}" th:href="${@commonUtil.getPublicIOPath(item)}"
th:text="${item.originalFilename}"
></a>
<a href="javascript:void(0);" onclick="removeFile(this);"
th:attr="data-del-file-seq=${item.seq}"><i
></i></a>
<a href="javascript:void(0);" onclick="cancelRemove(this);" style="display: none;"
th:attr="data-cancel-file-seq=${item.seq}"
> (취소)</a>
</div>
</div>
</div>
<div th:if="${formDto.editMode}">
<label for="content" style="padding-top: 0;">private 파일</label>
<div>
<div th:each="item, status : ${formDto.uploadedPrivates}">
<a th:attr="data-file-seq=${item.seq}" th:href="${@commonUtil.getPrivateIOPath(item)}"
th:text="${item.originalFilename}"
></a>
<a href="javascript:void(0);" onclick="removeFile(this);"
th:attr="data-del-file-seq=${item.seq}"><i
></i></a>
<a href="javascript:void(0);" onclick="cancelRemove(this);" style="display: none;"
th:attr="data-cancel-file-seq=${item.seq}"
> (취소)</a>
</div>
</div>
</div>
</div>
<button onclick="gotoList();return false;" type="button">목록으로 이동</button>
</form>
<!-- 이전 목록페이지의 검색 및 정렬조건 폼 -->
<form method="get" name="prevParamForm" th:action="@{/board/exampleBoard}"
th:if="${formDto.editMode}"
th:object="${paramDto}">
<input th:field="*{searchField}" type="hidden">
<input th:field="*{searchValue}" type="hidden">
<input th:field="*{searchOpen}" type="hidden">
<input th:field="*{page}" type="hidden">
<input th:field="*{size}" type="hidden">
<input th:field="*{sort}" type="hidden">
</form>
<script>
function gotoList() {
document.prevParamForm ? document.prevParamForm.submit()
: location.href = '/board/exampleBoard';
}
function removeFile(oj) {
const fileSeq = $(oj).data('del-file-seq');
const el = $('a[data-file-seq=' + fileSeq + ']');
el.addClass('text-decoration-line-through');
$(oj).hide();
const cancelEl = $('a[data-cancel-file-seq=' + fileSeq + ']');
cancelEl.show();
const f = document.updateForm;
let input = $('<input type="hidden" name="delFileSeq">');
input.val(fileSeq);
input.attr('id', 'del_' + fileSeq);
$(f).append(input);
}
function cancelRemove(oj) {
const fileSeq = $(oj).data('cancel-file-seq');
const el = $('a[data-file-seq=' + fileSeq + ']');
el.removeClass('text-decoration-line-through');
$('#del_' + fileSeq).remove();
$('a[data-del-file-seq=' + fileSeq + ']').show();
$(oj).hide();
}
function addFileInput(type) {
let tmpl = $.templates('#fileInputTmpl');
switch (type) {
case 'public':
$('.publicFileInputs').append(tmpl.render({'name': 'multipartFiles'}));
break;
case 'private':
$('.privateFileInputs').append(tmpl.render({'name': 'privateFiles'}));
break;
}
}
</script>
<script id="fileInputTmpl" type="text/x-jsrender">
<input type="file" name="{{:name}}"/>
</script>
</section>
</html>

View File

@@ -0,0 +1,174 @@
<!DOCTYPE html>
<html layout:decorate="~{layout/layout}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:th="http://www.thymeleaf.org">
<section layout:fragment="content">
<form method="post" name="paramForm" onsubmit="goSearch();"
th:action="@{/board/exampleBoard}" th:object="${paramDto}">
<!-- hidden parameters -->
<input name="page" th:value="${listOutput.pageable.pageNumber}" type="hidden"/>
<input name="sort" th:value="${listOutput.pageable.sort}" type="hidden"/>
<div style="--bs-bg-opacity: .2;">
<div>
<label for="searchField">검색필드</label>
<select id="searchField"
th:field="*{searchField}">
<option selected value="">선택</option>
<option value="title">제목</option>
<option value="createdBy">작성자</option>
</select> <label>
<input placeholder="검색어를 입력하세요."
style="width: 250px;" th:field="*{searchValue}"
type="text">
</label>
</div>
<div>
<label for="searchOpen">공개여부</label>
<select id="searchOpen"
th:field="*{searchOpen}">
<option selected value="">전체</option>
<option value="true">Y</option>
<option value="false">N</option>
</select>
</div>
<div>
<button onclick="goSearch();"
type="button">검색
</button>
<button onclick="goInit();" type="button">초기화
</button>
</div>
</div>
<div>
<div>
<div>
Total: <span th:text="${listOutput.totalElements}"></span>
</div>
</div>
<div>
<i></i> <label> <select
onchange="goSearch()"
th:field="*{size}">
<option
th:each="item : ${pageRows}"
th:selected="${#strings.toString(listOutput.pageable.pageSize) eq item.codeValue}" th:text="${item.codeText}"
th:value="${item.codeValue}"></option>
</select>
</label>
</div>
</div>
<table>
<thead>
<tr>
<th scope="col">#</th>
<th scope="col"><label>
<input
onchange="toggleCheckbox(this);" type="checkbox"/></label>
</th>
<th scope="col"><a data-sort-field="title"
href="#">제목</a></th>
<th scope="col"><a data-sort-field="open"
href="#">공개여부</a></th>
<th scope="col"><a data-sort-field="boardStartDate"
href="#">게시일</a></th>
<th scope="col"><a data-sort-field="boardEndDate"
href="#">종료일</a></th>
<th scope="col"><a data-sort-field="updatedBy"
href="#">수정자</a></th>
<th scope="col"><a data-sort-field="updatedAt"
href="#">최근 수정일</a></th>
</tr>
</thead>
<tbody>
<tr th:each="item, status : ${listOutput.content}">
<th
scope="row"
th:text="${status.count + (listOutput.pageable.pageNumber * listOutput.pageable.pageSize)}">게시물번호
</th>
<td><label>
<input
name="checkedIds" th:value="${item.id}" type="checkbox"/></label>
<td><a th:href="|javascript:goSave('${item.id}')|"
th:text="${item.title}">Title</a></td>
<td><i th:if="${item.visible}"></i> <i
th:if="${!item.visible}"></i></td>
<td
th:text="${#temporals.format(item.boardStartDate, 'yyyy-MM-dd hh:mm')}">게시일
</td>
<td
th:text="${#temporals.format(item.boardEndDate, 'yyyy-MM-dd hh:mm')}">종료일
</td>
<td th:text="${item.updatedBy}">작성자</td>
<td
th:text="${#temporals.format(item.updatedAt, 'yyyy-MM-dd hh:mm')}">수정일
</td>
</tr>
</tbody>
</table>
</form>
<div th:replace="common/list-components :: pagination(${listOutput})"></div>
<script th:inline="javascript">
// 검색
function goSearch() {
const f = document.paramForm;
f.action = '/board/exampleBoard';
f.page.value = 0;
f.sort.value = convertToPageableSortValue(f.sort.value);
f.method = 'get';
f.submit();
}
// 초기화
function goInit() {
const f = document.paramForm;
f.searchField.value = '';
f.searchValue.value = '';
f.searchOpen.value = '';
}
// 수정페이지 이동
function goSave(itemId) {
const f = document.paramForm;
f.action = '/board/exampleBoard/update/' + itemId;
f.method = 'get';
f.submit();
}
function goExcel() {
const f = document.paramForm;
f.action = '/board/exampleBoard/excel';
f.method = 'get';
f.submit();
}
// 체크박스 선택/해제
function toggleCheckbox(oj) {
$('input[name=checkedIds]').prop("checked", oj.checked);
}
function goRemove() {
if (!$('input[name=checkedIds]').is(':checked')) {
alert(/*[[#{operation.common.remove.choose}]]*/);
return;
}
if (confirm(/*[[#{operation.common.remove.ask}]]*/)) {
const f = document.paramForm;
f.action = '/board/exampleBoard/delete';
f.method = 'post';
f.submit();
}
}
</script>
</section>
</html>

View File

@@ -0,0 +1,197 @@
<!DOCTYPE html>
<html xmlns:sec="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<!--
██ ██ ██ ███████ █████ ██████ ██
██ ██ ██ ██ ██ ██ ██ ██ ██
██ ███████ █████ ███████ ██ ██ ██
██ ██ ██ ██ ██ ██ ██ ██ ██
██ ██ ██ ███████ ██ ██ ██████ ██
-->
<head th:fragment="head">
<meta charset="UTF-8">
<meta content="IE=edge" http-equiv="X-UA-Compatible">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<meta name="_csrf" th:content="${_csrf.token}"/>
<meta name="_csrf_header" th:content="${_csrf.headerName}"/>
<title th:text="${currentURI.ogTitle}"></title>
<meta name="title" th:content="${currentURI.ogTitle}"/>
<meta name="description" th:content="${currentURI.ogDesc}"/>
<meta name="keywords" th:content="${currentURI.ogKeywords}"/>
<meta property="og:title" th:content="${currentURI.ogTitle}"/>
<meta property="og:description" th:content="${currentURI.ogDesc}"/>
<meta property="og:keywords" th:content="${currentURI.ogKeywords}"/>
<meta property="og:image" th:content="${currentURI.ogImage}"/>
<script th:src="@{/static/library/jquery/jquery-3.6.0.min.js}"></script>
<script th:src="@{/static/library/jsUri/Uri.js}"></script>
<script th:src="@{/static/library/jsRender/jsrender.min.js}"></script>
<script th:src="@{/static/ui/uiUtil.js}"></script>
<script th:src="@{/static/library/jquery/jquery-serializeObject.min.js}"></script>
<link rel="stylesheet" th:href="@{/static/library/flatpickr/flatpickr.min.css}">
<link rel="stylesheet" th:href="@{/static/library/flatpickr/flatpickr.dark.css}">
<script th:src="@{/static/library/flatpickr/flatpickr.min.js}"></script>
<script th:each="flashMsg : ${session.flashAlertMessages}" th:if="${session.flashAlertMessages != null}"
th:inline="javascript">
$(function () {
const flashAlertMessage = [[${flashMsg}]];
if (flashAlertMessage) {
alert(flashAlertMessage);
}
});
</script>
<script th:if="${session.flashAlertMessages != null}" th:inline="javascript">
[[${#session.removeAttribute('flashAlertMessages')}]]
</script>
<style type="text/css">
.active {
font-weight: bold;
}
</style>
</head>
<body>
<!--
██ ███ ██ █████ ██ ██ ██ ██ ██ ███████ █████ ██████ ███████ ██████
██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██ ██ ██ ██ ███████ ██ ██ ██ █████ ███████ █████ ███████ ██ ██ █████ ██████
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██ ██ ████ ██ ██ ████ ██ ██ ██ ███████ ██ ██ ██████ ███████ ██ ██
-->
<nav th:fragment="header">
<section style="background:#eee; border-radius: 1px;">
<h2>Header 영역</h2>
<p>
<strong>Current Locale</strong> :
<select name="localeSelect" onchange="localeChange(this);">
<option>언어 설정</option>
<option th:selected="${#locale.toString() == 'ko_KR'}" value="ko_KR">ko_KR</option>
<option th:selected="${#locale.toString() == 'en_US'}" value="en_US">en_US</option>
</select>
</p>
<p>
<strong>Current Device</strong> : [[${currentDevice}]]
</p>
<div>
<strong>Current Login User</strong> :
<p sec:authorize="isAnonymous()" th:remove="tag">
<a href="/login">[로그인]</a>
</p>
<p sec:authorize="isAuthenticated()" th:remove="tag">
<strong th:text="${#authentication.principal.nickname}">로그인 사용자명</strong>
<a href="/logout">[로그아웃]</a>
<a href="/user/info">[정보수정]</a>
</p>
</div>
<script th:inline="javascript">
function localeChange(oj) {
if (!oj.value) {
return;
}
location.href = new Uri(location.href).replaceQueryParam('lang', oj.value);
}
</script>
<ul th:if="${topNode != null}">
<li>
<a th:classappend="${topNode.uri eq currentURI.uri} ? 'active'"
th:href="${topNode.uri}">[[${#messages.msg(topNode.id)}]]</a>
</li>
<li th:each="menu : ${topNode.children}" th:if="${menu.showOnNavi}">
<!-- 자식 nodes 가 없는 경우 -->
<a th:classappend="${currentURI.id == menu.id}? 'active'"
th:href="${menu.uri}" th:if="${#lists.size(menu.children) == 0}"
th:text="${#messages.msg(menu.id)}">메뉴명</a>
<!-- 자식 nodes 가 있는 경우 -->
<a th:classappend="${@coreUtil.containsCurrentURI(menuHierarchy, menu.id)}? 'active'"
th:href="${menu.uri}"
th:if="${#lists.size(menu.children) > 0}" th:text="${#messages.msg(menu.id)}">메뉴명</a>
<ul th:if="${#lists.size(menu.children) > 0}">
<li th:each="child : ${menu.children}" th:if="${child.showOnNavi}">
<a class="dropdown-item"
th:classappend="${@coreUtil.containsCurrentURI(menuHierarchy, child.id)}? 'active'"
th:href="${child.uri}" th:text="${#messages.msg(child.id)}">메뉴명</a>
</li>
</ul>
</li>
</ul>
</section>
</nav>
<!--
██████ ██████ ███████ █████ ██████ ██████ ██████ ██ ██ ███ ███ ██████
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ████ ██ ██
██████ ██████ █████ ███████ ██ ██ ██ ██████ ██ ██ ██ ████ ██ ██████
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██████ ██ ██ ███████ ██ ██ ██████ ██████ ██ ██ ██████ ██ ██ ██████
-->
<div th:fragment="breadcrumb">
<div style="background:#eee;">
<h2>Breadcrumb 영역</h2>
<nav>
<ol>
<li th:classappend="${item.id == currentURI.id}? 'active'"
th:each="item, status : ${menuHierarchy}">
<a th:href="${item.uri}" th:if="${item.id != currentURI.id}">
<span th:remove="tag" th:text="${@coreUtil.getUriTitle(item)}"></span>
</a>
<span th:if="${item.id == currentURI.id}" th:remove="tag"
th:text="${@coreUtil.getUriTitle(item)}"></span>
</li>
</ol>
</nav>
</div>
</div>
<!--
██████ █████ ██████ ███████ ██ ██ ███████ █████ ██████ ██ ███ ██ ██████
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ ██
██████ ███████ ██ ███ █████ ███████ █████ ███████ ██ ██ ██ ██ ██ ██ ██ ███
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██ ██ ██ ██████ ███████ ██ ██ ███████ ██ ██ ██████ ██ ██ ████ ██████
-->
<div th:fragment="pageHeading">
<h1 th:text="${#messages.msg(currentURI.id)}"></h1>
</div>
<!--
██████ ██████ ███████ ██████ █████ ████████ ██ ██████ ███ ██ ███ ███ ███████ ██████
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ ████ ████ ██ ██
██ ██ ██████ █████ ██████ ███████ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ ███████ ██ ███
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██████ ██ ███████ ██ ██ ██ ██ ██ ██ ██████ ██ ████ ██ ██ ███████ ██████
-->
<div class="row" th:fragment="operationMessage" th:if="${not #strings.isEmpty(operationMessage)}">
<div class="alert alert-info fw-bold" th:utext="${operationMessage}">
</div>
</div>
<!--
███████ ██████ ██████ ████████ ███████ ██████
██ ██ ██ ██ ██ ██ ██ ██ ██
█████ ██ ██ ██ ██ ██ █████ ██████
██ ██ ██ ██ ██ ██ ██ ██ ██
██ ██████ ██████ ██ ███████ ██ ██
-->
<div th:fragment="footer">
<footer>
<div>
<span>&copy; 2022 All rights reserved</span>
</div>
</footer>
</div>
</body>
</html>

View File

@@ -0,0 +1,40 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<body>
<!--
██████ █████ ██████ ██ ███ ██ █████ ████████ ██ ██████ ███ ██
██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ████ ██
██████ ███████ ██ ███ ██ ██ ██ ██ ███████ ██ ██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██ ██ ██ ██████ ██ ██ ████ ██ ██ ██ ██ ██████ ██ ████
-->
<div th:fragment="pagination(items)">
<div class="row">
<nav aria-label="Page navigation example">
<ul class="pagination justify-content-center">
<li class="page-item" th:classappend="${!items.pageable.hasPrevious} ? 'disabled'">
<a class="page-link"
th:href="|javascript:goPageable(${items.pageable.pageNumber - 1}, ${items.pageable.pageSize}, '${items.pageable.sort}')|">이전</a>
</li>
<li class="page-item"
th:classappend="${idx == items.pageable.pageNumber} ? 'disabled'"
th:each="idx : ${#numbers.sequence(0, items.totalPages == 0 ? 0 : items.totalPages - 1)}">
<a class="page-link"
th:href="|javascript:goPageable(${idx}, ${items.pageable.pageSize}, '${items.pageable.sort}')|"
th:text="${idx+1}">페이지넘버</a>
</li>
<li class="page-item"
th:classappend="${items.pageable.pageNumber == items.totalPages - 1 or items.totalPages == 0 or items.totalPages == 0} ? 'disabled'">
<a class="page-link"
th:href="|javascript:goPageable(${items.pageable.pageNumber + 1}, ${items.pageable.pageSize}, '${items.pageable.sort}')|">다음</a>
</li>
</ul>
</nav>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,37 @@
<!DOCTYPE html>
<html layout:decorate="~{layout/layout-error}"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:th="http://www.w3.org/1999/xhtml">
<head>
<title>404</title>
</head>
<body>
<section layout:fragment="content">
<div class="container">
<div class="row">
<div class="p-5 mb-4 bg-light rounded-3">
<div class="container-fluid py-5">
<h1 class="display-5 fw-bold"><i class="bi bi-eye-slash-fill"></i>
Oops, 404 Not Found :-(</h1>
<p class="col-md-8 fs-4">
존재하지 않는 URI 주소로 접근했습니다. 다시 확인해주세요.
</p>
<p class="col-md-8 fs-5">
<span>Error</span> <span class="text-muted" th:text="${error}"></span>
<br/>
<span>Message</span> <span class="text-muted" th:text="${message}"></span>
</p>
<button class="btn btn-primary btn-lg" onclick="location.href='/'" type="button">홈으로 이동
</button>
</div>
</div>
</div>
</div>
</section>
</body>
</html>

View File

@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html layout:decorate="~{layout/layout-error}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:th="http://www.thymeleaf.org">
<head>
<title>500 - 에러발생</title>
</head>
<body>
<section layout:fragment="content">
<div class="container">
<div class="row">
<div class="p-5 mb-4 bg-light rounded-3">
<div class="container-fluid py-5">
<h1 class="display-5 fw-bold"><i class="bi bi-cone-striped"></i>
Oops, <span class="text-muted">에러가 발생했습니다!</span> :-(</h1>
<p class="col-md-8 fs-4">
아래 에러 메세지를 담당자에게 전달해주세요.
</p>
<p class="col-md-8 fs-5">
<span>Error</span> <span class="text-muted" th:text="${error}"></span>
<br/>
<span>Message</span> <span class="text-muted" th:text="${message}"></span>
<!-- <br/>-->
<!-- <span>Status</span> <span th:text="${status}" class="text-muted"></span>-->
<!-- <br/>-->
<!-- <span>Path</span> <span th:text="${path}" class="text-muted"></span>-->
<!-- <br/>-->
<!-- <span>Timestamp</span> <span th:text="${timestamp}" class="text-muted"></span>-->
</p>
<hr>
<button class="btn btn-primary btn-lg" onclick="history.go(-1)" type="button">이전으로 이동
</button>
</div>
</div>
</div>
</div>
</section>
</body>
</html>

View File

@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html layout:decorate="~{layout/layout}"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
<head>
<title>Home</title>
</head>
<body>
<section layout:fragment="content">
<h1>HELLO</h1>
</section>
</body>
</html>

View File

@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
<body>
<section layout:fragment="content">
<p>Page content goes here</p>
</section>
<div class="container">
<footer class="py-3 my-4 border-top">
<div class="text-center">
<span class="text-muted">&copy; 2022 All rights reserved</span>
</div>
</footer>
</div>
</body>
</html>

View File

@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:th="http://www.thymeleaf.org">
<head th:replace="~{common/components :: head}"></head>
<body>
<header th:replace="~{common/components :: header}"></header>
<div class="container">
<div th:replace="~{common/components :: operationMessage}"></div>
<section class="container" layout:fragment="content">
page content
</section>
</div>
<div th:replace="~{common/components :: footer}"></div>
</body>
</html>

View File

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:th="http://www.thymeleaf.org">
<head th:replace="~{common/components :: head}"></head>
<body>
<section class="container" layout:fragment="content">
<p>Page content goes here</p>
</section>
</body>
</html>

View File

@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:th="http://www.thymeleaf.org">
<head th:replace="~{common/components :: head}"></head>
<body>
<header th:replace="~{common/components :: header}"></header>
<div>
<div th:replace="~{common/components :: breadcrumb}"></div>
<div th:replace="~{common/components :: pageHeading}"></div>
<div th:replace="~{common/components :: operationMessage}"></div>
<section layout:fragment="content">
page content
</section>
</div>
<div th:replace="~{common/components :: footer}"></div>
<section layout:fragment="script"></section>
</body>
</html>

View File

@@ -0,0 +1,45 @@
<!DOCTYPE html>
<html layout:decorate="~{layout/layout}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:th="http://www.thymeleaf.org">
<section layout:fragment="content">
<form method="post" th:action="@{/login}">
<div class="" th:if="${session['SPRING_SECURITY_LAST_EXCEPTION']} != null">
<div class="alert alert-danger fw-bold"
th:utext="${session['SPRING_SECURITY_LAST_EXCEPTION'].message}">
</div>
</div>
<h3>
<a href="/oauth2/authorization/kakao">카카오 로그인</a>
<a href="/oauth2/authorization/naver">네이버 로그인</a>
</h3>
<div class="">
<label for="">ID</label>
<input autofocus class="" id="floatingInput" name="username" placeholder="ID를 입력해주세요"
type="text">
</div>
<div class="">
<label for="floatingPassword">Password</label>
<input class="f" id="floatingPassword" name="password" placeholder="Password" type="password">
</div>
<div class="">
<div aria-label="Basic checkbox toggle button group" class="" roleDto="group">
<input autocomplete="off" class="" id="btn_ck1" name="remember-me" type="checkbox">
<label class="" for="btn_ck1">로그인 상태 유지하기</label>
</div>
</div>
<button class="" type="submit">Sign in</button>
</form>
<div>
<a href="/user/register">회원가입</a>
</div>
</section>
</html>

View File

@@ -0,0 +1,141 @@
<!DOCTYPE html>
<html layout:decorate="~{layout/layout}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:th="http://www.thymeleaf.org">
<section layout:fragment="content">
<style>
label {
display: inline-block;
width: 150px;
}
div {
margin-bottom: 15px;
}
.invalid-feedback {
display: none;
font-size: 12px;
font-weight: bold;
}
.is-invalid + .invalid-feedback {
display: block;
}
input[readonly] {
background-color: #e9ecef;
color: #6c757d;
cursor: not-allowed;
}
</style>
<div>
<form
method="get"
name="reqForm"
th:action="@{/user/info}" th:object="${userInfo}">
<div>
<label class="form-label d-block" for="profileImgFile">프로필 이미지</label>
<div class="input-group w-50">
<input accept="image/*" class="form-control"
id="profileImgFile"
name="profileImgFile"
onchange="uiUtil.uploadFile('PROFILE_IMG', this);"
type="file">
<div class="invalid-feedback field-profileImgFile">
에러 메세지
</div>
</div>
<div style="clear: both;"></div>
</div>
<div>
<label for="userId">아이디</label>
<input id="userId" name="id" placeholder="아이디" readonly="readonly" th:field="*{id}"
type="text">
<div class="invalid-feedback field-id"></div>
</div>
<div>
<label for="nickname">닉네임</label>
<input id="nickname" name="nickname" placeholder="닉네임" th:field="*{nickname}" type="text">
<div class="invalid-feedback field-id"></div>
</div>
<div>
<label for="userPwd">새 비밀번호</label>
<input id="userPwd" name="password" placeholder="변경할 패스워드를 입력해주세요." th:field="*{password}"
type="password">
<div class="invalid-feedback field-password"></div>
</div>
<div>
<label for="userPwdRe">새 비밀번호 재확인</label>
<input id="userPwdRe" name="passwordRe" placeholder="변경할 패스워드를 재입력해주세요."
type="password">
<div class="invalid-feedback field-passwordRe"></div>
</div>
<div>
<label for="userEmail">이메일</label>
<input id="userEmail" name="email" placeholder="이메일을 입력해주세요." th:field="*{email}"
type="text">
<div class="invalid-feedback field-email"></div>
</div>
</form>
<button onclick="updateUser();">수정하기</button>
</div>
</section>
<section layout:fragment="script">
<script>
const updateUser = () => {
const f = document.reqForm;
const obj = $(f).serializeObject();
// 기존 에러 메세지 초기화
$('.is-invalid').removeClass('is-invalid');
$.ajax({
method: 'PATCH',
url: '/api/front/user/update',
data: obj,
beforeSend: function (xhr) {
xhr.setRequestHeader(
$("meta[name='_csrf_header']").attr("content"),
$("meta[name='_csrf']").attr("content"));
},
success(res) {
if (confirm(`'${res.id}' 정보가 수정되었습니다.`)) {
location.reload();
}
},
statusCode: {
'422': (res) => {
const fieldErrors = res.responseJSON.fieldErrors;
$(fieldErrors).each(function (idx, error) {
let target = $(f).find('[name=' + error.field + ']');
target.addClass('is-invalid');
target.parent().find('.invalid-feedback').text(error.message);
});
}
}
})
}
</script>
<script th:inline="javascript">
const showProfileImage = () => {
const f = document.reqForm;
const uploadFile = [[${userInfo.uploadFile}]];
if (uploadFile != null) {
const input = $(f.profileImgFile);
input.parent().append(
`<input type="hidden" name="fileMappingId" value="${uploadFile.id}"/>`);
uiUtil.showFileInfo(input, uploadFile, true);
}
}
showProfileImage();
</script>
</section>
</html>

View File

@@ -0,0 +1,104 @@
<!DOCTYPE html>
<html layout:decorate="~{layout/layout}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:th="http://www.thymeleaf.org">
<section layout:fragment="content">
<style>
label {
display: inline-block;
width: 130px;
}
div {
margin-bottom: 15px;
}
.invalid-feedback {
display: none;
font-size: 12px;
font-weight: bold;
}
.is-invalid + .invalid-feedback {
display: block;
}
</style>
<div>
<form method="post" name="reqForm" th:action="@{/user/register}">
<div>
<label for="userId">아이디</label>
<input id="userId" name="id" placeholder="아이디" type="text">
<div class="invalid-feedback field-id"></div>
</div>
<div>
<label for="nickname">닉네임</label>
<input id="nickname" name="nickname" placeholder="닉네임" type="text">
<div class="invalid-feedback field-id"></div>
</div>
<div>
<label for="userPwd">비밀번호</label>
<input id="userPwd" name="password" placeholder="패스워드를 입력해주세요." type="password">
<div class="invalid-feedback field-password"></div>
</div>
<div>
<label for="userPwdRe">비밀번호 재확인</label>
<input id="userPwdRe" name="passwordRe" placeholder="패스워드를 재입력해주세요." type="password">
<div class="invalid-feedback field-passwordRe"></div>
</div>
<div>
<label for="userEmail">이메일</label>
<input id="userEmail" name="email" placeholder="이메일을 입력해주세요." type="text">
<div class="invalid-feedback field-email"></div>
</div>
</form>
<button onclick="goSave()">가입하기</button>
</div>
</section>
<section layout:fragment="script">
<script>
// 가입하기
const goSave = () => {
const f = document.reqForm;
const obj = $(f).serializeObject();
// 기존 에러 메세지 초기화
$('.is-invalid').removeClass('is-invalid');
$.ajax({
method: 'POST',
url: '/api/public/user/create',
data: obj,
beforeSend: function (xhr) {
xhr.setRequestHeader(
$("meta[name='_csrf_header']").attr("content"),
$("meta[name='_csrf']").attr("content"));
},
success: (res) => {
alert('회원가입이 완료되었습니다.\n로그인 페이지로 이동합니다.');
location.href = '/login';
},
statusCode: {
// error
400: function (res) {
const resJson = res.responseJSON;
alert(resJson.message);
},
// validation fail
422: function (res) {
const fieldErrors = res.responseJSON.fieldErrors;
$(fieldErrors).each(function (idx, error) {
let target = $(f).find('[name=' + error.field + ']');
target.addClass('is-invalid');
target.parent().find('.invalid-feedback').text(error.message);
});
}
}
});
}
</script>
</section>
</html>