Merge branch 'dev' into 'deploy-dev-front'

Dev

See merge request korea-research/korea-research!52
This commit is contained in:
김현주 개발
2025-06-26 07:01:57 +00:00
115 changed files with 1858 additions and 379 deletions

View File

@@ -113,7 +113,7 @@ recycle 의 demo 가 궁금하다면 아래 URL 에서 확인 해주세요.
-Dspring.datasource.username=ko_research -Dspring.datasource.username=ko_research
-Dspring.datasource.password=koresearch1@#4 -Dspring.datasource.password=koresearch1@#4
-Daes.secret-key=092HW829O0A0AVR0 -Daes.secret-key=092HW829O0A0AVR0
-Dpath.upload.storage=SFTP -Dpath.upload.storage=LOCAL
-Dpath.upload.sftp.public=/home/etribe/data/upload -Dpath.upload.sftp.public=/home/etribe/data/upload
-Dpath.upload.sftp.tmpdir=${user.home}/upload/tmpdir -Dpath.upload.sftp.tmpdir=${user.home}/upload/tmpdir
-Dfile.upload.sftp.ip=115.68.193.117 -Dfile.upload.sftp.ip=115.68.193.117
@@ -121,6 +121,9 @@ recycle 의 demo 가 궁금하다면 아래 URL 에서 확인 해주세요.
-Dfile.upload.sftp.password=Etribe@3415 -Dfile.upload.sftp.password=Etribe@3415
-Dfile.upload.sftp.port=22 -Dfile.upload.sftp.port=22
``` ```
** 주의 : 운영서버일 경우 -Dpath.upload.storage=SFTP로 설정
## JDBC 및 데이터 핸들링 구성 옵션 ## JDBC 및 데이터 핸들링 구성 옵션

View File

@@ -1,8 +1,8 @@
package app.module.admin.config.application.security; package app.module.admin.config.application.security;
import app.module.admin.usecase.loggedinuser.save.ports.LoggedInUserSavePortIn; import app.module.core.usecase.loggedinuser.save.ports.LoggedInUserSavePortIn;
import app.module.admin.usecase.loggedinuser.save.ports.application.domain.LoggedInUserIdSaveCmd; import app.module.core.usecase.loggedinuser.save.ports.application.domain.LoggedInUserIdSaveCmd;
import app.module.admin.usecase.loggedinuser.save.ports.application.domain.LoggedInUserSaveCmd; import app.module.core.usecase.loggedinuser.save.ports.application.domain.LoggedInUserSaveCmd;
import app.module.core.config.application.enums.AppType; import app.module.core.config.application.enums.AppType;
import app.module.core.config.application.util.CommonUtil; import app.module.core.config.application.util.CommonUtil;
import app.module.core.config.application.util.MessageUtil; import app.module.core.config.application.util.MessageUtil;

View File

@@ -0,0 +1,134 @@
package app.module.admin.config.application.util;
import app.module.admin.config.application.util.model.ExcelSheetDto;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.stereotype.Component;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.List;
@Component
public class ExcelWriterUtil {
public static byte[] writeExcel(List<ExcelSheetDto> sheets) {
try (Workbook workbook = new XSSFWorkbook()) {
CellStyle bodyStyle = createBodyStyle(workbook);
CellStyle commaStyle = createCommaStyle(workbook);
for (ExcelSheetDto sheetDto : sheets) {
Sheet sheet = workbook.createSheet(sheetDto.getSheetName());
List<String> headers = sheetDto.getHeaders();
List<List<String>> dataRows = sheetDto.getData();
// 헤더 작성
Row headerRow = sheet.createRow(0);
for (int col = 0; col < headers.size(); col++) {
String headerText = headers.get(col);
IndexedColors bgColor = sheetDto.getHeaderBgColors() != null
? sheetDto.getHeaderBgColors().getOrDefault(col, IndexedColors.GREY_25_PERCENT)
: IndexedColors.GREY_25_PERCENT;
CellStyle headerStyle = createHeaderStyle(workbook, bgColor);
Cell cell = headerRow.createCell(col);
cell.setCellValue(headerText);
cell.setCellStyle(headerStyle);
}
// 데이터 작성
for (int r = 0; r < dataRows.size(); r++) {
Row row = sheet.createRow(r + 1);
List<String> rowData = dataRows.get(r);
for (int c = 0; c < rowData.size(); c++) {
Cell cell = row.createCell(c);
String value = rowData.get(c);
if (sheetDto.getCommaColumns() != null &&
sheetDto.getCommaColumns().contains(c) &&
isNumeric(value)) {
cell.setCellValue(Double.parseDouble(value));
cell.setCellStyle(commaStyle);
} else {
cell.setCellValue(value);
cell.setCellStyle(bodyStyle);
}
}
}
// 컬럼 너비 수동 계산
for (int col = 0; col < headers.size(); col++) {
int maxLength = getByteLength(headers.get(col));
for (List<String> rowData : dataRows) {
if (col < rowData.size()) {
int length = getByteLength(rowData.get(col));
if (length > maxLength) {
maxLength = length;
}
}
}
sheet.setColumnWidth(col, (maxLength + 2) * 256);
}
}
ByteArrayOutputStream out = new ByteArrayOutputStream();
workbook.write(out);
return out.toByteArray();
} catch (IOException e) {
throw new RuntimeException("엑셀 생성 실패", e);
}
}
private static boolean isNumeric(String value) {
if (value == null) return false;
try {
Double.parseDouble(value);
return true;
} catch (NumberFormatException e) {
return false;
}
}
private static int getByteLength(String value) {
return value == null ? 0 : value.getBytes().length;
}
private static CellStyle createHeaderStyle(Workbook workbook, IndexedColors bgColor) {
CellStyle style = workbook.createCellStyle();
Font font = workbook.createFont();
font.setBold(true);
style.setFont(font);
style.setAlignment(HorizontalAlignment.CENTER);
style.setVerticalAlignment(VerticalAlignment.CENTER);
style.setFillForegroundColor(bgColor.getIndex());
style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
setBorder(style);
return style;
}
private static CellStyle createBodyStyle(Workbook workbook) {
CellStyle style = workbook.createCellStyle();
style.setAlignment(HorizontalAlignment.LEFT);
style.setVerticalAlignment(VerticalAlignment.CENTER);
setBorder(style);
return style;
}
private static CellStyle createCommaStyle(Workbook workbook) {
CellStyle style = workbook.createCellStyle();
style.setAlignment(HorizontalAlignment.RIGHT);
style.setVerticalAlignment(VerticalAlignment.CENTER);
style.setDataFormat(workbook.createDataFormat().getFormat("#,##0"));
setBorder(style);
return style;
}
private static void setBorder(CellStyle style) {
style.setBorderTop(BorderStyle.THIN);
style.setBorderBottom(BorderStyle.THIN);
style.setBorderLeft(BorderStyle.THIN);
style.setBorderRight(BorderStyle.THIN);
}
}

View File

@@ -0,0 +1,45 @@
package app.module.admin.config.application.util.model;
import org.apache.poi.ss.usermodel.IndexedColors;
import java.util.List;
import java.util.Set;
import java.util.Map;
public class ExcelSheetDto {
/**
* 시트명
*/
private String sheetName;
/**
* 테이블 해더 리스트
*/
private List<String> headers;
/**
* 데이터 리스트 (해더와 같아야 한다. 값이 없다면 null이라도 넣어줘야해요.)
*/
private List<List<String>> data;
/**
* 입력한 데이터 중 comma가 필요한 라인 선택 0 부터
*/
private Set<Integer> commaColumns;
/**
* 해더의 배경색 지정 : 0부터 시작
*/
private Map<Integer, IndexedColors> headerBgColors; // 💡 추가: 컬럼별 배경색
public ExcelSheetDto(String sheetName, List<String> headers, List<List<String>> data,
Set<Integer> commaColumns, Map<Integer, IndexedColors> headerBgColors) {
this.sheetName = sheetName;
this.headers = headers;
this.data = data;
this.commaColumns = commaColumns;
this.headerBgColors = headerBgColors;
}
public String getSheetName() { return sheetName; }
public List<String> getHeaders() { return headers; }
public List<List<String>> getData() { return data; }
public Set<Integer> getCommaColumns() { return commaColumns; }
public Map<Integer, IndexedColors> getHeaderBgColors() { return headerBgColors; }
}

View File

