월별임산물

This commit is contained in:
주우성
2025-06-15 17:32:22 +09:00
parent 4f9eeb9e02
commit 0bc85b825c
5 changed files with 237 additions and 18 deletions

View File

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

View File

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

View File

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

View File

@@ -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<CreateMonthlyProductReqVO> productList;
public List<CreateMonthlyProductReqVO> getProductList() {
return productList != null ? productList : new ArrayList<>();
}
public void setProductList(List<CreateMonthlyProductReqVO> productList) {
this.productList = productList;
}
}