Merge branch 'daily' into dev

This commit is contained in:
김현주
2025-06-12 10:24:17 +09:00
30 changed files with 1249 additions and 184 deletions

View File

@@ -30,8 +30,6 @@ public class AuditCommand {
}
public void delete() {
this.updatedAt = LocalDateTime.now();
this.updatedBy = getCurrentUsername();
this.deletedAt = LocalDateTime.now();
this.deletedBy = getCurrentUsername();
}

View File

@@ -32,8 +32,6 @@
</sql>
<sql id="DeleteBaseSet">
updated_by = #{updatedBy},
updated_at = #{updatedAt},
deleted_by = #{deletedBy},
deleted_at = #{deletedAt},
is_deleted = true

View File

@@ -4,7 +4,7 @@ import app.module.front.usecase.daily.calendar.persistence.model.DailyRecordCale
import app.module.front.usecase.daily.calendar.persistence.model.DailyRecordStatusDto;
import app.module.front.usecase.daily.calendar.web.model.RecordCalendarUIReqVO;
import app.module.front.usecase.daily.record.web.model.CreateDailyRecordReqVO;
import app.module.front.usecase.daily.record.web.model.UpdateDailyRecordStatusCmd;
import app.module.front.usecase.daily.record.persistence.model.UpdateDailyRecordStatusCmd;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

View File

@@ -2,6 +2,7 @@ package app.module.front.usecase.daily.income.persistence;
import app.module.front.usecase.daily.income.persistence.model.CreateDailyIncomeCmd;
import app.module.front.usecase.daily.income.persistence.model.DailyIncomeDto;
import app.module.front.usecase.daily.income.persistence.model.RemoveDailyIncomeCmd;
import app.module.front.usecase.daily.income.web.model.DailyIncomeUIReqVO;
import org.apache.ibatis.annotations.Mapper;
@@ -23,7 +24,7 @@ public interface DailyIncomeMapper {
* @param reqVO
* @return
*/
Integer getDailyIncomeExistCount(DailyIncomeUIReqVO reqVO);
Integer getRecordExistCount(DailyIncomeUIReqVO reqVO);
/**
* 수입내역 등록
@@ -44,7 +45,8 @@ public interface DailyIncomeMapper {
/**
* 수입내역 삭제
*
* @param command
* @return
*/
int removeDailyIncome();
int removeDailyIncome(RemoveDailyIncomeCmd command);
}

View File

