관리자 엑셀 파일 업로드 추가 (모달창 퍼블 수정 필요,,,)
This commit is contained in:
@@ -17,7 +17,7 @@ class AdminIdDuplicateCheckPostController {
|
||||
private final CheckAdminIdPortIn checkAdminIdPortIn;
|
||||
|
||||
@GetMapping("/api/settings/admin/idCheck")
|
||||
ResponseEntity<?> updateMappingHousehold(@RequestParam String id ) {
|
||||
ResponseEntity<?> selectIdCheck(@RequestParam String id ) {
|
||||
return ResponseEntity.status(HttpStatus.OK).body(checkAdminIdPortIn.connect(id));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package app.module.admin.usecase.admin.excelSaveAdmin.adapters.web;
|
||||
|
||||
import app.module.core.usecase.admin.excelSaveAdmin.ports.ExcelSaveAdminPortIn;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
class ExcelSaveAdminController {
|
||||
|
||||
private final ExcelSaveAdminPortIn excelSaveAdminPortIn;
|
||||
|
||||
@PostMapping("/api/settings/admin/excelUpload")
|
||||
ResponseEntity<?> excelUploadSaveAdmin(@RequestParam("file") MultipartFile file ) throws IOException {
|
||||
return ResponseEntity.status(HttpStatus.OK).body(excelSaveAdminPortIn.operate(file));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package app.module.admin.usecase.admin.excelSaveAdmin.adapters.web.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ExcelAdminCreateVO {
|
||||
private String id;
|
||||
private String password;
|
||||
private String name;
|
||||
private String phone;
|
||||
private String regionMainCode;
|
||||
private String roleId;
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
<form method="post" name="adminParamForm" onsubmit="goSearch();"
|
||||
th:action="@{/settings/admins}"
|
||||
th:object="${listStatus}">
|
||||
|
||||
<div th:replace="admin/modal/modal-admin-excel:: modalFragment"></div>
|
||||
<!-- hidden parameters -->
|
||||
<input name="page" th:value="${listOutput.pageable.pageNumber}" type="hidden"/>
|
||||
<input name="sort" th:value="${listOutput.pageable.sort}" type="hidden"/>
|
||||
@@ -128,6 +128,9 @@
|
||||
|
||||
<div class="component-btns bottom-btn-group">
|
||||
<div class="btns-row align-right">
|
||||
<button class="btn" onclick="showAdminExcelUploadModal();" type="button">
|
||||
<span class="btn-txt">엑셀 업로드</span>
|
||||
</button>
|
||||
<button class="btn" onclick="goExcel();" type="button"><span class="btn-txt">엑셀 다운로드</span></button>
|
||||
<button class="btn" onclick="location.href='/settings/admins/create';" type="button"><span class="btn-txt">등록</span></button>
|
||||
<button class="btn" onclick="goRemove();" type="button"><span class="btn-txt">삭제</span></button>
|
||||
@@ -135,15 +138,10 @@
|
||||
</div>
|
||||
</section>
|
||||
</form>
|
||||
|
||||
</section>
|
||||
|
||||
<section layout:fragment="script">
|
||||
<!-- <script th:inline="javascript">
|
||||
// 목록 정렬 표기 및 갱신 기능 적용
|
||||
uiUtil.applyListSortNotation([[${listOutput.pageable.pageSize}]],
|
||||
[[${listOutput.pageable.sort.toString()}]]);
|
||||
</script>-->
|
||||
|
||||
<script th:inline="javascript">
|
||||
// 검색
|
||||
function goSearch() {
|
||||
@@ -211,6 +209,51 @@
|
||||
f.method = 'post';
|
||||
f.submit();
|
||||
}
|
||||
|
||||
|
||||
function showAdminExcelUploadModal() {
|
||||
const modal = document.querySelector(".modal02");
|
||||
modal.ui.open();
|
||||
|
||||
}
|
||||
const uploadAdminExcel = () => {
|
||||
event.preventDefault(); // 폼 기본 제출 방지
|
||||
|
||||
const fileInput = document.getElementById('file');
|
||||
|
||||
if (fileInput.files.length === 0) {
|
||||
alert('업로드할 엑셀 파일을 선택해주세요.');
|
||||
return;
|
||||
}
|
||||
|
||||
let formData = new FormData();
|
||||
formData.append('file', fileInput.files[0]);
|
||||
|
||||
const csrfToken = $("meta[name='_csrf']").attr("content");
|
||||
const csrfHeader = $("meta[name='_csrf_header']").attr("content");
|
||||
|
||||
console.log('FormData:', formData);
|
||||
debugger
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
url: '/api/settings/admin/excelUpload',
|
||||
data: formData,
|
||||
contentType: false, // * 중요 *
|
||||
processData: false, // * 중요 *
|
||||
enctype: 'multipart/form-data', // * 중요 *
|
||||
beforeSend: function (xhr) {
|
||||
xhr.setRequestHeader(
|
||||
$("meta[name='_csrf_header']").attr("content"),
|
||||
$("meta[name='_csrf']").attr("content"));
|
||||
},
|
||||
success(res) {
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const closeModal = () => {
|
||||
document.querySelector(".modal02").ui.close();
|
||||
};
|
||||
</script>
|
||||
</section>
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:th="http://www.thymeleaf.org"
|
||||
layout:decorate="~{layout/layout}">
|
||||
|
||||
<div class="layer-wrap" th:fragment="modalFragment">
|
||||
<div class="component-modal modal02" id="test" data-props-dimm-click="true" data-state="close">
|
||||
<div class="modal-dimm"></div>
|
||||
<div class="modal-frame">
|
||||
<div class="modal-container">
|
||||
<div class="modal-header">
|
||||
<h3 class="modal-tit" >엑셀 업로드</h3>
|
||||
</div>
|
||||
<div class="modal-content">
|
||||
<div class="modal-content-inner">
|
||||
<section>
|
||||
<form autocomplete="off" method="post" name="AdminExcelReqForm" id ="AdminExcelReqForm" enctype="multipart/form-data" action="/api/settings/admin/excelUpload">
|
||||
<label for="file" class="input-file-btn">
|
||||
<input type="file" name="file" id="file" accept=".xlsx, .xls">
|
||||
</label>
|
||||
<div class="component-btns bottom-btn-group" th:fragment="modalButtons">
|
||||
<div class="btns-row align-right">
|
||||
<button type="button" class="btn btn-primary" onclick="uploadAdminExcel()">
|
||||
<span class="btn-txt">등록</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
</div>
|
||||
<button class="modal-close" onclick="closeModal()"></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<section layout:fragment="script">
|
||||
<script th:inline="javascript">
|
||||
|
||||
</script>
|
||||
</section>
|
||||
</div>
|
||||
</html>
|
||||
Reference in New Issue
Block a user