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
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package br.com.entra21.teamroxo.TMSProject.controllers;

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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import br.com.entra21.teamroxo.TMSProject.interfaces.CarriersRepository;
import br.com.entra21.teamroxo.TMSProject.template.Carriers;

@RestController
@CrossOrigin(origins = "*")
@RequestMapping("/carriers")
public class CarriersControllers {

@Autowired
private CarriersRepository carriersRepository;

@GetMapping()
public List<Carriers> listCarriers(){

return carriersRepository.findAll();

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ public class LoginController {

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

@Autowired
private PessoaRepository pessoaRepository;

@Autowired
private LoginRepository loginRepository;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,12 @@ public class PessoaController {

@GetMapping("/{id}")
public Optional<Pessoa> list(@PathVariable int id){

return pessoaRepository.findById(id);

}

@GetMapping("/count")
public long numberClients() {
return pessoaRepository.count();
}

@PostMapping()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package br.com.entra21.teamroxo.TMSProject.controllers;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

import javax.net.ssl.HttpsURLConnection;

import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@CrossOrigin(origins = "*")
@RequestMapping("/ship")
public class ShipController {

final String GOOGLE = "https://maps.googleapis.com/maps/api/directions/json?origin=";

@GetMapping("/{cepOrigem}/{cepDestino}")
public ArrayList<String> getGoogleAPI(@PathVariable ("cepOrigem") int param1, @PathVariable ("cepDestino") int param2 ){

try {

String APIUrl = GOOGLE+param1+"&destination="+param2+"&key=AIzaSyCKNjLUI0d01M0SfoDjIov4vZlR3DprotM";

URL url = new URL(APIUrl);
HttpsURLConnection get = (HttpsURLConnection) url.openConnection();

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

ArrayList<String> jsonEmString = converteJsonEmString(response);

return jsonEmString;

}catch (Exception e) {

return null;

}

}

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

String resposta;
ArrayList<String> json = new ArrayList<>();

while ((resposta = buffereReader.readLine()) != null) {

json.add(resposta);

}

return json;
}

}
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.Carriers;

public interface CarriersRepository extends JpaRepository<Carriers, Integer> {

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

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name = "carriers")
public class Carriers {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String razao;
private String email;
private String cnpj;
private float taxa;

public Carriers() {
super();
}

public Carriers(Integer id, String razao, String email, String cnpj, float taxa) {
super();
this.id = id;
this.razao = razao;
this.email = email;
this.cnpj = cnpj;
this.taxa = taxa;
}

public Integer getId() {
return id;
}

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

public String getRazao() {
return razao;
}

public void setRazao(String razao) {
this.razao = razao;
}

public String getEmail() {
return email;
}

public void setEmail(String email) {
this.email = email;
}

public String getCnpj() {
return cnpj;
}

public void setCnpj(String cnpj) {
this.cnpj = cnpj;
}

public float getTaxa() {
return taxa;
}

public void setTaxa(float taxa) {
this.taxa = taxa;
}

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

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name = "recent")
public class RecentQuote {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private float price;
private byte await;
private String origin;
private String destiny;
private byte carrier_id;
private float cub_height;
private int pessoa_id;

public RecentQuote() {
super();
}

public RecentQuote(Integer id, float price, byte await, String origin, String destiny, byte carrier_id,
float cub_height, int pessoa_id) {
super();
this.id = id;
this.price = price;
this.await = await;
this.origin = origin;
this.destiny = destiny;
this.carrier_id = carrier_id;
this.cub_height = cub_height;
this.pessoa_id = pessoa_id;
}

public Integer getId() {
return id;
}

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

public float getPrice() {
return price;
}

public void setPrice(float price) {
this.price = price;
}

public byte getAwait() {
return await;
}

public void setAwait(byte await) {
this.await = await;
}

public String getOrigin() {
return origin;
}

public void setOrigin(String origin) {
this.origin = origin;
}

public String getDestiny() {
return destiny;
}

public void setDestiny(String destiny) {
this.destiny = destiny;
}

public byte getCarrier_id() {
return carrier_id;
}

public void setCarrier_id(byte carrier_id) {
this.carrier_id = carrier_id;
}

public float getCub_height() {
return cub_height;
}

public void setCub_height(float cub_height) {
this.cub_height = cub_height;
}

public int getPessoa_id() {
return pessoa_id;
}

public void setPessoa_id(int pessoa_id) {
this.pessoa_id = pessoa_id;
}

}
Loading