@@ -1,24 +1,30 @@
package app.module.front.usecase.daily.income.persistence.model;
import app.module.front.config.adapters.persistence.component.FrontAuditCommand;
import app.module.front.usecase.daily.income.web.model.CreateDailyIncomeReqVO;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@Getter
@Setter
public class CreateDailyIncomeCmd {
private Long id;
private Long householdSeq;
private Boolean isCredit;
private String cropCode;
// TODO : 수입종류의 코드맵핑 여부 판단
private String categoryCode;
private String categoryName;
private String sourcePurpose;
// TODO : 타입
private String quantity;
private String unitCode;
private Integer price;
private Integer estimatedValue;
// TODO : 무슨 데이터 넣을 것인가?
private String createdBy;
@AllArgsConstructor
@ToString
public class CreateDailyIncomeCmd extends FrontAuditCommand {
private Long id;
private Long dailyRecordSeq;
// SELF, OCR
private String inputType;
private Boolean credit;
private String cropCode;
// TODO : 수입종류의 코드맵핑 여부 판단
private String categoryCode;
private String categorySelf;
private String sourcePurpose;
// TODO : 데이터 타입 재정의 여부
private Integer quantity;
private String unitCode;
private Integer price;
private Integer estimatedValue;
}

View File

@@ -12,13 +12,20 @@ public class DailyIncomeDto {
private Long dailyRecordSeq;
// SELF, OCR
private String inputType;
private Boolean isCredit;
private Boolean credit;
private String cropCode;
private String cropLabel;
private String categoryCode;
private String categoryLabel;
private String categorySelf;
private String sourcePurpose;
private String quantity;
private Integer quantity;
private String unitCode;
private String price;
private String estimated_value;
private String unitLabel;
private Integer price;
private Integer estimatedValue;
public boolean isUpdated() {
return this.id != null;
}
}

View File

@@ -0,0 +1,18 @@
package app.module.front.usecase.daily.income.persistence.model;
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 RemoveDailyIncomeCmd extends FrontAuditCommand {
private String searchMonth;
private Integer groupNo;
private Long id;
private Long dailyRecordSeq;
}

View File

@@ -8,11 +8,33 @@ import app.module.front.usecase.daily.income.web.model.RemoveDailyIncomeReqVO;
import java.util.List;
public interface DailyIncomeService {
/**
* 수입내역 목록 조회
*
* @param reqVO 검색 조건
* @return
*/
List<DailyIncomeDto> getDailyIncomeList(DailyIncomeUIReqVO reqVO);
/**
* 수입내역 조회
*
* @param reqVO 검색 조건
* @return
*/
DailyIncomeDto getDailyIncome(DailyIncomeUIReqVO reqVO);
void createDailyIncome(CreateDailyIncomeReqVO command);
/**
* 수입내역 등록
*
* @param formVO 등록 데이터
*/
void create(CreateDailyIncomeReqVO formVO);
void removeDailyIncome(RemoveDailyIncomeReqVO command);
/**
* 수입내역 삭제
*
* @param formVO 검색 조건
*/
void remove(RemoveDailyIncomeReqVO formVO);
}

View File

@@ -1,7 +1,12 @@
package app.module.front.usecase.daily.income.service;
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.persistence.DailyIncomeMapper;
import app.module.front.usecase.daily.income.persistence.model.CreateDailyIncomeCmd;
import app.module.front.usecase.daily.income.persistence.model.DailyIncomeDto;
import app.module.front.usecase.daily.income.persistence.model.RemoveDailyIncomeCmd;
import app.module.front.usecase.daily.income.web.model.CreateDailyIncomeReqVO;
import app.module.front.usecase.daily.income.web.model.DailyIncomeUIReqVO;
import app.module.front.usecase.daily.income.web.model.RemoveDailyIncomeReqVO;
@@ -15,6 +20,7 @@ import java.util.List;
@Service
@RequiredArgsConstructor
public class DailyIncomeServiceImpl implements DailyIncomeService {
private final UICodeListPortIn uiCodeListPortIn;
private final DailyIncomeMapper dailyIncomeMapper;
@Override
@@ -35,16 +41,86 @@ public class DailyIncomeServiceImpl implements DailyIncomeService {
private List<DailyIncomeDto> getRefineIncomeList(DailyIncomeUIReqVO reqVO) {
List<DailyIncomeDto> list = dailyIncomeMapper.getDailyIncomeList(reqVO);
List<UICodeElement> recordIncome = uiCodeListPortIn.connect("code.record.income");
List<UICodeElement> recordCrop = uiCodeListPortIn.connect("code.record.crop");
List<UICodeElement> recordUnit = uiCodeListPortIn.connect("code.record.unit");
for (DailyIncomeDto dto : list) {
dto.setCategoryLabel(this.getCodeLabel(dto.getCategoryCode(), recordIncome));
dto.setCropLabel(this.getCodeLabel(dto.getCropCode(), recordCrop));
dto.setUnitLabel(this.getCodeLabel(dto.getUnitCode(), recordUnit));
}
return list;
}
@Override
public void createDailyIncome(CreateDailyIncomeReqVO command) {
/**
* 코드명 조회
* @param code 코드
* @param codeList 공통 코드 목록
* @return
*/
private String getCodeLabel(String code, List<UICodeElement> codeList) {
String returnValue = null;
for (UICodeElement codeSetup : codeList) {
if (codeSetup.getCodeValue().equalsIgnoreCase(code)) {
returnValue = codeSetup.getCodeText();
break;
}
}
return returnValue;
}
@Override
public void removeDailyIncome(RemoveDailyIncomeReqVO command) {
public void create(CreateDailyIncomeReqVO formVO) {
CreateDailyIncomeCmd command = AuditUtil.create(
new CreateDailyIncomeCmd(
formVO.getId(),
formVO.getDailyRecordSeq(),
formVO.getInputType(),
formVO.getCredit(),
formVO.getCropCode(),
formVO.getCategoryCode(),
formVO.getCategorySelf(),
formVO.getSourcePurpose(),
formVO.getQuantity(),
formVO.getUnitCode(),
formVO.getPrice(),
formVO.getEstimatedValue()));
DailyIncomeUIReqVO existReqVO = new DailyIncomeUIReqVO(formVO.getSearchMonth(), formVO.getGroupNo());
existReqVO.setId(formVO.getId());
Integer existCount = dailyIncomeMapper.getRecordExistCount(existReqVO);
if (existCount == 0) {
dailyIncomeMapper.createDailyIncome(command);
log.debug("[CreateDailyIncome] record={}", command);
} else {
dailyIncomeMapper.updateDailyIncome(command);
log.debug("[UpdateDailyIncome] record={}", command);
}
}
@Override
public void remove(RemoveDailyIncomeReqVO formVO) {
Long id = formVO.getId() != null ? Long.parseLong(formVO.getId()) : null;
RemoveDailyIncomeCmd command = AuditUtil.delete(
new RemoveDailyIncomeCmd(
formVO.getSearchMonth(),
formVO.getGroupNo(),
id,
formVO.getDailyRecordSeq()));
DailyIncomeUIReqVO existReqVO = new DailyIncomeUIReqVO(formVO.getSearchMonth(), formVO.getGroupNo());
existReqVO.setId(id);
Integer existCount = dailyIncomeMapper.getRecordExistCount(existReqVO);
if (existCount != 0) {
dailyIncomeMapper.removeDailyIncome(command);
log.debug("[RemoveDailyIncome] record={}", command);
}
}
}

View File

@@ -1,63 +1,151 @@
package app.module.front.usecase.daily.income.web;
import app.module.core.config.application.exception.NoMatchingURIException;
import app.module.core.config.application.exception.NoRecordDataException;
import app.module.front.config.application.util.AuthUtil;
import app.module.front.usecase.daily.income.persistence.model.DailyIncomeDto;
import app.module.front.usecase.daily.income.service.DailyIncomeService;
import app.module.front.usecase.daily.income.web.model.DailyIncomeUIReqVO;
import app.module.front.usecase.daily.income.web.model.CreateDailyIncomeReqVO;
import app.module.front.usecase.daily.income.web.model.RemoveDailyIncomeReqVO;
import app.module.front.usecase.daily.income.web.validator.CreateDailyIncomeValidator;
import app.module.front.usecase.daily.record.persistence.model.DailyRecordDto;
import app.module.front.usecase.daily.record.service.DailyRecordService;
import app.module.front.usecase.daily.record.web.model.DailyRecordUIReqVO;
import app.module.front.usecase.daily.record.web.model.DailyTargetStatus;
import jakarta.validation.Valid;
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 java.util.List;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
@Slf4j
@Controller
@RestController
@RequiredArgsConstructor
@RequestMapping(path = "/record/income")
@RequestMapping(path = "/api/record/income")
public class DailyIncomeController {
private final DailyRecordService dailyRecordService;
private final DailyIncomeService dailyIncomeService;
private final CreateDailyIncomeValidator createDailyIncomeValidator;
/**
* 일계부 수입내역 등록 화면
* 일계부 수입내역 등록 처리
*
* @param model
* @param searchMonth 검색 월(yyyyMM)
* @param groupNo 검색 그룹
* @param searchMonth
* @param groupNo
* @param id
* @param formVO
* @param bindingResult
* @return
*/
@GetMapping(path = "/{searchMonth}/{groupNo}")
public String index(Model model, @PathVariable(required = true) String searchMonth, @PathVariable(required = true) String groupNo) {
@PostMapping(path = "/{searchMonth}/{groupNo}/form/{id}")
ResponseEntity<?> create(@PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo
, @PathVariable("id") String id
, @Valid @RequestBody CreateDailyIncomeReqVO formVO, BindingResult bindingResult) {
DailyRecordUIReqVO recordReqVO = new DailyRecordUIReqVO(searchMonth, groupNo);
log.debug("recordReqVO: {}", recordReqVO);
createDailyIncomeValidator.validate(formVO, bindingResult);
if (bindingResult.hasErrors()) {
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
.body(bindingResult.getFieldErrors());
}
DailyRecordDto dailyRecord = dailyRecordService.getDailyRecord(recordReqVO);
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);
dailyIncomeService.create(formVO);
return ResponseEntity.status(HttpStatus.OK).body(formVO);
}
@PostMapping(path = "/{searchMonth}/{groupNo}/none")
ResponseEntity<?> updateByTodayNone(@PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo) {
DailyRecordDto dailyRecord = this.vaildGetDailyRecord(searchMonth, groupNo);
RemoveDailyIncomeReqVO formVO = new RemoveDailyIncomeReqVO();
formVO.setSearchMonth(dailyRecord.getRecordMonth());
formVO.setGroupNo(dailyRecord.getGroupNo());
formVO.setDailyRecordSeq(dailyRecord.getId());
log.debug("formVO: {}", formVO);
dailyRecordService.updateDailyRecordStatus(dailyRecord.getRecordMonth(), dailyRecord.getGroupNo(),
"INCOME", DailyTargetStatus.TODAY_NONE.name());
return ResponseEntity.status(HttpStatus.OK).body(null);
}
/**
* 일계부 수입내역 삭제 처리
*
* @param searchMonth
* @param groupNo
* @param formVO
* @param bindingResult
* @return
*/
@PostMapping(path = "/{searchMonth}/{groupNo}/remove")
ResponseEntity<?> remove(@PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo
, @Valid @RequestBody RemoveDailyIncomeReqVO formVO, BindingResult bindingResult) {
log.debug("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);
dailyIncomeService.remove(formVO);
return ResponseEntity.status(HttpStatus.OK).body(formVO);
}
/**
* 일계부 수입내역 전체 삭제 처리
*
* @param searchMonth
* @param groupNo
* @return
*/
@PostMapping(path = "/{searchMonth}/{groupNo}/reset")
ResponseEntity<?> removeAll(@PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo) {
DailyRecordDto dailyRecord = this.vaildGetDailyRecord(searchMonth, groupNo);
RemoveDailyIncomeReqVO formVO = new RemoveDailyIncomeReqVO();
formVO.setSearchMonth(dailyRecord.getRecordMonth());
formVO.setGroupNo(dailyRecord.getGroupNo());
formVO.setDailyRecordSeq(dailyRecord.getId());
log.debug("formVO: {}", formVO);
dailyIncomeService.remove(formVO);
return ResponseEntity.status(HttpStatus.OK).body(formVO);
}
/**
* 일계부 유효성 체크 및 데이터 조회
*
* @param searchMonth
* @param groupNo
* @return
*/
private DailyRecordDto vaildGetDailyRecord(String searchMonth, String groupNo) {
DailyRecordUIReqVO reqVO = new DailyRecordUIReqVO(searchMonth, groupNo);
log.debug("getRecordUIReq: {}", reqVO);
DailyRecordDto dailyRecord = dailyRecordService.getDailyRecord(reqVO);
if (dailyRecord == null || dailyRecord.getId() == null) {
throw new NoRecordDataException();
}
DailyIncomeUIReqVO reqVOs = new DailyIncomeUIReqVO();
reqVOs.setSearchMonth(searchMonth);
reqVOs.setGroupNo(Integer.parseInt(groupNo));
reqVOs.setHouseholdSeq(AuthUtil.getUserSeq());
log.debug("reqVO: {}", reqVOs);
List<DailyIncomeDto> incomeList = dailyIncomeService.getDailyIncomeList(reqVOs);
model.addAttribute("reqVO", reqVOs);
model.addAttribute("dailyRecord", dailyRecord);
model.addAttribute("incomeList", incomeList);
return "record/income/index";
return dailyRecord;
}
}

View File

@@ -0,0 +1,111 @@
package app.module.front.usecase.daily.income.web;
import app.module.core.config.application.exception.NoRecordDataException;
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
import app.module.front.usecase.daily.income.persistence.model.DailyIncomeDto;
import app.module.front.usecase.daily.income.service.DailyIncomeService;
import app.module.front.usecase.daily.income.web.model.DailyIncomeUIReqVO;
import app.module.front.usecase.daily.record.persistence.model.DailyRecordDto;
import app.module.front.usecase.daily.record.service.DailyRecordService;
import app.module.front.usecase.daily.record.web.model.DailyRecordUIReqVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.thymeleaf.util.StringUtils;
import java.util.List;
@Slf4j
@Controller
@RequiredArgsConstructor
@RequestMapping(path = "/record/income")
public class DailyIncomeUIController {
private final UICodeListPortIn uiCodeListPortIn;
private final DailyRecordService dailyRecordService;
private final DailyIncomeService dailyIncomeService;
/**
* 일계부 수입내역 목록 화면
*
* @param model Model
* @param searchMonth 검색 월(yyyyMM)
* @param groupNo 검색 그룹
* @return
*/
@GetMapping(path = "/{searchMonth}/{groupNo}")
public String index(Model model, @PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo) {
DailyRecordDto dailyRecord = this.vaildGetDailyRecord(searchMonth, groupNo);
DailyIncomeUIReqVO reqVO = new DailyIncomeUIReqVO(searchMonth, groupNo);
log.debug("reqVO: {}", reqVO);
List<DailyIncomeDto> incomeList = dailyIncomeService.getDailyIncomeList(reqVO);
model.addAttribute("reqVO", reqVO);
model.addAttribute("dailyRecord", dailyRecord);
model.addAttribute("incomeList", incomeList);
return "record/income/index";
}
/**
* 일계부 수입내역 등록 화면
*
* @param model
* @param searchMonth
* @param groupNo
* @param id
* @return
*/
@GetMapping(path = "/{searchMonth}/{groupNo}/form/{id}")
public String formBySelf(Model model, @PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo
, @PathVariable("id") String id) {
DailyIncomeUIReqVO reqVO = new DailyIncomeUIReqVO(searchMonth, groupNo);
if (StringUtils.isEmpty(id)) {
reqVO.setId(0L);
} else {
reqVO.setId(Long.parseLong(id));
}
log.debug("reqVO: {}", reqVO);
DailyIncomeDto detail = new DailyIncomeDto();
if (reqVO.getId() != 0L) {
detail = dailyIncomeService.getDailyIncome(reqVO);
if (detail == null || !detail.isUpdated()) {
throw new NoRecordDataException();
}
}
model.addAttribute("recordIncome", uiCodeListPortIn.connect("code.record.income"));
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/income/form";
}
/**
* 일계부 유효성 체크 및 데이터 조회
*
* @param searchMonth
* @param groupNo
* @return
*/
private DailyRecordDto vaildGetDailyRecord(String searchMonth, String groupNo) {
DailyRecordUIReqVO reqVO = new DailyRecordUIReqVO(searchMonth, groupNo);
log.debug("getRecordUIReq: {}", reqVO);
DailyRecordDto dailyRecord = dailyRecordService.getDailyRecord(reqVO);
if (dailyRecord == null || dailyRecord.getId() == null) {
throw new NoRecordDataException();
}
return dailyRecord;
}
}

View File

@@ -1,22 +1,60 @@
package app.module.front.usecase.daily.income.web.model;
import lombok.Data;
import app.module.front.usecase.daily.record.web.model.DailyUIReqVO;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@Data
@ToString
public class CreateDailyIncomeReqVO {
@Getter
@Setter
@ToString(callSuper = true)
public class CreateDailyIncomeReqVO extends DailyUIReqVO {
/**
* 수입 일련번호
*/
private Long id;
/**
* 일계부 일련번호
*/
private Long dailyRecordSeq;
// SELF, OCR
/**
* 등록 유형(SELF, OCR)
*/
private String inputType;
private Boolean isCredit;
/**
* 외상판매 여부
*/
private Boolean credit;
/**
* 재배형태 코드
*/
private String cropCode;
/**
* 수입의 종류 코드
*/
private String categoryCode;
/**
* 수입의 종류 직접입력
*/
private String categorySelf;
/**
* 수입원
*/
private String sourcePurpose;
private String quantity;
/**
* 수량
*/
private Integer quantity;
/**
* 단위 코드
*/
private String unitCode;
private String price;
private String estimated_value;
/**
* 현금
*/
private Integer price;
/**
* 현물평가액
*/
private Integer estimatedValue;
}

View File

@@ -1,13 +1,29 @@
package app.module.front.usecase.daily.income.web.model;
import lombok.Data;
import app.module.front.usecase.daily.record.web.model.DailyUIReqVO;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.apache.tika.utils.StringUtils;
@Data
@ToString
public class DailyIncomeUIReqVO {
private String searchMonth;
private Integer groupNo;
private Long householdSeq;
private Long incomeId;
@Getter
@Setter
@ToString(callSuper = true)
public class DailyIncomeUIReqVO extends DailyUIReqVO {
public DailyIncomeUIReqVO(String month, String no) {
setSearchMonth(month);
if (!StringUtils.isBlank(no)) {
setGroupNo(Integer.parseInt(no));
}
}
public DailyIncomeUIReqVO(String month, Integer no) {
setSearchMonth(month);
setGroupNo(no);
}
/**
* 수입 일련번호
*/
private Long id;
}

View File

@@ -1,10 +1,20 @@
package app.module.front.usecase.daily.income.web.model;
import lombok.Data;
import lombok.ToString;
import app.module.front.usecase.daily.record.web.model.DailyUIReqVO;
import jakarta.validation.constraints.NotBlank;
import lombok.*;
@Data
@ToString
public class RemoveDailyIncomeReqVO {
private Long id;
@Getter
@Setter
@ToString(callSuper = true)
public class RemoveDailyIncomeReqVO extends DailyUIReqVO {
/**
* 수입 일련번호
*/
@NotBlank(message = "{valid.common.required}")
private String id;
/**
* 일계부 일련번호
*/
private Long dailyRecordSeq;
}

View File

@@ -0,0 +1,39 @@
package app.module.front.usecase.daily.income.web.validator;
import app.module.core.config.application.util.MessageUtil;
import app.module.front.usecase.daily.income.web.model.CreateDailyIncomeReqVO;
import app.module.front.usecase.daily.record.web.model.CreateDailyRecordReqVO;
import app.module.front.usecase.daily.record.web.model.DailyStatus;
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 CreateDailyIncomeValidator implements Validator {
private final MessageUtil messageUtil;
@Override
public boolean supports(Class<?> clazz) {
return CreateDailyIncomeReqVO.class.equals(clazz);
}
@Override
public void validate(Object target, Errors errors) {
CreateDailyIncomeReqVO vo = (CreateDailyIncomeReqVO) target;
if ("SELF".equals(vo.getInputType()) || StringUtils.isBlank(vo.getInputType())) {
if (StringUtils.isBlank(vo.getCategoryCode())) {
errors.rejectValue(
"categoryCode", "valid.common.required",
"수입 종류를 선택해 주세요.");
}
}
// TODO : valid
}
}

View File

@@ -3,9 +3,8 @@ package app.module.front.usecase.daily.record.persistence;
import app.module.front.usecase.daily.record.persistence.model.CreateDailyRecordCmd;
import app.module.front.usecase.daily.record.persistence.model.DailyRecordDto;
import app.module.front.usecase.daily.record.web.model.DailyRecordUIReqVO;
import app.module.front.usecase.daily.record.web.model.UpdateDailyRecordStatusCmd;
import app.module.front.usecase.daily.record.persistence.model.UpdateDailyRecordStatusCmd;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface DailyRecordMapper {

View File

@@ -13,6 +13,7 @@ public class DailyRecordDto {
// , all_status, income_status, work_status, expense_status, power_status, forestry_status
// , created_at, created_by, is_deleted
private String recordMonth;
private Integer groupNo;
private Integer startDay;
private Integer endDay;

View File

@@ -0,0 +1,21 @@
package app.module.front.usecase.daily.record.persistence.model;
import app.module.front.config.adapters.persistence.component.FrontAuditCommand;
import app.module.front.usecase.daily.record.web.model.DailyStatus;
import app.module.front.usecase.daily.record.web.model.DailyTargetStatus;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@Getter
@Setter
@AllArgsConstructor
@ToString
public class UpdateDailyRecordStatusCmd extends FrontAuditCommand {
private String recordMonth;
private Integer dayGroupNo;
private String allStatus;
private String targetType;
private String targetStatus;
}

View File

@@ -8,4 +8,6 @@ public interface DailyRecordService {
DailyRecordDto getDailyRecord(DailyRecordUIReqVO reqVO);
void createDailyRecord(CreateDailyRecordReqVO reqVO);
void updateDailyRecordStatus(String recordMonth, Integer dayGroupNo, String targetType, String targetStatus);
}

View File

@@ -4,6 +4,7 @@ import app.module.front.config.application.util.AuditUtil;
import app.module.front.usecase.daily.record.persistence.DailyRecordMapper;
import app.module.front.usecase.daily.record.persistence.model.CreateDailyRecordCmd;
import app.module.front.usecase.daily.record.persistence.model.DailyRecordDto;
import app.module.front.usecase.daily.record.persistence.model.UpdateDailyRecordStatusCmd;
import app.module.front.usecase.daily.record.web.model.CreateDailyRecordReqVO;
import app.module.front.usecase.daily.record.web.model.DailyRecordUIReqVO;
import lombok.RequiredArgsConstructor;
@@ -68,4 +69,21 @@ public class DailyRecordServiceImpl implements DailyRecordService {
log.warn("[DailyRecordCreate] existCount={}, recordMonth={}, dayGroupNo={}", existCount, reqVO.getRecordMonth(), reqVO.getDayGroupNo());
}
}
@Override
public void updateDailyRecordStatus(String recordMonth, Integer dayGroupNo, String targetType, String targetStatus) {
UpdateDailyRecordStatusCmd command = AuditUtil.update(
new UpdateDailyRecordStatusCmd(
recordMonth,
dayGroupNo,
"ALL".equals(targetType) ? targetStatus : null,
!"ALL".equals(targetType) ? targetType : null,
!"ALL".equals(targetType) ? targetStatus : null
)
);
dailyRecordMapper.updateDailyRecordStatus(command);
// TODO : target 업데이트 후 데이터 등록이 완료된 건은 allStatus 값 변경해주기
}
}

View File

@@ -6,6 +6,7 @@ import app.module.front.usecase.daily.record.persistence.model.DailyRecordDto;
import app.module.front.usecase.daily.record.service.DailyRecordService;
import app.module.front.usecase.daily.record.web.model.CreateDailyRecordReqVO;
import app.module.front.usecase.daily.record.web.model.DailyRecordUIReqVO;
import app.module.front.usecase.daily.record.web.model.DailyTargetStatus;
import app.module.front.usecase.daily.record.web.validator.CreateDailyRecordValidator;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
@@ -18,39 +19,14 @@ import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
@Slf4j
@Controller
@RestController
@RequiredArgsConstructor
@RequestMapping(path = "/record/daily")
@RequestMapping(path = "/api/record/daily")
public class DailyRecordController {
private final RecordCalendarService recordCalendarService;
private final DailyRecordService dailyRecordService;
private final CreateDailyRecordValidator createDailyRecordValidator;
/**
* 일계부 등록 화면
*
* @param model
* @param searchMonth 검색 월(yyyyMM)
* @param groupNo 검색 그룹
* @return
*/
@GetMapping(path = "/{searchMonth}/{groupNo}")
public String createForm(Model model, @PathVariable(required = true) String searchMonth, @PathVariable(required = true) String groupNo) {
DailyRecordUIReqVO reqVO = new DailyRecordUIReqVO(searchMonth, groupNo);
log.debug("reqVO: {}", reqVO);
DailyRecordDto dailyRecord = dailyRecordService.getDailyRecord(reqVO);
if (dailyRecord == null) {
throw new NoMatchingURIException("[Record] 잘못된 접근");
}
model.addAttribute("reqVO", reqVO);
model.addAttribute("dailyRecord", dailyRecord);
return "record/daily";
}
/**
* 일계부 등록 처리
*
@@ -61,7 +37,7 @@ public class DailyRecordController {
* @return
*/
@PostMapping(path = "/{searchMonth}/{groupNo}")
ResponseEntity<?> create(@PathVariable(required = true) String searchMonth, @PathVariable(required = true) String groupNo
ResponseEntity<?> create(@PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo
, @Valid @RequestBody CreateDailyRecordReqVO formVO, BindingResult bindingResult) {
createDailyRecordValidator.validate(formVO, bindingResult);
@@ -84,4 +60,22 @@ public class DailyRecordController {
return ResponseEntity.status(HttpStatus.OK).body(reqVO);
}
@PostMapping(path = "/{searchMonth}/{groupNo}/today-none")
ResponseEntity<?> todayNone(@PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo
, @RequestParam(name = "target", required = true, defaultValue = "") String targetType
, @RequestParam(name = "status", required = false, defaultValue = "N") String targetStatus) {
DailyRecordUIReqVO reqVO = new DailyRecordUIReqVO(searchMonth, groupNo);
log.debug("reqVO: {}", reqVO);
log.debug("target: {}", targetType);
log.debug("status: {}", targetStatus);
DailyRecordDto detail = dailyRecordService.getDailyRecord(reqVO);
// TODO : true / false 를 업데이트하는 것은 대상 타켓이 되는 것이라 판단하여 그냥 강제 업데이트할 것인가? valid 체크
dailyRecordService.updateDailyRecordStatus(detail.getRecordMonth(), detail.getGroupNo(), targetType, "Y".equals(targetStatus) ? DailyTargetStatus.TODAY_NONE.name() : DailyTargetStatus.TARGET.name());
return ResponseEntity.status(HttpStatus.OK).body(reqVO);
}
}

View File

@@ -0,0 +1,53 @@
package app.module.front.usecase.daily.record.web;
import app.module.core.config.application.exception.NoMatchingURIException;
import app.module.front.usecase.daily.calendar.service.RecordCalendarService;
import app.module.front.usecase.daily.record.persistence.model.DailyRecordDto;
import app.module.front.usecase.daily.record.service.DailyRecordService;
import app.module.front.usecase.daily.record.web.model.CreateDailyRecordReqVO;
import app.module.front.usecase.daily.record.web.model.DailyRecordUIReqVO;
import app.module.front.usecase.daily.record.web.validator.CreateDailyRecordValidator;
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.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
@Slf4j
@Controller
@RequiredArgsConstructor
@RequestMapping(path = "/record/daily")
public class DailyRecordUIController {
private final RecordCalendarService recordCalendarService;
private final DailyRecordService dailyRecordService;
private final CreateDailyRecordValidator createDailyRecordValidator;
/**
* 일계부 등록 화면
*
* @param model
* @param searchMonth 검색 월(yyyyMM)
* @param groupNo 검색 그룹
* @return
*/
@GetMapping(path = "/{searchMonth}/{groupNo}")
public String createForm(Model model, @PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo) {
DailyRecordUIReqVO reqVO = new DailyRecordUIReqVO(searchMonth, groupNo);
log.debug("reqVO: {}", reqVO);
DailyRecordDto dailyRecord = dailyRecordService.getDailyRecord(reqVO);
if (dailyRecord == null) {
throw new NoMatchingURIException("[Record] 잘못된 접근");
}
model.addAttribute("reqVO", reqVO);
model.addAttribute("dailyRecord", dailyRecord);
return "record/daily";
}
}

View File

@@ -2,9 +2,9 @@ package app.module.front.usecase.daily.record.web.model;
public enum DailyTargetStatus {
/**
* 입력 중
* 등록 대상
*/
WAITING,
TARGET,
/**
* 금일 없음
*/

View File

@@ -1,20 +0,0 @@
package app.module.front.usecase.daily.record.web.model;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class UpdateDailyRecordStatusCmd {
private Long id;
private Long householdSeq;
private String recordMonth;
private int dayGroupNo;
// TODO : 전체 상태값 정의 ING, DONE
private String allStatus;
// TODO : 개별 상태값 정의 WAITING, TYPING, TODAY_NONE, NONE, DONE
private String targetType;
private String targetStatus;
// TODO : 무슨 데이터 넣을 것인가?
private String updatedBy;
}

View File

@@ -4,42 +4,47 @@
<select id="getDailyIncomeList"
resultType="app.module.front.usecase.daily.income.persistence.model.DailyIncomeDto">
select ds.id, ds.daily_record_seq, ds.input_type, ds.is_credit
select ds.id, ds.daily_record_seq, ds.input_type, ds.is_credit as credit
, ds.crop_code, ds.category_code, ds.category_self, ds.source_purpose
, ds.quantity, ds.unit_code, ds.price, ds.estimated_value
from daily_income ds
<include refid="app.module.front.usecase.daily.record.persistence.DailyRecordMapper.InnerJoinByDailyRecord"/>
where ds.is_deleted = false
<if test="incomeId != null and incomeId != ''">
and ds.id = ${incomeId}
<if test="id != null and id != '0'">
and ds.id = ${id}
</if>
order by
ds.id desc
</select>
<select id="getDailyIncomeExistCount" resultType="int">
<select id="getRecordExistCount" resultType="int">
select count(1)
from daily_income ds
<include refid="app.module.front.usecase.daily.record.persistence.DailyRecordMapper.InnerJoinByDailyRecord"/>
where ds.is_deleted = false
<if test="id != null and id != '0'">
and ds.id = ${id}
</if>
</select>
<insert id="createDailyIncome" useGeneratedKeys="true" keyProperty="id">
insert into daily_income (
daily_record_seq, is_credit, crop_code, category_code, category_self, source_purpose
daily_record_seq, input_type, is_credit, crop_code, category_code, category_self, source_purpose
, quantity, unit_code, price, estimated_value
, created_at, created_by, is_deleted
, is_deleted
, <include refid="common.fields.CreateUpdateBaseColumns"/>
) values (
#{householdSeq}
, #{isCredit}, #{cropCode}, #{categoryCode}, #{categoryName}, #{sourcePurpose}
#{dailyRecordSeq}
, #{inputType}, #{credit}, #{cropCode}, #{categoryCode}, #{categorySelf}, #{sourcePurpose}
, #{quantity}, #{unitCode}, #{price}, #{estimatedValue}
, now(), #{createdBy}, false
, false
, <include refid="common.fields.CreateUpdateBaseValues"/>
)
</insert>
<update id="updateDailyIncome">
update daily_income set
updated_at = now()
, updated_by = #{updatedBy}
, is_credit = #{isCredit}
update daily_income set <include refid="common.fields.UpdateBaseSet"/>
, is_credit = #{credit}
, crop_code = #{cropCode}
, category_code = #{categoryCode}
, category_self = #{categorySelf}
@@ -49,18 +54,18 @@
, price = #{price}
, estimated_value = #{estimatedValue}
where is_deleted = false
and daily_record_seq = 1
and id = 1
and daily_record_seq = #{dailyRecordSeq}
and id = #{id}
</update>
<update id="removeDailyIncome">
update daily_income set
deleted_at = now(),
deleted_by = '_system',
is_deleted = true
<include refid="common.fields.DeleteBaseSet"/>
where is_deleted = false
and daily_record_seq = 1
and id = 1
and daily_record_seq = #{dailyRecordSeq}
<if test="id != null and id != ''">
and id = #{id}
</if>
</update>
</mapper>

View File

@@ -41,7 +41,7 @@
</insert>
<update id="updateDailyRecordStatus">
update daily_record set <include refid="common.fields.UpdateBaseSet"/>
update daily_record set <include refid="common.fields.UpdateBaseSet"/>
<if test="allStatus != null and allStatus != ''">
, all_status = #{allStatus}
</if>
@@ -51,12 +51,27 @@
<when test="targetType eq 'INCOME'">
, income_status = #{targetStatus}
</when>
<when test="targetType eq 'WORK'">
, work_status = #{targetStatus}
</when>
<when test="targetType eq 'EXPENSE'">
, expense_status = #{targetStatus}
</when>
<when test="targetType eq 'POWER'">
, power_status = #{targetStatus}
</when>
<when test="targetType eq 'FORESTRY'">
, forestry_status = #{targetStatus}
</when>
<when test="targetType eq 'FARMING'">
, farming_status = #{targetStatus}
</when>
</choose>
</if>
where is_deleted = false
and household_seq = #{householdSeq}
and record_month = #{recordMonth}
and day_group_no = #{dayGroupNo}
where is_deleted = false
and household_seq = #{householdSeq}
and record_month = #{recordMonth}
and day_group_no = #{dayGroupNo}
</update>
<sql id="InnerJoinByDailyRecord">

View File

@@ -33,4 +33,25 @@ krip.daily.goToNext = function(target, searchMonth, groupNo) {
console.log(url);
//location.href = url;
};
/**
* 금일 등록내용 없음 변경
* @param month
* @param groupNo
* @param target
* @param checked
*/
krip.daily.todayNone = function(month, groupNo, target, checked) {
let url = '/api/record/daily/{month}/{groupNo}/today-none'.replace('{month}', month).replace('{groupNo}', groupNo);
url += '?target=' + target;
url += '&status=' + (checked ? 'Y' : 'N');
ajaxUtil._ajaxAsync(
url,
{},
function (rstData, status) {
console.log('rstData', rstData)
},
);
};

View File

@@ -49,7 +49,7 @@
ajaxUtil._ajaxAsync(
ENV.httpUrl.list.replace('{searchMonth}', searchMonth).replace('{groupNo}', groupNo),
null,
{},
function(rstHtml, status) {
$('#selectedDay').html(rstHtml);
},

View File

@@ -0,0 +1,260 @@
<!DOCTYPE html>
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:th="http://www.thymeleaf.org" lang="ko">
<th:block>
<th:block th:if="${@systemProperties['spring.profiles.active'] eq 'local'}">
<div>
reqVO: [[${reqVO}]]
</div>
<div>
detail: [[${dailyRecord}]]
</div>
</th:block>
<div class="modal-content-inner">
<div class="component-btns type-tab"
th:if="${not detail.updated}">
<div class="btns-row">
<button type="button" class="btn active">수기 등록</button>
<!--/* TODO : 2차 오픈 */-->
<!--<button class="btn">영수증 등록</button>-->
</div>
</div>
<p class="form-desc">필수입력</p>
<form name="reqModalForm">
<input type="hidden" name="inputType" th:value="${#strings.defaultString(detail.inputType, 'SELF')}">
<input type="hidden" name="id" th:value="${detail.id}">
<section class="form-group">
<div class="segment-label">
<p class="label-txt">
외상판매 여부
</p>
</div>
<div class="component-segment">
<div class="component-radio">
<label class="radio-inner">
<input type="radio" name="credit" value="true" th:checked="${detail.credit}">
<span class="radio-item">
<span class="radio-txt">예</span>
</span>
</label>
</div>
<div class="component-radio">
<label class="radio-inner">
<input type="radio" name="credit" value="false" th:checked="not ${detail.credit}">
<span class="radio-item">
<span class="radio-txt">아니오</span>
</span>
</label>
</div>
</div>
<div class="select-group">
<div class="select-label">
<p class="label-txt">
재배형태
</p>
<span class="select-sub-txt">임산물 수입이 있는 경우, 등록해 주세요.</span>
</div>
<div id="select3" class="component-select bottom-sheet" data-props-default="재배형태를 선택해 주세요" data-props-type="bottomSheet">
<!-- TODO : select html -->
<select name="cropCode">
<option value="">선택</option>
<option th:each="uiCode : ${recordCrop}"
th:value="${uiCode.codeValue}"
th:selected="${uiCode.codeValue eq detail.cropCode}"
>[[${uiCode.codeText}]] ([[${uiCode.codeValue}]])
</option>
</select>
<!--<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" data-value="option1">option1</li>
<li class="option" data-value="option2">option2</li>
<li class="option" data-value="option3">option3</li>
<li class="option" data-value="option4">option4</li>
<li class="option" data-value="option5">option5</li>
<li class="option" data-value="option6">option6</li>
<li class="option" data-value="option7">option7</li>
</ul>
</div>
</div>-->
</div>
</div>
</section>
<hr>
<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="select3" class="component-select bottom-sheet" data-props-default="수입 종류를 선택해 주세요" data-props-type="bottomSheet">
<!-- TODO : select html -->
<select name="categoryCode">
<option value="">선택</option>
<option th:each="uiCode : ${recordIncome}"
th:value="${uiCode.codeValue}"
th:selected="${uiCode.codeValue eq detail.categoryCode}"
>[[${uiCode.codeText}]] ([[${uiCode.codeValue}]])
</option>
</select>
<!-- TODO : 직접입력 html -->
<input type="text" name="categorySelf" th:value="${detail.categorySelf}">
<!--<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" data-value="option1">option1</li>
<li class="option" data-value="option2">option2</li>
<li class="option" data-value="option3">option3</li>
<li class="option" data-value="option4">option4</li>
<li class="option" data-value="option5">option5</li>
<li class="option" data-value="option6">option6</li>
<li class="option" data-value="option7">option7</li>
</ul>
</div>
</div>-->
</div>
</div>
<div class="component-input">
<div class="input-label">
<label for="sourcePurpose" class="label-txt">
수입원
<i class="ico-required-mark" role="img" aria-label="필수">*</i>
</label>
</div>
<div class="input-field">
<input type="text" id="sourcePurpose" name="sourcePurpose" th:value="${detail.sourcePurpose}" maxlength="50" 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="numeric" 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="select3" class="component-select bottom-sheet" data-props-default="단위를 선택해 주세요" data-props-type="bottomSheet">
<!-- TODO : select html -->
<select name="unitCode">
<option value="">선택</option>
<option th:each="uiCode : ${recordUnit}"
th:value="${uiCode.codeValue}"
th:selected="${uiCode.codeValue eq detail.unitCode}"
>[[${uiCode.codeText}]] ([[${uiCode.codeValue}]])
</option>
</select>
<!--<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" data-value="option1">option1</li>
<li class="option" data-value="option2">option2</li>
<li class="option" data-value="option3">option3</li>
<li class="option" data-value="option4">option4</li>
<li class="option" data-value="option5">option5</li>
<li class="option" data-value="option6">option6</li>
<li class="option" data-value="option7">option7</li>
</ul>
</div>
</div>-->
</div>
</div>
</section>
<hr>
<section class="form-group">
<div class="component-input">
<div class="input-label">
<label for="price" 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="price" name="price" th:value="${detail.price}" maxlength="10" placeholder="금액을 입력해 주세요">
<span class="input-field-txt">원</span>
</div>
<ul class="guide-info">
<li>예 : 30000</li>
</ul>
</div>
<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>
</form>
<div class="component-btns">
<div class="btns-row">
<button type="button" class="btn btn-full btn-l btn-primary" onclick="formControl.createVaild();">
<span class="btn-txt">등록</span>
</button>
</div>
</div>
</div>
</th:block>
</html>

View File

@@ -1,33 +1,300 @@
<!DOCTYPE html>
<html layout:decorate="~{layout/layout}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:th="http://www.thymeleaf.org">
<html layout:decorate="~{layout/layout-none}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:th="http://www.thymeleaf.org" lang="ko">
<section layout:fragment="content">
<h2>daily Form</h2>
<div>
reqVO: [[${reqVO}]]
</div>
<div>
<br/><br/>
detail: [[${detail}]]
<div layout:fragment="content" th:classappend="acco-wrap">
<th:block th:if="${@systemProperties['spring.profiles.active'] eq 'local'}">
<div>
reqVO: [[${reqVO}]]
</div>
<div>
dailyRecord: [[${dailyRecord}]]
</div>
</th:block>
<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(incomeList) ? 0 : #lists.size(incomeList)}]]건 등록</strong> <br>
되었습니다.
</h3>
<p>수입 내역을 등록해 주세요.</p>
</hgroup>
<form name="reqForm">
<input type="hidden" name="todayNone" value="N">
</form>
<!--/* 신규 등록 */-->
<th:block th:if="${#lists.isEmpty(incomeList)}">
<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>
<div class="component-input align-center">
<label class="checkbox-inner" id="todayNone">
<input type="checkbox" name="todayNone">
<span class="checkbox-item">
<span class="checkbox-txt">금일 등록내용 없음</span>
</span>
</label>
</div>
</th:block>
<!--/* 목록 */-->
<th:block th:unless="${#lists.isEmpty(incomeList)}">
<section class="regist-item-area">
<p class="total">
<span>총 <strong>[[${#lists.size(incomeList)}]]</strong>건</span>
<button class="btn-reset" onclick="formControl.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 : ${incomeList}">
<div class="item-tit-group">
<p class="item-name">[[${item.categoryLabel}]] [[${item.categorySelf}]]</p>
<div class="btn-group">
<button class="delete" th:onclick="formControl.removeConfirm([[${item.id}]])"><span class="hide-txt">삭제</span></button>
<button class="edit" th:onclick="formControl.createModal([[${item.id}]])"><span class="hide-txt">수정</span></button>
</div>
</div>
<ul class="detail-list">
<li th:if="${item.credit != null}">
<p>외상판매</p>
<span th:text="${item.credit ? '예' : '아니오'}">아니오</span>
</li>
<li th:if="${not #strings.isEmpty(item.cropLabel)}">
<p>재배형태</p>
<span th:text="${item.cropLabel}">재배형태</span>
</li>
<li th:if="${not #strings.isEmpty(item.sourcePurpose)}">
<p>수입원</p>
<span th:text="${item.sourcePurpose}">소비자</span>
</li>
<li th:if="${not #strings.isEmpty(item.quantity)}">
<p>수량</p>
<span th:text="|${item.quantity}${item.unitLabel}|">500g</span>
</li>
<li th:if="${not #strings.isEmpty(item.price)}">
<p>현금 </p>
<span th:text="|${#numbers.formatInteger(item.price, 1, 'COMMA')}원|">302,000원</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>
</section>
</th:block>
</div>
</main>
<!-- 하단 고정 버튼 -->
<div class="component-btns "> <!-- TODO : fixed -->
<div class="btns-row">
<button type="button" class="btn btn-l btn-secondary">
<span class="btn-txt">이전 단계로 이동</span>
</button>
<!-- 비활성화 스타일/ 버튼 속성 disable 추가-->
<button type="button" class="btn btn-l btn-primary">
<span class="btn-txt">다음 단계로 이동</span>
</button>
</div>
</div>
<hr/>
</section>
<!-- 모달 팝업 -->
<div class="layer-wrap">
<div class="component-modal acco-wrap modal01" 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 class="modal-close"></button>
</div>
</div>
</div>
</div>
<!-- //모달 팝업 -->
</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: '',
create: '/record/daily/{searchMonth}/{groupNo}',
root: /*[[|/record/daily/${reqVO.searchMonth}/${reqVO.groupNo}|]]*/'rootUrl',
form: /*[[|/record/income/${reqVO.searchMonth}/${reqVO.groupNo}/form/{id}|]]*/'formUrl',
create: /*[[|/api/record/income/${reqVO.searchMonth}/${reqVO.groupNo}/form/{id}|]]*/'createUrl',
remove: /*[[|/api/record/income/${reqVO.searchMonth}/${reqVO.groupNo}/remove|]]*/'removeUrl',
reset: /*[[|/api/record/income/${reqVO.searchMonth}/${reqVO.groupNo}/reset|]]*/'resetUrl',
},
month: [[${reqVO.searchMonth}]],
groupNo: [[${reqVO.groupNo}]],
submitted: false,
};
let bind = {
form: {
selectorId: '.button-modal01',
selector: null,
// scheduleMSeq: null,
// scheduleDSeq: null,
// reserveSeq: null,
},
}
let formControl = {
init() {
formControl._bindUI();
//formControl.createModal();
},
_bindUI() {
etUI.locales.ko = {
dialog: {
positive: '예',
negative: '아니오',
},
};
let $noneWrap = $('#todayNone');
$noneWrap.on('click', 'input[name="todayNone"]', function() {
let checked = $(this).is(':checked');
let $btn = $('.button-modal01');
$btn.attr('disabled', checked);
if (checked) {
$btn.find('i').addClass('ico-add-disabled');
$btn.find('i').removeClass('ico-add');
document.reqForm.todayNone.value = 'Y';
} else {
$btn.find('i').addClass('ico-add');
$btn.find('i').removeClass('ico-add-disabled');
document.reqForm.todayNone.value = 'N';
}
krip.daily.todayNone(ENV.month, ENV.groupNo, 'INCOME', checked);
});
let $formWrap = $(bind.form.selectorId);
$formWrap.on('click', function() {
formControl.createModal();
});
// const $btnModal01 = document.querySelector(".button-modal01");
// $btnModal01.addEventListener("click", function() {
// const modal01 = document.querySelector(".modal01").ui;
// modal01.open();
// });
},
createModal(id) {
if (id === undefined) {
id = 0;
}
ajaxUtil._ajaxAsyncMethod(
ENV.httpUrl.form.replace('{id}', id),
{},
function(rstHtml, status) {
$('.modal01').find('.modal-content').html(rstHtml);
const modal01 = document.querySelector(".modal01").ui;
modal01.open();
},
function(code, rstData) {
kri.logger.error('Do nothing. code: '+ code, rstData);
},
'get',
'html'
);
},
createVaild() {
formControl.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) {
console.log('rstData', rstData)
location.reload();
/*
if (f.todayNone.value === 'Y') {
krip.daily.goToMain();
} else {
krip.daily.goToNext($('input:checked').eq(0).data('target'), ENV.month, ENV.groupNo);
}
*/
},
);
},
removeConfirm(id) {
etUI.dialog.alert({
title: "삭제 안내",
message: "등록하신 내용을 삭제하시겠어요?<br>삭제된 내용은 복구할 수 없습니다.",
type: "confirm",
dialogType: "confirm",
callback: function () {
formControl.remove(id);
},
});
},
remove(id) {
console.log('remove', id)
ajaxUtil._ajaxAsync(
ENV.httpUrl.remove,
{ 'id': id },
function (rstData, status) {
location.reload();
},
);
},
resetConfirm() {
etUI.dialog.alert({
title: "초기화 안내",
message: "등록하신 모든 내용을 삭제하시겠어요?<br>삭제된 내용은 복구할 수 없습니다.",
type: "confirm",
dialogType: "confirm",
callback: function () {
formControl.reset();
},
});
},
reset() {
ajaxUtil._ajaxAsync(
ENV.httpUrl.reset,
{},
function (rstData, status) {
location.reload();
},
);
},
};
</script>
</section>