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 new file mode 100644 index 00000000..2cb0b940 --- /dev/null +++ b/front/src/main/java/app/module/front/usecase/info/monthly/createMonthlyUI/adapters/web/CreateMonthlyController.java @@ -0,0 +1,109 @@ +package app.module.front.usecase.info.monthly.createMonthlyUI.adapters.web; + +import app.module.core.config.application.enums.MonthStatus; +import app.module.core.config.application.util.CommonUtil; +import app.module.core.config.application.util.CoreUtil; +import app.module.core.usecase.household.getHousehold.ports.GetHouseholdPortIn; +import app.module.core.usecase.household.getHousehold.ports.application.domain.GetHousehold; +import app.module.core.usecase.household.getHousehold.ports.application.domain.GetHouseholdCmd; +import app.module.core.usecase.household.updateFrontHousehold.ports.UpdateFrontHouseholdPortIn; +import app.module.core.usecase.household.updateFrontHousehold.ports.application.domain.UpdateFrontHouseholdCmd; +import app.module.core.usecase.monthly.getMonthlyInputStatus.ports.GetMonthlyInputStatusPortIn; +import app.module.core.usecase.monthly.getMonthlyInputStatus.ports.application.domain.GetMonthlyInputStatus; +import app.module.core.usecase.monthly.getMonthlyInputStatus.ports.application.domain.GetMonthlyInputStatusCmd; +import app.module.core.usecase.monthly.getPrevMonthlyInputStatus.ports.GetPrevMonthlyInputStatusPortIn; +import app.module.core.usecase.monthly.getPrevMonthlyInputStatus.ports.application.domain.GetPrevMonthlyInputStatus; +import app.module.core.usecase.monthly.getPrevMonthlyInputStatus.ports.application.domain.GetPrevMonthlyInputStatusCmd; +import app.module.core.usecase.monthly.updateMonthlyInputStatus.ports.UpdateMonthlyInputStatusPortIn; +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.getMonthlyForestProducts.ports.GetMonthlyForestProductsPortIn; +import app.module.core.usecase.product.getMonthlyForestProducts.ports.application.domain.GetMonthlyForestProducts; +import app.module.core.usecase.product.getMonthlyForestProducts.ports.application.domain.GetMonthlyForestProductsCmd; +import app.module.core.usecase.uicode.list.ports.UICodeListPortIn; +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; +import app.module.front.usecase.info.monthly.createMonthlyUI.adapters.web.model.CreateMonthlyReqVO; +import app.module.front.usecase.info.user.updateUserUI.adapters.web.model.UpdateUserReqVO; +import jakarta.validation.Valid; +import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.data.web.PageableDefault; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +@Controller +@RequiredArgsConstructor +class CreateMonthlyController { + + + private final GetMonthlyInputStatusPortIn getMonthlyInputStatusPortIn; + private final CreateForestProductPortIn createForestProductPortIn; + private final UpdateMonthlyInputStatusPortIn updateMonthlyInputStatusPortIn; + private final CoreUtil coreUtil; + + @PostMapping(path = "/api/front/info/monthly/create") + ResponseEntity operate(@RequestBody @Valid CreateMonthlyReqVO reqVO, BindingResult bindingResult){ + if (bindingResult.hasErrors()) { + return coreUtil.getErrorInfo(bindingResult); + } + GetMonthlyInputStatus currentMonthlyInfo = + getMonthlyInputStatusPortIn.operate( + 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(), + 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(), + MonthStatus.REGISTERED, + currentMonthlyInfo.getBankAutoTransferStatus() + )); + } else { + updateMonthlyInputStatusPortIn.operate(new UpdateMonthlyInputStatusCmd( + currentMonthlyInfo.getId(), + AuthUtil.getUserSeq(), + currentMonthlyInfo.getMonth(), + MonthStatus.NOTHING, + currentMonthlyInfo.getBankAutoTransferStatus() + )); + } + + + + 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 129278bd..1aba7752 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 @@ -17,7 +17,6 @@ import app.module.core.usecase.product.getMonthlyForestProducts.ports.applicatio import app.module.core.usecase.product.getMonthlyForestProducts.ports.application.domain.GetMonthlyForestProductsCmd; import app.module.core.usecase.uicode.list.ports.UICodeListPortIn; import app.module.front.config.application.util.AuthUtil; -import app.module.front.usecase.info.monthly.createMonthlyUI.adapters.web.model.CreateMonthlyReqVO; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; diff --git a/front/src/main/java/app/module/front/usecase/info/monthly/createMonthlyUI/adapters/web/model/CreateMonthlyProductReqVO.java b/front/src/main/java/app/module/front/usecase/info/monthly/createMonthlyUI/adapters/web/model/CreateMonthlyProductReqVO.java new file mode 100644 index 00000000..5112ffd0 --- /dev/null +++ b/front/src/main/java/app/module/front/usecase/info/monthly/createMonthlyUI/adapters/web/model/CreateMonthlyProductReqVO.java @@ -0,0 +1,35 @@ +package app.module.front.usecase.info.monthly.createMonthlyUI.adapters.web.model; + +import lombok.*; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@EqualsAndHashCode +public class CreateMonthlyProductReqVO { + + private Long id;// + private String streetNum;// + private String landType;// + private String town;// + + private Integer availableArea;// + private String cropName;// + private Integer landArea;// + + private BigDecimal mainYield;// + private String mainYieldUnitCode;// + private BigDecimal mainSaleAmount;// + private String mainSaleUnitCode;// + + private BigDecimal subYield;// + private String subYieldUnitCode;// + private BigDecimal subSaleAmount;// + private String subSaleUnitCode;// + + +} diff --git a/front/src/main/java/app/module/front/usecase/info/monthly/createMonthlyUI/adapters/web/model/CreateMonthlyReqVO.java b/front/src/main/java/app/module/front/usecase/info/monthly/createMonthlyUI/adapters/web/model/CreateMonthlyReqVO.java index 0ec14e42..3651c521 100644 --- a/front/src/main/java/app/module/front/usecase/info/monthly/createMonthlyUI/adapters/web/model/CreateMonthlyReqVO.java +++ b/front/src/main/java/app/module/front/usecase/info/monthly/createMonthlyUI/adapters/web/model/CreateMonthlyReqVO.java @@ -1,16 +1,31 @@ package app.module.front.usecase.info.monthly.createMonthlyUI.adapters.web.model; -import lombok.AllArgsConstructor; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.Setter; +import lombok.*; + +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; @Getter @Setter +@NoArgsConstructor @AllArgsConstructor @EqualsAndHashCode public class CreateMonthlyReqVO { - private String searchField; - private String searchValue; + + private Boolean status; + private Long id; + private List productList; + + public List getProductList() { + return productList != null ? productList : new ArrayList<>(); + } + + public void setProductList(List productList) { + this.productList = productList; + } + + } diff --git a/front/src/main/resources/templates/info/monthly/{id}.html b/front/src/main/resources/templates/info/monthly/{id}.html index 769c57ea..83f916c2 100644 --- a/front/src/main/resources/templates/info/monthly/{id}.html +++ b/front/src/main/resources/templates/info/monthly/{id}.html @@ -14,14 +14,14 @@
-

- 총 1건 +

-
+ @@ -30,12 +30,12 @@ 추가 등록 - -
+