Merge branch 'susu' into dev
This commit is contained in:
@@ -128,9 +128,6 @@
|
||||
|
||||
<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" th:unless="${activeProfile != 'local'}">엑셀 다운로드</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>
|
||||
@@ -138,7 +135,6 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div th:replace="admin/modal/modal-admin-excel:: modalFragment"></div>
|
||||
</form>
|
||||
|
||||
</section>
|
||||
@@ -214,61 +210,6 @@
|
||||
// f.submit();
|
||||
// }
|
||||
|
||||
function showAdminExcelUploadModal() {
|
||||
const modal = document.querySelector(".modal-admin-excel");
|
||||
const fileInput = document.getElementById("file");
|
||||
if (fileInput) {
|
||||
fileInput.value = '';
|
||||
}
|
||||
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]);
|
||||
|
||||
$.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) {
|
||||
alert("총 "+res.total+"건 중에 "+res.success+"건 등록되었습니다.");
|
||||
},
|
||||
statusCode: {
|
||||
400:() => {
|
||||
ajaxUtil._hideWaiting();
|
||||
alert("잘못된 엑셀파일입니다.");
|
||||
document.querySelector(".modal-admin-excel").ui.close();
|
||||
},
|
||||
500: () => {
|
||||
ajaxUtil._hideWaiting();
|
||||
alert("엑셀 업로드에 실패하였습니다.");
|
||||
document.querySelector(".modal-admin-excel").ui.close();
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const closeModal = () => {
|
||||
document.querySelector(".modal-admin-excel").ui.close();
|
||||
};
|
||||
</script>
|
||||
</section>
|
||||
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
layout:decorate="~{layout/layout}">
|
||||
|
||||
<div class="layer-wrap" th:fragment="modalFragment">
|
||||
<div class="component-modal modal01 modal-admin-excel" id="test" data-props-dimm-click="true" data-state="close">
|
||||
<div class="component-modal modal01 modal-researcher-excel" id="test" data-props-dimm-click="true" data-state="close">
|
||||
<div class="modal-dimm"></div>
|
||||
<div class="modal-frame">
|
||||
<div class="modal-container type-small">
|
||||
<div class="modal-header">
|
||||
<h3 class="modal-tit" >관리자 등록 엑셀업로드</h3>
|
||||
<h3 class="modal-tit">조사원 등록 엑셀업로드</h3>
|
||||
</div>
|
||||
<div class="modal-content">
|
||||
<div class="modal-content-inner">
|
||||
@@ -19,7 +19,7 @@
|
||||
</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()">
|
||||
<button type="button" class="btn btn-primary" onclick="uploadExcel()">
|
||||
<span class="btn-txt">등록</span>
|
||||
</button>
|
||||
</div>
|
||||
@@ -97,11 +97,15 @@
|
||||
|
||||
<div class="component-btns bottom-btn-group" >
|
||||
<div class="btns-row align-right">
|
||||
<button class="btn" onclick="showExcelUploadModal();" type="button">
|
||||
<span class="btn-txt">엑셀 업로드</span>
|
||||
</button>
|
||||
<button type="button" class="btn" onclick="goExcel();">
|
||||
<span class="btn-txt">엑셀 다운로드 <i class="ico-download ico-small" aria-hidden="true"></i></span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div th:replace="researcher/modal/modal-researcher-excel:: modalFragment"></div>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
@@ -238,6 +242,61 @@
|
||||
});
|
||||
}
|
||||
}
|
||||
function showExcelUploadModal() {
|
||||
const modal = document.querySelector(".modal-researcher-excel");
|
||||
const fileInput = document.getElementById("file");
|
||||
if (fileInput) {
|
||||
fileInput.value = '';
|
||||
}
|
||||
modal.ui.open();
|
||||
|
||||
}
|
||||
|
||||
const uploadExcel = () => {
|
||||
event.preventDefault();
|
||||
|
||||
const fileInput = document.getElementById('file');
|
||||
if (fileInput.files.length === 0) {
|
||||
alert('업로드할 엑셀 파일을 선택해주세요.');
|
||||
return;
|
||||
}
|
||||
|
||||
let formData = new FormData();
|
||||
formData.append('file', fileInput.files[0]);
|
||||
|
||||
$.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) {
|
||||
alert("총 "+res.total+"건 중에 "+res.success+"건 등록되었습니다.");
|
||||
},
|
||||
statusCode: {
|
||||
400:() => {
|
||||
ajaxUtil._hideWaiting();
|
||||
alert("잘못된 엑셀파일입니다.");
|
||||
document.querySelector(".modal-researcher-excel").ui.close();
|
||||
},
|
||||
500: () => {
|
||||
ajaxUtil._hideWaiting();
|
||||
alert("엑셀 업로드에 실패하였습니다.");
|
||||
document.querySelector(".modal-researcher-excel").ui.close();
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const closeModal = () => {
|
||||
document.querySelector(".modal-researcher-excel").ui.close();
|
||||
};
|
||||
</script>
|
||||
</section>
|
||||
|
||||
|
||||
@@ -42,4 +42,9 @@ public final class CommonConstants {
|
||||
*/
|
||||
public static final String VALID_CODE_NOTBLANK = "valid.common.required";
|
||||
|
||||
/**
|
||||
* 핸드폰 번호 규칙
|
||||
*/
|
||||
public static final String PHONE_REGEX = "^01([0|1|6|7|8|9])-?([0-9]{3,4})-?([0-9]{4})$";
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package app.module.core.usecase.admin.excelSaveAdmin.adapters.persistence;
|
||||
|
||||
import app.module.core.config.application.logging.SafeLogger;
|
||||
import app.module.core.config.application.util.AuditUtil;
|
||||
import app.module.core.config.application.util.CommonUtil;
|
||||
import app.module.core.config.constants.CommonConstants;
|
||||
import app.module.core.usecase.admin.checkAdminId.persistence.CheckAdminIdMapper;
|
||||
import app.module.core.usecase.admin.excelSaveAdmin.adapters.persistence.model.ExcelAdminCreateVO;
|
||||
import app.module.core.usecase.admin.excelSaveAdmin.adapters.persistence.model.ExcelResultVO;
|
||||
@@ -13,6 +15,7 @@ import app.module.core.usecase.uicode.list.adapters.persistence.UICodeListMapper
|
||||
import app.module.core.usecase.uicode.list.ports.application.domain.UICodeElement;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -21,11 +24,14 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
class ExcelSaveAdminIdDao implements ExcelSaveAdminPortOut {
|
||||
SafeLogger safeLogger = new SafeLogger(LoggerFactory.getLogger(ExcelSaveAdminIdDao.class));
|
||||
|
||||
@Value("${spring.profiles.active}")
|
||||
private String activeProfiles;
|
||||
|
||||
@@ -42,6 +48,8 @@ class ExcelSaveAdminIdDao implements ExcelSaveAdminPortOut {
|
||||
Sheet sheet = workbook.getSheetAt(0);
|
||||
Integer success = 0;
|
||||
List<UICodeElement> uiCodeElementList = uiCodeListMapper.findByParentId("code.region.main", CommonUtil.getLoginUserRole(),activeProfiles);
|
||||
List<String> errorList = new ArrayList<>();
|
||||
|
||||
// 첫 번째 행은 헤더로 간주하고 스킵
|
||||
for (int i = 1; i <= sheet.getLastRowNum(); i++) {
|
||||
Row row = sheet.getRow(i);
|
||||
@@ -57,7 +65,14 @@ class ExcelSaveAdminIdDao implements ExcelSaveAdminPortOut {
|
||||
|
||||
Integer duplicate = checkAdminIdMapper.checkAdminId(admin.getId());
|
||||
|
||||
if(duplicate == 0) {
|
||||
if(duplicate == 0
|
||||
&& !admin.getId().isEmpty()
|
||||
&& admin.getId().matches(CommonConstants.ADMIN_ID_REGEX)
|
||||
&& !admin.getRoleId().isEmpty()
|
||||
&& !admin.getPassword().isEmpty()
|
||||
&& admin.getPassword().matches(CommonConstants.ADMIN_PASSWORD_REGEX)
|
||||
&& !admin.getPhone().isEmpty()
|
||||
&& admin.getPhone().matches(CommonConstants.PHONE_REGEX) ) {
|
||||
SaveAdminCmd cmd = new SaveAdminCmd(
|
||||
null,
|
||||
admin.getId(),
|
||||
@@ -76,6 +91,18 @@ class ExcelSaveAdminIdDao implements ExcelSaveAdminPortOut {
|
||||
saveAdminMapper.insertAdminHasRoles(
|
||||
AuditUtil.create(new SaveAdminHasRoleParam(cmd.getSeq(), admin.getRoleId())));
|
||||
}
|
||||
}else{
|
||||
errorList.add(admin.getId());
|
||||
safeLogger.warn(
|
||||
"[EXCEL 누락] 관리자 아이디={} 필수 필드 누락: duplicate={}, role={}, name={}, password={}, regionMainCode={}, phone={} ",
|
||||
admin.getId(),
|
||||
duplicate == 0,
|
||||
admin.getRoleId(),
|
||||
admin.getName(),
|
||||
admin.getPassword(),
|
||||
admin.getRegionMainCode(),
|
||||
admin.getPhone()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +126,7 @@ class ExcelSaveAdminIdDao implements ExcelSaveAdminPortOut {
|
||||
case "관리자" -> "ROLE_ADMIN";
|
||||
case "지방실사" -> "ROLE_LOCAL_INSPECTOR";
|
||||
case "조사원" -> "ROLE_RESEARCHER";
|
||||
default -> "";
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -108,7 +135,7 @@ class ExcelSaveAdminIdDao implements ExcelSaveAdminPortOut {
|
||||
|
||||
return uiCodeElementList.stream().filter(code -> code.getCodeText().equals(cell.getStringCellValue().trim()))
|
||||
.findFirst()
|
||||
.map(UICodeElement::getId).orElse("");
|
||||
.map(UICodeElement::getId).orElse(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -608,7 +608,7 @@ as WITH param_matrix AS (
|
||||
SELECT p.household_seq,
|
||||
p.record_month,
|
||||
count(*) AS total_day_groups,
|
||||
case when to_char(CURRENT_DATE,'YYYYMM')::text = p.record_month then sum(case when to_char(CURRENT_DATE,'dd')::integer >= g.start_day then 1 else 0 end)else count(*) end as current_day_groups
|
||||
case when to_char(CURRENT_DATE,'YYYYMM')::text = p.record_month then sum(case when to_char(CURRENT_DATE,'dd')::integer >= g.start_day then 1 else 0 end) else count(*) end as current_day_groups
|
||||
FROM param_matrix p
|
||||
JOIN daily_day_group g ON g.start_day <= p.last_day
|
||||
GROUP BY p.household_seq, p.record_month;
|
||||
|
||||
@@ -62,9 +62,9 @@
|
||||
<when test="order.property eq 'endDate'">a.end_date</when>
|
||||
<when test="order.property eq 'updatedBy'">a.updated_by</when>
|
||||
<when test="order.property eq 'updatedAt'">a.updated_at</when>
|
||||
<when test="order.property eq 'createdBy'">a.created_by</when>
|
||||
<when test="order.property eq 'createdAt'">a.created_at</when>
|
||||
<otherwise>a.id</otherwise>
|
||||
<when test="order.property eq 'createdBy'">a.created_by</when>
|
||||
<when test="order.property eq 'createdAt'">a.created_at</when>
|
||||
<otherwise>a.id</otherwise>
|
||||
</choose>
|
||||
<choose>
|
||||
<when test="order.direction.toString() eq 'DESC'">DESC</when>
|
||||
|
||||
@@ -144,7 +144,7 @@
|
||||
<script th:inline="javascript">
|
||||
let ENV = {
|
||||
httpUrl: {
|
||||
root: /*[[|/record/daily/${reqVO.searchMonth}/${reqVO.groupNo}|]]*/'rootUrl',
|
||||
root: /*[[|/record/expense/${reqVO.searchMonth}/${reqVO.groupNo}|]]*/'rootUrl',
|
||||
form: /*[[|/record/expense/${reqVO.searchMonth}/${reqVO.groupNo}/form/{id}|]]*/'formUrl',
|
||||
create: /*[[|/api/record/expense/${reqVO.searchMonth}/${reqVO.groupNo}/form/{id}|]]*/'createUrl',
|
||||
remove: /*[[|/api/record/expense/${reqVO.searchMonth}/${reqVO.groupNo}/remove|]]*/'removeUrl',
|
||||
|
||||
@@ -158,7 +158,7 @@
|
||||
<script th:inline="javascript">
|
||||
let ENV = {
|
||||
httpUrl: {
|
||||
root: /*[[|/record/daily/${reqVO.searchMonth}/${reqVO.groupNo}|]]*/'rootUrl',
|
||||
root: /*[[|/record/income/${reqVO.searchMonth}/${reqVO.groupNo}|]]*/'rootUrl',
|
||||
form: /*[[|/record/income/${reqVO.searchMonth}/${reqVO.groupNo}/form/{id}|]]*/'formUrl',
|
||||
create: /*[[|/api/record/income/${reqVO.searchMonth}/${reqVO.groupNo}/form/{id}|]]*/'createUrl',
|
||||
remove: /*[[|/api/record/income/${reqVO.searchMonth}/${reqVO.groupNo}/remove|]]*/'removeUrl',
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<p th:if="${#lists.isEmpty(workList)}">임업노동 투입 내역을 등록해 주세요.</p>
|
||||
<p th:unless="${#lists.isEmpty(workList)}">등록 내용을 확인하거나 다음 단계로 이동하세요.</p>
|
||||
</hgroup>
|
||||
|
||||
-
|
||||
<!--/* 신규 등록 : dailyRecord.modifiable=false 수정 기간 아님 */-->
|
||||
<th:block th:if="${#lists.isEmpty(workList)}">
|
||||
<button type="button" class="btn btn-m btn-secondary btn-full button-modal01" data-testid="button-modal01"
|
||||
|
||||
Reference in New Issue
Block a user