-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9935e86
commit b47654a
Showing
27 changed files
with
247 additions
and
202 deletions.
There are no files selected for viewing
8 changes: 4 additions & 4 deletions
8
...zenjob/challenge/service/IJobService.java → ...ge/application/interfaces/JobService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 0 additions & 69 deletions
69
src/main/java/com/zenjob/challenge/controller/JobController.java
This file was deleted.
Oops, something went wrong.
96 changes: 0 additions & 96 deletions
96
src/main/java/com/zenjob/challenge/controller/ShiftController.java
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...java/com/zenjob/challenge/entity/Job.java → ...m/zenjob/challenge/domain/entity/Job.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...va/com/zenjob/challenge/entity/Shift.java → ...zenjob/challenge/domain/entity/Shift.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...stomexception/InvalidActionException.java → ...in/exceptions/InvalidActionException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...tomexception/InvalidEndDateException.java → ...n/exceptions/InvalidEndDateException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...mexception/InvalidStartDateException.java → ...exceptions/InvalidStartDateException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/java/com/zenjob/challenge/repository/JobRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/java/com/zenjob/challenge/repository/ShiftRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../zenjob/challenge/config/ClockConfig.java → ...ob/challenge/rest/config/ClockConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...b/challenge/config/TimedAspectConfig.java → ...llenge/rest/config/TimedAspectConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/main/java/com/zenjob/challenge/rest/controller/JobController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.zenjob.challenge.rest.controller; | ||
|
||
import com.zenjob.challenge.rest.dto.job.CancelJobRequestDto; | ||
import com.zenjob.challenge.rest.dto.job.RequestJobRequestDto; | ||
import com.zenjob.challenge.rest.dto.job.RequestJobResponseDto; | ||
import com.zenjob.challenge.rest.dto.ResponseDto; | ||
import com.zenjob.challenge.domain.entity.Job; | ||
import com.zenjob.challenge.application.interfaces.JobService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import javax.validation.Valid; | ||
import java.util.UUID; | ||
|
||
@RestController | ||
@RequestMapping(path = "/job") | ||
@RequiredArgsConstructor | ||
public class JobController { | ||
private final JobService jobService; | ||
|
||
@PostMapping | ||
@ResponseBody | ||
public ResponseDto<RequestJobResponseDto> requestJob(@RequestBody @Valid RequestJobRequestDto dto) { | ||
Job job = jobService.createJob(dto.getCompanyId(), dto.getStart(), dto.getEnd()); | ||
return ResponseDto.<RequestJobResponseDto>builder() | ||
.data(RequestJobResponseDto.builder() | ||
.jobId(job.getId()) | ||
.build()) | ||
.build(); | ||
} | ||
|
||
@DeleteMapping(path = "/{id}/cancel") | ||
@ResponseStatus(code = HttpStatus.NO_CONTENT) | ||
public void cancelJob(@PathVariable("id") UUID jobId, @RequestBody @Valid CancelJobRequestDto dto) { | ||
jobService.cancelJob(dto.getCompanyId(), jobId); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
src/main/java/com/zenjob/challenge/rest/controller/ShiftController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.zenjob.challenge.rest.controller; | ||
|
||
import com.zenjob.challenge.rest.dto.ResponseDto; | ||
import com.zenjob.challenge.application.interfaces.JobService; | ||
import com.zenjob.challenge.rest.dto.shift.*; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import javax.validation.Valid; | ||
import java.util.List; | ||
import java.util.UUID; | ||
import java.util.stream.Collectors; | ||
|
||
@RestController | ||
@RequestMapping(path = "/shift") | ||
@RequiredArgsConstructor | ||
public class ShiftController { | ||
private final JobService jobService; | ||
|
||
@GetMapping(path = "/{jobId}") | ||
@ResponseBody | ||
public ResponseDto<GetShiftsResponseDto> getShifts(@PathVariable("jobId") UUID uuid) { | ||
List<ShiftResponseDto> shiftResponses = jobService.getShifts(uuid).stream() | ||
.map(shift -> ShiftResponseDto.builder() | ||
.id(shift.getId()) | ||
.talentId(shift.getTalentId()) | ||
.jobId(shift.getJob().getId()) | ||
.start(shift.getCreatedAt()) | ||
.end(shift.getEndTime()) | ||
.build()) | ||
.collect(Collectors.toList()); | ||
return ResponseDto.<GetShiftsResponseDto>builder() | ||
.data(GetShiftsResponseDto.builder() | ||
.shifts(shiftResponses) | ||
.build()) | ||
.build(); | ||
} | ||
|
||
@PatchMapping(path = "/{id}/book") | ||
@ResponseStatus(code = HttpStatus.NO_CONTENT) | ||
public void bookTalent(@PathVariable("id") UUID shiftId, @RequestBody @Valid BookTalentRequestDto dto) { | ||
jobService.bookTalent(dto.getTalentId(), shiftId); | ||
} | ||
|
||
@PatchMapping(path = "/cancel-talent") | ||
@ResponseStatus(code = HttpStatus.NO_CONTENT) | ||
public void cancelShiftForTalent(@RequestBody @Valid CancelShiftForTalentRequestDto dto) { | ||
jobService.cancelShiftForTalent(dto.getCompanyId(), dto.getTalentId()); | ||
} | ||
|
||
@DeleteMapping(path = "/{id}/cancel") | ||
@ResponseStatus(code = HttpStatus.NO_CONTENT) | ||
public void cancelShift(@PathVariable("id") UUID shiftId, @RequestBody @Valid CancelShiftRequestDto dto) { | ||
jobService.cancelShift(dto.getCompanyId(), shiftId); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...com/zenjob/challenge/dto/ResponseDto.java → ...enjob/challenge/rest/dto/ResponseDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/main/java/com/zenjob/challenge/rest/dto/job/CancelJobRequestDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.zenjob.challenge.rest.dto.job; | ||
|
||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.UUID; | ||
|
||
@NoArgsConstructor | ||
@Data | ||
public class CancelJobRequestDto { | ||
private UUID companyId; | ||
} |
Oops, something went wrong.