From 061bbd02cc8edff7beab0d0590ddc0760d020ea9 Mon Sep 17 00:00:00 2001 From: masoudarvishian Date: Fri, 10 May 2024 09:28:00 +0200 Subject: [PATCH] Added cancelJob endpoint rest api --- .../challenge/controller/JobController.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/zenjob/challenge/controller/JobController.java b/src/main/java/com/zenjob/challenge/controller/JobController.java index f586eee..ad60470 100644 --- a/src/main/java/com/zenjob/challenge/controller/JobController.java +++ b/src/main/java/com/zenjob/challenge/controller/JobController.java @@ -10,11 +10,9 @@ import lombok.NoArgsConstructor; import lombok.RequiredArgsConstructor; import org.springframework.format.annotation.DateTimeFormat; +import org.springframework.http.HttpStatus; import org.springframework.stereotype.Controller; -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.ResponseBody; +import org.springframework.web.bind.annotation.*; import javax.validation.Valid; import javax.validation.constraints.NotNull; @@ -38,6 +36,18 @@ public ResponseDto requestJob(@RequestBody @Valid RequestJob .build(); } + @DeleteMapping(path = "/{id}/cancel") + @ResponseStatus(code = HttpStatus.NO_CONTENT) + public void cancelJob(@PathVariable("id") UUID jobId, @RequestBody @Valid CancelJobRequestDto dto) { + jobService.cancelJob(dto.companyId, jobId); + } + + @NoArgsConstructor + @Data + private static class CancelJobRequestDto { + UUID companyId; + } + @NoArgsConstructor @AllArgsConstructor @Data