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