최초 커밋!

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,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>