-
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.
✨ feat: 'Criação do Controller da entidade Job junto de Endpoint para…
… a inserção de um novo Job'
- Loading branch information
1 parent
5867446
commit dc054e3
Showing
4 changed files
with
59 additions
and
2 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
src/main/java/dev/v3ktor/vacancymanagementa/modules/company/controllers/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,27 @@ | ||
package dev.v3ktor.vacancymanagementa.modules.company.controllers; | ||
|
||
import dev.v3ktor.vacancymanagementa.modules.company.entitys.JobEntity; | ||
import dev.v3ktor.vacancymanagementa.modules.company.useCase.CreateJobUseCase; | ||
import jakarta.validation.Valid; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
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.RestController; | ||
|
||
@RestController @RequestMapping("/job") | ||
public class JobController { | ||
|
||
// Atributos | ||
@Autowired private CreateJobUseCase createJobUseCase; | ||
|
||
// Endpoints | ||
@PostMapping | ||
public ResponseEntity< Object > create( @Valid @RequestBody JobEntity job) | ||
{ | ||
return ResponseEntity.status(HttpStatus.CREATED ).body( createJobUseCase.execute(job) ); | ||
} | ||
|
||
} |
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
9 changes: 9 additions & 0 deletions
9
src/main/java/dev/v3ktor/vacancymanagementa/modules/company/repositorys/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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package dev.v3ktor.vacancymanagementa.modules.company.repositorys; | ||
|
||
import dev.v3ktor.vacancymanagementa.modules.company.entitys.JobEntity; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.UUID; | ||
|
||
public interface JobRepository extends JpaRepository<JobEntity, UUID> { | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/dev/v3ktor/vacancymanagementa/modules/company/useCase/CreateJobUseCase.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,20 @@ | ||
package dev.v3ktor.vacancymanagementa.modules.company.useCase; | ||
|
||
import dev.v3ktor.vacancymanagementa.modules.company.entitys.JobEntity; | ||
import dev.v3ktor.vacancymanagementa.modules.company.repositorys.JobRepository; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class CreateJobUseCase { | ||
|
||
// Atributos | ||
@Autowired private JobRepository jobRepository; | ||
|
||
// Métodos | ||
public JobEntity execute(JobEntity job) | ||
{ | ||
return jobRepository.save( job ); | ||
} | ||
|
||
} |