[FO] 일계부 항목 등록, 수입내역 등록 wip
This commit is contained in:
@@ -1,58 +1,50 @@
|
||||
package app.module.front.usecase.daily.income.persistence;
|
||||
|
||||
import app.module.front.usecase.daily.income.application.model.DailyIncomeCmd;
|
||||
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.web.model.DailyIncomeUIReqVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface DailyIncomeMapper {
|
||||
/**
|
||||
* 수입내역 데이터 존재 여부
|
||||
* @param householdSeq
|
||||
* @param recordMonth
|
||||
* @param dayGroupNo
|
||||
* @return
|
||||
*/
|
||||
Long getDailyIncomeExistCount(@Param("householdSeq") Long householdSeq, @Param("recordMonth") String recordMonth, @Param("dayGroupNo") Integer dayGroupNo);
|
||||
/**
|
||||
* 수입내역 목록 조회
|
||||
*
|
||||
* @param reqVO
|
||||
* @return
|
||||
*/
|
||||
List<DailyIncomeDto> getDailyIncomeList(DailyIncomeUIReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 수입내역 목록 조회
|
||||
* @param householdSeq
|
||||
* @param recordMonth
|
||||
* @param dayGroupNo
|
||||
* @return
|
||||
*/
|
||||
List<DailyIncomeDto> getDailyIncomeList(@Param("householdSeq") Long householdSeq, @Param("recordMonth") String recordMonth, @Param("dayGroupNo") Integer dayGroupNo);
|
||||
/**
|
||||
* 수입내역 데이터 존재 여부
|
||||
*
|
||||
* @param reqVO
|
||||
* @return
|
||||
*/
|
||||
Integer getDailyIncomeExistCount(DailyIncomeUIReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 수입내역 단건 조회
|
||||
* @param householdSeq
|
||||
* @param recordMonth
|
||||
* @param dayGroupNo
|
||||
* @return
|
||||
*/
|
||||
DailyIncomeDto getDailyIncome(@Param("householdSeq") Long householdSeq, @Param("recordMonth") String recordMonth, @Param("dayGroupNo") Integer dayGroupNo);
|
||||
/**
|
||||
* 수입내역 등록
|
||||
*
|
||||
* @param command
|
||||
* @return
|
||||
*/
|
||||
void createDailyIncome(CreateDailyIncomeCmd command);
|
||||
|
||||
/**
|
||||
* 수입내역 등록
|
||||
* @param command
|
||||
* @return
|
||||
*/
|
||||
Long createDailyIncome(DailyIncomeCmd command);
|
||||
/**
|
||||
* 수입내역 수정
|
||||
*
|
||||
* @param command
|
||||
* @return
|
||||
*/
|
||||
int updateDailyIncome(CreateDailyIncomeCmd command);
|
||||
|
||||
/**
|
||||
* 수입내역 수정
|
||||
* @param command
|
||||
* @return
|
||||
*/
|
||||
int updateDailyIncome(DailyIncomeCmd command);
|
||||
|
||||
/**
|
||||
* 수입내역 삭제
|
||||
* @return
|
||||
*/
|
||||
int removeDailyIncome();
|
||||
/**
|
||||
* 수입내역 삭제
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
int removeDailyIncome();
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package app.module.front.usecase.daily.income.application.model;
|
||||
package app.module.front.usecase.daily.income.persistence.model;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class DailyIncomeCmd {
|
||||
public class CreateDailyIncomeCmd {
|
||||
private Long id;
|
||||
private Long householdSeq;
|
||||
private Boolean isCredit;
|
||||
@@ -8,14 +8,17 @@ import java.time.LocalDateTime;
|
||||
@Getter
|
||||
@Setter
|
||||
public class DailyIncomeDto {
|
||||
private Long id;
|
||||
private Long householdSeq;
|
||||
private Boolean isCredit;
|
||||
// TODO
|
||||
private String createdBy;
|
||||
private LocalDateTime createdAt;
|
||||
private Integer price;
|
||||
private Integer estimatedValue;
|
||||
private String updatedBy;
|
||||
private LocalDateTime updatedAt;
|
||||
private Long id;
|
||||
private Long dailyRecordSeq;
|
||||
// SELF, OCR
|
||||
private String inputType;
|
||||
private Boolean isCredit;
|
||||
private String cropCode;
|
||||
private String categoryCode;
|
||||
private String categorySelf;
|
||||
private String sourcePurpose;
|
||||
private String quantity;
|
||||
private String unitCode;
|
||||
private String price;
|
||||
private String estimated_value;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
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 {
|
||||
List<DailyIncomeDto> getDailyIncomeList(DailyIncomeUIReqVO reqVO);
|
||||
|
||||
DailyIncomeDto getDailyIncome(DailyIncomeUIReqVO reqVO);
|
||||
|
||||
void createDailyIncome(CreateDailyIncomeReqVO command);
|
||||
|
||||
void removeDailyIncome(RemoveDailyIncomeReqVO command);
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package app.module.front.usecase.daily.income.service;
|
||||
|
||||
import app.module.front.usecase.daily.income.persistence.DailyIncomeMapper;
|
||||
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 lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DailyIncomeServiceImpl implements DailyIncomeService {
|
||||
private final DailyIncomeMapper dailyIncomeMapper;
|
||||
|
||||
@Override
|
||||
public List<DailyIncomeDto> getDailyIncomeList(DailyIncomeUIReqVO reqVO) {
|
||||
return this.getRefineIncomeList(reqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DailyIncomeDto getDailyIncome(DailyIncomeUIReqVO reqVO) {
|
||||
List<DailyIncomeDto> list = this.getRefineIncomeList(reqVO);
|
||||
if (list.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return list.get(0);
|
||||
}
|
||||
|
||||
private List<DailyIncomeDto> getRefineIncomeList(DailyIncomeUIReqVO reqVO) {
|
||||
List<DailyIncomeDto> list = dailyIncomeMapper.getDailyIncomeList(reqVO);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createDailyIncome(CreateDailyIncomeReqVO command) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeDailyIncome(RemoveDailyIncomeReqVO command) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,13 @@
|
||||
package app.module.front.usecase.daily.income.web;
|
||||
|
||||
import app.module.core.config.application.exception.NoMatchingURIException;
|
||||
import app.module.core.config.application.exception.NoRecordDataException;
|
||||
import app.module.front.config.application.util.AuthUtil;
|
||||
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;
|
||||
@@ -12,26 +17,47 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping(path = "/record/income")
|
||||
public class DailyIncomeController {
|
||||
private final DailyRecordService dailyRecordService;
|
||||
private final DailyIncomeService dailyIncomeService;
|
||||
|
||||
@GetMapping(path = "/{searchMonth}/{groupNo}")
|
||||
public String index(Model model,
|
||||
@PathVariable(required = true) String searchMonth,
|
||||
@PathVariable(required = true) String groupNo) {
|
||||
/**
|
||||
* 일계부 수입내역 등록 화면
|
||||
*
|
||||
* @param model
|
||||
* @param searchMonth 검색 월(yyyyMM)
|
||||
* @param groupNo 검색 그룹
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(path = "/{searchMonth}/{groupNo}")
|
||||
public String index(Model model, @PathVariable(required = true) String searchMonth, @PathVariable(required = true) String groupNo) {
|
||||
|
||||
DailyIncomeUIReqVO reqVO = new DailyIncomeUIReqVO();
|
||||
reqVO.setSearchMonth(searchMonth);
|
||||
reqVO.setGroupNo(Integer.parseInt(groupNo));
|
||||
reqVO.setHouseholdSeq(AuthUtil.getUserSeq());
|
||||
log.debug("reqVO: {}", reqVO);
|
||||
DailyRecordUIReqVO recordReqVO = new DailyRecordUIReqVO(searchMonth, groupNo);
|
||||
log.debug("recordReqVO: {}", recordReqVO);
|
||||
|
||||
model.addAttribute("reqVO", reqVO);
|
||||
model.addAttribute("detail", null);
|
||||
DailyRecordDto dailyRecord = dailyRecordService.getDailyRecord(recordReqVO);
|
||||
if (dailyRecord == null || dailyRecord.getId() == null) {
|
||||
throw new NoRecordDataException();
|
||||
}
|
||||
|
||||
return "record/income/index";
|
||||
}
|
||||
DailyIncomeUIReqVO reqVOs = new DailyIncomeUIReqVO();
|
||||
reqVOs.setSearchMonth(searchMonth);
|
||||
reqVOs.setGroupNo(Integer.parseInt(groupNo));
|
||||
reqVOs.setHouseholdSeq(AuthUtil.getUserSeq());
|
||||
log.debug("reqVO: {}", reqVOs);
|
||||
|
||||
List<DailyIncomeDto> incomeList = dailyIncomeService.getDailyIncomeList(reqVOs);
|
||||
|
||||
model.addAttribute("reqVO", reqVOs);
|
||||
model.addAttribute("dailyRecord", dailyRecord);
|
||||
model.addAttribute("incomeList", incomeList);
|
||||
|
||||
return "record/income/index";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package app.module.front.usecase.daily.income.web.model;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
public class CreateDailyIncomeReqVO {
|
||||
private Long id;
|
||||
private Long dailyRecordSeq;
|
||||
// SELF, OCR
|
||||
private String inputType;
|
||||
private Boolean isCredit;
|
||||
private String cropCode;
|
||||
private String categoryCode;
|
||||
private String categorySelf;
|
||||
private String sourcePurpose;
|
||||
private String quantity;
|
||||
private String unitCode;
|
||||
private String price;
|
||||
private String estimated_value;
|
||||
}
|
||||
@@ -9,4 +9,5 @@ public class DailyIncomeUIReqVO {
|
||||
private String searchMonth;
|
||||
private Integer groupNo;
|
||||
private Long householdSeq;
|
||||
private Long incomeId;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package app.module.front.usecase.daily.income.web.model;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
public class RemoveDailyIncomeReqVO {
|
||||
private Long id;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
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.CreateDailyRecordReqVO;
|
||||
import app.module.front.usecase.daily.record.web.model.DailyRecordUIReqVO;
|
||||
import app.module.front.usecase.daily.record.web.model.UpdateDailyRecordStatusCmd;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
@@ -10,28 +10,28 @@ import org.apache.ibatis.annotations.Param;
|
||||
@Mapper
|
||||
public interface DailyRecordMapper {
|
||||
|
||||
DailyRecordDto getDailyRecord(DailyRecordUIReqVO reqVO);
|
||||
DailyRecordDto getDailyRecord(DailyRecordUIReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 일계부 등록 여부
|
||||
* @param householdSeq
|
||||
* @param recordMonth
|
||||
* @param dayGroupNo
|
||||
* @return
|
||||
*/
|
||||
Long getDailyRecordExistCount(@Param("householdSeq") Long householdSeq, @Param("recordMonth") String recordMonth, @Param("dayGroupNo") Integer dayGroupNo);
|
||||
/**
|
||||
* 일계부 등록 여부
|
||||
*
|
||||
* @param reqVO
|
||||
* @return
|
||||
*/
|
||||
Integer getDailyRecordExistCount(DailyRecordUIReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 일계부 등록(생성)
|
||||
* @param command
|
||||
* @return
|
||||
*/
|
||||
Long createDailyRecord(CreateDailyRecordReqVO command);
|
||||
/**
|
||||
* 일계부 등록(생성)
|
||||
*
|
||||
* @param command
|
||||
*/
|
||||
void createDailyRecord(CreateDailyRecordCmd command);
|
||||
|
||||
/**
|
||||
* 일계부 상태 수정
|
||||
* @param command
|
||||
* @return
|
||||
*/
|
||||
int updateDailyRecordStatus(UpdateDailyRecordStatusCmd command);
|
||||
/**
|
||||
* 일계부 상태 수정
|
||||
*
|
||||
* @param command
|
||||
* @return
|
||||
*/
|
||||
int updateDailyRecordStatus(UpdateDailyRecordStatusCmd command);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
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,5 +1,7 @@
|
||||
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;
|
||||
|
||||
@@ -11,23 +13,22 @@ public class DailyRecordDto {
|
||||
// , all_status, income_status, work_status, expense_status, power_status, forestry_status
|
||||
// , created_at, created_by, is_deleted
|
||||
|
||||
private Integer groupNo;
|
||||
private Integer startDay;
|
||||
private Integer endDay;
|
||||
private Integer groupNo;
|
||||
private Integer startDay;
|
||||
private Integer endDay;
|
||||
|
||||
private Long id;
|
||||
// TODO enum
|
||||
private LocalDate startDate;
|
||||
private LocalDate endDate;
|
||||
private String allStatus;
|
||||
private String incomeStatus;
|
||||
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() {
|
||||
boolean returnValue = false;
|
||||
if (id != null) {
|
||||
returnValue = true;
|
||||
public boolean isUpdated() {
|
||||
return this.id != null;
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ import lombok.Setter;
|
||||
@Getter
|
||||
@Setter
|
||||
public class UpdateDailyRecordDto {
|
||||
private String monthly;
|
||||
private String updatedBy;
|
||||
private String statusType;
|
||||
private String statusCode;
|
||||
private String monthly;
|
||||
private String updatedBy;
|
||||
private String statusType;
|
||||
private String statusCode;
|
||||
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ 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);
|
||||
DailyRecordDto getDailyRecord(DailyRecordUIReqVO reqVO);
|
||||
|
||||
void createDailyRecord(CreateDailyRecordReqVO command);
|
||||
void createDailyRecord(CreateDailyRecordReqVO reqVO);
|
||||
}
|
||||
|
||||
@@ -2,11 +2,10 @@ package app.module.front.usecase.daily.record.service;
|
||||
|
||||
import app.module.front.config.application.util.AuditUtil;
|
||||
import app.module.front.usecase.daily.record.persistence.DailyRecordMapper;
|
||||
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.CreateDailyRecordReqVO;
|
||||
import app.module.front.usecase.daily.record.web.model.DailyRecordUIReqVO;
|
||||
import app.module.front.usecase.daily.record.web.model.DailyStatus;
|
||||
import app.module.front.usecase.daily.record.web.model.DailyTargetStatus;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -20,54 +19,53 @@ import java.util.Locale;
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DailyRecordServiceImpl implements DailyRecordService {
|
||||
private final DailyRecordMapper dailyRecordMapper;
|
||||
private final DailyRecordMapper dailyRecordMapper;
|
||||
|
||||
@Override
|
||||
public DailyRecordDto getDailyRecord(DailyRecordUIReqVO reqVO) {
|
||||
DailyRecordDto detail = dailyRecordMapper.getDailyRecord(reqVO);
|
||||
if (detail != null && !detail.isUpdated()) {
|
||||
try {
|
||||
SimpleDateFormat beforeSdf = new SimpleDateFormat("yyyyMMdd", Locale.KOREAN);
|
||||
SimpleDateFormat afterSdf = new SimpleDateFormat("yyyy-MM-dd", Locale.KOREAN);
|
||||
@Override
|
||||
public DailyRecordDto getDailyRecord(DailyRecordUIReqVO reqVO) {
|
||||
DailyRecordDto detail = dailyRecordMapper.getDailyRecord(reqVO);
|
||||
if (detail != null && !detail.isUpdated()) {
|
||||
try {
|
||||
SimpleDateFormat beforeSdf = new SimpleDateFormat("yyyyMMdd", Locale.KOREAN);
|
||||
SimpleDateFormat afterSdf = new SimpleDateFormat("yyyy-MM-dd", Locale.KOREAN);
|
||||
|
||||
Date formatDate = beforeSdf.parse(reqVO.getSearchMonth() + String.format("%02d", detail.getStartDay()));
|
||||
detail.setStartDate(LocalDate.parse(afterSdf.format(formatDate)));
|
||||
Date formatDate = beforeSdf.parse(reqVO.getSearchMonth() + String.format("%02d", detail.getStartDay()));
|
||||
detail.setStartDate(LocalDate.parse(afterSdf.format(formatDate)));
|
||||
|
||||
formatDate = beforeSdf.parse(reqVO.getSearchMonth() + String.format("%02d", detail.getEndDay()));
|
||||
detail.setEndDate(LocalDate.parse(afterSdf.format(formatDate)));
|
||||
formatDate = beforeSdf.parse(reqVO.getSearchMonth() + String.format("%02d", detail.getEndDay()));
|
||||
detail.setEndDate(LocalDate.parse(afterSdf.format(formatDate)));
|
||||
|
||||
} catch (Exception e) {
|
||||
log.warn("[DateParse] target={}", detail.getStartDay(), e);
|
||||
}
|
||||
}
|
||||
return detail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createDailyRecord(CreateDailyRecordReqVO command) {
|
||||
|
||||
if ("Y".equals(command.getTodayNone())) {
|
||||
command.setAllStatus(DailyStatus.TODAY_NONE);
|
||||
} else {
|
||||
command.setAllStatus(DailyStatus.WAITING);
|
||||
|
||||
if (command.getIncomeStatus() == null) {
|
||||
command.setIncomeStatus(DailyTargetStatus.NONE);
|
||||
}
|
||||
if (command.getWorkStatus() == null) {
|
||||
command.setWorkStatus(DailyTargetStatus.NONE);
|
||||
}
|
||||
if (command.getExpenseStatus() == null) {
|
||||
command.setExpenseStatus(DailyTargetStatus.NONE);
|
||||
}
|
||||
if (command.getPowerStatus() == null) {
|
||||
command.setPowerStatus(DailyTargetStatus.NONE);
|
||||
}
|
||||
if (command.getForestryStatus() == null) {
|
||||
command.setForestryStatus(DailyTargetStatus.NONE);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("[DateParse] target={}", detail.getStartDay(), e);
|
||||
}
|
||||
}
|
||||
return detail;
|
||||
}
|
||||
|
||||
dailyRecordMapper.createDailyRecord(AuditUtil.create(command));
|
||||
}
|
||||
@Override
|
||||
public void createDailyRecord(CreateDailyRecordReqVO reqVO) {
|
||||
CreateDailyRecordCmd command = AuditUtil.create(
|
||||
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) {
|
||||
dailyRecordMapper.createDailyRecord(command);
|
||||
|
||||
log.debug("[CreateDailyRecord] record={}", command);
|
||||
} else {
|
||||
log.warn("[DailyRecordCreate] existCount={}, recordMonth={}, dayGroupNo={}", existCount, reqVO.getRecordMonth(), reqVO.getDayGroupNo());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package app.module.front.usecase.daily.record.web;
|
||||
|
||||
import app.module.front.config.application.util.AuthUtil;
|
||||
import app.module.core.config.application.exception.NoMatchingURIException;
|
||||
import app.module.front.usecase.daily.calendar.service.RecordCalendarService;
|
||||
import app.module.front.usecase.daily.record.persistence.model.DailyRecordDto;
|
||||
import app.module.front.usecase.daily.record.service.DailyRecordService;
|
||||
@@ -22,62 +22,66 @@ import org.springframework.web.bind.annotation.*;
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping(path = "/record/daily")
|
||||
public class DailyRecordController {
|
||||
private final RecordCalendarService recordCalendarService;
|
||||
private final DailyRecordService dailyRecordService;
|
||||
private final CreateDailyRecordValidator createDailyRecordValidator;;
|
||||
private final RecordCalendarService recordCalendarService;
|
||||
private final DailyRecordService dailyRecordService;
|
||||
private final CreateDailyRecordValidator createDailyRecordValidator;
|
||||
|
||||
@GetMapping(path = "/{searchMonth}/{groupNo}")
|
||||
public String createForm(Model model
|
||||
, @PathVariable(required = true) String searchMonth
|
||||
, @PathVariable(required = true) String groupNo) {
|
||||
/**
|
||||
* 일계부 등록 화면
|
||||
*
|
||||
* @param model
|
||||
* @param searchMonth 검색 월(yyyyMM)
|
||||
* @param groupNo 검색 그룹
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(path = "/{searchMonth}/{groupNo}")
|
||||
public String createForm(Model model, @PathVariable(required = true) String searchMonth, @PathVariable(required = true) String groupNo) {
|
||||
|
||||
DailyRecordUIReqVO reqVO = new DailyRecordUIReqVO();
|
||||
reqVO.setSearchMonth(searchMonth);
|
||||
reqVO.setGroupNo(Integer.parseInt(groupNo));
|
||||
reqVO.setHouseholdSeq(AuthUtil.getUserSeq());
|
||||
log.debug("reqVO: {}", reqVO);
|
||||
DailyRecordUIReqVO reqVO = new DailyRecordUIReqVO(searchMonth, groupNo);
|
||||
log.debug("reqVO: {}", reqVO);
|
||||
|
||||
//uiCodeListPortIn.connect("code.pageable.rows");
|
||||
DailyRecordDto dailyRecord = dailyRecordService.getDailyRecord(reqVO);
|
||||
if (dailyRecord == null) {
|
||||
throw new NoMatchingURIException("[Record] 잘못된 접근");
|
||||
}
|
||||
|
||||
DailyRecordDto detail = dailyRecordService.getDailyRecord(reqVO);
|
||||
model.addAttribute("reqVO", reqVO);
|
||||
model.addAttribute("dailyRecord", dailyRecord);
|
||||
|
||||
model.addAttribute("reqVO", reqVO);
|
||||
model.addAttribute("detail", detail);
|
||||
|
||||
return "record/daily";
|
||||
}
|
||||
|
||||
@PostMapping(path = "/{searchMonth}/{groupNo}")
|
||||
ResponseEntity<?> create(@PathVariable(required = true) String searchMonth
|
||||
, @PathVariable(required = true) String groupNo
|
||||
, @Valid @RequestBody CreateDailyRecordReqVO formVO, BindingResult bindingResult) {
|
||||
|
||||
createDailyRecordValidator.validate(formVO, bindingResult);
|
||||
if (bindingResult.hasErrors()) {
|
||||
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
|
||||
.body(bindingResult.getFieldErrors());
|
||||
return "record/daily";
|
||||
}
|
||||
|
||||
DailyRecordUIReqVO reqVO = new DailyRecordUIReqVO();
|
||||
reqVO.setSearchMonth(searchMonth);
|
||||
reqVO.setGroupNo(Integer.parseInt(groupNo));
|
||||
// reqVO.setHouseholdSeq(AuthUtil.getUserSeq());
|
||||
log.debug("reqVO: {}", reqVO);
|
||||
/**
|
||||
* 일계부 등록 처리
|
||||
*
|
||||
* @param searchMonth
|
||||
* @param groupNo
|
||||
* @param formVO
|
||||
* @param bindingResult
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(path = "/{searchMonth}/{groupNo}")
|
||||
ResponseEntity<?> create(@PathVariable(required = true) String searchMonth, @PathVariable(required = true) String groupNo
|
||||
, @Valid @RequestBody CreateDailyRecordReqVO formVO, BindingResult bindingResult) {
|
||||
|
||||
//uiCodeListPortIn.connect("code.pageable.rows");
|
||||
createDailyRecordValidator.validate(formVO, bindingResult);
|
||||
if (bindingResult.hasErrors()) {
|
||||
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
|
||||
.body(bindingResult.getFieldErrors());
|
||||
}
|
||||
|
||||
DailyRecordDto detail = dailyRecordService.getDailyRecord(reqVO);
|
||||
DailyRecordUIReqVO reqVO = new DailyRecordUIReqVO(searchMonth, groupNo);
|
||||
log.debug("reqVO: {}", reqVO);
|
||||
|
||||
formVO.setHouseholdSeq(reqVO.getHouseholdSeq());
|
||||
formVO.setRecordMonth(reqVO.getSearchMonth());
|
||||
formVO.setDayGroupNo(reqVO.getGroupNo());
|
||||
formVO.setStartDate(detail.getStartDate());
|
||||
formVO.setEndDate(detail.getEndDate());
|
||||
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);
|
||||
|
||||
log.debug("formVO: {}", formVO);
|
||||
dailyRecordService.createDailyRecord(formVO);
|
||||
log.debug("createDailyRecord: id-{}", formVO.getId());
|
||||
dailyRecordService.createDailyRecord(formVO);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(reqVO);
|
||||
}
|
||||
return ResponseEntity.status(HttpStatus.OK).body(reqVO);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,26 +2,51 @@ 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
|
||||
public class CreateDailyRecordReqVO extends FrontAuditCommand {
|
||||
private Long id;
|
||||
// private Long householdSeq;
|
||||
private String recordMonth;
|
||||
private int dayGroupNo;
|
||||
private LocalDate startDate;
|
||||
private LocalDate endDate;
|
||||
// TODO : 전체 상태값 정의 ING, DONE
|
||||
private String todayNone;
|
||||
private DailyStatus allStatus;
|
||||
// TODO : 개별 상태값 정의 WAITING, TYPING, TODAY_NONE, NONE, DONE
|
||||
private DailyTargetStatus incomeStatus;
|
||||
private DailyTargetStatus workStatus;
|
||||
private DailyTargetStatus expenseStatus;
|
||||
private DailyTargetStatus powerStatus;
|
||||
private DailyTargetStatus forestryStatus;
|
||||
// TODO : 무슨 데이터 넣을 것인가?
|
||||
// private String createdBy;
|
||||
@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,12 +1,21 @@
|
||||
package app.module.front.usecase.daily.record.web.model;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
public class DailyRecordUIReqVO {
|
||||
private String searchMonth;
|
||||
private Integer groupNo;
|
||||
private Long householdSeq;
|
||||
@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,5 +1,17 @@
|
||||
package app.module.front.usecase.daily.record.web.model;
|
||||
|
||||
public enum DailyStatus {
|
||||
WAITING, TODAY_NONE, DONE;
|
||||
/**
|
||||
* 입력중
|
||||
*/
|
||||
WAITING,
|
||||
/**
|
||||
* 등록 없음
|
||||
*/
|
||||
TODAY_NONE,
|
||||
/**
|
||||
* 등록 완료
|
||||
*/
|
||||
DONE,
|
||||
;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,21 @@
|
||||
package app.module.front.usecase.daily.record.web.model;
|
||||
|
||||
public enum DailyTargetStatus {
|
||||
WAITING, TODAY_NONE, NONE, DONE;
|
||||
/**
|
||||
* 입력 중
|
||||
*/
|
||||
WAITING,
|
||||
/**
|
||||
* 금일 없음
|
||||
*/
|
||||
TODAY_NONE,
|
||||
/**
|
||||
* 등록 없음
|
||||
*/
|
||||
NONE,
|
||||
/**
|
||||
* 등록 완료
|
||||
*/
|
||||
DONE,
|
||||
;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
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;
|
||||
}
|
||||
@@ -6,15 +6,15 @@ import lombok.Setter;
|
||||
@Getter
|
||||
@Setter
|
||||
public class UpdateDailyRecordStatusCmd {
|
||||
private Long id;
|
||||
private Long householdSeq;
|
||||
private String recordMonth;
|
||||
private int dayGroupNo;
|
||||
// TODO : 전체 상태값 정의 ING, DONE
|
||||
private String allStatus;
|
||||
// TODO : 개별 상태값 정의 WAITING, TYPING, TODAY_NONE, NONE, DONE
|
||||
private String targetType;
|
||||
private String targetStatus;
|
||||
// TODO : 무슨 데이터 넣을 것인가?
|
||||
private String updatedBy;
|
||||
private Long id;
|
||||
private Long householdSeq;
|
||||
private String recordMonth;
|
||||
private int dayGroupNo;
|
||||
// TODO : 전체 상태값 정의 ING, DONE
|
||||
private String allStatus;
|
||||
// TODO : 개별 상태값 정의 WAITING, TYPING, TODAY_NONE, NONE, DONE
|
||||
private String targetType;
|
||||
private String targetStatus;
|
||||
// TODO : 무슨 데이터 넣을 것인가?
|
||||
private String updatedBy;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ 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;
|
||||
@@ -10,41 +11,41 @@ import org.springframework.validation.Validator;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class CreateDailyRecordValidator implements Validator {
|
||||
private final MessageUtil messageUtil;
|
||||
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 (StringUtils.isBlank(vo.getTodayNone())) {
|
||||
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",
|
||||
messageUtil.getMessage("valid.common.required"));
|
||||
}
|
||||
@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",
|
||||
"등록하실 항목을 선택해 주세요.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,12 +6,12 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||
@Controller
|
||||
public class HomeController {
|
||||
|
||||
/**
|
||||
* FRONT 메인 페이지
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(path = "/")
|
||||
public String home() {
|
||||
return "forward:/record/calendar";
|
||||
}
|
||||
/**
|
||||
* FRONT 메인 페이지
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(path = "/")
|
||||
public String home() {
|
||||
return "forward:/record/calendar";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,12 +6,12 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||
@Controller
|
||||
public class LoginController {
|
||||
|
||||
/**
|
||||
* FRONT 로그인 페이지
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/login")
|
||||
public String login() {
|
||||
return "security/login";
|
||||
}
|
||||
/**
|
||||
* FRONT 로그인 페이지
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/login")
|
||||
public String login() {
|
||||
return "security/login";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user