Order 삭제를 위한 앤드포인트 추가
This commit is contained in:
parent
33ca6f76d5
commit
42d020c3cd
|
|
@ -164,4 +164,14 @@ public class CustomerDailyOrderController {
|
||||||
dailyOrderService.deleteDailyOrder(uuid);
|
dailyOrderService.deleteDailyOrder(uuid);
|
||||||
return ResponseEntity.noContent().build();
|
return ResponseEntity.noContent().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/customer/{customerNo}/date/{orderDate}/jobtype/{jobType}")
|
||||||
|
public ResponseEntity<Void> deleteDailyOrderByBusinessKey(
|
||||||
|
@PathVariable String customerNo,
|
||||||
|
@PathVariable @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate orderDate,
|
||||||
|
@PathVariable String jobType) {
|
||||||
|
|
||||||
|
dailyOrderService.removeDailyOrderByBusinessKey(customerNo, orderDate, jobType);
|
||||||
|
return ResponseEntity.noContent().build(); // 204
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,108 @@
|
||||||
|
package com.goi.erp.entity;
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.EntityListeners;
|
||||||
|
import jakarta.persistence.GeneratedValue;
|
||||||
|
import jakarta.persistence.GenerationType;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(schema="crm", name = "customer_daily_order_removed")
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Builder
|
||||||
|
@EntityListeners(AuditingEntityListener.class)
|
||||||
|
public class CustomerDailyOrderRemoved {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long cdoId;
|
||||||
|
|
||||||
|
private UUID cdoUuid;
|
||||||
|
|
||||||
|
private LocalDateTime cdoDeletedAt;
|
||||||
|
|
||||||
|
private LocalDate cdoOrderDate;
|
||||||
|
|
||||||
|
private String cdoJobType;
|
||||||
|
|
||||||
|
@Column(length = 1)
|
||||||
|
private String cdoOrderType;
|
||||||
|
|
||||||
|
private String cdoRequestNote;
|
||||||
|
|
||||||
|
private Long cdoRegionId;
|
||||||
|
private Long cdoDriverId;
|
||||||
|
|
||||||
|
private Long cdoCustomerId;
|
||||||
|
private String cdoCustomerNo;
|
||||||
|
|
||||||
|
@Column(length = 10)
|
||||||
|
private String cdoPaymentType;
|
||||||
|
|
||||||
|
@Column(length = 1)
|
||||||
|
private String cdoCycle;
|
||||||
|
|
||||||
|
private BigDecimal cdoRate;
|
||||||
|
|
||||||
|
private LocalDateTime cdoCreatedAt;
|
||||||
|
|
||||||
|
@Column(name = "cdo_created_by")
|
||||||
|
private String cdoCreatedBy;
|
||||||
|
|
||||||
|
private LocalDateTime cdoUpdatedAt;
|
||||||
|
|
||||||
|
@Column(name = "cdo_updated_by")
|
||||||
|
private String cdoUpdatedBy;
|
||||||
|
|
||||||
|
@Column(length = 1)
|
||||||
|
private String cdoStatus;
|
||||||
|
|
||||||
|
@Column(length = 1)
|
||||||
|
private String cdoVisitFlag;
|
||||||
|
|
||||||
|
private LocalDateTime cdoPickupAt;
|
||||||
|
|
||||||
|
private String cdoPickupNote;
|
||||||
|
|
||||||
|
private BigDecimal cdoEstimatedQty;
|
||||||
|
|
||||||
|
private BigDecimal cdoQuantity;
|
||||||
|
|
||||||
|
private Integer cdoSludge;
|
||||||
|
|
||||||
|
@Column(length = 1)
|
||||||
|
private String cdoPayStatus;
|
||||||
|
|
||||||
|
private BigDecimal cdoPayAmount;
|
||||||
|
|
||||||
|
@Column(length = 200)
|
||||||
|
private String cdoPayeeName;
|
||||||
|
|
||||||
|
@Column(length = 200)
|
||||||
|
private String cdoPayeeSign;
|
||||||
|
|
||||||
|
@Column(precision = 10, scale = 7)
|
||||||
|
private BigDecimal cdoPickupLat;
|
||||||
|
|
||||||
|
@Column(precision = 10, scale = 7)
|
||||||
|
private BigDecimal cdoPickupLon;
|
||||||
|
|
||||||
|
private Integer cdoPickupMin;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.goi.erp.repository;
|
||||||
|
|
||||||
|
import com.goi.erp.entity.CustomerDailyOrderRemoved;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface CustomerDailyOrderRemovedRepository extends JpaRepository<CustomerDailyOrderRemoved, Long> {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -13,7 +13,7 @@ import java.time.LocalDate;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface CustomerDailyOrderRepository extends JpaRepository<CustomerDailyOrder, Integer> {
|
public interface CustomerDailyOrderRepository extends JpaRepository<CustomerDailyOrder, Long> {
|
||||||
|
|
||||||
// 기본 페이징 조회
|
// 기본 페이징 조회
|
||||||
Page<CustomerDailyOrder> findAll(Pageable pageable);
|
Page<CustomerDailyOrder> findAll(Pageable pageable);
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,9 @@ package com.goi.erp.service;
|
||||||
import com.goi.erp.dto.CustomerDailyOrderRequestDto;
|
import com.goi.erp.dto.CustomerDailyOrderRequestDto;
|
||||||
import com.goi.erp.dto.CustomerDailyOrderResponseDto;
|
import com.goi.erp.dto.CustomerDailyOrderResponseDto;
|
||||||
import com.goi.erp.entity.CustomerDailyOrder;
|
import com.goi.erp.entity.CustomerDailyOrder;
|
||||||
|
import com.goi.erp.entity.CustomerDailyOrderRemoved;
|
||||||
import com.goi.erp.repository.CustomerDailyOrderRepository;
|
import com.goi.erp.repository.CustomerDailyOrderRepository;
|
||||||
|
import com.goi.erp.repository.CustomerDailyOrderRemovedRepository;
|
||||||
import com.goi.erp.repository.CustomerRepository;
|
import com.goi.erp.repository.CustomerRepository;
|
||||||
|
|
||||||
import jakarta.transaction.Transactional;
|
import jakarta.transaction.Transactional;
|
||||||
|
|
@ -24,6 +26,7 @@ import java.util.UUID;
|
||||||
public class CustomerDailyOrderService {
|
public class CustomerDailyOrderService {
|
||||||
|
|
||||||
private final CustomerDailyOrderRepository dailyOrderRepository;
|
private final CustomerDailyOrderRepository dailyOrderRepository;
|
||||||
|
private final CustomerDailyOrderRemovedRepository removedRepository;
|
||||||
private final CustomerRepository customerRepository;
|
private final CustomerRepository customerRepository;
|
||||||
private final HcmEmployeeClient hcmEmployeeClient;
|
private final HcmEmployeeClient hcmEmployeeClient;
|
||||||
|
|
||||||
|
|
@ -179,6 +182,57 @@ public class CustomerDailyOrderService {
|
||||||
dailyOrderRepository.delete(existing);
|
dailyOrderRepository.delete(existing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void removeDailyOrderByBusinessKey(String customerNo, LocalDate orderDate, String jobType) {
|
||||||
|
|
||||||
|
CustomerDailyOrder existing = dailyOrderRepository
|
||||||
|
.findByCdoCustomerNoAndCdoOrderDateAndCdoJobType(customerNo, orderDate, jobType)
|
||||||
|
.orElse(null);
|
||||||
|
|
||||||
|
// ★ 멱등성: 이미 없으면 성공 처리하고 끝
|
||||||
|
if (existing == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// customer_daily_order_removed 로 복사
|
||||||
|
CustomerDailyOrderRemoved removed = CustomerDailyOrderRemoved.builder()
|
||||||
|
.cdoUuid(existing.getCdoUuid())
|
||||||
|
.cdoOrderDate(existing.getCdoOrderDate())
|
||||||
|
.cdoJobType(existing.getCdoJobType())
|
||||||
|
.cdoOrderType(existing.getCdoOrderType())
|
||||||
|
.cdoRequestNote(existing.getCdoRequestNote())
|
||||||
|
.cdoRegionId(existing.getCdoRegionId())
|
||||||
|
.cdoDriverId(existing.getCdoDriverId())
|
||||||
|
.cdoCustomerId(existing.getCdoCustomerId())
|
||||||
|
.cdoCustomerNo(existing.getCdoCustomerNo())
|
||||||
|
.cdoPaymentType(existing.getCdoPaymentType())
|
||||||
|
.cdoCycle(existing.getCdoCycle())
|
||||||
|
.cdoRate(existing.getCdoRate())
|
||||||
|
.cdoCreatedAt(existing.getCdoCreatedAt())
|
||||||
|
.cdoCreatedBy(existing.getCdoCreatedBy())
|
||||||
|
.cdoUpdatedAt(existing.getCdoUpdatedAt())
|
||||||
|
.cdoUpdatedBy(existing.getCdoUpdatedBy())
|
||||||
|
.cdoStatus(existing.getCdoStatus())
|
||||||
|
.cdoVisitFlag(existing.getCdoVisitFlag())
|
||||||
|
.cdoEstimatedQty(existing.getCdoEstimatedQty())
|
||||||
|
.cdoQuantity(existing.getCdoQuantity())
|
||||||
|
.cdoSludge(existing.getCdoSludge())
|
||||||
|
.cdoPayStatus(existing.getCdoPayStatus())
|
||||||
|
.cdoPayAmount(existing.getCdoPayAmount())
|
||||||
|
.cdoPayeeName(existing.getCdoPayeeName())
|
||||||
|
.cdoPayeeSign(existing.getCdoPayeeSign())
|
||||||
|
.cdoPickupAt(existing.getCdoPickupAt())
|
||||||
|
.cdoPickupNote(existing.getCdoPickupNote())
|
||||||
|
.cdoPickupLat(existing.getCdoPickupLat())
|
||||||
|
.cdoPickupLon(existing.getCdoPickupLon())
|
||||||
|
.cdoPickupMin(existing.getCdoPickupMin())
|
||||||
|
.cdoDeletedAt(LocalDateTime.now())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
removedRepository.save(removed);
|
||||||
|
dailyOrderRepository.delete(existing);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal Update Logic (CustomerService 동일 스타일)
|
* Internal Update Logic (CustomerService 동일 스타일)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue