You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
2.5 KiB
Java
57 lines
2.5 KiB
Java
package com.vmis.interfaceapp.service;
|
|
|
|
import com.vmis.interfaceapp.mapper.CarBassMatterInqireMapper;
|
|
import com.vmis.interfaceapp.model.basic.CarBassMatterInqireVO;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
/**
|
|
* 자동차 기본사항 조회 로그 전용 서비스.
|
|
*
|
|
* <p>로그 적재만 별도 트랜잭션(REQUIRES_NEW)으로 처리하여,
|
|
* 외부 호출 실패나 상위 트랜잭션 롤백 상황에서도 로그는 영속화되도록 보장한다.</p>
|
|
*/
|
|
@Slf4j
|
|
@Service
|
|
@RequiredArgsConstructor
|
|
public class CarBassMatterInqireLogService {
|
|
|
|
private final CarBassMatterInqireMapper carBassMatterInqireMapper;
|
|
|
|
/**
|
|
* 최초 API 요청 정보를 등록한다. (REQUIRES_NEW)
|
|
* @param request 요청 정보
|
|
* @return 생성된 ID
|
|
*/
|
|
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
|
public String createInitialRequestNewTx(CarBassMatterInqireVO request) {
|
|
String generatedId = carBassMatterInqireMapper.selectNextCarBassMatterInqireId();
|
|
request.setCarBassMatterInqireId(generatedId);
|
|
int result = carBassMatterInqireMapper.insertCarBassMatterInqire(request);
|
|
if (result != 1) {
|
|
throw new RuntimeException("자동차 기본 사항 조회 정보 등록 실패");
|
|
}
|
|
log.info("[BASIC-REQ-LOG] 요청 정보 저장 완료(별도TX) - ID: {}, 차량번호: {}", generatedId, request.getDmndVhrno());
|
|
return generatedId;
|
|
}
|
|
|
|
/**
|
|
* 응답/에러 결과를 업데이트한다. (REQUIRES_NEW)
|
|
* @param response 업데이트 내용
|
|
*/
|
|
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
|
public void updateResponseNewTx(CarBassMatterInqireVO response) {
|
|
if (response.getCarBassMatterInqireId() == null) {
|
|
throw new IllegalArgumentException("자동차 기본 사항 조회 ID는 필수입니다.");
|
|
}
|
|
int result = carBassMatterInqireMapper.updateCarBassMatterInqire(response);
|
|
if (result != 1) {
|
|
throw new RuntimeException("자동차 기본 사항 조회 정보 업데이트 실패 - ID: " + response.getCarBassMatterInqireId());
|
|
}
|
|
log.info("[BASIC-RES-LOG] 응답/에러 정보 저장 완료(별도TX) - ID: {}, 결과코드: {}", response.getCarBassMatterInqireId(), response.getCntcResultCode());
|
|
}
|
|
}
|