From b441837da625c1096f55cfe15e5c4bb1bb643d06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=ED=98=84=EC=A3=BC?= Date: Fri, 27 Jun 2025 11:45:42 +0900 Subject: [PATCH] =?UTF-8?q?[FO]=20=EC=88=98=EB=9F=89=EA=B3=BC=20=EB=8B=A8?= =?UTF-8?q?=EC=9C=84=EC=9D=98=20valid=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CreateDailyExpenseValidator.java | 24 ++++++++++++++----- .../CreateDailyFarmingValidator.java | 18 ++++++++++++++ .../CreateDailyForestryValidator.java | 19 +++++++++++++++ .../validator/CreateDailyIncomeValidator.java | 24 ++++++++++++++----- .../src/main/resources/static/ui/ajaxUtil.js | 2 +- .../templates/record/expense/form.html | 2 +- .../templates/record/farming/form.html | 2 +- .../templates/record/forestry/form.html | 2 +- .../templates/record/income/form.html | 2 +- 9 files changed, 78 insertions(+), 17 deletions(-) diff --git a/front/src/main/java/app/module/front/usecase/daily/expense/adapters/web/validator/CreateDailyExpenseValidator.java b/front/src/main/java/app/module/front/usecase/daily/expense/adapters/web/validator/CreateDailyExpenseValidator.java index 9bdfedc1..a67f79c1 100644 --- a/front/src/main/java/app/module/front/usecase/daily/expense/adapters/web/validator/CreateDailyExpenseValidator.java +++ b/front/src/main/java/app/module/front/usecase/daily/expense/adapters/web/validator/CreateDailyExpenseValidator.java @@ -21,6 +21,24 @@ public class CreateDailyExpenseValidator implements Validator { public void validate(Object target, Errors errors) { CreateDailyExpenseReqVO vo = (CreateDailyExpenseReqVO) target; + if (vo.getQuantity() == null && !StringUtils.isBlank(vo.getUnitCode())) { + errors.rejectValue( + "quantity", "valid.common.required", + "수량을 입력해 주세요."); + } + + if (vo.getQuantity() != null && StringUtils.isBlank(vo.getUnitCode())) { + errors.rejectValue( + "unitCode", "valid.common.required", + "단위를 선택해 주세요."); + } + + if (CommonConstants.UNIT_CODE_SELF.equals(vo.getUnitCode()) && StringUtils.isBlank(vo.getUnitSelf())) { + errors.rejectValue( + "unitSelf", "valid.common.required", + "단위를 입력해 주세요."); + } + if (vo.getPrice() == null && vo.getEstimatedValue() == null) { errors.rejectValue( "price", "valid.common.required", @@ -29,11 +47,5 @@ public class CreateDailyExpenseValidator implements Validator { "estimatedValue", "valid.common.required", "현금 또는 현물평가액을 입력해 주세요."); } - - if (CommonConstants.UNIT_CODE_SELF.equals(vo.getUnitCode()) && StringUtils.isBlank(vo.getUnitSelf())) { - errors.rejectValue( - "unitSelf", "valid.common.required", - "단위를 입력해 주세요."); - } } } diff --git a/front/src/main/java/app/module/front/usecase/daily/farming/adapters/web/validator/CreateDailyFarmingValidator.java b/front/src/main/java/app/module/front/usecase/daily/farming/adapters/web/validator/CreateDailyFarmingValidator.java index 67b37635..e112ce1f 100644 --- a/front/src/main/java/app/module/front/usecase/daily/farming/adapters/web/validator/CreateDailyFarmingValidator.java +++ b/front/src/main/java/app/module/front/usecase/daily/farming/adapters/web/validator/CreateDailyFarmingValidator.java @@ -27,6 +27,24 @@ public class CreateDailyFarmingValidator implements Validator { "생산물을 입력해 주세요."); } + if (vo.getQuantity() == null && !StringUtils.isBlank(vo.getUnitCode())) { + errors.rejectValue( + "quantity", "valid.common.required", + "수량을 입력해 주세요."); + } + + if (vo.getQuantity() != null && StringUtils.isBlank(vo.getUnitCode())) { + errors.rejectValue( + "unitCode", "valid.common.required", + "단위를 선택해 주세요."); + } + + if (CommonConstants.UNIT_CODE_SELF.equals(vo.getUnitCode()) && StringUtils.isBlank(vo.getUnitSelf())) { + errors.rejectValue( + "unitSelf", "valid.common.required", + "단위를 입력해 주세요."); + } + if (vo.getEstimatedValue() == null) { errors.rejectValue( "estimatedValue", "valid.common.required", diff --git a/front/src/main/java/app/module/front/usecase/daily/forestry/adapters/web/validator/CreateDailyForestryValidator.java b/front/src/main/java/app/module/front/usecase/daily/forestry/adapters/web/validator/CreateDailyForestryValidator.java index 5d198bbd..1ca14c4a 100644 --- a/front/src/main/java/app/module/front/usecase/daily/forestry/adapters/web/validator/CreateDailyForestryValidator.java +++ b/front/src/main/java/app/module/front/usecase/daily/forestry/adapters/web/validator/CreateDailyForestryValidator.java @@ -1,5 +1,6 @@ package app.module.front.usecase.daily.forestry.adapters.web.validator; +import app.module.front.config.constants.CommonConstants; import app.module.front.usecase.daily.forestry.adapters.web.model.CreateDailyForestryReqVO; import lombok.RequiredArgsConstructor; import org.apache.tika.utils.StringUtils; @@ -20,6 +21,24 @@ public class CreateDailyForestryValidator implements Validator { public void validate(Object target, Errors errors) { CreateDailyForestryReqVO vo = (CreateDailyForestryReqVO) target; + if (vo.getQuantity() == null && !StringUtils.isBlank(vo.getUnitCode())) { + errors.rejectValue( + "quantity", "valid.common.required", + "수량을 입력해 주세요."); + } + + if (vo.getQuantity() != null && StringUtils.isBlank(vo.getUnitCode())) { + errors.rejectValue( + "unitCode", "valid.common.required", + "단위를 선택해 주세요."); + } + + if (CommonConstants.UNIT_CODE_SELF.equals(vo.getUnitCode()) && StringUtils.isBlank(vo.getUnitSelf())) { + errors.rejectValue( + "unitSelf", "valid.common.required", + "단위를 입력해 주세요."); + } + if (vo.getEstimatedValue() == null) { errors.rejectValue( "estimatedValue", "valid.common.required", diff --git a/front/src/main/java/app/module/front/usecase/daily/income/adapters/web/validator/CreateDailyIncomeValidator.java b/front/src/main/java/app/module/front/usecase/daily/income/adapters/web/validator/CreateDailyIncomeValidator.java index e8667e4f..8983829a 100644 --- a/front/src/main/java/app/module/front/usecase/daily/income/adapters/web/validator/CreateDailyIncomeValidator.java +++ b/front/src/main/java/app/module/front/usecase/daily/income/adapters/web/validator/CreateDailyIncomeValidator.java @@ -21,6 +21,24 @@ public class CreateDailyIncomeValidator implements Validator { public void validate(Object target, Errors errors) { CreateDailyIncomeReqVO vo = (CreateDailyIncomeReqVO) target; + if (vo.getQuantity() == null && !StringUtils.isBlank(vo.getUnitCode())) { + errors.rejectValue( + "quantity", "valid.common.required", + "수량을 입력해 주세요."); + } + + if (vo.getQuantity() != null && StringUtils.isBlank(vo.getUnitCode())) { + errors.rejectValue( + "unitCode", "valid.common.required", + "단위를 선택해 주세요."); + } + + if (CommonConstants.UNIT_CODE_SELF.equals(vo.getUnitCode()) && StringUtils.isBlank(vo.getUnitSelf())) { + errors.rejectValue( + "unitSelf", "valid.common.required", + "단위를 입력해 주세요."); + } + if (vo.getPrice() == null && vo.getEstimatedValue() == null) { errors.rejectValue( "price", "valid.common.required", @@ -29,11 +47,5 @@ public class CreateDailyIncomeValidator implements Validator { "estimatedValue", "valid.common.required", "현금 또는 현물평가액을 입력해 주세요."); } - - if (CommonConstants.UNIT_CODE_SELF.equals(vo.getUnitCode()) && StringUtils.isBlank(vo.getUnitSelf())) { - errors.rejectValue( - "unitSelf", "valid.common.required", - "단위를 입력해 주세요."); - } } } diff --git a/front/src/main/resources/static/ui/ajaxUtil.js b/front/src/main/resources/static/ui/ajaxUtil.js index 7a498220..65508942 100644 --- a/front/src/main/resources/static/ui/ajaxUtil.js +++ b/front/src/main/resources/static/ui/ajaxUtil.js @@ -180,7 +180,7 @@ var ajaxUtil = { if (formElement.length > 0) { $(formElement).find('.component-input').removeClass('input-invalid'); $(formElement).find('.input-flex-group').removeClass('invalid'); - $(formElement).find('.select-group').removeClass('input-invalid'); + $(formElement).find('.select-group').removeClass('select-invalid'); $(formElement).find('.input-info').each(function () { $(this).remove(); }); diff --git a/front/src/main/resources/templates/record/expense/form.html b/front/src/main/resources/templates/record/expense/form.html index a40636c3..b9d87fa9 100644 --- a/front/src/main/resources/templates/record/expense/form.html +++ b/front/src/main/resources/templates/record/expense/form.html @@ -93,7 +93,7 @@

- + diff --git a/front/src/main/resources/templates/record/farming/form.html b/front/src/main/resources/templates/record/farming/form.html index e3bce5d6..ea11e632 100644 --- a/front/src/main/resources/templates/record/farming/form.html +++ b/front/src/main/resources/templates/record/farming/form.html @@ -80,7 +80,7 @@

- + diff --git a/front/src/main/resources/templates/record/forestry/form.html b/front/src/main/resources/templates/record/forestry/form.html index 1cd4749b..db4bbca8 100644 --- a/front/src/main/resources/templates/record/forestry/form.html +++ b/front/src/main/resources/templates/record/forestry/form.html @@ -55,7 +55,7 @@

- + diff --git a/front/src/main/resources/templates/record/income/form.html b/front/src/main/resources/templates/record/income/form.html index 9baacbdd..a7a8cf04 100644 --- a/front/src/main/resources/templates/record/income/form.html +++ b/front/src/main/resources/templates/record/income/form.html @@ -123,7 +123,7 @@

- +