From ffea20482073df2b490d1e0c1dcd3ae411cb107f Mon Sep 17 00:00:00 2001 From: thkim Date: Thu, 25 Jan 2024 10:02:49 +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=88=98=EC=A0=95=20=EC=8B=9C,=20=EC=88=98=EC=A0=95=ED=95=98?= =?UTF-8?q?=EB=8A=94=20API=20=EC=B6=94=EA=B0=80=20=EA=B1=B4=20back-end?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../popUp/controller/PopUpApiController.java | 4 +- .../contents/popUp/model/UpdatePopupVO.java | 18 ++---- .../popUp/service/PopUpApiService.java | 4 +- .../service/impl/PopUpApiServiceImpl.java | 59 +++++++++++++++---- .../repository/TnPopupMngRepository.java | 33 ++++++++++- 5 files changed, 93 insertions(+), 25 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 3d15090..87e9847 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 @@ -6,6 +6,7 @@ import com.dbnt.kcscbackend.admin.committee.schedules.model.UpdateScheduleVO; import com.dbnt.kcscbackend.admin.committee.schedules.service.EgovIndvdlSchdulManageService; import com.dbnt.kcscbackend.admin.contents.popUp.model.CreatePopupVO; import com.dbnt.kcscbackend.admin.contents.popUp.model.FileVO; +import com.dbnt.kcscbackend.admin.contents.popUp.model.UpdatePopupVO; import com.dbnt.kcscbackend.admin.contents.popUp.service.PopUpApiService; import com.dbnt.kcscbackend.admin.contents.popUp.utils.EgovFileMngUtil; import com.dbnt.kcscbackend.auth.entity.LoginVO; @@ -134,13 +135,14 @@ public class PopUpApiController { public ResultVO contentsApiPopUpManageUpdate( HttpServletRequest request, @AuthenticationPrincipal LoginVO loginVO, + UpdatePopupVO updatePopupVO, @PathVariable("popupId") Long popupId ) throws Exception { ResultVO resultVO = new ResultVO(); try { - resultVO = popUpApiService.contentsApiPopUpManageUpdate(resultVO, request, loginVO, popupId); + resultVO = popUpApiService.contentsApiPopUpManageUpdate(resultVO, request, loginVO, updatePopupVO, popupId); } catch (Exception e) { resultVO.setResultCode(ResponseCode.FAILED.getCode()); resultVO.setResultMessage(e.getMessage()); diff --git a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/contents/popUp/model/UpdatePopupVO.java b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/contents/popUp/model/UpdatePopupVO.java index c08d8ba..9408459 100644 --- a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/contents/popUp/model/UpdatePopupVO.java +++ b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/contents/popUp/model/UpdatePopupVO.java @@ -9,23 +9,17 @@ import lombok.ToString; import java.io.Serializable; -@ApiModel(value = "CreatePopupVO", description = - "관리자 단에서 '컨텐츠 관리' > '팝업 관리' 페이지에서 팝업을 추가하는 API에 사용된다." + "" +@ApiModel(value = "UpdatePopupVO", description = + "관리자 단에서 '컨텐츠 관리' > '팝업 관리' 페이지에서 팝업을 수정하는 API에 사용된다." + "" ) @RequiredArgsConstructor @Getter @Setter @ToString -public class CreatePopupVO implements Serializable { +public class UpdatePopupVO extends CreatePopupVO implements Serializable { - private static final long serialVersionUID = 719256850119704956L; + private static final long serialVersionUID = 5871943231162448850L; - @ApiModelProperty(value = "startDate") - private String startDate; - @ApiModelProperty(value = "endDate") - private String endDate; - @ApiModelProperty(value = "title") - private String title; - @ApiModelProperty(value = "contents") - private String contents; + @ApiModelProperty(value = "popupId") + private String popupId; } 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 1de5717..cac0e52 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 @@ -1,6 +1,7 @@ package com.dbnt.kcscbackend.admin.contents.popUp.service; 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 org.springframework.data.domain.Pageable; @@ -12,6 +13,7 @@ public interface PopUpApiService { public ResultVO contentsApiPopUpManageList(ResultVO resultVO, HttpServletRequest request, LoginVO user, Pageable pageable) throws Exception; 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, 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; } \ 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 ca2b32a..844dfd4 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 @@ -3,12 +3,10 @@ package com.dbnt.kcscbackend.admin.contents.popUp.service.impl; import com.dbnt.kcscbackend.admin.contents.popUp.model.CreatePopupVO; import com.dbnt.kcscbackend.admin.contents.popUp.model.FileVO; +import com.dbnt.kcscbackend.admin.contents.popUp.model.UpdatePopupVO; import com.dbnt.kcscbackend.admin.contents.popUp.repository.TnPopupMngRepositoryWithoutPopupContents; import com.dbnt.kcscbackend.admin.contents.popUp.service.PopUpApiService; import com.dbnt.kcscbackend.auth.entity.LoginVO; -import com.dbnt.kcscbackend.commonCode.entity.TcCodeItem; -import com.dbnt.kcscbackend.commonCode.entity.TnCmtEvent; -import com.dbnt.kcscbackend.commonCode.entity.TnCmtOrg; import com.dbnt.kcscbackend.commonCode.entity.TnPopupMng; import com.dbnt.kcscbackend.commonCode.repository.TnPopupMngRepository; import com.dbnt.kcscbackend.config.common.ResponseCode; @@ -16,10 +14,7 @@ import com.dbnt.kcscbackend.config.common.ResultVO; import lombok.RequiredArgsConstructor; import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; import org.egovframe.rte.ptl.mvc.tags.ui.pagination.PaginationInfo; -import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; -import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartHttpServletRequest; @@ -116,7 +111,6 @@ public class PopUpApiServiceImpl extends EgovAbstractServiceImpl implements PopU //_atchFileId = fileMngService.insertFileInfs(_result); //파일이 생성되고나면 생성된 첨부파일 ID를 리턴한다. } - //call kcsc.sp_add_tn_popup_mng ('팝업제목','2023-08-17 10:00:00','2023-08-23 10:00:00',NULL,'이러저런 내용 ','kcsc_admin',NULL,NULL,NULL,NULL); Map response = tnPopupMngRepository.spAddTnPopupMng( createPopupVO.getTitle(), createPopupVO.getStartDate(), @@ -157,7 +151,7 @@ public class PopUpApiServiceImpl extends EgovAbstractServiceImpl implements PopU ); - int isValid = tnPopupMngRepository.spIsValidTnCmtEventId( popupId.intValue() ); + int isValid = tnPopupMngRepository.spIsValidTnPopupMngId( popupId.intValue() ); if( isValid == 0 ) { throw new Exception("대상이 존재하지 않습니다."); @@ -181,10 +175,55 @@ public class PopUpApiServiceImpl extends EgovAbstractServiceImpl implements PopU } @Override - public ResultVO contentsApiPopUpManageUpdate(ResultVO resultVO, HttpServletRequest request, LoginVO user, Long popupId) throws Exception { - return null; + public ResultVO contentsApiPopUpManageUpdate(ResultVO resultVO, HttpServletRequest request, LoginVO user, UpdatePopupVO updatePopupVO, Long popupId) throws Exception { + System.out.println( + "\n--------------------------------------------------------------\n" + + request.getRequestURI() + " IN:" + + "\n--------------------------------------------------------------\n" + + "updatePopupVO:" + "\n" + + updatePopupVO.toString() + "\n" + + "popupId:" + "\n" + + popupId + "\n" + + "\n--------------------------------------------------------------\n" + ); + + // 유효성 검사 실시 + int isValid = tnPopupMngRepository.spIsValidTnPopupMngId( popupId.intValue() ); + + if( isValid == 0 ) { + throw new Exception("대상이 존재하지 않습니다."); + } + + if( Long.parseLong(updatePopupVO.getStartDate()) > Long.parseLong(updatePopupVO.getEndDate()) ) { + throw new Exception("종료일시는 시작일시보다 앞 설 수 없습니다."); + } + + Map response = tnPopupMngRepository.spUpdateTnPopupMng( + popupId.intValue(), + updatePopupVO.getTitle(), + updatePopupVO.getStartDate(), + updatePopupVO.getEndDate(), + null, + updatePopupVO.getContents(), + "kcsc_admin", + null, + null, + null + ); + + + Map dto = new HashMap(); + dto.put("errorMessage", response.get("_error_message") ); + dto.put("popupId", popupId); + + resultVO.setResult(dto); + resultVO.setResultCode(ResponseCode.SUCCESS.getCode()); + resultVO.setResultMessage(ResponseCode.SUCCESS.getMessage()); + + return resultVO; } + @Override public ResultVO contentsApiPopUpManageDelete(ResultVO resultVO, HttpServletRequest request, LoginVO user, Long popupId) throws Exception { return null; 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 3476b36..710c85f 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 @@ -45,8 +45,39 @@ public interface TnPopupMngRepository extends JpaRepository spUpdateTnPopupMng( + @Param("_popup_seq") Integer popupSeq, + @Param("_popup_title") String popupTitle, + @Param("_popup_start_date") String popupStartDate, + @Param("_popup_end_date") String popupEndDate, + @Param("_file_grp_id") String fileGrpId, + @Param("_popup_contents") String popupContents, + @Param("_modi_id") String modiId, + @Param("_result_count") Integer resultCount, + @Param("_result_code") String resultCode, + @Param("_error_message") String errorMessage + ); + @Procedure("sp_is_valid_tn_popup_mng_id") - int spIsValidTnCmtEventId( Integer popupSeq ); + int spIsValidTnPopupMngId( Integer popupSeq ); TnPopupMng findByPopupSeq(Long popupSeq);