feat: 캔버스 팝업 상태 생성/저장/삭제 api 추가
This commit is contained in:
parent
bb400f2688
commit
98c8da7859
@ -0,0 +1,80 @@
|
||||
package com.interplug.qcast.biz.canvaspopupstatus;
|
||||
|
||||
import com.interplug.qcast.biz.canvaspopupstatus.dto.CanvasPopupStatus;
|
||||
import com.interplug.qcast.config.Exception.ErrorCode;
|
||||
import com.interplug.qcast.config.Exception.QcastException;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
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.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/canvas-popup-status")
|
||||
@RequiredArgsConstructor
|
||||
@Tag(name = "CanvasPopupStatusController", description = "Canvas Popup Status 관련 API")
|
||||
public class CanvasPopupStatusController {
|
||||
|
||||
private final CanvasPopupStatusService canvasPopupStatusService;
|
||||
|
||||
/**
|
||||
* 캔버스 팝업 상태를 조회한다.
|
||||
*
|
||||
* @param objectNo 물건정보 번호
|
||||
* @param planNo plan 번호
|
||||
* @param popupType 캔버스 팝업 단계
|
||||
* @return 조회된 CanvasPopupStatus 객체
|
||||
* @throws QcastException 조회된 데이터가 없을 경우 예외 발생
|
||||
*/
|
||||
@Operation(description = "캔버스 팝업 상태를 조회한다.")
|
||||
@GetMapping
|
||||
public CanvasPopupStatus getCanvasPopupStatus(
|
||||
@RequestParam @Schema(description = "물건정보 번호") String objectNo,
|
||||
@RequestParam @Schema(description = "plan 번호") Integer planNo,
|
||||
@RequestParam @Schema(description = "캔버스 팝업 단계") String popupType)
|
||||
throws QcastException {
|
||||
if (objectNo == null
|
||||
|| objectNo.trim().isEmpty()
|
||||
|| planNo == null
|
||||
|| popupType == null
|
||||
|| popupType.trim().isEmpty()) {
|
||||
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE);
|
||||
}
|
||||
return canvasPopupStatusService.selectCanvasPopupStatus(objectNo, planNo, popupType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 캔버스 팝업 상태를 저장 또는 수정한다.
|
||||
*
|
||||
* @param canvasPopupStatus 저장 또는 수정할 CanvasPopupStatus 객체
|
||||
* @throws QcastException 저장 또는 수정 중 예외 발생 시
|
||||
*/
|
||||
@Operation(description = "캔버스 팝업 상태를 저장 또는 수정한다.")
|
||||
@PostMapping
|
||||
public void saveCanvasPopupStatus(@RequestBody CanvasPopupStatus canvasPopupStatus)
|
||||
throws QcastException {
|
||||
canvasPopupStatusService.saveCanvasPopupStatus(canvasPopupStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
* 캔버스 팝업 상태를 삭제한다. (미사용)
|
||||
*
|
||||
* @param canvasPopupStatus 삭제할 CanvasPopupStatus 객체
|
||||
* @throws QcastException 삭제 중 예외 발생 시
|
||||
*/
|
||||
@Operation(description = "캔버스 팝업 상태를 삭제한다. (미사용)")
|
||||
@DeleteMapping
|
||||
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||
public void deleteCanvasPopupStatus(@RequestBody CanvasPopupStatus canvasPopupStatus)
|
||||
throws QcastException {
|
||||
canvasPopupStatusService.deleteCanvasPopupStatus(canvasPopupStatus);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
package com.interplug.qcast.biz.canvaspopupstatus;
|
||||
|
||||
import com.interplug.qcast.biz.canvaspopupstatus.dto.CanvasPopupStatus;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface CanvasPopupStatusMapper {
|
||||
|
||||
/**
|
||||
* Canvas Popup Status 조회
|
||||
*
|
||||
* @param canvasPopupStatus 조회할 CanvasPopupStatus 객체
|
||||
* @return 조회된 CanvasPopupStatus 객체
|
||||
*/
|
||||
public CanvasPopupStatus selectCanvasPopupStatus(CanvasPopupStatus canvasPopupStatus);
|
||||
|
||||
/**
|
||||
* Canvas Popup Status 생성
|
||||
*
|
||||
* @param canvasPopupStatus 생성할 CanvasPopupStatus 객체
|
||||
*/
|
||||
public void insertCanvasPopupStatus(CanvasPopupStatus canvasPopupStatus);
|
||||
|
||||
/**
|
||||
* Canvas Popup Status 수정
|
||||
*
|
||||
* @param canvasPopupStatus 수정할 CanvasPopupStatus 객체
|
||||
*/
|
||||
public void updateCanvasPopupStatus(CanvasPopupStatus canvasPopupStatus);
|
||||
|
||||
/**
|
||||
* Canvas Popup Status 삭제
|
||||
*
|
||||
* @param canvasPopupStatus 삭제할 CanvasPopupStatus 객체
|
||||
*/
|
||||
public void deleteCanvasPopupStatus(CanvasPopupStatus canvasPopupStatus);
|
||||
}
|
||||
@ -0,0 +1,91 @@
|
||||
package com.interplug.qcast.biz.canvaspopupstatus;
|
||||
|
||||
import com.interplug.qcast.biz.canvaspopupstatus.dto.CanvasPopupStatus;
|
||||
import com.interplug.qcast.config.Exception.ErrorCode;
|
||||
import com.interplug.qcast.config.Exception.QcastException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class CanvasPopupStatusService {
|
||||
|
||||
private final CanvasPopupStatusMapper canvasPopupStatusMapper;
|
||||
|
||||
/**
|
||||
* Canvas Popup Status 조회
|
||||
*
|
||||
* @param objectNo 조회할 object 번호
|
||||
* @param planNo 조회할 plan 번호
|
||||
* @param popupType 조회할 popup 타입
|
||||
* @return 조회된 CanvasPopupStatus 객체
|
||||
* @throws QcastException 조회된 데이터가 없을 경우 예외 발생
|
||||
*/
|
||||
public CanvasPopupStatus selectCanvasPopupStatus(
|
||||
String objectNo, Integer planNo, String popupType) throws QcastException {
|
||||
CanvasPopupStatus request =
|
||||
CanvasPopupStatus.builder().objectNo(objectNo).planNo(planNo).popupType(popupType).build();
|
||||
CanvasPopupStatus cps = canvasPopupStatusMapper.selectCanvasPopupStatus(request);
|
||||
if (cps == null) throw new QcastException(ErrorCode.NOT_FOUND);
|
||||
return cps;
|
||||
}
|
||||
|
||||
/**
|
||||
* Canvas Popup Status 저장 - 이미 존재하는 데이터인 경우 수정, 없는 경우 생성
|
||||
*
|
||||
* @param cps 저장할 CanvasPopupStatus 객체
|
||||
* @throws QcastException 저장 중 예외 발생 시
|
||||
*/
|
||||
public void saveCanvasPopupStatus(CanvasPopupStatus cps) throws QcastException {
|
||||
CanvasPopupStatus chk = canvasPopupStatusMapper.selectCanvasPopupStatus(cps);
|
||||
if (chk == null) {
|
||||
createCanvasPopupStatus(cps);
|
||||
} else {
|
||||
updateCanvasPopupStatus(cps);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Canvas Popup Status 생성
|
||||
*
|
||||
* @param cps 생성할 CanvasPopupStatus 객체
|
||||
* @throws QcastException 생성 중 예외 발생 시
|
||||
*/
|
||||
public void createCanvasPopupStatus(CanvasPopupStatus cps) throws QcastException {
|
||||
try {
|
||||
canvasPopupStatusMapper.insertCanvasPopupStatus(cps);
|
||||
} catch (Exception e) {
|
||||
throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Canvas Popup Status 수정
|
||||
*
|
||||
* @param cps 수정할 CanvasPopupStatus 객체
|
||||
* @throws QcastException 수정 중 예외 발생 시
|
||||
*/
|
||||
public void updateCanvasPopupStatus(CanvasPopupStatus cps) throws QcastException {
|
||||
try {
|
||||
canvasPopupStatusMapper.updateCanvasPopupStatus(cps);
|
||||
} catch (Exception e) {
|
||||
throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Canvas Popup Status 삭제
|
||||
*
|
||||
* @param cps 삭제할 CanvasPopupStatus 객체
|
||||
* @throws QcastException 삭제 중 예외 발생 시
|
||||
*/
|
||||
public void deleteCanvasPopupStatus(CanvasPopupStatus cps) throws QcastException {
|
||||
// 존재 유무 확인
|
||||
selectCanvasPopupStatus(cps.getObjectNo(), cps.getPlanNo(), cps.getPopupType());
|
||||
try {
|
||||
canvasPopupStatusMapper.deleteCanvasPopupStatus(cps);
|
||||
} catch (Exception e) {
|
||||
throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
package com.interplug.qcast.biz.canvaspopupstatus.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@Schema(description = "캔버스 팝업 상태")
|
||||
public class CanvasPopupStatus {
|
||||
|
||||
// @Schema(description = "id")
|
||||
// private Long id;
|
||||
|
||||
@Schema(description = "물건정보 번호")
|
||||
private String objectNo;
|
||||
|
||||
@Schema(description = "plan 번호")
|
||||
private Integer planNo;
|
||||
|
||||
@Schema(description = "캔버스 팝업 단계")
|
||||
private String popupType;
|
||||
|
||||
@Schema(description = "캔버스 팝업 상태 데이터")
|
||||
private String popupStatus;
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.interplug.qcast.biz.canvaspopupstatus.CanvasPopupStatusMapper">
|
||||
|
||||
<select id="selectCanvasPopupStatus"
|
||||
parameterType="com.interplug.qcast.biz.canvaspopupstatus.dto.CanvasPopupStatus"
|
||||
resultType="com.interplug.qcast.biz.canvaspopupstatus.dto.CanvasPopupStatus">
|
||||
SELECT object_no,
|
||||
plan_no,
|
||||
popup_type,
|
||||
popup_status
|
||||
FROM T_CANVAS_POPUP_STATUS
|
||||
WHERE object_no = #{objectNo}
|
||||
AND plan_no = #{planNo}
|
||||
AND popup_type = #{popupType}
|
||||
</select>
|
||||
|
||||
<insert id="insertCanvasPopupStatus"
|
||||
parameterType="com.interplug.qcast.biz.canvaspopupstatus.dto.CanvasPopupStatus">
|
||||
INSERT INTO T_CANVAS_POPUP_STATUS
|
||||
(object_no,
|
||||
plan_no,
|
||||
popup_type,
|
||||
popup_status)
|
||||
VALUES (#{objectNo},
|
||||
#{planNo},
|
||||
#{popupType},
|
||||
#{popupStatus})
|
||||
</insert>
|
||||
|
||||
<update id="updateCanvasPopupStatus"
|
||||
parameterType="com.interplug.qcast.biz.canvaspopupstatus.dto.CanvasPopupStatus">
|
||||
UPDATE T_CANVAS_POPUP_STATUS
|
||||
SET popup_status = #{popupStatus}
|
||||
WHERE object_no = #{objectNo}
|
||||
AND plan_no = #{planNo}
|
||||
AND popup_type = #{popupType}
|
||||
</update>
|
||||
|
||||
<delete id="deleteCanvasPopupStatus"
|
||||
parameterType="com.interplug.qcast.biz.canvaspopupstatus.dto.CanvasPopupStatus">
|
||||
DELETE
|
||||
FROM T_CANVAS_POPUP_STATUS
|
||||
WHERE object_no = #{objectNo}
|
||||
AND plan_no = #{planNo}
|
||||
AND popup_type = #{popupType}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
Loading…
x
Reference in New Issue
Block a user