diff --git a/core/src/main/java/app/module/core/usecase/product/removeMonthForestProducts/adapters/persistence/RemoveMonthForestProductsDao.java b/core/src/main/java/app/module/core/usecase/product/removeMonthForestProducts/adapters/persistence/RemoveMonthForestProductsDao.java new file mode 100644 index 00000000..cf20430e --- /dev/null +++ b/core/src/main/java/app/module/core/usecase/product/removeMonthForestProducts/adapters/persistence/RemoveMonthForestProductsDao.java @@ -0,0 +1,26 @@ +package app.module.core.usecase.product.removeMonthForestProducts.adapters.persistence; + +import app.module.core.config.application.util.CommonUtil; +import app.module.core.usecase.product.removeMonthForestProducts.adapters.persistence.model.RemoveMonthForestProductsParam; +import app.module.core.usecase.product.removeMonthForestProducts.ports.RemoveMonthForestProductsPortOut; +import app.module.core.usecase.product.removeMonthForestProducts.ports.application.domain.RemoveMonthForestProductsCmd; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Repository; + +import java.time.LocalDateTime; + +@Repository +@RequiredArgsConstructor +class RemoveMonthForestProductsDao implements RemoveMonthForestProductsPortOut { + + private final RemoveMonthForestProductsMapper mapper; + + @Override + public void operate(RemoveMonthForestProductsCmd command) { + String loginUser = CommonUtil.getLoginUsername();; + LocalDateTime now = LocalDateTime.now(); + + mapper.deleteForestProducts( + new RemoveMonthForestProductsParam(command.getId(), command.getHouseholdSeq(), now, loginUser, now, loginUser)); + } +} diff --git a/core/src/main/java/app/module/core/usecase/product/removeMonthForestProducts/adapters/persistence/RemoveMonthForestProductsMapper.java b/core/src/main/java/app/module/core/usecase/product/removeMonthForestProducts/adapters/persistence/RemoveMonthForestProductsMapper.java new file mode 100644 index 00000000..4bbb1873 --- /dev/null +++ b/core/src/main/java/app/module/core/usecase/product/removeMonthForestProducts/adapters/persistence/RemoveMonthForestProductsMapper.java @@ -0,0 +1,9 @@ +package app.module.core.usecase.product.removeMonthForestProducts.adapters.persistence; + +import app.module.core.usecase.product.removeMonthForestProducts.adapters.persistence.model.RemoveMonthForestProductsParam; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface RemoveMonthForestProductsMapper { + void deleteForestProducts(RemoveMonthForestProductsParam param); +} diff --git a/core/src/main/java/app/module/core/usecase/product/removeMonthForestProducts/adapters/persistence/model/RemoveMonthForestProductsParam.java b/core/src/main/java/app/module/core/usecase/product/removeMonthForestProducts/adapters/persistence/model/RemoveMonthForestProductsParam.java new file mode 100644 index 00000000..227bd923 --- /dev/null +++ b/core/src/main/java/app/module/core/usecase/product/removeMonthForestProducts/adapters/persistence/model/RemoveMonthForestProductsParam.java @@ -0,0 +1,20 @@ +package app.module.core.usecase.product.removeMonthForestProducts.adapters.persistence.model; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.Setter; + +import java.time.LocalDateTime; +import java.util.Set; + +@Getter +@Setter +@AllArgsConstructor +public class RemoveMonthForestProductsParam { + private Long id; + private Long householdSeq; + private LocalDateTime updatedAt; + private String updatedBy; + private LocalDateTime deletedAt; + private String deletedBy; +} diff --git a/core/src/main/java/app/module/core/usecase/product/removeMonthForestProducts/ports/RemoveMonthForestProductsPortIn.java b/core/src/main/java/app/module/core/usecase/product/removeMonthForestProducts/ports/RemoveMonthForestProductsPortIn.java new file mode 100644 index 00000000..533ee381 --- /dev/null +++ b/core/src/main/java/app/module/core/usecase/product/removeMonthForestProducts/ports/RemoveMonthForestProductsPortIn.java @@ -0,0 +1,7 @@ +package app.module.core.usecase.product.removeMonthForestProducts.ports; + +import app.module.core.usecase.product.removeMonthForestProducts.ports.application.domain.RemoveMonthForestProductsCmd; + +public interface RemoveMonthForestProductsPortIn { + void operate(RemoveMonthForestProductsCmd command); +} \ No newline at end of file diff --git a/core/src/main/java/app/module/core/usecase/product/removeMonthForestProducts/ports/RemoveMonthForestProductsPortOut.java b/core/src/main/java/app/module/core/usecase/product/removeMonthForestProducts/ports/RemoveMonthForestProductsPortOut.java new file mode 100644 index 00000000..ed6df1df --- /dev/null +++ b/core/src/main/java/app/module/core/usecase/product/removeMonthForestProducts/ports/RemoveMonthForestProductsPortOut.java @@ -0,0 +1,7 @@ +package app.module.core.usecase.product.removeMonthForestProducts.ports; + +import app.module.core.usecase.product.removeMonthForestProducts.ports.application.domain.RemoveMonthForestProductsCmd; + +public interface RemoveMonthForestProductsPortOut { + void operate(RemoveMonthForestProductsCmd command); +} \ No newline at end of file diff --git a/core/src/main/java/app/module/core/usecase/product/removeMonthForestProducts/ports/application/RemoveMonthForestProductsService.java b/core/src/main/java/app/module/core/usecase/product/removeMonthForestProducts/ports/application/RemoveMonthForestProductsService.java new file mode 100644 index 00000000..a3cbea45 --- /dev/null +++ b/core/src/main/java/app/module/core/usecase/product/removeMonthForestProducts/ports/application/RemoveMonthForestProductsService.java @@ -0,0 +1,19 @@ +package app.module.core.usecase.product.removeMonthForestProducts.ports.application; + +import app.module.core.usecase.product.removeMonthForestProducts.ports.RemoveMonthForestProductsPortIn; +import app.module.core.usecase.product.removeMonthForestProducts.ports.RemoveMonthForestProductsPortOut; +import app.module.core.usecase.product.removeMonthForestProducts.ports.application.domain.RemoveMonthForestProductsCmd; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +class RemoveMonthForestProductsService implements RemoveMonthForestProductsPortIn { + + private final RemoveMonthForestProductsPortOut portOut; + + @Override + public void operate(RemoveMonthForestProductsCmd command) { + portOut.operate(command); + } +} \ No newline at end of file diff --git a/core/src/main/java/app/module/core/usecase/product/removeMonthForestProducts/ports/application/domain/RemoveMonthForestProductsCmd.java b/core/src/main/java/app/module/core/usecase/product/removeMonthForestProducts/ports/application/domain/RemoveMonthForestProductsCmd.java new file mode 100644 index 00000000..dca3cb1f --- /dev/null +++ b/core/src/main/java/app/module/core/usecase/product/removeMonthForestProducts/ports/application/domain/RemoveMonthForestProductsCmd.java @@ -0,0 +1,17 @@ +package app.module.core.usecase.product.removeMonthForestProducts.ports.application.domain; + +import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; + +import java.util.Set; + +@Getter +@Setter +@AllArgsConstructor +@EqualsAndHashCode +public class RemoveMonthForestProductsCmd { + private Long id; + private Long householdSeq; +} diff --git a/core/src/main/resources/mappers/product/RemoveMonthForestProductsMapper.xml b/core/src/main/resources/mappers/product/RemoveMonthForestProductsMapper.xml new file mode 100644 index 00000000..7197e2aa --- /dev/null +++ b/core/src/main/resources/mappers/product/RemoveMonthForestProductsMapper.xml @@ -0,0 +1,16 @@ + + + + + /* deleteForestProducts : 게시물 삭제 */ + UPDATE forest_product + SET + WHERE + household_seq = #{householdSeq} + AND monthly_input_status_id = #{id} + + + + \ No newline at end of file diff --git a/front/src/main/java/app/module/front/usecase/info/monthly/createMonthlyUI/adapters/web/CreateMonthlyController.java b/front/src/main/java/app/module/front/usecase/info/monthly/createMonthlyUI/adapters/web/CreateMonthlyController.java index 93c7afab..6e62b90e 100644 --- a/front/src/main/java/app/module/front/usecase/info/monthly/createMonthlyUI/adapters/web/CreateMonthlyController.java +++ b/front/src/main/java/app/module/front/usecase/info/monthly/createMonthlyUI/adapters/web/CreateMonthlyController.java @@ -9,6 +9,8 @@ import app.module.core.usecase.monthly.updateMonthlyInputStatus.ports.UpdateMont import app.module.core.usecase.monthly.updateMonthlyInputStatus.ports.application.domain.UpdateMonthlyInputStatusCmd; import app.module.core.usecase.product.createForestProduct.ports.CreateForestProductPortIn; import app.module.core.usecase.product.createForestProduct.ports.application.domain.CreateForestProductCmd; +import app.module.core.usecase.product.removeMonthForestProducts.ports.RemoveMonthForestProductsPortIn; +import app.module.core.usecase.product.removeMonthForestProducts.ports.application.domain.RemoveMonthForestProductsCmd; import app.module.front.config.application.response.ApiResponse; import app.module.front.config.application.util.AuthUtil; import app.module.front.usecase.info.monthly.createMonthlyUI.adapters.web.model.CreateMonthlyProductReqVO; @@ -29,6 +31,8 @@ class CreateMonthlyController { private final GetMonthlyInputStatusPortIn getMonthlyInputStatusPortIn; private final CreateForestProductPortIn createForestProductPortIn; private final UpdateMonthlyInputStatusPortIn updateMonthlyInputStatusPortIn; + private final RemoveMonthForestProductsPortIn removeMonthForestProductsPortIn; + private final CoreUtil coreUtil; @PostMapping(path = "/api/front/info/monthly/create") @@ -41,50 +45,57 @@ class CreateMonthlyController { new GetMonthlyInputStatusCmd( reqVO.getId(), AuthUtil.getUserSeq())).orElse(null); - if(!reqVO.getStatus() && reqVO.getProductList()!=null && !reqVO.getProductList().isEmpty()){ // 등록없음 처리가 아님. - for(CreateMonthlyProductReqVO item : reqVO.getProductList()){ - createForestProductPortIn.operate(new CreateForestProductCmd( - AuthUtil.getUserSeq(), - item.getStreetNum(), - item.getLandType(), - item.getTown(), - item.getAvailableArea(), - item.getCropName(), - null, - item.getLandArea(), + + if(currentMonthlyInfo!=null) { + //TODO 트렌젝션 고려 + removeMonthForestProductsPortIn.operate(new RemoveMonthForestProductsCmd(currentMonthlyInfo.getId(), AuthUtil.getUserSeq())); + + if (!reqVO.getStatus() && reqVO.getProductList() != null && !reqVO.getProductList().isEmpty()) { // 등록없음 처리가 아님. + for (CreateMonthlyProductReqVO item : reqVO.getProductList()) { + createForestProductPortIn.operate(new CreateForestProductCmd( + AuthUtil.getUserSeq(), + item.getStreetNum(), + item.getLandType(), + item.getTown(), + item.getAvailableArea(), + item.getCropName(), + null, + item.getLandArea(), + currentMonthlyInfo.getMonth(), + item.getMainYield(), + item.getMainYieldUnitCode(), + item.getMainSaleAmount(), + item.getMainSaleUnitCode(), + item.getSubYield(), + item.getSubYieldUnitCode(), + item.getSubSaleAmount(), + item.getSubSaleUnitCode(), + currentMonthlyInfo.getId() + )); + } + updateMonthlyInputStatusPortIn.operate(new UpdateMonthlyInputStatusCmd( + currentMonthlyInfo.getId(), + AuthUtil.getUserSeq(), currentMonthlyInfo.getMonth(), - item.getMainYield(), - item.getMainYieldUnitCode(), - item.getMainSaleAmount(), - item.getMainSaleUnitCode(), - item.getSubYield(), - item.getSubYieldUnitCode(), - item.getSubSaleAmount(), - item.getSubSaleUnitCode(), - currentMonthlyInfo.getId() + MonthStatus.REGISTERED, + currentMonthlyInfo.getBankAutoTransferInputStatus(), + currentMonthlyInfo.getBankAutoTransferOutputStatus() + )); + } else { + updateMonthlyInputStatusPortIn.operate(new UpdateMonthlyInputStatusCmd( + currentMonthlyInfo.getId(), + AuthUtil.getUserSeq(), + currentMonthlyInfo.getMonth(), + MonthStatus.NOTHING, + currentMonthlyInfo.getBankAutoTransferInputStatus(), + currentMonthlyInfo.getBankAutoTransferOutputStatus() )); } - updateMonthlyInputStatusPortIn.operate(new UpdateMonthlyInputStatusCmd( - currentMonthlyInfo.getId(), - AuthUtil.getUserSeq(), - currentMonthlyInfo.getMonth(), - MonthStatus.REGISTERED, - currentMonthlyInfo.getBankAutoTransferInputStatus(), - currentMonthlyInfo.getBankAutoTransferOutputStatus() - )); + return ResponseEntity.ok(ApiResponse.success(null)); } else { - updateMonthlyInputStatusPortIn.operate(new UpdateMonthlyInputStatusCmd( - currentMonthlyInfo.getId(), - AuthUtil.getUserSeq(), - currentMonthlyInfo.getMonth(), - MonthStatus.NOTHING, - currentMonthlyInfo.getBankAutoTransferInputStatus(), - currentMonthlyInfo.getBankAutoTransferOutputStatus() - )); + return ResponseEntity.ok(ApiResponse.failure(null)); } - - return ResponseEntity.ok(ApiResponse.success(null)); } } \ No newline at end of file diff --git a/front/src/main/java/app/module/front/usecase/info/monthly/createMonthlyUI/adapters/web/CreateMonthlyUIController.java b/front/src/main/java/app/module/front/usecase/info/monthly/createMonthlyUI/adapters/web/CreateMonthlyUIController.java index 1aba7752..b35b95c6 100644 --- a/front/src/main/java/app/module/front/usecase/info/monthly/createMonthlyUI/adapters/web/CreateMonthlyUIController.java +++ b/front/src/main/java/app/module/front/usecase/info/monthly/createMonthlyUI/adapters/web/CreateMonthlyUIController.java @@ -26,6 +26,9 @@ import org.springframework.stereotype.Controller; import org.springframework.ui.Model; 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; @Controller @RequiredArgsConstructor @@ -50,7 +53,7 @@ class CreateMonthlyUIController { new GetPrevMonthlyInputStatusCmd( id, AuthUtil.getUserSeq())).orElse(null); - //현재 달 입력 상태 취득 + //이번달 달 입력 상태 취득 GetMonthlyInputStatus currentMonthlyInfo = getMonthlyInputStatusPortIn.operate( new GetMonthlyInputStatusCmd( @@ -75,6 +78,11 @@ class CreateMonthlyUIController { currentMonthlyInfo.getId(), AuthUtil.getUserSeq())); } + //수정 가능 여부 판단 + 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); @@ -87,6 +95,7 @@ class CreateMonthlyUIController { model.addAttribute("unitList", uiCodeListPortIn.connect("code.record.unit")); model.addAttribute("MonthStatus", MonthStatus.class); + model.addAttribute("editable", editable); return "info/monthly/{id}"; } diff --git a/front/src/main/resources/static/ui/ajaxUtil.js b/front/src/main/resources/static/ui/ajaxUtil.js index d81a84ff..f830f8cd 100644 --- a/front/src/main/resources/static/ui/ajaxUtil.js +++ b/front/src/main/resources/static/ui/ajaxUtil.js @@ -55,7 +55,6 @@ var ajaxUtil = { }, }); } - }, _alertId : function (alertId, afterEvent) { ajaxUtil._alertMethod({ diff --git a/front/src/main/resources/templates/info/bank/input.html b/front/src/main/resources/templates/info/bank/input.html new file mode 100644 index 00000000..a90afba8 --- /dev/null +++ b/front/src/main/resources/templates/info/bank/input.html @@ -0,0 +1,53 @@ + + + +
+
+
+
+

+ 이번달의
+ 은행 자동이체 내역 입력 현황을 + 확인하세요. +

+
+ +
+
+
+ +
+ + +
+ + \ No newline at end of file diff --git a/front/src/main/resources/templates/info/bank/output.html b/front/src/main/resources/templates/info/bank/output.html new file mode 100644 index 00000000..a90afba8 --- /dev/null +++ b/front/src/main/resources/templates/info/bank/output.html @@ -0,0 +1,53 @@ + + + +
+
+
+
+

+ 이번달의
+ 은행 자동이체 내역 입력 현황을 + 확인하세요. +

+
+ +
+
+
+ +
+ + +
+ + \ No newline at end of file diff --git a/front/src/main/resources/templates/info/monthly/{id}.html b/front/src/main/resources/templates/info/monthly/{id}.html index 83f916c2..65a9fdbf 100644 --- a/front/src/main/resources/templates/info/monthly/{id}.html +++ b/front/src/main/resources/templates/info/monthly/{id}.html @@ -16,7 +16,7 @@
+