From 30b06b7f8b233475b00af1c65b63c05b18809c04 Mon Sep 17 00:00:00 2001 From: Daseul Kim Date: Wed, 12 Feb 2025 14:18:01 +0900 Subject: [PATCH 1/4] =?UTF-8?q?style:=20biz=20=ED=95=98=EC=9C=84=20?= =?UTF-8?q?=ED=8C=A8=ED=82=A4=EC=A7=80=20controller,=20service=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EB=82=B4=20=EC=BD=94=EB=93=9C=20=ED=8F=AC=EB=A7=B7?= =?UTF-8?q?=ED=84=B0=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CanvasBasicSettingController.java | 41 ++-- .../CanvasBasicSettingService.java | 226 +++++++++--------- .../CanvasGridSettingController.java | 21 +- .../CanvasGridSettingService.java | 42 ++-- .../CanvasSettingController.java | 32 +-- .../canvasSetting/CanvasSettingService.java | 91 ++++--- .../qcast/biz/commCode/CommCodeService.java | 30 +-- .../qcast/biz/community/BoardController.java | 22 +- .../qcast/biz/community/BoardService.java | 79 +++--- .../biz/displayItem/DisplayItemService.java | 3 +- .../biz/excelDown/ExcelDownController.java | 1 - .../qcast/biz/file/FileController.java | 2 +- .../qcast/biz/login/LoginController.java | 74 +++--- .../qcast/biz/login/LoginService.java | 75 +++--- .../qcast/biz/myInfo/MyInfoController.java | 3 +- .../qcast/biz/myInfo/MyInfoService.java | 1 - .../specialNote/SpecialNoteController.java | 5 +- .../biz/specialNote/SpecialNoteService.java | 9 +- .../StoreFavoriteController.java | 7 +- 19 files changed, 389 insertions(+), 375 deletions(-) diff --git a/src/main/java/com/interplug/qcast/biz/canvasBasicSetting/CanvasBasicSettingController.java b/src/main/java/com/interplug/qcast/biz/canvasBasicSetting/CanvasBasicSettingController.java index 691f0bb8..1e4ff0a6 100644 --- a/src/main/java/com/interplug/qcast/biz/canvasBasicSetting/CanvasBasicSettingController.java +++ b/src/main/java/com/interplug/qcast/biz/canvasBasicSetting/CanvasBasicSettingController.java @@ -20,41 +20,42 @@ import org.springframework.web.bind.annotation.*; @Tag(name = "CanvasBasicSettingController", description = "Canvas Basic Setting 관련 API") public class CanvasBasicSettingController { private final CanvasBasicSettingService canvasBasicSettingService; - + @Operation(description = "Canvas Basic Setting 정보를 조회 한다.") @GetMapping("/canvas-basic-settings/by-object/{objectNo}") public List selectCanvasBasicSetting(@PathVariable String objectNo) { - - log.debug("Basic Setting 조회 ::::: " + objectNo); - - return canvasBasicSettingService.selectCanvasBasicSetting(objectNo); + + log.debug("Basic Setting 조회 ::::: " + objectNo); + + return canvasBasicSettingService.selectCanvasBasicSetting(objectNo); } - + @Operation(description = "Canvas Basic Setting 정보를 등록 한다.") @PostMapping("/canvas-basic-settings") @ResponseStatus(HttpStatus.CREATED) - public Map insertCanvasBasicSetting(@RequestBody CanvasBasicSettingInfo csi) throws QcastException { - - log.debug("Basic Setting 등록 ::::: " + csi.getObjectNo()); - - return canvasBasicSettingService.insertCanvasBasicSetting(csi); + public Map insertCanvasBasicSetting(@RequestBody CanvasBasicSettingInfo csi) + throws QcastException { + + log.debug("Basic Setting 등록 ::::: " + csi.getObjectNo()); + + return canvasBasicSettingService.insertCanvasBasicSetting(csi); } - + @Operation(description = "지붕면 할당 정보를 등록 한다.") @PostMapping("/roof-allocation-settings") @ResponseStatus(HttpStatus.CREATED) - public Map insertRoofAllocSetting(@RequestBody RoofAllocationSettingInfo rasi) throws QcastException { - - log.debug("지붕면 할당 등록 ::::: " + rasi.getObjectNo()); - - return canvasBasicSettingService.insertRoofAllocSetting(rasi); + public Map insertRoofAllocSetting(@RequestBody RoofAllocationSettingInfo rasi) + throws QcastException { + + log.debug("지붕면 할당 등록 ::::: " + rasi.getObjectNo()); + + return canvasBasicSettingService.insertRoofAllocSetting(rasi); } - + @Operation(description = "Canvas 지붕재추가 Setting 정보를 삭제 한다.") @DeleteMapping("/canvas-basic-settings/delete-RoofMaterials/{objectNo}") @ResponseStatus(HttpStatus.NO_CONTENT) public void deleteRoofMaterialsAdd(@PathVariable String objectNo) throws QcastException { - canvasBasicSettingService.deleteRoofMaterialsAdd(objectNo); + canvasBasicSettingService.deleteRoofMaterialsAdd(objectNo); } - } diff --git a/src/main/java/com/interplug/qcast/biz/canvasBasicSetting/CanvasBasicSettingService.java b/src/main/java/com/interplug/qcast/biz/canvasBasicSetting/CanvasBasicSettingService.java index 4ac2722f..6b6dc436 100644 --- a/src/main/java/com/interplug/qcast/biz/canvasBasicSetting/CanvasBasicSettingService.java +++ b/src/main/java/com/interplug/qcast/biz/canvasBasicSetting/CanvasBasicSettingService.java @@ -1,14 +1,5 @@ package com.interplug.qcast.biz.canvasBasicSetting; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.springframework.stereotype.Service; - import com.interplug.qcast.biz.canvasBasicSetting.dto.CanvasBasicSettingInfo; import com.interplug.qcast.biz.canvasBasicSetting.dto.CanvasBasicSettingResponse; import com.interplug.qcast.biz.canvasBasicSetting.dto.RoofAllocationInfo; @@ -16,124 +7,129 @@ import com.interplug.qcast.biz.canvasBasicSetting.dto.RoofAllocationSettingInfo; import com.interplug.qcast.biz.canvasBasicSetting.dto.RoofMaterialsAddInfo; import com.interplug.qcast.config.Exception.ErrorCode; import com.interplug.qcast.config.Exception.QcastException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; @Slf4j @Service @RequiredArgsConstructor public class CanvasBasicSettingService { - private final CanvasBasicSettingMapper canvasBasicSettingMapper; + private final CanvasBasicSettingMapper canvasBasicSettingMapper; - // Canvas Basic Setting 조회(objectNo) - public List selectCanvasBasicSetting(String objectNo) { - return canvasBasicSettingMapper.selectCanvasBasicSetting(objectNo); - } + // Canvas Basic Setting 조회(objectNo) + public List selectCanvasBasicSetting(String objectNo) { + return canvasBasicSettingMapper.selectCanvasBasicSetting(objectNo); + } - // Canvas Basic Setting 등록 - public Map insertCanvasBasicSetting(CanvasBasicSettingInfo csi) throws QcastException { - - Map response = new HashMap<>(); - - if (csi.getObjectNo() == null) { - throw new QcastException (ErrorCode.INVALID_INPUT_VALUE ,"올바르지 않은 입력값입니다."); - } + // Canvas Basic Setting 등록 + public Map insertCanvasBasicSetting(CanvasBasicSettingInfo csi) + throws QcastException { - try { - - // 먼저 데이터가 존재하는지 확인 - CanvasBasicSettingInfo cntData = canvasBasicSettingMapper.getCanvasBasicSettingCnt(csi.getObjectNo()); - - log.debug("cntData ::::: " + cntData); - - // 데이터가 존재하지 않으면 insert - if (cntData.getRoofCnt().intValue() < 1) { - // 도면/치수/각도 정보 insert - canvasBasicSettingMapper.insertCanvasBasicSetting(csi); - - // for-each 루프를 사용하여 지붕재추가 Setting - for (RoofMaterialsAddInfo rma : csi.getRoofMaterialsAddList()) { - - rma.setObjectNo(csi.getObjectNo()); - // 신규 지붕재추가 정보 insert - canvasBasicSettingMapper.insertRoofMaterialsAdd(rma); - } - - response.put("objectNo", csi.getObjectNo()); - response.put("returnMessage", "common.message.confirm.mark"); - - } else { - // 도면/치수/각도 정보 update - canvasBasicSettingMapper.updateCanvasBasicSetting(csi); - - // for-each 루프를 사용하여 지붕재추가 Setting - for (RoofMaterialsAddInfo rma : csi.getRoofMaterialsAddList()) { - - rma.setObjectNo(csi.getObjectNo()); - // 신규 지붕재추가 정보 insert - canvasBasicSettingMapper.updateRoofMaterialsAdd(rma); - } - - response.put("objectNo", csi.getObjectNo()); - response.put("returnMessage", "common.message.confirm.mark"); - } - - } catch (Exception e) { - response.put("objectNo", csi.getObjectNo()); - response.put("returnMessage", "common.message.save.error"); - } + Map response = new HashMap<>(); - // 생성된 objectNo 반환 - return response; + if (csi.getObjectNo() == null) { + throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, "올바르지 않은 입력값입니다."); + } - } - - // 지붕면 할당 Setting 등록 - public Map insertRoofAllocSetting(RoofAllocationSettingInfo rasi) throws QcastException { - - Map response = new HashMap<>(); - - if (rasi.getObjectNo() == null) { - throw new QcastException (ErrorCode.INVALID_INPUT_VALUE ,"올바르지 않은 입력값입니다."); - } + try { - try { - - // 기존 지붕재추가 정보 삭제 후 insert - canvasBasicSettingMapper.deleteRoofMaterialsAdd(rasi.getObjectNo()); - - // for-each 루프를 사용하여 지붕재추가 Setting - for (RoofAllocationInfo rai : rasi.getRoofAllocationList()) { - rai.setObjectNo(rasi.getObjectNo()); - canvasBasicSettingMapper.insertRoofAllocation(rai); - } - response.put("objectNo", rasi.getObjectNo()); - response.put("returnMessage", "common.message.confirm.mark"); - } catch (Exception e) { - response.put("objectNo", rasi.getObjectNo()); - response.put("returnMessage", "common.message.save.error"); - } + // 먼저 데이터가 존재하는지 확인 + CanvasBasicSettingInfo cntData = + canvasBasicSettingMapper.getCanvasBasicSettingCnt(csi.getObjectNo()); - // 생성된 objectNo 반환 - return response; + log.debug("cntData ::::: " + cntData); - } - - // 지붕재추가 삭제 - public void deleteRoofMaterialsAdd(String objectNo) throws QcastException { - - if (objectNo == null || objectNo.trim().isEmpty()) { - throw new QcastException (ErrorCode.INVALID_INPUT_VALUE ,"올바르지 않은 입력값입니다."); - } - - // 먼저 데이터가 존재하는지 확인 - RoofMaterialsAddInfo cntData = canvasBasicSettingMapper.getRoofMaterialsCnt(objectNo); - - // 데이터가 존재하지 않으면 수정하지 않고 예외를 던짐 - if (cntData.getRoofCnt().intValue() > 0) { - canvasBasicSettingMapper.deleteRoofMaterialsAdd(objectNo); - } else { - throw new QcastException (ErrorCode.NOT_FOUND ,"삭제할 지붕재가 존재하지 않습니다."); - } - - } + // 데이터가 존재하지 않으면 insert + if (cntData.getRoofCnt().intValue() < 1) { + // 도면/치수/각도 정보 insert + canvasBasicSettingMapper.insertCanvasBasicSetting(csi); + // for-each 루프를 사용하여 지붕재추가 Setting + for (RoofMaterialsAddInfo rma : csi.getRoofMaterialsAddList()) { + + rma.setObjectNo(csi.getObjectNo()); + // 신규 지붕재추가 정보 insert + canvasBasicSettingMapper.insertRoofMaterialsAdd(rma); + } + + response.put("objectNo", csi.getObjectNo()); + response.put("returnMessage", "common.message.confirm.mark"); + + } else { + // 도면/치수/각도 정보 update + canvasBasicSettingMapper.updateCanvasBasicSetting(csi); + + // for-each 루프를 사용하여 지붕재추가 Setting + for (RoofMaterialsAddInfo rma : csi.getRoofMaterialsAddList()) { + + rma.setObjectNo(csi.getObjectNo()); + // 신규 지붕재추가 정보 insert + canvasBasicSettingMapper.updateRoofMaterialsAdd(rma); + } + + response.put("objectNo", csi.getObjectNo()); + response.put("returnMessage", "common.message.confirm.mark"); + } + + } catch (Exception e) { + response.put("objectNo", csi.getObjectNo()); + response.put("returnMessage", "common.message.save.error"); + } + + // 생성된 objectNo 반환 + return response; + } + + // 지붕면 할당 Setting 등록 + public Map insertRoofAllocSetting(RoofAllocationSettingInfo rasi) + throws QcastException { + + Map response = new HashMap<>(); + + if (rasi.getObjectNo() == null) { + throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, "올바르지 않은 입력값입니다."); + } + + try { + + // 기존 지붕재추가 정보 삭제 후 insert + canvasBasicSettingMapper.deleteRoofMaterialsAdd(rasi.getObjectNo()); + + // for-each 루프를 사용하여 지붕재추가 Setting + for (RoofAllocationInfo rai : rasi.getRoofAllocationList()) { + rai.setObjectNo(rasi.getObjectNo()); + canvasBasicSettingMapper.insertRoofAllocation(rai); + } + response.put("objectNo", rasi.getObjectNo()); + response.put("returnMessage", "common.message.confirm.mark"); + } catch (Exception e) { + response.put("objectNo", rasi.getObjectNo()); + response.put("returnMessage", "common.message.save.error"); + } + + // 생성된 objectNo 반환 + return response; + } + + // 지붕재추가 삭제 + public void deleteRoofMaterialsAdd(String objectNo) throws QcastException { + + if (objectNo == null || objectNo.trim().isEmpty()) { + throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, "올바르지 않은 입력값입니다."); + } + + // 먼저 데이터가 존재하는지 확인 + RoofMaterialsAddInfo cntData = canvasBasicSettingMapper.getRoofMaterialsCnt(objectNo); + + // 데이터가 존재하지 않으면 수정하지 않고 예외를 던짐 + if (cntData.getRoofCnt().intValue() > 0) { + canvasBasicSettingMapper.deleteRoofMaterialsAdd(objectNo); + } else { + throw new QcastException(ErrorCode.NOT_FOUND, "삭제할 지붕재가 존재하지 않습니다."); + } + } } diff --git a/src/main/java/com/interplug/qcast/biz/canvasGridSetting/CanvasGridSettingController.java b/src/main/java/com/interplug/qcast/biz/canvasGridSetting/CanvasGridSettingController.java index 6d9ce950..a09f0f43 100644 --- a/src/main/java/com/interplug/qcast/biz/canvasGridSetting/CanvasGridSettingController.java +++ b/src/main/java/com/interplug/qcast/biz/canvasGridSetting/CanvasGridSettingController.java @@ -19,24 +19,23 @@ import org.springframework.web.bind.annotation.*; @Tag(name = "CanvasGridSettingController", description = "Canvas Grid Setting 관련 API") public class CanvasGridSettingController { private final CanvasGridSettingService canvasGridSettingService; - + @Operation(description = "Canvas Grid Setting 정보를 조회 한다.") @GetMapping("/canvas-grid-settings/by-object/{objectNo}") public CanvasGridSettingInfo selectCanvasGridSetting(@PathVariable String objectNo) { - - log.debug("Grid Setting 조회 ::::: " + objectNo); - - return canvasGridSettingService.selectCanvasGridSetting(objectNo); + + log.debug("Grid Setting 조회 ::::: " + objectNo); + + return canvasGridSettingService.selectCanvasGridSetting(objectNo); } - + @Operation(description = "Canvas Grid Setting 정보를 등록 한다.") @PostMapping("/canvas-grid-settings") @ResponseStatus(HttpStatus.CREATED) public Map insertCanvasGridStatus(@RequestBody CanvasGridSettingInfo csi) { - - log.debug("Grid Setting 등록 ::::: " + csi.getObjectNo()); - - return canvasGridSettingService.insertCanvasGridSetting(csi); + + log.debug("Grid Setting 등록 ::::: " + csi.getObjectNo()); + + return canvasGridSettingService.insertCanvasGridSetting(csi); } - } diff --git a/src/main/java/com/interplug/qcast/biz/canvasGridSetting/CanvasGridSettingService.java b/src/main/java/com/interplug/qcast/biz/canvasGridSetting/CanvasGridSettingService.java index 89fee56d..dcfc9986 100644 --- a/src/main/java/com/interplug/qcast/biz/canvasGridSetting/CanvasGridSettingService.java +++ b/src/main/java/com/interplug/qcast/biz/canvasGridSetting/CanvasGridSettingService.java @@ -12,32 +12,30 @@ import org.springframework.stereotype.Service; @Service @RequiredArgsConstructor public class CanvasGridSettingService { - private final CanvasGridSettingMapper canvasGridSettingMapper; + private final CanvasGridSettingMapper canvasGridSettingMapper; - // Canvas Setting 조회(objectNo) - public CanvasGridSettingInfo selectCanvasGridSetting(String objectNo) { - return canvasGridSettingMapper.selectCanvasGridSetting(objectNo); - } + // Canvas Setting 조회(objectNo) + public CanvasGridSettingInfo selectCanvasGridSetting(String objectNo) { + return canvasGridSettingMapper.selectCanvasGridSetting(objectNo); + } - // Canvas Setting 등록 - public Map insertCanvasGridSetting(CanvasGridSettingInfo csi) { - - Map response = new HashMap<>(); + // Canvas Setting 등록 + public Map insertCanvasGridSetting(CanvasGridSettingInfo csi) { - try { - canvasGridSettingMapper.insertCanvasGridSetting(csi); - - response.put("objectNo", csi.getObjectNo()); - response.put("returnMessage", "common.message.confirm.mark"); - - } catch (Exception e) { - response.put("objectNo", csi.getObjectNo()); - response.put("returnMessage", "common.message.save.error"); - } + Map response = new HashMap<>(); - // 생성된 objectNo 반환 - return response; + try { + canvasGridSettingMapper.insertCanvasGridSetting(csi); - } + response.put("objectNo", csi.getObjectNo()); + response.put("returnMessage", "common.message.confirm.mark"); + } catch (Exception e) { + response.put("objectNo", csi.getObjectNo()); + response.put("returnMessage", "common.message.save.error"); + } + + // 생성된 objectNo 반환 + return response; + } } diff --git a/src/main/java/com/interplug/qcast/biz/canvasSetting/CanvasSettingController.java b/src/main/java/com/interplug/qcast/biz/canvasSetting/CanvasSettingController.java index 741bd9c8..f1a91853 100644 --- a/src/main/java/com/interplug/qcast/biz/canvasSetting/CanvasSettingController.java +++ b/src/main/java/com/interplug/qcast/biz/canvasSetting/CanvasSettingController.java @@ -20,33 +20,33 @@ import org.springframework.web.bind.annotation.*; @Tag(name = "CanvasSettingController", description = "Canvas Setting 관련 API") public class CanvasSettingController { private final CanvasSettingService canvasSettingService; - + @Operation(description = "Canvas Setting 정보를 조회 한다.") @GetMapping("/canvas-settings/by-object/{objectNo}") public CanvasSettingInfo selectCanvasSetting(@PathVariable String objectNo) { - - log.debug("Setting 조회 ::::: " + objectNo); - - return canvasSettingService.selectCanvasSetting(objectNo); + + log.debug("Setting 조회 ::::: " + objectNo); + + return canvasSettingService.selectCanvasSetting(objectNo); } - + @Operation(description = "Canvas Setting 정보를 등록 한다.") @PostMapping("/canvas-settings") @ResponseStatus(HttpStatus.CREATED) - public Map insertCanvasSetting(@RequestBody CanvasSettingInfo csi) throws QcastException { - - log.debug("Setting 등록 ::::: " + csi.getObjectNo()); - - return canvasSettingService.insertCanvasSetting(csi); + public Map insertCanvasSetting(@RequestBody CanvasSettingInfo csi) + throws QcastException { + + log.debug("Setting 등록 ::::: " + csi.getObjectNo()); + + return canvasSettingService.insertCanvasSetting(csi); } @Operation(description = "Canvas Setting 정보를 수정 한다.") @PutMapping("/canvas-settings") public void updateCanvasStatus(@RequestBody CanvasSettingInfo csi) { - - log.debug("Setting 수정 ::::: " + csi.getObjectNo()); - - canvasSettingService.updateCanvasSetting(csi); + + log.debug("Setting 수정 ::::: " + csi.getObjectNo()); + + canvasSettingService.updateCanvasSetting(csi); } - } diff --git a/src/main/java/com/interplug/qcast/biz/canvasSetting/CanvasSettingService.java b/src/main/java/com/interplug/qcast/biz/canvasSetting/CanvasSettingService.java index 40f4505b..239c5655 100644 --- a/src/main/java/com/interplug/qcast/biz/canvasSetting/CanvasSettingService.java +++ b/src/main/java/com/interplug/qcast/biz/canvasSetting/CanvasSettingService.java @@ -3,65 +3,60 @@ package com.interplug.qcast.biz.canvasSetting; import com.interplug.qcast.biz.canvasSetting.dto.CanvasSettingInfo; import com.interplug.qcast.config.Exception.ErrorCode; import com.interplug.qcast.config.Exception.QcastException; - -import lombok.RequiredArgsConstructor; - import java.util.HashMap; import java.util.Map; - +import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @Service @RequiredArgsConstructor public class CanvasSettingService { - private final CanvasSettingMapper canvasSettingMapper; + private final CanvasSettingMapper canvasSettingMapper; - // Canvas Setting 조회(objectNo) - public CanvasSettingInfo selectCanvasSetting(String objectNo) { - return canvasSettingMapper.selectCanvasSetting(objectNo); - } + // Canvas Setting 조회(objectNo) + public CanvasSettingInfo selectCanvasSetting(String objectNo) { + return canvasSettingMapper.selectCanvasSetting(objectNo); + } - // Canvas Setting 등록 - public Map insertCanvasSetting(CanvasSettingInfo csi) throws QcastException { - - Map response = new HashMap<>(); - - if (csi.getObjectNo() == null) { - throw new QcastException (ErrorCode.INVALID_INPUT_VALUE ,"올바르지 않은 입력값입니다."); - } - - try { - - // 먼저 데이터가 존재하는지 확인 - CanvasSettingInfo cntData = canvasSettingMapper.getCanvasSettingCnt(csi.getObjectNo()); - - // 데이터가 존재하지 않으면 insert - if (cntData.getCnt().intValue() < 1) { - canvasSettingMapper.insertCanvasSetting(csi); - - response.put("objectNo", csi.getObjectNo()); - response.put("returnMessage", "common.message.confirm.mark"); - - } else { - 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("returnMessage", "common.message.save.error"); - } + // Canvas Setting 등록 + public Map insertCanvasSetting(CanvasSettingInfo csi) throws QcastException { - // 생성된 objectNo 반환 - return response; + Map response = new HashMap<>(); - } + if (csi.getObjectNo() == null) { + throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, "올바르지 않은 입력값입니다."); + } - // Canvas Setting 수정 - public void updateCanvasSetting(CanvasSettingInfo csi) { - canvasSettingMapper.updateCanvasSetting(csi); - } + try { + // 먼저 데이터가 존재하는지 확인 + CanvasSettingInfo cntData = canvasSettingMapper.getCanvasSettingCnt(csi.getObjectNo()); + + // 데이터가 존재하지 않으면 insert + if (cntData.getCnt().intValue() < 1) { + canvasSettingMapper.insertCanvasSetting(csi); + + response.put("objectNo", csi.getObjectNo()); + response.put("returnMessage", "common.message.confirm.mark"); + + } else { + 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("returnMessage", "common.message.save.error"); + } + + // 생성된 objectNo 반환 + return response; + } + + // Canvas Setting 수정 + public void updateCanvasSetting(CanvasSettingInfo csi) { + canvasSettingMapper.updateCanvasSetting(csi); + } } diff --git a/src/main/java/com/interplug/qcast/biz/commCode/CommCodeService.java b/src/main/java/com/interplug/qcast/biz/commCode/CommCodeService.java index 1147c4a2..6aa411e2 100644 --- a/src/main/java/com/interplug/qcast/biz/commCode/CommCodeService.java +++ b/src/main/java/com/interplug/qcast/biz/commCode/CommCodeService.java @@ -1,15 +1,15 @@ package com.interplug.qcast.biz.commCode; -import java.util.ArrayList; -import java.util.List; -import org.springframework.stereotype.Service; import com.interplug.qcast.biz.commCode.dto.CodeReq; import com.interplug.qcast.biz.commCode.dto.CodeRes; import com.interplug.qcast.biz.commCode.dto.CommCodeRes; import com.interplug.qcast.biz.commCode.dto.DetailCodeRequest; import com.interplug.qcast.biz.commCode.dto.HeadCodeRequest; +import java.util.ArrayList; +import java.util.List; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; @Slf4j @Service @@ -53,18 +53,23 @@ public class CommCodeService { public List selectQcastCommCode() { List result = commCodeMapper.selectQcastCommCode(); List commCodeList = new ArrayList<>(); - result.forEach(cr -> { - commCodeList.add(CommCodeRes.builder().clHeadCd(cr.getClHeadCd()).clCode(cr.getClCode()) - .clCodeNm(cr.getClCodeNm()).clCodeJp(cr.getClCodeJp()).clPriority(cr.getClPriority()) - .build()); - }); + result.forEach( + cr -> { + commCodeList.add( + CommCodeRes.builder() + .clHeadCd(cr.getClHeadCd()) + .clCode(cr.getClCode()) + .clCodeNm(cr.getClCodeNm()) + .clCodeJp(cr.getClCodeJp()) + .clPriority(cr.getClPriority()) + .build()); + }); return commCodeList; } - /** * 헤더코드 동기화 - * + * * @param headCodeList * @throws Exception */ @@ -81,13 +86,12 @@ public class CommCodeService { } catch (Exception e) { log.error(e.getMessage()); } - } } /** * 상세코드 동기화 - * + * * @param detailCodeList * @throws Exception */ @@ -104,8 +108,6 @@ public class CommCodeService { } catch (Exception e) { log.error(e.getMessage()); } - - } } } diff --git a/src/main/java/com/interplug/qcast/biz/community/BoardController.java b/src/main/java/com/interplug/qcast/biz/community/BoardController.java index f9ce8aaf..4585866c 100644 --- a/src/main/java/com/interplug/qcast/biz/community/BoardController.java +++ b/src/main/java/com/interplug/qcast/biz/community/BoardController.java @@ -1,12 +1,5 @@ package com.interplug.qcast.biz.community; -import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestController; import com.interplug.qcast.biz.community.dto.BoardRequest; import com.interplug.qcast.biz.community.dto.BoardResponse; import io.swagger.v3.oas.annotations.Operation; @@ -14,6 +7,13 @@ import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; @Slf4j @RestController @@ -41,9 +41,11 @@ public class BoardController { @Operation(description = "커뮤니티(공지사항, FAQ, 자료다운로드) 파일 다운로드를 진행한다.") @GetMapping("/file/download") @ResponseStatus(HttpStatus.OK) - public void getFileDownload(HttpServletResponse response, - @RequestParam(required = true) String keyNo, @RequestParam String zipYn) throws Exception { + public void getFileDownload( + HttpServletResponse response, + @RequestParam(required = true) String keyNo, + @RequestParam String zipYn) + throws Exception { boardService.getFileDownload(response, keyNo, zipYn); } - } diff --git a/src/main/java/com/interplug/qcast/biz/community/BoardService.java b/src/main/java/com/interplug/qcast/biz/community/BoardService.java index d412b7a0..4e4c9767 100644 --- a/src/main/java/com/interplug/qcast/biz/community/BoardService.java +++ b/src/main/java/com/interplug/qcast/biz/community/BoardService.java @@ -1,17 +1,5 @@ package com.interplug.qcast.biz.community; -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.util.HashMap; -import java.util.Map; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.http.HttpMethod; -import org.springframework.stereotype.Service; -import org.springframework.util.StreamUtils; -import org.springframework.web.util.UriComponentsBuilder; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.interplug.qcast.biz.community.dto.BoardRequest; @@ -21,8 +9,20 @@ import com.interplug.qcast.config.Exception.QcastException; import com.interplug.qcast.config.message.Messages; import com.interplug.qcast.util.InterfaceQsp; import jakarta.servlet.http.HttpServletResponse; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.HashMap; +import java.util.Map; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpMethod; +import org.springframework.stereotype.Service; +import org.springframework.util.StreamUtils; +import org.springframework.web.util.UriComponentsBuilder; @Slf4j @Service @@ -30,8 +30,7 @@ import lombok.extern.slf4j.Slf4j; public class BoardService { private final InterfaceQsp interfaceQsp; - @Autowired - Messages message; + @Autowired Messages message; @Value("${qsp.url}") private String QSP_API_URL; @@ -50,12 +49,14 @@ public class BoardService { /* [0]. Validation Check */ if ("".equals(boardRequest.getSchNoticeClsCd())) { // [msg] {0} is required input value. - throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, + throw new QcastException( + ErrorCode.INVALID_INPUT_VALUE, message.getMessage("common.message.required.data", "Notice Cls Code")); } if ("".equals(boardRequest.getSchNoticeTpCd())) { // [msg] {0} is required input value. - throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, + throw new QcastException( + ErrorCode.INVALID_INPUT_VALUE, message.getMessage("common.message.required.data", "Notice Type Code")); } @@ -66,14 +67,17 @@ public class BoardService { } String url = QSP_API_URL + "/api/board/list"; - String apiUrl = UriComponentsBuilder.fromHttpUrl(url) - .queryParam("noticeNo", boardRequest.getNoticeNo()).queryParam("schTitle", encodedSchTitle) - .queryParam("schNoticeTpCd", boardRequest.getSchNoticeTpCd()) - .queryParam("schNoticeClsCd", boardRequest.getSchNoticeClsCd()) - .queryParam("startRow", boardRequest.getStartRow()) - .queryParam("endRow", boardRequest.getEndRow()) - .queryParam("schMainYn", boardRequest.getSchMainYn()).build().toUriString(); - + String apiUrl = + UriComponentsBuilder.fromHttpUrl(url) + .queryParam("noticeNo", boardRequest.getNoticeNo()) + .queryParam("schTitle", encodedSchTitle) + .queryParam("schNoticeTpCd", boardRequest.getSchNoticeTpCd()) + .queryParam("schNoticeClsCd", boardRequest.getSchNoticeClsCd()) + .queryParam("startRow", boardRequest.getStartRow()) + .queryParam("endRow", boardRequest.getEndRow()) + .queryParam("schMainYn", boardRequest.getSchMainYn()) + .build() + .toUriString(); /* [2]. QSP API CALL -> Response */ String strResponse = interfaceQsp.callApi(HttpMethod.GET, apiUrl, null); @@ -105,14 +109,18 @@ public class BoardService { /* [0]. Validation Check */ if (boardRequest.getNoticeNo() == null) { // [msg] {0} is required input value. - throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, + throw new QcastException( + ErrorCode.INVALID_INPUT_VALUE, message.getMessage("common.message.required.data", "Notice No")); } /* [1]. QSP API (url + param) Setting */ String url = QSP_API_URL + "/api/board/detail"; - String apiUrl = UriComponentsBuilder.fromHttpUrl(url) - .queryParam("noticeNo", boardRequest.getNoticeNo()).build().toUriString(); + String apiUrl = + UriComponentsBuilder.fromHttpUrl(url) + .queryParam("noticeNo", boardRequest.getNoticeNo()) + .build() + .toUriString(); /* [2]. QSP API CALL -> Response */ String strResponse = interfaceQsp.callApi(HttpMethod.GET, apiUrl, null); @@ -144,8 +152,8 @@ public class BoardService { if ("".equals(keyNo)) { // [msg] {0} is required input value. String arg = "Y".equals(zipYn) ? "Notice No" : "File No"; - throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, - message.getMessage("common.message.required.data", arg)); + throw new QcastException( + ErrorCode.INVALID_INPUT_VALUE, message.getMessage("common.message.required.data", arg)); } /* [1]. QSP API (url + fileNo) Setting */ @@ -165,9 +173,11 @@ public class BoardService { /* [3]. API 응답 파일 처리 */ response.addHeader("Access-Control-Expose-Headers", "Content-Disposition"); response.setContentType( - !"".equals(result.get("type")) && result.get("type") != null ? result.get("type") + !"".equals(result.get("type")) && result.get("type") != null + ? result.get("type") : "application/octet-stream"); - response.setHeader("Content-Disposition", + response.setHeader( + "Content-Disposition", !"".equals(result.get("disposition")) && result.get("disposition") != null ? result.get("disposition") : "attachment;"); @@ -180,14 +190,15 @@ public class BoardService { } catch (Exception e) { // [msg] File download error - throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, + throw new QcastException( + ErrorCode.INTERNAL_SERVER_ERROR, message.getMessage("common.message.file.download.error")); } } else { // [msg] File does not exist. - throw new QcastException(ErrorCode.NOT_FOUND, - message.getMessage("common.message.file.download.exists")); + throw new QcastException( + ErrorCode.NOT_FOUND, message.getMessage("common.message.file.download.exists")); } } } diff --git a/src/main/java/com/interplug/qcast/biz/displayItem/DisplayItemService.java b/src/main/java/com/interplug/qcast/biz/displayItem/DisplayItemService.java index 956c14ed..d90211c8 100644 --- a/src/main/java/com/interplug/qcast/biz/displayItem/DisplayItemService.java +++ b/src/main/java/com/interplug/qcast/biz/displayItem/DisplayItemService.java @@ -130,7 +130,7 @@ public class DisplayItemService { /** * 노출 아이템 동기화 - Batch - * + * * @param displayItemList * @throws Exception */ @@ -144,5 +144,4 @@ public class DisplayItemService { } } } - } diff --git a/src/main/java/com/interplug/qcast/biz/excelDown/ExcelDownController.java b/src/main/java/com/interplug/qcast/biz/excelDown/ExcelDownController.java index 957ea896..9b668140 100644 --- a/src/main/java/com/interplug/qcast/biz/excelDown/ExcelDownController.java +++ b/src/main/java/com/interplug/qcast/biz/excelDown/ExcelDownController.java @@ -74,5 +74,4 @@ public class ExcelDownController { log.error(e.getMessage()); } } - } diff --git a/src/main/java/com/interplug/qcast/biz/file/FileController.java b/src/main/java/com/interplug/qcast/biz/file/FileController.java index f8948c4e..3313d6de 100644 --- a/src/main/java/com/interplug/qcast/biz/file/FileController.java +++ b/src/main/java/com/interplug/qcast/biz/file/FileController.java @@ -51,7 +51,7 @@ public class FileController { public List fileUpload( HttpServletRequest request, HttpServletResponse response, FileRequest fileRequest) throws Exception { - return fileService.fileUpload(request,fileRequest); + return fileService.fileUpload(request, fileRequest); } @Operation(description = "파일을 삭제 한다.") diff --git a/src/main/java/com/interplug/qcast/biz/login/LoginController.java b/src/main/java/com/interplug/qcast/biz/login/LoginController.java index ad662f06..cbb5af84 100644 --- a/src/main/java/com/interplug/qcast/biz/login/LoginController.java +++ b/src/main/java/com/interplug/qcast/biz/login/LoginController.java @@ -1,21 +1,5 @@ package com.interplug.qcast.biz.login; -import java.time.LocalDate; -import java.time.format.DateTimeFormatter; -import java.util.Base64; -import javax.crypto.Cipher; -import javax.crypto.SecretKey; -import javax.crypto.spec.IvParameterSpec; -import javax.crypto.spec.SecretKeySpec; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.PatchMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestController; import com.interplug.qcast.biz.login.dto.JoinUser; import com.interplug.qcast.biz.login.dto.LoginUser; import com.interplug.qcast.biz.login.dto.UserLoginResponse; @@ -26,8 +10,24 @@ import com.interplug.qcast.config.Exception.QcastException; import com.interplug.qcast.config.message.Messages; import com.interplug.qcast.util.DefaultResponse; import io.swagger.v3.oas.annotations.Operation; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.Base64; +import javax.crypto.Cipher; +import javax.crypto.SecretKey; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.PatchMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; @Slf4j @RestController @@ -37,8 +37,7 @@ public class LoginController { // @Autowired private LoginService loginService; private final LoginService loginService; - @Autowired - Messages message; + @Autowired Messages message; @Value("${qsp.aes256.key}") String loginPasswordAesKey; @@ -46,10 +45,9 @@ public class LoginController { @Value("${qsp.auto.login.aes256.key}") String autoLoginAesKey; - /** * Q.CAST III에 로그인하여 사용자 정보를 획득한다. - * + * * @param loginUser LoginUser * @return UserLoginResponse * @throws Exception @@ -69,7 +67,7 @@ public class LoginController { /** * 가입 신청 정보를 등록한다. - * + * * @param joinUser JoinUser * @return DefaultResponse * @throws Exception @@ -83,7 +81,7 @@ public class LoginController { /** * 비밀번호를 초기화한다. - * + * * @param userPassword UserPassword * @return DefaultResponse * @throws Exception @@ -96,7 +94,7 @@ public class LoginController { /** * 비밀번호를 변경한다. - * + * * @param userPassword UserPassword * @return DefaultResponse * @throws Exception @@ -109,7 +107,7 @@ public class LoginController { /** * 자동 로그인에 사용하는 아이디를 암호화한다. - * + * * @param loginUser LoginUser * @return String * @throws Exception @@ -121,7 +119,8 @@ public class LoginController { String loginEncryptId = ""; if ("".equals(loginUser.getLoginId()) || loginUser.getLoginId() == null) { - throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, + throw new QcastException( + ErrorCode.INVALID_INPUT_VALUE, message.getMessage("common.message.required.data", "User Id")); } @@ -136,16 +135,19 @@ public class LoginController { byte[] keyData = loginPasswordAesKey.getBytes(); SecretKey secureKey = new SecretKeySpec(keyData, "AES"); Cipher c = Cipher.getInstance("AES/CBC/PKCS5Padding"); - c.init(Cipher.ENCRYPT_MODE, secureKey, + c.init( + Cipher.ENCRYPT_MODE, + secureKey, new IvParameterSpec(encryptKey.substring(0, 16).getBytes())); byte[] encrypted = c.doFinal(loginUser.getLoginId().getBytes("UTF-8")); // [2]. 암호화 값 셋팅 - loginEncryptId = new String(Base64.getEncoder().encode(encrypted));; + loginEncryptId = new String(Base64.getEncoder().encode(encrypted)); + ; } catch (Exception e) { - throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, - message.getMessage("common.message.error")); + throw new QcastException( + ErrorCode.INTERNAL_SERVER_ERROR, message.getMessage("common.message.error")); } return loginEncryptId; @@ -153,7 +155,7 @@ public class LoginController { /** * 자동 로그인에 사용하는 아이디를 복호화한다. - * + * * @param loginUser LoginUser * @return String * @throws Exception @@ -165,7 +167,8 @@ public class LoginController { String loginDecryptId = ""; if ("".equals(loginUser.getLoginId()) || loginUser.getLoginId() == null) { - throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, + throw new QcastException( + ErrorCode.INVALID_INPUT_VALUE, message.getMessage("common.message.required.data", "User Id")); } @@ -180,7 +183,9 @@ public class LoginController { byte[] keyData = loginPasswordAesKey.getBytes(); SecretKey secureKey = new SecretKeySpec(keyData, "AES"); Cipher c = Cipher.getInstance("AES/CBC/PKCS5Padding"); - c.init(Cipher.DECRYPT_MODE, secureKey, + c.init( + Cipher.DECRYPT_MODE, + secureKey, new IvParameterSpec(decryptKey.substring(0, 16).getBytes("UTF-8"))); byte[] byteStr = Base64.getDecoder().decode(loginUser.getLoginId().getBytes()); @@ -189,11 +194,10 @@ public class LoginController { loginDecryptId = new String(c.doFinal(byteStr), "UTF-8"); } catch (Exception e) { - throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, - message.getMessage("common.message.error")); + throw new QcastException( + ErrorCode.INTERNAL_SERVER_ERROR, message.getMessage("common.message.error")); } return loginDecryptId; } - } diff --git a/src/main/java/com/interplug/qcast/biz/login/LoginService.java b/src/main/java/com/interplug/qcast/biz/login/LoginService.java index 4f4bed68..7cc1a085 100644 --- a/src/main/java/com/interplug/qcast/biz/login/LoginService.java +++ b/src/main/java/com/interplug/qcast/biz/login/LoginService.java @@ -1,9 +1,5 @@ package com.interplug.qcast.biz.login; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.http.HttpMethod; -import org.springframework.stereotype.Service; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.interplug.qcast.biz.login.dto.JoinUser; @@ -18,6 +14,10 @@ import com.interplug.qcast.util.DefaultResponse; import com.interplug.qcast.util.InterfaceQsp; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpMethod; +import org.springframework.stereotype.Service; @Slf4j @Service @@ -30,23 +30,24 @@ public class LoginService { @Value("${qsp.url}") private String qspUrl; - @Autowired - Messages message; + @Autowired Messages message; /** * 로그인 처리 - * + * * @param loginUser LoginUser * @return UserLoginResponse * @throws Exception */ public UserLoginResponse getLogin(LoginUser loginUser) throws Exception { if (loginUser.getLoginId() == null || "".equals(loginUser.getLoginId())) - throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, + throw new QcastException( + ErrorCode.INVALID_INPUT_VALUE, message.getMessage("common.message.required.data", "Login Id")); if (loginUser.getPwd() == null || "".equals(loginUser.getPwd())) - throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, + throw new QcastException( + ErrorCode.INVALID_INPUT_VALUE, message.getMessage("common.message.required.data", "Password")); UserLoginResponse userLoginResponse = null; @@ -72,42 +73,49 @@ public class LoginService { /** * 가입 신청 등록 - * + * * @param joinUser JoinUser * @return DefaultResponse * @throws Exception */ public DefaultResponse joinUser(JoinUser joinUser) throws Exception { if (joinUser.getStoreQcastNm() == null || "".equals(joinUser.getStoreQcastNm())) - throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, + throw new QcastException( + ErrorCode.INVALID_INPUT_VALUE, message.getMessage("common.message.required.data", "Store QCast Name")); if (joinUser.getStoreQcastNmKana() == null || "".equals(joinUser.getStoreQcastNmKana())) - throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, + throw new QcastException( + ErrorCode.INVALID_INPUT_VALUE, message.getMessage("common.message.required.data", "Store QCast Name Kana")); if (joinUser.getPostCd() == null || "".equals(joinUser.getPostCd())) - throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, + throw new QcastException( + ErrorCode.INVALID_INPUT_VALUE, message.getMessage("common.message.required.data", "Postal Code")); if (joinUser.getAddr() == null || "".equals(joinUser.getAddr())) - throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, + throw new QcastException( + ErrorCode.INVALID_INPUT_VALUE, message.getMessage("common.message.required.data", "Address")); if (joinUser.getTelNo() == null || "".equals(joinUser.getTelNo())) - throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, + throw new QcastException( + ErrorCode.INVALID_INPUT_VALUE, message.getMessage("common.message.required.data", "Telephone")); if (joinUser.getFax() == null || "".equals(joinUser.getFax())) - throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, - message.getMessage("common.message.required.data", "Fax")); + throw new QcastException( + ErrorCode.INVALID_INPUT_VALUE, message.getMessage("common.message.required.data", "Fax")); if (joinUser.getUserInfo().getUserId() == null || "".equals(joinUser.getUserInfo().getUserId())) - throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, + throw new QcastException( + ErrorCode.INVALID_INPUT_VALUE, message.getMessage("common.message.required.data", "User Id")); if (joinUser.getUserInfo().getUserNm() == null || "".equals(joinUser.getUserInfo().getUserNm())) - throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, + throw new QcastException( + ErrorCode.INVALID_INPUT_VALUE, message.getMessage("common.message.required.data", "Name")); // if (joinUser.getUserInfo().getUserNmKana() == null @@ -116,15 +124,17 @@ public class LoginService { // message.getMessage("common.message.required.data", "Name Kana")); if (joinUser.getUserInfo().getTelNo() == null || "".equals(joinUser.getUserInfo().getTelNo())) - throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, + throw new QcastException( + ErrorCode.INVALID_INPUT_VALUE, message.getMessage("common.message.required.data", "Telephone")); if (joinUser.getUserInfo().getFax() == null || "".equals(joinUser.getUserInfo().getFax())) - throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, - message.getMessage("common.message.required.data", "Fax")); + throw new QcastException( + ErrorCode.INVALID_INPUT_VALUE, message.getMessage("common.message.required.data", "Fax")); if (joinUser.getUserInfo().getEmail() == null || "".equals(joinUser.getUserInfo().getEmail())) - throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, + throw new QcastException( + ErrorCode.INVALID_INPUT_VALUE, message.getMessage("common.message.required.data", "E-Mail")); // QSP API Call.. @@ -145,18 +155,20 @@ public class LoginService { /** * 비밀번호 초기화 - * + * * @param userPassword UserPassword * @return DefaultResponse * @throws Exception */ public DefaultResponse initPassword(UserPassword userPassword) throws Exception { if (userPassword.getLoginId() == null || "".equals(userPassword.getLoginId())) - throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, + throw new QcastException( + ErrorCode.INVALID_INPUT_VALUE, message.getMessage("common.message.required.data", "Login Id")); if (userPassword.getEmail() == null || "".equals(userPassword.getEmail())) - throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, + throw new QcastException( + ErrorCode.INVALID_INPUT_VALUE, message.getMessage("common.message.required.data", "E-Mail")); // QSP API Call.. @@ -177,22 +189,25 @@ public class LoginService { /** * 비밀번호 변경 - * + * * @param userPassword UserPassword * @return DefaultResponse * @throws Exception */ public DefaultResponse changePassword(UserPassword userPassword) throws Exception { if (userPassword.getLoginId() == null || "".equals(userPassword.getLoginId())) - throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, + throw new QcastException( + ErrorCode.INVALID_INPUT_VALUE, message.getMessage("common.message.required.data", "Login Id")); if (userPassword.getChgType() == null || "".equals(userPassword.getChgType())) - throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, + throw new QcastException( + ErrorCode.INVALID_INPUT_VALUE, message.getMessage("common.message.required.data", "Change Type (I :Init , C: Change)")); if (userPassword.getChgPwd() == null || "".equals(userPassword.getChgPwd())) - throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, + throw new QcastException( + ErrorCode.INVALID_INPUT_VALUE, message.getMessage("common.message.required.data", "Change Password")); // QSP API Call.. diff --git a/src/main/java/com/interplug/qcast/biz/myInfo/MyInfoController.java b/src/main/java/com/interplug/qcast/biz/myInfo/MyInfoController.java index d8ddcb4d..f486f922 100644 --- a/src/main/java/com/interplug/qcast/biz/myInfo/MyInfoController.java +++ b/src/main/java/com/interplug/qcast/biz/myInfo/MyInfoController.java @@ -24,7 +24,7 @@ public class MyInfoController { /** * 사용자 ID의 정보 조회 - * + * * @param myInfoRequest * @return */ @@ -34,5 +34,4 @@ public class MyInfoController { public MyInfoResponse getMyInfo(@ModelAttribute MyInfoRequest myInfoRequest) { return myInfoService.getMyInfo(myInfoRequest); } - } diff --git a/src/main/java/com/interplug/qcast/biz/myInfo/MyInfoService.java b/src/main/java/com/interplug/qcast/biz/myInfo/MyInfoService.java index af5c14b4..b0a050b0 100644 --- a/src/main/java/com/interplug/qcast/biz/myInfo/MyInfoService.java +++ b/src/main/java/com/interplug/qcast/biz/myInfo/MyInfoService.java @@ -22,5 +22,4 @@ public class MyInfoService { public MyInfoResponse getMyInfo(MyInfoRequest myInfoRequest) { return myInfoMapper.selectMyInfo(myInfoRequest); } - } diff --git a/src/main/java/com/interplug/qcast/biz/specialNote/SpecialNoteController.java b/src/main/java/com/interplug/qcast/biz/specialNote/SpecialNoteController.java index 11ed6245..bf6f588f 100644 --- a/src/main/java/com/interplug/qcast/biz/specialNote/SpecialNoteController.java +++ b/src/main/java/com/interplug/qcast/biz/specialNote/SpecialNoteController.java @@ -24,7 +24,7 @@ public class SpecialNoteController { /** * 견적 특이사항 정보 등록/수정 - * + * * @param specialNoteRequest * @throws Exception */ @@ -38,7 +38,7 @@ public class SpecialNoteController { /** * 견적 특이사항 ITEM 정보 등록/수정 - * + * * @param specialNoteItemRequest * @throws Exception */ @@ -49,5 +49,4 @@ public class SpecialNoteController { throws Exception { specialNoteService.setSpecialNoteItemSave(specialNoteItemRequest); } - } diff --git a/src/main/java/com/interplug/qcast/biz/specialNote/SpecialNoteService.java b/src/main/java/com/interplug/qcast/biz/specialNote/SpecialNoteService.java index cdbfdfe2..3b753c0b 100644 --- a/src/main/java/com/interplug/qcast/biz/specialNote/SpecialNoteService.java +++ b/src/main/java/com/interplug/qcast/biz/specialNote/SpecialNoteService.java @@ -16,7 +16,7 @@ public class SpecialNoteService { /** * 견적 특이사항 저장 - * + * * @param specialNoteRequest * @throws Exception */ @@ -26,7 +26,7 @@ public class SpecialNoteService { /** * 견적 특이사항 아이템 저장 - * + * * @param specialNoteItemRequest * @throws Exception */ @@ -37,7 +37,7 @@ public class SpecialNoteService { /** * 견적 특이사항 동기화 - Batch - * + * * @param specialNoteList * @throws Exception */ @@ -54,7 +54,7 @@ public class SpecialNoteService { /** * 견적 특이사항 아이템 동기화 - Batch - * + * * @param specialNoteItemList * @throws Exception */ @@ -69,5 +69,4 @@ public class SpecialNoteService { } } } - } diff --git a/src/main/java/com/interplug/qcast/biz/storeFavorite/StoreFavoriteController.java b/src/main/java/com/interplug/qcast/biz/storeFavorite/StoreFavoriteController.java index 860a5ff4..75dae9d5 100644 --- a/src/main/java/com/interplug/qcast/biz/storeFavorite/StoreFavoriteController.java +++ b/src/main/java/com/interplug/qcast/biz/storeFavorite/StoreFavoriteController.java @@ -32,10 +32,8 @@ public class StoreFavoriteController { int resultCnt = storeFavService.setStoreFavoriteSave(req); - if (resultCnt > 0) - userResponse.setCode("200"); - else - userResponse.setCode("500"); + if (resultCnt > 0) userResponse.setCode("200"); + else userResponse.setCode("500"); return userResponse; } @@ -47,5 +45,4 @@ public class StoreFavoriteController { throws Exception { return storeFavService.getStoreFavoriteList(req); } - } From ff25eb4565a24b9de5cc61ab12d3eac6f029b556 Mon Sep 17 00:00:00 2001 From: Daseul Kim Date: Wed, 12 Feb 2025 17:42:00 +0900 Subject: [PATCH 2/4] =?UTF-8?q?refactor:=20service=20=EB=82=B4=20transacti?= =?UTF-8?q?on,=20throw=20QcastException=20=EC=B2=98=EB=A6=AC=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CanvasBasicSettingController.java | 3 +- .../CanvasBasicSettingService.java | 47 +++++---- .../CanvasGridSettingController.java | 12 +-- .../CanvasGridSettingService.java | 19 +++- .../CanvasSettingController.java | 10 +- .../canvasSetting/CanvasSettingService.java | 33 ++++--- .../biz/canvasStatus/CanvasStatusService.java | 98 ++++++++++++------- .../displayItem/DisplayItemController.java | 14 +-- .../biz/displayItem/DisplayItemService.java | 75 ++++++++------ 9 files changed, 192 insertions(+), 119 deletions(-) diff --git a/src/main/java/com/interplug/qcast/biz/canvasBasicSetting/CanvasBasicSettingController.java b/src/main/java/com/interplug/qcast/biz/canvasBasicSetting/CanvasBasicSettingController.java index 1e4ff0a6..6a4b7f5b 100644 --- a/src/main/java/com/interplug/qcast/biz/canvasBasicSetting/CanvasBasicSettingController.java +++ b/src/main/java/com/interplug/qcast/biz/canvasBasicSetting/CanvasBasicSettingController.java @@ -23,7 +23,8 @@ public class CanvasBasicSettingController { @Operation(description = "Canvas Basic Setting 정보를 조회 한다.") @GetMapping("/canvas-basic-settings/by-object/{objectNo}") - public List selectCanvasBasicSetting(@PathVariable String objectNo) { + public List selectCanvasBasicSetting(@PathVariable String objectNo) + throws QcastException { log.debug("Basic Setting 조회 ::::: " + objectNo); diff --git a/src/main/java/com/interplug/qcast/biz/canvasBasicSetting/CanvasBasicSettingService.java b/src/main/java/com/interplug/qcast/biz/canvasBasicSetting/CanvasBasicSettingService.java index 6b6dc436..50be0da3 100644 --- a/src/main/java/com/interplug/qcast/biz/canvasBasicSetting/CanvasBasicSettingService.java +++ b/src/main/java/com/interplug/qcast/biz/canvasBasicSetting/CanvasBasicSettingService.java @@ -13,19 +13,27 @@ import java.util.Map; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Slf4j @Service @RequiredArgsConstructor +@Transactional(readOnly = true) public class CanvasBasicSettingService { private final CanvasBasicSettingMapper canvasBasicSettingMapper; // Canvas Basic Setting 조회(objectNo) - public List selectCanvasBasicSetting(String objectNo) { - return canvasBasicSettingMapper.selectCanvasBasicSetting(objectNo); + public List selectCanvasBasicSetting(String objectNo) + throws QcastException { + try { + return canvasBasicSettingMapper.selectCanvasBasicSetting(objectNo); + } catch (Exception e) { + throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, e.getMessage()); + } } // Canvas Basic Setting 등록 + @Transactional public Map insertCanvasBasicSetting(CanvasBasicSettingInfo csi) throws QcastException { @@ -56,9 +64,6 @@ public class CanvasBasicSettingService { canvasBasicSettingMapper.insertRoofMaterialsAdd(rma); } - response.put("objectNo", csi.getObjectNo()); - response.put("returnMessage", "common.message.confirm.mark"); - } else { // 도면/치수/각도 정보 update canvasBasicSettingMapper.updateCanvasBasicSetting(csi); @@ -70,14 +75,12 @@ public class CanvasBasicSettingService { // 신규 지붕재추가 정보 insert 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) { - response.put("objectNo", csi.getObjectNo()); - response.put("returnMessage", "common.message.save.error"); + throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, e.getMessage()); } // 생성된 objectNo 반환 @@ -85,6 +88,7 @@ public class CanvasBasicSettingService { } // 지붕면 할당 Setting 등록 + @Transactional public Map insertRoofAllocSetting(RoofAllocationSettingInfo rasi) throws QcastException { @@ -107,8 +111,7 @@ public class CanvasBasicSettingService { response.put("objectNo", rasi.getObjectNo()); response.put("returnMessage", "common.message.confirm.mark"); } catch (Exception e) { - response.put("objectNo", rasi.getObjectNo()); - response.put("returnMessage", "common.message.save.error"); + throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, e.getMessage()); } // 생성된 objectNo 반환 @@ -116,20 +119,26 @@ public class CanvasBasicSettingService { } // 지붕재추가 삭제 + @Transactional public void deleteRoofMaterialsAdd(String objectNo) throws QcastException { if (objectNo == null || objectNo.trim().isEmpty()) { throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, "올바르지 않은 입력값입니다."); } - // 먼저 데이터가 존재하는지 확인 - RoofMaterialsAddInfo cntData = canvasBasicSettingMapper.getRoofMaterialsCnt(objectNo); + try { + // 먼저 데이터가 존재하는지 확인 + RoofMaterialsAddInfo cntData = canvasBasicSettingMapper.getRoofMaterialsCnt(objectNo); - // 데이터가 존재하지 않으면 수정하지 않고 예외를 던짐 - if (cntData.getRoofCnt().intValue() > 0) { - canvasBasicSettingMapper.deleteRoofMaterialsAdd(objectNo); - } else { - throw new QcastException(ErrorCode.NOT_FOUND, "삭제할 지붕재가 존재하지 않습니다."); + // 데이터가 존재하지 않으면 수정하지 않고 예외를 던짐 + if (cntData.getRoofCnt().intValue() > 0) { + canvasBasicSettingMapper.deleteRoofMaterialsAdd(objectNo); + } else { + throw new QcastException(ErrorCode.NOT_FOUND, "삭제할 지붕재가 존재하지 않습니다."); + } + } catch (Exception e) { + if (e instanceof QcastException) throw e; + throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, e.getMessage()); } } } diff --git a/src/main/java/com/interplug/qcast/biz/canvasGridSetting/CanvasGridSettingController.java b/src/main/java/com/interplug/qcast/biz/canvasGridSetting/CanvasGridSettingController.java index a09f0f43..f245d333 100644 --- a/src/main/java/com/interplug/qcast/biz/canvasGridSetting/CanvasGridSettingController.java +++ b/src/main/java/com/interplug/qcast/biz/canvasGridSetting/CanvasGridSettingController.java @@ -1,14 +1,12 @@ package com.interplug.qcast.biz.canvasGridSetting; 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.tags.Tag; +import java.util.Map; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; - -import java.util.Map; - import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; @@ -22,7 +20,8 @@ public class CanvasGridSettingController { @Operation(description = "Canvas Grid Setting 정보를 조회 한다.") @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); @@ -32,7 +31,8 @@ public class CanvasGridSettingController { @Operation(description = "Canvas Grid Setting 정보를 등록 한다.") @PostMapping("/canvas-grid-settings") @ResponseStatus(HttpStatus.CREATED) - public Map insertCanvasGridStatus(@RequestBody CanvasGridSettingInfo csi) { + public Map insertCanvasGridStatus(@RequestBody CanvasGridSettingInfo csi) + throws QcastException { log.debug("Grid Setting 등록 ::::: " + csi.getObjectNo()); diff --git a/src/main/java/com/interplug/qcast/biz/canvasGridSetting/CanvasGridSettingService.java b/src/main/java/com/interplug/qcast/biz/canvasGridSetting/CanvasGridSettingService.java index dcfc9986..8b0d8e93 100644 --- a/src/main/java/com/interplug/qcast/biz/canvasGridSetting/CanvasGridSettingService.java +++ b/src/main/java/com/interplug/qcast/biz/canvasGridSetting/CanvasGridSettingService.java @@ -2,25 +2,35 @@ package com.interplug.qcast.biz.canvasGridSetting; 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 java.util.HashMap; import java.util.Map; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Service @RequiredArgsConstructor +@Transactional(readOnly = true) public class CanvasGridSettingService { private final CanvasGridSettingMapper canvasGridSettingMapper; // Canvas Setting 조회(objectNo) - public CanvasGridSettingInfo selectCanvasGridSetting(String objectNo) { - return canvasGridSettingMapper.selectCanvasGridSetting(objectNo); + public CanvasGridSettingInfo selectCanvasGridSetting(String objectNo) throws QcastException { + try { + return canvasGridSettingMapper.selectCanvasGridSetting(objectNo); + } catch (Exception e) { + throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, e.getMessage()); + } } // Canvas Setting 등록 - public Map insertCanvasGridSetting(CanvasGridSettingInfo csi) { + @Transactional + public Map insertCanvasGridSetting(CanvasGridSettingInfo csi) + throws QcastException { Map response = new HashMap<>(); @@ -31,8 +41,7 @@ public class CanvasGridSettingService { response.put("returnMessage", "common.message.confirm.mark"); } catch (Exception e) { - response.put("objectNo", csi.getObjectNo()); - response.put("returnMessage", "common.message.save.error"); + throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, e.getMessage()); } // 생성된 objectNo 반환 diff --git a/src/main/java/com/interplug/qcast/biz/canvasSetting/CanvasSettingController.java b/src/main/java/com/interplug/qcast/biz/canvasSetting/CanvasSettingController.java index f1a91853..c2cc8193 100644 --- a/src/main/java/com/interplug/qcast/biz/canvasSetting/CanvasSettingController.java +++ b/src/main/java/com/interplug/qcast/biz/canvasSetting/CanvasSettingController.java @@ -2,14 +2,11 @@ package com.interplug.qcast.biz.canvasSetting; import com.interplug.qcast.biz.canvasSetting.dto.CanvasSettingInfo; import com.interplug.qcast.config.Exception.QcastException; - import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.Map; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; - -import java.util.Map; - import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; @@ -23,7 +20,8 @@ public class CanvasSettingController { @Operation(description = "Canvas Setting 정보를 조회 한다.") @GetMapping("/canvas-settings/by-object/{objectNo}") - public CanvasSettingInfo selectCanvasSetting(@PathVariable String objectNo) { + public CanvasSettingInfo selectCanvasSetting(@PathVariable String objectNo) + throws QcastException { log.debug("Setting 조회 ::::: " + objectNo); @@ -43,7 +41,7 @@ public class CanvasSettingController { @Operation(description = "Canvas Setting 정보를 수정 한다.") @PutMapping("/canvas-settings") - public void updateCanvasStatus(@RequestBody CanvasSettingInfo csi) { + public void updateCanvasStatus(@RequestBody CanvasSettingInfo csi) throws QcastException { log.debug("Setting 수정 ::::: " + csi.getObjectNo()); diff --git a/src/main/java/com/interplug/qcast/biz/canvasSetting/CanvasSettingService.java b/src/main/java/com/interplug/qcast/biz/canvasSetting/CanvasSettingService.java index 239c5655..c9fb2f6e 100644 --- a/src/main/java/com/interplug/qcast/biz/canvasSetting/CanvasSettingService.java +++ b/src/main/java/com/interplug/qcast/biz/canvasSetting/CanvasSettingService.java @@ -7,18 +7,25 @@ import java.util.HashMap; import java.util.Map; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Service @RequiredArgsConstructor +@Transactional(readOnly = true) public class CanvasSettingService { private final CanvasSettingMapper canvasSettingMapper; // Canvas Setting 조회(objectNo) - public CanvasSettingInfo selectCanvasSetting(String objectNo) { - return canvasSettingMapper.selectCanvasSetting(objectNo); + public CanvasSettingInfo selectCanvasSetting(String objectNo) throws QcastException { + try { + return canvasSettingMapper.selectCanvasSetting(objectNo); + } catch (Exception e) { + throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, e.getMessage()); + } } // Canvas Setting 등록 + @Transactional public Map insertCanvasSetting(CanvasSettingInfo csi) throws QcastException { Map response = new HashMap<>(); @@ -35,20 +42,13 @@ public class CanvasSettingService { // 데이터가 존재하지 않으면 insert if (cntData.getCnt().intValue() < 1) { canvasSettingMapper.insertCanvasSetting(csi); - - response.put("objectNo", csi.getObjectNo()); - response.put("returnMessage", "common.message.confirm.mark"); - } else { 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("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 반환 @@ -56,7 +56,12 @@ public class CanvasSettingService { } // Canvas Setting 수정 - public void updateCanvasSetting(CanvasSettingInfo csi) { - canvasSettingMapper.updateCanvasSetting(csi); + @Transactional + public void updateCanvasSetting(CanvasSettingInfo csi) throws QcastException { + try { + canvasSettingMapper.updateCanvasSetting(csi); + } catch (Exception e) { + throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, e.getMessage()); + } } } diff --git a/src/main/java/com/interplug/qcast/biz/canvasStatus/CanvasStatusService.java b/src/main/java/com/interplug/qcast/biz/canvasStatus/CanvasStatusService.java index 5b0abd71..c2e5e606 100644 --- a/src/main/java/com/interplug/qcast/biz/canvasStatus/CanvasStatusService.java +++ b/src/main/java/com/interplug/qcast/biz/canvasStatus/CanvasStatusService.java @@ -8,9 +8,11 @@ import com.interplug.qcast.config.Exception.QcastException; import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Service @RequiredArgsConstructor +@Transactional(readOnly = true) public class CanvasStatusService { private final CanvasStatusMapper canvasStatusMapper; @@ -18,10 +20,15 @@ public class CanvasStatusService { public List selectAllCanvasStatus(String userId) throws QcastException { List result = null; - if (userId != null && !userId.trim().isEmpty()) { - result = canvasStatusMapper.selectAllCanvasStatus(userId); - } else { - throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, "올바르지 않은 입력값입니다."); + try { + if (userId != null && !userId.trim().isEmpty()) { + result = canvasStatusMapper.selectAllCanvasStatus(userId); + } 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; @@ -32,16 +39,22 @@ public class CanvasStatusService { throws QcastException { List result = null; - if (objectNo != null && !objectNo.trim().isEmpty()) { - result = canvasStatusMapper.selectObjectNoCanvasStatus(objectNo); - } else { - throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, "올바르지 않은 입력값입니다."); + try { + if (objectNo != null && !objectNo.trim().isEmpty()) { + result = canvasStatusMapper.selectObjectNoCanvasStatus(objectNo); + } 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; } // 캔버스 등록 + @Transactional public Integer insertCanvasStatus(CanvasStatus cs) throws QcastException { Integer id = 0; @@ -56,7 +69,7 @@ public class CanvasStatusService { id = maxId.get(0).getId(); } catch (Exception e) { - throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, "캔버스 등록 중 오류 발생"); + throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, e.getMessage()); } // 생성된 id 반환 @@ -64,63 +77,82 @@ public class CanvasStatusService { } // 캔버스 수정 + @Transactional public void updateCanvasStatus(CanvasStatus cs) throws QcastException { if (cs.getId() == null) { throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, "올바르지 않은 입력값입니다."); } - // 먼저 데이터가 존재하는지 확인 - List existingStatus = canvasStatusMapper.getIdCanvasStatus(cs.getId()); + try { + // 먼저 데이터가 존재하는지 확인 + List existingStatus = canvasStatusMapper.getIdCanvasStatus(cs.getId()); - // 데이터가 존재하지 않으면 수정하지 않고 예외를 던짐 - if (existingStatus.size() > 0) { - canvasStatusMapper.updateCanvasStatus(cs); - } else { - throw new QcastException(ErrorCode.NOT_FOUND, "수정할 캔버스가 존재하지 않습니다."); + // 데이터가 존재하지 않으면 수정하지 않고 예외를 던짐 + if (existingStatus.size() > 0) { + canvasStatusMapper.updateCanvasStatus(cs); + } else { + 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)에 해당하는 캔버스 삭제 + @Transactional public void deleteObjectNoCanvasStatus(String objectNo) throws QcastException { if (objectNo == null || objectNo.trim().isEmpty()) { throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, "올바르지 않은 입력값입니다."); } - // 먼저 데이터가 존재하는지 확인 - List existingStatus = - canvasStatusMapper.getObjectNoCanvasStatus(objectNo); + try { + // 먼저 데이터가 존재하는지 확인 + List existingStatus = + canvasStatusMapper.getObjectNoCanvasStatus(objectNo); - // 데이터가 존재하지 않으면 수정하지 않고 예외를 던짐 - if (existingStatus.size() > 0) { - canvasStatusMapper.deleteObjectNoCanvasStatus(objectNo); - } else { - throw new QcastException(ErrorCode.NOT_FOUND, "삭제할 캔버스가 존재하지 않습니다."); + // 데이터가 존재하지 않으면 수정하지 않고 예외를 던짐 + if (existingStatus.size() > 0) { + canvasStatusMapper.deleteObjectNoCanvasStatus(objectNo); + } else { + 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에 해당하는 캔버스 삭제 + @Transactional public void deleteIdCanvasStatus(Integer id) throws QcastException { if (id == null) { throw new QcastException(ErrorCode.INVALID_INPUT_VALUE, "올바르지 않은 입력값입니다."); } - // 먼저 데이터가 존재하는지 확인 - List existingStatus = canvasStatusMapper.getIdCanvasStatus(id); + try { + // 먼저 데이터가 존재하는지 확인 + List existingStatus = canvasStatusMapper.getIdCanvasStatus(id); - // 데이터가 존재하지 않으면 처리하지 않고 예외를 던짐 - if (existingStatus.size() > 0) { - // 데이터를 삭제하는 기존 방식에서 데이터를 삭제하지 않고 deleted 데이터를 바꾸는 방식으로 변경 (2025.02.11) - // canvasStatusMapper.deleteIdCanvasStatus(id); - canvasStatusMapper.updateDeletedCanvasStatus(id); - } else { - throw new QcastException(ErrorCode.NOT_FOUND, "삭제할 캔버스가 존재하지 않습니다."); + // 데이터가 존재하지 않으면 처리하지 않고 예외를 던짐 + if (existingStatus.size() > 0) { + // 데이터를 삭제하는 기존 방식에서 데이터를 삭제하지 않고 deleted 데이터를 바꾸는 방식으로 변경 (2025.02.11) + // canvasStatusMapper.deleteIdCanvasStatus(id); + canvasStatusMapper.updateDeletedCanvasStatus(id); + } else { + 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 { try { canvasStatusMapper.copyCanvasStatus(cs); diff --git a/src/main/java/com/interplug/qcast/biz/displayItem/DisplayItemController.java b/src/main/java/com/interplug/qcast/biz/displayItem/DisplayItemController.java index d4c46425..47543967 100644 --- a/src/main/java/com/interplug/qcast/biz/displayItem/DisplayItemController.java +++ b/src/main/java/com/interplug/qcast/biz/displayItem/DisplayItemController.java @@ -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.ItemRequest; 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.tags.Tag; import java.util.List; @@ -30,13 +31,13 @@ public class DisplayItemController { * 전시제품 정보 등록/수정 * * @param displayItemRequest - * @throws Exception + * @throws QcastException */ @Operation(description = "전시제품 정보를 등록/수정한다. (동기화)") @PostMapping("/display-item-save") @ResponseStatus(HttpStatus.OK) public void setStoreDisplayItemSave(@RequestBody DisplayItemRequest displayItemRequest) - throws Exception { + throws QcastException { displayItemService.setStoreDisplayItemSave(displayItemRequest); } @@ -45,12 +46,13 @@ public class DisplayItemController { * * @param itemRequest * @return - * @throws Exception + * @throws QcastException */ @Operation(description = "제품 목록을 조회한다.") @PostMapping("/item-list") @ResponseStatus(HttpStatus.OK) - public List getItemList(@RequestBody ItemRequest itemRequest) throws Exception { + public List getItemList(@RequestBody ItemRequest itemRequest) + throws QcastException { return displayItemService.getItemList(itemRequest); } @@ -59,12 +61,12 @@ public class DisplayItemController { * * @param itemId * @return - * @throws Exception + * @throws QcastException */ @Operation(description = "제품 상세 정보를 조회한다.") @GetMapping("/item-detail") @ResponseStatus(HttpStatus.OK) - public ItemDetailResponse getItemDetail(@RequestParam String itemId) throws Exception { + public ItemDetailResponse getItemDetail(@RequestParam String itemId) throws QcastException { return displayItemService.getItemDetail(itemId); } } diff --git a/src/main/java/com/interplug/qcast/biz/displayItem/DisplayItemService.java b/src/main/java/com/interplug/qcast/biz/displayItem/DisplayItemService.java index d90211c8..ceb9ec5c 100644 --- a/src/main/java/com/interplug/qcast/biz/displayItem/DisplayItemService.java +++ b/src/main/java/com/interplug/qcast/biz/displayItem/DisplayItemService.java @@ -4,15 +4,19 @@ import com.interplug.qcast.biz.displayItem.dto.*; import com.interplug.qcast.biz.estimate.EstimateMapper; import com.interplug.qcast.biz.estimate.dto.NoteRequest; 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 java.util.List; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Slf4j @Service @RequiredArgsConstructor +@Transactional(readOnly = true) public class DisplayItemService { private final EstimateMapper estimateMapper; @@ -23,10 +27,15 @@ public class DisplayItemService { * 판매점 노출 아이템 정보 저장 * * @param displayItemRequest - * @throws Exception + * @throws QcastException */ - public void setStoreDisplayItemSave(DisplayItemRequest displayItemRequest) throws Exception { - displayItemMapper.setStoreDisplayItemSave(displayItemRequest); + @Transactional + 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 * @return + * @throws QcastException */ - public List getItemList(ItemRequest itemRequest) { - return displayItemMapper.getItemList(itemRequest); + public List getItemList(ItemRequest itemRequest) throws QcastException { + 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 * @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 itemBomList = displayItemMapper.selectItemBomList(itemId); - if (itemDetailResponse != null) { - // BOM 헤더 아이템인 경우 BOM List를 내려준다. - if ("ERLA".equals(itemDetailResponse.getItemCtgGr())) { - List itemBomList = displayItemMapper.selectItemBomList(itemId); + itemDetailResponse.setItemBomList(itemBomList); + } - itemDetailResponse.setItemBomList(itemBomList); + // 견적특이사항 관련 데이터 셋팅 + String[] arrItemId = {itemId}; + + NoteRequest noteRequest = new NoteRequest(); + noteRequest.setArrItemId(arrItemId); + noteRequest.setSchSpnTypeCd("PROD"); + List noteItemList = estimateMapper.selectEstimateNoteItemList(noteRequest); + + String spnAttrCds = ""; + for (NoteResponse noteResponse : noteItemList) { + spnAttrCds += !StringUtils.isEmpty(spnAttrCds) ? "、" : ""; + spnAttrCds += noteResponse.getCode(); + } + + itemDetailResponse.setSpnAttrCds(spnAttrCds); } - // 견적특이사항 관련 데이터 셋팅 - String[] arrItemId = {itemId}; - - NoteRequest noteRequest = new NoteRequest(); - noteRequest.setArrItemId(arrItemId); - noteRequest.setSchSpnTypeCd("PROD"); - List noteItemList = estimateMapper.selectEstimateNoteItemList(noteRequest); - - String spnAttrCds = ""; - for (NoteResponse noteResponse : noteItemList) { - spnAttrCds += !StringUtils.isEmpty(spnAttrCds) ? "、" : ""; - spnAttrCds += noteResponse.getCode(); - } - - itemDetailResponse.setSpnAttrCds(spnAttrCds); + return itemDetailResponse; + } catch (Exception e) { + throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, e.getMessage()); } - - return itemDetailResponse; } /** From 75e511867987c8a62ac3416ff3856fbcb4595f7d Mon Sep 17 00:00:00 2001 From: yoosangwook Date: Wed, 12 Feb 2025 18:17:36 +0900 Subject: [PATCH 3/4] =?UTF-8?q?fix:=20=ED=8F=AC=EB=A9=A7=ED=8C=85,=20@Tran?= =?UTF-8?q?sactional,=20throws=20exception=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../qcast/biz/canvaspopupstatus/CanvasPopupStatusService.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/interplug/qcast/biz/canvaspopupstatus/CanvasPopupStatusService.java b/src/main/java/com/interplug/qcast/biz/canvaspopupstatus/CanvasPopupStatusService.java index 2b0e86d4..9f0c5855 100644 --- a/src/main/java/com/interplug/qcast/biz/canvaspopupstatus/CanvasPopupStatusService.java +++ b/src/main/java/com/interplug/qcast/biz/canvaspopupstatus/CanvasPopupStatusService.java @@ -5,9 +5,11 @@ import com.interplug.qcast.config.Exception.ErrorCode; import com.interplug.qcast.config.Exception.QcastException; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Service @RequiredArgsConstructor +@Transactional(readOnly = true) public class CanvasPopupStatusService { private final CanvasPopupStatusMapper canvasPopupStatusMapper; @@ -34,6 +36,7 @@ public class CanvasPopupStatusService { * @param cps 저장할 CanvasPopupStatus 객체 * @throws QcastException 저장 중 예외 발생 시 */ + @Transactional public void saveCanvasPopupStatus(CanvasPopupStatus cps) throws QcastException { CanvasPopupStatus chk = canvasPopupStatusMapper.selectCanvasPopupStatus(cps); if (chk == null) { @@ -49,6 +52,7 @@ public class CanvasPopupStatusService { * @param cps 생성할 CanvasPopupStatus 객체 * @throws QcastException 생성 중 예외 발생 시 */ + @Transactional public void createCanvasPopupStatus(CanvasPopupStatus cps) throws QcastException { try { canvasPopupStatusMapper.insertCanvasPopupStatus(cps); From 22e11ec0578ad0fa8c29883ddb61147573deb981 Mon Sep 17 00:00:00 2001 From: yoosangwook Date: Wed, 12 Feb 2025 18:24:09 +0900 Subject: [PATCH 4/4] fix: Add service tx annotation --- .../biz/canvasBasicSetting/CanvasBasicSettingService.java | 5 ----- .../biz/canvasGridSetting/CanvasGridSettingService.java | 8 +------- .../qcast/biz/canvasSetting/CanvasSettingService.java | 4 ---- .../qcast/biz/canvasStatus/CanvasStatusService.java | 5 ----- .../qcast/biz/displayItem/DisplayItemService.java | 3 --- 5 files changed, 1 insertion(+), 24 deletions(-) diff --git a/src/main/java/com/interplug/qcast/biz/canvasBasicSetting/CanvasBasicSettingService.java b/src/main/java/com/interplug/qcast/biz/canvasBasicSetting/CanvasBasicSettingService.java index 50be0da3..95c1631d 100644 --- a/src/main/java/com/interplug/qcast/biz/canvasBasicSetting/CanvasBasicSettingService.java +++ b/src/main/java/com/interplug/qcast/biz/canvasBasicSetting/CanvasBasicSettingService.java @@ -13,12 +13,10 @@ import java.util.Map; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; @Slf4j @Service @RequiredArgsConstructor -@Transactional(readOnly = true) public class CanvasBasicSettingService { private final CanvasBasicSettingMapper canvasBasicSettingMapper; @@ -33,7 +31,6 @@ public class CanvasBasicSettingService { } // Canvas Basic Setting 등록 - @Transactional public Map insertCanvasBasicSetting(CanvasBasicSettingInfo csi) throws QcastException { @@ -88,7 +85,6 @@ public class CanvasBasicSettingService { } // 지붕면 할당 Setting 등록 - @Transactional public Map insertRoofAllocSetting(RoofAllocationSettingInfo rasi) throws QcastException { @@ -119,7 +115,6 @@ public class CanvasBasicSettingService { } // 지붕재추가 삭제 - @Transactional public void deleteRoofMaterialsAdd(String objectNo) throws QcastException { if (objectNo == null || objectNo.trim().isEmpty()) { diff --git a/src/main/java/com/interplug/qcast/biz/canvasGridSetting/CanvasGridSettingService.java b/src/main/java/com/interplug/qcast/biz/canvasGridSetting/CanvasGridSettingService.java index 8b0d8e93..fb7889a3 100644 --- a/src/main/java/com/interplug/qcast/biz/canvasGridSetting/CanvasGridSettingService.java +++ b/src/main/java/com/interplug/qcast/biz/canvasGridSetting/CanvasGridSettingService.java @@ -1,20 +1,15 @@ package com.interplug.qcast.biz.canvasGridSetting; 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 java.util.HashMap; import java.util.Map; - +import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; @Service @RequiredArgsConstructor -@Transactional(readOnly = true) public class CanvasGridSettingService { private final CanvasGridSettingMapper canvasGridSettingMapper; @@ -28,7 +23,6 @@ public class CanvasGridSettingService { } // Canvas Setting 등록 - @Transactional public Map insertCanvasGridSetting(CanvasGridSettingInfo csi) throws QcastException { diff --git a/src/main/java/com/interplug/qcast/biz/canvasSetting/CanvasSettingService.java b/src/main/java/com/interplug/qcast/biz/canvasSetting/CanvasSettingService.java index c9fb2f6e..991e6247 100644 --- a/src/main/java/com/interplug/qcast/biz/canvasSetting/CanvasSettingService.java +++ b/src/main/java/com/interplug/qcast/biz/canvasSetting/CanvasSettingService.java @@ -7,11 +7,9 @@ import java.util.HashMap; import java.util.Map; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; @Service @RequiredArgsConstructor -@Transactional(readOnly = true) public class CanvasSettingService { private final CanvasSettingMapper canvasSettingMapper; @@ -25,7 +23,6 @@ public class CanvasSettingService { } // Canvas Setting 등록 - @Transactional public Map insertCanvasSetting(CanvasSettingInfo csi) throws QcastException { Map response = new HashMap<>(); @@ -56,7 +53,6 @@ public class CanvasSettingService { } // Canvas Setting 수정 - @Transactional public void updateCanvasSetting(CanvasSettingInfo csi) throws QcastException { try { canvasSettingMapper.updateCanvasSetting(csi); diff --git a/src/main/java/com/interplug/qcast/biz/canvasStatus/CanvasStatusService.java b/src/main/java/com/interplug/qcast/biz/canvasStatus/CanvasStatusService.java index c2e5e606..313c836f 100644 --- a/src/main/java/com/interplug/qcast/biz/canvasStatus/CanvasStatusService.java +++ b/src/main/java/com/interplug/qcast/biz/canvasStatus/CanvasStatusService.java @@ -12,7 +12,6 @@ import org.springframework.transaction.annotation.Transactional; @Service @RequiredArgsConstructor -@Transactional(readOnly = true) public class CanvasStatusService { private final CanvasStatusMapper canvasStatusMapper; @@ -54,7 +53,6 @@ public class CanvasStatusService { } // 캔버스 등록 - @Transactional public Integer insertCanvasStatus(CanvasStatus cs) throws QcastException { Integer id = 0; @@ -77,7 +75,6 @@ public class CanvasStatusService { } // 캔버스 수정 - @Transactional public void updateCanvasStatus(CanvasStatus cs) throws QcastException { if (cs.getId() == null) { @@ -101,7 +98,6 @@ public class CanvasStatusService { } // 물건번호(objectNo)에 해당하는 캔버스 삭제 - @Transactional public void deleteObjectNoCanvasStatus(String objectNo) throws QcastException { if (objectNo == null || objectNo.trim().isEmpty()) { @@ -126,7 +122,6 @@ public class CanvasStatusService { } // id에 해당하는 캔버스 삭제 - @Transactional public void deleteIdCanvasStatus(Integer id) throws QcastException { if (id == null) { diff --git a/src/main/java/com/interplug/qcast/biz/displayItem/DisplayItemService.java b/src/main/java/com/interplug/qcast/biz/displayItem/DisplayItemService.java index ceb9ec5c..534b6cfe 100644 --- a/src/main/java/com/interplug/qcast/biz/displayItem/DisplayItemService.java +++ b/src/main/java/com/interplug/qcast/biz/displayItem/DisplayItemService.java @@ -11,12 +11,10 @@ import java.util.List; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; @Slf4j @Service @RequiredArgsConstructor -@Transactional(readOnly = true) public class DisplayItemService { private final EstimateMapper estimateMapper; @@ -29,7 +27,6 @@ public class DisplayItemService { * @param displayItemRequest * @throws QcastException */ - @Transactional public void setStoreDisplayItemSave(DisplayItemRequest displayItemRequest) throws QcastException { try { displayItemMapper.setStoreDisplayItemSave(displayItemRequest);