feat: 관리자 - 컨텐츠관리 - 팝업관리에서 특정 팝업 눌러서 삭제 시, 실제 삭제 되도록 API 수정

thkim
thkim 2024-01-25 14:04:47 +09:00
parent 2f7456ae62
commit b3eecb0f50
5 changed files with 111 additions and 10 deletions

View File

@ -13,6 +13,7 @@ import com.dbnt.kcscbackend.auth.entity.LoginVO;
import com.dbnt.kcscbackend.config.common.ResponseCode; import com.dbnt.kcscbackend.config.common.ResponseCode;
import com.dbnt.kcscbackend.config.common.ResultVO; import com.dbnt.kcscbackend.config.common.ResultVO;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.responses.ApiResponses;
@ -161,6 +162,7 @@ public class PopUpApiController {
} }
@Operation( @Operation(
summary = "팝업 비활성화 API", summary = "팝업 비활성화 API",
description = "관리자 단에서 '컨텐츠 관리' > '팝업 관리' 페이지에서 팝업을 비활성화 API. 삭제가 아닌 비활성화 임. 삭제는 없음.", description = "관리자 단에서 '컨텐츠 관리' > '팝업 관리' 페이지에서 팝업을 비활성화 API. 삭제가 아닌 비활성화 임. 삭제는 없음.",
@ -199,6 +201,47 @@ public class PopUpApiController {
return resultVO; 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( @Operation(
summary = "팝업 내용 불러오기 API", summary = "팝업 내용 불러오기 API",
description = "관리자 단에서 '컨텐츠 관리' > '팝업 관리' 페이지에서 저장된 팝업을 불러오는 API", description = "관리자 단에서 '컨텐츠 관리' > '팝업 관리' 페이지에서 저장된 팝업을 불러오는 API",

View File

@ -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.admin.contents.popUp.model.UpdatePopupVO;
import com.dbnt.kcscbackend.auth.entity.LoginVO; import com.dbnt.kcscbackend.auth.entity.LoginVO;
import com.dbnt.kcscbackend.config.common.ResultVO; import com.dbnt.kcscbackend.config.common.ResultVO;
import io.swagger.annotations.ApiParam;
import org.springframework.data.domain.Pageable; 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 org.springframework.web.multipart.MultipartHttpServletRequest;
import javax.servlet.http.HttpServletRequest; 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 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 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 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 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;
} }

View File

@ -236,16 +236,26 @@ public class PopUpApiServiceImpl extends EgovAbstractServiceImpl implements PopU
); );
Map<String, Object> response = tnPopupMngRepository.spDeleteTnPopupMng(
popupId.intValue(),
"admin",
null,
null,
null
);
Map<String, Object> dto = new HashMap<String, Object>(); Map<String, Object> dto = new HashMap<String, Object>();
dto.put("errorMessage", response.get("_error_message") );
if( false ) {
// 삭제 procedure가 삭제가 아닌 비활성화만 시키므로 해당 프로시저 사용 안 함.
Map<String, Object> response = tnPopupMngRepository.spDeleteTnPopupMng(
popupId.intValue(),
"admin",
null,
null,
null
);
dto.put("errorMessage", response.get("_error_message") );
} else {
tnPopupMngRepository.deleteById(popupId);
}
dto.put("popupId", popupId ); dto.put("popupId", popupId );
resultVO.setResult(dto); resultVO.setResult(dto);
@ -255,5 +265,47 @@ public class PopUpApiServiceImpl extends EgovAbstractServiceImpl implements PopU
return resultVO; 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<String, Object> dto = new HashMap<String, Object>();
dto.put("popupId", popupId);
resultVO.setResult(dto);
resultVO.setResultCode(ResponseCode.SUCCESS.getCode());
resultVO.setResultMessage(ResponseCode.SUCCESS.getMessage());
return resultVO;
}
} }

View File

@ -62,6 +62,7 @@ public class TnPopupMng {
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public static class TnPopupMngId implements Serializable { public static class TnPopupMngId implements Serializable {
private static final long serialVersionUID = -6558812991140219351L;
private String popupSeq; private String popupSeq;
} }

View File

@ -11,7 +11,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
public interface TnPopupMngRepository extends JpaRepository<TnPopupMng, TnPopupMng.TnPopupMngId> { public interface TnPopupMngRepository extends JpaRepository<TnPopupMng, Long> {
@Query(value = "CALL sp_add_tn_popup_mng (" + @Query(value = "CALL sp_add_tn_popup_mng (" +
":_popup_title, " + ":_popup_title, " +