Merge branch 'daily' into dev
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
package app.module.front.usecase.daily.calendar.adapters.persistence;
|
||||
|
||||
import app.module.core.config.application.enums.MonthStatus;
|
||||
import app.module.front.usecase.daily.calendar.adapters.persistence.model.DailyRecordCalendarDto;
|
||||
import app.module.front.usecase.daily.calendar.adapters.persistence.model.DailyRecordStatusDto;
|
||||
import app.module.front.usecase.daily.calendar.adapters.persistence.model.MonthlyStatusDto;
|
||||
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.CalendarChildren;
|
||||
@@ -10,6 +12,8 @@ import app.module.front.usecase.daily.record.adapters.web.model.DailyTargetStatu
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -24,6 +28,7 @@ public class RecordCalendarDao implements RecordCalendarPortOut {
|
||||
public List<RecordCalendar> operate(RecordCalendarCmd command) {
|
||||
List<DailyRecordCalendarDto> calendarList = this.getCalendarList(command);
|
||||
List<DailyRecordStatusDto> statusList = this.getDailyRecordStatus(command);
|
||||
MonthlyStatusDto monthlyStatus = this.getBankExist(command);
|
||||
|
||||
String pathFormat = "/record/%s/%s/%s";
|
||||
|
||||
@@ -38,10 +43,10 @@ public class RecordCalendarDao implements RecordCalendarPortOut {
|
||||
.filter(f -> Objects.equals(calendar.getDailyId(), f.getDailyId()))
|
||||
.findFirst().orElse(null);
|
||||
|
||||
List<CalendarChildren> childList = new ArrayList<>();
|
||||
if (findStatus == null) {
|
||||
refine.setChildren(new ArrayList<>());
|
||||
} else {
|
||||
List<CalendarChildren> childList = new ArrayList<>();
|
||||
if (DailyTargetStatus.TARGET.equals(findStatus.getIncomeStatus())
|
||||
|| DailyTargetStatus.TODAY_NONE.equals(findStatus.getIncomeStatus())) {
|
||||
childList.add(new CalendarChildren(
|
||||
@@ -90,23 +95,22 @@ public class RecordCalendarDao implements RecordCalendarPortOut {
|
||||
findStatus.getFarmingCount(),
|
||||
String.format(pathFormat, "farming", command.getSearchMonth(), findStatus.getDayGroupNo())));
|
||||
}
|
||||
|
||||
// TODO /info/monthly
|
||||
childList.add(new CalendarChildren(
|
||||
"MONTHLY",
|
||||
"임산물 현황 등록",
|
||||
0,
|
||||
String.format("/info/monthly/month/%s", command.getSearchMonth())));
|
||||
|
||||
childList.add(new CalendarChildren(
|
||||
"BANK",
|
||||
"은행 자동이체 내역 등록",
|
||||
0,
|
||||
"/info/bank"));
|
||||
|
||||
refine.setChildren(childList);
|
||||
}
|
||||
|
||||
childList.add(new CalendarChildren(
|
||||
"MONTHLY",
|
||||
"임산물 현황 등록",
|
||||
monthlyStatus.isForestNone() ? 0 : 1,
|
||||
String.format("/info/monthly/month/%s", command.getSearchMonth())));
|
||||
|
||||
childList.add(new CalendarChildren(
|
||||
"BANK",
|
||||
"은행 자동이체 내역 등록",
|
||||
monthlyStatus.isBankNone() ? 0 : 1,
|
||||
(LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMM")).equals(command.getSearchMonth())) ? "/info/bank" : null));
|
||||
|
||||
refine.setChildren(childList);
|
||||
|
||||
refineList.add(refine);
|
||||
}
|
||||
|
||||
@@ -151,4 +155,16 @@ public class RecordCalendarDao implements RecordCalendarPortOut {
|
||||
|
||||
return statusList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 특정월의 월별 작성 상태 조회
|
||||
*
|
||||
* @param command 검색 조건
|
||||
* @return true=등록완료, false=미등록
|
||||
*/
|
||||
private MonthlyStatusDto getBankExist(RecordCalendarCmd command) {
|
||||
MonthlyStatusDto detail = recordCalendarMapper.getMonthlyStatus(command);
|
||||
|
||||
return detail == null ? new MonthlyStatusDto(MonthStatus.NONE, MonthStatus.NONE, MonthStatus.NONE) : detail;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package app.module.front.usecase.daily.calendar.adapters.persistence;
|
||||
|
||||
import app.module.front.usecase.daily.calendar.adapters.persistence.model.DailyRecordCalendarDto;
|
||||
import app.module.front.usecase.daily.calendar.adapters.persistence.model.DailyRecordStatusDto;
|
||||
import app.module.front.usecase.daily.calendar.adapters.persistence.model.MonthlyStatusDto;
|
||||
import app.module.front.usecase.daily.calendar.ports.application.domain.RecordCalendarCmd;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@@ -12,16 +13,24 @@ public interface RecordCalendarMapper {
|
||||
/**
|
||||
* 특정월의 일 그룹 조회
|
||||
*
|
||||
* @param cmd 검색 조건
|
||||
* @param command 검색 조건
|
||||
* @return 일(DAY) 그룹 목록
|
||||
*/
|
||||
List<DailyRecordCalendarDto> getCalendarByDailyRecord(RecordCalendarCmd cmd);
|
||||
List<DailyRecordCalendarDto> getCalendarByDailyRecord(RecordCalendarCmd command);
|
||||
|
||||
/**
|
||||
* 특정일의 일계부 등록 상태 조회
|
||||
*
|
||||
* @param cmd 검색 조건
|
||||
* @param command 검색 조건
|
||||
* @return 일계부 등록 현황 목록
|
||||
*/
|
||||
List<DailyRecordStatusDto> getDailyRecordStatus(RecordCalendarCmd cmd);
|
||||
List<DailyRecordStatusDto> getDailyRecordStatus(RecordCalendarCmd command);
|
||||
|
||||
/**
|
||||
* 특정월의 월별 작성 상태 조회
|
||||
*
|
||||
* @param command 검색 조건
|
||||
* @return 월별 작성 상태
|
||||
*/
|
||||
MonthlyStatusDto getMonthlyStatus(RecordCalendarCmd command);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package app.module.front.usecase.daily.calendar.adapters.persistence.model;
|
||||
|
||||
import app.module.core.config.application.enums.MonthStatus;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
public class MonthlyStatusDto {
|
||||
private MonthStatus forestProduct;
|
||||
private MonthStatus bankInput;
|
||||
private MonthStatus bankOutput;
|
||||
|
||||
/**
|
||||
* 임산물 현황 등록 여부
|
||||
* @return true=미등록, false=등록완료
|
||||
*/
|
||||
public boolean isForestNone() {
|
||||
return MonthStatus.NONE.equals(forestProduct) || forestProduct == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 은행 자동이체 내역 등록 여부
|
||||
* @return true=미등록, false=등록완료
|
||||
*/
|
||||
public boolean isBankNone() {
|
||||
return (MonthStatus.NONE.equals(bankInput) || bankInput == null)
|
||||
&& (MonthStatus.NONE.equals(bankOutput) || bankOutput == null);
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ import java.util.List;
|
||||
@RequestMapping(path = "/record/income")
|
||||
public class DailyIncomeUIController {
|
||||
private final UICodeListPortIn uiCodeListPortIn;
|
||||
private final DailyRecordPortIn dailyRecordService;
|
||||
private final DailyRecordPortIn dailyRecordPortIn;
|
||||
private final DailyIncomePortIn dailyIncomePortIn;
|
||||
|
||||
/**
|
||||
@@ -37,7 +37,6 @@ public class DailyIncomeUIController {
|
||||
* @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
|
||||
@@ -66,7 +65,6 @@ public class DailyIncomeUIController {
|
||||
* @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
|
||||
@@ -102,13 +100,12 @@ public class DailyIncomeUIController {
|
||||
*
|
||||
* @param searchMonth 검색 월(yyyyMM)
|
||||
* @param groupNo 검색 그룹
|
||||
* @return
|
||||
*/
|
||||
private DailyRecordDto vaildGetDailyRecord(String searchMonth, String groupNo) {
|
||||
DailyUIReqVO reqVO = new DailyUIReqVO(searchMonth, groupNo);
|
||||
log.debug("getRecordUIReq: {}", reqVO);
|
||||
|
||||
DailyRecordDto dailyRecord = dailyRecordService.detail(reqVO);
|
||||
DailyRecordDto dailyRecord = dailyRecordPortIn.detail(reqVO);
|
||||
if (dailyRecord == null || dailyRecord.getId() == null) {
|
||||
throw new NoRecordDataException();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package app.module.front.usecase.daily.power.adapters.persistence;
|
||||
|
||||
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
|
||||
import app.module.front.usecase.daily.power.adapters.persistence.model.DailyPowerDto;
|
||||
import app.module.front.usecase.daily.power.ports.DailyPowerPortOut;
|
||||
import app.module.front.usecase.daily.power.ports.application.domain.CreateDailyPowerCmd;
|
||||
import app.module.front.usecase.daily.power.ports.application.domain.GetDailyPowerCmd;
|
||||
import app.module.front.usecase.daily.power.ports.application.domain.RemoveDailyPowerCmd;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DailyPowerDao implements DailyPowerPortOut {
|
||||
private final UICodeListPortIn uiCodeListPortIn;
|
||||
private final DailyPowerMapper dailyPowerMapper;
|
||||
|
||||
@Override
|
||||
public List<DailyPowerDto> list(GetDailyPowerCmd command) {
|
||||
return dailyPowerMapper.getDailyPowerList(command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(GetDailyPowerCmd findCmd, CreateDailyPowerCmd command) {
|
||||
Integer existCount = dailyPowerMapper.getRecordExistCount(findCmd);
|
||||
if (existCount == 0) {
|
||||
dailyPowerMapper.createDailyPower(command);
|
||||
|
||||
log.debug("[CreateDailyPower] record={}", command);
|
||||
} else {
|
||||
dailyPowerMapper.updateDailyPower(command);
|
||||
|
||||
log.debug("[UpdateDailyPower] record={}", command);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(GetDailyPowerCmd findCmd, RemoveDailyPowerCmd command) {
|
||||
Integer existCount = dailyPowerMapper.getRecordExistCount(findCmd);
|
||||
if (existCount != 0) {
|
||||
dailyPowerMapper.removeDailyPower(command);
|
||||
|
||||
log.debug("[RemoveDailyPower] record={}", command);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package app.module.front.usecase.daily.power.adapters.persistence;
|
||||
|
||||
import app.module.front.usecase.daily.power.ports.application.domain.CreateDailyPowerCmd;
|
||||
import app.module.front.usecase.daily.power.adapters.persistence.model.DailyPowerDto;
|
||||
import app.module.front.usecase.daily.power.ports.application.domain.GetDailyPowerCmd;
|
||||
import app.module.front.usecase.daily.power.ports.application.domain.RemoveDailyPowerCmd;
|
||||
import app.module.front.usecase.daily.power.adapters.web.model.DailyPowerUIReqVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface DailyPowerMapper {
|
||||
/**
|
||||
* 일계부 동력 사용시간 목록 조회
|
||||
*
|
||||
* @param command 검색 조건
|
||||
* @return 동력 사용시간 목록
|
||||
*/
|
||||
List<DailyPowerDto> getDailyPowerList(GetDailyPowerCmd command);
|
||||
|
||||
/**
|
||||
* 일계부 동력 사용시간 데이터 존재 여부
|
||||
*
|
||||
* @param command 검색 조건
|
||||
* @return 중복 개수
|
||||
*/
|
||||
Integer getRecordExistCount(GetDailyPowerCmd command);
|
||||
|
||||
/**
|
||||
* 일계부 동력 사용시간 등록
|
||||
*
|
||||
* @param command 등록 데이터
|
||||
*/
|
||||
void createDailyPower(CreateDailyPowerCmd command);
|
||||
|
||||
/**
|
||||
* 일계부 동력 사용시간 수정
|
||||
*
|
||||
* @param command 수정 데이터
|
||||
*/
|
||||
void updateDailyPower(CreateDailyPowerCmd command);
|
||||
|
||||
/**
|
||||
* 일계부 동력 사용시간 삭제
|
||||
*
|
||||
* @param command 삭제 데이터
|
||||
*/
|
||||
void removeDailyPower(RemoveDailyPowerCmd command);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package app.module.front.usecase.daily.power.adapters.persistence.model;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class DailyPowerDto {
|
||||
private Long id;
|
||||
private Long dailyRecordSeq;
|
||||
private String equipmentName;
|
||||
private Integer ownedHours;
|
||||
private Integer leasedHours;
|
||||
|
||||
/**
|
||||
* 수정 가능 여부
|
||||
* @return true=가능, false=불가능(등록 상태)
|
||||
*/
|
||||
public boolean isUpdated() {
|
||||
return this.id != null && this.id != 0L;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
package app.module.front.usecase.daily.power.adapters.web;
|
||||
|
||||
import app.module.core.config.application.exception.NoRecordDataException;
|
||||
import app.module.core.config.application.util.CoreUtil;
|
||||
import app.module.front.usecase.daily.power.adapters.web.model.CreateDailyPowerReqVO;
|
||||
import app.module.front.usecase.daily.power.adapters.web.model.RemoveDailyPowerReqVO;
|
||||
import app.module.front.usecase.daily.power.adapters.web.validator.CreateDailyPowerValidator;
|
||||
import app.module.front.usecase.daily.power.ports.DailyPowerPortIn;
|
||||
import app.module.front.usecase.daily.record.adapters.persistence.model.DailyRecordDto;
|
||||
import app.module.front.usecase.daily.record.adapters.web.model.DailyUIReqVO;
|
||||
import app.module.front.usecase.daily.record.ports.DailyRecordPortIn;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping(path = "/api/record/power")
|
||||
public class DailyPowerController {
|
||||
private final CoreUtil coreUtil;
|
||||
private final DailyRecordPortIn dailyRecordService;
|
||||
private final DailyPowerPortIn dailyPowerService;
|
||||
private final CreateDailyPowerValidator createDailyPowerValidator;
|
||||
|
||||
/**
|
||||
* 일계부 동력 사용시간 등록 처리
|
||||
*
|
||||
* @param searchMonth 검색 월(yyyyMM)
|
||||
* @param groupNo 검색 그룹
|
||||
* @param id 수입 일련번호
|
||||
* @param formVO 입력 데이터
|
||||
* @param bindingResult BindingResult
|
||||
*/
|
||||
@PostMapping(path = "/{searchMonth}/{groupNo}/form/{id}")
|
||||
ResponseEntity<?> create(@PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo
|
||||
, @PathVariable("id") String id
|
||||
, @Valid @RequestBody CreateDailyPowerReqVO formVO, BindingResult bindingResult) {
|
||||
|
||||
createDailyPowerValidator.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);
|
||||
|
||||
dailyPowerService.create(formVO);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(formVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 일계부 동력 사용시간 삭제 처리
|
||||
*
|
||||
* @param searchMonth 검색 월(yyyyMM)
|
||||
* @param groupNo 검색 그룹
|
||||
* @param formVO 입력 데이터
|
||||
* @param bindingResult BindingResult
|
||||
*/
|
||||
@PostMapping(path = "/{searchMonth}/{groupNo}/remove")
|
||||
ResponseEntity<?> remove(@PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo
|
||||
, @Valid @RequestBody RemoveDailyPowerReqVO 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);
|
||||
|
||||
dailyPowerService.remove(formVO);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(formVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 일계부 동력 사용시간 전체 삭제 처리
|
||||
*
|
||||
* @param searchMonth 검색 월(yyyyMM)
|
||||
* @param groupNo 검색 그룹
|
||||
*/
|
||||
@PostMapping(path = "/{searchMonth}/{groupNo}/reset")
|
||||
ResponseEntity<?> removeAll(@PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo) {
|
||||
|
||||
DailyRecordDto dailyRecord = this.vaildGetDailyRecord(searchMonth, groupNo);
|
||||
|
||||
RemoveDailyPowerReqVO formVO = new RemoveDailyPowerReqVO();
|
||||
formVO.setSearchMonth(dailyRecord.getRecordMonth());
|
||||
formVO.setGroupNo(dailyRecord.getGroupNo());
|
||||
formVO.setDailyRecordSeq(dailyRecord.getId());
|
||||
log.debug("formVO: {}", formVO);
|
||||
|
||||
dailyPowerService.remove(formVO);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(formVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 일계부 유효성 체크 및 데이터 조회
|
||||
*
|
||||
* @param searchMonth 검색 월(yyyyMM)
|
||||
* @param groupNo 검색 그룹
|
||||
*/
|
||||
private DailyRecordDto vaildGetDailyRecord(String searchMonth, String groupNo) {
|
||||
DailyUIReqVO reqVO = new DailyUIReqVO(searchMonth, groupNo);
|
||||
log.debug("getRecordUIReq: {}", reqVO);
|
||||
|
||||
DailyRecordDto dailyRecord = dailyRecordService.detail(reqVO);
|
||||
if (dailyRecord == null || dailyRecord.getId() == null) {
|
||||
throw new NoRecordDataException();
|
||||
}
|
||||
|
||||
return dailyRecord;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package app.module.front.usecase.daily.power.adapters.web;
|
||||
|
||||
import app.module.core.config.application.exception.NoRecordDataException;
|
||||
import app.module.front.usecase.daily.power.adapters.persistence.model.DailyPowerDto;
|
||||
import app.module.front.usecase.daily.power.adapters.web.model.DailyPowerUIReqVO;
|
||||
import app.module.front.usecase.daily.power.ports.DailyPowerPortIn;
|
||||
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;
|
||||
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.springframework.web.bind.annotation.RequestParam;
|
||||
import org.thymeleaf.util.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping(path = "/record/power")
|
||||
public class DailyPowerUIController {
|
||||
private final DailyRecordPortIn dailyRecordPortIn;
|
||||
private final DailyPowerPortIn dailyPowerPortIn;
|
||||
|
||||
/**
|
||||
* 일계부 동력 사용시간 목록 화면
|
||||
*
|
||||
* @param model Model
|
||||
* @param searchMonth 검색 월(yyyyMM)
|
||||
* @param groupNo 검색 그룹
|
||||
* @param searchType 수정여부
|
||||
*/
|
||||
@GetMapping(path = "/{searchMonth}/{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);
|
||||
|
||||
DailyPowerUIReqVO reqVO = new DailyPowerUIReqVO(searchMonth, groupNo);
|
||||
log.debug("reqVO: {}", reqVO);
|
||||
|
||||
List<DailyPowerDto> powerList = dailyPowerPortIn.list(reqVO);
|
||||
|
||||
model.addAttribute("reqVO", reqVO);
|
||||
model.addAttribute("dailyRecord", dailyRecord);
|
||||
model.addAttribute("powerList", powerList);
|
||||
model.addAttribute("moveStep", !"update".equals(searchType));
|
||||
model.addAttribute("nextStep", dailyRecord.getNextStep(DailySort.POWER));
|
||||
|
||||
return "record/power/index";
|
||||
}
|
||||
|
||||
/**
|
||||
* 일계부 동력 사용시간 등록 화면
|
||||
*
|
||||
* @param model Model
|
||||
* @param searchMonth 검색 월(yyyyMM)
|
||||
* @param groupNo 검색 그룹
|
||||
* @param id 수입 일련번호
|
||||
*/
|
||||
@GetMapping(path = "/{searchMonth}/{groupNo}/form/{id}")
|
||||
public String formBySelf(Model model, @PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo
|
||||
, @PathVariable("id") String id) {
|
||||
|
||||
DailyPowerUIReqVO reqVO = new DailyPowerUIReqVO(searchMonth, groupNo);
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
reqVO.setId(0L);
|
||||
} else {
|
||||
reqVO.setId(Long.parseLong(id));
|
||||
}
|
||||
log.debug("reqVO: {}", reqVO);
|
||||
|
||||
DailyPowerDto detail = new DailyPowerDto();
|
||||
if (reqVO.getId() != 0L) {
|
||||
detail = dailyPowerPortIn.detail(reqVO);
|
||||
if (detail == null || !detail.isUpdated()) {
|
||||
throw new NoRecordDataException();
|
||||
}
|
||||
}
|
||||
|
||||
model.addAttribute("reqVO", reqVO);
|
||||
model.addAttribute("detail", detail);
|
||||
|
||||
return "record/power/form";
|
||||
}
|
||||
|
||||
/**
|
||||
* 일계부 유효성 체크 및 데이터 조회
|
||||
*
|
||||
* @param searchMonth 검색 월(yyyyMM)
|
||||
* @param groupNo 검색 그룹
|
||||
*/
|
||||
private DailyRecordDto vaildGetDailyRecord(String searchMonth, String groupNo) {
|
||||
DailyUIReqVO reqVO = new DailyUIReqVO(searchMonth, groupNo);
|
||||
log.debug("getRecordUIReq: {}", reqVO);
|
||||
|
||||
DailyRecordDto dailyRecord = dailyRecordPortIn.detail(reqVO);
|
||||
if (dailyRecord == null || dailyRecord.getId() == null) {
|
||||
throw new NoRecordDataException();
|
||||
}
|
||||
|
||||
return dailyRecord;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package app.module.front.usecase.daily.power.adapters.web.model;
|
||||
|
||||
import app.module.front.usecase.daily.record.adapters.web.model.DailyUIReqVO;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString(callSuper = true)
|
||||
public class CreateDailyPowerReqVO extends DailyUIReqVO {
|
||||
/**
|
||||
* 동력 사용시간 일련번호
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 일계부 일련번호
|
||||
*/
|
||||
private Long dailyRecordSeq;
|
||||
|
||||
/**
|
||||
* 명칭
|
||||
*/
|
||||
@NotBlank(message = "사용 기계 이름을 입력해 주세요.")
|
||||
private String equipmentName;
|
||||
/**
|
||||
* 자가 사용시간
|
||||
*/
|
||||
private Integer ownedHours;
|
||||
/**
|
||||
* 임차 사용시간
|
||||
*/
|
||||
private Integer leasedHours;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package app.module.front.usecase.daily.power.adapters.web.model;
|
||||
|
||||
import app.module.front.usecase.daily.record.adapters.web.model.DailyUIReqVO;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.apache.tika.utils.StringUtils;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString(callSuper = true)
|
||||
public class DailyPowerUIReqVO extends DailyUIReqVO {
|
||||
public DailyPowerUIReqVO(String month, String no) {
|
||||
setSearchMonth(month);
|
||||
if (!StringUtils.isBlank(no)) {
|
||||
setGroupNo(Integer.parseInt(no));
|
||||
}
|
||||
}
|
||||
|
||||
public DailyPowerUIReqVO(String month, Integer no) {
|
||||
setSearchMonth(month);
|
||||
setGroupNo(no);
|
||||
}
|
||||
|
||||
/**
|
||||
* 수입 일련번호
|
||||
*/
|
||||
private Long id;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package app.module.front.usecase.daily.power.adapters.web.model;
|
||||
|
||||
import app.module.front.usecase.daily.record.adapters.web.model.DailyUIReqVO;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString(callSuper = true)
|
||||
public class RemoveDailyPowerReqVO extends DailyUIReqVO {
|
||||
/**
|
||||
* 수입 일련번호
|
||||
*/
|
||||
@NotBlank(message = "{valid.common.required}")
|
||||
private String id;
|
||||
/**
|
||||
* 일계부 일련번호
|
||||
*/
|
||||
private Long dailyRecordSeq;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package app.module.front.usecase.daily.power.adapters.web.validator;
|
||||
|
||||
import app.module.front.usecase.daily.power.adapters.web.model.CreateDailyPowerReqVO;
|
||||
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 CreateDailyPowerValidator implements Validator {
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> clazz) {
|
||||
return CreateDailyPowerReqVO.class.equals(clazz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(Object target, Errors errors) {
|
||||
CreateDailyPowerReqVO vo = (CreateDailyPowerReqVO) target;
|
||||
|
||||
if (vo.getOwnedHours() == null && vo.getLeasedHours() == null) {
|
||||
errors.rejectValue(
|
||||
"ownedHours", "valid.common.required",
|
||||
"자가 또는 임차 사용시간을 입력 해주세요.");
|
||||
errors.rejectValue(
|
||||
"leasedHours", "valid.common.required",
|
||||
"자가 또는 임차 사용시간을 입력 해주세요.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package app.module.front.usecase.daily.power.ports;
|
||||
|
||||
|
||||
import app.module.front.usecase.daily.power.adapters.persistence.model.DailyPowerDto;
|
||||
import app.module.front.usecase.daily.power.adapters.web.model.CreateDailyPowerReqVO;
|
||||
import app.module.front.usecase.daily.power.adapters.web.model.DailyPowerUIReqVO;
|
||||
import app.module.front.usecase.daily.power.adapters.web.model.RemoveDailyPowerReqVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface DailyPowerPortIn {
|
||||
/**
|
||||
* 일계부 동력 사용시간 조회
|
||||
*
|
||||
* @param reqVO 검색 조건
|
||||
* @return 동력 사용시간 목록
|
||||
*/
|
||||
List<DailyPowerDto> list(DailyPowerUIReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 일계부 동력 사용시간 조회
|
||||
*
|
||||
* @param reqVO 검색 조건
|
||||
* @return 동력 사용시간 상세
|
||||
*/
|
||||
DailyPowerDto detail(DailyPowerUIReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 일계부 동력 사용시간 등록
|
||||
*
|
||||
* @param formVO 입력 데이터
|
||||
*/
|
||||
void create(CreateDailyPowerReqVO formVO);
|
||||
|
||||
/**
|
||||
* 일계부 동력 사용시간 삭제
|
||||
*
|
||||
* @param formVO 삭제 검색 조건
|
||||
*/
|
||||
void remove(RemoveDailyPowerReqVO formVO);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package app.module.front.usecase.daily.power.ports;
|
||||
|
||||
|
||||
import app.module.front.usecase.daily.power.adapters.persistence.model.DailyPowerDto;
|
||||
import app.module.front.usecase.daily.power.ports.application.domain.CreateDailyPowerCmd;
|
||||
import app.module.front.usecase.daily.power.ports.application.domain.GetDailyPowerCmd;
|
||||
import app.module.front.usecase.daily.power.ports.application.domain.RemoveDailyPowerCmd;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface DailyPowerPortOut {
|
||||
/**
|
||||
* 일계부 동력 사용시간 조회
|
||||
*
|
||||
* @param command 검색 조건
|
||||
* @return 동력 사용시간 목록
|
||||
*/
|
||||
List<DailyPowerDto> list(GetDailyPowerCmd command);
|
||||
|
||||
/**
|
||||
* 일계부 동력 사용시간 등록
|
||||
*
|
||||
* @param findCmd 검색 조건
|
||||
* @param command 입력 데이터
|
||||
*/
|
||||
void create(GetDailyPowerCmd findCmd, CreateDailyPowerCmd command);
|
||||
|
||||
/**
|
||||
* 일계부 동력 사용시간 삭제
|
||||
*
|
||||
* @param findCmd 검색 조건
|
||||
* @param command 삭제 검색 조건
|
||||
*/
|
||||
void remove(GetDailyPowerCmd findCmd, RemoveDailyPowerCmd command);
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package app.module.front.usecase.daily.power.ports.application;
|
||||
|
||||
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
|
||||
import app.module.core.usecase.uicode.list.ports.application.domain.UICodeElement;
|
||||
import app.module.front.config.application.util.AuditUtil;
|
||||
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 app.module.front.usecase.daily.power.adapters.persistence.model.DailyPowerDto;
|
||||
import app.module.front.usecase.daily.power.adapters.web.model.CreateDailyPowerReqVO;
|
||||
import app.module.front.usecase.daily.power.adapters.web.model.DailyPowerUIReqVO;
|
||||
import app.module.front.usecase.daily.power.adapters.web.model.RemoveDailyPowerReqVO;
|
||||
import app.module.front.usecase.daily.power.ports.DailyPowerPortIn;
|
||||
import app.module.front.usecase.daily.power.ports.DailyPowerPortOut;
|
||||
import app.module.front.usecase.daily.power.ports.application.domain.CreateDailyPowerCmd;
|
||||
import app.module.front.usecase.daily.power.ports.application.domain.GetDailyPowerCmd;
|
||||
import app.module.front.usecase.daily.power.ports.application.domain.RemoveDailyPowerCmd;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DailyPowerService implements DailyPowerPortIn {
|
||||
private final DailyPowerPortOut portOut;
|
||||
private final UICodeListPortIn uiCodeListPortIn;
|
||||
|
||||
@Override
|
||||
public List<DailyPowerDto> list(DailyPowerUIReqVO reqVO) {
|
||||
return this.getRefineList(reqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DailyPowerDto detail(DailyPowerUIReqVO reqVO) {
|
||||
List<DailyPowerDto> list = this.getRefineList(reqVO);
|
||||
if (list.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return list.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록 데이터 조회
|
||||
*
|
||||
* @param reqVO 검색 조건
|
||||
* @return 공통 처리된 목록
|
||||
*/
|
||||
private List<DailyPowerDto> getRefineList(DailyPowerUIReqVO reqVO) {
|
||||
return portOut.list(new GetDailyPowerCmd(reqVO.getSearchMonth(),
|
||||
reqVO.getGroupNo(),
|
||||
reqVO.getHouseholdSeq(),
|
||||
reqVO.getId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(CreateDailyPowerReqVO formVO) {
|
||||
GetDailyPowerCmd findCmd = new GetDailyPowerCmd(
|
||||
formVO.getSearchMonth(),
|
||||
formVO.getGroupNo(),
|
||||
formVO.getHouseholdSeq(),
|
||||
formVO.getId());
|
||||
|
||||
CreateDailyPowerCmd command = AuditUtil.create(
|
||||
new CreateDailyPowerCmd(
|
||||
formVO.getId(),
|
||||
formVO.getDailyRecordSeq(),
|
||||
null,
|
||||
null,
|
||||
formVO.getEquipmentName(),
|
||||
formVO.getOwnedHours(),
|
||||
formVO.getLeasedHours()));
|
||||
|
||||
portOut.create(findCmd, command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(RemoveDailyPowerReqVO formVO) {
|
||||
Long id = formVO.getId() != null ? Long.parseLong(formVO.getId()) : null;
|
||||
|
||||
GetDailyPowerCmd findCmd = new GetDailyPowerCmd(
|
||||
formVO.getSearchMonth(),
|
||||
formVO.getGroupNo(),
|
||||
formVO.getHouseholdSeq(),
|
||||
id);
|
||||
|
||||
RemoveDailyPowerCmd command = AuditUtil.delete(
|
||||
new RemoveDailyPowerCmd(
|
||||
formVO.getSearchMonth(),
|
||||
formVO.getGroupNo(),
|
||||
id,
|
||||
formVO.getDailyRecordSeq()));
|
||||
|
||||
portOut.remove(findCmd, command);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package app.module.front.usecase.daily.power.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 CreateDailyPowerCmd extends FrontAuditCommand {
|
||||
private Long id;
|
||||
private Long dailyRecordSeq;
|
||||
private String incomeMark;
|
||||
private String expenseMark;
|
||||
private String equipmentName;
|
||||
private Integer ownedHours;
|
||||
private Integer leasedHours;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package app.module.front.usecase.daily.power.ports.application.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public class GetDailyPowerCmd {
|
||||
/**
|
||||
* 검색 월(yyyyMM)
|
||||
*/
|
||||
private String searchMonth;
|
||||
/**
|
||||
* 검색 그룸번호
|
||||
*/
|
||||
private Integer groupNo;
|
||||
/**
|
||||
* 임가 일련번호
|
||||
*/
|
||||
private Long householdSeq;
|
||||
/**
|
||||
* 동력 사용시간 일련번호
|
||||
*/
|
||||
private Long id;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package app.module.front.usecase.daily.power.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 RemoveDailyPowerCmd extends FrontAuditCommand {
|
||||
private String searchMonth;
|
||||
private Integer groupNo;
|
||||
private Long id;
|
||||
private Long dailyRecordSeq;
|
||||
}
|
||||
@@ -52,10 +52,6 @@ public class DailyRecordDto {
|
||||
}
|
||||
}
|
||||
|
||||
if (returnValue == null) {
|
||||
returnValue = "LAST";
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
package app.module.front.usecase.daily.record.adapters.web;
|
||||
|
||||
import app.module.core.config.application.exception.NoMatchingURIException;
|
||||
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.income.adapters.persistence.model.DailyIncomeDto;
|
||||
import app.module.front.usecase.daily.income.adapters.web.model.DailyIncomeUIReqVO;
|
||||
import app.module.front.usecase.daily.income.ports.DailyIncomePortIn;
|
||||
import app.module.front.usecase.daily.power.adapters.web.model.DailyPowerUIReqVO;
|
||||
import app.module.front.usecase.daily.power.ports.DailyPowerPortIn;
|
||||
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;
|
||||
@@ -14,13 +21,17 @@ 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/daily")
|
||||
public class DailyRecordUIController {
|
||||
private final DailyRecordPortIn dailyRecordPortIn;
|
||||
private final CreateDailyRecordValidator createDailyRecordValidator;
|
||||
private final DailyIncomePortIn dailyIncomePortIn;
|
||||
private final DailyExpensePortIn dailyExpensePortIn;
|
||||
private final DailyPowerPortIn dailyPowerPortIn;
|
||||
|
||||
/**
|
||||
* 일계부 항목 등록 화면
|
||||
@@ -69,6 +80,13 @@ public class DailyRecordUIController {
|
||||
String modelAndView = "record/daily/done";
|
||||
if (DailyStatus.TODAY_NONE.equals(dailyRecord.getAllStatus())) {
|
||||
modelAndView = "record/daily/finish";
|
||||
} else {
|
||||
model.addAttribute("incomeList", dailyIncomePortIn.list(new DailyIncomeUIReqVO(searchMonth, groupNo)));
|
||||
model.addAttribute("expenseList", dailyExpensePortIn.list(new DailyExpenseUIReqVO(searchMonth, groupNo)));
|
||||
model.addAttribute("workList", null); // TODO
|
||||
model.addAttribute("powerList", dailyPowerPortIn.list(new DailyPowerUIReqVO(searchMonth, groupNo)));
|
||||
model.addAttribute("forestryList", null); // TODO
|
||||
model.addAttribute("farmingList", null); // TODO
|
||||
}
|
||||
|
||||
model.addAttribute("reqVO", reqVO);
|
||||
|
||||
Reference in New Issue
Block a user