[FO] 일계부 항목, 수입, 지출 package 변경
This commit is contained in:
@@ -6,7 +6,7 @@ import app.module.front.usecase.daily.calendar.ports.RecordCalendarPortOut;
|
|||||||
import app.module.front.usecase.daily.calendar.ports.application.domain.RecordCalendar;
|
import app.module.front.usecase.daily.calendar.ports.application.domain.RecordCalendar;
|
||||||
import app.module.front.usecase.daily.calendar.ports.application.domain.CalendarChildren;
|
import app.module.front.usecase.daily.calendar.ports.application.domain.CalendarChildren;
|
||||||
import app.module.front.usecase.daily.calendar.ports.application.domain.RecordCalendarCmd;
|
import app.module.front.usecase.daily.calendar.ports.application.domain.RecordCalendarCmd;
|
||||||
import app.module.front.usecase.daily.record.web.model.DailyTargetStatus;
|
import app.module.front.usecase.daily.record.adapters.web.model.DailyTargetStatus;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package app.module.front.usecase.daily.calendar.adapters.persistence.model;
|
package app.module.front.usecase.daily.calendar.adapters.persistence.model;
|
||||||
|
|
||||||
import app.module.front.usecase.daily.record.web.model.DailyStatus;
|
import app.module.front.usecase.daily.record.adapters.web.model.DailyStatus;
|
||||||
import app.module.front.usecase.daily.record.web.model.DailyTargetStatus;
|
import app.module.front.usecase.daily.record.adapters.web.model.DailyTargetStatus;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package app.module.front.usecase.daily.calendar.adapters.web.model;
|
package app.module.front.usecase.daily.calendar.adapters.web.model;
|
||||||
|
|
||||||
import app.module.front.usecase.daily.record.web.model.DailyUIReqVO;
|
import app.module.front.usecase.daily.record.adapters.web.model.DailyUIReqVO;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
import org.apache.tika.utils.StringUtils;
|
import org.apache.tika.utils.StringUtils;
|
||||||
|
|||||||
@@ -1,17 +1,6 @@
|
|||||||
package app.module.front.usecase.daily.calendar.ports.application.domain;
|
package app.module.front.usecase.daily.calendar.ports.application.domain;
|
||||||
|
|
||||||
import app.module.front.usecase.daily.record.web.model.DailyCmd;
|
|
||||||
import app.module.front.usecase.daily.record.web.model.DailyUIReqVO;
|
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import org.apache.tika.utils.StringUtils;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package app.module.front.usecase.daily.expense.adapters.persistence;
|
||||||
|
|
||||||
|
import app.module.front.usecase.daily.expense.adapters.persistence.model.DailyExpenseDto;
|
||||||
|
import app.module.front.usecase.daily.expense.ports.DailyExpensePortOut;
|
||||||
|
import app.module.front.usecase.daily.expense.ports.application.domain.CreateDailyExpenseCmd;
|
||||||
|
import app.module.front.usecase.daily.expense.ports.application.domain.GetDailyExpenseCmd;
|
||||||
|
import app.module.front.usecase.daily.expense.ports.application.domain.RemoveDailyExpenseCmd;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Repository
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class DailyExpenseDao implements DailyExpensePortOut {
|
||||||
|
private final DailyExpenseMapper dailyExpenseMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DailyExpenseDto> list(GetDailyExpenseCmd command) {
|
||||||
|
return dailyExpenseMapper.getDailyExpenseList(command);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void create(GetDailyExpenseCmd findCmd, CreateDailyExpenseCmd command) {
|
||||||
|
Integer existCount = dailyExpenseMapper.getRecordExistCount(findCmd);
|
||||||
|
if (existCount == 0) {
|
||||||
|
dailyExpenseMapper.createDailyExpense(command);
|
||||||
|
|
||||||
|
log.debug("[CreateDailyExpense] record={}", command);
|
||||||
|
} else {
|
||||||
|
dailyExpenseMapper.updateDailyExpense(command);
|
||||||
|
|
||||||
|
log.debug("[UpdateDailyExpense] record={}", command);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void remove(GetDailyExpenseCmd findCmd, RemoveDailyExpenseCmd command) {
|
||||||
|
Integer existCount = dailyExpenseMapper.getRecordExistCount(findCmd);
|
||||||
|
if (existCount != 0) {
|
||||||
|
dailyExpenseMapper.removeDailyExpense(command);
|
||||||
|
|
||||||
|
log.debug("[RemoveDailyExpense] record={}", command);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
package app.module.front.usecase.daily.expense.persistence;
|
|
||||||
|
|
||||||
import app.module.front.usecase.daily.expense.persistence.model.CreateDailyExpenseCmd;
|
|
||||||
import app.module.front.usecase.daily.expense.persistence.model.DailyExpenseDto;
|
|
||||||
import app.module.front.usecase.daily.expense.persistence.model.RemoveDailyExpenseCmd;
|
|
||||||
import app.module.front.usecase.daily.expense.web.model.DailyExpenseUIReqVO;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Mapper
|
|
||||||
public interface DailyExpenseMapper {
|
|
||||||
/**
|
|
||||||
* 일계부 지출 목록 조회
|
|
||||||
*
|
|
||||||
* @param reqVO 검색 조건
|
|
||||||
* @return 수입 목록
|
|
||||||
*/
|
|
||||||
List<DailyExpenseDto> getDailyExpenseList(DailyExpenseUIReqVO reqVO);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 일계부 지출 데이터 존재 여부
|
|
||||||
*
|
|
||||||
* @param reqVO 검색 조건
|
|
||||||
* @return 중복 개수
|
|
||||||
*/
|
|
||||||
Integer getRecordExistCount(DailyExpenseUIReqVO reqVO);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 일계부 지출 등록
|
|
||||||
*
|
|
||||||
* @param command 등록 데이터
|
|
||||||
*/
|
|
||||||
void createDailyExpense(CreateDailyExpenseCmd command);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 일계부 지출 수정
|
|
||||||
*
|
|
||||||
* @param command 수정 데이터
|
|
||||||
*/
|
|
||||||
void updateDailyExpense(CreateDailyExpenseCmd command);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 일계부 지출 삭제
|
|
||||||
*
|
|
||||||
* @param command 삭제 데이터
|
|
||||||
*/
|
|
||||||
void removeDailyExpense(RemoveDailyExpenseCmd command);
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
package app.module.front.usecase.daily.expense.persistence.model;
|
|
||||||
|
|
||||||
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 Integer price;
|
|
||||||
private Integer estimatedValue;
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
package app.module.front.usecase.daily.expense.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 Integer price;
|
|
||||||
private Integer estimatedValue;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 수정 가능 여부
|
|
||||||
* @return true=가능, false=불가능(등록 상태)
|
|
||||||
*/
|
|
||||||
public boolean isUpdated() {
|
|
||||||
return this.id != null && this.id != 0L;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package app.module.front.usecase.daily.expense.persistence.model;
|
|
||||||
|
|
||||||
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,40 @@
|
|||||||
|
package app.module.front.usecase.daily.expense.ports;
|
||||||
|
|
||||||
|
import app.module.front.usecase.daily.expense.adapters.persistence.model.DailyExpenseDto;
|
||||||
|
import app.module.front.usecase.daily.expense.adapters.web.model.CreateDailyExpenseReqVO;
|
||||||
|
import app.module.front.usecase.daily.expense.adapters.web.model.DailyExpenseUIReqVO;
|
||||||
|
import app.module.front.usecase.daily.expense.adapters.web.model.RemoveDailyExpenseReqVO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface DailyExpensePortIn {
|
||||||
|
/**
|
||||||
|
* 일계부 지출 조회
|
||||||
|
*
|
||||||
|
* @param reqVO 검색 조건
|
||||||
|
* @return 지출 목록
|
||||||
|
*/
|
||||||
|
List<DailyExpenseDto> list(DailyExpenseUIReqVO reqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 지출 조회
|
||||||
|
*
|
||||||
|
* @param reqVO 검색 조건
|
||||||
|
* @return 지출 상세
|
||||||
|
*/
|
||||||
|
DailyExpenseDto detail(DailyExpenseUIReqVO reqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 지출 등록
|
||||||
|
*
|
||||||
|
* @param formVO 입력 데이터
|
||||||
|
*/
|
||||||
|
void create(CreateDailyExpenseReqVO formVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 지출 삭제
|
||||||
|
*
|
||||||
|
* @param formVO 삭제 검색 조건
|
||||||
|
*/
|
||||||
|
void remove(RemoveDailyExpenseReqVO formVO);
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package app.module.front.usecase.daily.expense.ports;
|
||||||
|
|
||||||
|
import app.module.front.usecase.daily.expense.adapters.persistence.model.DailyExpenseDto;
|
||||||
|
import app.module.front.usecase.daily.expense.ports.application.domain.CreateDailyExpenseCmd;
|
||||||
|
import app.module.front.usecase.daily.expense.ports.application.domain.GetDailyExpenseCmd;
|
||||||
|
import app.module.front.usecase.daily.expense.ports.application.domain.RemoveDailyExpenseCmd;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface DailyExpensePortOut {
|
||||||
|
/**
|
||||||
|
* 일계부 지출 조회
|
||||||
|
*
|
||||||
|
* @param command 검색 조건
|
||||||
|
* @return 지출 목록
|
||||||
|
*/
|
||||||
|
List<DailyExpenseDto> list(GetDailyExpenseCmd command);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 지출 등록
|
||||||
|
*
|
||||||
|
* @param findCmd 검색 조건
|
||||||
|
* @param command 입력 데이터
|
||||||
|
*/
|
||||||
|
void create(GetDailyExpenseCmd findCmd, CreateDailyExpenseCmd command);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 지출 삭제
|
||||||
|
*
|
||||||
|
* @param findCmd 검색 조건
|
||||||
|
* @param command 삭제 검색 조건
|
||||||
|
*/
|
||||||
|
void remove(GetDailyExpenseCmd findCmd, RemoveDailyExpenseCmd command);
|
||||||
|
}
|
||||||
@@ -1,36 +1,36 @@
|
|||||||
package app.module.front.usecase.daily.expense.service;
|
package app.module.front.usecase.daily.expense.ports.application;
|
||||||
|
|
||||||
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
|
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
|
||||||
import app.module.core.usecase.uicode.list.ports.application.domain.UICodeElement;
|
import app.module.core.usecase.uicode.list.ports.application.domain.UICodeElement;
|
||||||
import app.module.front.config.application.util.AuditUtil;
|
import app.module.front.config.application.util.AuditUtil;
|
||||||
import app.module.front.usecase.daily.expense.persistence.DailyExpenseMapper;
|
import app.module.front.usecase.daily.expense.adapters.persistence.model.DailyExpenseDto;
|
||||||
import app.module.front.usecase.daily.expense.persistence.model.CreateDailyExpenseCmd;
|
import app.module.front.usecase.daily.expense.adapters.web.model.CreateDailyExpenseReqVO;
|
||||||
import app.module.front.usecase.daily.expense.persistence.model.DailyExpenseDto;
|
import app.module.front.usecase.daily.expense.adapters.web.model.DailyExpenseUIReqVO;
|
||||||
import app.module.front.usecase.daily.expense.persistence.model.RemoveDailyExpenseCmd;
|
import app.module.front.usecase.daily.expense.adapters.web.model.RemoveDailyExpenseReqVO;
|
||||||
import app.module.front.usecase.daily.expense.web.model.CreateDailyExpenseReqVO;
|
import app.module.front.usecase.daily.expense.ports.DailyExpensePortIn;
|
||||||
import app.module.front.usecase.daily.expense.web.model.DailyExpenseUIReqVO;
|
import app.module.front.usecase.daily.expense.ports.DailyExpensePortOut;
|
||||||
import app.module.front.usecase.daily.expense.web.model.RemoveDailyExpenseReqVO;
|
import app.module.front.usecase.daily.expense.ports.application.domain.CreateDailyExpenseCmd;
|
||||||
|
import app.module.front.usecase.daily.expense.ports.application.domain.GetDailyExpenseCmd;
|
||||||
|
import app.module.front.usecase.daily.expense.ports.application.domain.RemoveDailyExpenseCmd;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class DailyExpenseServiceImpl implements DailyExpenseService {
|
public class DailyExpenseService implements DailyExpensePortIn {
|
||||||
|
private final DailyExpensePortOut portOut;
|
||||||
private final UICodeListPortIn uiCodeListPortIn;
|
private final UICodeListPortIn uiCodeListPortIn;
|
||||||
private final DailyExpenseMapper DailyExpenseMapper;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DailyExpenseDto> getDailyExpenseList(DailyExpenseUIReqVO reqVO) {
|
public List<DailyExpenseDto> list(DailyExpenseUIReqVO reqVO) {
|
||||||
return this.getRefineIncomeList(reqVO);
|
return this.getRefineList(reqVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DailyExpenseDto getDailyExpense(DailyExpenseUIReqVO reqVO) {
|
public DailyExpenseDto detail(DailyExpenseUIReqVO reqVO) {
|
||||||
List<DailyExpenseDto> list = this.getRefineIncomeList(reqVO);
|
List<DailyExpenseDto> list = this.getRefineList(reqVO);
|
||||||
if (list.isEmpty()) {
|
if (list.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -38,8 +38,17 @@ public class DailyExpenseServiceImpl implements DailyExpenseService {
|
|||||||
return list.get(0);
|
return list.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<DailyExpenseDto> getRefineIncomeList(DailyExpenseUIReqVO reqVO) {
|
/**
|
||||||
List<DailyExpenseDto> list = DailyExpenseMapper.getDailyExpenseList(reqVO);
|
* 목록 데이터 조회
|
||||||
|
*
|
||||||
|
* @param reqVO 검색 조건
|
||||||
|
* @return 공통 처리된 목록
|
||||||
|
*/
|
||||||
|
private List<DailyExpenseDto> getRefineList(DailyExpenseUIReqVO reqVO) {
|
||||||
|
List<DailyExpenseDto> list = portOut.list(new GetDailyExpenseCmd(reqVO.getSearchMonth(),
|
||||||
|
reqVO.getGroupNo(),
|
||||||
|
reqVO.getHouseholdSeq(),
|
||||||
|
reqVO.getId()));
|
||||||
|
|
||||||
List<UICodeElement> recordUnit = uiCodeListPortIn.connect("code.record.unit");
|
List<UICodeElement> recordUnit = uiCodeListPortIn.connect("code.record.unit");
|
||||||
|
|
||||||
@@ -70,6 +79,12 @@ public class DailyExpenseServiceImpl implements DailyExpenseService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void create(CreateDailyExpenseReqVO formVO) {
|
public void create(CreateDailyExpenseReqVO formVO) {
|
||||||
|
GetDailyExpenseCmd findCmd = new GetDailyExpenseCmd(
|
||||||
|
formVO.getSearchMonth(),
|
||||||
|
formVO.getGroupNo(),
|
||||||
|
formVO.getHouseholdSeq(),
|
||||||
|
formVO.getId());
|
||||||
|
|
||||||
CreateDailyExpenseCmd command = AuditUtil.create(
|
CreateDailyExpenseCmd command = AuditUtil.create(
|
||||||
new CreateDailyExpenseCmd(
|
new CreateDailyExpenseCmd(
|
||||||
formVO.getId(),
|
formVO.getId(),
|
||||||
@@ -84,24 +99,19 @@ public class DailyExpenseServiceImpl implements DailyExpenseService {
|
|||||||
formVO.getPrice(),
|
formVO.getPrice(),
|
||||||
formVO.getEstimatedValue()));
|
formVO.getEstimatedValue()));
|
||||||
|
|
||||||
DailyExpenseUIReqVO existReqVO = new DailyExpenseUIReqVO(formVO.getSearchMonth(), formVO.getGroupNo());
|
portOut.create(findCmd, command);
|
||||||
existReqVO.setId(formVO.getId());
|
|
||||||
|
|
||||||
Integer existCount = DailyExpenseMapper.getRecordExistCount(existReqVO);
|
|
||||||
if (existCount == 0) {
|
|
||||||
DailyExpenseMapper.createDailyExpense(command);
|
|
||||||
|
|
||||||
log.debug("[CreateDailyExpense] record={}", command);
|
|
||||||
} else {
|
|
||||||
DailyExpenseMapper.updateDailyExpense(command);
|
|
||||||
|
|
||||||
log.debug("[UpdateDailyExpense] record={}", command);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove(RemoveDailyExpenseReqVO formVO) {
|
public void remove(RemoveDailyExpenseReqVO formVO) {
|
||||||
Long id = formVO.getId() != null ? Long.parseLong(formVO.getId()) : null;
|
Long id = formVO.getId() != null ? Long.parseLong(formVO.getId()) : null;
|
||||||
|
|
||||||
|
GetDailyExpenseCmd findCmd = new GetDailyExpenseCmd(
|
||||||
|
formVO.getSearchMonth(),
|
||||||
|
formVO.getGroupNo(),
|
||||||
|
formVO.getHouseholdSeq(),
|
||||||
|
id);
|
||||||
|
|
||||||
RemoveDailyExpenseCmd command = AuditUtil.delete(
|
RemoveDailyExpenseCmd command = AuditUtil.delete(
|
||||||
new RemoveDailyExpenseCmd(
|
new RemoveDailyExpenseCmd(
|
||||||
formVO.getSearchMonth(),
|
formVO.getSearchMonth(),
|
||||||
@@ -109,14 +119,6 @@ public class DailyExpenseServiceImpl implements DailyExpenseService {
|
|||||||
id,
|
id,
|
||||||
formVO.getDailyRecordSeq()));
|
formVO.getDailyRecordSeq()));
|
||||||
|
|
||||||
DailyExpenseUIReqVO existReqVO = new DailyExpenseUIReqVO(formVO.getSearchMonth(), formVO.getGroupNo());
|
portOut.remove(findCmd, command);
|
||||||
existReqVO.setId(id);
|
|
||||||
|
|
||||||
Integer existCount = DailyExpenseMapper.getRecordExistCount(existReqVO);
|
|
||||||
if (existCount != 0) {
|
|
||||||
DailyExpenseMapper.removeDailyExpense(command);
|
|
||||||
|
|
||||||
log.debug("[RemoveDailyExpense] record={}", command);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package app.module.front.usecase.daily.expense.ports.application.domain;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class GetDailyExpenseCmd {
|
||||||
|
/**
|
||||||
|
* 검색 월(yyyyMM)
|
||||||
|
*/
|
||||||
|
private String searchMonth;
|
||||||
|
/**
|
||||||
|
* 검색 그룸번호
|
||||||
|
*/
|
||||||
|
private Integer groupNo;
|
||||||
|
/**
|
||||||
|
* 임가 일련번호
|
||||||
|
*/
|
||||||
|
private Long householdSeq;
|
||||||
|
/**
|
||||||
|
* 수입 일련번호
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
}
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
package app.module.front.usecase.daily.expense.service;
|
|
||||||
|
|
||||||
import app.module.front.usecase.daily.expense.persistence.model.DailyExpenseDto;
|
|
||||||
import app.module.front.usecase.daily.expense.web.model.CreateDailyExpenseReqVO;
|
|
||||||
import app.module.front.usecase.daily.expense.web.model.DailyExpenseUIReqVO;
|
|
||||||
import app.module.front.usecase.daily.expense.web.model.RemoveDailyExpenseReqVO;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface DailyExpenseService {
|
|
||||||
/**
|
|
||||||
* 일계부 수입 목록 조회
|
|
||||||
*
|
|
||||||
* @param reqVO 검색 조건
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<DailyExpenseDto> getDailyExpenseList(DailyExpenseUIReqVO reqVO);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 일계부 수입 조회
|
|
||||||
*
|
|
||||||
* @param reqVO 검색 조건
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
DailyExpenseDto getDailyExpense(DailyExpenseUIReqVO reqVO);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 일계부 수입 등록
|
|
||||||
*
|
|
||||||
* @param formVO 입력 데이터
|
|
||||||
*/
|
|
||||||
void create(CreateDailyExpenseReqVO formVO);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 일계부 수입 삭제
|
|
||||||
*
|
|
||||||
* @param formVO 삭제 검색 조건
|
|
||||||
*/
|
|
||||||
void remove(RemoveDailyExpenseReqVO formVO);
|
|
||||||
}
|
|
||||||
@@ -1,135 +0,0 @@
|
|||||||
package app.module.front.usecase.daily.expense.web;
|
|
||||||
|
|
||||||
import app.module.core.config.application.exception.NoRecordDataException;
|
|
||||||
import app.module.core.config.application.util.CoreUtil;
|
|
||||||
import app.module.front.usecase.daily.expense.service.DailyExpenseService;
|
|
||||||
import app.module.front.usecase.daily.expense.web.model.CreateDailyExpenseReqVO;
|
|
||||||
import app.module.front.usecase.daily.expense.web.model.RemoveDailyExpenseReqVO;
|
|
||||||
import app.module.front.usecase.daily.expense.web.validator.CreateDailyExpenseValidator;
|
|
||||||
import app.module.front.usecase.daily.record.persistence.model.DailyRecordDto;
|
|
||||||
import app.module.front.usecase.daily.record.service.DailyRecordService;
|
|
||||||
import app.module.front.usecase.daily.record.web.model.DailyRecordUIReqVO;
|
|
||||||
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 DailyRecordService dailyRecordService;
|
|
||||||
private final DailyExpenseService DailyExpenseService;
|
|
||||||
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);
|
|
||||||
|
|
||||||
DailyExpenseService.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);
|
|
||||||
|
|
||||||
DailyExpenseService.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);
|
|
||||||
|
|
||||||
DailyExpenseService.remove(formVO);
|
|
||||||
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(formVO);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 일계부 유효성 체크 및 데이터 조회
|
|
||||||
*
|
|
||||||
* @param searchMonth 검색 월(yyyyMM)
|
|
||||||
* @param groupNo 검색 그룹
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private DailyRecordDto vaildGetDailyRecord(String searchMonth, String groupNo) {
|
|
||||||
DailyRecordUIReqVO reqVO = new DailyRecordUIReqVO(searchMonth, groupNo);
|
|
||||||
log.debug("getRecordUIReq: {}", reqVO);
|
|
||||||
|
|
||||||
DailyRecordDto dailyRecord = dailyRecordService.getDailyRecord(reqVO);
|
|
||||||
if (dailyRecord == null || dailyRecord.getId() == null) {
|
|
||||||
throw new NoRecordDataException();
|
|
||||||
}
|
|
||||||
|
|
||||||
return dailyRecord;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,112 +0,0 @@
|
|||||||
package app.module.front.usecase.daily.expense.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.persistence.model.DailyExpenseDto;
|
|
||||||
import app.module.front.usecase.daily.expense.service.DailyExpenseService;
|
|
||||||
import app.module.front.usecase.daily.expense.web.model.DailyExpenseUIReqVO;
|
|
||||||
import app.module.front.usecase.daily.record.persistence.model.DailyRecordDto;
|
|
||||||
import app.module.front.usecase.daily.record.service.DailyRecordService;
|
|
||||||
import app.module.front.usecase.daily.record.web.model.DailyRecordUIReqVO;
|
|
||||||
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 DailyRecordService dailyRecordService;
|
|
||||||
private final DailyExpenseService DailyExpenseService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 일계부 지출 목록 화면
|
|
||||||
*
|
|
||||||
* @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 = DailyExpenseService.getDailyExpenseList(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 = DailyExpenseService.getDailyExpense(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) {
|
|
||||||
DailyRecordUIReqVO reqVO = new DailyRecordUIReqVO(searchMonth, groupNo);
|
|
||||||
log.debug("getRecordUIReq: {}", reqVO);
|
|
||||||
|
|
||||||
DailyRecordDto dailyRecord = dailyRecordService.getDailyRecord(reqVO);
|
|
||||||
if (dailyRecord == null || dailyRecord.getId() == null) {
|
|
||||||
throw new NoRecordDataException();
|
|
||||||
}
|
|
||||||
|
|
||||||
return dailyRecord;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
package app.module.front.usecase.daily.expense.web.model;
|
|
||||||
|
|
||||||
import app.module.front.usecase.daily.record.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 Integer price;
|
|
||||||
/**
|
|
||||||
* 현물평가액
|
|
||||||
*/
|
|
||||||
private Integer estimatedValue;
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
package app.module.front.usecase.daily.expense.web.model;
|
|
||||||
|
|
||||||
import app.module.front.usecase.daily.record.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;
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
package app.module.front.usecase.daily.expense.web.model;
|
|
||||||
|
|
||||||
import app.module.front.usecase.daily.record.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;
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
package app.module.front.usecase.daily.expense.web.validator;
|
|
||||||
|
|
||||||
import app.module.front.usecase.daily.expense.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",
|
|
||||||
"현금 또는 현물평가액을 입력 해주세요.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package app.module.front.usecase.daily.income.adapters.persistence;
|
||||||
|
|
||||||
|
import app.module.front.usecase.daily.income.adapters.persistence.model.DailyIncomeDto;
|
||||||
|
import app.module.front.usecase.daily.income.ports.DailyIncomePortOut;
|
||||||
|
import app.module.front.usecase.daily.income.ports.application.domain.CreateDailyIncomeCmd;
|
||||||
|
import app.module.front.usecase.daily.income.ports.application.domain.GetDailyIncomeCmd;
|
||||||
|
import app.module.front.usecase.daily.income.ports.application.domain.RemoveDailyIncomeCmd;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class DailyIncomeDao implements DailyIncomePortOut {
|
||||||
|
private final DailyIncomeMapper dailyIncomeMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DailyIncomeDto> list(GetDailyIncomeCmd command) {
|
||||||
|
return dailyIncomeMapper.getDailyIncomeList(command);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void create(GetDailyIncomeCmd findCmd, CreateDailyIncomeCmd command) {
|
||||||
|
Integer existCount = dailyIncomeMapper.getRecordExistCount(findCmd);
|
||||||
|
if (existCount == 0) {
|
||||||
|
dailyIncomeMapper.createDailyIncome(command);
|
||||||
|
|
||||||
|
log.debug("[CreateDailyIncome] record={}", command);
|
||||||
|
} else {
|
||||||
|
dailyIncomeMapper.updateDailyIncome(command);
|
||||||
|
|
||||||
|
log.debug("[UpdateDailyIncome] record={}", command);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void remove(GetDailyIncomeCmd findCmd, RemoveDailyIncomeCmd command) {
|
||||||
|
Integer existCount = dailyIncomeMapper.getRecordExistCount(findCmd);
|
||||||
|
if (existCount != 0) {
|
||||||
|
dailyIncomeMapper.removeDailyIncome(command);
|
||||||
|
|
||||||
|
log.debug("[RemoveDailyIncome] record={}", command);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
package app.module.front.usecase.daily.income.persistence;
|
|
||||||
|
|
||||||
import app.module.front.usecase.daily.income.persistence.model.CreateDailyIncomeCmd;
|
|
||||||
import app.module.front.usecase.daily.income.persistence.model.DailyIncomeDto;
|
|
||||||
import app.module.front.usecase.daily.income.persistence.model.RemoveDailyIncomeCmd;
|
|
||||||
import app.module.front.usecase.daily.income.web.model.DailyIncomeUIReqVO;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Mapper
|
|
||||||
public interface DailyIncomeMapper {
|
|
||||||
/**
|
|
||||||
* 일계부 수입 목록 조회
|
|
||||||
*
|
|
||||||
* @param reqVO 검색 조건
|
|
||||||
* @return 수입 목록
|
|
||||||
*/
|
|
||||||
List<DailyIncomeDto> getDailyIncomeList(DailyIncomeUIReqVO reqVO);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 일계부 수입 데이터 존재 여부
|
|
||||||
*
|
|
||||||
* @param reqVO 검색 조건
|
|
||||||
* @return 중복 개수
|
|
||||||
*/
|
|
||||||
Integer getRecordExistCount(DailyIncomeUIReqVO reqVO);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 일계부 수입 등록
|
|
||||||
*
|
|
||||||
* @param command 등록 데이터
|
|
||||||
*/
|
|
||||||
void createDailyIncome(CreateDailyIncomeCmd command);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 일계부 수입 수정
|
|
||||||
*
|
|
||||||
* @param command 수정 데이터
|
|
||||||
*/
|
|
||||||
void updateDailyIncome(CreateDailyIncomeCmd command);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 일계부 수입 삭제
|
|
||||||
*
|
|
||||||
* @param command 삭제 데이터
|
|
||||||
*/
|
|
||||||
void removeDailyIncome(RemoveDailyIncomeCmd command);
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
package app.module.front.usecase.daily.income.persistence.model;
|
|
||||||
|
|
||||||
import app.module.front.config.adapters.persistence.component.FrontAuditCommand;
|
|
||||||
import app.module.front.usecase.daily.income.web.model.CreateDailyIncomeReqVO;
|
|
||||||
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 Integer price;
|
|
||||||
private Integer estimatedValue;
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
package app.module.front.usecase.daily.income.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 Integer price;
|
|
||||||
private Integer estimatedValue;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 수정 가능 여부
|
|
||||||
* @return true=가능, false=불가능(등록 상태)
|
|
||||||
*/
|
|
||||||
public boolean isUpdated() {
|
|
||||||
return this.id != null && this.id != 0L;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package app.module.front.usecase.daily.income.persistence.model;
|
|
||||||
|
|
||||||
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,40 @@
|
|||||||
|
package app.module.front.usecase.daily.income.ports;
|
||||||
|
|
||||||
|
import app.module.front.usecase.daily.income.adapters.persistence.model.DailyIncomeDto;
|
||||||
|
import app.module.front.usecase.daily.income.adapters.web.model.CreateDailyIncomeReqVO;
|
||||||
|
import app.module.front.usecase.daily.income.adapters.web.model.DailyIncomeUIReqVO;
|
||||||
|
import app.module.front.usecase.daily.income.adapters.web.model.RemoveDailyIncomeReqVO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface DailyIncomePortIn {
|
||||||
|
/**
|
||||||
|
* 일계부 수입 조회
|
||||||
|
*
|
||||||
|
* @param reqVO 검색 조건
|
||||||
|
* @return 수입 목록
|
||||||
|
*/
|
||||||
|
List<DailyIncomeDto> list(DailyIncomeUIReqVO reqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 수입 조회
|
||||||
|
*
|
||||||
|
* @param reqVO 검색 조건
|
||||||
|
* @return 수입 상세
|
||||||
|
*/
|
||||||
|
DailyIncomeDto detail(DailyIncomeUIReqVO reqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 수입 등록
|
||||||
|
*
|
||||||
|
* @param formVO 입력 데이터
|
||||||
|
*/
|
||||||
|
void create(CreateDailyIncomeReqVO formVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 수입 삭제
|
||||||
|
*
|
||||||
|
* @param formVO 삭제 검색 조건
|
||||||
|
*/
|
||||||
|
void remove(RemoveDailyIncomeReqVO formVO);
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package app.module.front.usecase.daily.income.ports;
|
||||||
|
|
||||||
|
import app.module.front.usecase.daily.income.adapters.persistence.model.DailyIncomeDto;
|
||||||
|
import app.module.front.usecase.daily.income.ports.application.domain.CreateDailyIncomeCmd;
|
||||||
|
import app.module.front.usecase.daily.income.ports.application.domain.GetDailyIncomeCmd;
|
||||||
|
import app.module.front.usecase.daily.income.ports.application.domain.RemoveDailyIncomeCmd;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface DailyIncomePortOut {
|
||||||
|
/**
|
||||||
|
* 일계부 수입 조회
|
||||||
|
*
|
||||||
|
* @param command 검색 조건
|
||||||
|
* @return 수입 목록
|
||||||
|
*/
|
||||||
|
List<DailyIncomeDto> list(GetDailyIncomeCmd command);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 수입 등록
|
||||||
|
*
|
||||||
|
* @param findCmd 검색 조건
|
||||||
|
* @param command 입력 데이터
|
||||||
|
*/
|
||||||
|
void create(GetDailyIncomeCmd findCmd, CreateDailyIncomeCmd command);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 수입 삭제
|
||||||
|
*
|
||||||
|
* @param findCmd 검색 조건
|
||||||
|
* @param command 삭제 검색 조건
|
||||||
|
*/
|
||||||
|
void remove(GetDailyIncomeCmd findCmd, RemoveDailyIncomeCmd command);
|
||||||
|
}
|
||||||
@@ -1,36 +1,36 @@
|
|||||||
package app.module.front.usecase.daily.income.service;
|
package app.module.front.usecase.daily.income.ports.application;
|
||||||
|
|
||||||
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
|
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
|
||||||
import app.module.core.usecase.uicode.list.ports.application.domain.UICodeElement;
|
import app.module.core.usecase.uicode.list.ports.application.domain.UICodeElement;
|
||||||
import app.module.front.config.application.util.AuditUtil;
|
import app.module.front.config.application.util.AuditUtil;
|
||||||
import app.module.front.usecase.daily.income.persistence.DailyIncomeMapper;
|
import app.module.front.usecase.daily.income.adapters.persistence.model.DailyIncomeDto;
|
||||||
import app.module.front.usecase.daily.income.persistence.model.CreateDailyIncomeCmd;
|
import app.module.front.usecase.daily.income.adapters.web.model.CreateDailyIncomeReqVO;
|
||||||
import app.module.front.usecase.daily.income.persistence.model.DailyIncomeDto;
|
import app.module.front.usecase.daily.income.adapters.web.model.DailyIncomeUIReqVO;
|
||||||
import app.module.front.usecase.daily.income.persistence.model.RemoveDailyIncomeCmd;
|
import app.module.front.usecase.daily.income.adapters.web.model.RemoveDailyIncomeReqVO;
|
||||||
import app.module.front.usecase.daily.income.web.model.CreateDailyIncomeReqVO;
|
import app.module.front.usecase.daily.income.ports.DailyIncomePortIn;
|
||||||
import app.module.front.usecase.daily.income.web.model.DailyIncomeUIReqVO;
|
import app.module.front.usecase.daily.income.ports.DailyIncomePortOut;
|
||||||
import app.module.front.usecase.daily.income.web.model.RemoveDailyIncomeReqVO;
|
import app.module.front.usecase.daily.income.ports.application.domain.CreateDailyIncomeCmd;
|
||||||
|
import app.module.front.usecase.daily.income.ports.application.domain.GetDailyIncomeCmd;
|
||||||
|
import app.module.front.usecase.daily.income.ports.application.domain.RemoveDailyIncomeCmd;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class DailyIncomeServiceImpl implements DailyIncomeService {
|
public class DailyIncomeService implements DailyIncomePortIn {
|
||||||
|
private final DailyIncomePortOut portOut;
|
||||||
private final UICodeListPortIn uiCodeListPortIn;
|
private final UICodeListPortIn uiCodeListPortIn;
|
||||||
private final DailyIncomeMapper dailyIncomeMapper;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DailyIncomeDto> getDailyIncomeList(DailyIncomeUIReqVO reqVO) {
|
public List<DailyIncomeDto> list(DailyIncomeUIReqVO reqVO) {
|
||||||
return this.getRefineIncomeList(reqVO);
|
return this.getRefineList(reqVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DailyIncomeDto getDailyIncome(DailyIncomeUIReqVO reqVO) {
|
public DailyIncomeDto detail(DailyIncomeUIReqVO reqVO) {
|
||||||
List<DailyIncomeDto> list = this.getRefineIncomeList(reqVO);
|
List<DailyIncomeDto> list = this.getRefineList(reqVO);
|
||||||
if (list.isEmpty()) {
|
if (list.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -38,8 +38,17 @@ public class DailyIncomeServiceImpl implements DailyIncomeService {
|
|||||||
return list.get(0);
|
return list.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<DailyIncomeDto> getRefineIncomeList(DailyIncomeUIReqVO reqVO) {
|
/**
|
||||||
List<DailyIncomeDto> list = dailyIncomeMapper.getDailyIncomeList(reqVO);
|
* 목록 데이터 조회
|
||||||
|
*
|
||||||
|
* @param reqVO 검색 조건
|
||||||
|
* @return 공통 처리된 목록
|
||||||
|
*/
|
||||||
|
private List<DailyIncomeDto> getRefineList(DailyIncomeUIReqVO reqVO) {
|
||||||
|
List<DailyIncomeDto> list = portOut.list(new GetDailyIncomeCmd(reqVO.getSearchMonth(),
|
||||||
|
reqVO.getGroupNo(),
|
||||||
|
reqVO.getHouseholdSeq(),
|
||||||
|
reqVO.getId()));
|
||||||
|
|
||||||
List<UICodeElement> recordCrop = uiCodeListPortIn.connect("code.record.crop");
|
List<UICodeElement> recordCrop = uiCodeListPortIn.connect("code.record.crop");
|
||||||
List<UICodeElement> recordUnit = uiCodeListPortIn.connect("code.record.unit");
|
List<UICodeElement> recordUnit = uiCodeListPortIn.connect("code.record.unit");
|
||||||
@@ -72,6 +81,12 @@ public class DailyIncomeServiceImpl implements DailyIncomeService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void create(CreateDailyIncomeReqVO formVO) {
|
public void create(CreateDailyIncomeReqVO formVO) {
|
||||||
|
GetDailyIncomeCmd findCmd = new GetDailyIncomeCmd(
|
||||||
|
formVO.getSearchMonth(),
|
||||||
|
formVO.getGroupNo(),
|
||||||
|
formVO.getHouseholdSeq(),
|
||||||
|
formVO.getId());
|
||||||
|
|
||||||
CreateDailyIncomeCmd command = AuditUtil.create(
|
CreateDailyIncomeCmd command = AuditUtil.create(
|
||||||
new CreateDailyIncomeCmd(
|
new CreateDailyIncomeCmd(
|
||||||
formVO.getId(),
|
formVO.getId(),
|
||||||
@@ -87,24 +102,19 @@ public class DailyIncomeServiceImpl implements DailyIncomeService {
|
|||||||
formVO.getPrice(),
|
formVO.getPrice(),
|
||||||
formVO.getEstimatedValue()));
|
formVO.getEstimatedValue()));
|
||||||
|
|
||||||
DailyIncomeUIReqVO existReqVO = new DailyIncomeUIReqVO(formVO.getSearchMonth(), formVO.getGroupNo());
|
portOut.create(findCmd, command);
|
||||||
existReqVO.setId(formVO.getId());
|
|
||||||
|
|
||||||
Integer existCount = dailyIncomeMapper.getRecordExistCount(existReqVO);
|
|
||||||
if (existCount == 0) {
|
|
||||||
dailyIncomeMapper.createDailyIncome(command);
|
|
||||||
|
|
||||||
log.debug("[CreateDailyIncome] record={}", command);
|
|
||||||
} else {
|
|
||||||
dailyIncomeMapper.updateDailyIncome(command);
|
|
||||||
|
|
||||||
log.debug("[UpdateDailyIncome] record={}", command);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove(RemoveDailyIncomeReqVO formVO) {
|
public void remove(RemoveDailyIncomeReqVO formVO) {
|
||||||
Long id = formVO.getId() != null ? Long.parseLong(formVO.getId()) : null;
|
Long id = formVO.getId() != null ? Long.parseLong(formVO.getId()) : null;
|
||||||
|
|
||||||
|
GetDailyIncomeCmd findCmd = new GetDailyIncomeCmd(
|
||||||
|
formVO.getSearchMonth(),
|
||||||
|
formVO.getGroupNo(),
|
||||||
|
formVO.getHouseholdSeq(),
|
||||||
|
id);
|
||||||
|
|
||||||
RemoveDailyIncomeCmd command = AuditUtil.delete(
|
RemoveDailyIncomeCmd command = AuditUtil.delete(
|
||||||
new RemoveDailyIncomeCmd(
|
new RemoveDailyIncomeCmd(
|
||||||
formVO.getSearchMonth(),
|
formVO.getSearchMonth(),
|
||||||
@@ -112,14 +122,6 @@ public class DailyIncomeServiceImpl implements DailyIncomeService {
|
|||||||
id,
|
id,
|
||||||
formVO.getDailyRecordSeq()));
|
formVO.getDailyRecordSeq()));
|
||||||
|
|
||||||
DailyIncomeUIReqVO existReqVO = new DailyIncomeUIReqVO(formVO.getSearchMonth(), formVO.getGroupNo());
|
portOut.remove(findCmd, command);
|
||||||
existReqVO.setId(id);
|
|
||||||
|
|
||||||
Integer existCount = dailyIncomeMapper.getRecordExistCount(existReqVO);
|
|
||||||
if (existCount != 0) {
|
|
||||||
dailyIncomeMapper.removeDailyIncome(command);
|
|
||||||
|
|
||||||
log.debug("[RemoveDailyIncome] record={}", command);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package app.module.front.usecase.daily.income.ports.application.domain;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class GetDailyIncomeCmd {
|
||||||
|
/**
|
||||||
|
* 검색 월(yyyyMM)
|
||||||
|
*/
|
||||||
|
private String searchMonth;
|
||||||
|
/**
|
||||||
|
* 검색 그룸번호
|
||||||
|
*/
|
||||||
|
private Integer groupNo;
|
||||||
|
/**
|
||||||
|
* 임가 일련번호
|
||||||
|
*/
|
||||||
|
private Long householdSeq;
|
||||||
|
/**
|
||||||
|
* 수입 일련번호
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
}
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
package app.module.front.usecase.daily.income.service;
|
|
||||||
|
|
||||||
import app.module.front.usecase.daily.income.persistence.model.DailyIncomeDto;
|
|
||||||
import app.module.front.usecase.daily.income.web.model.CreateDailyIncomeReqVO;
|
|
||||||
import app.module.front.usecase.daily.income.web.model.DailyIncomeUIReqVO;
|
|
||||||
import app.module.front.usecase.daily.income.web.model.RemoveDailyIncomeReqVO;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface DailyIncomeService {
|
|
||||||
/**
|
|
||||||
* 일계부 수입 목록 조회
|
|
||||||
*
|
|
||||||
* @param reqVO 검색 조건
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<DailyIncomeDto> getDailyIncomeList(DailyIncomeUIReqVO reqVO);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 일계부 수입 조회
|
|
||||||
*
|
|
||||||
* @param reqVO 검색 조건
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
DailyIncomeDto getDailyIncome(DailyIncomeUIReqVO reqVO);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 일계부 수입 등록
|
|
||||||
*
|
|
||||||
* @param formVO 입력 데이터
|
|
||||||
*/
|
|
||||||
void create(CreateDailyIncomeReqVO formVO);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 일계부 수입 삭제
|
|
||||||
*
|
|
||||||
* @param formVO 삭제 검색 조건
|
|
||||||
*/
|
|
||||||
void remove(RemoveDailyIncomeReqVO formVO);
|
|
||||||
}
|
|
||||||
@@ -1,136 +0,0 @@
|
|||||||
package app.module.front.usecase.daily.income.web;
|
|
||||||
|
|
||||||
import app.module.core.config.application.exception.NoRecordDataException;
|
|
||||||
import app.module.core.config.application.util.CoreUtil;
|
|
||||||
import app.module.front.usecase.daily.income.service.DailyIncomeService;
|
|
||||||
import app.module.front.usecase.daily.income.web.model.CreateDailyIncomeReqVO;
|
|
||||||
import app.module.front.usecase.daily.income.web.model.RemoveDailyIncomeReqVO;
|
|
||||||
import app.module.front.usecase.daily.income.web.validator.CreateDailyIncomeValidator;
|
|
||||||
import app.module.front.usecase.daily.record.persistence.model.DailyRecordDto;
|
|
||||||
import app.module.front.usecase.daily.record.service.DailyRecordService;
|
|
||||||
import app.module.front.usecase.daily.record.web.model.DailyRecordUIReqVO;
|
|
||||||
import app.module.front.usecase.daily.record.web.model.DailyTargetStatus;
|
|
||||||
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 DailyRecordService dailyRecordService;
|
|
||||||
private final DailyIncomeService dailyIncomeService;
|
|
||||||
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);
|
|
||||||
|
|
||||||
dailyIncomeService.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);
|
|
||||||
|
|
||||||
dailyIncomeService.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);
|
|
||||||
|
|
||||||
dailyIncomeService.remove(formVO);
|
|
||||||
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(formVO);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 일계부 유효성 체크 및 데이터 조회
|
|
||||||
*
|
|
||||||
* @param searchMonth 검색 월(yyyyMM)
|
|
||||||
* @param groupNo 검색 그룹
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private DailyRecordDto vaildGetDailyRecord(String searchMonth, String groupNo) {
|
|
||||||
DailyRecordUIReqVO reqVO = new DailyRecordUIReqVO(searchMonth, groupNo);
|
|
||||||
log.debug("getRecordUIReq: {}", reqVO);
|
|
||||||
|
|
||||||
DailyRecordDto dailyRecord = dailyRecordService.getDailyRecord(reqVO);
|
|
||||||
if (dailyRecord == null || dailyRecord.getId() == null) {
|
|
||||||
throw new NoRecordDataException();
|
|
||||||
}
|
|
||||||
|
|
||||||
return dailyRecord;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,110 +0,0 @@
|
|||||||
package app.module.front.usecase.daily.income.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.persistence.model.DailyIncomeDto;
|
|
||||||
import app.module.front.usecase.daily.income.service.DailyIncomeService;
|
|
||||||
import app.module.front.usecase.daily.income.web.model.DailyIncomeUIReqVO;
|
|
||||||
import app.module.front.usecase.daily.record.persistence.model.DailyRecordDto;
|
|
||||||
import app.module.front.usecase.daily.record.service.DailyRecordService;
|
|
||||||
import app.module.front.usecase.daily.record.web.model.DailyRecordUIReqVO;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.ui.Model;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
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 DailyRecordService dailyRecordService;
|
|
||||||
private final DailyIncomeService dailyIncomeService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 일계부 수입 목록 화면
|
|
||||||
*
|
|
||||||
* @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 = dailyIncomeService.getDailyIncomeList(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 = dailyIncomeService.getDailyIncome(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) {
|
|
||||||
DailyRecordUIReqVO reqVO = new DailyRecordUIReqVO(searchMonth, groupNo);
|
|
||||||
log.debug("getRecordUIReq: {}", reqVO);
|
|
||||||
|
|
||||||
DailyRecordDto dailyRecord = dailyRecordService.getDailyRecord(reqVO);
|
|
||||||
if (dailyRecord == null || dailyRecord.getId() == null) {
|
|
||||||
throw new NoRecordDataException();
|
|
||||||
}
|
|
||||||
|
|
||||||
return dailyRecord;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
package app.module.front.usecase.daily.income.web.model;
|
|
||||||
|
|
||||||
import app.module.front.usecase.daily.record.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 Integer price;
|
|
||||||
/**
|
|
||||||
* 현물평가액
|
|
||||||
*/
|
|
||||||
private Integer estimatedValue;
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
package app.module.front.usecase.daily.income.web.model;
|
|
||||||
|
|
||||||
import app.module.front.usecase.daily.record.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;
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
package app.module.front.usecase.daily.income.web.model;
|
|
||||||
|
|
||||||
import app.module.front.usecase.daily.record.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;
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
package app.module.front.usecase.daily.income.web.validator;
|
|
||||||
|
|
||||||
import app.module.core.config.application.util.MessageUtil;
|
|
||||||
import app.module.front.usecase.daily.income.web.model.CreateDailyIncomeReqVO;
|
|
||||||
import app.module.front.usecase.daily.record.web.model.CreateDailyRecordReqVO;
|
|
||||||
import app.module.front.usecase.daily.record.web.model.DailyStatus;
|
|
||||||
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",
|
|
||||||
"현금 또는 현물평가액을 입력 해주세요.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +1,15 @@
|
|||||||
package app.module.front.usecase.daily.record.service;
|
package app.module.front.usecase.daily.record.adapters.persistence;
|
||||||
|
|
||||||
import app.module.front.config.application.util.AuditUtil;
|
import app.module.front.config.application.util.AuditUtil;
|
||||||
import app.module.front.usecase.daily.record.persistence.DailyRecordMapper;
|
import app.module.front.usecase.daily.record.adapters.persistence.model.DailyRecordDto;
|
||||||
import app.module.front.usecase.daily.record.persistence.model.CreateDailyRecordCmd;
|
import app.module.front.usecase.daily.record.adapters.web.model.CreateDailyRecordReqVO;
|
||||||
import app.module.front.usecase.daily.record.persistence.model.DailyRecordDto;
|
import app.module.front.usecase.daily.record.ports.DailyRecordPortOut;
|
||||||
import app.module.front.usecase.daily.record.persistence.model.UpdateDailyRecordStatusCmd;
|
import app.module.front.usecase.daily.record.ports.application.domain.CreateDailyRecordCmd;
|
||||||
import app.module.front.usecase.daily.record.web.model.CreateDailyRecordReqVO;
|
import app.module.front.usecase.daily.record.ports.application.domain.GetDailyRecordCmd;
|
||||||
import app.module.front.usecase.daily.record.web.model.DailyRecordUIReqVO;
|
import app.module.front.usecase.daily.record.ports.application.domain.UpdateDailyRecordStatusCmd;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
@@ -17,23 +17,23 @@ import java.util.Date;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Repository
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class DailyRecordServiceImpl implements DailyRecordService {
|
public class DailyRecordDao implements DailyRecordPortOut {
|
||||||
private final DailyRecordMapper dailyRecordMapper;
|
private final DailyRecordMapper dailyRecordMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DailyRecordDto getDailyRecord(DailyRecordUIReqVO reqVO) {
|
public DailyRecordDto detail(GetDailyRecordCmd command) {
|
||||||
DailyRecordDto detail = dailyRecordMapper.getDailyRecord(reqVO);
|
DailyRecordDto detail = dailyRecordMapper.getDailyRecord(command);
|
||||||
if (detail != null && !detail.isUpdated()) {
|
if (detail != null && !detail.isUpdated()) {
|
||||||
try {
|
try {
|
||||||
SimpleDateFormat beforeSdf = new SimpleDateFormat("yyyyMMdd", Locale.KOREAN);
|
SimpleDateFormat beforeSdf = new SimpleDateFormat("yyyyMMdd", Locale.KOREAN);
|
||||||
SimpleDateFormat afterSdf = new SimpleDateFormat("yyyy-MM-dd", Locale.KOREAN);
|
SimpleDateFormat afterSdf = new SimpleDateFormat("yyyy-MM-dd", Locale.KOREAN);
|
||||||
|
|
||||||
Date formatDate = beforeSdf.parse(reqVO.getSearchMonth() + String.format("%02d", detail.getStartDay()));
|
Date formatDate = beforeSdf.parse(command.getSearchMonth() + String.format("%02d", detail.getStartDay()));
|
||||||
detail.setStartDate(LocalDate.parse(afterSdf.format(formatDate)));
|
detail.setStartDate(LocalDate.parse(afterSdf.format(formatDate)));
|
||||||
|
|
||||||
formatDate = beforeSdf.parse(reqVO.getSearchMonth() + String.format("%02d", detail.getEndDay()));
|
formatDate = beforeSdf.parse(command.getSearchMonth() + String.format("%02d", detail.getEndDay()));
|
||||||
detail.setEndDate(LocalDate.parse(afterSdf.format(formatDate)));
|
detail.setEndDate(LocalDate.parse(afterSdf.format(formatDate)));
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -44,23 +44,8 @@ public class DailyRecordServiceImpl implements DailyRecordService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createDailyRecord(CreateDailyRecordReqVO reqVO) {
|
public void create(GetDailyRecordCmd findCmd, CreateDailyRecordCmd command) {
|
||||||
CreateDailyRecordCmd command = AuditUtil.create(
|
Integer existCount = dailyRecordMapper.getDailyRecordExistCount(findCmd);
|
||||||
new CreateDailyRecordCmd(
|
|
||||||
null,
|
|
||||||
reqVO.getRecordMonth(),
|
|
||||||
reqVO.getDayGroupNo(),
|
|
||||||
reqVO.getStartDate(),
|
|
||||||
reqVO.getEndDate(),
|
|
||||||
reqVO.getAllStatus(),
|
|
||||||
reqVO.getIncomeStatus(),
|
|
||||||
reqVO.getWorkStatus(),
|
|
||||||
reqVO.getExpenseStatus(),
|
|
||||||
reqVO.getPowerStatus(),
|
|
||||||
reqVO.getForestryStatus(),
|
|
||||||
reqVO.getFarmingStatus()));
|
|
||||||
|
|
||||||
Integer existCount = dailyRecordMapper.getDailyRecordExistCount(new DailyRecordUIReqVO(reqVO.getRecordMonth(), reqVO.getDayGroupNo()));
|
|
||||||
if (existCount == 0) {
|
if (existCount == 0) {
|
||||||
dailyRecordMapper.createDailyRecord(command);
|
dailyRecordMapper.createDailyRecord(command);
|
||||||
|
|
||||||
@@ -69,12 +54,12 @@ public class DailyRecordServiceImpl implements DailyRecordService {
|
|||||||
// TODO : NONE 으로 변경시 연관 테이블 데이터 삭제할 것인가?
|
// TODO : NONE 으로 변경시 연관 테이블 데이터 삭제할 것인가?
|
||||||
dailyRecordMapper.updateDailyRecord(command);
|
dailyRecordMapper.updateDailyRecord(command);
|
||||||
|
|
||||||
log.warn("[DailyRecordCreate] existCount={}, recordMonth={}, dayGroupNo={}", existCount, reqVO.getRecordMonth(), reqVO.getDayGroupNo());
|
log.warn("[DailyRecordCreate] existCount={}, recordMonth={}, dayGroupNo={}", existCount, findCmd.getSearchMonth(), findCmd.getGroupNo());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateDailyRecordStatus(String recordMonth, Integer dayGroupNo, String targetType, String targetStatus) {
|
public void updateByStatus(String recordMonth, Integer dayGroupNo, String targetType, String targetStatus) {
|
||||||
UpdateDailyRecordStatusCmd command = AuditUtil.update(
|
UpdateDailyRecordStatusCmd command = AuditUtil.update(
|
||||||
new UpdateDailyRecordStatusCmd(
|
new UpdateDailyRecordStatusCmd(
|
||||||
recordMonth,
|
recordMonth,
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
package app.module.front.usecase.daily.record.persistence;
|
|
||||||
|
|
||||||
import app.module.front.usecase.daily.record.persistence.model.CreateDailyRecordCmd;
|
|
||||||
import app.module.front.usecase.daily.record.persistence.model.DailyRecordDto;
|
|
||||||
import app.module.front.usecase.daily.record.web.model.DailyRecordUIReqVO;
|
|
||||||
import app.module.front.usecase.daily.record.persistence.model.UpdateDailyRecordStatusCmd;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
@Mapper
|
|
||||||
public interface DailyRecordMapper {
|
|
||||||
|
|
||||||
DailyRecordDto getDailyRecord(DailyRecordUIReqVO reqVO);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 일계부 항목 등록 여부
|
|
||||||
*
|
|
||||||
* @param reqVO
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Integer getDailyRecordExistCount(DailyRecordUIReqVO reqVO);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 일계부 항목 등록(생성)
|
|
||||||
*
|
|
||||||
* @param command
|
|
||||||
*/
|
|
||||||
void createDailyRecord(CreateDailyRecordCmd command);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 일계부 항목 수정
|
|
||||||
*
|
|
||||||
* @param command
|
|
||||||
*/
|
|
||||||
void updateDailyRecord(CreateDailyRecordCmd command);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 일계부 항목의 상태 수정
|
|
||||||
*
|
|
||||||
* @param command
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
int updateDailyRecordStatus(UpdateDailyRecordStatusCmd command);
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
package app.module.front.usecase.daily.record.persistence.model;
|
|
||||||
|
|
||||||
import app.module.front.config.adapters.persistence.component.FrontAuditCommand;
|
|
||||||
import app.module.front.usecase.daily.record.web.model.DailyStatus;
|
|
||||||
import app.module.front.usecase.daily.record.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;
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
package app.module.front.usecase.daily.record.persistence.model;
|
|
||||||
|
|
||||||
import app.module.front.usecase.daily.record.web.model.DailyStatus;
|
|
||||||
import app.module.front.usecase.daily.record.web.model.DailyTargetStatus;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
package app.module.front.usecase.daily.record.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;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package app.module.front.usecase.daily.record.persistence.model;
|
|
||||||
|
|
||||||
import app.module.front.config.adapters.persistence.component.FrontAuditCommand;
|
|
||||||
import app.module.front.usecase.daily.record.web.model.DailyStatus;
|
|
||||||
import app.module.front.usecase.daily.record.web.model.DailyTargetStatus;
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package app.module.front.usecase.daily.record.ports;
|
||||||
|
|
||||||
|
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.DailyUIReqVO;
|
||||||
|
|
||||||
|
public interface DailyRecordPortIn {
|
||||||
|
/**
|
||||||
|
* 일계부 항목 조회
|
||||||
|
*
|
||||||
|
* @param reqVO 검색 조건
|
||||||
|
* @return 항목 상세
|
||||||
|
*/
|
||||||
|
DailyRecordDto detail(DailyUIReqVO reqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 항목 등록
|
||||||
|
*
|
||||||
|
* @param formVO 입력 데이터
|
||||||
|
*/
|
||||||
|
void create(CreateDailyRecordReqVO formVO);
|
||||||
|
|
||||||
|
void updateByStatus(String recordMonth, Integer dayGroupNo, String targetType, String targetStatus);
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package app.module.front.usecase.daily.record.ports;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
public interface DailyRecordPortOut {
|
||||||
|
/**
|
||||||
|
* 일계부 항목 조회
|
||||||
|
* @param command 검색 조건
|
||||||
|
* @return 항목 상세
|
||||||
|
*/
|
||||||
|
DailyRecordDto detail(GetDailyRecordCmd command);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 일계부 항목 등록
|
||||||
|
*
|
||||||
|
* @param findCmd 검색 조건
|
||||||
|
* @param command 입력 데이터
|
||||||
|
*/
|
||||||
|
void create(GetDailyRecordCmd findCmd, CreateDailyRecordCmd command);
|
||||||
|
|
||||||
|
void updateByStatus(String recordMonth, Integer dayGroupNo, String targetType, String targetStatus);
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
package app.module.front.usecase.daily.record.ports.application;
|
||||||
|
|
||||||
|
import app.module.front.config.application.util.AuditUtil;
|
||||||
|
import app.module.front.config.application.util.AuthUtil;
|
||||||
|
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.DailyUIReqVO;
|
||||||
|
import app.module.front.usecase.daily.record.ports.DailyRecordPortIn;
|
||||||
|
import app.module.front.usecase.daily.record.ports.DailyRecordPortOut;
|
||||||
|
import app.module.front.usecase.daily.record.ports.application.domain.CreateDailyRecordCmd;
|
||||||
|
import app.module.front.usecase.daily.record.ports.application.domain.GetDailyRecordCmd;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class DailyRecordService implements DailyRecordPortIn {
|
||||||
|
private final DailyRecordPortOut portOut;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DailyRecordDto detail(DailyUIReqVO reqVO) {
|
||||||
|
return portOut.detail(new GetDailyRecordCmd(reqVO.getSearchMonth(),
|
||||||
|
reqVO.getGroupNo(),
|
||||||
|
reqVO.getHouseholdSeq()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void create(CreateDailyRecordReqVO formVO) {
|
||||||
|
GetDailyRecordCmd findCmd = new GetDailyRecordCmd(
|
||||||
|
formVO.getRecordMonth(),
|
||||||
|
formVO.getDayGroupNo(),
|
||||||
|
AuthUtil.getUserSeq());
|
||||||
|
|
||||||
|
CreateDailyRecordCmd command = AuditUtil.create(
|
||||||
|
new CreateDailyRecordCmd(
|
||||||
|
null,
|
||||||
|
formVO.getRecordMonth(),
|
||||||
|
formVO.getDayGroupNo(),
|
||||||
|
formVO.getStartDate(),
|
||||||
|
formVO.getEndDate(),
|
||||||
|
formVO.getAllStatus(),
|
||||||
|
formVO.getIncomeStatus(),
|
||||||
|
formVO.getWorkStatus(),
|
||||||
|
formVO.getExpenseStatus(),
|
||||||
|
formVO.getPowerStatus(),
|
||||||
|
formVO.getForestryStatus(),
|
||||||
|
formVO.getFarmingStatus()));
|
||||||
|
|
||||||
|
portOut.create(findCmd, command);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateByStatus(String recordMonth, Integer dayGroupNo, String targetType, String targetStatus) {
|
||||||
|
portOut.updateByStatus(recordMonth, dayGroupNo, targetType, targetStatus);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
package app.module.front.usecase.daily.record.web.model;
|
package app.module.front.usecase.daily.record.ports.application.domain;
|
||||||
|
|
||||||
import app.module.front.config.application.util.AuthUtil;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Getter;
|
||||||
import lombok.ToString;
|
import lombok.Setter;
|
||||||
|
|
||||||
@Data
|
@Getter
|
||||||
@ToString
|
@Setter
|
||||||
public class DailyCmd {
|
@AllArgsConstructor
|
||||||
|
public class GetDailyRecordCmd {
|
||||||
/**
|
/**
|
||||||
* 검색 월(yyyyMM)
|
* 검색 월(yyyyMM)
|
||||||
*/
|
*/
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package app.module.front.usecase.daily.record.service;
|
|
||||||
|
|
||||||
import app.module.front.usecase.daily.record.persistence.model.DailyRecordDto;
|
|
||||||
import app.module.front.usecase.daily.record.web.model.CreateDailyRecordReqVO;
|
|
||||||
import app.module.front.usecase.daily.record.web.model.DailyRecordUIReqVO;
|
|
||||||
|
|
||||||
public interface DailyRecordService {
|
|
||||||
DailyRecordDto getDailyRecord(DailyRecordUIReqVO reqVO);
|
|
||||||
|
|
||||||
void createDailyRecord(CreateDailyRecordReqVO reqVO);
|
|
||||||
|
|
||||||
void updateDailyRecordStatus(String recordMonth, Integer dayGroupNo, String targetType, String targetStatus);
|
|
||||||
}
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
package app.module.front.usecase.daily.record.web;
|
|
||||||
|
|
||||||
import app.module.core.config.application.exception.NoMatchingURIException;
|
|
||||||
import app.module.front.usecase.daily.record.persistence.model.DailyRecordDto;
|
|
||||||
import app.module.front.usecase.daily.record.service.DailyRecordService;
|
|
||||||
import app.module.front.usecase.daily.record.web.model.CreateDailyRecordReqVO;
|
|
||||||
import app.module.front.usecase.daily.record.web.model.DailyRecordUIReqVO;
|
|
||||||
import app.module.front.usecase.daily.record.web.model.DailyTargetStatus;
|
|
||||||
import app.module.front.usecase.daily.record.web.validator.CreateDailyRecordValidator;
|
|
||||||
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.stereotype.Controller;
|
|
||||||
import org.springframework.ui.Model;
|
|
||||||
import org.springframework.validation.BindingResult;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
@RequestMapping(path = "/api/record/daily")
|
|
||||||
public class DailyRecordController {
|
|
||||||
private final DailyRecordService dailyRecordService;
|
|
||||||
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());
|
|
||||||
}
|
|
||||||
|
|
||||||
DailyRecordUIReqVO reqVO = new DailyRecordUIReqVO(searchMonth, groupNo);
|
|
||||||
log.debug("reqVO: {}", reqVO);
|
|
||||||
|
|
||||||
DailyRecordDto detail = dailyRecordService.getDailyRecord(reqVO);
|
|
||||||
formVO.setRecordMonth(reqVO.getSearchMonth());
|
|
||||||
formVO.setDayGroupNo(reqVO.getGroupNo());
|
|
||||||
formVO.setStartDate(detail.getStartDate());
|
|
||||||
formVO.setEndDate(detail.getEndDate());
|
|
||||||
log.debug("formVO: {}", formVO);
|
|
||||||
|
|
||||||
dailyRecordService.createDailyRecord(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) {
|
|
||||||
|
|
||||||
DailyRecordUIReqVO reqVO = new DailyRecordUIReqVO(searchMonth, groupNo);
|
|
||||||
log.debug("reqVO: {}", reqVO);
|
|
||||||
log.debug("target: {}", targetType);
|
|
||||||
log.debug("status: {}", targetStatus);
|
|
||||||
|
|
||||||
DailyRecordDto detail = dailyRecordService.getDailyRecord(reqVO);
|
|
||||||
|
|
||||||
// TODO : true / false 를 업데이트하는 것은 대상 타켓이 되는 것이라 판단하여 그냥 강제 업데이트할 것인가? valid 체크
|
|
||||||
dailyRecordService.updateDailyRecordStatus(detail.getRecordMonth(), detail.getGroupNo(), targetType, "Y".equals(targetStatus) ? DailyTargetStatus.TODAY_NONE.name() : DailyTargetStatus.TARGET.name());
|
|
||||||
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(reqVO);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
package app.module.front.usecase.daily.record.web;
|
|
||||||
|
|
||||||
import app.module.core.config.application.exception.NoMatchingURIException;
|
|
||||||
import app.module.front.usecase.daily.record.persistence.model.DailyRecordDto;
|
|
||||||
import app.module.front.usecase.daily.record.service.DailyRecordService;
|
|
||||||
import app.module.front.usecase.daily.record.web.model.CreateDailyRecordReqVO;
|
|
||||||
import app.module.front.usecase.daily.record.web.model.DailyRecordUIReqVO;
|
|
||||||
import app.module.front.usecase.daily.record.web.validator.CreateDailyRecordValidator;
|
|
||||||
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.stereotype.Controller;
|
|
||||||
import org.springframework.ui.Model;
|
|
||||||
import org.springframework.validation.BindingResult;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@Controller
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
@RequestMapping(path = "/record/daily")
|
|
||||||
public class DailyRecordUIController {
|
|
||||||
private final DailyRecordService dailyRecordService;
|
|
||||||
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) {
|
|
||||||
|
|
||||||
DailyRecordUIReqVO reqVO = new DailyRecordUIReqVO(searchMonth, groupNo);
|
|
||||||
log.debug("reqVO: {}", reqVO);
|
|
||||||
|
|
||||||
DailyRecordDto dailyRecord = dailyRecordService.getDailyRecord(reqVO);
|
|
||||||
if (dailyRecord == null) {
|
|
||||||
throw new NoMatchingURIException("[Record] 잘못된 접근");
|
|
||||||
}
|
|
||||||
|
|
||||||
model.addAttribute("reqVO", reqVO);
|
|
||||||
model.addAttribute("dailyRecord", dailyRecord);
|
|
||||||
|
|
||||||
return "record/daily";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
package app.module.front.usecase.daily.record.web.model;
|
|
||||||
|
|
||||||
import app.module.front.config.adapters.persistence.component.FrontAuditCommand;
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package app.module.front.usecase.daily.record.web.model;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@ToString(callSuper = true)
|
|
||||||
public class DailyRecordUIReqVO extends DailyUIReqVO {
|
|
||||||
public DailyRecordUIReqVO(String month, String no) {
|
|
||||||
setSearchMonth(month);
|
|
||||||
setGroupNo(Integer.parseInt(no));
|
|
||||||
}
|
|
||||||
|
|
||||||
public DailyRecordUIReqVO(String month, Integer no) {
|
|
||||||
setSearchMonth(month);
|
|
||||||
setGroupNo(no);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package app.module.front.usecase.daily.record.web.model;
|
|
||||||
|
|
||||||
public enum DailyStatus {
|
|
||||||
/**
|
|
||||||
* 입력중
|
|
||||||
*/
|
|
||||||
WAITING,
|
|
||||||
/**
|
|
||||||
* 등록 없음
|
|
||||||
*/
|
|
||||||
TODAY_NONE,
|
|
||||||
/**
|
|
||||||
* 등록 완료
|
|
||||||
*/
|
|
||||||
DONE,
|
|
||||||
;
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package app.module.front.usecase.daily.record.web.model;
|
|
||||||
|
|
||||||
public enum DailyTargetStatus {
|
|
||||||
/**
|
|
||||||
* 등록 대상
|
|
||||||
*/
|
|
||||||
TARGET,
|
|
||||||
/**
|
|
||||||
* 금일 없음
|
|
||||||
*/
|
|
||||||
TODAY_NONE,
|
|
||||||
/**
|
|
||||||
* 등록 없음
|
|
||||||
*/
|
|
||||||
NONE,
|
|
||||||
// /**
|
|
||||||
// * 등록 완료
|
|
||||||
// */
|
|
||||||
// DONE,
|
|
||||||
;
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
package app.module.front.usecase.daily.record.web.model;
|
|
||||||
|
|
||||||
import app.module.front.config.application.util.AuthUtil;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@ToString
|
|
||||||
public class DailyUIReqVO {
|
|
||||||
public DailyUIReqVO() {
|
|
||||||
this.householdSeq = AuthUtil.getUserSeq();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 검색 월(yyyyMM)
|
|
||||||
*/
|
|
||||||
private String searchMonth;
|
|
||||||
/**
|
|
||||||
* 검색 그룸번호
|
|
||||||
*/
|
|
||||||
private Integer groupNo;
|
|
||||||
/**
|
|
||||||
* 임가 일련번호
|
|
||||||
*/
|
|
||||||
private Long householdSeq;
|
|
||||||
}
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
package app.module.front.usecase.daily.record.web.validator;
|
|
||||||
|
|
||||||
import app.module.core.config.application.util.MessageUtil;
|
|
||||||
import app.module.front.usecase.daily.record.web.model.CreateDailyRecordReqVO;
|
|
||||||
import app.module.front.usecase.daily.record.web.model.DailyStatus;
|
|
||||||
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 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",
|
|
||||||
"등록하실 항목을 선택해 주세요.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
<mapper namespace="app.module.front.usecase.daily.expense.persistence.DailyExpenseMapper">
|
<mapper namespace="app.module.front.usecase.daily.expense.adapters.persistence.DailyExpenseMapper">
|
||||||
|
|
||||||
<select id="getDailyExpenseList"
|
<select id="getDailyExpenseList"
|
||||||
resultType="app.module.front.usecase.daily.expense.persistence.model.DailyExpenseDto">
|
resultType="app.module.front.usecase.daily.expense.adapters.persistence.model.DailyExpenseDto">
|
||||||
select ds.id, ds.daily_record_seq, ds.input_type, ds.is_credit as credit
|
select ds.id, ds.daily_record_seq, ds.input_type, ds.is_credit as credit
|
||||||
, ds.category_self, ds.source_purpose
|
, ds.category_self, ds.source_purpose
|
||||||
, ds.quantity, ds.unit_code, ds.price, ds.estimated_value
|
, ds.quantity, ds.unit_code, ds.price, ds.estimated_value
|
||||||
from daily_expense ds
|
from daily_expense ds
|
||||||
<include refid="app.module.front.usecase.daily.record.persistence.DailyRecordMapper.InnerJoinByDailyRecord"/>
|
<include refid="app.module.front.usecase.daily.record.adapters.persistence.DailyRecordMapper.InnerJoinByDailyRecord"/>
|
||||||
where ds.is_deleted = false
|
where ds.is_deleted = false
|
||||||
<if test="id != null and id != '0'">
|
<if test="id != null and id != '0'">
|
||||||
and ds.id = ${id}
|
and ds.id = ${id}
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
<select id="getRecordExistCount" resultType="int">
|
<select id="getRecordExistCount" resultType="int">
|
||||||
select count(1)
|
select count(1)
|
||||||
from daily_expense ds
|
from daily_expense ds
|
||||||
<include refid="app.module.front.usecase.daily.record.persistence.DailyRecordMapper.InnerJoinByDailyRecord"/>
|
<include refid="app.module.front.usecase.daily.record.adapters.persistence.DailyRecordMapper.InnerJoinByDailyRecord"/>
|
||||||
where ds.is_deleted = false
|
where ds.is_deleted = false
|
||||||
<if test="id != null and id != '0'">
|
<if test="id != null and id != '0'">
|
||||||
and ds.id = ${id}
|
and ds.id = ${id}
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
<mapper namespace="app.module.front.usecase.daily.income.persistence.DailyIncomeMapper">
|
<mapper namespace="app.module.front.usecase.daily.income.adapters.persistence.DailyIncomeMapper">
|
||||||
|
|
||||||
<select id="getDailyIncomeList"
|
<select id="getDailyIncomeList"
|
||||||
resultType="app.module.front.usecase.daily.income.persistence.model.DailyIncomeDto">
|
resultType="app.module.front.usecase.daily.income.adapters.persistence.model.DailyIncomeDto">
|
||||||
select ds.id, ds.daily_record_seq, ds.input_type, ds.is_credit as credit
|
select ds.id, ds.daily_record_seq, ds.input_type, ds.is_credit as credit
|
||||||
, ds.crop_code, ds.category_self, ds.source_purpose
|
, ds.crop_code, ds.category_self, ds.source_purpose
|
||||||
, ds.quantity, ds.unit_code, ds.price, ds.estimated_value
|
, ds.quantity, ds.unit_code, ds.price, ds.estimated_value
|
||||||
from daily_income ds
|
from daily_income ds
|
||||||
<include refid="app.module.front.usecase.daily.record.persistence.DailyRecordMapper.InnerJoinByDailyRecord"/>
|
<include refid="app.module.front.usecase.daily.record.adapters.persistence.DailyRecordMapper.InnerJoinByDailyRecord"/>
|
||||||
where ds.is_deleted = false
|
where ds.is_deleted = false
|
||||||
<if test="id != null and id != '0'">
|
<if test="id != null and id != '0'">
|
||||||
and ds.id = ${id}
|
and ds.id = ${id}
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
<select id="getRecordExistCount" resultType="int">
|
<select id="getRecordExistCount" resultType="int">
|
||||||
select count(1)
|
select count(1)
|
||||||
from daily_income ds
|
from daily_income ds
|
||||||
<include refid="app.module.front.usecase.daily.record.persistence.DailyRecordMapper.InnerJoinByDailyRecord"/>
|
<include refid="app.module.front.usecase.daily.record.adapters.persistence.DailyRecordMapper.InnerJoinByDailyRecord"/>
|
||||||
where ds.is_deleted = false
|
where ds.is_deleted = false
|
||||||
<if test="id != null and id != '0'">
|
<if test="id != null and id != '0'">
|
||||||
and ds.id = ${id}
|
and ds.id = ${id}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
<mapper namespace="app.module.front.usecase.daily.record.persistence.DailyRecordMapper">
|
<mapper namespace="app.module.front.usecase.daily.record.adapters.persistence.DailyRecordMapper">
|
||||||
|
|
||||||
<select id="getDailyRecord"
|
<select id="getDailyRecord"
|
||||||
resultType="app.module.front.usecase.daily.record.persistence.model.DailyRecordDto">
|
resultType="app.module.front.usecase.daily.record.adapters.persistence.model.DailyRecordDto">
|
||||||
select ddg.group_no, ddg.start_day, ddg.end_day
|
select ddg.group_no, ddg.start_day, ddg.end_day
|
||||||
, dr.id, dr.record_month, dr.day_group_no, dr.start_date, dr.end_date
|
, dr.id, dr.record_month, dr.day_group_no, dr.start_date, dr.end_date
|
||||||
, dr.all_status, dr.income_status, dr.work_status, dr.expense_status, dr.power_status, dr.forestry_status
|
, dr.all_status, dr.income_status, dr.work_status, dr.expense_status, dr.power_status, dr.forestry_status
|
||||||
|
|||||||
Reference in New Issue
Block a user