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
Expand Up @@ -3,15 +3,18 @@
import java.util.List;

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

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

@RestController
@CrossOrigin(origins = "*")
Expand All @@ -29,10 +32,11 @@ public List<Carriers> listCarriers(){
}

@PostMapping()
public Carriers postCarrier(@RequestBody Carriers carrier) {
@ResponseStatus(code = HttpStatus.CREATED)
public Carriers register(@RequestBody Carriers dados) {

return carriersRepository.save(carrier);
return carriersRepository.save(dados);

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

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;


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

public interface CarriersRepository extends JpaRepository<Carriers, Integer> {

// @Query("FROM carriers WHERE idade >= :idadeParam")
// List<Carriers> maiorIdade (@Param("idadeParam")Integer idade);

}
12 changes: 12 additions & 0 deletions frontend/main/src/app/carrier.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,16 @@ export class CarrierService {
return this.http.get(this.apiURL)

}

adicionar(object:any){
this.http.post(this.apiURL,object)
.subscribe((response)=>{


console.log(response);

})


}
}
37 changes: 23 additions & 14 deletions frontend/main/src/app/carriers/carriers.component.html
Original file line number Diff line number Diff line change
@@ -1,43 +1,52 @@
<table class="table table-bordered">
<thead>
<th>Razão social</th>
<th>Taxa</th>
<th>E-mail</th>
<th>CNPJ</th>
<th>Taxa - Tabela de frete</th>
<th>Cnpj</th>

</thead>
<tbody>
<tr>
<td><input type="text" [(ngModel)]="name"></td>

<td><input type="text" [(ngModel)]="razao"></td>
<td><input type="text" [(ngModel)]="taxa"></td>
<td><input type="text" [(ngModel)]="email"></td>
<td><input type="text" [(ngModel)]="cnpj"></td>
<td><input type="text" [(ngModel)]="taxValorFrete"></td>

</tr>
</tbody>
</table>

<button class="btn btn-success" (click)="adicionar()">Add</button>




<button class="btn btn-success" (click)="adicionar(this.razao, this.taxa, this.email, this.cnpj)">Add</button>
<br>
<hr>

<table class="table table-bordered">
<thead>

<th>ID</th>
<th>Razão social</th>
<th>Taxa</th>
<th>E-mail</th>
<th>CNPJ</th>
<th>Taxa - Tabela de frete</th>
<th>Ações</th>
<th>Cnpj</th>


</thead>
<tbody>
<tr *ngFor="let carrier of carriers;let i = index;">

<td>{{i}}</td>
<td>{{carrier.name}}</td>
<td>{{carrier.razao}}</td>
<td>{{carrier.taxa}}</td>
<td>{{carrier.email}}</td>
<td>{{carrier.cnpj}}</td>
<td>{{carrier.taxValorFrete}}</td>
<td>
<button class="btn btn-danger mr-2" (click)="deletar(i)">Deletar</button>
<button class="btn btn-primary mr-2" (click)="alterar(i)">Alterar</button>
</td>


</tr>
</tbody>
</table>
84 changes: 53 additions & 31 deletions frontend/main/src/app/carriers/carriers.component.ts
Original file line number Diff line number Diff line change
@@ -1,52 +1,74 @@
import { HttpClient } from '@angular/common/http';
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { CarrierService } from '../carrier.service';
import { QuoteService } from '../quote.service';

@Component({
selector: 'app-carriers',
templateUrl: './carriers.component.html',
styleUrls: ['./carriers.component.css']
})
export class CarriersComponent implements OnInit {
carriers!:Array<any>
name!:string
email!:string
cnpj!:string
taxValorFrete!:number

constructor(
private router:Router
) { }
carriers!: Array<any>
cnpj!: string
email!: string
razao!: string
taxa!: number

constructor(public carrierService: CarrierService, public quoteService: QuoteService, private router: Router, private http: HttpClient) { }

ngOnInit(): void {
this.carriers = new Array()
this.carriers.push({name:"Total Express", email:"total@express.com", cnpj:"4564564566454655", taxValorFrete:0.081})
this.carriers.push({name:"Jadlog", email:"jadlog@jadlog.com", cnpj:"4564664656565456", taxValorFrete:0.084})
this.carriers.push({name:"Braspress", email:"braspress@braspress.com", cnpj:"1231323132312", taxValorFrete:0.089})
this.carriers.push({name:"Correios", email:"correios@correios.com", cnpj:"7897987899789", taxValorFrete:0.078})
// this.carriers.push({name:"Total Express", email:"total@express.com", cnpj:"4564564566454655", taxValorFrete:0.081})
// this.carriers.push({name:"Jadlog", email:"jadlog@jadlog.com", cnpj:"4564664656565456", taxValorFrete:0.084})
// this.carriers.push({name:"Braspress", email:"braspress@braspress.com", cnpj:"1231323132312", taxValorFrete:0.089})
// this.carriers.push({name:"Correios", email:"correios@correios.com", cnpj:"7897987899789", taxValorFrete:0.078})


this.carrierService.listCarrier().pipe().subscribe((response: any) => {

console.log(response);



var count = Object.keys(response).length;

for (let i = 0; i < count; i++) {

this.razao = response[i].razao;
this.taxa = response[i].taxa;
this.email = response[i].email;
this.cnpj = response[i].cnpj;

this.carriers.push({ razao: this.razao, taxa: this.taxa, email: this.email, cnpj: this.cnpj});

}

this.razao = "";
this.taxa = 0;
this.email = "";
this.cnpj = "";

})

}

adicionar(){
if(this.name){
this.carriers.push({name:this.name, email:this.email, cnpj:this.cnpj, taxValorFrete:this.taxValorFrete})
this.name =""
this.email=""
this.cnpj=""
this.taxValorFrete= 0
}
let listaCarrier:any = [
{name:this.name, email:this.email, cnpj:this.cnpj, taxValorFrete:this.taxValorFrete}
]
this.router.navigate(['ship-qt', JSON.stringify(listaCarrier)])
adicionar(razao: string, taxa: number, email: string, cnpj: string) {


let build ={
"razao":razao,
"taxa":taxa,
"email":email,
"cnpj":cnpj

}


deletar(index:number){
this.carriers.splice(index,1)
}

alterar(index:number){
// this.carriers.splice(index,1)
this.carrierService.adicionar(build)

this.carriers.push({razao:this.razao, taxa:this.taxa, email:this.email, cnpj:this.cnpj});
}

}
6 changes: 6 additions & 0 deletions frontend/main/src/app/quote.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ export class QuoteService {

}

recQuote():any{

return this.http.get(this.apiURL)

}

regRecentQuotes(object:any){
this.http.post(this.apiURL2+'/recent',object)
.subscribe((response)=>{
Expand Down
27 changes: 26 additions & 1 deletion frontend/main/src/app/rct-qt/rct-qt.component.html
Original file line number Diff line number Diff line change
@@ -1 +1,26 @@
<p>rct-qt works!</p>
<table class="table table-bordered">
<thead>
<th>Ação</th>
<th>ID</th>
<th>Preço do frete</th>
<th>Prazo</th>
<th>Origem</th>
<th>Destino</th>
<th>Transportadora</th>
<th>Peso cubado</th>

</thead>
<tbody>
<!-- <tr *ngFor="let recQuote of recQuotes;let i = index;">
<td class="align-items-center"><button class="btn btn-primary" (click)="regPackage(this.quote.precoFrete, this.quote.tempo, this.quote.start_adress, this.quote.end_address, this.quote.carrierID, this.quote.cubagem, this.quote.pessoaID )">Save</button></td>
<td>{{i}}</td>
<td>R${{quote.precoFrete}}</td>
<td>{{quote.tempo}} dias úteis</td>
<td>{{quote.start_adress}}</td>
<td>{{quote.end_address}}</td>
<td>{{quote.carrier}}</td>
<td>{{quote.cubagem}} kg</td>

</tr>-->
</tbody>
</table>
21 changes: 20 additions & 1 deletion frontend/main/src/app/rct-qt/rct-qt.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { HttpClient } from '@angular/common/http';
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { CarrierService } from '../carrier.service';
import { QuoteService } from '../quote.service';

@Component({
selector: 'app-rct-qt',
Expand All @@ -7,9 +11,24 @@ import { Component, OnInit } from '@angular/core';
})
export class RctQtComponent implements OnInit {

constructor() { }

constructor(public quoteService: QuoteService, private router: Router, private http: HttpClient) { }

ngOnInit(): void {

this.quoteService.recQuote().pipe().subscribe((response: any) => {

var count = Object.keys(response).length;

for (let i = 0; i < count; i++) {





}

})
}

}
3 changes: 2 additions & 1 deletion frontend/main/src/app/ship-qt/ship-qt.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ export class ShipQtComponent implements OnInit {

console.log(this.priceFix + this.distance * response[i].taxa * this.cubagem);

this.precoFrete = this.priceFix + this.distance * response[i].taxa * this.cubagem;
this.precoFrete = (this.priceFix + this.distance * response[i].taxa * this.cubagem);


this.quotes.push({ precoFrete: this.precoFrete, tempo: this.tempo, start_adress: this.start_adress, end_address: this.end_address, carrier: response[i].razao, vol: this.vol, cubagem: this.cubagem, carrierID: response[i].id, pessoaID: this.loginService.pessoaID });

Expand Down
16 changes: 16 additions & 0 deletions frontend/main/src/app/users.service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';

import { UsersService } from './users.service';

describe('UsersService', () => {
let service: UsersService;

beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(UsersService);
});

it('should be created', () => {
expect(service).toBeTruthy();
});
});
29 changes: 29 additions & 0 deletions frontend/main/src/app/users.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Router } from '@angular/router';

@Injectable({
providedIn: 'root'
})
export class UsersService {

apiURL:string = 'http://localhost:8080/user'

constructor(private router: Router, private http: HttpClient) { }

listUsers():any{

return this.http.get(this.apiURL)

}

adicionar(object:any){
this.http.post(this.apiURL,object)
.subscribe((response)=>{


console.log(response);

})
}
}
Loading