[FO] 일계부 항목, 수입, 지출 package 변경
This commit is contained in:
@@ -0,0 +1,50 @@
|
|||||||
|
package app.module.front.usecase.daily.expense.adapters.persistence;
|
||||||
|
|
||||||
|
import app.module.front.usecase.daily.expense.ports.application.domain.CreateDailyExpenseCmd;
|
||||||
|
import app.module.front.usecase.daily.expense.adapters.persistence.model.DailyExpenseDto;
|
||||||
|
import app.module.front.usecase.daily.expense.ports.application.domain.GetDailyExpenseCmd;
|
||||||
|
import app.module.front.usecase.daily.expense.ports.application.domain.RemoveDailyExpenseCmd;
|
||||||
|
import app.module.front.usecase.daily.expense.adapters.web.model.DailyExpenseUIReqVO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface DailyExpenseMapper {
|
||||||
|
/**
|
||||||
|
* 일계부 지출 목록 조회
|
||||||
|
*
|
||||||
|
* @param command 검색 조건
|
||||||
|
* @return 수입 목록
|
||||||
|
*/
|
||||||
|
List<DailyExpenseDto> getDailyExpenseList(GetDailyExpenseCmd command);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 지출 데이터 존재 여부
|
||||||
|
*
|
||||||
|
* @param command 검색 조건
|
||||||
|
* @return 중복 개수
|
||||||
|
*/
|
||||||
|
Integer getRecordExistCount(GetDailyExpenseCmd command);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 지출 등록
|
||||||
|
*
|
||||||
|
* @param command 등록 데이터
|
||||||
|
*/
|
||||||
|
void createDailyExpense(CreateDailyExpenseCmd command);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 지출 수정
|
||||||
|
*
|
||||||
|
* @param command 수정 데이터
|
||||||
|
*/
|
||||||
|
void updateDailyExpense(CreateDailyExpenseCmd command);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 지출 삭제
|
||||||
|
*
|
||||||
|
* @param command 삭제 데이터
|
||||||
|
*/
|
||||||
|
void removeDailyExpense(RemoveDailyExpenseCmd command);
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package app.module.front.usecase.daily.expense.adapters.persistence.model;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class DailyExpenseDto {
|
||||||
|
private Long id;
|
||||||
|
private Long dailyRecordSeq;
|
||||||
|
// TODO : SELF, OCR
|
||||||
|
private String inputType;
|
||||||
|
private Boolean credit;
|
||||||
|
private String categorySelf;
|
||||||
|
private String sourcePurpose;
|
||||||
|
private Integer quantity;
|
||||||
|
private String unitCode;
|
||||||
|
private String unitLabel;
|
||||||
|
private String unitSelf;
|
||||||
|
private Integer price;
|
||||||
|
private Integer estimatedValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 수정 가능 여부
|
||||||
|
* @return true=가능, false=불가능(등록 상태)
|
||||||
|
*/
|
||||||
|
public boolean isUpdated() {
|
||||||
|
return this.id != null && this.id != 0L;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,135 @@
|
|||||||
|
package app.module.front.usecase.daily.expense.adapters.web;
|
||||||
|
|
||||||
|
import app.module.core.config.application.exception.NoRecordDataException;
|
||||||
|
import app.module.core.config.application.util.CoreUtil;
|
||||||
|
import app.module.front.usecase.daily.expense.adapters.web.model.CreateDailyExpenseReqVO;
|
||||||
|
import app.module.front.usecase.daily.expense.adapters.web.model.RemoveDailyExpenseReqVO;
|
||||||
|
import app.module.front.usecase.daily.expense.adapters.web.validator.CreateDailyExpenseValidator;
|
||||||
|
import app.module.front.usecase.daily.expense.ports.DailyExpensePortIn;
|
||||||
|
import app.module.front.usecase.daily.record.adapters.persistence.model.DailyRecordDto;
|
||||||
|
import app.module.front.usecase.daily.record.adapters.web.model.DailyUIReqVO;
|
||||||
|
import app.module.front.usecase.daily.record.ports.DailyRecordPortIn;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.validation.BindingResult;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RequestMapping(path = "/api/record/expense")
|
||||||
|
public class DailyExpenseController {
|
||||||
|
private final CoreUtil coreUtil;
|
||||||
|
private final DailyRecordPortIn dailyRecordService;
|
||||||
|
private final DailyExpensePortIn dailyExpensePortIn;
|
||||||
|
private final CreateDailyExpenseValidator createDailyExpenseValidator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 지출 등록 처리
|
||||||
|
*
|
||||||
|
* @param searchMonth 검색 월(yyyyMM)
|
||||||
|
* @param groupNo 검색 그룹
|
||||||
|
* @param id 수입 일련번호
|
||||||
|
* @param formVO 입력 데이터
|
||||||
|
* @param bindingResult BindingResult
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping(path = "/{searchMonth}/{groupNo}/form/{id}")
|
||||||
|
ResponseEntity<?> create(@PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo
|
||||||
|
, @PathVariable("id") String id
|
||||||
|
, @Valid @RequestBody CreateDailyExpenseReqVO formVO, BindingResult bindingResult) {
|
||||||
|
|
||||||
|
createDailyExpenseValidator.validate(formVO, bindingResult);
|
||||||
|
if (bindingResult.hasErrors()) {
|
||||||
|
return coreUtil.getErrorInfo(bindingResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
DailyRecordDto dailyRecord = this.vaildGetDailyRecord(searchMonth, groupNo);
|
||||||
|
|
||||||
|
formVO.setSearchMonth(searchMonth);
|
||||||
|
formVO.setGroupNo(Integer.parseInt(groupNo));
|
||||||
|
formVO.setId(Long.parseLong(id));
|
||||||
|
formVO.setDailyRecordSeq(dailyRecord.getId());
|
||||||
|
log.debug("formVO: {}", formVO);
|
||||||
|
|
||||||
|
dailyExpensePortIn.create(formVO);
|
||||||
|
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(formVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 지출 삭제 처리
|
||||||
|
*
|
||||||
|
* @param searchMonth 검색 월(yyyyMM)
|
||||||
|
* @param groupNo 검색 그룹
|
||||||
|
* @param formVO 입력 데이터
|
||||||
|
* @param bindingResult BindingResult
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping(path = "/{searchMonth}/{groupNo}/remove")
|
||||||
|
ResponseEntity<?> remove(@PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo
|
||||||
|
, @Valid @RequestBody RemoveDailyExpenseReqVO formVO, BindingResult bindingResult) {
|
||||||
|
|
||||||
|
log.debug("before formVO: {}", formVO);
|
||||||
|
if (bindingResult.hasErrors()) {
|
||||||
|
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
|
||||||
|
.body(bindingResult.getFieldErrors());
|
||||||
|
}
|
||||||
|
|
||||||
|
DailyRecordDto dailyRecord = this.vaildGetDailyRecord(searchMonth, groupNo);
|
||||||
|
|
||||||
|
formVO.setSearchMonth(dailyRecord.getRecordMonth());
|
||||||
|
formVO.setGroupNo(dailyRecord.getGroupNo());
|
||||||
|
formVO.setDailyRecordSeq(dailyRecord.getId());
|
||||||
|
log.debug("formVO: {}", formVO);
|
||||||
|
|
||||||
|
dailyExpensePortIn.remove(formVO);
|
||||||
|
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(formVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 지출 전체 삭제 처리
|
||||||
|
*
|
||||||
|
* @param searchMonth 검색 월(yyyyMM)
|
||||||
|
* @param groupNo 검색 그룹
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping(path = "/{searchMonth}/{groupNo}/reset")
|
||||||
|
ResponseEntity<?> removeAll(@PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo) {
|
||||||
|
|
||||||
|
DailyRecordDto dailyRecord = this.vaildGetDailyRecord(searchMonth, groupNo);
|
||||||
|
|
||||||
|
RemoveDailyExpenseReqVO formVO = new RemoveDailyExpenseReqVO();
|
||||||
|
formVO.setSearchMonth(dailyRecord.getRecordMonth());
|
||||||
|
formVO.setGroupNo(dailyRecord.getGroupNo());
|
||||||
|
formVO.setDailyRecordSeq(dailyRecord.getId());
|
||||||
|
log.debug("formVO: {}", formVO);
|
||||||
|
|
||||||
|
dailyExpensePortIn.remove(formVO);
|
||||||
|
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(formVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 유효성 체크 및 데이터 조회
|
||||||
|
*
|
||||||
|
* @param searchMonth 검색 월(yyyyMM)
|
||||||
|
* @param groupNo 검색 그룹
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private DailyRecordDto vaildGetDailyRecord(String searchMonth, String groupNo) {
|
||||||
|
DailyUIReqVO reqVO = new DailyUIReqVO(searchMonth, groupNo);
|
||||||
|
log.debug("getRecordUIReq: {}", reqVO);
|
||||||
|
|
||||||
|
DailyRecordDto dailyRecord = dailyRecordService.detail(reqVO);
|
||||||
|
if (dailyRecord == null || dailyRecord.getId() == null) {
|
||||||
|
throw new NoRecordDataException();
|
||||||
|
}
|
||||||
|
|
||||||
|
return dailyRecord;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
package app.module.front.usecase.daily.expense.adapters.web;
|
||||||
|
|
||||||
|
import app.module.core.config.application.exception.NoRecordDataException;
|
||||||
|
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
|
||||||
|
import app.module.front.usecase.daily.expense.adapters.persistence.model.DailyExpenseDto;
|
||||||
|
import app.module.front.usecase.daily.expense.adapters.web.model.DailyExpenseUIReqVO;
|
||||||
|
import app.module.front.usecase.daily.expense.ports.DailyExpensePortIn;
|
||||||
|
import app.module.front.usecase.daily.record.adapters.persistence.model.DailyRecordDto;
|
||||||
|
import app.module.front.usecase.daily.record.adapters.web.model.DailyUIReqVO;
|
||||||
|
import app.module.front.usecase.daily.record.ports.DailyRecordPortIn;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.thymeleaf.util.StringUtils;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Controller
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RequestMapping(path = "/record/expense")
|
||||||
|
public class DailyExpenseUIController {
|
||||||
|
private final UICodeListPortIn uiCodeListPortIn;
|
||||||
|
private final DailyRecordPortIn dailyRecordService;
|
||||||
|
private final DailyExpensePortIn dailyExpensePortIn;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 지출 목록 화면
|
||||||
|
*
|
||||||
|
* @param model Model
|
||||||
|
* @param searchMonth 검색 월(yyyyMM)
|
||||||
|
* @param groupNo 검색 그룹
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(path = "/{searchMonth}/{groupNo}")
|
||||||
|
public String index(Model model, @PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo) {
|
||||||
|
|
||||||
|
DailyRecordDto dailyRecord = this.vaildGetDailyRecord(searchMonth, groupNo);
|
||||||
|
|
||||||
|
DailyExpenseUIReqVO reqVO = new DailyExpenseUIReqVO(searchMonth, groupNo);
|
||||||
|
log.debug("reqVO: {}", reqVO);
|
||||||
|
|
||||||
|
List<DailyExpenseDto> expenseList = dailyExpensePortIn.list(reqVO);
|
||||||
|
|
||||||
|
model.addAttribute("reqVO", reqVO);
|
||||||
|
model.addAttribute("dailyRecord", dailyRecord);
|
||||||
|
model.addAttribute("expenseList", expenseList);
|
||||||
|
|
||||||
|
return "record/expense/index";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 지출 등록 화면
|
||||||
|
*
|
||||||
|
* @param model Model
|
||||||
|
* @param searchMonth 검색 월(yyyyMM)
|
||||||
|
* @param groupNo 검색 그룹
|
||||||
|
* @param id 수입 일련번호
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(path = "/{searchMonth}/{groupNo}/form/{id}")
|
||||||
|
public String formBySelf(Model model, @PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo
|
||||||
|
, @PathVariable("id") String id) {
|
||||||
|
|
||||||
|
DailyExpenseUIReqVO reqVO = new DailyExpenseUIReqVO(searchMonth, groupNo);
|
||||||
|
if (StringUtils.isEmpty(id)) {
|
||||||
|
reqVO.setId(0L);
|
||||||
|
} else {
|
||||||
|
reqVO.setId(Long.parseLong(id));
|
||||||
|
}
|
||||||
|
log.debug("reqVO: {}", reqVO);
|
||||||
|
|
||||||
|
DailyExpenseDto detail = new DailyExpenseDto();
|
||||||
|
if (reqVO.getId() != 0L) {
|
||||||
|
detail = dailyExpensePortIn.detail(reqVO);
|
||||||
|
if (detail == null || !detail.isUpdated()) {
|
||||||
|
throw new NoRecordDataException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
model.addAttribute("recordCrop", uiCodeListPortIn.connect("code.record.crop"));
|
||||||
|
model.addAttribute("recordUnit", uiCodeListPortIn.connect("code.record.unit"));
|
||||||
|
|
||||||
|
model.addAttribute("reqVO", reqVO);
|
||||||
|
model.addAttribute("detail", detail);
|
||||||
|
|
||||||
|
return "record/expense/form";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 유효성 체크 및 데이터 조회
|
||||||
|
*
|
||||||
|
* @param searchMonth 검색 월(yyyyMM)
|
||||||
|
* @param groupNo 검색 그룹
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private DailyRecordDto vaildGetDailyRecord(String searchMonth, String groupNo) {
|
||||||
|
DailyUIReqVO reqVO = new DailyUIReqVO(searchMonth, groupNo);
|
||||||
|
log.debug("getRecordUIReq: {}", reqVO);
|
||||||
|
|
||||||
|
DailyRecordDto dailyRecord = dailyRecordService.detail(reqVO);
|
||||||
|
if (dailyRecord == null || dailyRecord.getId() == null) {
|
||||||
|
throw new NoRecordDataException();
|
||||||
|
}
|
||||||
|
|
||||||
|
return dailyRecord;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
package app.module.front.usecase.daily.expense.adapters.web.model;
|
||||||
|
|
||||||
|
import app.module.front.usecase.daily.record.adapters.web.model.DailyUIReqVO;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class CreateDailyExpenseReqVO extends DailyUIReqVO {
|
||||||
|
/**
|
||||||
|
* 수입 일련번호
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 일계부 일련번호
|
||||||
|
*/
|
||||||
|
private Long dailyRecordSeq;
|
||||||
|
/**
|
||||||
|
* 등록 유형(SELF, OCR)
|
||||||
|
*/
|
||||||
|
private String inputType;
|
||||||
|
/**
|
||||||
|
* 외상판매 여부
|
||||||
|
*/
|
||||||
|
private Boolean credit;
|
||||||
|
/**
|
||||||
|
* 지출의 종류 직접입력
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "지출 종류를 입력해 주세요.")
|
||||||
|
private String categorySelf;
|
||||||
|
/**
|
||||||
|
* 용도
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "용도를 입력해 주세요.")
|
||||||
|
private String sourcePurpose;
|
||||||
|
/**
|
||||||
|
* 수량
|
||||||
|
*/
|
||||||
|
private Integer quantity;
|
||||||
|
/**
|
||||||
|
* 단위 코드
|
||||||
|
*/
|
||||||
|
private String unitCode;
|
||||||
|
/**
|
||||||
|
* 단위 직접입력
|
||||||
|
*/
|
||||||
|
private String unitSelf;
|
||||||
|
/**
|
||||||
|
* 현금
|
||||||
|
*/
|
||||||
|
private Integer price;
|
||||||
|
/**
|
||||||
|
* 현물평가액
|
||||||
|
*/
|
||||||
|
private Integer estimatedValue;
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package app.module.front.usecase.daily.expense.adapters.web.model;
|
||||||
|
|
||||||
|
import app.module.front.usecase.daily.record.adapters.web.model.DailyUIReqVO;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
import org.apache.tika.utils.StringUtils;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class DailyExpenseUIReqVO extends DailyUIReqVO {
|
||||||
|
public DailyExpenseUIReqVO(String month, String no) {
|
||||||
|
setSearchMonth(month);
|
||||||
|
if (!StringUtils.isBlank(no)) {
|
||||||
|
setGroupNo(Integer.parseInt(no));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public DailyExpenseUIReqVO(String month, Integer no) {
|
||||||
|
setSearchMonth(month);
|
||||||
|
setGroupNo(no);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 수입 일련번호
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package app.module.front.usecase.daily.expense.adapters.web.model;
|
||||||
|
|
||||||
|
import app.module.front.usecase.daily.record.adapters.web.model.DailyUIReqVO;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class RemoveDailyExpenseReqVO extends DailyUIReqVO {
|
||||||
|
/**
|
||||||
|
* 수입 일련번호
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "{valid.common.required}")
|
||||||
|
private String id;
|
||||||
|
/**
|
||||||
|
* 일계부 일련번호
|
||||||
|
*/
|
||||||
|
private Long dailyRecordSeq;
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package app.module.front.usecase.daily.expense.adapters.web.validator;
|
||||||
|
|
||||||
|
import app.module.front.usecase.daily.expense.adapters.web.model.CreateDailyExpenseReqVO;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.apache.tika.utils.StringUtils;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.validation.Errors;
|
||||||
|
import org.springframework.validation.Validator;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class CreateDailyExpenseValidator implements Validator {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supports(Class<?> clazz) {
|
||||||
|
return CreateDailyExpenseReqVO.class.equals(clazz);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void validate(Object target, Errors errors) {
|
||||||
|
CreateDailyExpenseReqVO vo = (CreateDailyExpenseReqVO) target;
|
||||||
|
|
||||||
|
if (vo.getPrice() == null && vo.getEstimatedValue() == null) {
|
||||||
|
errors.rejectValue(
|
||||||
|
"price", "valid.common.required",
|
||||||
|
"현금 또는 현물평가액을 입력해 주세요.");
|
||||||
|
errors.rejectValue(
|
||||||
|
"estimatedValue", "valid.common.required",
|
||||||
|
"현금 또는 현물평가액을 입력해 주세요.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("code.record.unit.self".equals(vo.getUnitCode()) && StringUtils.isBlank(vo.getUnitSelf())) {
|
||||||
|
errors.rejectValue(
|
||||||
|
"unitSelf", "valid.common.required",
|
||||||
|
"단위를 입력해 주세요.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package app.module.front.usecase.daily.expense.ports.application.domain;
|
||||||
|
|
||||||
|
import app.module.front.config.adapters.persistence.component.FrontAuditCommand;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@AllArgsConstructor
|
||||||
|
@ToString
|
||||||
|
public class CreateDailyExpenseCmd extends FrontAuditCommand {
|
||||||
|
private Long id;
|
||||||
|
private Long dailyRecordSeq;
|
||||||
|
private String inputType;
|
||||||
|
private Boolean credit;
|
||||||
|
private String incomeMarkCode;
|
||||||
|
private String categorySelf;
|
||||||
|
private String sourcePurpose;
|
||||||
|
private Integer quantity;
|
||||||
|
private String unitCode;
|
||||||
|
private String unitSelf;
|
||||||
|
private Integer price;
|
||||||
|
private Integer estimatedValue;
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package app.module.front.usecase.daily.expense.ports.application.domain;
|
||||||
|
|
||||||
|
import app.module.front.config.adapters.persistence.component.FrontAuditCommand;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@AllArgsConstructor
|
||||||
|
@ToString
|
||||||
|
public class RemoveDailyExpenseCmd extends FrontAuditCommand {
|
||||||
|
private String searchMonth;
|
||||||
|
private Integer groupNo;
|
||||||
|
private Long id;
|
||||||
|
private Long dailyRecordSeq;
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package app.module.front.usecase.daily.income.adapters.persistence;
|
||||||
|
|
||||||
|
import app.module.front.usecase.daily.income.ports.application.domain.CreateDailyIncomeCmd;
|
||||||
|
import app.module.front.usecase.daily.income.adapters.persistence.model.DailyIncomeDto;
|
||||||
|
import app.module.front.usecase.daily.income.ports.application.domain.GetDailyIncomeCmd;
|
||||||
|
import app.module.front.usecase.daily.income.ports.application.domain.RemoveDailyIncomeCmd;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface DailyIncomeMapper {
|
||||||
|
/**
|
||||||
|
* 일계부 수입 목록 조회
|
||||||
|
*
|
||||||
|
* @param command 검색 조건
|
||||||
|
* @return 수입 목록
|
||||||
|
*/
|
||||||
|
List<DailyIncomeDto> getDailyIncomeList(GetDailyIncomeCmd command);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 수입 데이터 존재 여부
|
||||||
|
*
|
||||||
|
* @param command 검색 조건
|
||||||
|
* @return 중복 개수
|
||||||
|
*/
|
||||||
|
Integer getRecordExistCount(GetDailyIncomeCmd command);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 수입 등록
|
||||||
|
*
|
||||||
|
* @param command 등록 데이터
|
||||||
|
*/
|
||||||
|
void createDailyIncome(CreateDailyIncomeCmd command);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 수입 수정
|
||||||
|
*
|
||||||
|
* @param command 수정 데이터
|
||||||
|
*/
|
||||||
|
void updateDailyIncome(CreateDailyIncomeCmd command);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 수입 삭제
|
||||||
|
*
|
||||||
|
* @param command 삭제 데이터
|
||||||
|
*/
|
||||||
|
void removeDailyIncome(RemoveDailyIncomeCmd command);
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package app.module.front.usecase.daily.income.adapters.persistence.model;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class DailyIncomeDto {
|
||||||
|
private Long id;
|
||||||
|
private Long dailyRecordSeq;
|
||||||
|
// TODO : SELF, OCR
|
||||||
|
private String inputType;
|
||||||
|
private Boolean credit;
|
||||||
|
private String cropCode;
|
||||||
|
private String cropLabel;
|
||||||
|
private String categorySelf;
|
||||||
|
private String sourcePurpose;
|
||||||
|
private Integer quantity;
|
||||||
|
private String unitCode;
|
||||||
|
private String unitLabel;
|
||||||
|
private String unitSelf;
|
||||||
|
private Integer price;
|
||||||
|
private Integer estimatedValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 수정 가능 여부
|
||||||
|
* @return true=가능, false=불가능(등록 상태)
|
||||||
|
*/
|
||||||
|
public boolean isUpdated() {
|
||||||
|
return this.id != null && this.id != 0L;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,135 @@
|
|||||||
|
package app.module.front.usecase.daily.income.adapters.web;
|
||||||
|
|
||||||
|
import app.module.core.config.application.exception.NoRecordDataException;
|
||||||
|
import app.module.core.config.application.util.CoreUtil;
|
||||||
|
import app.module.front.usecase.daily.income.adapters.web.model.CreateDailyIncomeReqVO;
|
||||||
|
import app.module.front.usecase.daily.income.adapters.web.model.RemoveDailyIncomeReqVO;
|
||||||
|
import app.module.front.usecase.daily.income.adapters.web.validator.CreateDailyIncomeValidator;
|
||||||
|
import app.module.front.usecase.daily.income.ports.DailyIncomePortIn;
|
||||||
|
import app.module.front.usecase.daily.record.adapters.persistence.model.DailyRecordDto;
|
||||||
|
import app.module.front.usecase.daily.record.adapters.web.model.DailyUIReqVO;
|
||||||
|
import app.module.front.usecase.daily.record.ports.DailyRecordPortIn;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.validation.BindingResult;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RequestMapping(path = "/api/record/income")
|
||||||
|
public class DailyIncomeController {
|
||||||
|
private final CoreUtil coreUtil;
|
||||||
|
private final DailyRecordPortIn dailyRecordPortIn;
|
||||||
|
private final DailyIncomePortIn dailyIncomePortIn;
|
||||||
|
private final CreateDailyIncomeValidator createDailyIncomeValidator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 수입 등록 처리
|
||||||
|
*
|
||||||
|
* @param searchMonth 검색 월(yyyyMM)
|
||||||
|
* @param groupNo 검색 그룹
|
||||||
|
* @param id 수입 일련번호
|
||||||
|
* @param formVO 입력 데이터
|
||||||
|
* @param bindingResult BindingResult
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping(path = "/{searchMonth}/{groupNo}/form/{id}")
|
||||||
|
ResponseEntity<?> create(@PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo
|
||||||
|
, @PathVariable("id") String id
|
||||||
|
, @Valid @RequestBody CreateDailyIncomeReqVO formVO, BindingResult bindingResult) {
|
||||||
|
|
||||||
|
createDailyIncomeValidator.validate(formVO, bindingResult);
|
||||||
|
if (bindingResult.hasErrors()) {
|
||||||
|
return coreUtil.getErrorInfo(bindingResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
DailyRecordDto dailyRecord = this.vaildGetDailyRecord(searchMonth, groupNo);
|
||||||
|
|
||||||
|
formVO.setSearchMonth(searchMonth);
|
||||||
|
formVO.setGroupNo(Integer.parseInt(groupNo));
|
||||||
|
formVO.setId(Long.parseLong(id));
|
||||||
|
formVO.setDailyRecordSeq(dailyRecord.getId());
|
||||||
|
log.debug("formVO: {}", formVO);
|
||||||
|
|
||||||
|
dailyIncomePortIn.create(formVO);
|
||||||
|
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(formVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 수입 삭제 처리
|
||||||
|
*
|
||||||
|
* @param searchMonth 검색 월(yyyyMM)
|
||||||
|
* @param groupNo 검색 그룹
|
||||||
|
* @param formVO 입력 데이터
|
||||||
|
* @param bindingResult BindingResult
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping(path = "/{searchMonth}/{groupNo}/remove")
|
||||||
|
ResponseEntity<?> remove(@PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo
|
||||||
|
, @Valid @RequestBody RemoveDailyIncomeReqVO formVO, BindingResult bindingResult) {
|
||||||
|
|
||||||
|
log.debug("before formVO: {}", formVO);
|
||||||
|
if (bindingResult.hasErrors()) {
|
||||||
|
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
|
||||||
|
.body(bindingResult.getFieldErrors());
|
||||||
|
}
|
||||||
|
|
||||||
|
DailyRecordDto dailyRecord = this.vaildGetDailyRecord(searchMonth, groupNo);
|
||||||
|
|
||||||
|
formVO.setSearchMonth(dailyRecord.getRecordMonth());
|
||||||
|
formVO.setGroupNo(dailyRecord.getGroupNo());
|
||||||
|
formVO.setDailyRecordSeq(dailyRecord.getId());
|
||||||
|
log.debug("formVO: {}", formVO);
|
||||||
|
|
||||||
|
dailyIncomePortIn.remove(formVO);
|
||||||
|
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(formVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 수입 전체 삭제 처리
|
||||||
|
*
|
||||||
|
* @param searchMonth 검색 월(yyyyMM)
|
||||||
|
* @param groupNo 검색 그룹
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping(path = "/{searchMonth}/{groupNo}/reset")
|
||||||
|
ResponseEntity<?> removeAll(@PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo) {
|
||||||
|
|
||||||
|
DailyRecordDto dailyRecord = this.vaildGetDailyRecord(searchMonth, groupNo);
|
||||||
|
|
||||||
|
RemoveDailyIncomeReqVO formVO = new RemoveDailyIncomeReqVO();
|
||||||
|
formVO.setSearchMonth(dailyRecord.getRecordMonth());
|
||||||
|
formVO.setGroupNo(dailyRecord.getGroupNo());
|
||||||
|
formVO.setDailyRecordSeq(dailyRecord.getId());
|
||||||
|
log.debug("formVO: {}", formVO);
|
||||||
|
|
||||||
|
dailyIncomePortIn.remove(formVO);
|
||||||
|
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(formVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 유효성 체크 및 데이터 조회
|
||||||
|
*
|
||||||
|
* @param searchMonth 검색 월(yyyyMM)
|
||||||
|
* @param groupNo 검색 그룹
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private DailyRecordDto vaildGetDailyRecord(String searchMonth, String groupNo) {
|
||||||
|
DailyUIReqVO reqVO = new DailyUIReqVO(searchMonth, groupNo);
|
||||||
|
log.debug("getRecordUIReq: {}", reqVO);
|
||||||
|
|
||||||
|
DailyRecordDto dailyRecord = dailyRecordPortIn.detail(reqVO);
|
||||||
|
if (dailyRecord == null || dailyRecord.getId() == null) {
|
||||||
|
throw new NoRecordDataException();
|
||||||
|
}
|
||||||
|
|
||||||
|
return dailyRecord;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
package app.module.front.usecase.daily.income.adapters.web;
|
||||||
|
|
||||||
|
import app.module.core.config.application.exception.NoRecordDataException;
|
||||||
|
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
|
||||||
|
import app.module.front.usecase.daily.income.adapters.persistence.model.DailyIncomeDto;
|
||||||
|
import app.module.front.usecase.daily.income.adapters.web.model.DailyIncomeUIReqVO;
|
||||||
|
import app.module.front.usecase.daily.income.ports.DailyIncomePortIn;
|
||||||
|
import app.module.front.usecase.daily.record.adapters.persistence.model.DailyRecordDto;
|
||||||
|
import app.module.front.usecase.daily.record.adapters.web.model.DailyUIReqVO;
|
||||||
|
import app.module.front.usecase.daily.record.ports.DailyRecordPortIn;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.thymeleaf.util.StringUtils;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Controller
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RequestMapping(path = "/record/income")
|
||||||
|
public class DailyIncomeUIController {
|
||||||
|
private final UICodeListPortIn uiCodeListPortIn;
|
||||||
|
private final DailyRecordPortIn dailyRecordService;
|
||||||
|
private final DailyIncomePortIn dailyIncomePortIn;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 수입 목록 화면
|
||||||
|
*
|
||||||
|
* @param model Model
|
||||||
|
* @param searchMonth 검색 월(yyyyMM)
|
||||||
|
* @param groupNo 검색 그룹
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(path = "/{searchMonth}/{groupNo}")
|
||||||
|
public String index(Model model, @PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo) {
|
||||||
|
|
||||||
|
DailyRecordDto dailyRecord = this.vaildGetDailyRecord(searchMonth, groupNo);
|
||||||
|
|
||||||
|
DailyIncomeUIReqVO reqVO = new DailyIncomeUIReqVO(searchMonth, groupNo);
|
||||||
|
log.debug("reqVO: {}", reqVO);
|
||||||
|
|
||||||
|
List<DailyIncomeDto> incomeList = dailyIncomePortIn.list(reqVO);
|
||||||
|
|
||||||
|
model.addAttribute("reqVO", reqVO);
|
||||||
|
model.addAttribute("dailyRecord", dailyRecord);
|
||||||
|
model.addAttribute("incomeList", incomeList);
|
||||||
|
|
||||||
|
return "record/income/index";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 수입 등록 화면
|
||||||
|
*
|
||||||
|
* @param model Model
|
||||||
|
* @param searchMonth 검색 월(yyyyMM)
|
||||||
|
* @param groupNo 검색 그룹
|
||||||
|
* @param id 수입 일련번호
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(path = "/{searchMonth}/{groupNo}/form/{id}")
|
||||||
|
public String formBySelf(Model model, @PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo
|
||||||
|
, @PathVariable("id") String id) {
|
||||||
|
|
||||||
|
DailyIncomeUIReqVO reqVO = new DailyIncomeUIReqVO(searchMonth, groupNo);
|
||||||
|
if (StringUtils.isEmpty(id)) {
|
||||||
|
reqVO.setId(0L);
|
||||||
|
} else {
|
||||||
|
reqVO.setId(Long.parseLong(id));
|
||||||
|
}
|
||||||
|
log.debug("reqVO: {}", reqVO);
|
||||||
|
|
||||||
|
DailyIncomeDto detail = new DailyIncomeDto();
|
||||||
|
if (reqVO.getId() != 0L) {
|
||||||
|
detail = dailyIncomePortIn.detail(reqVO);
|
||||||
|
if (detail == null || !detail.isUpdated()) {
|
||||||
|
throw new NoRecordDataException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
model.addAttribute("recordCrop", uiCodeListPortIn.connect("code.record.crop"));
|
||||||
|
model.addAttribute("recordUnit", uiCodeListPortIn.connect("code.record.unit"));
|
||||||
|
|
||||||
|
model.addAttribute("reqVO", reqVO);
|
||||||
|
model.addAttribute("detail", detail);
|
||||||
|
|
||||||
|
return "record/income/form";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 유효성 체크 및 데이터 조회
|
||||||
|
*
|
||||||
|
* @param searchMonth 검색 월(yyyyMM)
|
||||||
|
* @param groupNo 검색 그룹
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private DailyRecordDto vaildGetDailyRecord(String searchMonth, String groupNo) {
|
||||||
|
DailyUIReqVO reqVO = new DailyUIReqVO(searchMonth, groupNo);
|
||||||
|
log.debug("getRecordUIReq: {}", reqVO);
|
||||||
|
|
||||||
|
DailyRecordDto dailyRecord = dailyRecordService.detail(reqVO);
|
||||||
|
if (dailyRecord == null || dailyRecord.getId() == null) {
|
||||||
|
throw new NoRecordDataException();
|
||||||
|
}
|
||||||
|
|
||||||
|
return dailyRecord;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
package app.module.front.usecase.daily.income.adapters.web.model;
|
||||||
|
|
||||||
|
import app.module.front.usecase.daily.record.adapters.web.model.DailyUIReqVO;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class CreateDailyIncomeReqVO extends DailyUIReqVO {
|
||||||
|
/**
|
||||||
|
* 수입 일련번호
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 일계부 일련번호
|
||||||
|
*/
|
||||||
|
private Long dailyRecordSeq;
|
||||||
|
/**
|
||||||
|
* 등록 유형(SELF, OCR)
|
||||||
|
*/
|
||||||
|
private String inputType;
|
||||||
|
/**
|
||||||
|
* 외상판매 여부
|
||||||
|
*/
|
||||||
|
private Boolean credit;
|
||||||
|
/**
|
||||||
|
* 재배형태 코드
|
||||||
|
*/
|
||||||
|
private String cropCode;
|
||||||
|
/**
|
||||||
|
* 수입의 종류 직접입력
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "수입 종류를 입력해 주세요.")
|
||||||
|
private String categorySelf;
|
||||||
|
/**
|
||||||
|
* 수입원
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "수입원을 입력해 주세요.")
|
||||||
|
private String sourcePurpose;
|
||||||
|
/**
|
||||||
|
* 수량
|
||||||
|
*/
|
||||||
|
private Integer quantity;
|
||||||
|
/**
|
||||||
|
* 단위 코드
|
||||||
|
*/
|
||||||
|
private String unitCode;
|
||||||
|
/**
|
||||||
|
* 단위 직접입력
|
||||||
|
*/
|
||||||
|
private String unitSelf;
|
||||||
|
/**
|
||||||
|
* 현금
|
||||||
|
*/
|
||||||
|
private Integer price;
|
||||||
|
/**
|
||||||
|
* 현물평가액
|
||||||
|
*/
|
||||||
|
private Integer estimatedValue;
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package app.module.front.usecase.daily.income.adapters.web.model;
|
||||||
|
|
||||||
|
import app.module.front.usecase.daily.record.adapters.web.model.DailyUIReqVO;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
import org.apache.tika.utils.StringUtils;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class DailyIncomeUIReqVO extends DailyUIReqVO {
|
||||||
|
public DailyIncomeUIReqVO(String month, String no) {
|
||||||
|
setSearchMonth(month);
|
||||||
|
if (!StringUtils.isBlank(no)) {
|
||||||
|
setGroupNo(Integer.parseInt(no));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public DailyIncomeUIReqVO(String month, Integer no) {
|
||||||
|
setSearchMonth(month);
|
||||||
|
setGroupNo(no);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 수입 일련번호
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package app.module.front.usecase.daily.income.adapters.web.model;
|
||||||
|
|
||||||
|
import app.module.front.usecase.daily.record.adapters.web.model.DailyUIReqVO;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class RemoveDailyIncomeReqVO extends DailyUIReqVO {
|
||||||
|
/**
|
||||||
|
* 수입 일련번호
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "{valid.common.required}")
|
||||||
|
private String id;
|
||||||
|
/**
|
||||||
|
* 일계부 일련번호
|
||||||
|
*/
|
||||||
|
private Long dailyRecordSeq;
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package app.module.front.usecase.daily.income.adapters.web.validator;
|
||||||
|
|
||||||
|
import app.module.front.config.constants.CommonConstants;
|
||||||
|
import app.module.front.usecase.daily.income.adapters.web.model.CreateDailyIncomeReqVO;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.apache.tika.utils.StringUtils;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.validation.Errors;
|
||||||
|
import org.springframework.validation.Validator;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class CreateDailyIncomeValidator implements Validator {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supports(Class<?> clazz) {
|
||||||
|
return CreateDailyIncomeReqVO.class.equals(clazz);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void validate(Object target, Errors errors) {
|
||||||
|
CreateDailyIncomeReqVO vo = (CreateDailyIncomeReqVO) target;
|
||||||
|
|
||||||
|
if (vo.getPrice() == null && vo.getEstimatedValue() == null) {
|
||||||
|
errors.rejectValue(
|
||||||
|
"price", "valid.common.required",
|
||||||
|
"현금 또는 현물평가액을 입력해 주세요.");
|
||||||
|
errors.rejectValue(
|
||||||
|
"estimatedValue", "valid.common.required",
|
||||||
|
"현금 또는 현물평가액을 입력해 주세요.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CommonConstants.UNIT_CODE_SELF.equals(vo.getUnitCode()) && StringUtils.isBlank(vo.getUnitSelf())) {
|
||||||
|
errors.rejectValue(
|
||||||
|
"unitSelf", "valid.common.required",
|
||||||
|
"단위를 입력해 주세요.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package app.module.front.usecase.daily.income.ports.application.domain;
|
||||||
|
|
||||||
|
import app.module.front.config.adapters.persistence.component.FrontAuditCommand;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@AllArgsConstructor
|
||||||
|
@ToString
|
||||||
|
public class CreateDailyIncomeCmd extends FrontAuditCommand {
|
||||||
|
private Long id;
|
||||||
|
private Long dailyRecordSeq;
|
||||||
|
private String inputType;
|
||||||
|
private Boolean credit;
|
||||||
|
private String cropCode;
|
||||||
|
private String expenseMarkCode;
|
||||||
|
private String categorySelf;
|
||||||
|
private String sourcePurpose;
|
||||||
|
private Integer quantity;
|
||||||
|
private String unitCode;
|
||||||
|
private String unitSelf;
|
||||||
|
private Integer price;
|
||||||
|
private Integer estimatedValue;
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package app.module.front.usecase.daily.income.ports.application.domain;
|
||||||
|
|
||||||
|
import app.module.front.config.adapters.persistence.component.FrontAuditCommand;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@AllArgsConstructor
|
||||||
|
@ToString
|
||||||
|
public class RemoveDailyIncomeCmd extends FrontAuditCommand {
|
||||||
|
private String searchMonth;
|
||||||
|
private Integer groupNo;
|
||||||
|
private Long id;
|
||||||
|
private Long dailyRecordSeq;
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package app.module.front.usecase.daily.record.adapters.persistence;
|
||||||
|
|
||||||
|
import app.module.front.usecase.daily.record.adapters.persistence.model.DailyRecordDto;
|
||||||
|
import app.module.front.usecase.daily.record.ports.application.domain.CreateDailyRecordCmd;
|
||||||
|
import app.module.front.usecase.daily.record.ports.application.domain.GetDailyRecordCmd;
|
||||||
|
import app.module.front.usecase.daily.record.ports.application.domain.UpdateDailyRecordStatusCmd;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface DailyRecordMapper {
|
||||||
|
/**
|
||||||
|
* 일계부 항목 조회
|
||||||
|
*
|
||||||
|
* @param command 검색 조건
|
||||||
|
* @return 항목 상세
|
||||||
|
*/
|
||||||
|
DailyRecordDto getDailyRecord(GetDailyRecordCmd command);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 항목 등록 여부
|
||||||
|
*
|
||||||
|
* @param command 검색 조건
|
||||||
|
* @return 등록 여부
|
||||||
|
*/
|
||||||
|
Integer getDailyRecordExistCount(GetDailyRecordCmd command);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 항목 등록(생성)
|
||||||
|
*
|
||||||
|
* @param command 등록 데이터
|
||||||
|
*/
|
||||||
|
void createDailyRecord(CreateDailyRecordCmd command);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 항목 수정
|
||||||
|
*
|
||||||
|
* @param command 수정 데이터
|
||||||
|
*/
|
||||||
|
void updateDailyRecord(CreateDailyRecordCmd command);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 항목의 상태 수정
|
||||||
|
*
|
||||||
|
* @param command 수정 데이터
|
||||||
|
*/
|
||||||
|
void updateDailyRecordStatus(UpdateDailyRecordStatusCmd command);
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package app.module.front.usecase.daily.record.adapters.persistence.model;
|
||||||
|
|
||||||
|
import app.module.front.usecase.daily.record.adapters.web.model.DailyStatus;
|
||||||
|
import app.module.front.usecase.daily.record.adapters.web.model.DailyTargetStatus;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class DailyRecordDto {
|
||||||
|
// household_seq, record_month, day_group_no, start_date, end_date
|
||||||
|
// , all_status, income_status, work_status, expense_status, power_status, forestry_status
|
||||||
|
// , created_at, created_by, is_deleted
|
||||||
|
|
||||||
|
private String recordMonth;
|
||||||
|
private Integer groupNo;
|
||||||
|
private Integer startDay;
|
||||||
|
private Integer endDay;
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
private LocalDate startDate;
|
||||||
|
private LocalDate endDate;
|
||||||
|
private DailyStatus allStatus;
|
||||||
|
private DailyTargetStatus incomeStatus;
|
||||||
|
private DailyTargetStatus workStatus;
|
||||||
|
private DailyTargetStatus expenseStatus;
|
||||||
|
private DailyTargetStatus powerStatus;
|
||||||
|
private DailyTargetStatus forestryStatus;
|
||||||
|
private DailyTargetStatus farmingStatus;
|
||||||
|
|
||||||
|
public boolean isUpdated() {
|
||||||
|
return this.id != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package app.module.front.usecase.daily.record.adapters.persistence.model;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class UpdateDailyRecordDto {
|
||||||
|
private String monthly;
|
||||||
|
private String updatedBy;
|
||||||
|
private String statusType;
|
||||||
|
private String statusCode;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
package app.module.front.usecase.daily.record.adapters.web;
|
||||||
|
|
||||||
|
import app.module.front.usecase.daily.record.adapters.persistence.model.DailyRecordDto;
|
||||||
|
import app.module.front.usecase.daily.record.adapters.web.model.CreateDailyRecordReqVO;
|
||||||
|
import app.module.front.usecase.daily.record.adapters.web.model.DailyTargetStatus;
|
||||||
|
import app.module.front.usecase.daily.record.adapters.web.model.DailyUIReqVO;
|
||||||
|
import app.module.front.usecase.daily.record.adapters.web.validator.CreateDailyRecordValidator;
|
||||||
|
import app.module.front.usecase.daily.record.ports.DailyRecordPortIn;
|
||||||
|
import app.module.front.usecase.daily.record.ports.application.domain.GetDailyRecordCmd;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.validation.BindingResult;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RequestMapping(path = "/api/record/daily")
|
||||||
|
public class DailyRecordController {
|
||||||
|
private final DailyRecordPortIn dailyRecordPortIn;
|
||||||
|
private final CreateDailyRecordValidator createDailyRecordValidator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 등록 처리
|
||||||
|
*
|
||||||
|
* @param searchMonth
|
||||||
|
* @param groupNo
|
||||||
|
* @param formVO
|
||||||
|
* @param bindingResult
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping(path = "/{searchMonth}/{groupNo}")
|
||||||
|
ResponseEntity<?> create(@PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo
|
||||||
|
, @Valid @RequestBody CreateDailyRecordReqVO formVO, BindingResult bindingResult) {
|
||||||
|
|
||||||
|
createDailyRecordValidator.validate(formVO, bindingResult);
|
||||||
|
if (bindingResult.hasErrors()) {
|
||||||
|
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
|
||||||
|
.body(bindingResult.getFieldErrors());
|
||||||
|
}
|
||||||
|
|
||||||
|
DailyUIReqVO reqVO = new DailyUIReqVO(searchMonth, groupNo);
|
||||||
|
log.debug("reqVO: {}", reqVO);
|
||||||
|
|
||||||
|
DailyRecordDto detail = dailyRecordPortIn.detail(reqVO);
|
||||||
|
formVO.setRecordMonth(reqVO.getSearchMonth());
|
||||||
|
formVO.setDayGroupNo(reqVO.getGroupNo());
|
||||||
|
formVO.setStartDate(detail.getStartDate());
|
||||||
|
formVO.setEndDate(detail.getEndDate());
|
||||||
|
log.debug("formVO: {}", formVO);
|
||||||
|
|
||||||
|
dailyRecordPortIn.create(formVO);
|
||||||
|
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(reqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(path = "/{searchMonth}/{groupNo}/today-none")
|
||||||
|
ResponseEntity<?> todayNone(@PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo
|
||||||
|
, @RequestParam(name = "target", required = true, defaultValue = "") String targetType
|
||||||
|
, @RequestParam(name = "status", required = false, defaultValue = "N") String targetStatus) {
|
||||||
|
|
||||||
|
DailyUIReqVO reqVO = new DailyUIReqVO(searchMonth, groupNo);
|
||||||
|
log.debug("reqVO: {}", reqVO);
|
||||||
|
log.debug("target: {}", targetType);
|
||||||
|
log.debug("status: {}", targetStatus);
|
||||||
|
|
||||||
|
DailyRecordDto detail = dailyRecordPortIn.detail(reqVO);
|
||||||
|
|
||||||
|
// TODO : true / false 를 업데이트하는 것은 대상 타켓이 되는 것이라 판단하여 그냥 강제 업데이트할 것인가? valid 체크
|
||||||
|
dailyRecordPortIn.updateByStatus(detail.getRecordMonth(), detail.getGroupNo(), targetType, "Y".equals(targetStatus) ? DailyTargetStatus.TODAY_NONE.name() : DailyTargetStatus.TARGET.name());
|
||||||
|
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(reqVO);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package app.module.front.usecase.daily.record.adapters.web;
|
||||||
|
|
||||||
|
import app.module.core.config.application.exception.NoMatchingURIException;
|
||||||
|
import app.module.front.usecase.daily.record.adapters.persistence.model.DailyRecordDto;
|
||||||
|
import app.module.front.usecase.daily.record.adapters.web.model.DailyUIReqVO;
|
||||||
|
import app.module.front.usecase.daily.record.adapters.web.validator.CreateDailyRecordValidator;
|
||||||
|
import app.module.front.usecase.daily.record.ports.DailyRecordPortIn;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Controller
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RequestMapping(path = "/record/daily")
|
||||||
|
public class DailyRecordUIController {
|
||||||
|
private final DailyRecordPortIn dailyRecordPortIn;
|
||||||
|
private final CreateDailyRecordValidator createDailyRecordValidator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 등록 화면
|
||||||
|
*
|
||||||
|
* @param model
|
||||||
|
* @param searchMonth 검색 월(yyyyMM)
|
||||||
|
* @param groupNo 검색 그룹
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(path = "/{searchMonth}/{groupNo}")
|
||||||
|
public String createForm(Model model, @PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo) {
|
||||||
|
|
||||||
|
DailyUIReqVO reqVO = new DailyUIReqVO(searchMonth, groupNo);
|
||||||
|
log.debug("reqVO: {}", reqVO);
|
||||||
|
|
||||||
|
DailyRecordDto dailyRecord = dailyRecordPortIn.detail(reqVO);
|
||||||
|
if (dailyRecord == null) {
|
||||||
|
throw new NoMatchingURIException("[Record] 잘못된 접근");
|
||||||
|
}
|
||||||
|
|
||||||
|
model.addAttribute("reqVO", reqVO);
|
||||||
|
model.addAttribute("dailyRecord", dailyRecord);
|
||||||
|
|
||||||
|
return "record/daily";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package app.module.front.usecase.daily.record.adapters.web.model;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ToString
|
||||||
|
public class CreateDailyRecordReqVO {
|
||||||
|
private Long id;
|
||||||
|
private String recordMonth;
|
||||||
|
private int dayGroupNo;
|
||||||
|
private LocalDate startDate;
|
||||||
|
private LocalDate endDate;
|
||||||
|
private String todayNone;
|
||||||
|
private DailyStatus allStatus;
|
||||||
|
private DailyTargetStatus incomeStatus;
|
||||||
|
private DailyTargetStatus workStatus;
|
||||||
|
private DailyTargetStatus expenseStatus;
|
||||||
|
private DailyTargetStatus powerStatus;
|
||||||
|
private DailyTargetStatus forestryStatus;
|
||||||
|
private DailyTargetStatus farmingStatus;
|
||||||
|
|
||||||
|
public void setTodayNone(String todayNone) {
|
||||||
|
if ("Y".equals(todayNone)) {
|
||||||
|
this.allStatus = DailyStatus.TODAY_NONE;
|
||||||
|
} else {
|
||||||
|
this.allStatus = DailyStatus.WAITING;
|
||||||
|
|
||||||
|
if (incomeStatus == null) {
|
||||||
|
this.incomeStatus = DailyTargetStatus.NONE;
|
||||||
|
}
|
||||||
|
if (workStatus == null) {
|
||||||
|
this.workStatus = DailyTargetStatus.NONE;
|
||||||
|
}
|
||||||
|
if (expenseStatus == null) {
|
||||||
|
this.expenseStatus = DailyTargetStatus.NONE;
|
||||||
|
}
|
||||||
|
if (powerStatus == null) {
|
||||||
|
this.powerStatus = DailyTargetStatus.NONE;
|
||||||
|
}
|
||||||
|
if (forestryStatus == null) {
|
||||||
|
this.forestryStatus = DailyTargetStatus.NONE;
|
||||||
|
}
|
||||||
|
if (farmingStatus == null) {
|
||||||
|
this.farmingStatus = DailyTargetStatus.NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package app.module.front.usecase.daily.record.adapters.web.model;
|
||||||
|
|
||||||
|
import app.module.front.config.application.util.AuthUtil;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ToString
|
||||||
|
public class DailyCmd {
|
||||||
|
/**
|
||||||
|
* 검색 월(yyyyMM)
|
||||||
|
*/
|
||||||
|
private String searchMonth;
|
||||||
|
/**
|
||||||
|
* 검색 그룸번호
|
||||||
|
*/
|
||||||
|
private Integer groupNo;
|
||||||
|
/**
|
||||||
|
* 임가 일련번호
|
||||||
|
*/
|
||||||
|
private Long householdSeq;
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package app.module.front.usecase.daily.record.adapters.web.model;
|
||||||
|
|
||||||
|
public enum DailyStatus {
|
||||||
|
/**
|
||||||
|
* 입력중
|
||||||
|
*/
|
||||||
|
WAITING,
|
||||||
|
/**
|
||||||
|
* 등록 없음
|
||||||
|
*/
|
||||||
|
TODAY_NONE,
|
||||||
|
/**
|
||||||
|
* 등록 완료
|
||||||
|
*/
|
||||||
|
DONE,
|
||||||
|
;
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package app.module.front.usecase.daily.record.adapters.web.model;
|
||||||
|
|
||||||
|
public enum DailyTargetStatus {
|
||||||
|
/**
|
||||||
|
* 등록 대상
|
||||||
|
*/
|
||||||
|
TARGET,
|
||||||
|
/**
|
||||||
|
* 금일 없음
|
||||||
|
*/
|
||||||
|
TODAY_NONE,
|
||||||
|
/**
|
||||||
|
* 등록 없음
|
||||||
|
*/
|
||||||
|
NONE,
|
||||||
|
// /**
|
||||||
|
// * 등록 완료
|
||||||
|
// */
|
||||||
|
// DONE,
|
||||||
|
;
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package app.module.front.usecase.daily.record.adapters.web.model;
|
||||||
|
|
||||||
|
import app.module.front.config.application.util.AuthUtil;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.ToString;
|
||||||
|
import org.apache.tika.utils.StringUtils;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ToString
|
||||||
|
public class DailyUIReqVO {
|
||||||
|
public DailyUIReqVO() {
|
||||||
|
this.householdSeq = AuthUtil.getUserSeq();
|
||||||
|
}
|
||||||
|
|
||||||
|
public DailyUIReqVO(String searchMonth, Integer groupNo) {
|
||||||
|
this.householdSeq = AuthUtil.getUserSeq();
|
||||||
|
this.searchMonth = searchMonth;
|
||||||
|
this.groupNo = groupNo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DailyUIReqVO(String searchMonth, String groupNo) {
|
||||||
|
this.householdSeq = AuthUtil.getUserSeq();
|
||||||
|
this.searchMonth = searchMonth;
|
||||||
|
if (!StringUtils.isBlank(groupNo)) {
|
||||||
|
this.groupNo = Integer.parseInt(groupNo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 검색 월(yyyyMM)
|
||||||
|
*/
|
||||||
|
private String searchMonth;
|
||||||
|
/**
|
||||||
|
* 검색 그룸번호
|
||||||
|
*/
|
||||||
|
private Integer groupNo;
|
||||||
|
/**
|
||||||
|
* 임가 일련번호
|
||||||
|
*/
|
||||||
|
private Long householdSeq;
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package app.module.front.usecase.daily.record.adapters.web.validator;
|
||||||
|
|
||||||
|
import app.module.core.config.application.util.MessageUtil;
|
||||||
|
import app.module.front.usecase.daily.record.adapters.web.model.CreateDailyRecordReqVO;
|
||||||
|
import app.module.front.usecase.daily.record.adapters.web.model.DailyStatus;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.validation.Errors;
|
||||||
|
import org.springframework.validation.Validator;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class CreateDailyRecordValidator implements Validator {
|
||||||
|
private final MessageUtil messageUtil;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supports(Class<?> clazz) {
|
||||||
|
return CreateDailyRecordReqVO.class.equals(clazz);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void validate(Object target, Errors errors) {
|
||||||
|
CreateDailyRecordReqVO vo = (CreateDailyRecordReqVO) target;
|
||||||
|
|
||||||
|
if (DailyStatus.WAITING.equals(vo.getAllStatus())) {
|
||||||
|
int noneCount = 0;
|
||||||
|
if (vo.getIncomeStatus() != null) {
|
||||||
|
noneCount++;
|
||||||
|
}
|
||||||
|
if (vo.getWorkStatus() != null) {
|
||||||
|
noneCount++;
|
||||||
|
}
|
||||||
|
if (vo.getExpenseStatus() != null) {
|
||||||
|
noneCount++;
|
||||||
|
}
|
||||||
|
if (vo.getPowerStatus() != null) {
|
||||||
|
noneCount++;
|
||||||
|
}
|
||||||
|
if (vo.getForestryStatus() != null) {
|
||||||
|
noneCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (noneCount == 0) {
|
||||||
|
errors.rejectValue(
|
||||||
|
"incomeStatus", "valid.common.required",
|
||||||
|
"등록하실 항목을 선택해 주세요.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package app.module.front.usecase.daily.record.ports.application.domain;
|
||||||
|
|
||||||
|
import app.module.front.config.adapters.persistence.component.FrontAuditCommand;
|
||||||
|
import app.module.front.usecase.daily.record.adapters.web.model.DailyStatus;
|
||||||
|
import app.module.front.usecase.daily.record.adapters.web.model.DailyTargetStatus;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@AllArgsConstructor
|
||||||
|
@ToString
|
||||||
|
public class CreateDailyRecordCmd extends FrontAuditCommand {
|
||||||
|
private Long id;
|
||||||
|
private String recordMonth;
|
||||||
|
private int dayGroupNo;
|
||||||
|
private LocalDate startDate;
|
||||||
|
private LocalDate endDate;
|
||||||
|
private DailyStatus allStatus;
|
||||||
|
private DailyTargetStatus incomeStatus;
|
||||||
|
private DailyTargetStatus workStatus;
|
||||||
|
private DailyTargetStatus expenseStatus;
|
||||||
|
private DailyTargetStatus powerStatus;
|
||||||
|
private DailyTargetStatus forestryStatus;
|
||||||
|
private DailyTargetStatus farmingStatus;
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package app.module.front.usecase.daily.record.ports.application.domain;
|
||||||
|
|
||||||
|
import app.module.front.config.adapters.persistence.component.FrontAuditCommand;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@AllArgsConstructor
|
||||||
|
@ToString
|
||||||
|
public class UpdateDailyRecordStatusCmd extends FrontAuditCommand {
|
||||||
|
private String recordMonth;
|
||||||
|
private Integer dayGroupNo;
|
||||||
|
private String allStatus;
|
||||||
|
private String targetType;
|
||||||
|
private String targetStatus;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user