[FO] 일계부 동력 사용시간 CRUD, 일계부 공통 수정
This commit is contained in:
@@ -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