Skip to content

Commit

Permalink
Fix date format
Browse files Browse the repository at this point in the history
  • Loading branch information
ailtonbsj committed Aug 26, 2022
1 parent 21d0931 commit 7182083
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ public class NivelEscolar {
private String nivelEscolar;

@Column
@JsonFormat(pattern = "dd/MM/yyyy HH:mm")
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm")
private LocalDateTime createdAt;

@Column
@JsonFormat(pattern = "dd/MM/yyyy HH:mm")
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm")
private LocalDateTime updatedAt;

@PrePersist
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package ailtonbsj.sauteweb.sauteapi.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;

import ailtonbsj.sauteweb.sauteapi.model.NivelEscolar;

public interface NivelEscolarRepository extends JpaRepository<NivelEscolar, Long> {
List<NivelEscolar> findByNivelEscolarContainingIgnoreCase(String nivelEscolar);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@

import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
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.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.server.ResponseStatusException;

Expand All @@ -20,14 +23,18 @@

@RestController
@RequestMapping("/api/nivelescolar")
@CrossOrigin("http://localhost:4200")
public class NivelEscolarController {

@Autowired
private NivelEscolarRepository repository;

@GetMapping
public List<NivelEscolar> index() {
return repository.findAll();
public List<NivelEscolar> index(@RequestParam Optional<String> q) {
if (q.isEmpty())
return repository.findAll();
else
return repository.findByNivelEscolarContainingIgnoreCase(q.get());
}

@PostMapping
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ spring:
datasource:
url: jdbc:mysql://localhost:3306/saute
username: root
password: YOUR_PASS
password: q1w2e3r4t5y6
jpa:
show-sql: true
hibernate:
Expand Down

0 comments on commit 7182083

Please sign in to comment.