refactor: service 내 transaction, throw QcastException 처리 추가

This commit is contained in:
Daseul Kim 2025-02-12 17:42:00 +09:00
parent 30b06b7f8b
commit ff25eb4565
9 changed files with 192 additions and 119 deletions

View File

@ -23,7 +23,8 @@ public class CanvasBasicSettingController {
@Operation(description = "Canvas Basic Setting 정보를 조회 한다.") @Operation(description = "Canvas Basic Setting 정보를 조회 한다.")
@GetMapping("/canvas-basic-settings/by-object/{objectNo}") @GetMapping("/canvas-basic-settings/by-object/{objectNo}")
public List<CanvasBasicSettingResponse> selectCanvasBasicSetting(@PathVariable String objectNo) { public List<CanvasBasicSettingResponse> selectCanvasBasicSetting(@PathVariable String objectNo)
throws QcastException {
log.debug("Basic Setting 조회 ::::: " + objectNo); log.debug("Basic Setting 조회 ::::: " + objectNo);

View File

@ -13,19 +13,27 @@ import java.util.Map;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Slf4j @Slf4j
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
@Transactional(readOnly = true)
public class CanvasBasicSettingService { public class CanvasBasicSettingService {
private final CanvasBasicSettingMapper canvasBasicSettingMapper; private final CanvasBasicSettingMapper canvasBasicSettingMapper;
// Canvas Basic Setting 조회(objectNo) // Canvas Basic Setting 조회(objectNo)
public List<CanvasBasicSettingResponse> selectCanvasBasicSetting(String objectNo) { public List<CanvasBasicSettingResponse> selectCanvasBasicSetting(String objectNo)
return canvasBasicSettingMapper.selectCanvasBasicSetting(objectNo); throws QcastException {
try {
return canvasBasicSettingMapper.selectCanvasBasicSetting(objectNo);
} catch (Exception e) {
throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, e.getMessage());
}
} }
// Canvas Basic Setting 등록 // Canvas Basic Setting 등록
@Transactional
public Map<String, String> insertCanvasBasicSetting(CanvasBasicSettingInfo csi) public Map<String, String> insertCanvasBasicSetting(CanvasBasicSettingInfo csi)
throws QcastException { throws QcastException {
@ -56,9 +64,6 @@ public class CanvasBasicSettingService {
canvasBasicSettingMapper.insertRoofMaterialsAdd(rma); canvasBasicSettingMapper.insertRoofMaterialsAdd(rma);
} }
response.put("objectNo", csi.getObjectNo());
response.put("returnMessage", "common.message.confirm.mark");
} else { } else {
// 도면/치수/각도 정보 update // 도면/치수/각도 정보 update
canvasBasicSettingMapper.updateCanvasBasicSetting(csi); canvasBasicSettingMapper.updateCanvasBasicSetting(csi);
@ -70,14 +75,12 @@ public class CanvasBasicSettingService {
// 신규 지붕재추가 정보 insert // 신규 지붕재추가 정보 insert
canvasBasicSettingMapper.updateRoofMaterialsAdd(rma); canvasBasicSettingMapper.updateRoofMaterialsAdd(rma);
} }
response.put("objectNo", csi.getObjectNo());
response.put("returnMessage", "common.message.confirm.mark");
} }
response.put("objectNo", csi.getObjectNo());
response.put("returnMessage", "common.message.confirm.mark");
} catch (Exception e) { } catch (Exception e) {
response.put("objectNo", csi.getObjectNo()); throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, e.getMessage());
response.put("returnMessage", "common.message.save.error");
} }
// 생성된 objectNo 반환 // 생성된 objectNo 반환
@ -85,6 +88,7 @@ public class CanvasBasicSettingService {
} }
// 지붕면 할당 Setting 등록 // 지붕면 할당 Setting 등록
@Transactional
public Map<String, String> insertRoofAllocSetting(RoofAllocationSettingInfo rasi) public Map<String, String> insertRoofAllocSetting(RoofAllocationSettingInfo rasi)
throws QcastException { throws QcastException {
@ -107,8 +111,7 @@ public class CanvasBasicSettingService {
response.put("objectNo", rasi.getObjectNo()); response.put("objectNo", rasi.getObjectNo());
response.put("returnMessage", "common.message.confirm.mark"); response.put("returnMessage", "common.message.confirm.mark");
} catch (Exception e) { } catch (Exception e) {
response.put("objectNo", rasi.getObjectNo()); throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, e.getMessage());
response.put("returnMessage", "common.message.save.error");
} }
// 생성된 objectNo 반환 // 생성된 objectNo 반환
@ -116,20 +119,26 @@ public class CanvasBasicSettingService {
} }
// 지붕재추가 삭제 // 지붕재추가 삭제
@Transactional
public void deleteRoofMaterialsAdd(String objectNo) throws QcastException { public void deleteRoofMaterialsAdd(String objectNo) throws QcastException {
if (objectNo == null || objectNo.trim().isEmpty()) { if (objectNo == null || objectNo.trim().isEmpty()) {
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, "올바르지 않은 입력값입니다."); throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, "올바르지 않은 입력값입니다.");
} }
// 먼저 데이터가 존재하는지 확인 try {
RoofMaterialsAddInfo cntData = canvasBasicSettingMapper.getRoofMaterialsCnt(objectNo); // 먼저 데이터가 존재하는지 확인
RoofMaterialsAddInfo cntData = canvasBasicSettingMapper.getRoofMaterialsCnt(objectNo);
// 데이터가 존재하지 않으면 수정하지 않고 예외를 던짐 // 데이터가 존재하지 않으면 수정하지 않고 예외를 던짐
if (cntData.getRoofCnt().intValue() > 0) { if (cntData.getRoofCnt().intValue() > 0) {
canvasBasicSettingMapper.deleteRoofMaterialsAdd(objectNo); canvasBasicSettingMapper.deleteRoofMaterialsAdd(objectNo);
} else { } else {
throw new QcastException(ErrorCode.NOT_FOUND, "삭제할 지붕재가 존재하지 않습니다."); throw new QcastException(ErrorCode.NOT_FOUND, "삭제할 지붕재가 존재하지 않습니다.");
}
} catch (Exception e) {
if (e instanceof QcastException) throw e;
throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, e.getMessage());
} }
} }
} }

