From b3eecb0f505bde1c0ece267b3c30496841280a51 Mon Sep 17 00:00:00 2001 From: thkim Date: Thu, 25 Jan 2024 14:04:47 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EA=B4=80=EB=A6=AC=EC=9E=90=20-=20?= =?UTF-8?q?=EC=BB=A8=ED=85=90=EC=B8=A0=EA=B4=80=EB=A6=AC=20-=20=ED=8C=9D?= =?UTF-8?q?=EC=97=85=EA=B4=80=EB=A6=AC=EC=97=90=EC=84=9C=20=ED=8A=B9?= =?UTF-8?q?=EC=A0=95=20=ED=8C=9D=EC=97=85=20=EB=88=8C=EB=9F=AC=EC=84=9C=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C=20=EC=8B=9C,=20=EC=8B=A4=EC=A0=9C=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C=20=EB=90=98=EB=8F=84=EB=A1=9D=20API=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../popUp/controller/PopUpApiController.java | 43 ++++++++++++ .../popUp/service/PopUpApiService.java | 7 +- .../service/impl/PopUpApiServiceImpl.java | 68 ++++++++++++++++--- .../commonCode/entity/TnPopupMng.java | 1 + .../repository/TnPopupMngRepository.java | 2 +- 5 files changed, 111 insertions(+), 10 deletions(-) diff --git a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/contents/popUp/controller/PopUpApiController.java b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/contents/popUp/controller/PopUpApiController.java index 4f48dff..23c74a8 100644 --- a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/contents/popUp/controller/PopUpApiController.java +++ b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/contents/popUp/controller/PopUpApiController.java @@ -13,6 +13,7 @@ import com.dbnt.kcscbackend.auth.entity.LoginVO; import com.dbnt.kcscbackend.config.common.ResponseCode; import com.dbnt.kcscbackend.config.common.ResultVO; import io.swagger.annotations.Api; +import io.swagger.annotations.ApiParam; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; @@ -161,6 +162,7 @@ public class PopUpApiController { } + @Operation( summary = "팝업 비활성화 API", description = "관리자 단에서 '컨텐츠 관리' > '팝업 관리' 페이지에서 팝업을 비활성화 API. 삭제가 아닌 비활성화 임. 삭제는 없음.", @@ -199,6 +201,47 @@ public class PopUpApiController { return resultVO; } + + @Operation( + summary = "팝업 활성화 또는 비활성화 설정하는 API", + description = "관리자 단에서 '컨텐츠 관리' > '팝업 관리' 페이지에서 '사용여부'를 활성화 또는 비활성화 설정해주는 API.", + tags = {"PopUpApiController"} + ) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "등록 성공"), + @ApiResponse(responseCode = "403", description = "인가된 사용자가 아님"), + }) + @PutMapping(value = "/contents/api/popup-manage/activation-switch/{popupId}") + public ResultVO contentsApiPopUpManageUpdateActivationSwitch( + HttpServletRequest request, + @AuthenticationPrincipal LoginVO loginVO, + @ApiParam(value="활성화 여부") @RequestParam(required=true) String checked, + @PathVariable("popupId") Long popupId + ) throws Exception { + + ResultVO resultVO = new ResultVO(); + + try { + resultVO = popUpApiService.contentsApiPopUpManageUpdateActivationSwitch(resultVO, request, loginVO, checked, popupId); + } catch (Exception e) { + resultVO.setResultCode(ResponseCode.FAILED.getCode()); + resultVO.setResultMessage(e.getMessage()); + } + + + System.out.println( + "\n--------------------------------------------------------------\n" + + request.getRequestURI() + " OUT:" + + "\n--------------------------------------------------------------\n" + + "resultVO.toString():" + "\n" + + resultVO.toString() + "\n" + + "\n--------------------------------------------------------------\n" + ); + + return resultVO; + + } + @Operation( summary = "팝업 내용 불러오기 API", description = "관리자 단에서 '컨텐츠 관리' > '팝업 관리' 페이지에서 저장된 팝업을 불러오는 API", diff --git a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/contents/popUp/service/PopUpApiService.java b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/contents/popUp/service/PopUpApiService.java index cac0e52..dee31af 100644 --- a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/contents/popUp/service/PopUpApiService.java +++ b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/contents/popUp/service/PopUpApiService.java @@ -4,7 +4,11 @@ import com.dbnt.kcscbackend.admin.contents.popUp.model.CreatePopupVO; import com.dbnt.kcscbackend.admin.contents.popUp.model.UpdatePopupVO; import com.dbnt.kcscbackend.auth.entity.LoginVO; import com.dbnt.kcscbackend.config.common.ResultVO; +import io.swagger.annotations.ApiParam; import org.springframework.data.domain.Pageable; +import org.springframework.security.core.annotation.AuthenticationPrincipal; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.multipart.MultipartHttpServletRequest; import javax.servlet.http.HttpServletRequest; @@ -14,6 +18,7 @@ public interface PopUpApiService { public ResultVO contentsApiPopUpManageCreate(ResultVO resultVO, HttpServletRequest request, LoginVO user, final MultipartHttpServletRequest multiRequest, CreatePopupVO createPopupVO) throws Exception; public ResultVO contentsApiPopUpManageRead(ResultVO resultVO, HttpServletRequest request, LoginVO user, Long popupId) throws Exception; public ResultVO contentsApiPopUpManageUpdate(ResultVO resultVO, HttpServletRequest request, LoginVO user, UpdatePopupVO updatePopupVO, Long popupId) throws Exception; - public ResultVO contentsApiPopUpManageDelete(ResultVO resultVO, HttpServletRequest request, LoginVO user, Long popupId) throws Exception; + public ResultVO contentsApiPopUpManageUpdateActivationSwitch(ResultVO resultVO, HttpServletRequest request, LoginVO user, String checked, Long popupId) throws Exception; + } \ No newline at end of file diff --git a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/contents/popUp/service/impl/PopUpApiServiceImpl.java b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/contents/popUp/service/impl/PopUpApiServiceImpl.java index c9261a3..93bdbbf 100644 --- a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/contents/popUp/service/impl/PopUpApiServiceImpl.java +++ b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/contents/popUp/service/impl/PopUpApiServiceImpl.java @@ -236,16 +236,26 @@ public class PopUpApiServiceImpl extends EgovAbstractServiceImpl implements PopU ); - Map response = tnPopupMngRepository.spDeleteTnPopupMng( - popupId.intValue(), - "admin", - null, - null, - null - ); + + Map dto = new HashMap(); - dto.put("errorMessage", response.get("_error_message") ); + + if( false ) { + // 삭제 procedure가 삭제가 아닌 비활성화만 시키므로 해당 프로시저 사용 안 함. + Map response = tnPopupMngRepository.spDeleteTnPopupMng( + popupId.intValue(), + "admin", + null, + null, + null + ); + dto.put("errorMessage", response.get("_error_message") ); + } else { + tnPopupMngRepository.deleteById(popupId); + } + + dto.put("popupId", popupId ); resultVO.setResult(dto); @@ -255,5 +265,47 @@ public class PopUpApiServiceImpl extends EgovAbstractServiceImpl implements PopU return resultVO; } + @Override + public ResultVO contentsApiPopUpManageUpdateActivationSwitch(ResultVO resultVO, HttpServletRequest request, LoginVO user, String checked, Long popupId) throws Exception { + System.out.println( + "\n--------------------------------------------------------------\n" + + request.getRequestURI() + " IN:" + + "\n--------------------------------------------------------------\n" + + "checked:" + "\n" + + checked + "\n" + + "popupId:" + "\n" + + popupId + "\n" + + "\n--------------------------------------------------------------\n" + ); + + + + // 유효성 검사 실시 + int isValid = tnPopupMngRepository.spIsValidTnPopupMngId( popupId.intValue() ); + + if( isValid == 0 ) { + throw new Exception("대상이 존재하지 않습니다."); + } + + TnPopupMng tnPopupMng = tnPopupMngRepository.findByPopupSeq(popupId); + if( Boolean.parseBoolean(checked) ) { + tnPopupMng.setUseYn("Y"); + } else { + tnPopupMng.setUseYn("N"); + } + + tnPopupMngRepository.saveAndFlush(tnPopupMng); + + + Map dto = new HashMap(); + dto.put("popupId", popupId); + + resultVO.setResult(dto); + resultVO.setResultCode(ResponseCode.SUCCESS.getCode()); + resultVO.setResultMessage(ResponseCode.SUCCESS.getMessage()); + + return resultVO; + } + } diff --git a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/commonCode/entity/TnPopupMng.java b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/commonCode/entity/TnPopupMng.java index 7f72ca5..d14af26 100644 --- a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/commonCode/entity/TnPopupMng.java +++ b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/commonCode/entity/TnPopupMng.java @@ -62,6 +62,7 @@ public class TnPopupMng { @NoArgsConstructor @AllArgsConstructor public static class TnPopupMngId implements Serializable { + private static final long serialVersionUID = -6558812991140219351L; private String popupSeq; } diff --git a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/commonCode/repository/TnPopupMngRepository.java b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/commonCode/repository/TnPopupMngRepository.java index b0403f2..b98a290 100644 --- a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/commonCode/repository/TnPopupMngRepository.java +++ b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/commonCode/repository/TnPopupMngRepository.java @@ -11,7 +11,7 @@ import java.util.List; import java.util.Map; -public interface TnPopupMngRepository extends JpaRepository { +public interface TnPopupMngRepository extends JpaRepository { @Query(value = "CALL sp_add_tn_popup_mng (" + ":_popup_title, " +