[BO] 일계부 등록 현황의 삭제 처리
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package app.module.admin.usecase.household.tab.dailyRecord.removeDaily.adapters.persistence;
|
||||
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.removeDaily.ports.RemoveDailyPortOut;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.removeDaily.ports.application.domain.RemoveDailyCmd;
|
||||
import app.module.core.config.application.enums.DailySort;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Slf4j
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
public class RemoveDailyDao implements RemoveDailyPortOut {
|
||||
private final RemoveDailyMapper mapper;
|
||||
|
||||
@Override
|
||||
public void operate(RemoveDailyCmd command) {
|
||||
if (command.getCurrentStep() != null) {
|
||||
log.error("[RemoveDaily] cmd: {}", command);
|
||||
|
||||
if (DailySort.INCOME.equals(command.getCurrentStep())) {
|
||||
mapper.removeDailyIncome(command);
|
||||
} else if (DailySort.WORK.equals(command.getCurrentStep())) {
|
||||
mapper.removeDailyWork(command);
|
||||
} else if (DailySort.EXPENSE.equals(command.getCurrentStep())) {
|
||||
mapper.removeDailyExpense(command);
|
||||
} else if (DailySort.POWER.equals(command.getCurrentStep())) {
|
||||
mapper.removeDailyPower(command);
|
||||
} else if (DailySort.FORESTRY.equals(command.getCurrentStep())) {
|
||||
mapper.removeDailyForestry(command);
|
||||
} else if (DailySort.FARMING.equals(command.getCurrentStep())) {
|
||||
mapper.removeDailyFarming(command);
|
||||
}
|
||||
|
||||
} else {
|
||||
log.error("[RemoveDaily] Current step is null. cmd: {}", command);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package app.module.admin.usecase.household.tab.dailyRecord.removeDaily.adapters.persistence;
|
||||
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.removeDaily.ports.application.domain.RemoveDailyCmd;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface RemoveDailyMapper {
|
||||
/**
|
||||
* 특정일의 수입 전체 삭제
|
||||
* @param command 검색 조건
|
||||
*/
|
||||
void removeDailyIncome(RemoveDailyCmd command);
|
||||
|
||||
/**
|
||||
* 특정일의 임업노동 투입 전체 삭제
|
||||
* @param command 검색 조건
|
||||
*/
|
||||
void removeDailyWork(RemoveDailyCmd command);
|
||||
|
||||
/**
|
||||
* 특정일의 지출 전체 삭제
|
||||
* @param command 검색 조건
|
||||
*/
|
||||
void removeDailyExpense(RemoveDailyCmd command);
|
||||
|
||||
/**
|
||||
* 동력 사용시간 전체 삭제
|
||||
* @param command 검색 조건
|
||||
*/
|
||||
void removeDailyPower(RemoveDailyCmd command);
|
||||
|
||||
/**
|
||||
* 자가임업 생산물 중 자가소비량 전체 삭제
|
||||
* @param command 검색 조건
|
||||
*/
|
||||
void removeDailyForestry(RemoveDailyCmd command);
|
||||
|
||||
/**
|
||||
* 자가농업 생산물 중 자가소비량 전체 삭제
|
||||
* @param command 검색 조건
|
||||
*/
|
||||
void removeDailyFarming(RemoveDailyCmd command);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package app.module.admin.usecase.household.tab.dailyRecord.removeDaily.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.removeDaily.adapters.web.modal.RemoveDailyReqVO;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.removeDaily.ports.RemoveDailyPortIn;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
class RemoveDailyController {
|
||||
private final RemoveDailyPortIn removeDailyNonePortIn;
|
||||
|
||||
@PostMapping(path = "/api/household/daily/remove")
|
||||
ResponseEntity<?> remove(@RequestBody RemoveDailyReqVO reqVO) {
|
||||
log.debug("reqVO: {}", reqVO);
|
||||
|
||||
if (!reqVO.getSelectedIds().isEmpty()) {
|
||||
removeDailyNonePortIn.operate(reqVO);
|
||||
}
|
||||
return ResponseEntity.status(HttpStatus.OK).body(reqVO);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package app.module.admin.usecase.household.tab.dailyRecord.removeDaily.adapters.web.modal;
|
||||
|
||||
import app.module.core.config.application.enums.DailySort;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class RemoveDailyReqVO {
|
||||
/**
|
||||
* 항목 일련번호
|
||||
*/
|
||||
private Set<Long> selectedIds;
|
||||
/**
|
||||
* 현재 단계
|
||||
*/
|
||||
private DailySort currentStep;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package app.module.admin.usecase.household.tab.dailyRecord.removeDaily.ports;
|
||||
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.removeDaily.adapters.web.modal.RemoveDailyReqVO;
|
||||
|
||||
public interface RemoveDailyPortIn {
|
||||
void operate(RemoveDailyReqVO reqVO);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package app.module.admin.usecase.household.tab.dailyRecord.removeDaily.ports;
|
||||
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.removeDaily.ports.application.domain.RemoveDailyCmd;
|
||||
|
||||
public interface RemoveDailyPortOut {
|
||||
void operate(RemoveDailyCmd command);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package app.module.admin.usecase.household.tab.dailyRecord.removeDaily.ports.application;
|
||||
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.removeDaily.adapters.web.modal.RemoveDailyReqVO;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.removeDaily.ports.RemoveDailyPortIn;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.removeDaily.ports.RemoveDailyPortOut;
|
||||
import app.module.admin.usecase.household.tab.dailyRecord.removeDaily.ports.application.domain.RemoveDailyCmd;
|
||||
import app.module.core.config.application.util.AuditUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class RemoveDailyService implements RemoveDailyPortIn {
|
||||
private final RemoveDailyPortOut portOut;
|
||||
|
||||
@Override
|
||||
public void operate(RemoveDailyReqVO reqVO) {
|
||||
RemoveDailyCmd command = AuditUtil.update(
|
||||
new RemoveDailyCmd(
|
||||
reqVO.getSelectedIds(),
|
||||
reqVO.getCurrentStep())
|
||||
);
|
||||
|
||||
portOut.operate(command);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package app.module.admin.usecase.household.tab.dailyRecord.removeDaily.ports.application.domain;
|
||||
|
||||
import app.module.core.config.adapters.persistence.component.AuditCommand;
|
||||
import app.module.core.config.application.enums.DailySort;
|
||||
import app.module.core.config.application.enums.DailyTargetStatus;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@AllArgsConstructor
|
||||
public class RemoveDailyCmd extends AuditCommand {
|
||||
/**
|
||||
* 항목 일련번호
|
||||
*/
|
||||
private Set<Long> removeIds;
|
||||
/**
|
||||
* 현재 단계
|
||||
*/
|
||||
private DailySort currentStep;
|
||||
}
|
||||
@@ -41,7 +41,7 @@ class UpdateDailyNoneDao implements UpdateDailyNonePortOut {
|
||||
dailyRecordPortIn.updateByStatus(command.getSearchMonth(), command.getGroupNo(), command.getHouseholdSeq(), command.getCurrentStep().name(), command.getCurrentStatus().name());
|
||||
|
||||
} else {
|
||||
log.error("[CreateDailyNone] Current step is null. cmd:{}", command);
|
||||
log.error("[UpdateDailyNone] Current step is null. cmd: {}", command);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?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.admin.usecase.household.tab.dailyRecord.removeDaily.adapters.persistence.RemoveDailyMapper">
|
||||
|
||||
<select id="removeDailyIncome">
|
||||
<if test="removeIds != null and removeIds != ''">
|
||||
update daily_income set
|
||||
<include refid="common.fields.DeleteBaseSet"/>
|
||||
where is_deleted = false
|
||||
and id IN
|
||||
<foreach collection="removeIds" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="removeDailyWork">
|
||||
<if test="removeIds != null and removeIds != ''">
|
||||
update daily_work set
|
||||
<include refid="common.fields.DeleteBaseSet"/>
|
||||
where is_deleted = false
|
||||
and daily_record_seq = #{dailyRecordSeq}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="removeDailyExpense">
|
||||
<if test="removeIds != null and removeIds != ''">
|
||||
update daily_expense set
|
||||
<include refid="common.fields.DeleteBaseSet"/>
|
||||
where is_deleted = false
|
||||
and daily_record_seq = #{dailyRecordSeq}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="removeDailyPower">
|
||||
<if test="removeIds != null and removeIds != ''">
|
||||
update daily_power set
|
||||
<include refid="common.fields.DeleteBaseSet"/>
|
||||
where is_deleted = false
|
||||
and daily_record_seq = #{dailyRecordSeq}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="removeDailyForestry">
|
||||
<if test="removeIds != null and removeIds != ''">
|
||||
update daily_forestry set
|
||||
<include refid="common.fields.DeleteBaseSet"/>
|
||||
where is_deleted = false
|
||||
and daily_record_seq = #{dailyRecordSeq}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="removeDailyFarming">
|
||||
<if test="removeIds != null and removeIds != ''">
|
||||
update daily_farming set
|
||||
<include refid="common.fields.DeleteBaseSet"/>
|
||||
where is_deleted = false
|
||||
and daily_record_seq = #{dailyRecordSeq}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -502,7 +502,7 @@
|
||||
<td>
|
||||
<div class="component-input">
|
||||
<label class="checkbox-inner">
|
||||
<input type="checkbox" id="temp_checkbox_000${item.id}" name="temp_checkbox_000${item.id}" value="${item.id}">
|
||||
<input type="checkbox" id="temp_checkbox_000${item.id}" name="temp_checkbox_income" value="${item.id}">
|
||||
</label>
|
||||
</div>
|
||||
</td>
|
||||
@@ -510,7 +510,7 @@
|
||||
<td>${ifNullHyphen(item.cropText)}</td><!-- 재배형태 -->
|
||||
<td class="underline">${ifNullHyphen(item.incomeKind)}</td><!-- 수입의 종류 -->
|
||||
<td>${ifNullHyphen(item.sourcePurpose)}</td><!-- 수입원 -->
|
||||
<td class="align-right">${ifNullHyphen(item.quantity)}</td><!-- 수량 -->
|
||||
<td class="align-right">${formatNumberWithComma(item.quantity)}</td><!-- 수량 -->
|
||||
<td>${ifNullHyphen(item.unitText)}</td><!-- 단위 -->
|
||||
<td class="align-right">${formatNumberWithComma(item.price)}</td><!-- 현금(원) -->
|
||||
<td class="align-right">${formatNumberWithComma(item.estimatedValue)}</td><!-- 현물평가액 -->
|
||||
@@ -817,7 +817,39 @@
|
||||
const currentListId = $(el).data('listId');
|
||||
console.log('removeDaily', currentStep, currentListId);
|
||||
|
||||
alert('TODO : 삭제')
|
||||
if ($('#'+currentListId).find('input[type="checkbox"]:checked').length === 0) {
|
||||
alert('삭제내용은 최소 1건은 선택해야 합니다.');
|
||||
return;
|
||||
} else if ($('#'+currentListId).find('input[type="checkbox"]').length === $('#'+currentListId).find('input[type="checkbox"]:checked').length) {
|
||||
alert('등록내용은 최소 1건이 남아 있어야 합니다.');
|
||||
return;
|
||||
}
|
||||
|
||||
const selectedValues = [];
|
||||
$('#'+currentListId).find('input[type="checkbox"]:checked').each((idx, item) => {
|
||||
selectedValues.push($(item).val());
|
||||
});
|
||||
|
||||
const obj = {};
|
||||
obj.selectedIds = selectedValues;
|
||||
obj.currentStep = currentStep;
|
||||
console.log(obj)
|
||||
|
||||
etUI.dialog.confirm({
|
||||
title: '삭제 안내',
|
||||
message: '선택하신 항목을 삭제하시겠습니까?<br>삭제한 항목은 복구할 수 없습니다.',
|
||||
positiveCallback: function () {
|
||||
ajaxUtil._ajaxAsyncNoWaiting(
|
||||
'/api/household/daily/remove',
|
||||
obj,
|
||||
function () {
|
||||
alert('데이터 삭제가 완료되었습니다.');
|
||||
|
||||
getDailyRecordsView(f.dailyId.value, f.groupNo.value, f.dayGroupText.value);
|
||||
},
|
||||
);
|
||||
},
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user