@@ -27,10 +27,7 @@ import java.util.stream.Collectors;
class AdminUpdatePostController { class AdminUpdatePostController {
private final AdminUpdateValidator adminUpdateValidator; private final AdminUpdateValidator adminUpdateValidator;
private final RoleListPortIn roleListPortIn;
private final UICodeListPortIn uiCodeListPortIn;
private final SaveAdminPortIn saveAdminPortIn; private final SaveAdminPortIn saveAdminPortIn;
private final MessageUtil messageUtil;
@PostMapping(path = "/api/settings/admin/update") @PostMapping(path = "/api/settings/admin/update")
ResponseEntity<?> operate( @RequestBody AdminUpdateBindingVO bindingVO, BindingResult bindingResult) { ResponseEntity<?> operate( @RequestBody AdminUpdateBindingVO bindingVO, BindingResult bindingResult) {

View File

@@ -40,7 +40,7 @@ class CreateNoticeDao implements CreateNoticePortOut {
mapper.createNotice(dto); mapper.createNotice(dto);
if (dto.getFileMappingId() != null && !dto.getFileMappingId().isEmpty()) { if (dto.getFileMappingId() != null && !dto.getFileMappingId().isEmpty()) {
mapper.createNoticeHasUploadFile(new CreateNoticeHasUploadFilesParam( mapper.createNoticeUploadFile(new CreateNoticeHasUploadFilesParam(
dto.getId(), dto.getId(),
dto.getFileMappingId().stream() dto.getFileMappingId().stream()
.map(Long::parseLong) .map(Long::parseLong)

View File

@@ -7,5 +7,5 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper @Mapper
public interface CreateNoticeMapper { public interface CreateNoticeMapper {
void createNotice(CreateNoticeDto dto); void createNotice(CreateNoticeDto dto);
void createNoticeHasUploadFile(CreateNoticeHasUploadFilesParam param); void createNoticeUploadFile(CreateNoticeHasUploadFilesParam param);
} }

View File

@@ -4,8 +4,10 @@ import app.module.admin.usecase.communication.notice.getNotice.ports.GetNoticePo
import app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNotice; import app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNotice;
import app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNoticeCmd; import app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNoticeCmd;
import app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNoticeUploadFile; import app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNoticeUploadFile;
import app.module.core.config.application.enums.FileStorageType;
import app.module.core.usecase.file.url.application.port.in.FileUrlPortIn; import app.module.core.usecase.file.url.application.port.in.FileUrlPortIn;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@@ -19,6 +21,8 @@ class GetNoticeDao implements GetNoticePortOut {
private final GetNoticeMapper mapper; private final GetNoticeMapper mapper;
private final FileUrlPortIn fileUrlPortIn; private final FileUrlPortIn fileUrlPortIn;
@Value("${path.upload.storage}")
private String uploadStorageType;
@Override @Override
@Transactional @Transactional
@@ -35,13 +39,13 @@ class GetNoticeDao implements GetNoticePortOut {
// 참조 URL 전달 // 참조 URL 전달
uploadFile.setReferURL( uploadFile.setReferURL(
fileUrlPortIn.getInline( fileUrlPortIn.getInline(
uploadFile.getType().getFileStorageType(), FileStorageType.valueOf(uploadStorageType),
uploadFile.getPath(), uploadFile.getPath(),
uploadFile.getName())); uploadFile.getName()));
// attachment URL 전달 // attachment URL 전달
uploadFile.setAttachmentURL( uploadFile.setAttachmentURL(
fileUrlPortIn.getAttachment( fileUrlPortIn.getAttachment(
uploadFile.getType().getFileStorageType(), uploadFile.getId())); FileStorageType.valueOf(uploadStorageType), uploadFile.getId()));
return uploadFile; return uploadFile;
}) })

View File

@@ -20,7 +20,7 @@ class RemoveNoticesDao implements RemoveNoticesPortOut {
String loginUser = CommonUtil.getLoginUsername();; String loginUser = CommonUtil.getLoginUsername();;
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
mapper.deleteNoticeHasFiles( mapper.deleteNoticeUploadFiles(
new RemoveNoticesParam(command.getRemoveIds(), now, loginUser, now, loginUser)); new RemoveNoticesParam(command.getRemoveIds(), now, loginUser, now, loginUser));
mapper.deleteNotices( mapper.deleteNotices(
new RemoveNoticesParam(command.getRemoveIds(), now, loginUser, now, loginUser)); new RemoveNoticesParam(command.getRemoveIds(), now, loginUser, now, loginUser));

View File

@@ -6,5 +6,5 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper @Mapper
public interface RemoveNoticesMapper { public interface RemoveNoticesMapper {
void deleteNotices(RemoveNoticesParam param); void deleteNotices(RemoveNoticesParam param);
void deleteNoticeHasFiles(RemoveNoticesParam param); void deleteNoticeUploadFiles(RemoveNoticesParam param);
} }

View File

@@ -1,27 +1,27 @@
package app.module.admin.usecase.communication.notice.updateNotice.adapters.persistence; package app.module.admin.usecase.communication.notice.updateNotice.adapters.persistence;
import app.module.admin.usecase.communication.notice.updateNotice.adapters.persistence.model.CreateUploadFileParam;
import app.module.admin.usecase.communication.notice.updateNotice.adapters.persistence.model.UpdateNoticeDto; import app.module.admin.usecase.communication.notice.updateNotice.adapters.persistence.model.UpdateNoticeDto;
import app.module.admin.usecase.communication.notice.updateNotice.ports.UpdateNoticePortOut; import app.module.admin.usecase.communication.notice.updateNotice.ports.UpdateNoticePortOut;
import app.module.admin.usecase.communication.notice.updateNotice.ports.application.domain.UpdateNoticeCmd; import app.module.admin.usecase.communication.notice.updateNotice.ports.application.domain.UpdateNoticeCmd;
import app.module.core.config.adapters.persistence.entity.NoticeHasUploadFile; import app.module.core.config.application.annotation.UpdateCommand;
import app.module.core.config.application.util.CommonUtil; import app.module.core.config.application.util.CommonUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@Slf4j
@Repository @Repository
@RequiredArgsConstructor @RequiredArgsConstructor
class UpdateNoticeDao implements UpdateNoticePortOut { class UpdateNoticeDao implements UpdateNoticePortOut {
private final UpdateNoticeMapper mapper; private final UpdateNoticeMapper mapper;
@Override @Override
@UpdateCommand
public void operate(UpdateNoticeCmd command) { public void operate(UpdateNoticeCmd command) {
mapper.updateNotice( mapper.updateNotice(
new UpdateNoticeDto( new UpdateNoticeDto(
command.getId(), command.getId(),
command.getTitle(), command.getTitle(),
@@ -34,21 +34,5 @@ class UpdateNoticeDao implements UpdateNoticePortOut {
CommonUtil.getLoginUsername() CommonUtil.getLoginUsername()
)); ));
// 첨부파일 초기화
mapper.deleteFileUploads(new NoticeHasUploadFile(command.getId()));
// 첨부파일 있을 시, 등록
if (command.getFileMappingId() != null && !command.getFileMappingId().isEmpty()) {
mapper.createFileUploads(new CreateUploadFileParam(
command.getId(),
command.getFileMappingId().stream()
.map(Long::parseLong)
.toList(),
LocalDateTime.now(),
CommonUtil.getLoginUsername(),
LocalDateTime.now(),
CommonUtil.getLoginUsername()
));
}
} }
} }

View File

@@ -1,14 +1,9 @@
package app.module.admin.usecase.communication.notice.updateNotice.adapters.persistence; package app.module.admin.usecase.communication.notice.updateNotice.adapters.persistence;
import app.module.admin.usecase.communication.notice.updateNotice.adapters.persistence.model.CreateUploadFileParam;
import app.module.admin.usecase.communication.notice.updateNotice.adapters.persistence.model.UpdateNoticeDto; import app.module.admin.usecase.communication.notice.updateNotice.adapters.persistence.model.UpdateNoticeDto;
import app.module.core.config.adapters.persistence.entity.ArticleHasUploadFile;
import app.module.core.config.adapters.persistence.entity.NoticeHasUploadFile;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@Mapper @Mapper
public interface UpdateNoticeMapper { public interface UpdateNoticeMapper {
void updateNotice(UpdateNoticeDto dto); void updateNotice(UpdateNoticeDto dto);
void deleteFileUploads(NoticeHasUploadFile noticeHasUploadFile);
void createFileUploads(CreateUploadFileParam param);
} }

View File

@@ -1,18 +0,0 @@
package app.module.admin.usecase.communication.notice.updateNotice.adapters.persistence.model;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.time.LocalDateTime;
import java.util.List;
@Getter
@AllArgsConstructor
public class CreateUploadFileParam {
private Long id;
private List<Long> fileMappingId;
private LocalDateTime createdAt;
private String createdBy;
private LocalDateTime updatedAt;
private String updatedBy;
}

View File

@@ -3,6 +3,9 @@ package app.module.admin.usecase.communication.notice.updateNotice.adapters.web;
import app.module.admin.usecase.communication.notice.updateNotice.adapters.web.model.UpdateNoticeReqVO; import app.module.admin.usecase.communication.notice.updateNotice.adapters.web.model.UpdateNoticeReqVO;
import app.module.admin.usecase.communication.notice.updateNotice.ports.UpdateNoticePortIn; import app.module.admin.usecase.communication.notice.updateNotice.ports.UpdateNoticePortIn;
import app.module.admin.usecase.communication.notice.updateNotice.ports.application.domain.UpdateNoticeCmd; import app.module.admin.usecase.communication.notice.updateNotice.ports.application.domain.UpdateNoticeCmd;
import app.module.core.config.application.enums.FileUploadType;
import app.module.core.usecase.file.updateFile.ports.UpdateFilePortIn;
import app.module.core.usecase.file.updateFile.ports.application.domain.UpdateFileCmd;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@@ -16,6 +19,7 @@ import org.springframework.web.bind.annotation.RestController;
@RequiredArgsConstructor @RequiredArgsConstructor
class UpdateNoticeController { class UpdateNoticeController {
private final UpdateNoticePortIn updateNoticePortIn; private final UpdateNoticePortIn updateNoticePortIn;
private final UpdateFilePortIn updateFilePortIn;
@PutMapping(path = "/api/communication/notices/update") @PutMapping(path = "/api/communication/notices/update")
ResponseEntity<?> operate(@RequestBody @Valid UpdateNoticeReqVO reqVO, BindingResult bindingResult) { ResponseEntity<?> operate(@RequestBody @Valid UpdateNoticeReqVO reqVO, BindingResult bindingResult) {
@@ -26,6 +30,13 @@ class UpdateNoticeController {
.body(bindingResult.getFieldErrors()); .body(bindingResult.getFieldErrors());
} }
updateFilePortIn.operate(
new UpdateFileCmd(
reqVO.getId(),
reqVO.getFileMappingId().stream().map(Long::parseLong).toList(),
FileUploadType.NOTICE)
);
updateNoticePortIn.operate( updateNoticePortIn.operate(
new UpdateNoticeCmd( new UpdateNoticeCmd(
reqVO.getId(), reqVO.getId(),
@@ -34,8 +45,8 @@ class UpdateNoticeController {
reqVO.getVisible(), reqVO.getVisible(),
reqVO.getStartDate(), reqVO.getStartDate(),
reqVO.getEndDate(), reqVO.getEndDate(),
reqVO.getFileMappingId() reqVO.getFileMappingId())
)); );
return ResponseEntity.status(HttpStatus.OK).body(reqVO); return ResponseEntity.status(HttpStatus.OK).body(reqVO);
} }

View File

@@ -1,11 +1,13 @@
package app.module.admin.usecase.editor.adapters.web; package app.module.admin.usecase.editor.adapters.web;
import app.module.core.config.application.enums.FileStorageType;
import app.module.core.config.application.enums.FileUploadType; import app.module.core.config.application.enums.FileUploadType;
import app.module.core.usecase.file.saveToStorage.ports.SaveToStoragePortIn; import app.module.core.usecase.file.saveToStorage.ports.SaveToStoragePortIn;
import app.module.core.usecase.file.saveToStorage.ports.application.domain.SaveToStorage; import app.module.core.usecase.file.saveToStorage.ports.application.domain.SaveToStorage;
import app.module.core.usecase.file.url.application.port.in.FileUrlPortIn; import app.module.core.usecase.file.url.application.port.in.FileUrlPortIn;
import java.io.IOException; import java.io.IOException;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
@@ -18,6 +20,8 @@ public class EditorImageUploadController {
private final SaveToStoragePortIn saveToStoragePortIn; private final SaveToStoragePortIn saveToStoragePortIn;
private final FileUrlPortIn fileUrlPortIn; private final FileUrlPortIn fileUrlPortIn;
@Value("${path.upload.storage}")
private String uploadStorageType;
@PostMapping(path = "/api/editorImage/upload") @PostMapping(path = "/api/editorImage/upload")
ResponseEntity<?> editorImageUpload(MultipartFile editorImage) throws IOException { ResponseEntity<?> editorImageUpload(MultipartFile editorImage) throws IOException {
@@ -27,7 +31,7 @@ public class EditorImageUploadController {
return ResponseEntity.status(HttpStatus.OK) return ResponseEntity.status(HttpStatus.OK)
.body( .body(
fileUrlPortIn.getInline( fileUrlPortIn.getInline(
saveToStorage.getType().getFileStorageType(), FileStorageType.valueOf(uploadStorageType),
saveToStorage.getPath(), saveToStorage.getPath(),
saveToStorage.getName())); saveToStorage.getName()));
} }

View File

@@ -0,0 +1,124 @@
package app.module.admin.usecase.excel.getExcelMultilSheet.adapters.web;
import app.module.admin.config.application.util.model.ExcelSheetDto;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import app.module.admin.config.application.util.ExcelWriterUtil;
import java.util.List;
import java.util.Set;
import org.apache.poi.ss.usermodel.IndexedColors;
import java.util.Map;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
@RestController
@RequiredArgsConstructor
class GetExcelMultiSheetController {
@GetMapping("/api/admin/excel/multisheet")
public ResponseEntity<byte[]> exportHouseholdExcel() {
// 시트 1: 조사 대상 목록 (타이틀 10개)
ExcelSheetDto sheet1 = new ExcelSheetDto(
"조사 대상",
List.of("ID", "이름", "성별", "나이", "주소", "전화번호", "이메일", "등록일", "상태", "비고"),
List.of(
List.of("1", "홍길동", "남", "30", "서울", "010-1234-5678", "hong@example.com", "2024-01-01", "완료", ""),
List.of("2", "김영희", "여", "28", "부산", "010-2222-3333", "kim@example.com", "2024-01-02", "미완료", "응답 거부")
),
Set.of(3), // 나이 컬럼에 콤마 포맷 적용 (예시용)
Map.of(
0, IndexedColors.LIGHT_CORNFLOWER_BLUE,
3, IndexedColors.LIGHT_YELLOW,
7, IndexedColors.LIGHT_ORANGE
)
);
/*
취득 데이터는 변환해서 넣어줘도 됩니다.
List<Household> rawList = ... // List<Object>를 캐스팅 or 변환
List<List<String>> excelData = rawList.stream()
.map(dto -> List.of(
String.valueOf(dto.getId()),
dto.getName(),
dto.getGender(),
String.valueOf(dto.getAge()),
dto.getAddress(),
dto.getPhone(),
dto.getEmail(),
dto.getRegDate().toString(),
dto.getStatus(),
dto.getNote()
))
.toList();
ExcelSheetDto sheet = new ExcelSheetDto(
"조사 대상",
List.of("ID", "이름", "성별", "나이", "주소", "전화번호", "이메일", "등록일", "상태", "비고"),
excelData, // <----------------------------------@@@@@@@@@@@@@@@@
Set.of(3),
Map.of(
0, IndexedColors.LIGHT_CORNFLOWER_BLUE,
3, IndexedColors.LIGHT_YELLOW,
7, IndexedColors.LIGHT_ORANGE
)
);
*/
// 시트 2: 응답 통계 (타이틀 7개)
ExcelSheetDto sheet2 = new ExcelSheetDto(
"응답 통계",
List.of("구분", "총건수", "응답수", "미응답", "응답률", "평균시간", "비고"),
List.of(
List.of("전체", "1000", "850", "150", "85%", "5분", ""),
List.of("서울", "400", "360", "40", "90%", "4분", "")
),
Set.of(1, 2, 3), // 숫자열에 콤마 포맷 적용
Map.of(
1, IndexedColors.LIGHT_GREEN,
2, IndexedColors.LIGHT_GREEN,
3, IndexedColors.LIGHT_YELLOW
)
);
// 시트 3: 조사자별 실적 (타이틀 5개)
ExcelSheetDto sheet3 = new ExcelSheetDto(
"조사자 실적",
List.of("조사자명", "조사건수", "완료건수", "진행률", "비고"),
List.of(
List.of("박조사", "200", "180", "90%", ""),
List.of("이조사", "150", "100", "66.6%", "")
),
Set.of(1, 2), // 조사건수, 완료건수에 콤마 포맷
Map.of(
0, IndexedColors.LIGHT_TURQUOISE,
1, IndexedColors.LIGHT_ORANGE,
2, IndexedColors.LIGHT_ORANGE
)
);
// 시트 모음
List<ExcelSheetDto> sheets = List.of(sheet1, sheet2, sheet3);
byte[] excel = ExcelWriterUtil.writeExcel(sheets);
String rawFileName = "조사결과_" + LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")) + ".xlsx";
String encodedFileName = URLEncoder.encode(rawFileName, StandardCharsets.UTF_8).replaceAll("\\+", "%20");
return ResponseEntity.ok()
.contentType(MediaType.APPLICATION_OCTET_STREAM)
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename*=UTF-8''" + encodedFileName)
.body(excel);
}
}

View File

@@ -11,6 +11,7 @@ import lombok.Setter;
@EqualsAndHashCode @EqualsAndHashCode
public class GetDailyRecordsStatus { public class GetDailyRecordsStatus {
private Long id; private Long id;
private Integer dayGroupNo;
private String dayGroup; private String dayGroup;
private RecordStatusType allStatusType; private RecordStatusType allStatusType;
private String incomeStatus; private String incomeStatus;

View File

@@ -0,0 +1,47 @@
package app.module.admin.usecase.household.tab.dailyRecord.updateDailyNone.adapters.persistence;
import app.module.admin.usecase.household.tab.dailyRecord.updateDailyNone.ports.UpdateDailyNonePortOut;
import app.module.admin.usecase.household.tab.dailyRecord.updateDailyNone.ports.application.domain.UpdateDailyNoneCmd;
import app.module.core.config.application.enums.DailySort;
import app.module.core.config.application.enums.DailyTargetStatus;
import app.module.core.usecase.daily.record.ports.DailyRecordPortIn;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;
@Slf4j
@Repository
@RequiredArgsConstructor
class UpdateDailyNoneDao implements UpdateDailyNonePortOut {
private final UpdateDailyNoneMapper mapper;
private final DailyRecordPortIn dailyRecordPortIn;
@Override
public void create(UpdateDailyNoneCmd command) {
command.setDailyRecordSeq(mapper.getDailyRecordSeq(command));
if (command.getCurrentStep() != null) {
if (DailyTargetStatus.TODAY_NONE.equals(command.getCurrentStatus())) {
// 등록된 데이터 일괄 삭제
if (DailySort.INCOME.equals(command.getCurrentStep())) {
mapper.removeDailyIncome(command);
} else if (DailySort.WORK.equals(command.getCurrentStep())) {
mapper.removeDailyWork(command);
} else if (DailySort.EXPENSE.equals(command.getCurrentStep())) {
mapper.removeDailyExpense(command);
} else if (DailySort.POWER.equals(command.getCurrentStep())) {
mapper.removeDailyPower(command);
} else if (DailySort.FORESTRY.equals(command.getCurrentStep())) {
mapper.removeDailyForestry(command);
} else if (DailySort.FARMING.equals(command.getCurrentStep())) {
mapper.removeDailyFarming(command);
}
}
dailyRecordPortIn.updateByStatus(command.getSearchMonth(), command.getGroupNo(), command.getHouseholdSeq(), command.getCurrentStep().name(), command.getCurrentStatus().name());
} else {
log.error("[CreateDailyNone] Current step is null. cmd:{}", command);
}
}
}

View File

@@ -0,0 +1,51 @@
package app.module.admin.usecase.household.tab.dailyRecord.updateDailyNone.adapters.persistence;
import app.module.admin.usecase.household.tab.dailyRecord.updateDailyNone.ports.application.domain.UpdateDailyNoneCmd;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface UpdateDailyNoneMapper {
/**
* 일계부 항목 일련번호 조회
*
* @param command 검색 조건
* @return 일계부 항목 일련번호
*/
Long getDailyRecordSeq(UpdateDailyNoneCmd command);
/**
* 특정일의 수입 전체 삭제
* @param command 검색 조건
*/
void removeDailyIncome(UpdateDailyNoneCmd command);
/**
* 특정일의 임업노동 투입 전체 삭제
* @param command 검색 조건
*/
void removeDailyWork(UpdateDailyNoneCmd command);
/**
* 특정일의 지출 전체 삭제
* @param command 검색 조건
*/
void removeDailyExpense(UpdateDailyNoneCmd command);
/**
* 동력 사용시간 전체 삭제
* @param command 검색 조건
*/
void removeDailyPower(UpdateDailyNoneCmd command);
/**
* 자가임업 생산물 중 자가소비량 전체 삭제
* @param command 검색 조건
*/
void removeDailyForestry(UpdateDailyNoneCmd command);
/**
* 자가농업 생산물 중 자가소비량 전체 삭제
* @param command 검색 조건
*/
void removeDailyFarming(UpdateDailyNoneCmd command);
}

View File

@@ -0,0 +1,27 @@
package app.module.admin.usecase.household.tab.dailyRecord.updateDailyNone.adapters.web;
import app.module.admin.usecase.household.tab.dailyRecord.updateDailyNone.adapters.web.modal.UpdateDailyNoneReqVO;
import app.module.admin.usecase.household.tab.dailyRecord.updateDailyNone.ports.UpdateDailyNonePortIn;
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.RequestBody;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController
@RequiredArgsConstructor
class UpdateDailyNoneController {
private final UpdateDailyNonePortIn updateDailyNonePortIn;
@PostMapping(path = "/api/household/daily/today-none")
ResponseEntity<?> create(@RequestBody UpdateDailyNoneReqVO formVO) {
log.debug("formVO: {}", formVO);
updateDailyNonePortIn.create(formVO);
return ResponseEntity.status(HttpStatus.OK).body(formVO);
}
}

View File

@@ -0,0 +1,24 @@
package app.module.admin.usecase.household.tab.dailyRecord.updateDailyNone.adapters.web.modal;
import app.module.core.config.application.enums.DailySort;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@Getter
@Setter
@ToString
public class UpdateDailyNoneReqVO {
private String recordMonth;
private Integer groupNo;
private Long householdSeq;
/**
* 현재 단계
*/
private DailySort currentStep;
/**
* 금일 데이터 없음 여부 (Y/N)
*/
private String todayNone;
}

View File

@@ -0,0 +1,12 @@
package app.module.admin.usecase.household.tab.dailyRecord.updateDailyNone.ports;
import app.module.admin.usecase.household.tab.dailyRecord.updateDailyNone.adapters.web.modal.UpdateDailyNoneReqVO;
public interface UpdateDailyNonePortIn {
/**
* 일계부 금일 데이터 없음 등록
*
* @param formVO 입력 데이터
*/
void create(UpdateDailyNoneReqVO formVO);
}

View File

@@ -0,0 +1,12 @@
package app.module.admin.usecase.household.tab.dailyRecord.updateDailyNone.ports;
import app.module.admin.usecase.household.tab.dailyRecord.updateDailyNone.ports.application.domain.UpdateDailyNoneCmd;
public interface UpdateDailyNonePortOut {
/**
* 일계부 금일 데이터 없음 등록
*
* @param command 입력 데이터
*/
void create(UpdateDailyNoneCmd command);
}

View File

@@ -0,0 +1,33 @@
package app.module.admin.usecase.household.tab.dailyRecord.updateDailyNone.ports.application;
import app.module.admin.usecase.household.tab.dailyRecord.updateDailyNone.adapters.web.modal.UpdateDailyNoneReqVO;
import app.module.admin.usecase.household.tab.dailyRecord.updateDailyNone.ports.UpdateDailyNonePortIn;
import app.module.admin.usecase.household.tab.dailyRecord.updateDailyNone.ports.UpdateDailyNonePortOut;
import app.module.admin.usecase.household.tab.dailyRecord.updateDailyNone.ports.application.domain.UpdateDailyNoneCmd;
import app.module.core.config.application.enums.DailyTargetStatus;
import app.module.core.config.application.util.AuditUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
public class UpdateDailyNoneService implements UpdateDailyNonePortIn {
private final UpdateDailyNonePortOut portOut;
@Override
public void create(UpdateDailyNoneReqVO formVO) {
DailyTargetStatus currentStatus = "Y".equals(formVO.getTodayNone()) ? DailyTargetStatus.TODAY_NONE : DailyTargetStatus.TARGET;
UpdateDailyNoneCmd command = AuditUtil.update(
new UpdateDailyNoneCmd(
formVO.getRecordMonth(),
formVO.getGroupNo(),
formVO.getHouseholdSeq(),
formVO.getCurrentStep(),
currentStatus,
null)
);
portOut.create(command);
}
}

View File

@@ -0,0 +1,30 @@
package app.module.admin.usecase.household.tab.dailyRecord.updateDailyNone.ports.application.domain;
import app.module.core.config.adapters.persistence.component.AuditCommand;
import app.module.core.config.application.enums.DailySort;
import app.module.core.config.application.enums.DailyTargetStatus;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
public class UpdateDailyNoneCmd extends AuditCommand {
private String searchMonth;
private Integer groupNo;
private Long householdSeq;
/**
* 현재 단계
*/
private DailySort currentStep;
/**
* 현재 입력상태
*/
private DailyTargetStatus currentStatus;
/**
* 일계부 항목 일련번호
*/
private Long dailyRecordSeq;
}

View File

@@ -4,6 +4,7 @@ import app.module.admin.usecase.household.tab.forestProduct.getForestProductsSta
import app.module.admin.usecase.household.tab.forestProduct.getForestProductsStatus.ports.application.domain.GetForestProductsStatus; import app.module.admin.usecase.household.tab.forestProduct.getForestProductsStatus.ports.application.domain.GetForestProductsStatus;
import app.module.admin.usecase.household.tab.forestProduct.getForestProductsStatus.ports.application.domain.GetForestProductsStatusCmd; import app.module.admin.usecase.household.tab.forestProduct.getForestProductsStatus.ports.application.domain.GetForestProductsStatusCmd;
import app.module.admin.usecase.household.tab.forestProduct.getForestProductsStatus.ports.application.domain.GetForestProductsStatusResult; import app.module.admin.usecase.household.tab.forestProduct.getForestProductsStatus.ports.application.domain.GetForestProductsStatusResult;
import app.module.admin.usecase.household.tab.forestProduct.getForestProductsStatus.ports.application.domain.GetMonthlyForestProductsStatus;
import java.util.List; import java.util.List;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
@@ -17,7 +18,7 @@ class GetForestProductsStatusDao implements GetForestProductsStatusPortOut {
public GetForestProductsStatusResult operate(GetForestProductsStatusCmd cmd) { public GetForestProductsStatusResult operate(GetForestProductsStatusCmd cmd) {
// 임산물 등록 상태 조회 // 임산물 등록 상태 조회
String monthlyStatus = mapper.getMonthlyStatus(cmd); GetMonthlyForestProductsStatus monthlyStatus = mapper.getMonthlyStatus(cmd);
// 임산물 목록 조회 // 임산물 목록 조회
List<GetForestProductsStatus> forestProducts = mapper.getForestProductsStatus(cmd); List<GetForestProductsStatus> forestProducts = mapper.getForestProductsStatus(cmd);

View File

@@ -2,11 +2,12 @@ package app.module.admin.usecase.household.tab.forestProduct.getForestProductsSt
import app.module.admin.usecase.household.tab.forestProduct.getForestProductsStatus.ports.application.domain.GetForestProductsStatus; import app.module.admin.usecase.household.tab.forestProduct.getForestProductsStatus.ports.application.domain.GetForestProductsStatus;
import app.module.admin.usecase.household.tab.forestProduct.getForestProductsStatus.ports.application.domain.GetForestProductsStatusCmd; import app.module.admin.usecase.household.tab.forestProduct.getForestProductsStatus.ports.application.domain.GetForestProductsStatusCmd;
import app.module.admin.usecase.household.tab.forestProduct.getForestProductsStatus.ports.application.domain.GetMonthlyForestProductsStatus;
import java.util.List; import java.util.List;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@Mapper @Mapper
public interface GetForestProductsStatusMapper { public interface GetForestProductsStatusMapper {
String getMonthlyStatus(GetForestProductsStatusCmd cmd); GetMonthlyForestProductsStatus getMonthlyStatus(GetForestProductsStatusCmd cmd);
List<GetForestProductsStatus> getForestProductsStatus(GetForestProductsStatusCmd cmd); List<GetForestProductsStatus> getForestProductsStatus(GetForestProductsStatusCmd cmd);
} }

View File

@@ -11,6 +11,6 @@ import lombok.Setter;
@AllArgsConstructor @AllArgsConstructor
@EqualsAndHashCode @EqualsAndHashCode
public class GetForestProductsStatusResult { public class GetForestProductsStatusResult {
private String monthlyStatus; private GetMonthlyForestProductsStatus monthlyStatus;
private List<GetForestProductsStatus> forestProducts; private List<GetForestProductsStatus> forestProducts;
} }

View File

@@ -0,0 +1,15 @@
package app.module.admin.usecase.household.tab.forestProduct.getForestProductsStatus.ports.application.domain;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class GetMonthlyForestProductsStatus {
private Long id;
private String forestStatus;
}

View File

@@ -0,0 +1,24 @@
package app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.adapters.persistence;
import app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.ports.SaveForestProductPortOut;
import app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.ports.application.domain.SaveForestProductCmd;
import app.module.core.config.application.util.AuditUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
@Repository
@RequiredArgsConstructor
class SaveForestProductDao implements SaveForestProductPortOut {
private final SaveForestProductMapper mapper;
@Override
@Transactional
public void operate(SaveForestProductCmd inCmd) {
if (inCmd.getForestProductId() == null) {
mapper.createForestProduct(AuditUtil.create(inCmd));
} else {
mapper.updateForestProduct(AuditUtil.update(inCmd));
}
}
}

View File

@@ -0,0 +1,10 @@
package app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.adapters.persistence;
import app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.ports.application.domain.SaveForestProductCmd;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface SaveForestProductMapper {
void createForestProduct(SaveForestProductCmd cmd);
void updateForestProduct(SaveForestProductCmd cmd);
}

View File

@@ -0,0 +1,61 @@
package app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.adapters.web;
import app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.ports.SaveForestProductPortIn;
import app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.ports.application.domain.SaveForestProductCmd;
import app.module.core.config.application.util.MessageUtil;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.validation.BindingResult;
import app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.adapters.web.model.SaveForestProductReqVO;
import app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.adapters.web.model.SaveForestProductResVO;
import app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.adapters.web.validator.SaveForestProductValidator;
@RestController
@RequiredArgsConstructor
class SaveForestProductController {
private final SaveForestProductValidator validator;
private final SaveForestProductPortIn portIn;
private final MessageUtil messageUtil;
@PostMapping(path = "/api/forestProduct/save")
ResponseEntity<?> operate(@Valid @RequestBody SaveForestProductReqVO reqVO,
BindingResult bindingResult) {
validator.validate(reqVO, bindingResult);
if (bindingResult.hasErrors()) {
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
.body(bindingResult.getFieldErrors());
}
portIn.operate(new SaveForestProductCmd(
reqVO.getForestProductId(),
reqVO.getHouseholdSeq(),
reqVO.getMonthlyInputStatusId(),
reqVO.getRecordMonth(),
reqVO.getStreetNum(),
reqVO.getLandType(),
reqVO.getTown(),
reqVO.getCropName(),
reqVO.getLandArea(),
reqVO.getAvailableArea(),
reqVO.getMainYield(),
reqVO.getMainYieldUnitCode(),
reqVO.getMainYieldUnit(),
reqVO.getMainSaleAmount(),
reqVO.getMainSaleUnitCode(),
reqVO.getMainSaleUnit(),
reqVO.getSubYield(),
reqVO.getSubYieldUnitCode(),
reqVO.getSubYieldUnit(),
reqVO.getSubSaleAmount(),
reqVO.getSubSaleUnitCode(),
reqVO.getSubSaleUnit()));
return ResponseEntity.status(HttpStatus.OK).body(
new SaveForestProductResVO(messageUtil.getMessage("operation.common.save.done")));
}
}

View File

@@ -0,0 +1,37 @@
package app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.adapters.web.model;
import jakarta.validation.constraints.NotBlank;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
@EqualsAndHashCode
public class SaveForestProductReqVO {
private Long forestProductId;
private Long householdSeq;
private Long monthlyInputStatusId;
private String recordMonth;
private String streetNum;
private String landType;
private String town;
private String cropName;
private String landArea;
private String availableArea;
private String mainYield;
private String mainYieldUnitCode;
private String mainYieldUnit;
private String mainSaleAmount;
private String mainSaleUnitCode;
private String mainSaleUnit;
private String subYield;
private String subYieldUnitCode;
private String subYieldUnit;
private String subSaleAmount;
private String subSaleUnitCode;
private String subSaleUnit;
}

View File

@@ -0,0 +1,14 @@
package app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.adapters.web.model;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class SaveForestProductResVO {
private String message;
}

View File

@@ -0,0 +1,25 @@
package app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.adapters.web.validator;
import app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.adapters.web.model.SaveForestProductReqVO;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;
@Component
public class SaveForestProductValidator implements Validator {
@Override
public boolean supports(Class<?> clazz) {
return SaveForestProductReqVO.class.equals(clazz);
}
@Override
public void validate(Object target, Errors errors) {
SaveForestProductReqVO vo = (SaveForestProductReqVO) target;
if (!StringUtils.hasText(vo.getCropName())) {
errors.rejectValue("cropName", "error.cropName", "재배 작물명을 입력해주세요.");
}
}
}

View File

@@ -0,0 +1,7 @@
package app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.ports;
import app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.ports.application.domain.SaveForestProductCmd;
public interface SaveForestProductPortIn {
void operate(SaveForestProductCmd inCmd);
}

View File

@@ -0,0 +1,7 @@
package app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.ports;
import app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.ports.application.domain.SaveForestProductCmd;
public interface SaveForestProductPortOut {
void operate(SaveForestProductCmd inCmd);
}

View File

@@ -0,0 +1,18 @@
package app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.ports.application;
import app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.ports.SaveForestProductPortIn;
import app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.ports.SaveForestProductPortOut;
import app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.ports.application.domain.SaveForestProductCmd;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
class SaveForestProductService implements SaveForestProductPortIn {
private final SaveForestProductPortOut portOut;
@Override
public void operate(SaveForestProductCmd cmd) {
portOut.operate(cmd);
}
}

View File

@@ -0,0 +1,35 @@
package app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.ports.application.domain;
import app.module.core.config.adapters.persistence.component.AuditCommand;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
public class SaveForestProductCmd extends AuditCommand {
private Long forestProductId;
private Long householdSeq;
private Long monthlyInputStatusId;
private String recordMonth;
private String streetNum;
private String landType;
private String town;
private String cropName;
private String landArea;
private String availableArea;
private String mainYield;
private String mainYieldUnitCode;
private String mainYieldUnit;
private String mainSaleAmount;
private String mainSaleUnitCode;
private String mainSaleUnit;
private String subYield;
private String subYieldUnitCode;
private String subYieldUnit;
private String subSaleAmount;
private String subSaleUnitCode;
private String subSaleUnit;
}

View File

@@ -30,7 +30,7 @@ class SaveHouseholdVisitInfoController {
if (bindingResult.hasErrors()) { if (bindingResult.hasErrors()) {
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY) return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
.body(bindingResult.getAllErrors().get(0).getDefaultMessage()); .body(bindingResult.getFieldErrors());
} }
portIn.operate(new SaveHouseholdVisitInfoCmd( portIn.operate(new SaveHouseholdVisitInfoCmd(

View File

@@ -1,8 +0,0 @@
package app.module.admin.usecase.loggedinuser.save.ports;
import app.module.admin.usecase.loggedinuser.save.ports.application.domain.LoggedInUserSaveCmd;
public interface LoggedInUserSavePortIn {
void connect(LoggedInUserSaveCmd loggedInUserSaveCmd);
}

View File

@@ -1,8 +0,0 @@
package app.module.admin.usecase.loggedinuser.save.ports;
import app.module.admin.usecase.loggedinuser.save.ports.application.domain.LoggedInUserSaveCmd;
public interface LoggedInUserSavePortOut {
void connect(LoggedInUserSaveCmd loggedInUser);
}

View File

@@ -5,13 +5,14 @@ import app.module.core.config.adapters.persistence.component.AuditCommand;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@Getter @Getter
@Setter @Setter
public class ResearchersVisitDetailReqVO { public class ResearchersVisitDetailReqVO extends AuditCommand {
private String id; private Integer id;
private String visitDate; private LocalDate visitDate;
private ManagementType managementType; private ManagementType managementType;
private String content; private String content;
private String isGiftSent; private String isGiftSent;

View File

@@ -34,6 +34,7 @@
) )
SELECT SELECT
dr.id AS id, dr.id AS id,
ddg.group_no AS day_group_no,
/* 해당 월의 말일을 기준으로 종료일을 제한하여 일자 그룹 표시 */ /* 해당 월의 말일을 기준으로 종료일을 제한하여 일자 그룹 표시 */
ddg.start_day || ddg.start_day ||
CASE CASE

View File

@@ -4,9 +4,10 @@
<mapper <mapper
namespace="app.module.admin.usecase.household.tab.forestProduct.getForestProductsStatus.adapters.persistence.GetForestProductsStatusMapper"> namespace="app.module.admin.usecase.household.tab.forestProduct.getForestProductsStatus.adapters.persistence.GetForestProductsStatusMapper">
<select id="getMonthlyStatus" resultType="java.lang.String"> <select id="getMonthlyStatus" resultType="app.module.admin.usecase.household.tab.forestProduct.getForestProductsStatus.ports.application.domain.GetMonthlyForestProductsStatus">
/* getMonthlyStatus : 임산물 현황 등록 상태 조회 */ /* getMonthlyStatus : 임산물 현황 등록 상태 조회 */
SELECT forest_product_status SELECT id,
forest_product_status
FROM monthly_input_status mis FROM monthly_input_status mis
WHERE household_seq = #{householdSeq} WHERE household_seq = #{householdSeq}
AND month = #{recordMonth} AND month = #{recordMonth}

View File

@@ -83,9 +83,15 @@
<where> <where>
1=1 1=1
<if test="cmd.ownerField != null and cmd.ownerField != '' and cmd.ownerValue != ''"> <if test="cmd.ownerValue != null and cmd.ownerValue != ''">
/* 경영주 검색 */ /* 경영주 검색 */
<choose> <choose>
<when test="cmd.ownerField == ''">
AND (
hvr.householdName ILIKE '%' || #{cmd.ownerValue} || '%'
OR hvr.householdPhone ILIKE '%' || #{cmd.ownerValue} || '%'
)
</when>
<when test="cmd.ownerField eq 'name'"> <when test="cmd.ownerField eq 'name'">
AND hvr.householdName ILIKE '%' || #{cmd.ownerValue} || '%' AND hvr.householdName ILIKE '%' || #{cmd.ownerValue} || '%'
</when> </when>
@@ -95,9 +101,15 @@
</choose> </choose>
</if> </if>
<if test="cmd.researcherField != null and cmd.researcherField != '' and cmd.researcherValue != ''"> <if test="cmd.researcherValue != null and cmd.researcherValue != ''">
/* 조사원 검색 */ /* 조사원 검색 */
<choose> <choose>
<when test="cmd.researcherField == ''">
AND (
hvr.researcherName ILIKE '%' || #{cmd.researcherValue} || '%'
OR hvr.researcherPhone ILIKE '%' || #{cmd.researcherValue} || '%'
)
</when>
<when test="cmd.researcherField eq 'name'"> <when test="cmd.researcherField eq 'name'">
AND hvr.researcherName ILIKE '%' || #{cmd.researcherValue} || '%' AND hvr.researcherName ILIKE '%' || #{cmd.researcherValue} || '%'
</when> </when>

View File

@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper
namespace="app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.adapters.persistence.SaveForestProductMapper">
<insert id="createForestProduct">
/* createForestProduct : 임산물 현황 등록 */
INSERT INTO forest_product
(
household_seq,
month,
street_num,
land_type,
town,
crop_name,
land_area,
available_area,
main_yield,
main_yield_unit_code,
main_yield_unit,
main_sale_amount,
main_sale_unit_code,
main_sale_unit,
sub_yield,
sub_yield_unit_code,
sub_yield_unit,
sub_sale_amount,
sub_sale_unit_code,
sub_sale_unit,
monthly_input_status_id,
<include refid="common.fields.CreateUpdateBaseColumns"/>
)
VALUES
(
#{householdSeq},
#{recordMonth},
#{streetNum},
#{landType},
#{town},
#{cropName},
#{landArea},
#{availableArea},
#{mainYield},
#{mainYieldUnitCode},
#{mainYieldUnit},
#{mainSaleAmount},
#{mainSaleUnitCode},
#{mainSaleUnit},
#{subYield},
#{subYieldUnitCode},
#{subYieldUnit},
#{subSaleAmount},
#{subSaleUnitCode},
#{subSaleUnit},
#{monthlyInputStatusId},
<include refid="common.fields.CreateUpdateBaseValues"/>
)
</insert>
<update id="updateForestProduct">
/* updateForestProduct : 임산물 현황 수정 */
UPDATE forest_product
SET
household_seq = #{householdSeq},
street_num = #{streetNum},
land_type = #{landType},
town = #{town},
available_area = #{availableArea},
crop_name = #{cropName},
land_area = #{landArea},
month = #{recordMonth},
main_yield = #{mainYield},
main_yield_unit_code = #{mainYieldUnitCode},
main_yield_unit = #{mainYieldUnit},
main_sale_amount = #{mainSaleAmount},
main_sale_unit_code = #{mainSaleUnitCode},
main_sale_unit = #{mainSaleUnit},
sub_yield = #{subYield},
sub_yield_unit_code = #{subYieldUnitCode},
sub_yield_unit = #{subYieldUnit},
sub_sale_amount = #{subSaleAmount},
sub_sale_unit_code = #{subSaleUnitCode},
sub_sale_unit = #{subSaleUnit},
monthly_input_status_id = #{monthlyInputStatusId},
<include refid="common.fields.UpdateBaseSet"/>
WHERE id = #{forestProductId}
</update>
</mapper>

View File

@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="app.module.admin.usecase.household.tab.dailyRecord.updateDailyNone.adapters.persistence.UpdateDailyNoneMapper">
<select id="getDailyRecordSeq">
select id
from daily_record
where is_deleted = false
and record_month = #{searchMonth}
and day_group_no = #{groupNo}
and household_seq = #{householdSeq}
</select>
<select id="removeDailyIncome">
<if test="dailyRecordSeq != null and dailyRecordSeq != ''">
update daily_income set
<include refid="common.fields.DeleteBaseSet"/>
where is_deleted = false
and daily_record_seq = #{dailyRecordSeq}
</if>
</select>
<select id="removeDailyWork">
<if test="dailyRecordSeq != null and dailyRecordSeq != ''">
update daily_work set
<include refid="common.fields.DeleteBaseSet"/>
where is_deleted = false
and daily_record_seq = #{dailyRecordSeq}
</if>
</select>
<select id="removeDailyExpense">
<if test="dailyRecordSeq != null and dailyRecordSeq != ''">
update daily_expense set
<include refid="common.fields.DeleteBaseSet"/>
where is_deleted = false
and daily_record_seq = #{dailyRecordSeq}
</if>
</select>
<select id="removeDailyPower">
<if test="dailyRecordSeq != null and dailyRecordSeq != ''">
update daily_power set
<include refid="common.fields.DeleteBaseSet"/>
where is_deleted = false
and daily_record_seq = #{dailyRecordSeq}
</if>
</select>
<select id="removeDailyForestry">
<if test="dailyRecordSeq != null and dailyRecordSeq != ''">
update daily_forestry set
<include refid="common.fields.DeleteBaseSet"/>
where is_deleted = false
and daily_record_seq = #{dailyRecordSeq}
</if>
</select>
<select id="removeDailyFarming">
<if test="dailyRecordSeq != null and dailyRecordSeq != ''">
update daily_farming set
<include refid="common.fields.DeleteBaseSet"/>
where is_deleted = false
and daily_record_seq = #{dailyRecordSeq}
</if>
</select>
</mapper>

View File

@@ -37,23 +37,16 @@
) )
</insert> </insert>
<insert id="createNoticeHasUploadFile"> <update id="createNoticeUploadFile">
<!-- createNoticeHasUploadFile 게시글 등록 시, 첨부파일 join 데이터 등록 --> update upload_file
INSERT INTO notice_has_upload_file set mapping_id = #{id},
( <include refid="common.fields.UpdateBaseSet"/>
notice_id, where id IN (
upload_files_id,
<include refid="common.fields.CreateUpdateBaseColumns"/>
)
VALUES
<foreach collection="fileMappingIds" item="fileId" separator=","> <foreach collection="fileMappingIds" item="fileId" separator=",">
( #{fileId}
#{id},
#{fileId},
<include refid="common.fields.CreateUpdateBaseValues"/>
)
</foreach> </foreach>
</insert> )
</update>
</mapper> </mapper>

View File

@@ -29,8 +29,7 @@
resultType="app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNoticeUploadFile"> resultType="app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNoticeUploadFile">
/* getUploadFiles 상세 게시글 조회 시, 첨부파일 조회 */ /* getUploadFiles 상세 게시글 조회 시, 첨부파일 조회 */
SELECT SELECT
awuf.notice_id AS noticeId, uf.mapping_id,
awuf.upload_files_id AS uploadfileId,
uf.id AS id, uf.id AS id,
uf.created_at AS createdAt, uf.created_at AS createdAt,
uf.created_by AS createdBy, uf.created_by AS createdBy,
@@ -41,9 +40,7 @@
uf.origin_name AS originName, uf.origin_name AS originName,
uf.path AS path, uf.path AS path,
uf.type AS type uf.type AS type
FROM notice_has_upload_file awuf FROM upload_file uf
INNER JOIN upload_file uf WHERE uf.mapping_id = #{id} AND uf.is_deleted = false AND uf.type ='NOTICE'
ON awuf.upload_files_id = uf.id
WHERE awuf.notice_id = #{id} AND awuf.is_deleted = false
</select> </select>
</mapper> </mapper>

View File

@@ -78,16 +78,15 @@
resultType="app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain.GetNoticeFiles"> resultType="app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain.GetNoticeFiles">
/* getUploadFiles : 게시물 리스트의 대표 이미지 */ /* getUploadFiles : 게시물 리스트의 대표 이미지 */
SELECT SELECT
awuf.notice_id, uf.mapping_id as notice_id,
uf.id, uf.id,
uf.type, uf.type,
uf.path, uf.path,
uf.name, uf.name,
uf.origin_name, uf.origin_name,
uf.file_length uf.file_length
FROM notice_has_upload_file awuf FROM upload_file uf
INNER JOIN upload_file uf ON awuf.upload_files_id = uf.id WHERE uf.mapping_id IN
WHERE awuf.notice_id IN
<foreach collection="ids" item="id" open="(" separator="," close=")"> <foreach collection="ids" item="id" open="(" separator="," close=")">
#{id} #{id}
</foreach> </foreach>

View File

@@ -13,11 +13,11 @@
</foreach> </foreach>
</update> </update>
<update id="deleteNoticeHasFiles"> <update id="deleteNoticeUploadFiles">
/* deleteNoticeHasFiles : 게시물-파일 매핑 논리 삭제 */ /* deleteNoticeUploadFiles : 게시물-파일 매핑 논리 삭제 */
UPDATE notice_has_upload_file UPDATE upload_file
SET <include refid="common.fields.DeleteBaseSet" /> SET <include refid="common.fields.DeleteBaseSet" />
WHERE notice_id IN WHERE type='NOTICE' and mapping_id IN
<foreach collection="removeIds" item="id" open="(" separator="," close=")"> <foreach collection="removeIds" item="id" open="(" separator="," close=")">
#{id} #{id}
</foreach> </foreach>

View File

@@ -4,32 +4,6 @@
<mapper <mapper
namespace="app.module.admin.usecase.communication.notice.updateNotice.adapters.persistence.UpdateNoticeMapper"> namespace="app.module.admin.usecase.communication.notice.updateNotice.adapters.persistence.UpdateNoticeMapper">
<update id="deleteFileUploads">
/* deleteFileUploads 게시글 수정 시, 첨부파일 join 데이터 삭제 */
UPDATE notice_has_upload_file
SET
<include refid="common.fields.DeleteBaseSet"/>
WHERE notice_id = #{noticeId}
</update>
<insert id="createFileUploads">
/* createFileUploads 게시글 수정 시, 첨부파일 join 데이터 등록 */
INSERT INTO notice_has_upload_file
(
notice_id,
upload_files_id,
<include refid="common.fields.CreateUpdateBaseColumns"/>
)
VALUES
<foreach collection="fileMappingId" item="fileId" separator=",">
(
#{id},
#{fileId},
<include refid="common.fields.CreateUpdateBaseValues"/>
)
</foreach>
</insert>
<update id="updateNotice"> <update id="updateNotice">
/* updateNotice 게시글 수정 */ /* updateNotice 게시글 수정 */
UPDATE notice UPDATE notice
@@ -42,4 +16,5 @@
<include refid="common.fields.UpdateBaseSet"/> <include refid="common.fields.UpdateBaseSet"/>
WHERE id = #{id} WHERE id = #{id}
</update> </update>
</mapper> </mapper>

View File

@@ -225,8 +225,15 @@
set visit_date = #{visitDate}, set visit_date = #{visitDate},
content = #{content}, content = #{content},
management_type = #{managementType}, management_type = #{managementType},
is_gift_sent = #{isGiftSent}, <choose>
<include refid="common.fields.UpdateBaseSet" /> <when test="isGiftSent">
is_gift_sent = true,
</when>
<when test="!isGiftSent">
is_gift_sent = false,
</when>
</choose>
<include refid="common.fields.UpdateBaseSet" />
where id = #{id} where id = #{id}
</update> </update>

View File

@@ -8,6 +8,7 @@
<input type="hidden" name="forestProductId"> <input type="hidden" name="forestProductId">
<input type="hidden" name="householdSeq" th:value="${seq}"> <input type="hidden" name="householdSeq" th:value="${seq}">
<input type="hidden" name="recordMonth"> <input type="hidden" name="recordMonth">
<input type="hidden" name="monthlyInputStatusId">
<div class="component-modal mypage-wrap modal01 modal-forest-product" data-props-dimm-click="true" data-state="close"> <div class="component-modal mypage-wrap modal01 modal-forest-product" data-props-dimm-click="true" data-state="close">
<div class="modal-dimm"></div> <div class="modal-dimm"></div>
@@ -229,7 +230,7 @@
<div class="component-btns bottom-btn-group"> <div class="component-btns bottom-btn-group">
<div class="btns-row align-right"> <div class="btns-row align-right">
<button type="button" class="btn btn-primary"> <button type="button" class="btn btn-primary" onclick="goForestProductSave();">
<span class="btn-txt">등록</span> <span class="btn-txt">등록</span>
</button> </button>
</div> </div>
@@ -249,6 +250,7 @@
const showForestProductModal = (id) => { const showForestProductModal = (id) => {
const f = document.reqForestProductForm; const f = document.reqForestProductForm;
f.recordMonth.value = document.reqForm.recordMonth.value; f.recordMonth.value = document.reqForm.recordMonth.value;
f.monthlyInputStatusId.value = document.reqForm.monthlyInputStatusId.value;
resetForestProductForm(); resetForestProductForm();
@@ -261,6 +263,8 @@
(response) => { (response) => {
console.log("임산물현황 상세 응답값 : ", response); console.log("임산물현황 상세 응답값 : ", response);
setForestProductFormData(response); setForestProductFormData(response);
document.querySelector(".modal-forest-product").ui.open();
}, },
function (code, rstData) { function (code, rstData) {
console.log("error : ", code); console.log("error : ", code);
@@ -268,9 +272,9 @@
'get', 'get',
'json' 'json'
); );
} else {
document.querySelector(".modal-forest-product").ui.open();
} }
document.querySelector(".modal-forest-product").ui.open();
} }
// 임산물현황등록 상세 값 set // 임산물현황등록 상세 값 set
@@ -332,21 +336,47 @@
const form = document.reqForestProductForm; const form = document.reqForestProductForm;
if (!form) return; if (!form) return;
// 모든 input 초기화 const skipInputs = ['forestProductId', 'householdSeq', 'recordMonth', 'monthlyInputStatusId'];
form.querySelectorAll('input').forEach((input) => {
input.value = '';
// 단위 직접입력는 다시 비활성화하고 클래스 추가 form.querySelectorAll('input').forEach((el) => {
if (input.closest('.unit-self-input')) { if (!skipInputs.includes(el.name)) {
input.disabled = true; el.value = '';
input.closest('.unit-self-input').classList.add('input-disabled'); if (el.closest('.unit-self-input')) {
el.disabled = true;
el.closest('.unit-self-input').classList.add('input-disabled');
}
} }
}); });
// 모든 select 초기화 form.querySelectorAll('select').forEach((el) => el.selectedIndex = 0);
form.querySelectorAll('select').forEach((select) => { }
select.selectedIndex = 0; </script>
});
<script>
// 임산물 현황 저장 및 수정
const goForestProductSave = () => {
const f = document.reqForestProductForm;
if (!f) return;
let dataOj = $(f).serializeObject();
console.log("dataOj", dataOj);
ajaxUtil._ajaxMethod(
'/api/forestProduct/save',
JSON.stringify(dataOj),
(response) => { // 성공
alert("등록이 완료되었습니다.");
document.querySelector(".modal-forest-product").ui.close();
getForestProductsStatus();
},
function (code, rstData) {
if(code == 422) alert(rstData.responseJSON[0].defaultMessage);
},
'post',
'json',
{ handle422Type: 'alert' }
);
} }
</script> </script>
</div> </div>

View File

@@ -194,7 +194,7 @@
getVisitInfo(); getVisitInfo();
}, },
function (code, rstData) { function (code, rstData) {
if(code == 422) alert(rstData.responseText); if(code == 422) alert(rstData.responseJSON[0].defaultMessage);
if(code == 400) alert(rstData.responseJSON.message); //임가번호 중복체크 if(code == 400) alert(rstData.responseJSON.message); //임가번호 중복체크
}, },
'post', 'post',

View File

@@ -4,6 +4,10 @@
<div class="layer-wrap" th:fragment="tabFragment"> <div class="layer-wrap" th:fragment="tabFragment">
<div class="tab-content daily-record" data-tab-value="tab1" > <div class="tab-content daily-record" data-tab-value="tab1" >
<input type="hidden" name="dailyId">
<input type="hidden" name="groupNo">
<input type="hidden" name="dayGroupText">
<!-- 일계부 등록 현황 리스트 --> <!-- 일계부 등록 현황 리스트 -->
<div class="daily-record-content daily-record-list"> <div class="daily-record-content daily-record-list">
<div class="content-inner"> <div class="content-inner">
@@ -11,23 +15,23 @@
<ul> <ul>
<li> <li>
<p>작성완료</p> <p>작성완료</p>
<span><strong id="doneCount">6</strong>건</span> <span><strong id="doneCount">0</strong>건</span>
</li> </li>
<li> <li>
<p>미작성</p> <p>미작성</p>
<span><strong id="emptyCount">6</strong>건</span> <span><strong id="emptyCount">0</strong>건</span>
</li> </li>
<li> <li>
<p>미완료</p> <p>미완료</p>
<span><strong id="incompleteCount">6</strong>건</span> <span><strong id="incompleteCount">0</strong>건</span>
</li> </li>
<li> <li>
<p>대기</p> <p>대기</p>
<span><strong id="waitingCount">6</strong>건</span> <span><strong id="waitingCount">0</strong>건</span>
</li> </li>
<li> <li>
<p>완료율</p> <p>완료율</p>
<span><strong id="progressPercent">56.12</strong>%</span> <span><strong id="progressPercent">0</strong>%</span>
</li> </li>
</ul> </ul>
</article> </article>
@@ -53,8 +57,21 @@
<!-- 일계부 등록 현황 상세 --> <!-- 일계부 등록 현황 상세 -->
<div class="daily-record-content daily-record-detail" style="display: none;"> <div class="daily-record-content daily-record-detail" style="display: none;">
<div class="content-inner"> <div class="content-inner">
<!-- 현황 -->
<section class="table-group">
<div class="table-tit-group">
<h3 class="_selectedGroupNo">현황</h3>
<div class="component-btns bottom-btn-group" th:unless="${activeProfile != 'local'}">
<div class="btns-row align-right">
<button type="button" class="btn small" onclick="getDailyRecordsList()">
<span class="btn-txt">등록 현황 목록</span>
</button>
</div>
</div>
</div>
</section>
<!-- 수입 --> <!-- 수입 -->
<section class="table-group"> <section class="table-group">
<div class="table-tit-group"> <div class="table-tit-group">
@@ -65,12 +82,19 @@
<span class="btn-txt">영수증 다운로드 <i class="ico-download" aria-hidden="true"></i></span> <span class="btn-txt">영수증 다운로드 <i class="ico-download" aria-hidden="true"></i></span>
</button> </button>
<button type="button" class="btn small"> <button type="button" class="btn small">
<span class="btn-txt">등록여부</span> <span class="btn-txt">
<label class="radio-inner">
<span class="radio-item">
<span class="radio-txt">금일 데이터 없음</span>
</span>
<input type="checkbox" id="incomeStatus" data-step="INCOME" onclick="showDailyNoneConfirm(this)">
</label>
</span>
</button> </button>
<button type="button" class="btn small btn-secondary"> <button type="button" class="btn small btn-secondary" style="display: none;" data-step="INCOME" data-list-id="table-income" onclick="removeDaily(this)">
<span class=" btn-txt">삭제</span> <span class=" btn-txt">삭제</span>
</button> </button>
<button type="button" class="btn small btn-primary"> <button type="button" class="btn small btn-primary" style="display: none;" data-step="INCOME" data-modal-id="modal-income" onclick="saveDaily(this)">
<span class="btn-txt">추가</span> <span class="btn-txt">추가</span>
</button> </button>
</div> </div>
@@ -104,12 +128,19 @@
<div class="component-btns bottom-btn-group" th:unless="${activeProfile != 'local'}"> <div class="component-btns bottom-btn-group" th:unless="${activeProfile != 'local'}">
<div class="btns-row align-right"> <div class="btns-row align-right">
<button type="button" class="btn small"> <button type="button" class="btn small">
<span class="btn-txt">등록여부</span> <span class="btn-txt">
<label class="radio-inner">
<span class="radio-item">
<span class="radio-txt">금일 데이터 없음</span>
</span>
<input type="checkbox" id="workStatus" data-step="WORK" onclick="showDailyNoneConfirm(this)">
</label>
</span>
</button> </button>
<button type="button" class="btn small btn-secondary"> <button type="button" class="btn small btn-secondary" style="display: none;" data-step="WORK" data-list-id="table-work" onclick="removeDaily(this)">
<span class=" btn-txt">삭제</span> <span class=" btn-txt">삭제</span>
</button> </button>
<button type="button" class="btn small btn-primary"> <button type="button" class="btn small btn-primary" style="display: none;" data-step="WORK" data-modal-id="modal-work" onclick="saveDaily(this)">
<span class="btn-txt">추가</span> <span class="btn-txt">추가</span>
</button> </button>
</div> </div>
@@ -159,12 +190,19 @@
<span class="btn-txt">영수증 다운로드 <i class="ico-download" aria-hidden="true"></i></span> <span class="btn-txt">영수증 다운로드 <i class="ico-download" aria-hidden="true"></i></span>
</button> </button>
<button type="button" class="btn small"> <button type="button" class="btn small">
<span class="btn-txt">등록여부</span> <span class="btn-txt">
<label class="radio-inner">
<span class="radio-item">
<span class="radio-txt">금일 데이터 없음</span>
</span>
<input type="checkbox" id="expenseStatus" data-step="EXPENSE" onclick="showDailyNoneConfirm(this)">
</label>
</span>
</button> </button>
<button type="button" class="btn small btn-secondary"> <button type="button" class="btn small btn-secondary" style="display: none;" data-step="EXPENSE" data-list-id="table-expense" onclick="removeDaily(this)">
<span class=" btn-txt">삭제</span> <span class=" btn-txt">삭제</span>
</button> </button>
<button type="button" class="btn small btn-primary"> <button type="button" class="btn small btn-primary" style="display: none;" data-step="EXPENSE" data-modal-id="modal-expense" onclick="saveDaily(this)">
<span class="btn-txt">추가</span> <span class="btn-txt">추가</span>
</button> </button>
</div> </div>
@@ -197,12 +235,19 @@
<div class="component-btns bottom-btn-group" th:unless="${activeProfile != 'local'}"> <div class="component-btns bottom-btn-group" th:unless="${activeProfile != 'local'}">
<div class="btns-row align-right"> <div class="btns-row align-right">
<button type="button" class="btn small"> <button type="button" class="btn small">
<span class="btn-txt">등록여부</span> <span class="btn-txt">
<label class="radio-inner">
<span class="radio-item">
<span class="radio-txt">금일 데이터 없음</span>
</span>
<input type="checkbox" id="powerStatus" data-step="POWER" onclick="showDailyNoneConfirm(this)">
</label>
</span>
</button> </button>
<button type="button" class="btn small btn-secondary"> <button type="button" class="btn small btn-secondary" style="display: none;" data-step="POWER" data-list-id="table-power" onclick="removeDaily(this)">
<span class=" btn-txt">삭제</span> <span class=" btn-txt">삭제</span>
</button> </button>
<button type="button" class="btn small btn-primary"> <button type="button" class="btn small btn-primary" style="display: none;" data-step="POWER" data-modal-id="modal-power" onclick="saveDaily(this)">
<span class="btn-txt">추가</span> <span class="btn-txt">추가</span>
</button> </button>
</div> </div>
@@ -231,12 +276,19 @@
<div class="component-btns bottom-btn-group" th:unless="${activeProfile != 'local'}"> <div class="component-btns bottom-btn-group" th:unless="${activeProfile != 'local'}">
<div class="btns-row align-right"> <div class="btns-row align-right">
<button type="button" class="btn small"> <button type="button" class="btn small">
<span class="btn-txt">등록여부</span> <span class="btn-txt">
<label class="radio-inner">
<span class="radio-item">
<span class="radio-txt">금일 데이터 없음</span>
</span>
<input type="checkbox" id="forestryStatus" data-step="FORESTRY" onclick="showDailyNoneConfirm(this)">
</label>
</span>
</button> </button>
<button type="button" class="btn small btn-secondary"> <button type="button" class="btn small btn-secondary" style="display: none;" data-step="FORESTRY" data-list-id="table-forestry" onclick="removeDaily(this)">
<span class=" btn-txt">삭제</span> <span class=" btn-txt">삭제</span>
</button> </button>
<button type="button" class="btn small btn-primary"> <button type="button" class="btn small btn-primary" style="display: none;" data-step="FORESTRY" data-modal-id="modal-forestry" onclick="saveDaily(this)">
<span class="btn-txt">추가</span> <span class="btn-txt">추가</span>
</button> </button>
</div> </div>
@@ -267,12 +319,19 @@
<div class="component-btns bottom-btn-group" th:unless="${activeProfile != 'local'}"> <div class="component-btns bottom-btn-group" th:unless="${activeProfile != 'local'}">
<div class="btns-row align-right"> <div class="btns-row align-right">
<button type="button" class="btn small"> <button type="button" class="btn small">
<span class="btn-txt">등록여부</span> <span class="btn-txt">
<label class="radio-inner">
<span class="radio-item">
<span class="radio-txt">금일 데이터 없음</span>
</span>
<input type="checkbox" id="farmingStatus" data-step="FARMING" onclick="showDailyNoneConfirm(this)">
</label>
</span>
</button> </button>
<button type="button" class="btn small btn-secondary"> <button type="button" class="btn small btn-secondary" style="display: none;" data-step="FARMING" data-list-id="table-farming" onclick="removeDaily(this)">
<span class=" btn-txt">삭제</span> <span class=" btn-txt">삭제</span>
</button> </button>
<button type="button" class="btn small btn-primary"> <button type="button" class="btn small btn-primary" style="display: none;" data-step="FARMING" data-modal-id="modal-farming" onclick="saveDaily(this)">
<span class="btn-txt">추가</span> <span class="btn-txt">추가</span>
</button> </button>
</div> </div>
@@ -300,10 +359,10 @@
</div> </div>
<script th:inline="javascript"> <script th:inline="javascript">
const f = document.reqForm;
// 일계부 등록 현황 리스트 조회 // 일계부 등록 현황 리스트 조회
const getDailyRecords = () => { const getDailyRecords = () => {
const f = document.reqForm;
ajaxUtil._ajaxMethod( ajaxUtil._ajaxMethod(
'/api/household/dailyRecordsStatus', '/api/household/dailyRecordsStatus',
{ {
@@ -331,7 +390,7 @@
tmpl += tmpl +=
` `
<tr> <tr>
<td class="underline"><a href="javascript:void(0);" onclick="getDailyRecordsView(${item.id});">${item.dayGroup}</a></td> <td class="underline"><a href="javascript:void(0);" onclick="getDailyRecordsView(${item.id}, ${item.dayGroupNo}, '${item.dayGroup}');">${item.dayGroup}</a></td>
<td> <td>
<span class="tag ${statusInfoMap[item.allStatusType].className}"> <span class="tag ${statusInfoMap[item.allStatusType].className}">
${statusInfoMap[item.allStatusType].label} ${statusInfoMap[item.allStatusType].label}
@@ -357,15 +416,20 @@
); );
} }
// 임산물 등록 현황 상세 // 일계부 등록 현황 상세
const getDailyRecordsView = (id) => { const getDailyRecordsView = (id, groupNo, dayGroupText) => {
if(id == null) { if(id == null) {
alert('등록 내역이 없습니다.'); alert('등록 내역이 없습니다.');
return; return;
} }
f.dailyId.value = id;
f.groupNo.value = groupNo;
f.dayGroupText.value = dayGroupText;
const listArea = $('.tab-content .daily-record-list'); const listArea = $('.tab-content .daily-record-list');
const detailArea = $('.tab-content .daily-record-detail'); const detailArea = $('.tab-content .daily-record-detail');
detailArea.find('._selectedGroupNo').text(dayGroupText + '일 현황');
listArea.hide(); listArea.hide();
detailArea.show(); detailArea.show();
@@ -375,6 +439,24 @@
{ recordSeq: id }, { recordSeq: id },
function(response) { // 성공 function(response) { // 성공
console.log("일계부 등록 상세 데이터 : ", response); console.log("일계부 등록 상세 데이터 : ", response);
// 금일 데이터 없음 체크
$('#incomeStatus').attr('checked', response.status.incomeStatus === 'TODAY_NONE');
$('#workStatus').attr('checked', response.status.workStatus === 'TODAY_NONE');
$('#expenseStatus').attr('checked', response.status.expenseStatus === 'TODAY_NONE');
$('#powerStatus').attr('checked', response.status.powerStatus === 'TODAY_NONE');
$('#forestryStatus').attr('checked', response.status.forestryStatus === 'TODAY_NONE');
if (response.status.farmingStatus === 'NONE') {
$('#farmingStatus').attr('disabled', true);
} else {
$('#farmingStatus').attr('disabled', false);
$('#farmingStatus').attr('checked', response.status.farmingStatus === 'TODAY_NONE');
}
// 금일 데이터 없음에 따라 버튼 hide 처리
showDailyNoneBtn();
// 상세 테이블 그리기
gridIncomeTable(response.status.incomeStatus, response.incomes); gridIncomeTable(response.status.incomeStatus, response.incomes);
gridWorkTable(response.status.workStatus, response.works); gridWorkTable(response.status.workStatus, response.works);
gridExpenseTable(response.status.expenseStatus, response.expenses); gridExpenseTable(response.status.expenseStatus, response.expenses);
@@ -390,6 +472,17 @@
); );
} }
// 입력현황 목록
const getDailyRecordsList = () => {
getDailyRecords();
const listArea = $('.tab-content .daily-record-list');
const detailArea = $('.tab-content .daily-record-detail');
listArea.show();
detailArea.hide();
}
// 수입 테이블 그리기 // 수입 테이블 그리기
const gridIncomeTable = (status, data) => { const gridIncomeTable = (status, data) => {
const tbody = $('#table-income tbody'); const tbody = $('#table-income tbody');
@@ -637,6 +730,95 @@
tbody.append(tmpl); tbody.append(tmpl);
} }
// 금일 데이터 없음에 따라 버튼 hide/show 처리
const showDailyNoneBtn = () => {
$('.daily-record-detail').find('.table-tit-group').each(function(index, item) {
let checkedIndex = false;
$(item).find('[type="button"]').each(function(indexBtn, itemBtn) {
let $chkBox = $(itemBtn).find('input[type="checkbox"]');
if (($chkBox.length !== 0 && $chkBox.is(':disabled'))) {
checkedIndex = true;
}
if (checkedIndex) {
$(itemBtn).hide();
} else {
$(itemBtn).show();
}
if ($chkBox.length !== 0) {
checkedIndex = $chkBox.is(':checked') || $chkBox.is(':disabled');
}
});
});
}
// 데이터 초기화 Confirm
const showDailyNoneConfirm = (el) => {
const currentStep = $(el).data('step');
const todayNone = $(el).is(':checked') ? 'Y' : 'N';
if (currentStep === undefined) {
alert('변경할 수 없는 상태입니다.');
$(el).prop('checked', todayNone !== 'Y');
return;
}
const obj = $(f).serializeObject();
obj.currentStep = currentStep;
obj.todayNone = todayNone;
if (todayNone === 'Y') {
etUI.dialog.confirm({
title: '초기화 안내',
message: '등록하신 모든 내용을 삭제하시겠어요?<br>삭제된 내용은 복구할 수 없습니다.',
negativeCallback: function () {
$(el).prop('checked', todayNone !== 'Y');
},
positiveCallback: function () {
updateDailyNone(el, obj);
},
});
} else {
updateDailyNone(el, obj);
}
}
// 금일 데이터 없음 수정 처리
const updateDailyNone = (el, obj) => {
ajaxUtil._ajaxAsyncNoWaiting(
'/api/household/daily/today-none',
obj,
function () {
if (obj.todayNone === 'Y') {
alert('데이터 초기화가 완료되었습니다.');
} else {
alert('등록 상태가 변경되었습니다.');
}
getDailyRecordsView(f.dailyId.value, f.groupNo.value, f.dayGroupText.value);
},
);
}
// 일계부 등록 처리
const saveDaily = (el) => {
const currentStep = $(el).data('step');
const currentModalId = $(el).data('modalId');
console.log('removeDaily', currentStep, currentModalId);
alert('TODO : 추가')
}
// 일계부 삭제 처리
const removeDaily = (el) => {
const currentStep = $(el).data('step');
const currentListId = $(el).data('listId');
console.log('removeDaily', currentStep, currentListId);
alert('TODO : 삭제')
}
</script> </script>
</div> </div>
</html> </html>

View File

@@ -3,6 +3,8 @@
layout:decorate="~{layout/layout}"> layout:decorate="~{layout/layout}">
<div class="layer-wrap" th:fragment="tabFragment"> <div class="layer-wrap" th:fragment="tabFragment">
<input type="hidden" name="monthlyInputStatusId">
<div class="tab-content forest-product" data-tab-value="tab2"> <div class="tab-content forest-product" data-tab-value="tab2">
<div class="content-inner"> <div class="content-inner">
<section class="table-group"> <section class="table-group">
@@ -68,12 +70,15 @@
}, },
(response) => { // 성공 (response) => { // 성공
console.log("임산물 현황 리스트 조회 : ", response); console.log("임산물 현황 리스트 조회 : ", response);
// 임산물 현황 등록 상태 id set
f.monthlyInputStatusId.value = response.monthlyStatus.id;
const tbody = $('.tab-content.forest-product tbody'); const tbody = $('.tab-content.forest-product tbody');
tbody.empty(); tbody.empty();
if(response.forestProducts.length === 0) { if(response.forestProducts.length === 0) {
noDataMonthly(tbody, response.status, 15); noDataMonthly(tbody, response.monthlyStatus.status, 15);
return; return;
} }

View File

@@ -168,9 +168,6 @@
<button type="button" class="btn"> <button type="button" class="btn">
<span class="btn-txt">엑셀 다운로드 <i class="ico-download" aria-hidden="true"></i></span> <span class="btn-txt">엑셀 다운로드 <i class="ico-download" aria-hidden="true"></i></span>
</button> </button>
<button type="button" class="btn">
<span class="btn-txt">인쇄 <i class="ico-print" aria-hidden="true"></i></span>
</button>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -5,6 +5,14 @@
<th layout:fragment="content"> <th layout:fragment="content">
<section> <section>
<table class="type-form confirm" th:object="${researcherDto}" > <table class="type-form confirm" th:object="${researcherDto}" >
<colgroup>
<col width="8%" />
<col width="25.3%" />
<col width="8%" />
<col width="25.3%" />
<col width="8%" />
<col width="25.3%" />
</colgroup>
<tbody> <tbody>
<tr> <tr>
<th>아이디</th> <th>아이디</th>
@@ -42,6 +50,8 @@
</section> </section>
<section> <section>
<form autocomplete="off" method="get" name="householdReqForm" th:object="${reqVO}"> <form autocomplete="off" method="get" name="householdReqForm" th:object="${reqVO}">
<input type="hidden" name="currentMonth" th:value="${currentMonth}">
<div class="component-tab" data-active="tab1"> <div class="component-tab" data-active="tab1">
<div class="tab-head"> <div class="tab-head">
<button type="button" class="tab-label" data-tab-value="tab1">담당 임가 목록</button> <button type="button" class="tab-label" data-tab-value="tab1">담당 임가 목록</button>
@@ -218,8 +228,8 @@
tbody.append( tbody.append(
` `
<tr data-id="${ct.seq}"> <tr data-id="${ct.seq}">
<td><a href="#">${ct.householdNum}</a></td> <td><a href="/households/${ct.seq}?recordMonth=${f.currentMonth.value}">${ct.householdNum}</a></td>
<td>${ct.ownerName || '-'}</td> <td><a href="/households/${ct.seq}?recordMonth=${f.currentMonth.value}">${ct.ownerName || '-'}</a></td>
<td>${ct.phone || '-'}</td> <td>${ct.phone || '-'}</td>
<td>${ct.regionMainCodeName || '-'}</td> <td>${ct.regionMainCodeName || '-'}</td>
<td>${ct.regionSubCodeName || '-'}</td> <td>${ct.regionSubCodeName || '-'}</td>
@@ -231,7 +241,6 @@
` `
); );
}); });
// TODO 임가번호 OR 경영주명 선택시 임가현황 상세화면으로 이동
if (!$(response.content).length) { if (!$(response.content).length) {
tbody.append(` tbody.append(`

View File

@@ -40,9 +40,6 @@
<span class="btn-txt">로그인</span> <span class="btn-txt">로그인</span>
</button> </button>
</div> </div>
<ul class="info-bullet-list">
<li><a href="">공식가입센터 관리자 바로가기</a></li>
</ul>
</form> </form>
</section> </section>
<ul class="logo-list"> <ul class="logo-list">

View File

@@ -27,6 +27,8 @@ public class AuditCommand {
public void update() { public void update() {
this.updatedAt = LocalDateTime.now(); this.updatedAt = LocalDateTime.now();
this.updatedBy = getCurrentUsername(); this.updatedBy = getCurrentUsername();
this.deletedAt = LocalDateTime.now();
this.deletedBy = getCurrentUsername();
} }
public void delete() { public void delete() {

View File

@@ -10,4 +10,9 @@ public enum FileStorageType {
S3("AWS S3 스토리지"), S3("AWS S3 스토리지"),
SFTP("SFTP"); SFTP("SFTP");
private final String desc; private final String desc;
private String name;
public String getName() {
return name();
}
} }

View File

@@ -10,12 +10,12 @@ import lombok.RequiredArgsConstructor;
@JsonFormat(shape = JsonFormat.Shape.OBJECT) @JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum FileUploadType { public enum FileUploadType {
// URI og:image 용 이미지 파일 // URI og:image 용 이미지 파일
OG_IMAGE(FileStorageType.LOCAL, "/ogImage", Set.of(AcceptableFileType.IMAGE)), OG_IMAGE(Set.of(FileStorageType.LOCAL), "/ogImage", Set.of(AcceptableFileType.IMAGE)),
// WEB Editor 이미지 파일 // WEB Editor 이미지 파일
EDITOR_IMAGE(FileStorageType.LOCAL, "/editorImage", Set.of(AcceptableFileType.IMAGE)), EDITOR_IMAGE(Set.of(FileStorageType.LOCAL), "/editorImage", Set.of(AcceptableFileType.IMAGE)),
PUBLIC( PUBLIC(
FileStorageType.LOCAL, Set.of(FileStorageType.LOCAL),
"/common", "/common",
Set.of( Set.of(
AcceptableFileType.IMAGE, AcceptableFileType.IMAGE,
@@ -28,7 +28,7 @@ public enum FileUploadType {
AcceptableFileType.PDF, AcceptableFileType.PDF,
AcceptableFileType.ZIP)), AcceptableFileType.ZIP)),
PRIVATE( PRIVATE(
FileStorageType.LOCAL, Set.of(FileStorageType.LOCAL),
"/private", "/private",
Set.of( Set.of(
AcceptableFileType.IMAGE, AcceptableFileType.IMAGE,
@@ -41,7 +41,10 @@ public enum FileUploadType {
AcceptableFileType.PDF, AcceptableFileType.PDF,
AcceptableFileType.ZIP)), AcceptableFileType.ZIP)),
NOTICE( NOTICE(
FileStorageType.SFTP, Set.of(
FileStorageType.SFTP,
FileStorageType.LOCAL
),
"/notice", "/notice",
Set.of( Set.of(
AcceptableFileType.IMAGE, AcceptableFileType.IMAGE,
@@ -55,15 +58,15 @@ public enum FileUploadType {
AcceptableFileType.ZIP)), AcceptableFileType.ZIP)),
RECEIPT( RECEIPT(
FileStorageType.SFTP, Set.of(FileStorageType.SFTP,FileStorageType.LOCAL),
"/receipt", "/receipt",
Set.of( Set.of(
AcceptableFileType.IMAGE AcceptableFileType.IMAGE
) )
); );
private final FileStorageType fileStorageType; private final Set<FileStorageType> fileStorageType;
private final String subPath; private final String subPath;
private final Set<AcceptableFileType> acceptableFileTypes; private final Set<AcceptableFileType> acceptableFileTypes;

View File

@@ -1,8 +1,11 @@
package app.module.core.config.application.util; package app.module.core.config.application.util;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.Date; import java.util.Date;
@@ -10,6 +13,7 @@ import java.util.Locale;
@Slf4j @Slf4j
@Component @Component
@RequiredArgsConstructor
public class DailyUtil { public class DailyUtil {
/** /**
@@ -103,4 +107,25 @@ public class DailyUtil {
return (limitStart.isBefore(startDate) || limitStart.isEqual(startDate)); return (limitStart.isBefore(startDate) || limitStart.isEqual(startDate));
} }
/**
* 문자형 타입의 숫자에 콤마 적용
*
* @param value 입력 데이터
* @return 숫자(콤마, 도트)
*/
public String getStringComma(String value) {
if (StringUtils.isBlank(value)) {
return value;
}
String[] values = value.split("\\.");
if (values.length > 1) {
Double input = Double.parseDouble(values[0]);
return new DecimalFormat("###,###").format(input) + "." + values[1];
}
return new DecimalFormat("###,###").format(Double.parseDouble(value));
}
} }

View File

@@ -1,7 +1,7 @@
package app.module.core.config.application.util; package app.module.core.config.application.util;
import app.module.core.config.adapters.persistence.entity.UploadFile;
import app.module.core.usecase.file.saveToStorage.ports.application.strategy.SftpConnector; import app.module.core.usecase.file.saveToStorage.ports.application.strategy.SftpConnector;
import app.module.core.usecase.file.updateFile.ports.application.domain.UploadFileDto;
import com.jcraft.jsch.ChannelSftp; import com.jcraft.jsch.ChannelSftp;
import com.jcraft.jsch.JSchException; import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.SftpException; import com.jcraft.jsch.SftpException;
@@ -28,7 +28,7 @@ public class SftpFileDeleteUtil {
* @throws JSchException SFTP 연결 오류 * @throws JSchException SFTP 연결 오류
* @throws SftpException SFTP 작업 오류 * @throws SftpException SFTP 작업 오류
*/ */
public void deleteRealFile(UploadFile deleteFile) throws JSchException, SftpException { public void deleteRealFile(UploadFileDto deleteFile) throws JSchException, SftpException {
if (deleteFile == null || deleteFile.getPath() == null || deleteFile.getName() == null) { if (deleteFile == null || deleteFile.getPath() == null || deleteFile.getName() == null) {
log.error("Invalid file information: {}", deleteFile); log.error("Invalid file information: {}", deleteFile);
throw new IllegalArgumentException("Invalid file information"); throw new IllegalArgumentException("Invalid file information");

View File

@@ -1,5 +1,6 @@
package app.module.core.usecase.article.getArticle.adapters.persistence; package app.module.core.usecase.article.getArticle.adapters.persistence;
import app.module.core.config.application.enums.FileStorageType;
import app.module.core.usecase.article.getArticle.ports.GetArticlePortOut; import app.module.core.usecase.article.getArticle.ports.GetArticlePortOut;
import app.module.core.usecase.article.getArticle.ports.application.domain.GetArticle; import app.module.core.usecase.article.getArticle.ports.application.domain.GetArticle;
import app.module.core.usecase.article.getArticle.ports.application.domain.GetArticleCmd; import app.module.core.usecase.article.getArticle.ports.application.domain.GetArticleCmd;
@@ -9,6 +10,7 @@ import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@@ -19,6 +21,9 @@ class GetArticleDao implements GetArticlePortOut {
private final GetArticleMapper mapper; private final GetArticleMapper mapper;
private final FileUrlPortIn fileUrlPortIn; private final FileUrlPortIn fileUrlPortIn;
@Value("${path.upload.storage}")
private String uploadStorageType;
@Override @Override
@Transactional @Transactional
public Optional<GetArticle> operate(GetArticleCmd command) { public Optional<GetArticle> operate(GetArticleCmd command) {
@@ -34,13 +39,13 @@ class GetArticleDao implements GetArticlePortOut {
// 참조 URL 전달 // 참조 URL 전달
uploadFile.setReferURL( uploadFile.setReferURL(
fileUrlPortIn.getInline( fileUrlPortIn.getInline(
uploadFile.getType().getFileStorageType(), FileStorageType.valueOf(uploadStorageType),
uploadFile.getPath(), uploadFile.getPath(),
uploadFile.getName())); uploadFile.getName()));
// attachment URL 전달 // attachment URL 전달
uploadFile.setAttachmentURL( uploadFile.setAttachmentURL(
fileUrlPortIn.getAttachment( fileUrlPortIn.getAttachment(
uploadFile.getType().getFileStorageType(), uploadFile.getId())); FileStorageType.valueOf(uploadStorageType), uploadFile.getId()));
return uploadFile; return uploadFile;
}) })

View File

@@ -77,6 +77,7 @@ public class DailyRecordDao implements DailyRecordPortOut {
); );
if ("ALL".equals(targetType)) { if ("ALL".equals(targetType)) {
// 전체 입력상태 변경
String allStatus = this.getUpdateAllStatus(recordMonth, dayGroupNo, householdSeq); String allStatus = this.getUpdateAllStatus(recordMonth, dayGroupNo, householdSeq);
if (allStatus != null) { if (allStatus != null) {
command.setAllStatus(allStatus); command.setAllStatus(allStatus);
@@ -88,7 +89,11 @@ public class DailyRecordDao implements DailyRecordPortOut {
} }
} else { } else {
// 항목 입력상태 변경
dailyRecordMapper.updateDailyRecordStatus(command); dailyRecordMapper.updateDailyRecordStatus(command);
// 전체 입력상태 변경
this.updateByAllStatus(command.getRecordMonth(), command.getDayGroupNo(), command.getHouseholdSeq());
} }
} }

View File

@@ -8,8 +8,10 @@ public interface DailyRecordPortIn {
/** /**
* 일계부 항목 조회 * 일계부 항목 조회
* *
* @param reqVO 검색 조건 * @param recordMonth
* @return 항목 상세 * @param dayGroupNo
* @param householdSeq
* @return 항목 상세
*/ */
DailyRecordDto detail(String recordMonth, Integer dayGroupNo, Long householdSeq); DailyRecordDto detail(String recordMonth, Integer dayGroupNo, Long householdSeq);

View File

@@ -15,7 +15,16 @@ public class UpdateDailyRecordStatusCmd extends AuditCommand {
private Integer dayGroupNo; private Integer dayGroupNo;
private Long householdSeq; private Long householdSeq;
/**
* 전체 입력상태
*/
private String allStatus; private String allStatus;
/**
* 변경 대상
*/
private String targetType; private String targetType;
/**
* 변경 대상 입력상태
*/
private String targetStatus; private String targetStatus;
} }

View File

@@ -1,12 +1,14 @@
package app.module.core.usecase.file.createFile.adapters.persistence; package app.module.core.usecase.file.createFile.adapters.persistence;
import app.module.core.config.adapters.persistence.entity.UploadFile; import app.module.core.config.adapters.persistence.entity.UploadFile;
import app.module.core.config.application.enums.FileStorageType;
import app.module.core.usecase.file.createFile.ports.CreateFilePortOut; import app.module.core.usecase.file.createFile.ports.CreateFilePortOut;
import app.module.core.usecase.file.createFile.ports.application.domain.CreateFile; import app.module.core.usecase.file.createFile.ports.application.domain.CreateFile;
import app.module.core.usecase.file.createFile.ports.application.domain.CreateFileCmd; import app.module.core.usecase.file.createFile.ports.application.domain.CreateFileCmd;
import app.module.core.usecase.file.url.application.port.in.FileUrlPortIn; import app.module.core.usecase.file.url.application.port.in.FileUrlPortIn;
import java.util.Optional; import java.util.Optional;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
@Repository @Repository
@@ -15,6 +17,10 @@ class CreateFileDao implements CreateFilePortOut {
private final CreateFileMapper mapper; private final CreateFileMapper mapper;
private final FileUrlPortIn fileUrlPortIn; private final FileUrlPortIn fileUrlPortIn;
@Value("${path.upload.storage}")
private String uploadStorageType;
@Override @Override
public Optional<CreateFile> operate(CreateFileCmd command) { public Optional<CreateFile> operate(CreateFileCmd command) {
UploadFile uploadFile = new UploadFile( UploadFile uploadFile = new UploadFile(
@@ -23,7 +29,7 @@ class CreateFileDao implements CreateFilePortOut {
command.getPath(), command.getPath(),
command.getName(), command.getName(),
command.getOriginName(), command.getOriginName(),
command.getFileLength()); command.getFileLength() );
mapper.insertFile(uploadFile); mapper.insertFile(uploadFile);
@@ -37,11 +43,11 @@ class CreateFileDao implements CreateFilePortOut {
uploadFile.getFileLength(), uploadFile.getFileLength(),
// 참조 URL 전달 // 참조 URL 전달
fileUrlPortIn.getInline( fileUrlPortIn.getInline(
uploadFile.getType().getFileStorageType(), FileStorageType.valueOf(uploadStorageType),
uploadFile.getPath(), uploadFile.getPath(),
uploadFile.getName()), uploadFile.getName()),
// attachment URL 전달 // attachment URL 전달
fileUrlPortIn.getAttachment( fileUrlPortIn.getAttachment(
uploadFile.getType().getFileStorageType(), uploadFile.getId()))); FileStorageType.valueOf(uploadStorageType), uploadFile.getId())));
} }
} }

View File

@@ -20,6 +20,7 @@ import java.util.Set;
import java.util.UUID; import java.util.UUID;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.tika.Tika; import org.apache.tika.Tika;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@@ -30,6 +31,8 @@ public class SaveToStorageService implements SaveToStoragePortIn {
private final MessageUtil messageUtil; private final MessageUtil messageUtil;
private final Tika tika; private final Tika tika;
private final Set<FileUploadStrategy> fileUploadStrategies; private final Set<FileUploadStrategy> fileUploadStrategies;
@Value("${path.upload.storage}")
private String uploadStorageType;
@Override @Override
public Optional<SaveToStorage> operate(FileUploadType fileUploadType, public Optional<SaveToStorage> operate(FileUploadType fileUploadType,
@@ -45,7 +48,7 @@ public class SaveToStorageService implements SaveToStoragePortIn {
String subPath = getDirPath(fileUploadType.getSubPath()); String subPath = getDirPath(fileUploadType.getSubPath());
String createFilename = getUUIDFilename(getFileExtension(originalFilename).orElse(null)); String createFilename = getUUIDFilename(getFileExtension(originalFilename).orElse(null));
getFileUploadStrategy(fileUploadType.getFileStorageType()) getFileUploadStrategy(FileStorageType.valueOf(uploadStorageType))
.operate(multipartFile, subPath, createFilename); .operate(multipartFile, subPath, createFilename);
return Optional.of( return Optional.of(
@@ -128,6 +131,6 @@ public class SaveToStorageService implements SaveToStoragePortIn {
() -> () ->
new NoSuchElementException( new NoSuchElementException(
String.format("No file upload strategy found: %s", String.format("No file upload strategy found: %s",
fileStorageType.name()))); fileStorageType.getName())));
} }
} }

View File

@@ -0,0 +1,66 @@
package app.module.core.usecase.file.updateFile.adapters.persistence;
import app.module.core.config.adapters.persistence.entity.UploadFile;
import app.module.core.config.application.annotation.DeleteCommand;
import app.module.core.config.application.annotation.UpdateCommand;
import app.module.core.config.application.enums.FileUploadType;
import app.module.core.config.application.util.CommonUtil;
import app.module.core.config.application.util.SftpFileDeleteUtil;
import app.module.core.usecase.file.createFile.ports.CreateFilePortOut;
import app.module.core.usecase.file.createFile.ports.application.domain.CreateFile;
import app.module.core.usecase.file.createFile.ports.application.domain.CreateFileCmd;
import app.module.core.usecase.file.updateFile.ports.UpdateFilePortOut;
import app.module.core.usecase.file.updateFile.ports.application.domain.UpdateFileCmd;
import app.module.core.usecase.file.updateFile.ports.application.domain.UpdateUploadFileParam;
import app.module.core.usecase.file.updateFile.ports.application.domain.UploadFileDto;
import app.module.core.usecase.file.url.application.port.in.FileUrlPortIn;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.SftpException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Optional;
@Slf4j
@Repository
@RequiredArgsConstructor
class UpdateFileDao implements UpdateFilePortOut {
private final UpdateFileMapper mapper;
private final SftpFileDeleteUtil sftpFileDeleteUtil;
@Override
@DeleteCommand
public void operate(UpdateFileCmd command) {
List<UploadFileDto> deletedFileList = mapper.findDeleteFileList(new UpdateUploadFileParam(
command.getId(),
command.getFileMappingIds(),
command.getType().getName()
));
for (UploadFileDto file : deletedFileList) {
try {
sftpFileDeleteUtil.deleteRealFile(file);
} catch (JSchException | SftpException e) {
log.error("Failed to delete file from SFTP for mapping ID {}: {}", file.getId(), e.getMessage(), e);
throw new RuntimeException("Failed to delete file from SFTP", e);
} catch (Exception e) {
log.error("Unexpected error while deleting file for mapping ID {}: {}", file.getId(), e.getMessage(), e);
throw new RuntimeException("Unexpected error while deleting file", e);
}
}
if (!deletedFileList.isEmpty()) {
mapper.deleteFile(
new UpdateUploadFileParam(
command.getId(),
deletedFileList.stream().map(UploadFileDto::getId).toList(),
command.getType().getName()));
}
command.getFileMappingIds().forEach(fileId -> mapper.updateFile(new UploadFileDto(fileId, command.getId(),command.getType().getName())));
}
}

View File

@@ -0,0 +1,14 @@
package app.module.core.usecase.file.updateFile.adapters.persistence;
import app.module.core.usecase.file.updateFile.ports.application.domain.UpdateUploadFileParam;
import app.module.core.usecase.file.updateFile.ports.application.domain.UploadFileDto;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface UpdateFileMapper {
List<UploadFileDto> findDeleteFileList(UpdateUploadFileParam uploadFile);
void deleteFile(UpdateUploadFileParam uploadFile);
void updateFile(UploadFileDto uploadFile);
}

View File

@@ -0,0 +1,8 @@
package app.module.core.usecase.file.updateFile.ports;
import app.module.core.usecase.file.updateFile.ports.application.domain.UpdateFileCmd;
public interface UpdateFilePortIn {
void operate(UpdateFileCmd command);
}

View File

@@ -0,0 +1,8 @@
package app.module.core.usecase.file.updateFile.ports;
import app.module.core.usecase.file.updateFile.ports.application.domain.UpdateFileCmd;
public interface UpdateFilePortOut {
void operate(UpdateFileCmd command);
}

View File

@@ -0,0 +1,20 @@
package app.module.core.usecase.file.updateFile.ports.application;
import app.module.core.usecase.file.updateFile.ports.UpdateFilePortIn;
import app.module.core.usecase.file.updateFile.ports.UpdateFilePortOut;
import app.module.core.usecase.file.updateFile.ports.application.domain.UpdateFileCmd;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
class UpdateFileService implements UpdateFilePortIn {
private final UpdateFilePortOut portOut;
@Override
public void operate(UpdateFileCmd command) {
portOut.operate(command);
}
}

View File

@@ -0,0 +1,19 @@
package app.module.core.usecase.file.updateFile.ports.application.domain;
import app.module.core.config.application.enums.FileUploadType;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class UpdateFileCmd {
private Long id;
private List<Long> fileMappingIds;
private FileUploadType type;
}

View File

@@ -0,0 +1,18 @@
package app.module.core.usecase.file.updateFile.ports.application.domain;
import app.module.core.config.adapters.persistence.component.AuditCommand;
import app.module.core.config.application.enums.FileUploadType;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@Setter
@Getter
@AllArgsConstructor
public class UpdateUploadFileParam extends AuditCommand {
private Long id;
private List<Long> fileMappingIds;
private String type;
}

View File

@@ -0,0 +1,43 @@
package app.module.core.usecase.file.updateFile.ports.application.domain;
import app.module.core.config.adapters.persistence.component.AuditCommand;
import app.module.core.config.adapters.persistence.component.AuditEntity;
import app.module.core.config.application.enums.FileUploadType;
import lombok.*;
import java.time.LocalDateTime;
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class UploadFileDto extends AuditCommand {
private Long id;
private Long mappingId;
private String type;
private String path;
private String name;
private String originName;
private Long fileLength;
private LocalDateTime updatedAt;
private String updatedBy;
public UploadFileDto(Long id) {
this.id = id;
}
public UploadFileDto(Long id, Long mappingId, String type) {
this.id = id;
this.mappingId = mappingId;
this.type = type;
}
}

View File

@@ -1,5 +1,6 @@
package app.module.core.usecase.getAttachment.adapters.web; package app.module.core.usecase.getAttachment.adapters.web;
import app.module.core.config.application.enums.FileStorageType;
import app.module.core.usecase.file.getFile.ports.GetFilePortIn; import app.module.core.usecase.file.getFile.ports.GetFilePortIn;
import app.module.core.usecase.file.getFile.ports.application.domain.GetFile; import app.module.core.usecase.file.getFile.ports.application.domain.GetFile;
import app.module.core.usecase.file.getFile.ports.application.domain.GetFileCmd; import app.module.core.usecase.file.getFile.ports.application.domain.GetFileCmd;
@@ -27,6 +28,8 @@ class GetAttachmentController {
private String cloudFrontDomain; private String cloudFrontDomain;
@Value("${app.aws.s3.bucketFolder:null}") @Value("${app.aws.s3.bucketFolder:null}")
private String bucketFolder; private String bucketFolder;
@Value("${path.upload.storage}")
private String uploadStorageType;
@GetMapping(path = "/content-disposition/attachment/{fileId}") @GetMapping(path = "/content-disposition/attachment/{fileId}")
ResponseEntity<?> operate(@PathVariable Long fileId) throws MalformedURLException { ResponseEntity<?> operate(@PathVariable Long fileId) throws MalformedURLException {
@@ -55,7 +58,7 @@ class GetAttachmentController {
UrlResource resource = null; UrlResource resource = null;
switch (getFile.getType().getFileStorageType()) { switch (FileStorageType.valueOf(uploadStorageType)) {
case LOCAL: case LOCAL:
String filePath = String filePath =
Paths.get(publicPath, getFile.getPath(), getFile.getName()) Paths.get(publicPath, getFile.getPath(), getFile.getName())

View File

@@ -1,7 +1,7 @@
package app.module.admin.usecase.loggedinuser.save.adapter.persistence; package app.module.core.usecase.loggedinuser.save.adapter.persistence;
import app.module.admin.usecase.loggedinuser.save.ports.LoggedInUserSavePortOut; import app.module.core.usecase.loggedinuser.save.ports.LoggedInUserSavePortOut;
import app.module.admin.usecase.loggedinuser.save.ports.application.domain.LoggedInUserSaveCmd; import app.module.core.usecase.loggedinuser.save.ports.application.domain.LoggedInUserSaveCmd;
import app.module.core.config.adapters.persistence.entity.LoggedInUser; import app.module.core.config.adapters.persistence.entity.LoggedInUser;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;

View File

@@ -1,4 +1,4 @@
package app.module.admin.usecase.loggedinuser.save.adapter.persistence; package app.module.core.usecase.loggedinuser.save.adapter.persistence;
import app.module.core.config.adapters.persistence.entity.LoggedInUser; import app.module.core.config.adapters.persistence.entity.LoggedInUser;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;

View File

@@ -0,0 +1,8 @@
package app.module.core.usecase.loggedinuser.save.ports;
import app.module.core.usecase.loggedinuser.save.ports.application.domain.LoggedInUserSaveCmd;
public interface LoggedInUserSavePortIn {
void connect(LoggedInUserSaveCmd loggedInUserSaveCmd);
}

View File

@@ -0,0 +1,8 @@
package app.module.core.usecase.loggedinuser.save.ports;
import app.module.core.usecase.loggedinuser.save.ports.application.domain.LoggedInUserSaveCmd;
public interface LoggedInUserSavePortOut {
void connect(LoggedInUserSaveCmd loggedInUser);
}

View File

@@ -1,8 +1,8 @@
package app.module.admin.usecase.loggedinuser.save.ports.application; package app.module.core.usecase.loggedinuser.save.ports.application;
import app.module.admin.usecase.loggedinuser.save.ports.LoggedInUserSavePortIn; import app.module.core.usecase.loggedinuser.save.ports.LoggedInUserSavePortIn;
import app.module.admin.usecase.loggedinuser.save.ports.LoggedInUserSavePortOut; import app.module.core.usecase.loggedinuser.save.ports.LoggedInUserSavePortOut;
import app.module.admin.usecase.loggedinuser.save.ports.application.domain.LoggedInUserSaveCmd; import app.module.core.usecase.loggedinuser.save.ports.application.domain.LoggedInUserSaveCmd;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;

View File

@@ -1,11 +1,7 @@
package app.module.admin.usecase.loggedinuser.save.ports.application.domain; package app.module.core.usecase.loggedinuser.save.ports.application.domain;
import app.module.core.config.application.enums.AppType; import app.module.core.config.application.enums.AppType;
import lombok.AllArgsConstructor; import lombok.*;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter @Getter
@Setter @Setter

View File

@@ -1,11 +1,8 @@
package app.module.admin.usecase.loggedinuser.save.ports.application.domain; package app.module.core.usecase.loggedinuser.save.ports.application.domain;
import lombok.*;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Builder @Builder
@Getter @Getter

View File

@@ -1,6 +1,5 @@
package app.module.core.usecase.uicode.view.adapters.persistence; package app.module.core.usecase.uicode.view.adapters.persistence;
import app.module.core.config.adapters.persistence.repository.UICodeRepo;
import app.module.core.usecase.uicode.view.ports.UICodeViewPortOut; import app.module.core.usecase.uicode.view.ports.UICodeViewPortOut;
import app.module.core.usecase.uicode.view.ports.application.domain.UICodeView; import app.module.core.usecase.uicode.view.ports.application.domain.UICodeView;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;

View File

@@ -1,5 +1,6 @@
package app.module.core.usecase.uri.save.ports.application; package app.module.core.usecase.uri.save.ports.application;
import app.module.core.config.application.enums.FileStorageType;
import app.module.core.config.application.enums.FileUploadType; import app.module.core.config.application.enums.FileUploadType;
import app.module.core.config.application.exception.AlreadyExistItemException; import app.module.core.config.application.exception.AlreadyExistItemException;
import app.module.core.config.application.util.MessageUtil; import app.module.core.config.application.util.MessageUtil;
@@ -11,6 +12,7 @@ import app.module.core.usecase.uri.save.ports.URISavePortIn;
import app.module.core.usecase.uri.save.ports.URISavePortOut; import app.module.core.usecase.uri.save.ports.URISavePortOut;
import app.module.core.usecase.uri.save.ports.application.domain.URISaveCommand; import app.module.core.usecase.uri.save.ports.application.domain.URISaveCommand;
import app.module.core.usecase.uri.view.ports.URIViewPortIn; import app.module.core.usecase.uri.view.ports.URIViewPortIn;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.io.IOException; import java.io.IOException;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@@ -28,6 +30,8 @@ class URISaveService implements URISavePortIn {
private final MessageUtil messageUtil; private final MessageUtil messageUtil;
private final SaveToStoragePortIn saveToStoragePortIn; private final SaveToStoragePortIn saveToStoragePortIn;
private final FileUrlPortIn fileUrlPortIn; private final FileUrlPortIn fileUrlPortIn;
@Value("${path.upload.storage}")
private String uploadStorageType;
@Transactional @Transactional
@CacheEvict( @CacheEvict(
@@ -59,7 +63,7 @@ class URISaveService implements URISavePortIn {
uri.setOgImage( uri.setOgImage(
fileUrlPortIn.getInline( fileUrlPortIn.getInline(
ogImg.getType().getFileStorageType(), ogImg.getPath(), ogImg.getName())); FileStorageType.valueOf(uploadStorageType), ogImg.getPath(), ogImg.getName()));
} }
return uriSavePortOut.connect(uri); return uriSavePortOut.connect(uri);

View File

@@ -1,5 +1,6 @@
package app.module.core.usecase.user.findUser.ports.application; package app.module.core.usecase.user.findUser.ports.application;
import app.module.core.config.application.enums.FileStorageType;
import app.module.core.usecase.file.url.application.port.in.FileUrlPortIn; import app.module.core.usecase.file.url.application.port.in.FileUrlPortIn;
import app.module.core.usecase.user.findUser.ports.FindUserPortIn; import app.module.core.usecase.user.findUser.ports.FindUserPortIn;
import app.module.core.usecase.user.findUser.ports.FindUserPortOut; import app.module.core.usecase.user.findUser.ports.FindUserPortOut;
@@ -8,6 +9,7 @@ import app.module.core.usecase.user.findUser.ports.application.domain.FindUser;
import app.module.core.usecase.user.findUser.ports.application.domain.FindUserCmd; import app.module.core.usecase.user.findUser.ports.application.domain.FindUserCmd;
import java.util.Optional; import java.util.Optional;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@Service @Service
@@ -17,6 +19,9 @@ class FindUserService implements FindUserPortIn {
private final FindUserPortOut portOut; private final FindUserPortOut portOut;
private final FileUrlPortIn fileUrlPortIn; private final FileUrlPortIn fileUrlPortIn;
@Value("${path.upload.storage}")
private String uploadStorageType;
@Override @Override
public Optional<FindUser> operate(FindUserCmd command) { public Optional<FindUser> operate(FindUserCmd command) {
return portOut return portOut
@@ -29,14 +34,14 @@ class FindUserService implements FindUserPortIn {
// 참조 URL 전달 // 참조 URL 전달
profileImg.setReferURL( profileImg.setReferURL(
fileUrlPortIn.getInline( fileUrlPortIn.getInline(
profileImg.getType().getFileStorageType(), FileStorageType.valueOf(uploadStorageType),
profileImg.getPath(), profileImg.getPath(),
profileImg.getName())); profileImg.getName()));
// attachment URL 전달 // attachment URL 전달
profileImg.setAttachmentURL( profileImg.setAttachmentURL(
fileUrlPortIn.getAttachment( fileUrlPortIn.getAttachment(
profileImg.getType().getFileStorageType(), profileImg.getId())); FileStorageType.valueOf(uploadStorageType), profileImg.getId()));
} }
return Optional.of(findUser); return Optional.of(findUser);

View File

@@ -87,7 +87,6 @@
, all_status = #{allStatus} , all_status = #{allStatus}
</if> </if>
<if test="targetType != null and targetType != ''"> <if test="targetType != null and targetType != ''">
/* TODO 개별 상태값 변경 */
<choose> <choose>
<when test="targetType eq 'INCOME'"> <when test="targetType eq 'INCOME'">
, income_status = #{targetStatus} , income_status = #{targetStatus}

View File

@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="app.module.core.usecase.file.updateFile.adapters.persistence.UpdateFileMapper">
<select id="findDeleteFileList" resultType="app.module.core.usecase.file.updateFile.ports.application.domain.UploadFileDto">
SELECT file_length,
id,
name,
origin_name,
path,
type,
mapping_id
FROM upload_file
WHERE type = #{type} and mapping_id = #{id} and is_deleted = false
<if test="fileMappingIds != null and fileMappingIds.size() > 0">
and id NOT IN (
<foreach collection="fileMappingIds" item="fileId" separator="," >
#{fileId}
</foreach>
)
</if>
</select>
<update id="deleteFile">
UPDATE upload_file
SET
<include refid="common.fields.DeleteBaseSet"/>
WHERE type = #{type} and mapping_id = #{id} and is_deleted = false
<if test="fileMappingIds != null and fileMappingIds.size() > 0">
and id IN (
<foreach collection="fileMappingIds" item="fileId" separator="," >
#{fileId}
</foreach>
)
</if>
</update>
<update id="updateFile" >
UPDATE upload_file
SET mapping_id = #{mappingId},
type = #{type},
<include refid="common.fields.UpdateBaseSet"/>
WHERE id = #{id}
</update>
</mapper>

View File

@@ -2,7 +2,7 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" > "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper <mapper
namespace="app.module.admin.usecase.loggedinuser.save.adapter.persistence.LoggedInUserSaveMapper"> namespace="app.module.core.usecase.loggedinuser.save.adapter.persistence.LoggedInUserSaveMapper">
<insert id="insert" parameterType="app.module.core.config.adapters.persistence.entity.LoggedInUser"> <insert id="insert" parameterType="app.module.core.config.adapters.persistence.entity.LoggedInUser">
INSERT INTO logged_in_user INSERT INTO logged_in_user

View File

@@ -83,7 +83,8 @@ COMMENT ON COLUMN role.is_deleted IS '삭제 여부';
CREATE SEQUENCE upload_file_seq START WITH 1 INCREMENT BY 1 CACHE 1 NO CYCLE; CREATE SEQUENCE upload_file_seq START WITH 1 INCREMENT BY 1 CACHE 1 NO CYCLE;
CREATE TABLE upload_file ( CREATE TABLE upload_file (
id bigint DEFAULT nextval('upload_file_seq') NOT NULL, -- 파일 ID (PK) id int8 DEFAULT nextval('upload_file_seq') NOT NULL, -- 파일 ID (PK)
mapping_id int8, -- 파일 매핑 ID
name varchar(255), -- 시스템 저장 파일명 name varchar(255), -- 시스템 저장 파일명
origin_name varchar(255), -- 원본 파일명 origin_name varchar(255), -- 원본 파일명
path varchar(255), -- 파일 경로 path varchar(255), -- 파일 경로
@@ -115,6 +116,7 @@ CREATE TABLE upload_file (
COMMENT ON TABLE upload_file IS '업로드 파일 정보 테이블'; COMMENT ON TABLE upload_file IS '업로드 파일 정보 테이블';
COMMENT ON COLUMN upload_file.id IS '파일 ID (PK)'; COMMENT ON COLUMN upload_file.id IS '파일 ID (PK)';
COMMENT ON COLUMN upload_file.mapping_id IS '파일 매핑 ID';
COMMENT ON COLUMN upload_file.name IS '시스템 저장 파일명'; COMMENT ON COLUMN upload_file.name IS '시스템 저장 파일명';
COMMENT ON COLUMN upload_file.origin_name IS '원본 파일명'; COMMENT ON COLUMN upload_file.origin_name IS '원본 파일명';
COMMENT ON COLUMN upload_file.path IS '파일 경로'; COMMENT ON COLUMN upload_file.path IS '파일 경로';
@@ -1865,37 +1867,6 @@ COMMENT ON COLUMN notice.is_deleted IS '삭제여부';
-- ============================================
-- TABLE : notice_has_upload_file
-- DESC : 공지사항 파일 매핑 테이블
-- ============================================
CREATE TABLE notice_has_upload_file (
upload_files_id bigint NOT NULL, -- 업로드 파일 ID (FK)
notice_id varchar(255) NOT NULL, -- 공지사항 ID (FK)
created_at timestamp(6), -- 생성일
created_by varchar(255), -- 생성자
updated_at timestamp(6), -- 수정일
updated_by varchar(255), -- 수정자
deleted_at timestamp(6), -- 삭제일
deleted_by varchar(255), -- 삭제자
is_deleted boolean DEFAULT false NOT NULL -- 삭제 여부
);
ALTER TABLE notice_has_upload_file ADD CONSTRAINT fk_notice_has_upload_file__notice FOREIGN KEY (notice_id) REFERENCES notice(id);
ALTER TABLE notice_has_upload_file ADD CONSTRAINT fk_notice_has_upload_file__upload_file FOREIGN KEY (upload_files_id) REFERENCES upload_file(id);
COMMENT ON TABLE notice_has_upload_file IS '공지사항 파일 매핑 테이블';
COMMENT ON COLUMN notice_has_upload_file.upload_files_id IS '업로드 파일 ID';
COMMENT ON COLUMN notice_has_upload_file.notice_id IS '공지사항 ID';
COMMENT ON COLUMN notice_has_upload_file.created_at IS '생성일';
COMMENT ON COLUMN notice_has_upload_file.created_by IS '생성자';
COMMENT ON COLUMN notice_has_upload_file.updated_at IS '수정일';
COMMENT ON COLUMN notice_has_upload_file.updated_by IS '수정자';
COMMENT ON COLUMN notice_has_upload_file.deleted_at IS '삭제일';
COMMENT ON COLUMN notice_has_upload_file.deleted_by IS '삭제자';
COMMENT ON COLUMN notice_has_upload_file.is_deleted IS '삭제여부';
-- ============================================ -- ============================================

View File

@@ -0,0 +1,56 @@
package app.module.front.config.application.security;
import app.module.core.config.application.enums.AppType;
import app.module.core.config.application.util.CommonUtil;
import app.module.core.usecase.loggedinuser.save.ports.LoggedInUserSavePortIn;
import app.module.core.usecase.loggedinuser.save.ports.application.domain.LoggedInUserIdSaveCmd;
import app.module.core.usecase.loggedinuser.save.ports.application.domain.LoggedInUserSaveCmd;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.security.authentication.event.AbstractAuthenticationFailureEvent;
import org.springframework.security.authentication.event.AuthenticationSuccessEvent;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import java.time.LocalDateTime;
@Component
@RequiredArgsConstructor
@Slf4j
public class FrontAuthSuccessEvent {
private final LoggedInUserSavePortIn loggedInUserSavePortIn;
@EventListener
public void handleAuthenticationSuccessEvent(AuthenticationSuccessEvent event) {
Authentication authentication = event.getAuthentication();
FrontHouseholdUser householdUser = (FrontHouseholdUser) authentication.getPrincipal();
HttpServletRequest request =
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
// 로그인 이력 쌓기
loggedInUserSavePortIn.connect(
LoggedInUserSaveCmd.builder()
.loggedInUserId(
LoggedInUserIdSaveCmd.builder()
.appType(AppType.FRONT)
.id(authentication.getName())
.build())
.clientIP(CommonUtil.getClientIP(request))
.lastLoggedInAt(LocalDateTime.now())
.build());
}
@EventListener
public void handleAuthenticationFailureEvent(AbstractAuthenticationFailureEvent event) {
Exception e = event.getException();
Authentication authentication = event.getAuthentication();
log.warn("Unsuccessful authentication result: {}", authentication, e);
}
}

View File

@@ -77,7 +77,6 @@ public class DailyRecordController {
DailyRecordDto detail = dailyRecordPortIn.detail(reqVO.getSearchMonth(), reqVO.getGroupNo(), reqVO.getHouseholdSeq()); DailyRecordDto detail = dailyRecordPortIn.detail(reqVO.getSearchMonth(), reqVO.getGroupNo(), reqVO.getHouseholdSeq());
// TODO : true / false 를 업데이트하는 것은 대상 타켓이 되는 것이라 판단하여 그냥 강제 업데이트할 것인가? valid 체크
dailyRecordPortIn.updateByStatus(detail.getRecordMonth(), detail.getGroupNo(), reqVO.getHouseholdSeq(), targetType, "Y".equals(targetStatus) ? DailyTargetStatus.TODAY_NONE.name() : DailyTargetStatus.TARGET.name()); dailyRecordPortIn.updateByStatus(detail.getRecordMonth(), detail.getGroupNo(), reqVO.getHouseholdSeq(), targetType, "Y".equals(targetStatus) ? DailyTargetStatus.TODAY_NONE.name() : DailyTargetStatus.TARGET.name());
return ResponseEntity.status(HttpStatus.OK).body(reqVO); return ResponseEntity.status(HttpStatus.OK).body(reqVO);

View File

@@ -246,10 +246,15 @@ kri.form.error = function(errorList){
} }
} }
kri.form.maxlength = function(object){ $(function() {
if (object.value.length > object.maxLength) { $('body').on('input', 'input[type="number"]', function() {
object.value = object.value.slice(0, object.maxLength); let $el = $(this);
} if ($el.val().length > $el.attr('maxlength')) {
} $el.val($el.val().slice(0, $el.attr('maxlength')));
}
if ($el.attr('inputmode') === 'numeric') {
$el.val($el.val().replace('.', ''));
}
})
})

View File

@@ -120,8 +120,8 @@
</label> </label>
</div> </div>
<div class="input-field"> <div class="input-field">
<input type="number" id="count" placeholder="수량을 입력해 주세요" name="count" class="limitDecimalLength" <input type="number" id="count" placeholder="수량을 입력해 주세요" name="count" class="limitDecimalLength" min="1" max="9999999999"
inputmode="decimal" pattern="[0-9]*" maxlength="10" oninput="kri.form.maxlength(this)"> inputmode="decimal" pattern="[0-9]*" maxlength="10" >
</div> </div>
<ul class="guide-info"> <ul class="guide-info">
<li>예 : 2, 2.5</li> <li>예 : 2, 2.5</li>
@@ -181,8 +181,8 @@
</div> </div>
<div class="input-field type-price"> <div class="input-field type-price">
<input type="number" id="price" name="price" placeholder="금액을 입력해 주세요" <input type="number" id="price" name="price" placeholder="금액을 입력해 주세요"
class="limitAmountLength" class="limitAmountLength" min="1" max="9999999999"
maxlength="10" inputmode="numeric" pattern="[0-9]*" oninput="kri.form.maxlength(this)"> maxlength="10" inputmode="numeric" pattern="[0-9]*" >
<span class="input-field-txt">원</span> <span class="input-field-txt">원</span>
</div> </div>
<ul class="input-info" style="display:none"> <ul class="input-info" style="display:none">

View File

@@ -83,8 +83,8 @@
</label> </label>
</div> </div>
<div class="input-field"> <div class="input-field">
<input type="number" id="count" placeholder="수량을 입력해 주세요" name="count" class="limitDecimalLength" <input type="number" id="count" placeholder="수량을 입력해 주세요" name="count" class="limitDecimalLength" min="1" max="9999999999"
inputmode="decimal" pattern="[0-9]*" maxlength="10" oninput="kri.form.maxlength(this)"> inputmode="decimal" pattern="[0-9]*" maxlength="10" >
</div> </div>
<ul class="guide-info"> <ul class="guide-info">
<li>예 : 2, 2.5</li> <li>예 : 2, 2.5</li>
@@ -145,9 +145,9 @@
</label> </label>
</div> </div>
<div class="input-field type-price"> <div class="input-field type-price">
<input type="number" id="price" placeholder="금액을 입력해 주세요" name="price" <input type="number" id="price" placeholder="금액을 입력해 주세요" name="price" min="1" max="9999999999"
class="limitAmountLength" class="limitAmountLength"
maxlength="10" inputmode="numeric" pattern="[0-9]*" oninput="kri.form.maxlength(this)"> maxlength="10" inputmode="numeric" pattern="[0-9]*" >
<span class="input-field-txt">원</span> <span class="input-field-txt">원</span>
</div> </div>
<ul class="input-info" style="display:none"> <ul class="input-info" style="display:none">

Some files were not shown because too many files have changed in this diff Show More