[FO] 일계부 자가농업 CRUD, 공통 수정
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
package app.module.front.usecase.daily.farming.adapters.persistence;
|
||||
|
||||
import app.module.front.usecase.daily.farming.adapters.persistence.model.DailyFarmingDto;
|
||||
import app.module.front.usecase.daily.farming.ports.DailyFarmingPortOut;
|
||||
import app.module.front.usecase.daily.farming.ports.application.domain.CreateDailyFarmingCmd;
|
||||
import app.module.front.usecase.daily.farming.ports.application.domain.GetDailyFarmingCmd;
|
||||
import app.module.front.usecase.daily.farming.ports.application.domain.RemoveDailyFarmingCmd;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
public class DailyFarmingDao implements DailyFarmingPortOut {
|
||||
private final DailyFarmingMapper mapper;
|
||||
|
||||
@Override
|
||||
public List<DailyFarmingDto> list(GetDailyFarmingCmd command) {
|
||||
return mapper.getDailyFarmingList(command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(GetDailyFarmingCmd findCmd, CreateDailyFarmingCmd command) {
|
||||
Integer existCount = mapper.getRecordExistCount(findCmd);
|
||||
if (existCount == 0) {
|
||||
mapper.createDailyFarming(command);
|
||||
|
||||
log.debug("[CreateDailyFarming] record={}", command);
|
||||
} else {
|
||||
mapper.updateDailyFarming(command);
|
||||
|
||||
log.debug("[UpdateDailyFarming] record={}", command);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(GetDailyFarmingCmd findCmd, RemoveDailyFarmingCmd command) {
|
||||
Integer existCount = mapper.getRecordExistCount(findCmd);
|
||||
if (existCount != 0) {
|
||||
mapper.removeDailyFarming(command);
|
||||
|
||||
log.debug("[RemoveDailyFarming] record={}", command);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package app.module.front.usecase.daily.farming.adapters.persistence;
|
||||
|
||||
import app.module.front.usecase.daily.farming.adapters.persistence.model.DailyFarmingDto;
|
||||
import app.module.front.usecase.daily.farming.ports.application.domain.CreateDailyFarmingCmd;
|
||||
import app.module.front.usecase.daily.farming.ports.application.domain.GetDailyFarmingCmd;
|
||||
import app.module.front.usecase.daily.farming.ports.application.domain.RemoveDailyFarmingCmd;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface DailyFarmingMapper {
|
||||
/**
|
||||
* 일계부 자가농업 목록 조회
|
||||
*
|
||||
* @param command 검색 조건
|
||||
* @return 수입 목록
|
||||
*/
|
||||
List<DailyFarmingDto> getDailyFarmingList(GetDailyFarmingCmd command);
|
||||
|
||||
/**
|
||||
* 일계부 자가농업 데이터 존재 여부
|
||||
*
|
||||
* @param command 검색 조건
|
||||
* @return 중복 개수
|
||||
*/
|
||||
Integer getRecordExistCount(GetDailyFarmingCmd command);
|
||||
|
||||
/**
|
||||
* 일계부 자가농업 등록
|
||||
*
|
||||
* @param command 등록 데이터
|
||||
*/
|
||||
void createDailyFarming(CreateDailyFarmingCmd command);
|
||||
|
||||
/**
|
||||
* 일계부 자가농업 수정
|
||||
*
|
||||
* @param command 수정 데이터
|
||||
*/
|
||||
void updateDailyFarming(CreateDailyFarmingCmd command);
|
||||
|
||||
/**
|
||||
* 일계부 자가농업 삭제
|
||||
*
|
||||
* @param command 삭제 데이터
|
||||
*/
|
||||
void removeDailyFarming(RemoveDailyFarmingCmd command);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package app.module.front.usecase.daily.farming.adapters.persistence.model;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class DailyFarmingDto {
|
||||
private Long id;
|
||||
private Long dailyRecordSeq;
|
||||
private String productCode;
|
||||
private String productLabel;
|
||||
private String productSelf;
|
||||
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.farming.adapters.web;
|
||||
|
||||
import app.module.core.config.application.exception.NoRecordDataException;
|
||||
import app.module.core.config.application.util.CoreUtil;
|
||||
import app.module.front.usecase.daily.farming.adapters.web.model.CreateDailyFarmingReqVO;
|
||||
import app.module.front.usecase.daily.farming.adapters.web.model.RemoveDailyFarmingReqVO;
|
||||
import app.module.front.usecase.daily.farming.adapters.web.validator.CreateDailyFarmingValidator;
|
||||
import app.module.front.usecase.daily.farming.ports.application.DailyFarmingService;
|
||||
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/farming")
|
||||
public class DailyFarmingController {
|
||||
private final CoreUtil coreUtil;
|
||||
private final DailyRecordPortIn dailyRecordService;
|
||||
private final DailyFarmingService dailyFarmingPortIn;
|
||||
private final CreateDailyFarmingValidator 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 CreateDailyFarmingReqVO 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);
|
||||
|
||||
dailyFarmingPortIn.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 RemoveDailyFarmingReqVO 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);
|
||||
|
||||
dailyFarmingPortIn.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);
|
||||
|
||||
RemoveDailyFarmingReqVO formVO = new RemoveDailyFarmingReqVO();
|
||||
formVO.setSearchMonth(dailyRecord.getRecordMonth());
|
||||
formVO.setGroupNo(dailyRecord.getGroupNo());
|
||||
formVO.setDailyRecordSeq(dailyRecord.getId());
|
||||
log.debug("formVO: {}", formVO);
|
||||
|
||||
dailyFarmingPortIn.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.farming.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.farming.adapters.persistence.model.DailyFarmingDto;
|
||||
import app.module.front.usecase.daily.farming.adapters.web.model.DailyFarmingUIReqVO;
|
||||
import app.module.front.usecase.daily.farming.ports.application.DailyFarmingService;
|
||||
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/farming")
|
||||
public class DailyFarmingUIController {
|
||||
private final UICodeListPortIn uiCodeListPortIn;
|
||||
private final DailyRecordPortIn dailyRecordPortIn;
|
||||
private final DailyFarmingService dailyFarmingPortIn;
|
||||
|
||||
/**
|
||||
* 일계부 자가농업 목록 화면
|
||||
*
|
||||
* @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);
|
||||
|
||||
DailyFarmingUIReqVO reqVO = new DailyFarmingUIReqVO(searchMonth, groupNo);
|
||||
log.debug("reqVO: {}", reqVO);
|
||||
|
||||
List<DailyFarmingDto> farmingList = dailyFarmingPortIn.list(reqVO);
|
||||
|
||||
model.addAttribute("reqVO", reqVO);
|
||||
model.addAttribute("dailyRecord", dailyRecord);
|
||||
model.addAttribute("farmingList", farmingList);
|
||||
model.addAttribute("moveStep", !"update".equals(searchType));
|
||||
model.addAttribute("nextStep", dailyRecord.getNextStep(DailySort.FARMING));
|
||||
|
||||
return "record/farming/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) {
|
||||
|
||||
DailyFarmingUIReqVO reqVO = new DailyFarmingUIReqVO(searchMonth, groupNo);
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
reqVO.setId(0L);
|
||||
} else {
|
||||
reqVO.setId(Long.parseLong(id));
|
||||
}
|
||||
log.debug("reqVO: {}", reqVO);
|
||||
|
||||
DailyFarmingDto detail = new DailyFarmingDto();
|
||||
if (reqVO.getId() != 0L) {
|
||||
detail = dailyFarmingPortIn.detail(reqVO);
|
||||
if (detail == null || !detail.isUpdated()) {
|
||||
throw new NoRecordDataException();
|
||||
}
|
||||
}
|
||||
|
||||
model.addAttribute("recordFarming", uiCodeListPortIn.connect("code.record.farming"));
|
||||
model.addAttribute("recordUnit", uiCodeListPortIn.connect("code.record.unit"));
|
||||
|
||||
model.addAttribute("reqVO", reqVO);
|
||||
model.addAttribute("detail", detail);
|
||||
|
||||
return "record/farming/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,50 @@
|
||||
package app.module.front.usecase.daily.farming.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 CreateDailyFarmingReqVO extends DailyUIReqVO {
|
||||
/**
|
||||
* 자가농업 일련번호
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 일계부 일련번호
|
||||
*/
|
||||
private Long dailyRecordSeq;
|
||||
/**
|
||||
* 생산물
|
||||
*/
|
||||
@NotBlank(message = "생산물을 입력해 주세요.")
|
||||
private String productCode;
|
||||
/**
|
||||
* 생산물 직접 입력
|
||||
*/
|
||||
private String productSelf;
|
||||
/**
|
||||
* 용도
|
||||
*/
|
||||
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.farming.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 DailyFarmingUIReqVO extends DailyUIReqVO {
|
||||
public DailyFarmingUIReqVO(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.farming.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 RemoveDailyFarmingReqVO extends DailyUIReqVO {
|
||||
/**
|
||||
* 자가농업 일련번호
|
||||
*/
|
||||
@NotBlank(message = "{valid.common.required}")
|
||||
private String id;
|
||||
/**
|
||||
* 일계부 일련번호
|
||||
*/
|
||||
private Long dailyRecordSeq;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package app.module.front.usecase.daily.farming.adapters.web.validator;
|
||||
|
||||
import app.module.front.usecase.daily.farming.adapters.web.model.CreateDailyFarmingReqVO;
|
||||
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 CreateDailyFarmingValidator implements Validator {
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> clazz) {
|
||||
return CreateDailyFarmingReqVO.class.equals(clazz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(Object target, Errors errors) {
|
||||
CreateDailyFarmingReqVO vo = (CreateDailyFarmingReqVO) target;
|
||||
|
||||
if ("SELF".equals(vo.getProductCode()) && StringUtils.isBlank(vo.getProductSelf())) {
|
||||
errors.rejectValue(
|
||||
"categorySelf", "valid.common.required",
|
||||
"생산물을 입력해 주세요.");
|
||||
}
|
||||
|
||||
if (vo.getEstimatedValue() == null) {
|
||||
errors.rejectValue(
|
||||
"estimatedValue", "valid.common.required",
|
||||
"현물평가액을 입력해 주세요.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package app.module.front.usecase.daily.farming.ports;
|
||||
|
||||
|
||||
import app.module.front.usecase.daily.farming.adapters.persistence.model.DailyFarmingDto;
|
||||
import app.module.front.usecase.daily.farming.adapters.web.model.CreateDailyFarmingReqVO;
|
||||
import app.module.front.usecase.daily.farming.adapters.web.model.DailyFarmingUIReqVO;
|
||||
import app.module.front.usecase.daily.farming.adapters.web.model.RemoveDailyFarmingReqVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface DailyFarmingPortIn {
|
||||
/**
|
||||
* 일계부 자가농업 조회
|
||||
*
|
||||
* @param reqVO 검색 조건
|
||||
* @return 자가농업 목록
|
||||
*/
|
||||
List<DailyFarmingDto> list(DailyFarmingUIReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 일계부 자가농업 조회
|
||||
*
|
||||
* @param reqVO 검색 조건
|
||||
* @return 자가농업 상세
|
||||
*/
|
||||
DailyFarmingDto detail(DailyFarmingUIReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 일계부 자가농업 등록
|
||||
*
|
||||
* @param formVO 입력 데이터
|
||||
*/
|
||||
void create(CreateDailyFarmingReqVO formVO);
|
||||
|
||||
/**
|
||||
* 일계부 자가농업 삭제
|
||||
*
|
||||
* @param formVO 삭제 검색 조건
|
||||
*/
|
||||
void remove(RemoveDailyFarmingReqVO formVO);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package app.module.front.usecase.daily.farming.ports;
|
||||
|
||||
|
||||
import app.module.front.usecase.daily.farming.adapters.persistence.model.DailyFarmingDto;
|
||||
import app.module.front.usecase.daily.farming.ports.application.domain.CreateDailyFarmingCmd;
|
||||
import app.module.front.usecase.daily.farming.ports.application.domain.GetDailyFarmingCmd;
|
||||
import app.module.front.usecase.daily.farming.ports.application.domain.RemoveDailyFarmingCmd;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface DailyFarmingPortOut {
|
||||
/**
|
||||
* 일계부 자가농업 조회
|
||||
*
|
||||
* @param command 검색 조건
|
||||
* @return 자가농업 목록
|
||||
*/
|
||||
List<DailyFarmingDto> list(GetDailyFarmingCmd command);
|
||||
|
||||
/**
|
||||
* 일계부 자가농업 등록
|
||||
*
|
||||
* @param findCmd 검색 조건
|
||||
* @param command 입력 데이터
|
||||
*/
|
||||
void create(GetDailyFarmingCmd findCmd, CreateDailyFarmingCmd command);
|
||||
|
||||
/**
|
||||
* 일계부 자가농업 삭제
|
||||
*
|
||||
* @param findCmd 검색 조건
|
||||
* @param command 삭제 검색 조건
|
||||
*/
|
||||
void remove(GetDailyFarmingCmd findCmd, RemoveDailyFarmingCmd command);
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
package app.module.front.usecase.daily.farming.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.farming.adapters.persistence.model.DailyFarmingDto;
|
||||
import app.module.front.usecase.daily.farming.adapters.web.model.CreateDailyFarmingReqVO;
|
||||
import app.module.front.usecase.daily.farming.adapters.web.model.DailyFarmingUIReqVO;
|
||||
import app.module.front.usecase.daily.farming.adapters.web.model.RemoveDailyFarmingReqVO;
|
||||
import app.module.front.usecase.daily.farming.ports.DailyFarmingPortIn;
|
||||
import app.module.front.usecase.daily.farming.ports.DailyFarmingPortOut;
|
||||
import app.module.front.usecase.daily.farming.ports.application.domain.CreateDailyFarmingCmd;
|
||||
import app.module.front.usecase.daily.farming.ports.application.domain.GetDailyFarmingCmd;
|
||||
import app.module.front.usecase.daily.farming.ports.application.domain.RemoveDailyFarmingCmd;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DailyFarmingService implements DailyFarmingPortIn {
|
||||
private final DailyFarmingPortOut portOut;
|
||||
private final UICodeListPortIn uiCodeListPortIn;
|
||||
|
||||
@Override
|
||||
public List<DailyFarmingDto> list(DailyFarmingUIReqVO reqVO) {
|
||||
return this.getRefineList(reqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DailyFarmingDto detail(DailyFarmingUIReqVO reqVO) {
|
||||
List<DailyFarmingDto> list = this.getRefineList(reqVO);
|
||||
if (list.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return list.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 목록 데이터 조회
|
||||
*
|
||||
* @param reqVO 검색 조건
|
||||
* @return 공통 처리된 목록
|
||||
*/
|
||||
private List<DailyFarmingDto> getRefineList(DailyFarmingUIReqVO reqVO) {
|
||||
List<DailyFarmingDto> list = portOut.list(new GetDailyFarmingCmd(reqVO.getSearchMonth(),
|
||||
reqVO.getGroupNo(),
|
||||
reqVO.getHouseholdSeq(),
|
||||
reqVO.getId()));
|
||||
|
||||
List<UICodeElement> recordFarming = uiCodeListPortIn.connect("code.record.farming");
|
||||
List<UICodeElement> recordUnit = uiCodeListPortIn.connect("code.record.unit");
|
||||
|
||||
for (DailyFarmingDto dto : list) {
|
||||
if ("code.record.farming.self".equals(dto.getProductCode())) {
|
||||
dto.setProductLabel(dto.getProductSelf());
|
||||
} else {
|
||||
dto.setProductLabel(this.getCodeLabel(dto.getProductCode(), recordFarming));
|
||||
}
|
||||
|
||||
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(CreateDailyFarmingReqVO formVO) {
|
||||
GetDailyFarmingCmd findCmd = new GetDailyFarmingCmd(
|
||||
formVO.getSearchMonth(),
|
||||
formVO.getGroupNo(),
|
||||
formVO.getHouseholdSeq(),
|
||||
formVO.getId());
|
||||
|
||||
String incomeMark = null;
|
||||
String expenseMark = null;
|
||||
if (!"code.record.farming.self".equals(formVO.getProductCode())) {
|
||||
List<UICodeElement> recordFarming = uiCodeListPortIn.connect("code.record.farming");
|
||||
String returnValue = null;
|
||||
for (UICodeElement codeSetup : recordFarming) {
|
||||
if (codeSetup.getId().equalsIgnoreCase(formVO.getProductCode())) {
|
||||
returnValue = codeSetup.getCodeValue();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (returnValue != null) {
|
||||
incomeMark = returnValue.split(",")[0];
|
||||
expenseMark = returnValue.split(",")[1];
|
||||
}
|
||||
}
|
||||
|
||||
CreateDailyFarmingCmd command = AuditUtil.create(
|
||||
new CreateDailyFarmingCmd(
|
||||
formVO.getId(),
|
||||
formVO.getDailyRecordSeq(),
|
||||
incomeMark,
|
||||
expenseMark,
|
||||
formVO.getProductCode(),
|
||||
formVO.getProductSelf(),
|
||||
formVO.getUsage(),
|
||||
formVO.getQuantity(),
|
||||
formVO.getUnitCode(),
|
||||
formVO.getUnitSelf(),
|
||||
formVO.getEstimatedValue()));
|
||||
|
||||
portOut.create(findCmd, command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(RemoveDailyFarmingReqVO formVO) {
|
||||
Long id = formVO.getId() != null ? Long.parseLong(formVO.getId()) : null;
|
||||
|
||||
GetDailyFarmingCmd findCmd = new GetDailyFarmingCmd(
|
||||
formVO.getSearchMonth(),
|
||||
formVO.getGroupNo(),
|
||||
formVO.getHouseholdSeq(),
|
||||
id);
|
||||
|
||||
RemoveDailyFarmingCmd command = AuditUtil.delete(
|
||||
new RemoveDailyFarmingCmd(
|
||||
formVO.getSearchMonth(),
|
||||
formVO.getGroupNo(),
|
||||
id,
|
||||
formVO.getDailyRecordSeq()));
|
||||
|
||||
portOut.remove(findCmd, command);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package app.module.front.usecase.daily.farming.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 CreateDailyFarmingCmd extends FrontAuditCommand {
|
||||
private Long id;
|
||||
private Long dailyRecordSeq;
|
||||
private String incomeMark;
|
||||
private String expenseMark;
|
||||
private String productCode;
|
||||
private String productSelf;
|
||||
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.farming.ports.application.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public class GetDailyFarmingCmd {
|
||||
/**
|
||||
* 검색 월(yyyyMM)
|
||||
*/
|
||||
private String searchMonth;
|
||||
/**
|
||||
* 검색 그룸번호
|
||||
*/
|
||||
private Integer groupNo;
|
||||
/**
|
||||
* 임가 일련번호
|
||||
*/
|
||||
private Long householdSeq;
|
||||
/**
|
||||
* 자가농업 일련번호
|
||||
*/
|
||||
private Long id;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package app.module.front.usecase.daily.farming.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 RemoveDailyFarmingCmd extends FrontAuditCommand {
|
||||
private String searchMonth;
|
||||
private Integer groupNo;
|
||||
private Long id;
|
||||
private Long dailyRecordSeq;
|
||||
}
|
||||
@@ -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.farming.adapters.web.model.DailyFarmingUIReqVO;
|
||||
import app.module.front.usecase.daily.farming.ports.DailyFarmingPortIn;
|
||||
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;
|
||||
@@ -38,6 +40,7 @@ public class DailyRecordUIController {
|
||||
private final DailyWorkPortIn dailyWorkPortIn;
|
||||
private final DailyPowerPortIn dailyPowerPortIn;
|
||||
private final DailyForestryPortIn dailyForestryPortIn;
|
||||
private final DailyFarmingPortIn dailyFarmingPortIn;
|
||||
|
||||
/**
|
||||
* 일계부 항목 등록 화면
|
||||
@@ -92,7 +95,7 @@ public class DailyRecordUIController {
|
||||
model.addAttribute("workList", dailyWorkPortIn.list(new DailyWorkUIReqVO(searchMonth, groupNo)));
|
||||
model.addAttribute("powerList", dailyPowerPortIn.list(new DailyPowerUIReqVO(searchMonth, groupNo)));
|
||||
model.addAttribute("forestryList", dailyForestryPortIn.list(new DailyForestryUIReqVO(searchMonth, groupNo)));
|
||||
model.addAttribute("farmingList", null); // TODO
|
||||
model.addAttribute("farmingList", dailyFarmingPortIn.list(new DailyFarmingUIReqVO(searchMonth, groupNo)));
|
||||
}
|
||||
|
||||
model.addAttribute("reqVO", reqVO);
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="app.module.front.usecase.daily.farming.adapters.persistence.DailyFarmingMapper">
|
||||
|
||||
<select id="getDailyFarmingList"
|
||||
resultType="app.module.front.usecase.daily.farming.adapters.persistence.model.DailyFarmingDto">
|
||||
select ds.id, ds.daily_record_seq
|
||||
, ds.product_code, ds.product_self, ds.usage
|
||||
, ds.quantity, ds.unit_code, ds.unit_self, ds.estimated_value
|
||||
from daily_farming ds
|
||||
<include refid="app.module.front.usecase.daily.record.adapters.persistence.DailyRecordMapper.InnerJoinByDailyRecord"/>
|
||||
where ds.is_deleted = false
|
||||
<if test="id != null and id != '0'">
|
||||
and ds.id = ${id}
|
||||
</if>
|
||||
order by
|
||||
ds.id desc
|
||||
</select>
|
||||
|
||||
<select id="getRecordExistCount" resultType="int">
|
||||
select count(1)
|
||||
from daily_farming ds
|
||||
<include refid="app.module.front.usecase.daily.record.adapters.persistence.DailyRecordMapper.InnerJoinByDailyRecord"/>
|
||||
where ds.is_deleted = false
|
||||
<if test="id != null and id != '0'">
|
||||
and ds.id = ${id}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<insert id="createDailyFarming" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into daily_farming (
|
||||
daily_record_seq, income_mark, expense_mark
|
||||
, product_code, product_self, usage
|
||||
, quantity, unit_code, unit_self, estimated_value
|
||||
, is_deleted
|
||||
, <include refid="common.fields.CreateUpdateBaseColumns"/>
|
||||
) values (
|
||||
#{dailyRecordSeq}, #{incomeMark}, #{expenseMark}
|
||||
, #{productCode}, #{productSelf}, #{usage}
|
||||
, #{quantity}, #{unitCode}, #{unitSelf}, #{estimatedValue}
|
||||
, false
|
||||
, <include refid="common.fields.CreateUpdateBaseValues"/>
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updateDailyFarming">
|
||||
update daily_farming set <include refid="common.fields.UpdateBaseSet"/>
|
||||
, income_mark = #{incomeMark}
|
||||
, expense_mark = #{expenseMark}
|
||||
, product_code = #{productCode}
|
||||
, product_self = #{productSelf}
|
||||
, usage = #{usage}
|
||||
, quantity = #{quantity}
|
||||
, unit_code = #{unitCode}
|
||||
, unit_self = #{unitSelf}
|
||||
, estimated_value = #{estimatedValue}
|
||||
where is_deleted = false
|
||||
and daily_record_seq = #{dailyRecordSeq}
|
||||
and id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="removeDailyFarming">
|
||||
update daily_farming set
|
||||
<include refid="common.fields.DeleteBaseSet"/>
|
||||
where is_deleted = false
|
||||
and daily_record_seq = #{dailyRecordSeq}
|
||||
<if test="id != null and id != ''">
|
||||
and id = #{id}
|
||||
</if>
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
@@ -6,7 +6,7 @@
|
||||
resultType="app.module.front.usecase.daily.record.adapters.persistence.model.DailyRecordDto">
|
||||
select ddg.group_no, ddg.start_day, ddg.end_day
|
||||
, dr.id, dr.record_month, dr.day_group_no, dr.start_date, dr.end_date
|
||||
, dr.all_status, dr.income_status, dr.work_status, dr.expense_status, dr.power_status, dr.forestry_status
|
||||
, dr.all_status, dr.income_status, dr.work_status, dr.expense_status, dr.power_status, dr.forestry_status, dr.farming_status
|
||||
from daily_day_group ddg
|
||||
left join
|
||||
daily_record dr on dr.day_group_no = ddg.group_no and dr.is_deleted = false
|
||||
|
||||
@@ -42,6 +42,7 @@ uri.front.record.expense.{{pathVar}}=\uC77C\uACC4\uBD80 \uB4F1\uB85D
|
||||
uri.front.record.work.{{pathVar}}=\uC77C\uACC4\uBD80 \uB4F1\uB85D
|
||||
uri.front.record.power.{{pathVar}}=\uC77C\uACC4\uBD80 \uB4F1\uB85D
|
||||
uri.front.record.forestry.{{pathVar}}=\uC77C\uACC4\uBD80 \uB4F1\uB85D
|
||||
uri.front.record.farming.{{pathVar}}=\uC77C\uACC4\uBD80 \uB4F1\uB85D
|
||||
uri.front.record.daily.done=\uC77C\uACC4\uBD80 \uB4F1\uB85D
|
||||
|
||||
# \uAE30\uD0C0
|
||||
|
||||
@@ -132,7 +132,23 @@
|
||||
</li>
|
||||
</th:block>
|
||||
</ul>
|
||||
<!--/* TODO 농업생산물 중 자가소비량 */-->
|
||||
<!--/* 농업생산물 중 자가소비량 */-->
|
||||
<ul class="detail-list"
|
||||
th:if="${item.name eq 'FARMING'}"
|
||||
>
|
||||
<th:block th:if="${#lists.isEmpty(farmingList)}">
|
||||
<li>
|
||||
<p>없음</p>
|
||||
</li>
|
||||
</th:block>
|
||||
<th:block th:each="child, childStatus : ${farmingList}">
|
||||
<li>
|
||||
<p>[[${child.productLabel}]]</p>
|
||||
<span th:if="${not #strings.isEmpty(child.estimatedValue)}"
|
||||
th:text="|${#numbers.formatInteger(child.estimatedValue, 1, 'COMMA')}원|">302,000원</span>
|
||||
</li>
|
||||
</th:block>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<!--/* [정책] 자가농업 생산물 중 자가소비량은 7일차 등록일에만 노출 및 선택, 21일 이후는 마지막 날 */-->
|
||||
<!--/*<div class="component-input"
|
||||
<div class="component-input"
|
||||
th:if="${reqVO.groupNo eq 4 or reqVO.groupNo eq 8 or reqVO.groupNo eq 12
|
||||
or reqVO.groupNo eq 16 or reqVO.groupNo eq 17}">
|
||||
<label class="switch-inner type-txt">
|
||||
@@ -92,7 +92,7 @@
|
||||
<span class="switch-handle"></span>
|
||||
</span>
|
||||
</label>
|
||||
</div>*/-->
|
||||
</div>
|
||||
</section>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
145
front/src/main/resources/templates/record/farming/form.html
Normal file
145
front/src/main/resources/templates/record/farming/form.html
Normal file
@@ -0,0 +1,145 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
xmlns:th="http://www.thymeleaf.org" lang="ko">
|
||||
|
||||
<th:block>
|
||||
<div class="modal-content-inner">
|
||||
<p class="form-desc">필수입력</p>
|
||||
<form name="reqModalForm">
|
||||
<input type="hidden" name="id" th:value="${detail.id}">
|
||||
<section class="form-group">
|
||||
<div class="select-group">
|
||||
<div class="select-label">
|
||||
<p class="label-txt">
|
||||
생산물
|
||||
<i class="ico-required-mark" role="img" aria-label="필수">*</i>
|
||||
</p>
|
||||
</div>
|
||||
<div id="productCode" class="component-select bottom-sheet" data-props-default="생산물을 선택해 주세요" data-props-type="bottomSheet">
|
||||
<input type="hidden" name="productCode" th:value="${detail.productCode}">
|
||||
<button type="button" class="select-box">
|
||||
<span class="select-txt"></span>
|
||||
</button>
|
||||
<div class="select-options">
|
||||
<div class="select-header">
|
||||
<p>생산물</p>
|
||||
<button type="button" class="select-close">
|
||||
<span class="hide-txt">닫기</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="select-scroll">
|
||||
<ul class="">
|
||||
<li class="option" th:each="uiCode : ${recordFarming}"
|
||||
th:data-value="${uiCode.id}"
|
||||
th:text="${uiCode.codeText}"
|
||||
th:selected="${uiCode.id eq detail.productCode ? 'current' : ''}"
|
||||
></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="component-input" data-option="직접 입력">
|
||||
<div class="input-field">
|
||||
<input type="text" name="productSelf" th:value="${detail.productSelf}" maxlength="30" placeholder="생산물을 입력해 주세요">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="component-input">
|
||||
<div class="input-label">
|
||||
<label for="usage" class="label-txt">
|
||||
용도
|
||||
</label>
|
||||
</div>
|
||||
<div class="input-field">
|
||||
<input type="text" id="usage" name="usage" th:value="${detail.usage}" maxlength="30" placeholder="용도를 입력해 주세요">
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<hr>
|
||||
|
||||
<section class="form-group">
|
||||
<div class="component-input">
|
||||
<div class="input-label">
|
||||
<label for="quantity" class="label-txt">
|
||||
수량
|
||||
</label>
|
||||
</div>
|
||||
<div class="input-field">
|
||||
<input type="number" inputmode="decimal" pattern="[0-9]*" id="quantity" name="quantity"
|
||||
th:value="${detail.quantity}" maxlength="10" placeholder="수량을 입력해 주세요">
|
||||
</div>
|
||||
<ul class="guide-info">
|
||||
<li>예 : 2, 2.5</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="select-group">
|
||||
<div class="select-label">
|
||||
<p class="label-txt">
|
||||
단위
|
||||
</p>
|
||||
</div>
|
||||
<div id="unitCode" class="component-select bottom-sheet" data-props-default="단위를 선택해 주세요" data-props-type="bottomSheet">
|
||||
<input type="hidden" name="unitCode" th:value="${detail.unitCode}">
|
||||
<button type="button" class="select-box">
|
||||
<span class="select-txt"></span>
|
||||
</button>
|
||||
<div class="select-options">
|
||||
<div class="select-header">
|
||||
<p>단위</p>
|
||||
<button type="button" class="select-close">
|
||||
<span class="hide-txt">닫기</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="select-scroll">
|
||||
<ul class="">
|
||||
<li class="option" th:each="uiCode : ${recordUnit}"
|
||||
th:data-value="${uiCode.id}"
|
||||
th:text="${uiCode.codeText}"
|
||||
th:selected="${uiCode.id eq detail.unitCode ? 'current' : ''}"
|
||||
></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="component-input" data-option="직접 입력">
|
||||
<div class="input-field">
|
||||
<input type="text" name="unitSelf" th:value="${detail.unitSelf}" maxlength="30" placeholder="단위를 입력해 주세요">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<hr>
|
||||
|
||||
<section class="form-group">
|
||||
<div class="component-input">
|
||||
<div class="input-label">
|
||||
<label for="estimatedValue" class="label-txt">
|
||||
현물평가액
|
||||
<i class="ico-required-mark" role="img" aria-label="필수">*</i>
|
||||
</label>
|
||||
</div>
|
||||
<div class="input-field type-price">
|
||||
<input type="number" inputmode="numeric" pattern="[0-9]*" id="estimatedValue" name="estimatedValue"
|
||||
th:value="${detail.estimatedValue}" maxlength="10" placeholder="금액을 입력해 주세요">
|
||||
<span class="input-field-txt">원</span>
|
||||
</div>
|
||||
<ul class="guide-info">
|
||||
<li>예 : 30000</li>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="component-btns">
|
||||
<div class="btns-row">
|
||||
<button type="button" class="btn btn-full btn-l btn-primary" onclick="modalControl.createVaild();">
|
||||
<span class="btn-txt">등록</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</th:block>
|
||||
|
||||
</html>
|
||||
219
front/src/main/resources/templates/record/farming/index.html
Normal file
219
front/src/main/resources/templates/record/farming/index.html
Normal file
@@ -0,0 +1,219 @@
|
||||
<!DOCTYPE html>
|
||||
<html layout:decorate="~{layout/layout-none}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
xmlns:th="http://www.thymeleaf.org" lang="ko">
|
||||
|
||||
<div layout:fragment="content" th:classappend="acco-wrap">
|
||||
<main id="content" role="main">
|
||||
<div class="inner">
|
||||
<hgroup class="tit-group">
|
||||
<h3>
|
||||
<th:block th:if="${dailyRecord.startDay eq dailyRecord.endDay}">
|
||||
[[${#temporals.format(dailyRecord.startDate, 'M월 d일')}]], <br>
|
||||
</th:block>
|
||||
<th:block th:if="not ${dailyRecord.startDay eq dailyRecord.endDay}">
|
||||
[[${#temporals.format(dailyRecord.startDate, 'M월 d일')}]]~[[${#temporals.format(dailyRecord.endDate, 'd일')}]], <br>
|
||||
</th:block>
|
||||
<strong>농업생산물 중 자가소비량 내역 [[${#lists.isEmpty(farmingList) ? 0 : #lists.size(farmingList)}]]건 등록</strong>
|
||||
되었습니다.
|
||||
</h3>
|
||||
<p th:if="${#lists.isEmpty(farmingList)}">자가농업생산물 중 자가소비량 내역을 등록해 주세요.</p>
|
||||
<p th:unless="${#lists.isEmpty(farmingList)}">등록 내용을 확인하거나 다음 단계로 이동하세요.</p>
|
||||
</hgroup>
|
||||
|
||||
<!--/* 신규 등록 */-->
|
||||
<th:block th:if="${#lists.isEmpty(farmingList)}">
|
||||
<button type="button" class="btn btn-m btn-secondary btn-full button-modal01" data-testid="button-modal01"
|
||||
th:disabled="${#strings.equals(dailyRecord.farmingStatus, 'TODAY_NONE')}">
|
||||
<i class="ico-small" aria-hidden="true"
|
||||
th:classappend="${#strings.equals(dailyRecord.farmingStatus, 'TODAY_NONE') ? 'ico-add-disabled' : 'ico-add'}"></i>
|
||||
<span class="btn-txt">추가 등록</span>
|
||||
</button>
|
||||
<div class="component-input align-center">
|
||||
<label class="checkbox-inner" id="todayNone">
|
||||
<input type="checkbox" name="todayNone"
|
||||
data-type="FARMING"
|
||||
th:checked="${#strings.equals(dailyRecord.farmingStatus, 'TODAY_NONE')}">
|
||||
<span class="checkbox-item">
|
||||
<span class="checkbox-txt">금일 등록내용 없음</span>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<ul class="info-bullet-list">
|
||||
<li>
|
||||
다른 임가가 생산한 것을 취득하거나 외부로부터의 구입 • 증여한 것은 제외해 주세요.
|
||||
</li>
|
||||
</ul>
|
||||
</th:block>
|
||||
<!--/* 목록 */-->
|
||||
<th:block th:unless="${#lists.isEmpty(farmingList)}">
|
||||
<section class="regist-item-area">
|
||||
<p class="total">
|
||||
<span>총 <strong>[[${#lists.size(farmingList)}]]</strong>건</span>
|
||||
<button type="button" class="btn-reset" onclick="krip.daily.resetConfirm()">
|
||||
<i class="ico-reset ico-small" aria-hidden="true"></i>
|
||||
<span>초기화</span>
|
||||
</button>
|
||||
</p>
|
||||
<div class="item-list">
|
||||
<div class="list-item"
|
||||
th:each="item, itemStatus : ${farmingList}">
|
||||
<div class="item-tit-group">
|
||||
<p class="item-name">[[${item.productLabel}]]</p>
|
||||
<div class="btn-group">
|
||||
<button type="button" class="delete" th:onclick="krip.daily.removeConfirm([[${item.id}]])"><span class="hide-txt">삭제</span></button>
|
||||
<button type="button" class="edit" th:onclick="krip.daily.createModal([[${item.id}]])"><span class="hide-txt">수정</span></button>
|
||||
</div>
|
||||
</div>
|
||||
<ul class="detail-list">
|
||||
<li th:if="${not #strings.isEmpty(item.usage)}">
|
||||
<p>용도</p>
|
||||
<span th:text="${item.usage}">0시간</span>
|
||||
</li>
|
||||
<li th:if="${not #strings.isEmpty(item.quantity)}">
|
||||
<p>수량</p>
|
||||
<span th:text="|${item.quantity}${#strings.defaultString(item.unitLabel,'')}|">500g</span>
|
||||
</li>
|
||||
<li th:if="${not #strings.isEmpty(item.estimatedValue)}">
|
||||
<p>현물평가액</p>
|
||||
<span th:text="|${#numbers.formatInteger(item.estimatedValue, 1, 'COMMA')}원|">302,000원</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="btn btn-m btn-secondary btn-full button-modal01" data-testid="button-modal01">
|
||||
<i class="ico-add ico-small" aria-hidden="true"></i>
|
||||
<span class="btn-txt">추가 등록</span>
|
||||
</button>
|
||||
<ul class="info-bullet-list">
|
||||
<li>
|
||||
다른 임가가 생산한 것을 취득하거나 외부로부터의 구입 • 증여한 것은 제외해 주세요.
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
</th:block>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<!-- 하단 고정 버튼 -->
|
||||
<div class="component-btns fixed"
|
||||
th:if="${moveStep}">
|
||||
<div class="btns-row">
|
||||
<button type="button" class="btn btn-l btn-secondary" onclick="krip.daily.goToPrev();">
|
||||
<span class="btn-txt">이전 단계로 이동</span>
|
||||
</button>
|
||||
<button type="button" class="btn btn-l btn-primary"
|
||||
th:disabled="${not #strings.equals(dailyRecord.farmingStatus, 'TODAY_NONE') and #lists.isEmpty(farmingList)}"
|
||||
th:onclick="krip.daily.goToNext([[${nextStep}]], [[${reqVO.searchMonth}]], [[${reqVO.groupNo}]])">
|
||||
<span class="btn-txt">다음 단계로 이동</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 모달 팝업 -->
|
||||
<div class="layer-wrap">
|
||||
<div class="component-modal acco-wrap formModal" data-props-dimm-click="true">
|
||||
<div class="modal-dimm"></div>
|
||||
<div class="modal-frame">
|
||||
<div class="modal-container">
|
||||
<div class="modal-header">
|
||||
<h3 class="modal-tit">농업생산물 중 자가소비량 등록</h3>
|
||||
</div>
|
||||
<div class="modal-content">
|
||||
<!--/* form */-->
|
||||
</div>
|
||||
<button type="button" class="modal-close"></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- //모달 팝업 -->
|
||||
<!-- /* 건의사항 모달 팝업 */ -->
|
||||
<th:block th:replace="~{/record/comment-modal}"></th:block>
|
||||
<!-- /* //건의사항 모달 팝업 */ -->
|
||||
</div>
|
||||
|
||||
<section layout:fragment="script">
|
||||
<script th:src="@{/static/ui/page/daily-record.js}"></script>
|
||||
<script th:inline="javascript">
|
||||
$(function() {
|
||||
formControl.init();
|
||||
});
|
||||
|
||||
let ENV = {
|
||||
httpUrl: {
|
||||
root: /*[[|/record/farming/${reqVO.searchMonth}/${reqVO.groupNo}|]]*/'rootUrl',
|
||||
form: /*[[|/record/farming/${reqVO.searchMonth}/${reqVO.groupNo}/form/{id}|]]*/'formUrl',
|
||||
create: /*[[|/api/record/farming/${reqVO.searchMonth}/${reqVO.groupNo}/form/{id}|]]*/'createUrl',
|
||||
remove: /*[[|/api/record/farming/${reqVO.searchMonth}/${reqVO.groupNo}/remove|]]*/'removeUrl',
|
||||
reset: /*[[|/api/record/farming/${reqVO.searchMonth}/${reqVO.groupNo}/reset|]]*/'resetUrl',
|
||||
},
|
||||
modal: {
|
||||
// 등록 버튼
|
||||
selectorId: '.button-modal01',
|
||||
// 등록 영역
|
||||
selector: '.formModal',
|
||||
},
|
||||
month: /*[[${reqVO.searchMonth}]]*/'month',
|
||||
groupNo: /*[[${reqVO.groupNo}]]*/'groupNo',
|
||||
submitted: false,
|
||||
};
|
||||
|
||||
let formControl = {
|
||||
init() {
|
||||
krip.daily.baseBindUI();
|
||||
},
|
||||
};
|
||||
|
||||
let modalControl = {
|
||||
_bindModelUI() {
|
||||
const $select1 = document.querySelector('#productCode');
|
||||
const selectboxInstance1 = new etUI.components.SelectBox();
|
||||
selectboxInstance1.core.init($select1, {
|
||||
selectItemCallback({selectValue, dataValue}){
|
||||
console.log('selectItemCallback', selectValue, dataValue)
|
||||
$('input[name="productCode"]').val(dataValue)
|
||||
|
||||
etUI.pages.initDirectInputToggle();
|
||||
}
|
||||
});
|
||||
|
||||
const $select2 = document.querySelector('#unitCode');
|
||||
const selectboxInstance2 = new etUI.components.SelectBox();
|
||||
selectboxInstance2.core.init($select2, {
|
||||
selectItemCallback({selectValue, dataValue}){
|
||||
console.log('selectItemCallback', selectValue, dataValue)
|
||||
$('input[name="unitCode"]').val(dataValue)
|
||||
|
||||
etUI.pages.initDirectInputToggle();
|
||||
}
|
||||
});
|
||||
|
||||
const $formWrap = $(ENV.modal.selector).find('form');
|
||||
|
||||
// data set
|
||||
selectboxInstance1.setValue($formWrap.find('input[name="productCode"]').val());
|
||||
selectboxInstance2.setValue($formWrap.find('input[name="unitCode"]').val());
|
||||
},
|
||||
createVaild() {
|
||||
modalControl.create();
|
||||
},
|
||||
create() {
|
||||
const f = document.reqModalForm;
|
||||
|
||||
const obj = $(f).serializeObject();
|
||||
console.log(obj)
|
||||
|
||||
ajaxUtil._ajaxAsync(
|
||||
ENV.httpUrl.create.replace('{id}', f.id.value ? f.id.value : '0'),
|
||||
obj,
|
||||
function (rstData, status) {
|
||||
location.reload();
|
||||
},
|
||||
);
|
||||
},
|
||||
};
|
||||
</script>
|
||||
</section>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user