[BO] 임산물현황 등록 작업

This commit is contained in:
kangsunlee
2025-06-26 14:24:12 +09:00
parent 063c9018e4
commit f1aad02b70
21 changed files with 401 additions and 25 deletions

View File

@@ -4,6 +4,7 @@ import app.module.admin.usecase.household.tab.forestProduct.getForestProductsSta
import app.module.admin.usecase.household.tab.forestProduct.getForestProductsStatus.ports.application.domain.GetForestProductsStatus;
import app.module.admin.usecase.household.tab.forestProduct.getForestProductsStatus.ports.application.domain.GetForestProductsStatusCmd;
import app.module.admin.usecase.household.tab.forestProduct.getForestProductsStatus.ports.application.domain.GetForestProductsStatusResult;
import app.module.admin.usecase.household.tab.forestProduct.getForestProductsStatus.ports.application.domain.GetMonthlyForestProductsStatus;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;
@@ -17,7 +18,7 @@ class GetForestProductsStatusDao implements GetForestProductsStatusPortOut {
public GetForestProductsStatusResult operate(GetForestProductsStatusCmd cmd) {
// 임산물 등록 상태 조회
String monthlyStatus = mapper.getMonthlyStatus(cmd);
GetMonthlyForestProductsStatus monthlyStatus = mapper.getMonthlyStatus(cmd);
// 임산물 목록 조회
List<GetForestProductsStatus> forestProducts = mapper.getForestProductsStatus(cmd);

View File

@@ -2,11 +2,12 @@ package app.module.admin.usecase.household.tab.forestProduct.getForestProductsSt
import app.module.admin.usecase.household.tab.forestProduct.getForestProductsStatus.ports.application.domain.GetForestProductsStatus;
import app.module.admin.usecase.household.tab.forestProduct.getForestProductsStatus.ports.application.domain.GetForestProductsStatusCmd;
import app.module.admin.usecase.household.tab.forestProduct.getForestProductsStatus.ports.application.domain.GetMonthlyForestProductsStatus;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface GetForestProductsStatusMapper {
String getMonthlyStatus(GetForestProductsStatusCmd cmd);
GetMonthlyForestProductsStatus getMonthlyStatus(GetForestProductsStatusCmd cmd);
List<GetForestProductsStatus> getForestProductsStatus(GetForestProductsStatusCmd cmd);
}

View File

@@ -11,6 +11,6 @@ import lombok.Setter;
@AllArgsConstructor
@EqualsAndHashCode
public class GetForestProductsStatusResult {
private String monthlyStatus;
private GetMonthlyForestProductsStatus monthlyStatus;
private List<GetForestProductsStatus> forestProducts;
}

View File

@@ -0,0 +1,15 @@
package app.module.admin.usecase.household.tab.forestProduct.getForestProductsStatus.ports.application.domain;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class GetMonthlyForestProductsStatus {
private Long id;
private String forestStatus;
}

View File

@@ -0,0 +1,24 @@
package app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.adapters.persistence;
import app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.ports.SaveForestProductPortOut;
import app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.ports.application.domain.SaveForestProductCmd;
import app.module.core.config.application.util.AuditUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
@Repository
@RequiredArgsConstructor
class SaveForestProductDao implements SaveForestProductPortOut {
private final SaveForestProductMapper mapper;
@Override
@Transactional
public void operate(SaveForestProductCmd inCmd) {
if (inCmd.getForestProductId() == null) {
mapper.createForestProduct(AuditUtil.create(inCmd));
} else {
mapper.updateForestProduct(AuditUtil.update(inCmd));
}
}
}

View File

@@ -0,0 +1,10 @@
package app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.adapters.persistence;
import app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.ports.application.domain.SaveForestProductCmd;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface SaveForestProductMapper {
void createForestProduct(SaveForestProductCmd cmd);
void updateForestProduct(SaveForestProductCmd cmd);
}

View File

@@ -0,0 +1,61 @@
package app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.adapters.web;
import app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.ports.SaveForestProductPortIn;
import app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.ports.application.domain.SaveForestProductCmd;
import app.module.core.config.application.util.MessageUtil;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.validation.BindingResult;
import app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.adapters.web.model.SaveForestProductReqVO;
import app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.adapters.web.model.SaveForestProductResVO;
import app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.adapters.web.validator.SaveForestProductValidator;
@RestController
@RequiredArgsConstructor
class SaveForestProductController {
private final SaveForestProductValidator validator;
private final SaveForestProductPortIn portIn;
private final MessageUtil messageUtil;
@PostMapping(path = "/api/forestProduct/save")
ResponseEntity<?> operate(@Valid @RequestBody SaveForestProductReqVO reqVO,
BindingResult bindingResult) {
validator.validate(reqVO, bindingResult);
if (bindingResult.hasErrors()) {
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
.body(bindingResult.getFieldErrors());
}
portIn.operate(new SaveForestProductCmd(
reqVO.getForestProductId(),
reqVO.getHouseholdSeq(),
reqVO.getMonthlyInputStatusId(),
reqVO.getRecordMonth(),
reqVO.getStreetNum(),
reqVO.getLandType(),
reqVO.getTown(),
reqVO.getCropName(),
reqVO.getLandArea(),
reqVO.getAvailableArea(),
reqVO.getMainYield(),
reqVO.getMainYieldUnitCode(),
reqVO.getMainYieldUnit(),
reqVO.getMainSaleAmount(),
reqVO.getMainSaleUnitCode(),
reqVO.getMainSaleUnit(),
reqVO.getSubYield(),
reqVO.getSubYieldUnitCode(),
reqVO.getSubYieldUnit(),
reqVO.getSubSaleAmount(),
reqVO.getSubSaleUnitCode(),
reqVO.getSubSaleUnit()));
return ResponseEntity.status(HttpStatus.OK).body(
new SaveForestProductResVO(messageUtil.getMessage("operation.common.save.done")));
}
}

View File

@@ -0,0 +1,37 @@
package app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.adapters.web.model;
import jakarta.validation.constraints.NotBlank;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
@EqualsAndHashCode
public class SaveForestProductReqVO {
private Long forestProductId;
private Long householdSeq;
private Long monthlyInputStatusId;
private String recordMonth;
private String streetNum;
private String landType;
private String town;
private String cropName;
private String landArea;
private String availableArea;
private String mainYield;
private String mainYieldUnitCode;
private String mainYieldUnit;
private String mainSaleAmount;
private String mainSaleUnitCode;
private String mainSaleUnit;
private String subYield;
private String subYieldUnitCode;
private String subYieldUnit;
private String subSaleAmount;
private String subSaleUnitCode;
private String subSaleUnit;
}

View File

@@ -0,0 +1,14 @@
package app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.adapters.web.model;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class SaveForestProductResVO {
private String message;
}

View File

@@ -0,0 +1,25 @@
package app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.adapters.web.validator;
import app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.adapters.web.model.SaveForestProductReqVO;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;
@Component
public class SaveForestProductValidator implements Validator {
@Override
public boolean supports(Class<?> clazz) {
return SaveForestProductReqVO.class.equals(clazz);
}
@Override
public void validate(Object target, Errors errors) {
SaveForestProductReqVO vo = (SaveForestProductReqVO) target;
if (!StringUtils.hasText(vo.getCropName())) {
errors.rejectValue("cropName", "error.cropName", "재배 작물명을 입력해주세요.");
}
}
}

View File

@@ -0,0 +1,7 @@
package app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.ports;
import app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.ports.application.domain.SaveForestProductCmd;
public interface SaveForestProductPortIn {
void operate(SaveForestProductCmd inCmd);
}

View File

@@ -0,0 +1,7 @@
package app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.ports;
import app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.ports.application.domain.SaveForestProductCmd;
public interface SaveForestProductPortOut {
void operate(SaveForestProductCmd inCmd);
}

View File

@@ -0,0 +1,18 @@
package app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.ports.application;
import app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.ports.SaveForestProductPortIn;
import app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.ports.SaveForestProductPortOut;
import app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.ports.application.domain.SaveForestProductCmd;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
class SaveForestProductService implements SaveForestProductPortIn {
private final SaveForestProductPortOut portOut;
@Override
public void operate(SaveForestProductCmd cmd) {
portOut.operate(cmd);
}
}

View File

@@ -0,0 +1,35 @@
package app.module.admin.usecase.household.tab.forestProduct.saveForestProduct.ports.application.domain;
import app.module.core.config.adapters.persistence.component.AuditCommand;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
public class SaveForestProductCmd extends AuditCommand {
private Long forestProductId;
private Long householdSeq;
private Long monthlyInputStatusId;
private String recordMonth;
private String streetNum;
private String landType;
private String town;
private String cropName;
private String landArea;
private String availableArea;
private String mainYield;
private String mainYieldUnitCode;
private String mainYieldUnit;
private String mainSaleAmount;
private String mainSaleUnitCode;
private String mainSaleUnit;
private String subYield;
private String subYieldUnitCode;
private String subYieldUnit;
private String subSaleAmount;
private String subSaleUnitCode;
private String subSaleUnit;
}

View File

@@ -30,7 +30,7 @@ class SaveHouseholdVisitInfoController {
if (bindingResult.hasErrors()) {
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
.body(bindingResult.getAllErrors().get(0).getDefaultMessage());
.body(bindingResult.getFieldErrors());
}
portIn.operate(new SaveHouseholdVisitInfoCmd(