View File

@ -1,14 +1,12 @@
package com.interplug.qcast.biz.canvasGridSetting; package com.interplug.qcast.biz.canvasGridSetting;
import com.interplug.qcast.biz.canvasGridSetting.dto.CanvasGridSettingInfo; import com.interplug.qcast.biz.canvasGridSetting.dto.CanvasGridSettingInfo;
import com.interplug.qcast.config.Exception.QcastException;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.Map;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import java.util.Map;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -22,7 +20,8 @@ public class CanvasGridSettingController {
@Operation(description = "Canvas Grid Setting 정보를 조회 한다.") @Operation(description = "Canvas Grid Setting 정보를 조회 한다.")
@GetMapping("/canvas-grid-settings/by-object/{objectNo}") @GetMapping("/canvas-grid-settings/by-object/{objectNo}")
public CanvasGridSettingInfo selectCanvasGridSetting(@PathVariable String objectNo) { public CanvasGridSettingInfo selectCanvasGridSetting(@PathVariable String objectNo)
throws QcastException {
log.debug("Grid Setting 조회 ::::: " + objectNo); log.debug("Grid Setting 조회 ::::: " + objectNo);
@ -32,7 +31,8 @@ public class CanvasGridSettingController {
@Operation(description = "Canvas Grid Setting 정보를 등록 한다.") @Operation(description = "Canvas Grid Setting 정보를 등록 한다.")
@PostMapping("/canvas-grid-settings") @PostMapping("/canvas-grid-settings")
@ResponseStatus(HttpStatus.CREATED) @ResponseStatus(HttpStatus.CREATED)
public Map<String, String> insertCanvasGridStatus(@RequestBody CanvasGridSettingInfo csi) { public Map<String, String> insertCanvasGridStatus(@RequestBody CanvasGridSettingInfo csi)
throws QcastException {
log.debug("Grid Setting 등록 ::::: " + csi.getObjectNo()); log.debug("Grid Setting 등록 ::::: " + csi.getObjectNo());

View File

@ -2,25 +2,35 @@ package com.interplug.qcast.biz.canvasGridSetting;
import com.interplug.qcast.biz.canvasGridSetting.dto.CanvasGridSettingInfo; import com.interplug.qcast.biz.canvasGridSetting.dto.CanvasGridSettingInfo;
import com.interplug.qcast.config.Exception.ErrorCode;
import com.interplug.qcast.config.Exception.QcastException;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
@Transactional(readOnly = true)
public class CanvasGridSettingService { public class CanvasGridSettingService {
private final CanvasGridSettingMapper canvasGridSettingMapper; private final CanvasGridSettingMapper canvasGridSettingMapper;
// Canvas Setting 조회(objectNo) // Canvas Setting 조회(objectNo)
public CanvasGridSettingInfo selectCanvasGridSetting(String objectNo) { public CanvasGridSettingInfo selectCanvasGridSetting(String objectNo) throws QcastException {
return canvasGridSettingMapper.selectCanvasGridSetting(objectNo); try {
return canvasGridSettingMapper.selectCanvasGridSetting(objectNo);
} catch (Exception e) {
throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, e.getMessage());
}
} }
// Canvas Setting 등록 // Canvas Setting 등록
public Map<String, String> insertCanvasGridSetting(CanvasGridSettingInfo csi) { @Transactional
public Map<String, String> insertCanvasGridSetting(CanvasGridSettingInfo csi)
throws QcastException {
Map<String, String> response = new HashMap<>(); Map<String, String> response = new HashMap<>();
@ -31,8 +41,7 @@ public class CanvasGridSettingService {
response.put("returnMessage", "common.message.confirm.mark"); response.put("returnMessage", "common.message.confirm.mark");
} catch (Exception e) { } catch (Exception e) {
response.put("objectNo", csi.getObjectNo()); throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, e.getMessage());
response.put("returnMessage", "common.message.save.error");
} }
// 생성된 objectNo 반환 // 생성된 objectNo 반환

View File

@ -2,14 +2,11 @@ package com.interplug.qcast.biz.canvasSetting;
import com.interplug.qcast.biz.canvasSetting.dto.CanvasSettingInfo; import com.interplug.qcast.biz.canvasSetting.dto.CanvasSettingInfo;
import com.interplug.qcast.config.Exception.QcastException; import com.interplug.qcast.config.Exception.QcastException;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.Map;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import java.util.Map;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -23,7 +20,8 @@ public class CanvasSettingController {
@Operation(description = "Canvas Setting 정보를 조회 한다.") @Operation(description = "Canvas Setting 정보를 조회 한다.")
@GetMapping("/canvas-settings/by-object/{objectNo}") @GetMapping("/canvas-settings/by-object/{objectNo}")
public CanvasSettingInfo selectCanvasSetting(@PathVariable String objectNo) { public CanvasSettingInfo selectCanvasSetting(@PathVariable String objectNo)
throws QcastException {
log.debug("Setting 조회 ::::: " + objectNo); log.debug("Setting 조회 ::::: " + objectNo);
@ -43,7 +41,7 @@ public class CanvasSettingController {
@Operation(description = "Canvas Setting 정보를 수정 한다.") @Operation(description = "Canvas Setting 정보를 수정 한다.")
@PutMapping("/canvas-settings") @PutMapping("/canvas-settings")
public void updateCanvasStatus(@RequestBody CanvasSettingInfo csi) { public void updateCanvasStatus(@RequestBody CanvasSettingInfo csi) throws QcastException {
log.debug("Setting 수정 ::::: " + csi.getObjectNo()); log.debug("Setting 수정 ::::: " + csi.getObjectNo());

View File

@ -7,18 +7,25 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
@Transactional(readOnly = true)
public class CanvasSettingService { public class CanvasSettingService {
private final CanvasSettingMapper canvasSettingMapper; private final CanvasSettingMapper canvasSettingMapper;
// Canvas Setting 조회(objectNo) // Canvas Setting 조회(objectNo)
public CanvasSettingInfo selectCanvasSetting(String objectNo) { public CanvasSettingInfo selectCanvasSetting(String objectNo) throws QcastException {
return canvasSettingMapper.selectCanvasSetting(objectNo); try {
return canvasSettingMapper.selectCanvasSetting(objectNo);
} catch (Exception e) {
throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, e.getMessage());
}
} }
// Canvas Setting 등록 // Canvas Setting 등록
@Transactional
public Map<String, String> insertCanvasSetting(CanvasSettingInfo csi) throws QcastException { public Map<String, String> insertCanvasSetting(CanvasSettingInfo csi) throws QcastException {
Map<String, String> response = new HashMap<>(); Map<String, String> response = new HashMap<>();
@ -35,20 +42,13 @@ public class CanvasSettingService {
// 데이터가 존재하지 않으면 insert // 데이터가 존재하지 않으면 insert
if (cntData.getCnt().intValue() < 1) { if (cntData.getCnt().intValue() < 1) {
canvasSettingMapper.insertCanvasSetting(csi); canvasSettingMapper.insertCanvasSetting(csi);
response.put("objectNo", csi.getObjectNo());
response.put("returnMessage", "common.message.confirm.mark");
} else { } else {
canvasSettingMapper.updateCanvasSetting(csi); canvasSettingMapper.updateCanvasSetting(csi);
response.put("objectNo", csi.getObjectNo());
response.put("returnMessage", "common.message.confirm.mark");
} }
} catch (Exception e) {
response.put("objectNo", csi.getObjectNo()); response.put("objectNo", csi.getObjectNo());
response.put("returnMessage", "common.message.save.error"); response.put("returnMessage", "common.message.confirm.mark");
} catch (Exception e) {
throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, e.getMessage());
} }
// 생성된 objectNo 반환 // 생성된 objectNo 반환
@ -56,7 +56,12 @@ public class CanvasSettingService {
} }
// Canvas Setting 수정 // Canvas Setting 수정
public void updateCanvasSetting(CanvasSettingInfo csi) { @Transactional
canvasSettingMapper.updateCanvasSetting(csi); public void updateCanvasSetting(CanvasSettingInfo csi) throws QcastException {
try {
canvasSettingMapper.updateCanvasSetting(csi);
} catch (Exception e) {
throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, e.getMessage());
}
} }
} }

View File

@ -8,9 +8,11 @@ import com.interplug.qcast.config.Exception.QcastException;
import java.util.List; import java.util.List;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
@Transactional(readOnly = true)
public class CanvasStatusService { public class CanvasStatusService {
private final CanvasStatusMapper canvasStatusMapper; private final CanvasStatusMapper canvasStatusMapper;
@ -18,10 +20,15 @@ public class CanvasStatusService {
public List<CanvasStatusResponse> selectAllCanvasStatus(String userId) throws QcastException { public List<CanvasStatusResponse> selectAllCanvasStatus(String userId) throws QcastException {
List<CanvasStatusResponse> result = null; List<CanvasStatusResponse> result = null;
if (userId != null && !userId.trim().isEmpty()) { try {
result = canvasStatusMapper.selectAllCanvasStatus(userId); if (userId != null && !userId.trim().isEmpty()) {
} else { result = canvasStatusMapper.selectAllCanvasStatus(userId);
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, "올바르지 않은 입력값입니다."); } else {
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, "올바르지 않은 입력값입니다.");
}
} catch (Exception e) {
if (e instanceof QcastException) throw e;
throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, e.getMessage());
} }
return result; return result;
@ -32,16 +39,22 @@ public class CanvasStatusService {
throws QcastException { throws QcastException {
List<CanvasStatusResponse> result = null; List<CanvasStatusResponse> result = null;
if (objectNo != null && !objectNo.trim().isEmpty()) { try {
result = canvasStatusMapper.selectObjectNoCanvasStatus(objectNo); if (objectNo != null && !objectNo.trim().isEmpty()) {
} else { result = canvasStatusMapper.selectObjectNoCanvasStatus(objectNo);
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, "올바르지 않은 입력값입니다."); } else {
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, "올바르지 않은 입력값입니다.");
}
} catch (Exception e) {
if (e instanceof QcastException) throw e;
throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, e.getMessage());
} }
return result; return result;
} }
// 캔버스 등록 // 캔버스 등록
@Transactional
public Integer insertCanvasStatus(CanvasStatus cs) throws QcastException { public Integer insertCanvasStatus(CanvasStatus cs) throws QcastException {
Integer id = 0; Integer id = 0;
@ -56,7 +69,7 @@ public class CanvasStatusService {
id = maxId.get(0).getId(); id = maxId.get(0).getId();
} catch (Exception e) { } catch (Exception e) {
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, "캔버스 등록 중 오류 발생"); throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, e.getMessage());
} }
// 생성된 id 반환 // 생성된 id 반환
@ -64,63 +77,82 @@ public class CanvasStatusService {
} }
// 캔버스 수정 // 캔버스 수정
@Transactional
public void updateCanvasStatus(CanvasStatus cs) throws QcastException { public void updateCanvasStatus(CanvasStatus cs) throws QcastException {
if (cs.getId() == null) { if (cs.getId() == null) {
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, "올바르지 않은 입력값입니다."); throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, "올바르지 않은 입력값입니다.");
} }
// 먼저 데이터가 존재하는지 확인 try {
List<CanvasStatusResponse> existingStatus = canvasStatusMapper.getIdCanvasStatus(cs.getId()); // 먼저 데이터가 존재하는지 확인
List<CanvasStatusResponse> existingStatus = canvasStatusMapper.getIdCanvasStatus(cs.getId());
// 데이터가 존재하지 않으면 수정하지 않고 예외를 던짐 // 데이터가 존재하지 않으면 수정하지 않고 예외를 던짐
if (existingStatus.size() > 0) { if (existingStatus.size() > 0) {
canvasStatusMapper.updateCanvasStatus(cs); canvasStatusMapper.updateCanvasStatus(cs);
} else { } else {
throw new QcastException(ErrorCode.NOT_FOUND, "수정할 캔버스가 존재하지 않습니다."); throw new QcastException(ErrorCode.NOT_FOUND, "수정할 캔버스가 존재하지 않습니다.");
}
} catch (Exception e) {
if (e instanceof QcastException) throw e;
throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, e.getMessage());
} }
} }
// 물건번호(objectNo) 해당하는 캔버스 삭제 // 물건번호(objectNo) 해당하는 캔버스 삭제
@Transactional
public void deleteObjectNoCanvasStatus(String objectNo) throws QcastException { public void deleteObjectNoCanvasStatus(String objectNo) throws QcastException {
if (objectNo == null || objectNo.trim().isEmpty()) { if (objectNo == null || objectNo.trim().isEmpty()) {
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, "올바르지 않은 입력값입니다."); throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, "올바르지 않은 입력값입니다.");
} }
// 먼저 데이터가 존재하는지 확인 try {
List<CanvasStatusResponse> existingStatus = // 먼저 데이터가 존재하는지 확인
canvasStatusMapper.getObjectNoCanvasStatus(objectNo); List<CanvasStatusResponse> existingStatus =
canvasStatusMapper.getObjectNoCanvasStatus(objectNo);
// 데이터가 존재하지 않으면 수정하지 않고 예외를 던짐 // 데이터가 존재하지 않으면 수정하지 않고 예외를 던짐
if (existingStatus.size() > 0) { if (existingStatus.size() > 0) {
canvasStatusMapper.deleteObjectNoCanvasStatus(objectNo); canvasStatusMapper.deleteObjectNoCanvasStatus(objectNo);
} else { } else {
throw new QcastException(ErrorCode.NOT_FOUND, "삭제할 캔버스가 존재하지 않습니다."); throw new QcastException(ErrorCode.NOT_FOUND, "삭제할 캔버스가 존재하지 않습니다.");
}
} catch (Exception e) {
if (e instanceof QcastException) throw e;
throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, e.getMessage());
} }
} }
// id에 해당하는 캔버스 삭제 // id에 해당하는 캔버스 삭제
@Transactional
public void deleteIdCanvasStatus(Integer id) throws QcastException { public void deleteIdCanvasStatus(Integer id) throws QcastException {
if (id == null) { if (id == null) {
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, "올바르지 않은 입력값입니다."); throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, "올바르지 않은 입력값입니다.");
} }
// 먼저 데이터가 존재하는지 확인 try {
List<CanvasStatusResponse> existingStatus = canvasStatusMapper.getIdCanvasStatus(id); // 먼저 데이터가 존재하는지 확인
List<CanvasStatusResponse> existingStatus = canvasStatusMapper.getIdCanvasStatus(id);
// 데이터가 존재하지 않으면 처리하지 않고 예외를 던짐 // 데이터가 존재하지 않으면 처리하지 않고 예외를 던짐
if (existingStatus.size() > 0) { if (existingStatus.size() > 0) {
// 데이터를 삭제하는 기존 방식에서 데이터를 삭제하지 않고 deleted 데이터를 바꾸는 방식으로 변경 (2025.02.11) // 데이터를 삭제하는 기존 방식에서 데이터를 삭제하지 않고 deleted 데이터를 바꾸는 방식으로 변경 (2025.02.11)
// canvasStatusMapper.deleteIdCanvasStatus(id); // canvasStatusMapper.deleteIdCanvasStatus(id);
canvasStatusMapper.updateDeletedCanvasStatus(id); canvasStatusMapper.updateDeletedCanvasStatus(id);
} else { } else {
throw new QcastException(ErrorCode.NOT_FOUND, "삭제할 캔버스가 존재하지 않습니다."); throw new QcastException(ErrorCode.NOT_FOUND, "삭제할 캔버스가 존재하지 않습니다.");
}
} catch (Exception e) {
if (e instanceof QcastException) throw e;
throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, e.getMessage());
} }
} }
// 캔버스 복사 등록 // 캔버스 복사 등록
@Transactional
public int copyCanvasStatus(CanvasStatusCopyRequest cs) throws QcastException { public int copyCanvasStatus(CanvasStatusCopyRequest cs) throws QcastException {
try { try {
canvasStatusMapper.copyCanvasStatus(cs); canvasStatusMapper.copyCanvasStatus(cs);

View File

@ -4,6 +4,7 @@ import com.interplug.qcast.biz.displayItem.dto.DisplayItemRequest;
import com.interplug.qcast.biz.displayItem.dto.ItemDetailResponse; import com.interplug.qcast.biz.displayItem.dto.ItemDetailResponse;
import com.interplug.qcast.biz.displayItem.dto.ItemRequest; import com.interplug.qcast.biz.displayItem.dto.ItemRequest;
import com.interplug.qcast.biz.displayItem.dto.ItemResponse; import com.interplug.qcast.biz.displayItem.dto.ItemResponse;
import com.interplug.qcast.config.Exception.QcastException;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.List; import java.util.List;
@ -30,13 +31,13 @@ public class DisplayItemController {
* 전시제품 정보 등록/수정 * 전시제품 정보 등록/수정
* *
* @param displayItemRequest * @param displayItemRequest
* @throws Exception * @throws QcastException
*/ */
@Operation(description = "전시제품 정보를 등록/수정한다. (동기화)") @Operation(description = "전시제품 정보를 등록/수정한다. (동기화)")
@PostMapping("/display-item-save") @PostMapping("/display-item-save")
@ResponseStatus(HttpStatus.OK) @ResponseStatus(HttpStatus.OK)
public void setStoreDisplayItemSave(@RequestBody DisplayItemRequest displayItemRequest) public void setStoreDisplayItemSave(@RequestBody DisplayItemRequest displayItemRequest)
throws Exception { throws QcastException {
displayItemService.setStoreDisplayItemSave(displayItemRequest); displayItemService.setStoreDisplayItemSave(displayItemRequest);
} }
@ -45,12 +46,13 @@ public class DisplayItemController {
* *
* @param itemRequest * @param itemRequest
* @return * @return
* @throws Exception * @throws QcastException
*/ */
@Operation(description = "제품 목록을 조회한다.") @Operation(description = "제품 목록을 조회한다.")
@PostMapping("/item-list") @PostMapping("/item-list")
@ResponseStatus(HttpStatus.OK) @ResponseStatus(HttpStatus.OK)
public List<ItemResponse> getItemList(@RequestBody ItemRequest itemRequest) throws Exception { public List<ItemResponse> getItemList(@RequestBody ItemRequest itemRequest)
throws QcastException {
return displayItemService.getItemList(itemRequest); return displayItemService.getItemList(itemRequest);
} }
@ -59,12 +61,12 @@ public class DisplayItemController {
* *
* @param itemId * @param itemId
* @return * @return
* @throws Exception * @throws QcastException
*/ */
@Operation(description = "제품 상세 정보를 조회한다.") @Operation(description = "제품 상세 정보를 조회한다.")
@GetMapping("/item-detail") @GetMapping("/item-detail")
@ResponseStatus(HttpStatus.OK) @ResponseStatus(HttpStatus.OK)
public ItemDetailResponse getItemDetail(@RequestParam String itemId) throws Exception { public ItemDetailResponse getItemDetail(@RequestParam String itemId) throws QcastException {
return displayItemService.getItemDetail(itemId); return displayItemService.getItemDetail(itemId);
} }
} }

View File

@ -4,15 +4,19 @@ import com.interplug.qcast.biz.displayItem.dto.*;
import com.interplug.qcast.biz.estimate.EstimateMapper; import com.interplug.qcast.biz.estimate.EstimateMapper;
import com.interplug.qcast.biz.estimate.dto.NoteRequest; import com.interplug.qcast.biz.estimate.dto.NoteRequest;
import com.interplug.qcast.biz.estimate.dto.NoteResponse; import com.interplug.qcast.biz.estimate.dto.NoteResponse;
import com.interplug.qcast.config.Exception.ErrorCode;
import com.interplug.qcast.config.Exception.QcastException;
import io.micrometer.common.util.StringUtils; import io.micrometer.common.util.StringUtils;
import java.util.List; import java.util.List;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Slf4j @Slf4j
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
@Transactional(readOnly = true)
public class DisplayItemService { public class DisplayItemService {
private final EstimateMapper estimateMapper; private final EstimateMapper estimateMapper;
@ -23,10 +27,15 @@ public class DisplayItemService {
* 판매점 노출 아이템 정보 저장 * 판매점 노출 아이템 정보 저장
* *
* @param displayItemRequest * @param displayItemRequest
* @throws Exception * @throws QcastException
*/ */
public void setStoreDisplayItemSave(DisplayItemRequest displayItemRequest) throws Exception { @Transactional
displayItemMapper.setStoreDisplayItemSave(displayItemRequest); public void setStoreDisplayItemSave(DisplayItemRequest displayItemRequest) throws QcastException {
try {
displayItemMapper.setStoreDisplayItemSave(displayItemRequest);
} catch (Exception e) {
throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, e.getMessage());
}
} }
/** /**
@ -34,9 +43,14 @@ public class DisplayItemService {
* *
* @param itemRequest * @param itemRequest
* @return * @return
* @throws QcastException
*/ */
public List<ItemResponse> getItemList(ItemRequest itemRequest) { public List<ItemResponse> getItemList(ItemRequest itemRequest) throws QcastException {
return displayItemMapper.getItemList(itemRequest); try {
return displayItemMapper.getItemList(itemRequest);
} catch (Exception e) {
throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, e.getMessage());
}
} }
/** /**
@ -45,36 +59,39 @@ public class DisplayItemService {
* @param itemId * @param itemId
* @return * @return
*/ */
public ItemDetailResponse getItemDetail(String itemId) { public ItemDetailResponse getItemDetail(String itemId) throws QcastException {
try {
ItemDetailResponse itemDetailResponse = displayItemMapper.getItemDetail(itemId);
ItemDetailResponse itemDetailResponse = displayItemMapper.getItemDetail(itemId); if (itemDetailResponse != null) {
// BOM 헤더 아이템인 경우 BOM List를 내려준다.
if ("ERLA".equals(itemDetailResponse.getItemCtgGr())) {
List<ItemResponse> itemBomList = displayItemMapper.selectItemBomList(itemId);
if (itemDetailResponse != null) { itemDetailResponse.setItemBomList(itemBomList);
// BOM 헤더 아이템인 경우 BOM List를 내려준다. }
if ("ERLA".equals(itemDetailResponse.getItemCtgGr())) {
List<ItemResponse> itemBomList = displayItemMapper.selectItemBomList(itemId);
itemDetailResponse.setItemBomList(itemBomList); // 견적특이사항 관련 데이터 셋팅
String[] arrItemId = {itemId};
NoteRequest noteRequest = new NoteRequest();
noteRequest.setArrItemId(arrItemId);
noteRequest.setSchSpnTypeCd("PROD");
List<NoteResponse> noteItemList = estimateMapper.selectEstimateNoteItemList(noteRequest);
String spnAttrCds = "";
for (NoteResponse noteResponse : noteItemList) {
spnAttrCds += !StringUtils.isEmpty(spnAttrCds) ? "" : "";
spnAttrCds += noteResponse.getCode();
}
itemDetailResponse.setSpnAttrCds(spnAttrCds);
} }
// 견적특이사항 관련 데이터 셋팅 return itemDetailResponse;
String[] arrItemId = {itemId}; } catch (Exception e) {
throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, e.getMessage());
NoteRequest noteRequest = new NoteRequest();
noteRequest.setArrItemId(arrItemId);
noteRequest.setSchSpnTypeCd("PROD");
List<NoteResponse> noteItemList = estimateMapper.selectEstimateNoteItemList(noteRequest);
String spnAttrCds = "";
for (NoteResponse noteResponse : noteItemList) {
spnAttrCds += !StringUtils.isEmpty(spnAttrCds) ? "" : "";
spnAttrCds += noteResponse.getCode();
}
itemDetailResponse.setSpnAttrCds(spnAttrCds);
} }
return itemDetailResponse;
} }
/** /**