월 변경

This commit is contained in:
주우성
2025-06-16 20:28:18 +09:00
parent 8ed3249ab4
commit 59e80d87a4
7 changed files with 272 additions and 96 deletions

View File

@@ -1,13 +1,14 @@
package app.module.front.usecase.info.bankUI.getBankInputUI.adapters.web;
import app.module.core.config.application.enums.MonthStatus;
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
import app.module.front.config.application.util.AuthUtil;
import app.module.front.usecase.info.monthly.getMonthlyInputStatuss.ports.GetMonthlyInputStatussPortIn;
import app.module.front.usecase.info.monthly.getMonthlyInputStatuss.ports.application.domain.GetMonthlyInputStatuss;
import app.module.front.usecase.info.monthly.getMonthlyInputStatuss.ports.application.domain.GetMonthlyInputStatussCmd;
import app.module.front.usecase.info.monthly.getMonthlyInputStatus.ports.GetMonthlyInputStatusPortIn;
import app.module.front.usecase.info.monthly.getMonthlyInputStatus.ports.application.domain.GetMonthlyInputStatus;
import app.module.front.usecase.info.monthly.getMonthlyInputStatus.ports.application.domain.GetMonthlyInputStatusCmd;
import app.module.front.usecase.info.monthly.getPrevMonthlyInputStatus.ports.GetPrevMonthlyInputStatusPortIn;
import app.module.front.usecase.info.monthly.getPrevMonthlyInputStatus.ports.application.domain.GetPrevMonthlyInputStatus;
import app.module.front.usecase.info.monthly.getPrevMonthlyInputStatus.ports.application.domain.GetPrevMonthlyInputStatusCmd;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.PageableDefault;
@@ -17,15 +18,18 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import java.time.LocalDate;
import java.time.YearMonth;
import java.time.format.DateTimeFormatter;
import java.util.NoSuchElementException;
@Controller
@RequiredArgsConstructor
class GetBankInputUIController {
private final GetMonthlyInputStatussPortIn portIn;
private final GetPrevMonthlyInputStatusPortIn prevMonthlyInputStatusPortIn;
private final GetMonthlyInputStatusPortIn getMonthlyInputStatusPortIn;
private final UICodeListPortIn uiCodeListPortIn;
@GetMapping(path = "/info/bank/create/input/{id}")
@@ -33,7 +37,39 @@ class GetBankInputUIController {
@PathVariable Long id,
@PageableDefault(sort = "createAt", direction = Sort.Direction.DESC, page = 0, size = 100) Pageable pageable) {
String currentMonth = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM"));
String currentMonth = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMM"));
// 전달 입력 상태 취득 , 데이터가 없을 경우 null
// 이전달 입력상태:NONE일 경우도 null
GetPrevMonthlyInputStatus pastMonthlyInfo =
prevMonthlyInputStatusPortIn.operate(
new GetPrevMonthlyInputStatusCmd(
id, AuthUtil.getUserSeq())).orElse(null);
//이번달 달 입력 상태 취득
GetMonthlyInputStatus currentMonthlyInfo =
getMonthlyInputStatusPortIn.operate(
new GetMonthlyInputStatusCmd(
id, AuthUtil.getUserSeq())).orElse(null);
//수정 가능 여부 판단
YearMonth yearMonth = YearMonth.parse(currentMonthlyInfo.getMonth());
LocalDate maxMonth = yearMonth.plusMonths(1).atDay(15);
LocalDate today = LocalDate.now();
boolean editable = !today.isAfter(maxMonth);
model.addAttribute("pastMonthlyInfo", pastMonthlyInfo);
model.addAttribute("currentMonthlyInfo", currentMonthlyInfo);
model.addAttribute("transferCategoryList", uiCodeListPortIn.connect("code.bank.input"));
model.addAttribute("codeRecordCropList", uiCodeListPortIn.connect("code.record.crop"));
model.addAttribute("unitList", uiCodeListPortIn.connect("code.record.unit"));
model.addAttribute("editable", editable);
return "info/bank/input";
}

View File

@@ -32,7 +32,7 @@ class GetBankOutputUIController {
@PathVariable Long id,
@PageableDefault(sort = "createAt", direction = Sort.Direction.DESC, page = 0, size = 100) Pageable pageable) {
String currentMonth = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM"));
String currentMonth = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMM"));
return "info/bank/output";
}

View File

@@ -66,7 +66,7 @@ class GetBanksUIController {
@GetMapping(path = "/info/bank")
String operate() {
String currentMonth = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM"));
String currentMonth = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMM"));
return "redirect:/info/bank/" + currentMonth;

View File

@@ -26,10 +26,19 @@ public class GetMonthlyInputStatus {
private String updatedBy;
public String getKoreanMonth() {
if (month != null && month.contains("-")) {
String[] parts = month.split("-");
return parts[0] + "년 " + Integer.parseInt(parts[1]) + "월";
if (month != null) {
if (month.contains("-")) {
// 기존 처리: "2025-05" → "2025년 5월"
String[] parts = month.split("-");
return parts[0] + "년 " + Integer.parseInt(parts[1]) + "월";
} else if (month.length() == 6) {
// 신규 처리: "202505" → "2025년 5월"
String year = month.substring(0, 4);
String monthPart = month.substring(4, 6);
return year + "년 " + Integer.parseInt(monthPart) + "월";
}
}
return "";
}
}

View File

@@ -27,9 +27,17 @@ public class GetMonthlyInputStatuss {
private String updatedBy;
public String getKoreanMonth() {
if (month != null && month.contains("-")) {
String[] parts = month.split("-");
return parts[0] + "년 " + Integer.parseInt(parts[1]) + "월";
if (month != null) {
if (month.contains("-")) {
// 기존 처리: "2025-05" → "2025년 5월"
String[] parts = month.split("-");
return parts[0] + "년 " + Integer.parseInt(parts[1]) + "월";
} else if (month.length() == 6) {
// 신규 처리: "202505" → "2025년 5월"
String year = month.substring(0, 4);
String monthPart = month.substring(4, 6);
return year + "년 " + Integer.parseInt(monthPart) + "월";
}
}
return "";
}