Skip to content

Commit

Permalink
Feat : 스크립트 삭제 기능 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
MatchaKim committed Mar 23, 2024
1 parent d0c9dde commit e7db76b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,12 @@ public ResponseEntity<CommonResponse> patchDetailScript(@RequestBody ScriptReque
return scriptService.patchScript(scriptRequest, uid,scriptId);
}

@DeleteMapping("/script/detail/{scriptId}")
public ResponseEntity<CommonResponse> deleteDetailScript(@RequestHeader(value = "UID", required = false) String uid,
@PathVariable Long scriptId){

if(CommonUtils.isAnyParameterNullOrBlank(uid)) return CommonResponse.error(ErrorEnum.BALPYO_UID_KEY_MISSING);
return scriptService.deleteScript(uid,scriptId);
}

}
12 changes: 12 additions & 0 deletions src/main/java/site/balpyo/script/service/ScriptService.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,16 @@ public ResponseEntity<CommonResponse> patchScript(ScriptRequest scriptRequest, S
}


public ResponseEntity<CommonResponse> deleteScript(String uid, Long scriptId) {
Optional<ScriptEntity> optionalScriptEntity = scriptRepository.findScriptByGuestUidAndScriptId(uid, scriptId);

if(optionalScriptEntity.isEmpty())return CommonResponse.error(ErrorEnum.SCRIPT_DETAIL_NOT_FOUND);

ScriptEntity scriptEntity = optionalScriptEntity.get();

scriptRepository.delete(scriptEntity);

return CommonResponse.success("");

}
}

0 comments on commit e7db76b

Please sign in to comment.