Merge branch 'susu' into dev

This commit is contained in:
주수현
2025-07-23 14:28:10 +09:00
10 changed files with 104 additions and 72 deletions

View File

@@ -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})$";
}

View File

@@ -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);
}
}

View File

@@ -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;