[FO] 일계부 자가임업 CRUD, 공통 수정
This commit is contained in:
@@ -25,7 +25,7 @@ public class DailyExpenseController {
|
||||
private final CoreUtil coreUtil;
|
||||
private final DailyRecordPortIn dailyRecordService;
|
||||
private final DailyExpensePortIn dailyExpensePortIn;
|
||||
private final CreateDailyExpenseValidator createDailyExpenseValidator;
|
||||
private final CreateDailyExpenseValidator createValidator;
|
||||
|
||||
/**
|
||||
* 일계부 지출 등록 처리
|
||||
@@ -35,14 +35,13 @@ public class DailyExpenseController {
|
||||
* @param id 수입 일련번호
|
||||
* @param formVO 입력 데이터
|
||||
* @param bindingResult BindingResult
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(path = "/{searchMonth}/{groupNo}/form/{id}")
|
||||
ResponseEntity<?> create(@PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo
|
||||
, @PathVariable("id") String id
|
||||
, @Valid @RequestBody CreateDailyExpenseReqVO formVO, BindingResult bindingResult) {
|
||||
|
||||
createDailyExpenseValidator.validate(formVO, bindingResult);
|
||||
createValidator.validate(formVO, bindingResult);
|
||||
if (bindingResult.hasErrors()) {
|
||||
return coreUtil.getErrorInfo(bindingResult);
|
||||
}
|
||||
@@ -67,7 +66,6 @@ public class DailyExpenseController {
|
||||
* @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 +94,6 @@ public class DailyExpenseController {
|
||||
*
|
||||
* @param searchMonth 검색 월(yyyyMM)
|
||||
* @param groupNo 검색 그룹
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(path = "/{searchMonth}/{groupNo}/reset")
|
||||
ResponseEntity<?> removeAll(@PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo) {
|
||||
@@ -119,7 +116,6 @@ public class DailyExpenseController {
|
||||
*
|
||||
* @param searchMonth 검색 월(yyyyMM)
|
||||
* @param groupNo 검색 그룹
|
||||
* @return
|
||||
*/
|
||||
private DailyRecordDto vaildGetDailyRecord(String searchMonth, String groupNo) {
|
||||
DailyUIReqVO reqVO = new DailyUIReqVO(searchMonth, groupNo);
|
||||
|
||||
@@ -37,7 +37,6 @@ public class DailyExpenseUIController {
|
||||
* @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 DailyExpenseUIController {
|
||||
* @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,7 +100,6 @@ public class DailyExpenseUIController {
|
||||
*
|
||||
* @param searchMonth 검색 월(yyyyMM)
|
||||
* @param groupNo 검색 그룹
|
||||
* @return
|
||||
*/
|
||||
private DailyRecordDto vaildGetDailyRecord(String searchMonth, String groupNo) {
|
||||
DailyUIReqVO reqVO = new DailyUIReqVO(searchMonth, groupNo);
|
||||
|
||||
@@ -12,7 +12,7 @@ import lombok.ToString;
|
||||
@ToString(callSuper = true)
|
||||
public class CreateDailyExpenseReqVO extends DailyUIReqVO {
|
||||
/**
|
||||
* 수입 일련번호
|
||||
* 지출 일련번호
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
|
||||
@@ -23,7 +23,7 @@ public class DailyExpenseUIReqVO extends DailyUIReqVO {
|
||||
}
|
||||
|
||||
/**
|
||||
* 수입 일련번호
|
||||
* 지출 일련번호
|
||||
*/
|
||||
private Long id;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import lombok.ToString;
|
||||
@ToString(callSuper = true)
|
||||
public class RemoveDailyExpenseReqVO extends DailyUIReqVO {
|
||||
/**
|
||||
* 수입 일련번호
|
||||
* 지출 일련번호
|
||||
*/
|
||||
@NotBlank(message = "{valid.common.required}")
|
||||
private String id;
|
||||
|
||||
@@ -21,7 +21,7 @@ public class GetDailyExpenseCmd {
|
||||
*/
|
||||
private Long householdSeq;
|
||||
/**
|
||||
* 수입 일련번호
|
||||
* 지출 일련번호
|
||||
*/
|
||||
private Long id;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package app.module.front.usecase.daily.forestry.adapters.persistence;
|
||||
|
||||
import app.module.front.usecase.daily.forestry.adapters.persistence.model.DailyForestryDto;
|
||||
import app.module.front.usecase.daily.forestry.ports.DailyForestryPortOut;
|
||||
import app.module.front.usecase.daily.forestry.ports.application.domain.CreateDailyForestryCmd;
|
||||
import app.module.front.usecase.daily.forestry.ports.application.domain.GetDailyForestryCmd;
|
||||
import app.module.front.usecase.daily.forestry.ports.application.domain.RemoveDailyForestryCmd;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
public class DailyForestryDao implements DailyForestryPortOut {
|
||||
private final DailyForestryMapper mapper;
|
||||
|
||||
@Override
|
||||
public List<DailyForestryDto> list(GetDailyForestryCmd command) {
|
||||
return mapper.getDailyForestryList(command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(GetDailyForestryCmd findCmd, CreateDailyForestryCmd command) {
|
||||
Integer existCount = mapper.getRecordExistCount(findCmd);
|
||||
if (existCount == 0) {
|
||||
mapper.createDailyForestry(command);
|
||||
|
||||
log.debug("[CreateDailyForestry] record={}", command);
|
||||
} else {
|
||||
mapper.updateDailyForestry(command);
|
||||
|
||||
log.debug("[UpdateDailyForestry] record={}", command);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(GetDailyForestryCmd findCmd, RemoveDailyForestryCmd command) {
|
||||
Integer existCount = mapper.getRecordExistCount(findCmd);
|
||||
if (existCount != 0) {
|
||||
mapper.removeDailyForestry(command);
|
||||
|
||||
log.debug("[RemoveDailyForestry] record={}", command);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package app.module.front.usecase.daily.forestry.adapters.persistence;
|
||||
|
||||
|
||||
import app.module.front.usecase.daily.forestry.adapters.persistence.model.DailyForestryDto;
|
||||
import app.module.front.usecase.daily.forestry.ports.application.domain.CreateDailyForestryCmd;
|
||||
import app.module.front.usecase.daily.forestry.ports.application.domain.GetDailyForestryCmd;
|
||||
import app.module.front.usecase.daily.forestry.ports.application.domain.RemoveDailyForestryCmd;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface DailyForestryMapper {
|
||||
/**
|
||||
* 일계부 자가임업 목록 조회
|
||||
*
|
||||
* @param command 검색 조건
|
||||
* @return 수입 목록
|
||||
*/
|
||||
List<DailyForestryDto> getDailyForestryList(GetDailyForestryCmd command);
|
||||
|
||||
/**
|
||||
* 일계부 자가임업 데이터 존재 여부
|
||||
*
|
||||
* @param command 검색 조건
|
||||
* @return 중복 개수
|
||||
*/
|
||||
Integer getRecordExistCount(GetDailyForestryCmd command);
|
||||
|
||||
/**
|
||||
* 일계부 자가임업 등록
|
||||
*
|
||||
* @param command 등록 데이터
|
||||
*/
|
||||
void createDailyForestry(CreateDailyForestryCmd command);
|
||||
|
||||
/**
|
||||
* 일계부 자가임업 수정
|
||||
*
|
||||
* @param command 수정 데이터
|
||||
*/
|
||||
void updateDailyForestry(CreateDailyForestryCmd command);
|
||||
|
||||
/**
|
||||
* 일계부 자가임업 삭제
|
||||
*
|
||||
* @param command 삭제 데이터
|
||||
*/
|
||||
void removeDailyForestry(RemoveDailyForestryCmd command);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package app.module.front.usecase.daily.forestry.adapters.persistence.model;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class DailyForestryDto {
|
||||
private Long id;
|
||||
private Long dailyRecordSeq;
|
||||
private String productName;
|
||||
private String usage;
|
||||
private String quantity;
|
||||
private String unitCode;
|
||||
private String unitLabel;
|
||||
private String unitSelf;
|
||||
private Integer estimatedValue;
|
||||
|
||||
/**
|
||||
* 수정 가능 여부
|
||||
* @return true=가능, false=불가능(등록 상태)
|
||||
*/
|
||||
public boolean isUpdated() {
|
||||
return this.id != null && this.id != 0L;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
package app.module.front.usecase.daily.forestry.adapters.web;
|
||||
|
||||
import app.module.core.config.application.exception.NoRecordDataException;
|
||||
import app.module.core.config.application.util.CoreUtil;
|
||||
import app.module.front.usecase.daily.forestry.adapters.web.model.CreateDailyForestryReqVO;
|
||||
import app.module.front.usecase.daily.forestry.adapters.web.model.RemoveDailyForestryReqVO;
|
||||
import app.module.front.usecase.daily.forestry.adapters.web.validator.CreateDailyForestryValidator;
|
||||
import app.module.front.usecase.daily.forestry.ports.DailyForestryPortIn;
|
||||
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/forestry")
|
||||
public class DailyForestryController {
|
||||
private final CoreUtil coreUtil;
|
||||
private final DailyRecordPortIn dailyRecordService;
|
||||
private final DailyForestryPortIn dailyForestryPortIn;
|
||||
private final CreateDailyForestryValidator createValidator;
|
||||
|
||||
/**
|
||||
* 일계부 자가임업 등록 처리
|
||||
*
|
||||
* @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 CreateDailyForestryReqVO formVO, BindingResult bindingResult) {
|
||||
|
||||
createValidator.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);
|
||||
|
||||
dailyForestryPortIn.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 RemoveDailyForestryReqVO 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);
|
||||
|
||||
dailyForestryPortIn.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);
|
||||
|
||||
RemoveDailyForestryReqVO formVO = new RemoveDailyForestryReqVO();
|
||||
formVO.setSearchMonth(dailyRecord.getRecordMonth());
|
||||
formVO.setGroupNo(dailyRecord.getGroupNo());
|
||||
formVO.setDailyRecordSeq(dailyRecord.getId());
|
||||
log.debug("formVO: {}", formVO);
|
||||
|
||||
dailyForestryPortIn.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,115 @@
|
||||
package app.module.front.usecase.daily.forestry.adapters.web;
|
||||
|
||||
import app.module.core.config.application.exception.NoRecordDataException;
|
||||
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
|
||||
import app.module.front.usecase.daily.forestry.adapters.persistence.model.DailyForestryDto;
|
||||
import app.module.front.usecase.daily.forestry.adapters.web.model.DailyForestryUIReqVO;
|
||||
import app.module.front.usecase.daily.forestry.ports.DailyForestryPortIn;
|
||||
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/forestry")
|
||||
public class DailyForestryUIController {
|
||||
private final UICodeListPortIn uiCodeListPortIn;
|
||||
private final DailyRecordPortIn dailyRecordPortIn;
|
||||
private final DailyForestryPortIn dailyForestryPortIn;
|
||||
|
||||
/**
|
||||
* 일계부 자가임업 목록 화면
|
||||
*
|
||||
* @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);
|
||||
|
||||
DailyForestryUIReqVO reqVO = new DailyForestryUIReqVO(searchMonth, groupNo);
|
||||
log.debug("reqVO: {}", reqVO);
|
||||
|
||||
List<DailyForestryDto> forestryList = dailyForestryPortIn.list(reqVO);
|
||||
|
||||
model.addAttribute("reqVO", reqVO);
|
||||
model.addAttribute("dailyRecord", dailyRecord);
|
||||
model.addAttribute("forestryList", forestryList);
|
||||
model.addAttribute("moveStep", !"update".equals(searchType));
|
||||
model.addAttribute("nextStep", dailyRecord.getNextStep(DailySort.FORESTRY));
|
||||
|
||||
return "record/forestry/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) {
|
||||
|
||||
DailyForestryUIReqVO reqVO = new DailyForestryUIReqVO(searchMonth, groupNo);
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
reqVO.setId(0L);
|
||||
} else {
|
||||
reqVO.setId(Long.parseLong(id));
|
||||
}
|
||||
log.debug("reqVO: {}", reqVO);
|
||||
|
||||
DailyForestryDto detail = new DailyForestryDto();
|
||||
if (reqVO.getId() != 0L) {
|
||||
detail = dailyForestryPortIn.detail(reqVO);
|
||||
if (detail == null || !detail.isUpdated()) {
|
||||
throw new NoRecordDataException();
|
||||
}
|
||||
}
|
||||
|
||||
model.addAttribute("recordCrop", uiCodeListPortIn.connect("code.record.crop"));
|
||||
model.addAttribute("recordUnit", uiCodeListPortIn.connect("code.record.unit"));
|
||||
|
||||
model.addAttribute("reqVO", reqVO);
|
||||
model.addAttribute("detail", detail);
|
||||
|
||||
return "record/forestry/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,46 @@
|
||||
package app.module.front.usecase.daily.forestry.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 CreateDailyForestryReqVO extends DailyUIReqVO {
|
||||
/**
|
||||
* 자가임업 일련번호
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 일계부 일련번호
|
||||
*/
|
||||
private Long dailyRecordSeq;
|
||||
/**
|
||||
* 생산물
|
||||
*/
|
||||
@NotBlank(message = "생산물을 입력해 주세요.")
|
||||
private String productName;
|
||||
/**
|
||||
* 용도
|
||||
*/
|
||||
private String usage;
|
||||
/**
|
||||
* 수량
|
||||
*/
|
||||
private Double quantity;
|
||||
/**
|
||||
* 단위 코드
|
||||
*/
|
||||
private String unitCode;
|
||||
/**
|
||||
* 단위 직접 입력
|
||||
*/
|
||||
private String unitSelf;
|
||||
/**
|
||||
* 현물평가액
|
||||
*/
|
||||
private Integer estimatedValue;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package app.module.front.usecase.daily.forestry.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 DailyForestryUIReqVO extends DailyUIReqVO {
|
||||
public DailyForestryUIReqVO(String month, String no) {
|
||||
setSearchMonth(month);
|
||||
if (!StringUtils.isBlank(no)) {
|
||||
setGroupNo(Integer.parseInt(no));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 자가임업 일련번호
|
||||
*/
|
||||
private Long id;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package app.module.front.usecase.daily.forestry.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 RemoveDailyForestryReqVO extends DailyUIReqVO {
|
||||
/**
|
||||
* 자가임업 일련번호
|
||||
*/
|
||||
@NotBlank(message = "{valid.common.required}")
|
||||
private String id;
|
||||
/**
|
||||
* 일계부 일련번호
|
||||
*/
|
||||
private Long dailyRecordSeq;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package app.module.front.usecase.daily.forestry.adapters.web.validator;
|
||||
|
||||
import app.module.front.usecase.daily.forestry.adapters.web.model.CreateDailyForestryReqVO;
|
||||
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 CreateDailyForestryValidator implements Validator {
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> clazz) {
|
||||
return CreateDailyForestryReqVO.class.equals(clazz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(Object target, Errors errors) {
|
||||
CreateDailyForestryReqVO vo = (CreateDailyForestryReqVO) target;
|
||||
|
||||
if (vo.getEstimatedValue() == null) {
|
||||
errors.rejectValue(
|
||||
"estimatedValue", "valid.common.required",
|
||||
"현물평가액을 입력해 주세요.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package app.module.front.usecase.daily.forestry.ports;
|
||||
|
||||
import app.module.front.usecase.daily.forestry.adapters.persistence.model.DailyForestryDto;
|
||||
import app.module.front.usecase.daily.forestry.adapters.web.model.CreateDailyForestryReqVO;
|
||||
import app.module.front.usecase.daily.forestry.adapters.web.model.DailyForestryUIReqVO;
|
||||
import app.module.front.usecase.daily.forestry.adapters.web.model.RemoveDailyForestryReqVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface DailyForestryPortIn {
|
||||
/**
|
||||
* 일계부 자가임업 조회
|
||||
*
|
||||
* @param reqVO 검색 조건
|
||||
* @return 자가임업 목록
|
||||
*/
|
||||
List<DailyForestryDto> list(DailyForestryUIReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 일계부 자가임업 조회
|
||||
*
|
||||
* @param reqVO 검색 조건
|
||||
* @return 자가임업 상세
|
||||
*/
|
||||
DailyForestryDto detail(DailyForestryUIReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 일계부 자가임업 등록
|
||||
*
|
||||
* @param formVO 입력 데이터
|
||||
*/
|
||||
void create(CreateDailyForestryReqVO formVO);
|
||||
|
||||
/**
|
||||
* 일계부 자가임업 삭제
|
||||
*
|
||||
* @param formVO 삭제 검색 조건
|
||||
*/
|
||||
void remove(RemoveDailyForestryReqVO formVO);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package app.module.front.usecase.daily.forestry.ports;
|
||||
|
||||
import app.module.front.usecase.daily.forestry.adapters.persistence.model.DailyForestryDto;
|
||||
import app.module.front.usecase.daily.forestry.ports.application.domain.CreateDailyForestryCmd;
|
||||
import app.module.front.usecase.daily.forestry.ports.application.domain.GetDailyForestryCmd;
|
||||
import app.module.front.usecase.daily.forestry.ports.application.domain.RemoveDailyForestryCmd;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface DailyForestryPortOut {
|
||||
/**
|
||||
* 일계부 자가임업 조회
|
||||
*
|
||||
* @param command 검색 조건
|
||||
* @return 자가임업 목록
|
||||
*/
|
||||
List<DailyForestryDto> list(GetDailyForestryCmd command);
|
||||
|
||||
/**
|
||||
* 일계부 자가임업 등록
|
||||
*
|
||||
* @param findCmd 검색 조건
|
||||
* @param command 입력 데이터
|
||||
*/
|
||||
void create(GetDailyForestryCmd findCmd, CreateDailyForestryCmd command);
|
||||
|
||||
/**
|
||||
* 일계부 자가임업 삭제
|
||||
*
|
||||
* @param findCmd 검색 조건
|
||||
* @param command 삭제 검색 조건
|
||||
*/
|
||||
void remove(GetDailyForestryCmd findCmd, RemoveDailyForestryCmd command);
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
package app.module.front.usecase.daily.forestry.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.config.constants.CommonConstants;
|
||||
import app.module.front.usecase.daily.forestry.adapters.persistence.model.DailyForestryDto;
|
||||
import app.module.front.usecase.daily.forestry.adapters.web.model.CreateDailyForestryReqVO;
|
||||
import app.module.front.usecase.daily.forestry.adapters.web.model.DailyForestryUIReqVO;
|
||||
import app.module.front.usecase.daily.forestry.adapters.web.model.RemoveDailyForestryReqVO;
|
||||
import app.module.front.usecase.daily.forestry.ports.DailyForestryPortIn;
|
||||
import app.module.front.usecase.daily.forestry.ports.DailyForestryPortOut;
|
||||
import app.module.front.usecase.daily.forestry.ports.application.domain.CreateDailyForestryCmd;
|
||||
import app.module.front.usecase.daily.forestry.ports.application.domain.GetDailyForestryCmd;
|
||||
import app.module.front.usecase.daily.forestry.ports.application.domain.RemoveDailyForestryCmd;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DailyForestryService implements DailyForestryPortIn {
|
||||
private final DailyForestryPortOut portOut;
|
||||
private final UICodeListPortIn uiCodeListPortIn;
|
||||
|
||||
@Override
|
||||
public List<DailyForestryDto> list(DailyForestryUIReqVO reqVO) {
|
||||
return this.getRefineList(reqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DailyForestryDto detail(DailyForestryUIReqVO reqVO) {
|
||||
List<DailyForestryDto> list = this.getRefineList(reqVO);
|
||||
if (list.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return list.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록 데이터 조회
|
||||
*
|
||||
* @param reqVO 검색 조건
|
||||
* @return 공통 처리된 목록
|
||||
*/
|
||||
private List<DailyForestryDto> getRefineList(DailyForestryUIReqVO reqVO) {
|
||||
List<DailyForestryDto> list = portOut.list(new GetDailyForestryCmd(reqVO.getSearchMonth(),
|
||||
reqVO.getGroupNo(),
|
||||
reqVO.getHouseholdSeq(),
|
||||
reqVO.getId()));
|
||||
|
||||
List<UICodeElement> recordUnit = uiCodeListPortIn.connect("code.record.unit");
|
||||
|
||||
for (DailyForestryDto dto : list) {
|
||||
if (CommonConstants.UNIT_CODE_SELF.equals(dto.getUnitCode())) {
|
||||
dto.setUnitLabel(dto.getUnitSelf());
|
||||
} else {
|
||||
dto.setUnitLabel(this.getCodeLabel(dto.getUnitCode(), recordUnit));
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 코드명 조회
|
||||
*
|
||||
* @param codeId 코드
|
||||
* @param codeList 공통 코드 목록
|
||||
* @return 코드명
|
||||
*/
|
||||
private String getCodeLabel(String codeId, List<UICodeElement> codeList) {
|
||||
String returnValue = null;
|
||||
for (UICodeElement codeSetup : codeList) {
|
||||
if (codeSetup.getId().equalsIgnoreCase(codeId)) {
|
||||
returnValue = codeSetup.getCodeText();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(CreateDailyForestryReqVO formVO) {
|
||||
GetDailyForestryCmd findCmd = new GetDailyForestryCmd(
|
||||
formVO.getSearchMonth(),
|
||||
formVO.getGroupNo(),
|
||||
formVO.getHouseholdSeq(),
|
||||
formVO.getId());
|
||||
|
||||
CreateDailyForestryCmd command = AuditUtil.create(
|
||||
new CreateDailyForestryCmd(
|
||||
formVO.getId(),
|
||||
formVO.getDailyRecordSeq(),
|
||||
"81011", // [정책] 81011 고정
|
||||
formVO.getProductName(),
|
||||
formVO.getUsage(),
|
||||
formVO.getQuantity(),
|
||||
formVO.getUnitCode(),
|
||||
formVO.getUnitSelf(),
|
||||
formVO.getEstimatedValue()));
|
||||
|
||||
portOut.create(findCmd, command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(RemoveDailyForestryReqVO formVO) {
|
||||
Long id = formVO.getId() != null ? Long.parseLong(formVO.getId()) : null;
|
||||
|
||||
GetDailyForestryCmd findCmd = new GetDailyForestryCmd(
|
||||
formVO.getSearchMonth(),
|
||||
formVO.getGroupNo(),
|
||||
formVO.getHouseholdSeq(),
|
||||
id);
|
||||
|
||||
RemoveDailyForestryCmd command = AuditUtil.delete(
|
||||
new RemoveDailyForestryCmd(
|
||||
formVO.getSearchMonth(),
|
||||
formVO.getGroupNo(),
|
||||
id,
|
||||
formVO.getDailyRecordSeq()));
|
||||
|
||||
portOut.remove(findCmd, command);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package app.module.front.usecase.daily.forestry.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 CreateDailyForestryCmd extends FrontAuditCommand {
|
||||
private Long id;
|
||||
private Long dailyRecordSeq;
|
||||
private String expenseMark;
|
||||
private String productName;
|
||||
private String usage;
|
||||
private Double quantity;
|
||||
private String unitCode;
|
||||
private String unitSelf;
|
||||
private Integer estimatedValue;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package app.module.front.usecase.daily.forestry.ports.application.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public class GetDailyForestryCmd {
|
||||
/**
|
||||
* 검색 월(yyyyMM)
|
||||
*/
|
||||
private String searchMonth;
|
||||
/**
|
||||
* 검색 그룸번호
|
||||
*/
|
||||
private Integer groupNo;
|
||||
/**
|
||||
* 임가 일련번호
|
||||
*/
|
||||
private Long householdSeq;
|
||||
/**
|
||||
* 자가임업 일련번호
|
||||
*/
|
||||
private Long id;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package app.module.front.usecase.daily.forestry.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 RemoveDailyForestryCmd extends FrontAuditCommand {
|
||||
private String searchMonth;
|
||||
private Integer groupNo;
|
||||
private Long id;
|
||||
private Long dailyRecordSeq;
|
||||
}
|
||||
@@ -7,7 +7,6 @@ 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;
|
||||
@@ -18,9 +17,6 @@ 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
|
||||
@@ -29,7 +25,7 @@ public class DailyIncomeController {
|
||||
private final CoreUtil coreUtil;
|
||||
private final DailyRecordPortIn dailyRecordPortIn;
|
||||
private final DailyIncomePortIn dailyIncomePortIn;
|
||||
private final CreateDailyIncomeValidator createDailyIncomeValidator;
|
||||
private final CreateDailyIncomeValidator createValidator;
|
||||
|
||||
/**
|
||||
* 일계부 수입 등록 처리
|
||||
@@ -45,7 +41,7 @@ public class DailyIncomeController {
|
||||
, @PathVariable("id") String id
|
||||
, @Valid @RequestBody CreateDailyIncomeReqVO formVO, BindingResult bindingResult) {
|
||||
|
||||
createDailyIncomeValidator.validate(formVO, bindingResult);
|
||||
createValidator.validate(formVO, bindingResult);
|
||||
if (bindingResult.hasErrors()) {
|
||||
return coreUtil.getErrorInfo(bindingResult);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
@RequestMapping(path = "/api/record/daily")
|
||||
public class DailyRecordController {
|
||||
private final DailyRecordPortIn dailyRecordPortIn;
|
||||
private final CreateDailyRecordValidator createDailyRecordValidator;
|
||||
private final CreateDailyRecordValidator createValidator;
|
||||
|
||||
/**
|
||||
* 일계부 항목 등록 처리
|
||||
@@ -34,7 +34,7 @@ public class DailyRecordController {
|
||||
ResponseEntity<?> create(@PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo
|
||||
, @Valid @RequestBody CreateDailyRecordReqVO formVO, BindingResult bindingResult) {
|
||||
|
||||
createDailyRecordValidator.validate(formVO, bindingResult);
|
||||
createValidator.validate(formVO, bindingResult);
|
||||
if (bindingResult.hasErrors()) {
|
||||
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
|
||||
.body(bindingResult.getFieldErrors());
|
||||
|
||||
@@ -3,6 +3,8 @@ 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.forestry.adapters.web.model.DailyForestryUIReqVO;
|
||||
import app.module.front.usecase.daily.forestry.ports.DailyForestryPortIn;
|
||||
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;
|
||||
@@ -13,6 +15,8 @@ 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;
|
||||
import app.module.front.usecase.daily.work.adapters.web.model.DailyWorkUIReqVO;
|
||||
import app.module.front.usecase.daily.work.ports.DailyWorkPortIn;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@@ -31,7 +35,9 @@ public class DailyRecordUIController {
|
||||
private final DailyRecordPortIn dailyRecordPortIn;
|
||||
private final DailyIncomePortIn dailyIncomePortIn;
|
||||
private final DailyExpensePortIn dailyExpensePortIn;
|
||||
private final DailyWorkPortIn dailyWorkPortIn;
|
||||
private final DailyPowerPortIn dailyPowerPortIn;
|
||||
private final DailyForestryPortIn dailyForestryPortIn;
|
||||
|
||||
/**
|
||||
* 일계부 항목 등록 화면
|
||||
@@ -83,9 +89,9 @@ public class DailyRecordUIController {
|
||||
} 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("workList", dailyWorkPortIn.list(new DailyWorkUIReqVO(searchMonth, groupNo)));
|
||||
model.addAttribute("powerList", dailyPowerPortIn.list(new DailyPowerUIReqVO(searchMonth, groupNo)));
|
||||
model.addAttribute("forestryList", null); // TODO
|
||||
model.addAttribute("forestryList", dailyForestryPortIn.list(new DailyForestryUIReqVO(searchMonth, groupNo)));
|
||||
model.addAttribute("farmingList", null); // TODO
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,12 @@ package app.module.front.usecase.daily.work.adapters.persistence.model;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Slf4j
|
||||
@Getter
|
||||
@Setter
|
||||
public class DailyWorkDto {
|
||||
@@ -38,4 +43,24 @@ public class DailyWorkDto {
|
||||
public boolean isUpdated() {
|
||||
return this.id != null && this.id != 0L;
|
||||
}
|
||||
|
||||
public BigDecimal getTotalHour() {
|
||||
BigDecimal totalHour = BigDecimal.ZERO;
|
||||
try {
|
||||
totalHour = totalHour.add(new BigDecimal(StringUtils.defaultIfBlank(this.ownerTime, "0")));
|
||||
totalHour = totalHour.add(new BigDecimal(StringUtils.defaultIfBlank(this.spouseTime, "0")));
|
||||
totalHour = totalHour.add(new BigDecimal(StringUtils.defaultIfBlank(this.familyMHours, "0")));
|
||||
totalHour = totalHour.add(new BigDecimal(StringUtils.defaultIfBlank(this.familyFHours, "0")));
|
||||
totalHour = totalHour.add(new BigDecimal(StringUtils.defaultIfBlank(this.hiredMHours, "0")));
|
||||
totalHour = totalHour.add(new BigDecimal(StringUtils.defaultIfBlank(this.hiredFHours, "0")));
|
||||
totalHour = totalHour.add(new BigDecimal(StringUtils.defaultIfBlank(this.sharedMHours, "0")));
|
||||
totalHour = totalHour.add(new BigDecimal(StringUtils.defaultIfBlank(this.sharedFHours, "0")));
|
||||
totalHour = totalHour.add(new BigDecimal(StringUtils.defaultIfBlank(this.volunteerMHours, "0")));
|
||||
totalHour = totalHour.add(new BigDecimal(StringUtils.defaultIfBlank(this.volunteerFHours, "0")));
|
||||
} catch (Exception e) {
|
||||
log.warn("[DataParse] work BigDecimal.", e);
|
||||
}
|
||||
|
||||
return totalHour;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user