Skip to content

Commit

Permalink
Added cancel shift endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
masoudarvishian committed May 10, 2024
1 parent 6b93c79 commit efbc235
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public ResponseDto<RequestJobResponse> requestJob(@RequestBody @Valid RequestJob

@DeleteMapping(path = "/{id}/cancel")
@ResponseStatus(code = HttpStatus.NO_CONTENT)
public void cancelJob(@PathVariable("id") UUID jobId, @RequestBody @Valid CancelJobRequestDto dto) {
public void cancelJob(@PathVariable("id") UUID jobId, @RequestBody @Valid JobController.CancelJobRequestDto dto) {
jobService.cancelJob(dto.companyId, jobId);
}

Expand Down
20 changes: 13 additions & 7 deletions src/main/java/com/zenjob/challenge/controller/ShiftController.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
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.ResponseStatus;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.time.Instant;
Expand Down Expand Up @@ -54,6 +48,18 @@ public void bookTalent(@PathVariable("id") UUID shiftId, @RequestBody @Valid Shi
jobService.bookTalent(shiftId, dto.talent);
}

@DeleteMapping(path = "/{id}/cancel")
@ResponseStatus(code = HttpStatus.NO_CONTENT)
public void cancelShift(@PathVariable("id") UUID shiftId, @RequestBody @Valid ShiftController.CancelShiftRequestDto dto) {
jobService.cancelShift(dto.companyId, shiftId);
}

@NoArgsConstructor
@Data
private static class CancelShiftRequestDto {
UUID companyId;
}

@NoArgsConstructor
@Data
private static class BookTalentRequestDto {
Expand Down

0 comments on commit efbc235

Please sign in to comment.