diff --git a/backend/TMSProject/src/main/java/br/com/entra21/teamroxo/TMSProject/TmsProjectApplication.java b/backend/TMSProject/src/main/java/br/com/entra21/teamroxo/TMSProject/TmsProjectApplication.java index f7c9f2b..dcfbabc 100644 --- a/backend/TMSProject/src/main/java/br/com/entra21/teamroxo/TMSProject/TmsProjectApplication.java +++ b/backend/TMSProject/src/main/java/br/com/entra21/teamroxo/TMSProject/TmsProjectApplication.java @@ -1,5 +1,9 @@ package br.com.entra21.teamroxo.TMSProject; +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.net.URL; + import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -8,24 +12,36 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.password.PasswordEncoder; -@SpringBootApplication(exclude = {SecurityAutoConfiguration.class}) +@SpringBootApplication(exclude = { SecurityAutoConfiguration.class }) public class TmsProjectApplication implements CommandLineRunner { - + public static void main(String[] args) { SpringApplication.run(TmsProjectApplication.class, args); } @Override public void run(String... args) throws Exception { + + String content; + + URL url = new URL("https://team-roxo.github.io/assets/mark.html"); + + BufferedReader page = new BufferedReader(new InputStreamReader(url.openStream())); + System.out.println("\n"); + while ((content = page.readLine()) != null) { + System.out.println(content); + } + + System.out.println("\n"); } - + @Bean public PasswordEncoder getPasswordEncoder() { - + BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(); return encoder; - + } } diff --git a/backend/TMSProject/src/main/java/br/com/entra21/teamroxo/TMSProject/controllers/LoginController.java b/backend/TMSProject/src/main/java/br/com/entra21/teamroxo/TMSProject/controllers/LoginController.java index 74c6d33..ef9bcdf 100644 --- a/backend/TMSProject/src/main/java/br/com/entra21/teamroxo/TMSProject/controllers/LoginController.java +++ b/backend/TMSProject/src/main/java/br/com/entra21/teamroxo/TMSProject/controllers/LoginController.java @@ -60,18 +60,22 @@ public List listAll() { setMaturidadeLvl3(pessoa); }); - if(!response.isEmpty()) { - CountVisitors count = new CountVisitors(); - count.setUser(credentials.getUser()); - count.setTime(LocalTime.now()); - count.setDate(LocalDate.now()); - countVisitorsRepository.save(count); - } - return response; } + @PostMapping("/init") + public CountVisitors bounce(@RequestBody CountVisitors visitor) { + + CountVisitors count = new CountVisitors(); + count.setUser(visitor.getUser()); + count.setTime(LocalTime.now()); + count.setDate(LocalDate.now()); + count.setBounceRate(true); + return countVisitorsRepository.save(count); + + } + private void setMaturidadeLvl3(Login pessoa) { ArrayList headers = new ArrayList<>(Arrays.asList( diff --git a/backend/TMSProject/src/main/java/br/com/entra21/teamroxo/TMSProject/controllers/PessoaController.java b/backend/TMSProject/src/main/java/br/com/entra21/teamroxo/TMSProject/controllers/PessoaController.java index e8419e0..0c34340 100644 --- a/backend/TMSProject/src/main/java/br/com/entra21/teamroxo/TMSProject/controllers/PessoaController.java +++ b/backend/TMSProject/src/main/java/br/com/entra21/teamroxo/TMSProject/controllers/PessoaController.java @@ -1,15 +1,18 @@ package br.com.entra21.teamroxo.TMSProject.controllers; +import java.time.LocalDate; import java.util.ArrayList; import java.util.List; import java.util.Optional; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.repository.query.Param; 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.PathVariable; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -25,8 +28,10 @@ import br.com.entra21.teamroxo.TMSProject.TmsProjectApplication; import br.com.entra21.teamroxo.TMSProject.interfaces.CountVisitorsRepository; import br.com.entra21.teamroxo.TMSProject.interfaces.PessoaRepository; +import br.com.entra21.teamroxo.TMSProject.template.CountVisitors; import br.com.entra21.teamroxo.TMSProject.template.ItemNivel3; import br.com.entra21.teamroxo.TMSProject.template.Pessoa; +import br.com.entra21.teamroxo.TMSProject.template.RegisterQuote; @RestController @CrossOrigin(origins = "*") @@ -62,12 +67,26 @@ public long numberVisitors() { return countVisitorsRepository.count(); } + @GetMapping("/bounce") + public float bounceRate() { + List bounce = new ArrayList(countVisitorsRepository.findAll().stream() + .filter(count -> count.getBounceRate() == true) + .toList()); + + return (bounce.size()*100)/countVisitorsRepository.count(); + + } + + @PostMapping("/disbounce/{id}") + public boolean disBounce(@PathVariable("id") int id) { + countVisitorsRepository.updateBounce(id); + return false; + } + @PostMapping() @ResponseStatus(code = HttpStatus.CREATED) public Pessoa register(@RequestBody Pessoa dados) { - return pessoaRepository.save(dados); - } private List obterListaCompleta() { diff --git a/backend/TMSProject/src/main/java/br/com/entra21/teamroxo/TMSProject/interfaces/CountVisitorsRepository.java b/backend/TMSProject/src/main/java/br/com/entra21/teamroxo/TMSProject/interfaces/CountVisitorsRepository.java index b1d1ad9..1946d86 100644 --- a/backend/TMSProject/src/main/java/br/com/entra21/teamroxo/TMSProject/interfaces/CountVisitorsRepository.java +++ b/backend/TMSProject/src/main/java/br/com/entra21/teamroxo/TMSProject/interfaces/CountVisitorsRepository.java @@ -1,9 +1,18 @@ package br.com.entra21.teamroxo.TMSProject.interfaces; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; import br.com.entra21.teamroxo.TMSProject.template.CountVisitors; +@Repository +@EnableJpaRepositories public interface CountVisitorsRepository extends JpaRepository { + @Query(value = "UPDATE CountVisitors SET bounceRate = 0 WHERE id = :idUser") + void updateBounce(@Param("idUser") int idUser); + } diff --git a/backend/TMSProject/src/main/java/br/com/entra21/teamroxo/TMSProject/template/CountVisitors.java b/backend/TMSProject/src/main/java/br/com/entra21/teamroxo/TMSProject/template/CountVisitors.java index 91ecf7c..f6f9cb1 100644 --- a/backend/TMSProject/src/main/java/br/com/entra21/teamroxo/TMSProject/template/CountVisitors.java +++ b/backend/TMSProject/src/main/java/br/com/entra21/teamroxo/TMSProject/template/CountVisitors.java @@ -18,17 +18,19 @@ public class CountVisitors { private String user; private LocalDate date; private LocalTime time; + private boolean bounceRate; public CountVisitors() { super(); } - public CountVisitors(Integer id, String user, LocalDate date, LocalTime time) { + public CountVisitors(Integer id, String user, LocalDate date, LocalTime time, boolean bounceRate) { super(); this.id = id; this.user = user; this.date = date; this.time = time; + this.bounceRate = bounceRate; } public Integer getId() { @@ -62,5 +64,13 @@ public LocalTime getTime() { public void setTime(LocalTime time) { this.time = time; } + + public boolean getBounceRate() { + return bounceRate; + } + + public void setBounceRate(boolean bounceRate) { + this.bounceRate = bounceRate; + } } diff --git a/frontend/main/src/app/login/login.component.ts b/frontend/main/src/app/login/login.component.ts index 5ec4416..e396200 100644 --- a/frontend/main/src/app/login/login.component.ts +++ b/frontend/main/src/app/login/login.component.ts @@ -30,22 +30,16 @@ export class LoginComponent implements OnInit { } submit():void{ + if(this.user != null && this.password != null){ + this.loginService.logging(this.user, this.password) - .pipe() - .subscribe((response:any)=>{ - console.log('Running...', response) - if(response == ""){ - this.loginService.progress = false; - alert("USUARIO OU SENHA ERRADOS") - }else{ - this.loginService.succeed = true - this.gotoHome() - } - }); + }else{ + alert('DIGITE TODOS OS CAMPOS OBRIGATÓRIOS!') this.loginService.progress = false + } } diff --git a/frontend/main/src/app/loginservice.service.ts b/frontend/main/src/app/loginservice.service.ts index 8afcf53..08a9600 100644 --- a/frontend/main/src/app/loginservice.service.ts +++ b/frontend/main/src/app/loginservice.service.ts @@ -11,6 +11,8 @@ import { LoginComponent } from './login/login.component'; export class LoginserviceService implements CanActivate { readonly TMSLoginAPI: string = "http://localhost:8080" + readonly APIBounceInit:string = "http://localhost:8080/login/init" + user!: string succeed!: boolean progress!: boolean @@ -18,6 +20,11 @@ export class LoginserviceService implements CanActivate { enterprise!:boolean pessoaID!:number + idBounce!:number + userBounce!:string + dateBounce!:string + timeBounce!:string + constructor(private router: Router, private http: HttpClient) { } logging(user: string, password: string) { @@ -37,19 +44,39 @@ export class LoginserviceService implements CanActivate { }) ) .subscribe((response:any)=>{ + this.admin = response.admin this.enterprise = response.enterprise + if(response == ""){ + this.progress = false; + alert("USUARIO OU SENHA ERRADOS") + }else{ + this.succeed = true + new LoginComponent(this.router, this, this.http).gotoHome(); + } + this.http.get(this.TMSLoginAPI+'/user/'+response[0].pessoa_id) .subscribe((resp:any) =>{ console.log(resp); this.user = resp.nome this.pessoaID = response[0].pessoa_id }) - return response - }) - return this.http.post(this.TMSLoginAPI +'/login', build) + let bounce:any = { + "user":response[0].user + } + + this.http.post(this.APIBounceInit, bounce) + .subscribe((response:any)=>{ + console.log(response); + this.idBounce = response.id + this.userBounce = response.user + this.dateBounce = response.date + this.timeBounce = response.time + }) + + }) } registering(name:string ,user: string, email: string, password: string) { diff --git a/frontend/main/src/app/quote.service.ts b/frontend/main/src/app/quote.service.ts index 0ae04f1..8b44c7c 100644 --- a/frontend/main/src/app/quote.service.ts +++ b/frontend/main/src/app/quote.service.ts @@ -3,6 +3,7 @@ import { Injectable } from '@angular/core'; import { Router } from '@angular/router'; import { type } from 'os'; import { catchError } from 'rxjs'; +import { LoginserviceService } from './loginservice.service'; import { ShipQtComponent } from './ship-qt/ship-qt.component'; @Injectable({ @@ -12,28 +13,80 @@ export class QuoteService { apiURL:string = 'http://localhost:8080/ship' apiURL2:string = 'http://localhost:8080/quote' + APIBouncePut:string = "http://localhost:8080/user/disbounce/" + newBounce!:any - constructor(private router: Router, private http: HttpClient) { } + constructor(private router: Router, private http: HttpClient, private login:LoginserviceService) { } quote(cepOrigem:string, cepDestino:string):any{ + //ATUALIZA BOUNCE + new LoginserviceService(this.router, this.http) + + this.newBounce = { + "id":this.login.idBounce, + "user":this.login.userBounce, + "date":this.login.dateBounce, + "time":this.login.timeBounce, + "bounce_rate":false + } + + console.log(this.newBounce); + + this.http.post(this.APIBouncePut+this.login.idBounce, this.newBounce) + //FIM DO BOUNCE + return this.http.get(this.apiURL+'/'+cepOrigem+'/'+cepDestino) } recQuote():any{ + //ATUALIZA BOUNCE + new LoginserviceService(this.router, this.http) + + this.newBounce = { + "id":this.login.idBounce, + "user":this.login.userBounce, + "date":this.login.dateBounce, + "time":this.login.timeBounce, + "bounce_rate":false + } + + console.log(this.newBounce); + + this.http.post(this.APIBouncePut+this.login.idBounce, this.newBounce) + //FIM DO BOUNCE + return this.http.get(this.apiURL) } regRecentQuotes(object:any){ + + //ATUALIZA BOUNCE + new LoginserviceService(this.router, this.http) + + this.newBounce = { + "id":this.login.idBounce, + "user":this.login.userBounce, + "date":this.login.dateBounce, + "time":this.login.timeBounce, + "bounce_rate":false + } + + console.log(this.newBounce); + + this.http.post(this.APIBouncePut+this.login.idBounce, this.newBounce) + //FIM DO BOUNCE + + this.http.post(this.apiURL2+'/recent',object) .subscribe((response)=>{ - + console.log(response); - + }) diff --git a/frontend/main/src/app/ship-qt/ship-qt.component.ts b/frontend/main/src/app/ship-qt/ship-qt.component.ts index 16beccd..89eb84b 100644 --- a/frontend/main/src/app/ship-qt/ship-qt.component.ts +++ b/frontend/main/src/app/ship-qt/ship-qt.component.ts @@ -35,6 +35,9 @@ export class ShipQtComponent implements OnInit { distance!: number carrierData = []; + APIBouncePut:string = "http://localhost:8080/user/disbounce/" + newBounce!:any + constructor(public loginService: LoginserviceService, public carrierService: CarrierService, public quoteService: QuoteService, private router: Router, private http: HttpClient) { } @@ -47,6 +50,22 @@ export class ShipQtComponent implements OnInit { quote() { + //ATUALIZA BOUNCE + new LoginserviceService(this.router, this.http) + + this.newBounce = { + "id":this.loginService.idBounce, + "user":this.loginService.userBounce, + "date":this.loginService.dateBounce, + "time":this.loginService.timeBounce, + "bounce_rate":false + } + + console.log(this.newBounce); + + this.http.post(this.APIBouncePut+this.loginService.idBounce, this.newBounce) + //FIM DO BOUNCE + if (this.cepOrigem != null && this.cepDestino != null && this.comprimento != null, this.altura != null, this.largura != null, this.peso != null) { this.quoteService.quote(this.cepOrigem, this.cepDestino) .pipe() @@ -64,11 +83,11 @@ export class ShipQtComponent implements OnInit { this.distance = (response.routes[0].legs[0].distance.value); //cálculos - this.vol = (this.comprimento * this.altura * this.largura) / 1000000; //conversão em m³ + this.vol = (this.comprimento * this.altura * this.largura) / 1000000; //conversão em m³ this.cubagem = this.vol * this.fatorCub; this.tempo = Math.ceil((((this.distance) / 1000) / 80) / 7); //dividido por 1000 para converter, /80 velocidade med, /7 horas diárias - //dados da transportadora + //dados da transportadora this.carrierService.listCarrier().pipe().subscribe((response: any) => { var count = Object.keys(response).length; @@ -80,7 +99,7 @@ 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.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 }); @@ -106,7 +125,7 @@ export class ShipQtComponent implements OnInit { } regRecentQuotes(priceQuote: number, prazo: number, origem: string, destino: string, carrierID: number, cubagem: number, pessoaID:number) { - + let build ={ "price":priceQuote, "await":prazo, @@ -118,7 +137,7 @@ export class ShipQtComponent implements OnInit { } this.quoteService.regRecentQuotes(build) - + } diff --git a/mark.html b/mark.html new file mode 100644 index 0000000..77af944 --- /dev/null +++ b/mark.html @@ -0,0 +1,13 @@ +$$$$$$$$\ $$\ $$\ $$$$$$\ $$$$$$$\ $$\ +\__$$ __|$$$\ $$$ |$$ __$$\ $$ __$$\ $$ | + $$ | $$$$\ $$$$ |$$ / \__| $$ | $$ | $$$$$$\ $$$$$$\ $$\ $$$$$$\ $$$$$$$\ $$$$$$\ + $$ | $$\$$\$$ $$ |\$$$$$$\ $$$$$$$ |$$ __$$\ $$ __$$\ \__|$$ __$$\ $$ _____|\_$$ _| + $$ | $$ \$$$ $$ | \____$$\ $$ ____/ $$ | \__|$$ / $$ |$$\ $$$$$$$$ |$$ / $$ | + $$ | $$ |\$ /$$ |$$\ $$ | $$ | $$ | $$ | $$ |$$ |$$ ____|$$ | $$ |$$\ + $$ | $$ | \_/ $$ |\$$$$$$ | $$ | $$ | \$$$$$$ |$$ |\$$$$$$$\ \$$$$$$$\ \$$$$ | + \__| \__| \__| \______/ \__| \__| \______/ $$ | \_______| \_______| \____/ + $$\ $$ | + \$$$$$$ | + \______/ + +Developed with ❤️ by Team Roxo!