Merge branch 'daily' into dev
This commit is contained in:
@@ -42,43 +42,48 @@ public class RecordCalendarDao implements RecordCalendarPortOut {
|
||||
refine.setChildren(new ArrayList<>());
|
||||
} else {
|
||||
List<CalendarChildren> childList = new ArrayList<>();
|
||||
|
||||
if (DailyTargetStatus.TARGET.equals(findStatus.getIncomeStatus())) {
|
||||
if (DailyTargetStatus.TARGET.equals(findStatus.getIncomeStatus())
|
||||
|| DailyTargetStatus.TODAY_NONE.equals(findStatus.getIncomeStatus())) {
|
||||
childList.add(new CalendarChildren(
|
||||
"INCOME",
|
||||
"수입",
|
||||
findStatus.getIncomeCount(),
|
||||
String.format(pathFormat, "income", command.getSearchMonth(), findStatus.getDayGroupNo())));
|
||||
}
|
||||
if (DailyTargetStatus.TARGET.equals(findStatus.getWorkStatus())) {
|
||||
if (DailyTargetStatus.TARGET.equals(findStatus.getWorkStatus())
|
||||
|| DailyTargetStatus.TODAY_NONE.equals(findStatus.getWorkStatus())) {
|
||||
childList.add(new CalendarChildren(
|
||||
"WORK",
|
||||
"임업노동 투입 내역",
|
||||
findStatus.getWorkCount(),
|
||||
String.format(pathFormat, "work", command.getSearchMonth(), findStatus.getDayGroupNo())));
|
||||
}
|
||||
if (DailyTargetStatus.TARGET.equals(findStatus.getExpenseStatus())) {
|
||||
if (DailyTargetStatus.TARGET.equals(findStatus.getExpenseStatus())
|
||||
|| DailyTargetStatus.TODAY_NONE.equals(findStatus.getExpenseStatus())) {
|
||||
childList.add(new CalendarChildren(
|
||||
"EXPENSE",
|
||||
"지출",
|
||||
findStatus.getExpenseCount(),
|
||||
String.format(pathFormat, "expense", command.getSearchMonth(), findStatus.getDayGroupNo())));
|
||||
}
|
||||
if (DailyTargetStatus.TARGET.equals(findStatus.getPowerStatus())) {
|
||||
if (DailyTargetStatus.TARGET.equals(findStatus.getPowerStatus())
|
||||
|| DailyTargetStatus.TODAY_NONE.equals(findStatus.getPowerStatus())) {
|
||||
childList.add(new CalendarChildren(
|
||||
"POWER",
|
||||
"동력 사용시간",
|
||||
findStatus.getPowerCount(),
|
||||
String.format(pathFormat, "power", command.getSearchMonth(), findStatus.getDayGroupNo())));
|
||||
}
|
||||
if (DailyTargetStatus.TARGET.equals(findStatus.getForestryStatus())) {
|
||||
if (DailyTargetStatus.TARGET.equals(findStatus.getForestryStatus())
|
||||
|| DailyTargetStatus.TODAY_NONE.equals(findStatus.getForestryStatus())) {
|
||||
childList.add(new CalendarChildren(
|
||||
"FORESTRY",
|
||||
"자가임업 생산물 중 자가소비량",
|
||||
findStatus.getForestryCount(),
|
||||
String.format(pathFormat, "forestry", command.getSearchMonth(), findStatus.getDayGroupNo())));
|
||||
}
|
||||
if (DailyTargetStatus.TARGET.equals(findStatus.getFarmingStatus())) {
|
||||
if (DailyTargetStatus.TARGET.equals(findStatus.getFarmingStatus())
|
||||
|| DailyTargetStatus.TODAY_NONE.equals(findStatus.getFarmingStatus())) {
|
||||
childList.add(new CalendarChildren(
|
||||
"FARMING",
|
||||
"자가농업 생산물 중 자가소비량",
|
||||
|
||||
@@ -6,6 +6,7 @@ import app.module.front.usecase.daily.expense.adapters.persistence.model.DailyEx
|
||||
import app.module.front.usecase.daily.expense.adapters.web.model.DailyExpenseUIReqVO;
|
||||
import app.module.front.usecase.daily.expense.ports.DailyExpensePortIn;
|
||||
import app.module.front.usecase.daily.record.adapters.persistence.model.DailyRecordDto;
|
||||
import app.module.front.usecase.daily.record.adapters.web.model.DailySort;
|
||||
import app.module.front.usecase.daily.record.adapters.web.model.DailyUIReqVO;
|
||||
import app.module.front.usecase.daily.record.ports.DailyRecordPortIn;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -15,6 +16,7 @@ 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.springframework.web.bind.annotation.RequestParam;
|
||||
import org.thymeleaf.util.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
@@ -34,10 +36,12 @@ public class DailyExpenseUIController {
|
||||
* @param model Model
|
||||
* @param searchMonth 검색 월(yyyyMM)
|
||||
* @param groupNo 검색 그룹
|
||||
* @param searchType 수정여부
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(path = "/{searchMonth}/{groupNo}")
|
||||
public String index(Model model, @PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo) {
|
||||
public String index(Model model, @PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo
|
||||
, @RequestParam(name = "type", required = false) String searchType) {
|
||||
|
||||
DailyRecordDto dailyRecord = this.vaildGetDailyRecord(searchMonth, groupNo);
|
||||
|
||||
@@ -49,6 +53,8 @@ public class DailyExpenseUIController {
|
||||
model.addAttribute("reqVO", reqVO);
|
||||
model.addAttribute("dailyRecord", dailyRecord);
|
||||
model.addAttribute("expenseList", expenseList);
|
||||
model.addAttribute("moveStep", !"update".equals(searchType));
|
||||
model.addAttribute("nextStep", dailyRecord.getNextStep(DailySort.EXPENSE));
|
||||
|
||||
return "record/expense/index";
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import app.module.front.usecase.daily.income.adapters.web.model.RemoveDailyIncom
|
||||
import app.module.front.usecase.daily.income.adapters.web.validator.CreateDailyIncomeValidator;
|
||||
import app.module.front.usecase.daily.income.ports.DailyIncomePortIn;
|
||||
import app.module.front.usecase.daily.record.adapters.persistence.model.DailyRecordDto;
|
||||
import app.module.front.usecase.daily.record.adapters.web.model.DailyTargetStatus;
|
||||
import app.module.front.usecase.daily.record.adapters.web.model.DailyUIReqVO;
|
||||
import app.module.front.usecase.daily.record.ports.DailyRecordPortIn;
|
||||
import jakarta.validation.Valid;
|
||||
@@ -17,6 +18,9 @@ import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@@ -35,7 +39,6 @@ public class DailyIncomeController {
|
||||
* @param id 수입 일련번호
|
||||
* @param formVO 입력 데이터
|
||||
* @param bindingResult BindingResult
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(path = "/{searchMonth}/{groupNo}/form/{id}")
|
||||
ResponseEntity<?> create(@PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo
|
||||
@@ -67,7 +70,6 @@ public class DailyIncomeController {
|
||||
* @param groupNo 검색 그룹
|
||||
* @param formVO 입력 데이터
|
||||
* @param bindingResult BindingResult
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(path = "/{searchMonth}/{groupNo}/remove")
|
||||
ResponseEntity<?> remove(@PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo
|
||||
@@ -96,7 +98,6 @@ public class DailyIncomeController {
|
||||
*
|
||||
* @param searchMonth 검색 월(yyyyMM)
|
||||
* @param groupNo 검색 그룹
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(path = "/{searchMonth}/{groupNo}/reset")
|
||||
ResponseEntity<?> removeAll(@PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo) {
|
||||
@@ -119,7 +120,6 @@ public class DailyIncomeController {
|
||||
*
|
||||
* @param searchMonth 검색 월(yyyyMM)
|
||||
* @param groupNo 검색 그룹
|
||||
* @return
|
||||
*/
|
||||
private DailyRecordDto vaildGetDailyRecord(String searchMonth, String groupNo) {
|
||||
DailyUIReqVO reqVO = new DailyUIReqVO(searchMonth, groupNo);
|
||||
|
||||
@@ -6,6 +6,7 @@ import app.module.front.usecase.daily.income.adapters.persistence.model.DailyInc
|
||||
import app.module.front.usecase.daily.income.adapters.web.model.DailyIncomeUIReqVO;
|
||||
import app.module.front.usecase.daily.income.ports.DailyIncomePortIn;
|
||||
import app.module.front.usecase.daily.record.adapters.persistence.model.DailyRecordDto;
|
||||
import app.module.front.usecase.daily.record.adapters.web.model.DailySort;
|
||||
import app.module.front.usecase.daily.record.adapters.web.model.DailyUIReqVO;
|
||||
import app.module.front.usecase.daily.record.ports.DailyRecordPortIn;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -15,6 +16,7 @@ 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.springframework.web.bind.annotation.RequestParam;
|
||||
import org.thymeleaf.util.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
@@ -34,10 +36,12 @@ public class DailyIncomeUIController {
|
||||
* @param model Model
|
||||
* @param searchMonth 검색 월(yyyyMM)
|
||||
* @param groupNo 검색 그룹
|
||||
* @param searchType 수정여부
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(path = "/{searchMonth}/{groupNo}")
|
||||
public String index(Model model, @PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo) {
|
||||
public String index(Model model, @PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo
|
||||
, @RequestParam(name = "type", required = false) String searchType) {
|
||||
|
||||
DailyRecordDto dailyRecord = this.vaildGetDailyRecord(searchMonth, groupNo);
|
||||
|
||||
@@ -49,6 +53,8 @@ public class DailyIncomeUIController {
|
||||
model.addAttribute("reqVO", reqVO);
|
||||
model.addAttribute("dailyRecord", dailyRecord);
|
||||
model.addAttribute("incomeList", incomeList);
|
||||
model.addAttribute("moveStep", !"update".equals(searchType));
|
||||
model.addAttribute("nextStep", dailyRecord.getNextStep(DailySort.INCOME));
|
||||
|
||||
return "record/income/index";
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package app.module.front.usecase.daily.record.adapters.persistence.model;
|
||||
|
||||
import app.module.front.usecase.daily.record.adapters.web.model.DailySort;
|
||||
import app.module.front.usecase.daily.record.adapters.web.model.DailyStatus;
|
||||
import app.module.front.usecase.daily.record.adapters.web.model.DailyTargetStatus;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class DailyRecordDto {
|
||||
@@ -28,7 +30,32 @@ public class DailyRecordDto {
|
||||
private DailyTargetStatus forestryStatus;
|
||||
private DailyTargetStatus farmingStatus;
|
||||
|
||||
private boolean lastDay;
|
||||
private List<DailySort> targetList;
|
||||
|
||||
public boolean isUpdated() {
|
||||
return this.id != null;
|
||||
}
|
||||
|
||||
public String getNextStep(DailySort currentStep) {
|
||||
String returnValue = null;
|
||||
if (targetList != null) {
|
||||
int index = 0;
|
||||
int size = targetList.size();
|
||||
for (DailySort target : targetList) {
|
||||
if (target.equals(currentStep) && (index + 1) != size) {
|
||||
returnValue = targetList.get(index + 1).name();
|
||||
break;
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
if (returnValue == null) {
|
||||
returnValue = "LAST";
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import app.module.front.usecase.daily.record.adapters.web.model.DailyTargetStatu
|
||||
import app.module.front.usecase.daily.record.adapters.web.model.DailyUIReqVO;
|
||||
import app.module.front.usecase.daily.record.adapters.web.validator.CreateDailyRecordValidator;
|
||||
import app.module.front.usecase.daily.record.ports.DailyRecordPortIn;
|
||||
import app.module.front.usecase.daily.record.ports.application.domain.GetDailyRecordCmd;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -24,13 +23,12 @@ public class DailyRecordController {
|
||||
private final CreateDailyRecordValidator createDailyRecordValidator;
|
||||
|
||||
/**
|
||||
* 일계부 등록 처리
|
||||
* 일계부 항목 등록 처리
|
||||
*
|
||||
* @param searchMonth
|
||||
* @param groupNo
|
||||
* @param formVO
|
||||
* @param bindingResult
|
||||
* @return
|
||||
* @param searchMonth 검색 월(yyyyMM)
|
||||
* @param groupNo 검색 그룹
|
||||
* @param formVO 입력 데이터
|
||||
* @param bindingResult BindingResult
|
||||
*/
|
||||
@PostMapping(path = "/{searchMonth}/{groupNo}")
|
||||
ResponseEntity<?> create(@PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo
|
||||
@@ -57,15 +55,21 @@ public class DailyRecordController {
|
||||
return ResponseEntity.status(HttpStatus.OK).body(reqVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 일계부 금일 데이터 없음 처리
|
||||
*
|
||||
* @param searchMonth 검색 월(yyyyMM)
|
||||
* @param groupNo 검색 그룹
|
||||
* @param targetType 처리 대상
|
||||
* @param targetStatus 처리 상태
|
||||
*/
|
||||
@PostMapping(path = "/{searchMonth}/{groupNo}/today-none")
|
||||
ResponseEntity<?> todayNone(@PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo
|
||||
, @RequestParam(name = "target", required = true, defaultValue = "") String targetType
|
||||
, @RequestParam(name = "status", required = false, defaultValue = "N") String targetStatus) {
|
||||
|
||||
DailyUIReqVO reqVO = new DailyUIReqVO(searchMonth, groupNo);
|
||||
log.debug("reqVO: {}", reqVO);
|
||||
log.debug("target: {}", targetType);
|
||||
log.debug("status: {}", targetStatus);
|
||||
log.debug("reqVO: {}, target: {}, status: {}", reqVO, targetType, targetStatus);
|
||||
|
||||
DailyRecordDto detail = dailyRecordPortIn.detail(reqVO);
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package app.module.front.usecase.daily.record.adapters.web;
|
||||
|
||||
import app.module.core.config.application.exception.NoMatchingURIException;
|
||||
import app.module.front.usecase.daily.record.adapters.persistence.model.DailyRecordDto;
|
||||
import app.module.front.usecase.daily.record.adapters.web.model.DailyStatus;
|
||||
import app.module.front.usecase.daily.record.adapters.web.model.DailyUIReqVO;
|
||||
import app.module.front.usecase.daily.record.adapters.web.validator.CreateDailyRecordValidator;
|
||||
import app.module.front.usecase.daily.record.ports.DailyRecordPortIn;
|
||||
@@ -22,9 +23,9 @@ public class DailyRecordUIController {
|
||||
private final CreateDailyRecordValidator createDailyRecordValidator;
|
||||
|
||||
/**
|
||||
* 일계부 등록 화면
|
||||
* 일계부 항목 등록 화면
|
||||
*
|
||||
* @param model
|
||||
* @param model Model
|
||||
* @param searchMonth 검색 월(yyyyMM)
|
||||
* @param groupNo 검색 그룹
|
||||
* @return
|
||||
@@ -43,6 +44,36 @@ public class DailyRecordUIController {
|
||||
model.addAttribute("reqVO", reqVO);
|
||||
model.addAttribute("dailyRecord", dailyRecord);
|
||||
|
||||
return "record/daily";
|
||||
return "record/daily/index";
|
||||
}
|
||||
|
||||
/**
|
||||
* 일계부 완료(종료) 화면
|
||||
*
|
||||
* @param model Model
|
||||
* @param searchMonth 검색 월(yyyyMM)
|
||||
* @param groupNo 검색 그룹
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(path = "/{searchMonth}/{groupNo}/done")
|
||||
public String done(Model model, @PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo) {
|
||||
|
||||
DailyUIReqVO reqVO = new DailyUIReqVO(searchMonth, groupNo);
|
||||
log.debug("reqVO: {}", reqVO);
|
||||
|
||||
DailyRecordDto dailyRecord = dailyRecordPortIn.detail(reqVO);
|
||||
if (dailyRecord == null) {
|
||||
throw new NoMatchingURIException("[Record] 잘못된 접근");
|
||||
}
|
||||
|
||||
String modelAndView = "record/daily/done";
|
||||
if (DailyStatus.TODAY_NONE.equals(dailyRecord.getAllStatus())) {
|
||||
modelAndView = "record/daily/finish";
|
||||
}
|
||||
|
||||
model.addAttribute("reqVO", reqVO);
|
||||
model.addAttribute("dailyRecord", dailyRecord);
|
||||
|
||||
return modelAndView;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,18 @@ public class CreateDailyRecordReqVO {
|
||||
public void setTodayNone(String todayNone) {
|
||||
if ("Y".equals(todayNone)) {
|
||||
this.allStatus = DailyStatus.TODAY_NONE;
|
||||
this.incomeStatus = DailyTargetStatus.TODAY_NONE;
|
||||
this.workStatus = DailyTargetStatus.TODAY_NONE;
|
||||
this.expenseStatus = DailyTargetStatus.TODAY_NONE;
|
||||
this.powerStatus = DailyTargetStatus.TODAY_NONE;
|
||||
this.forestryStatus = DailyTargetStatus.TODAY_NONE;
|
||||
|
||||
// TODO : 7의 배수와 마지막날의 기준
|
||||
if (dayGroupNo == 4 || dayGroupNo == 8 || dayGroupNo == 12 || dayGroupNo == 16 || dayGroupNo == 17) {
|
||||
this.farmingStatus = DailyTargetStatus.TODAY_NONE;
|
||||
} else {
|
||||
this.farmingStatus = DailyTargetStatus.NONE;
|
||||
}
|
||||
} else {
|
||||
this.allStatus = DailyStatus.WAITING;
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package app.module.front.usecase.daily.record.adapters.web.model;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public enum DailySort {
|
||||
INCOME("수입"),
|
||||
WORK("임업노동 투입"),
|
||||
EXPENSE("지출"),
|
||||
POWER("동력 사용시간"),
|
||||
FORESTRY("임업생산물 중 자가소비량"),
|
||||
FARMING("농업생산물 중 자가소비량"),
|
||||
;
|
||||
|
||||
private final String desc;
|
||||
}
|
||||
@@ -4,14 +4,22 @@ 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.DailySort;
|
||||
import app.module.front.usecase.daily.record.adapters.web.model.DailyTargetStatus;
|
||||
import app.module.front.usecase.daily.record.adapters.web.model.DailyUIReqVO;
|
||||
import app.module.front.usecase.daily.record.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 lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DailyRecordService implements DailyRecordPortIn {
|
||||
@@ -19,9 +27,49 @@ public class DailyRecordService implements DailyRecordPortIn {
|
||||
|
||||
@Override
|
||||
public DailyRecordDto detail(DailyUIReqVO reqVO) {
|
||||
return portOut.detail(new GetDailyRecordCmd(reqVO.getSearchMonth(),
|
||||
DailyRecordDto dailyRecord = portOut.detail(new GetDailyRecordCmd(reqVO.getSearchMonth(),
|
||||
reqVO.getGroupNo(),
|
||||
reqVO.getHouseholdSeq()));
|
||||
|
||||
if (dailyRecord != null) {
|
||||
// TODO : 이전 다음을 체크하기 위함
|
||||
List<DailySort> targetList = new ArrayList<>();
|
||||
if (this.isTarget(dailyRecord.getIncomeStatus())) {
|
||||
targetList.add(DailySort.INCOME);
|
||||
}
|
||||
if (this.isTarget(dailyRecord.getWorkStatus())) {
|
||||
targetList.add(DailySort.WORK);
|
||||
}
|
||||
if (this.isTarget(dailyRecord.getExpenseStatus())) {
|
||||
targetList.add(DailySort.EXPENSE);
|
||||
}
|
||||
if (this.isTarget(dailyRecord.getPowerStatus())) {
|
||||
targetList.add(DailySort.POWER);
|
||||
}
|
||||
if (this.isTarget(dailyRecord.getForestryStatus())) {
|
||||
targetList.add(DailySort.FORESTRY);
|
||||
}
|
||||
if (this.isTarget(dailyRecord.getFarmingStatus())) {
|
||||
targetList.add(DailySort.FARMING);
|
||||
}
|
||||
dailyRecord.setTargetList(targetList);
|
||||
}
|
||||
|
||||
// TODO : 마지막날 건의사항 모달 팝업 뜨는 것
|
||||
LocalDate lastDate = dailyRecord.getEndDate().withDayOfMonth(dailyRecord.getEndDate().lengthOfMonth());
|
||||
log.debug("lastDate: {}", lastDate);
|
||||
|
||||
if (dailyRecord.getEndDate() == lastDate) {
|
||||
dailyRecord.setLastDay(true);
|
||||
} else {
|
||||
dailyRecord.setLastDay(false);
|
||||
}
|
||||
|
||||
return dailyRecord;
|
||||
}
|
||||
|
||||
private boolean isTarget(DailyTargetStatus status) {
|
||||
return DailyTargetStatus.TARGET.equals(status) || DailyTargetStatus.TODAY_NONE.equals(status);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package app.module.front.usecase.suggestion.adapters.persistence;
|
||||
|
||||
import app.module.front.usecase.suggestion.ports.SuggestionPortOut;
|
||||
import app.module.front.usecase.suggestion.ports.application.domain.CreateSuggestionCmd;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SuggestionDao implements SuggestionPortOut {
|
||||
private final SuggestionMapper suggestionMapper;
|
||||
|
||||
@Override
|
||||
public void create(CreateSuggestionCmd command) {
|
||||
suggestionMapper.createSuggestion(command);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package app.module.front.usecase.suggestion.adapters.persistence;
|
||||
|
||||
import app.module.front.usecase.suggestion.ports.application.domain.CreateSuggestionCmd;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface SuggestionMapper {
|
||||
/**
|
||||
* 건의사항 등록
|
||||
*
|
||||
* @param command 등록 데이터
|
||||
*/
|
||||
void createSuggestion(CreateSuggestionCmd command);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package app.module.front.usecase.suggestion.adapters.web;
|
||||
|
||||
import app.module.front.usecase.suggestion.adapters.web.model.CreateSuggestionReqVO;
|
||||
import app.module.front.usecase.suggestion.ports.SuggestionPortIn;
|
||||
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.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping(path = "/api/suggestion")
|
||||
public class SuggestionController {
|
||||
private final SuggestionPortIn suggestionPortIn;
|
||||
|
||||
/**
|
||||
* 건의사항 등록 처리
|
||||
*
|
||||
* @param formVO 입력 데이터
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(path = "")
|
||||
ResponseEntity<?> create(@Valid @RequestBody CreateSuggestionReqVO formVO) {
|
||||
log.debug("formVO: {}", formVO);
|
||||
|
||||
suggestionPortIn.create(formVO);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package app.module.front.usecase.suggestion.adapters.web.model;
|
||||
|
||||
import app.module.front.usecase.daily.record.adapters.web.model.DailyUIReqVO;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString(callSuper = true)
|
||||
public class CreateSuggestionReqVO extends DailyUIReqVO {
|
||||
/**
|
||||
* 내용
|
||||
*/
|
||||
private String content;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package app.module.front.usecase.suggestion.ports;
|
||||
|
||||
import app.module.front.usecase.suggestion.adapters.web.model.CreateSuggestionReqVO;
|
||||
|
||||
public interface SuggestionPortIn {
|
||||
/**
|
||||
* 건의사항 등록
|
||||
*
|
||||
* @param formVO 입력 데이터
|
||||
*/
|
||||
void create(CreateSuggestionReqVO formVO);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package app.module.front.usecase.suggestion.ports;
|
||||
|
||||
import app.module.front.usecase.suggestion.ports.application.domain.CreateSuggestionCmd;
|
||||
|
||||
public interface SuggestionPortOut {
|
||||
/**
|
||||
* 건의사항 등록
|
||||
*
|
||||
* @param command 입력 데이터
|
||||
*/
|
||||
void create(CreateSuggestionCmd command);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package app.module.front.usecase.suggestion.ports.application;
|
||||
|
||||
import app.module.front.config.application.util.AuditUtil;
|
||||
import app.module.front.usecase.suggestion.adapters.web.model.CreateSuggestionReqVO;
|
||||
import app.module.front.usecase.suggestion.ports.SuggestionPortIn;
|
||||
import app.module.front.usecase.suggestion.ports.SuggestionPortOut;
|
||||
import app.module.front.usecase.suggestion.ports.application.domain.CreateSuggestionCmd;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SuggestionService implements SuggestionPortIn {
|
||||
private final SuggestionPortOut portOut;
|
||||
|
||||
@Override
|
||||
public void create(CreateSuggestionReqVO formVO) {
|
||||
CreateSuggestionCmd command = AuditUtil.create(
|
||||
new CreateSuggestionCmd(
|
||||
formVO.getContent()));
|
||||
|
||||
portOut.create(command);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package app.module.front.usecase.suggestion.ports.application.domain;
|
||||
|
||||
import app.module.front.config.adapters.persistence.component.FrontAuditCommand;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
public class CreateSuggestionCmd extends FrontAuditCommand {
|
||||
private String content;
|
||||
}
|
||||
Reference in New Issue
Block a user