Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package br.com.entra21.teamroxo.TMSProject.controllers;

import java.time.LocalDate;
import java.time.LocalTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -62,7 +64,9 @@ public List<Login> listAll() {

if(!response.isEmpty()) {
CountVisitors count = new CountVisitors();
count.setCount(0);
count.setUser(credentials.getUser());
count.setTime(LocalTime.now());
count.setDate(LocalDate.now());
countVisitorsRepository.save(count);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
@RequestMapping("/user")
public class PessoaController {

private final String PATH = "http://localhost:8080/users";
private final String PATH = "http://localhost:8080/user";

@Autowired
private PessoaRepository pessoaRepository;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package br.com.entra21.teamroxo.TMSProject.controllers;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
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;

import br.com.entra21.teamroxo.TMSProject.interfaces.RecentQuoteRepository;
import br.com.entra21.teamroxo.TMSProject.interfaces.RegisterQuoteRepository;
import br.com.entra21.teamroxo.TMSProject.template.RecentQuote;
import br.com.entra21.teamroxo.TMSProject.template.RegisterQuote;

@RestController
@CrossOrigin(origins = "*")
@RequestMapping("/quote")
public class QuoteController {

@Autowired
private RegisterQuoteRepository registerQuoteRepository;

@Autowired
private RecentQuoteRepository recentQuoteRepository;

@PostMapping("/recent")
public RecentQuote recentPackage(@RequestBody RecentQuote quote) {

return recentQuoteRepository.save(quote);

}

@PostMapping("/register")
public RegisterQuote registerPackage(@RequestBody RegisterQuote quote) {

return registerQuoteRepository.save(quote);

}

@GetMapping("/go")
public int goingPackages() {

List<RegisterQuote> response = new ArrayList<RegisterQuote>(registerQuoteRepository.findAll().stream()
.filter(quote -> (quote.getPost().plusDays(quote.getAwait()).isAfter(LocalDate.now()) ||
quote.getPost().plusDays(quote.getAwait()).isEqual(LocalDate.now())))
.toList());

return response.size();

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public ArrayList<String> getGoogleAPI(@PathVariable ("cepOrigem") int param1, @P

BufferedReader response = new BufferedReader(new InputStreamReader(get.getInputStream()));

ArrayList<String> jsonEmString = converteJsonEmString(response);
String jsonEmString = converteJsonEmString(response);

return jsonEmString;

Expand All @@ -47,7 +47,7 @@ public ArrayList<String> getGoogleAPI(@PathVariable ("cepOrigem") int param1, @P

}

public static ArrayList<String> converteJsonEmString(BufferedReader buffereReader) throws IOException {
public static String converteJsonEmString(BufferedReader buffereReader) throws IOException {

String resposta;
ArrayList<String> json = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package br.com.entra21.teamroxo.TMSProject.interfaces;

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

import br.com.entra21.teamroxo.TMSProject.template.RecentQuote;

public interface RecentQuoteRepository extends JpaRepository<RecentQuote, Integer> {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package br.com.entra21.teamroxo.TMSProject.interfaces;

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

import br.com.entra21.teamroxo.TMSProject.template.RegisterQuote;

public interface RegisterQuoteRepository extends JpaRepository<RegisterQuote, Integer> {

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package br.com.entra21.teamroxo.TMSProject.template;

import java.time.LocalDate;
import java.time.LocalTime;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
Expand All @@ -13,23 +16,52 @@ public class CountVisitors {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private long count;
private String user;
private LocalDate date;
private LocalTime time;

public CountVisitors() {
super();
}

public CountVisitors(long count) {
public CountVisitors(Integer id, String user, LocalDate date, LocalTime time) {
super();
this.count = count;
this.id = id;
this.user = user;
this.date = date;
this.time = time;
}

public Integer getId() {
return id;
}

public void setId(Integer id) {
this.id = id;
}

public String getUser() {
return user;
}

public void setUser(String user) {
this.user = user;
}

public LocalDate getDate() {
return date;
}

public void setDate(LocalDate date) {
this.date = date;
}

public long getCount() {
return count;
public LocalTime getTime() {
return time;
}

public void setCount(long count) {
this.count = count;
public void setTime(LocalTime time) {
this.time = time;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package br.com.entra21.teamroxo.TMSProject.template;

import java.util.List;

public class GoogleAPI {

private List<String> geocoded_waypoints;
private List<String> routes;
private String status;

public GoogleAPI() {
super();
}

public GoogleAPI(List<String> geocoded_waypoints, List<String> routes, String status) {
super();
this.geocoded_waypoints = geocoded_waypoints;
this.routes = routes;
this.status = status;
}

public List<String> getGeocoded_waypoints() {
return geocoded_waypoints;
}

public void setGeocoded_waypoints(List<String> geocoded_waypoints) {
this.geocoded_waypoints = geocoded_waypoints;
}

public List<String> getRoutes() {
return routes;
}

public void setRoutes(List<String> routes) {
this.routes = routes;
}

public String getStatus() {
return status;
}

public void setStatus(String status) {
this.status = status;
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package br.com.entra21.teamroxo.TMSProject.template;

import java.time.LocalDate;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
Expand All @@ -15,6 +17,7 @@ public class RegisterQuote {
private Integer id;
private float price;
private byte await;
private LocalDate post;
private String origin;
private String destiny;
private byte carrier_id;
Expand All @@ -26,7 +29,7 @@ public RegisterQuote() {
}

public RegisterQuote(Integer id, float price, byte await, String origin, String destiny, byte carrier_id,
float cub_height, int pessoa_id) {
float cub_height, int pessoa_id, boolean isGoing) {
super();
this.id = id;
this.price = price;
Expand Down Expand Up @@ -102,4 +105,12 @@ public void setPessoa_id(int pessoa_id) {
this.pessoa_id = pessoa_id;
}

public LocalDate getPost() {
return post;
}

public void setPost(LocalDate post) {
this.post = post;
}

}