-
Notifications
You must be signed in to change notification settings - Fork 3
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
Showing
4 changed files
with
98 additions
and
1 deletion.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
src/main/java/ailtonbsj/sauteweb/sauteapi/model/Instituicao.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,67 @@ | ||
package ailtonbsj.sauteweb.sauteapi.model; | ||
|
||
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
|
||
import javax.persistence.CascadeType; | ||
import javax.persistence.Column; | ||
import javax.persistence.Embedded; | ||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import javax.persistence.ManyToOne; | ||
import javax.persistence.PrePersist; | ||
|
||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@Entity | ||
@Setter | ||
@Getter | ||
public class Instituicao { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.AUTO) | ||
Long id; | ||
|
||
String instituicao; | ||
|
||
@ManyToOne(cascade = CascadeType.DETACH) | ||
NivelEscolar nivelEscolar; | ||
|
||
@Embedded | ||
Endereco endereco; | ||
|
||
String email; | ||
|
||
String dependencia; | ||
|
||
String entidade; | ||
|
||
String credenciamento; | ||
|
||
@JsonFormat(pattern = "yyyy-MM-dd") | ||
LocalDate validadeCredenciamento; | ||
|
||
String recredenciamento; | ||
|
||
@JsonFormat(pattern = "yyyy-MM-dd") | ||
LocalDate validadeRecredenciamento; | ||
|
||
@Column(nullable = false) | ||
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm") | ||
private LocalDateTime createdAt; | ||
|
||
@Column(nullable = false) | ||
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm") | ||
private LocalDateTime updatedAt; | ||
|
||
@PrePersist | ||
public void beforeSave() { | ||
LocalDateTime now = LocalDateTime.now(); | ||
setCreatedAt(now); | ||
setUpdatedAt(now); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/ailtonbsj/sauteweb/sauteapi/repository/InstituicaoRepository.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 ailtonbsj.sauteweb.sauteapi.repository; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import ailtonbsj.sauteweb.sauteapi.model.Instituicao; | ||
|
||
public interface InstituicaoRepository extends JpaRepository<Instituicao, Long> { | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/ailtonbsj/sauteweb/sauteapi/rest/InstituicaoController.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,21 @@ | ||
package ailtonbsj.sauteweb.sauteapi.rest; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import ailtonbsj.sauteweb.sauteapi.model.Instituicao; | ||
import ailtonbsj.sauteweb.sauteapi.repository.InstituicaoRepository; | ||
|
||
@RestController | ||
@RequestMapping("/instituicao") | ||
public class InstituicaoController { | ||
|
||
@Autowired | ||
private InstituicaoRepository rep; | ||
|
||
public Instituicao save(@RequestBody Instituicao instituicao) { | ||
return rep.save(instituicao); | ||
} | ||
} |
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