Compare commits

..

6 Commits
main ... nosql

Author SHA1 Message Date
1672a95835 done 2023-05-19 15:21:42 +04:00
4a469eb8ad done 2023-05-15 16:01:22 +04:00
fe9682c43b Merge remote-tracking branch 'origin/nosql' into nosql
# Conflicts:
#	SUBD-back/build.gradle
#	SUBD-back/src/main/java/com/subd/subd/Controllers/CustomRequest.java
#	SUBD-back/src/main/java/com/subd/subd/Models/Car.java
#	SUBD-back/src/main/java/com/subd/subd/Models/Client.java
#	SUBD-back/src/main/java/com/subd/subd/Models/Order.java
#	SUBD-back/src/main/java/com/subd/subd/Repositories/OrderRepository.java
2023-05-14 19:09:55 +04:00
a9284a5971 many of done 2023-05-14 19:07:45 +04:00
3ad6e77a70 init of mongodb 2023-05-14 18:16:10 +04:00
bdc8ec8871 init of mongodb 2023-05-13 23:56:36 +04:00
33 changed files with 300 additions and 180 deletions

View File

@ -19,11 +19,10 @@ repositories {
} }
dependencies { dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-mongodb:3.0.4'
compileOnly 'org.projectlombok:lombok' compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools' developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'org.postgresql:postgresql'
annotationProcessor 'org.projectlombok:lombok' annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test' testImplementation 'org.springframework.boot:spring-boot-starter-test'
} }

View File

@ -14,23 +14,27 @@ public class CarController {
this.CarService = CarService; this.CarService = CarService;
} }
@GetMapping("/car/{id}") @GetMapping("/car/{id}")
public Car getCar(@PathVariable Long id) { public Car getCar(@PathVariable String id) {
return CarService.findCar(id); return CarService.findCar(id);
} }
@GetMapping("/car") @GetMapping("/car")
public List<Car> getCars() { public List<Car> getCars() {
return CarService.findAllCars(); return CarService.findAllCars();
} }
@PostMapping("/carWithId")
public Car createCarWithId(@RequestBody CarDto carDto) {
return CarService.addCarWithId(carDto.getId(), carDto.getGosNumber(), carDto.getVin(), carDto.getDriverId());
}
@PostMapping("/car") @PostMapping("/car")
public Car createCar(@RequestBody CarDto carDto) { public Car createCar(@RequestBody CarDto carDto) {
return CarService.addCar(carDto.getGosNumber(), carDto.getVin(), carDto.getDriverId()); return CarService.addCar(carDto.getGosNumber(), carDto.getVin(), carDto.getDriverId());
} }
@PutMapping("/car/{id}") @PutMapping("/car/{id}")
public Car updateCar(@PathVariable Long id, @RequestBody CarDto carDto) { public Car updateCar(@PathVariable String id, @RequestBody CarDto carDto) {
return CarService.updateCar(id, carDto.getGosNumber(), carDto.getVin(), carDto.getDriverId()); return CarService.updateCar(id, carDto.getGosNumber(), carDto.getVin(), carDto.getDriverId());
} }
@DeleteMapping("/car/{id}") @DeleteMapping("/car/{id}")
public Car deleteCar(@PathVariable Long id) { public Car deleteCar(@PathVariable String id) {
return CarService.deleteCar(id); return CarService.deleteCar(id);
} }
} }

View File

@ -2,6 +2,7 @@ package com.subd.subd.Controllers;
import com.subd.subd.Models.Client; import com.subd.subd.Models.Client;
import com.subd.subd.Services.ClientService; import com.subd.subd.Services.ClientService;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
@ -13,7 +14,7 @@ public class ClientController {
this.ClientService = ClientService; this.ClientService = ClientService;
} }
@GetMapping("/client/{id}") @GetMapping("/client/{id}")
public Client getClient(@PathVariable Long id) { public Client getClient(@PathVariable String id) {
return ClientService.findClient(id); return ClientService.findClient(id);
} }
@GetMapping("/client") @GetMapping("/client")
@ -24,12 +25,16 @@ public class ClientController {
public Client createClient(@RequestBody Client client) { public Client createClient(@RequestBody Client client) {
return ClientService.addClient(client.getName(), client.getPhone(), client.getEmail()); return ClientService.addClient(client.getName(), client.getPhone(), client.getEmail());
} }
@PostMapping("/clientWithId")
public Client createClientWithId(@RequestBody Client client) {
return ClientService.addClientWithId(client.getId(), client.getName(), client.getPhone(), client.getEmail());
}
@PutMapping("/client/{id}") @PutMapping("/client/{id}")
public Client updateClient(@PathVariable Long id, @RequestBody Client client) { public Client updateClient(@PathVariable String id, @RequestBody Client client) {
return ClientService.updateClient(id, client.getName(), client.getPhone(), client.getEmail()); return ClientService.updateClient(id, client.getName(), client.getPhone(), client.getEmail());
} }
@DeleteMapping("/client/{id}") @DeleteMapping("/client/{id}")
public Client deleteClient(@PathVariable Long id) { public Client deleteClient(@PathVariable String id) {
return ClientService.deleteClient(id); return ClientService.deleteClient(id);
} }
} }

View File

@ -2,9 +2,18 @@ package com.subd.subd.Controllers;
import com.subd.subd.Models.Order; import com.subd.subd.Models.Order;
import com.subd.subd.Repositories.OrderRepository; import com.subd.subd.Repositories.OrderRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.data.mongodb.core.query.Query;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
@ -13,16 +22,31 @@ import java.util.List;
@RestController @RestController
public class CustomRequest { public class CustomRequest {
private final OrderRepository orderRepository; private final OrderRepository orderRepository;
public CustomRequest(OrderRepository orderRepository) { private final MongoTemplate mongoTemplate;
private static final Logger log = LoggerFactory.getLogger(CustomRequest.class);
public CustomRequest(OrderRepository orderRepository, MongoTemplate mongoTemplate) {
this.orderRepository = orderRepository; this.orderRepository = orderRepository;
this.mongoTemplate = mongoTemplate;
} }
@GetMapping("/custom") @GetMapping("/custom")
public Long performCustomRequest(String date, Double value, String status, String orderBy) throws ParseException { public Long performCustomRequest(@RequestParam("date") String date,
@RequestParam("value") Double value,
@RequestParam("status") String status,
@RequestParam("orderBy") String orderBy) throws ParseException {
SimpleDateFormat format = new SimpleDateFormat("yyyy-M-d"); SimpleDateFormat format = new SimpleDateFormat("yyyy-M-d");
Date date1 = format.parse(date); Date date1 = format.parse(date);
Query query = new Query();
query.addCriteria(Criteria.where("date").gt(date1))
.addCriteria(Criteria.where("value").gt(value))
.addCriteria(Criteria.where("status").is(status));
query.with(Sort.by(Sort.Direction.ASC, orderBy));
Long start = System.nanoTime(); Long start = System.nanoTime();
orderRepository.customAction(date1, value, status, orderBy); // orderRepository.customAction(date1, value, status, orderBy);
List<Order> orders = mongoTemplate.find(query, Order.class);
Long finish = System.nanoTime(); Long finish = System.nanoTime();
for (Order order : orders) {
log.info(order.toString());
}
return finish - start; return finish - start;
} }
} }

View File

@ -13,7 +13,7 @@ public class DriverController {
this.DriverService = DriverService; this.DriverService = DriverService;
} }
@GetMapping("/driver/{id}") @GetMapping("/driver/{id}")
public Driver getDriver(@PathVariable Long id) { public Driver getDriver(@PathVariable String id) {
return DriverService.findDriver(id); return DriverService.findDriver(id);
} }
@GetMapping("/driver") @GetMapping("/driver")
@ -24,12 +24,16 @@ public class DriverController {
public Driver createDriver(@RequestBody Driver driver) { public Driver createDriver(@RequestBody Driver driver) {
return DriverService.addDriver(driver.getName(), driver.getBirthday(), driver.getPhone(), driver.getEmail()); return DriverService.addDriver(driver.getName(), driver.getBirthday(), driver.getPhone(), driver.getEmail());
} }
@PostMapping("/driverWithId")
public Driver createDriverWithId(@RequestBody Driver driver) {
return DriverService.addDriverWithId(driver.getId(), driver.getName(), driver.getBirthday(), driver.getPhone(), driver.getEmail());
}
@PutMapping("/driver/{id}") @PutMapping("/driver/{id}")
public Driver updateDriver(@PathVariable Long id, @RequestBody Driver driver) { public Driver updateDriver(@PathVariable String id, @RequestBody Driver driver) {
return DriverService.updateDriver(id, driver.getName(), driver.getBirthday(), driver.getPhone(), driver.getEmail()); return DriverService.updateDriver(id, driver.getName(), driver.getBirthday(), driver.getPhone(), driver.getEmail());
} }
@DeleteMapping("/driver/{id}") @DeleteMapping("/driver/{id}")
public Driver deleteDriver(@PathVariable Long id) { public Driver deleteDriver(@PathVariable String id) {
return DriverService.deleteDriver(id); return DriverService.deleteDriver(id);
} }
} }

View File

@ -15,7 +15,7 @@ public class OrderController {
this.OrderService = OrderService; this.OrderService = OrderService;
} }
@GetMapping("/order/{id}") @GetMapping("/order/{id}")
public Order getOrder(@PathVariable Long id) { public Order getOrder(@PathVariable String id) {
return OrderService.findOrder(id); return OrderService.findOrder(id);
} }
@GetMapping("/order") @GetMapping("/order")
@ -23,26 +23,30 @@ public class OrderController {
return OrderService.findAllOrders(); return OrderService.findAllOrders();
} }
@GetMapping("/order/filter") @GetMapping("/order/filter")
public List<Order> getFilteredOrders(@RequestParam(value = "id", required = false) Long id, public List<Order> getFilteredOrders(@RequestParam(value = "id", required = false) String id,
@RequestParam(value = "value", required = false) Double value, @RequestParam(value = "value", required = false) Double value,
@RequestParam(value = "status", required = false) String status, @RequestParam(value = "status", required = false) String status,
@RequestParam(value = "date", required = false) Date date, @RequestParam(value = "date", required = false) Date date,
@RequestParam(value = "clientId", required = false) Long clientId, @RequestParam(value = "clientId", required = false) String clientId,
@RequestParam(value = "sourcePickUpPointId", required = false) Long sourcePickUpPointId, @RequestParam(value = "sourcePickUpPointId", required = false) String sourcePickUpPointId,
@RequestParam(value = "destPickUpPointId", required = false) Long destPickUpPointId, @RequestParam(value = "destPickUpPointId", required = false) String destPickUpPointId,
@RequestParam(value = "carId", required = false) Long carId) { @RequestParam(value = "carId", required = false) String carId) {
return OrderService.findfilteredOrders(id, value, status, date, clientId, sourcePickUpPointId, destPickUpPointId, carId); return OrderService.findfilteredOrders(id, value, status, date, clientId, sourcePickUpPointId, destPickUpPointId, carId);
} }
@PostMapping("/order") @PostMapping("/order")
public Order createOrder(@RequestBody OrderDto orderDto) { public Order createOrder(@RequestBody OrderDto orderDto) {
return OrderService.addOrder(orderDto.getValue(), orderDto.getStatus(), orderDto.getDate(), orderDto.getClientId(), orderDto.getSourcePickUpPointId(), orderDto.getDestPickUpPointId(), orderDto.getCarId()); return OrderService.addOrder(orderDto.getValue(), orderDto.getStatus(), orderDto.getDate(), orderDto.getClientId(), orderDto.getSourcePickUpPointId(), orderDto.getDestPickUpPointId(), orderDto.getCarId());
} }
@PostMapping("/orderWithId")
public Order createOrderWithId(@RequestBody OrderDto orderDto) {
return OrderService.addOrderWithId(orderDto.getId(), orderDto.getValue(), orderDto.getStatus(), orderDto.getDate(), orderDto.getClientId(), orderDto.getSourcePickUpPointId(), orderDto.getDestPickUpPointId(), orderDto.getCarId());
}
@PutMapping("/order/{id}") @PutMapping("/order/{id}")
public Order updateOrder(@PathVariable Long id, @RequestBody OrderDto orderDto) { public Order updateOrder(@PathVariable String id, @RequestBody OrderDto orderDto) {
return OrderService.updateOrder(id, orderDto.getValue(), orderDto.getStatus(), orderDto.getDate(), orderDto.getClientId(), orderDto.getSourcePickUpPointId(), orderDto.getDestPickUpPointId(), orderDto.getCarId()); return OrderService.updateOrder(id, orderDto.getValue(), orderDto.getStatus(), orderDto.getDate(), orderDto.getClientId(), orderDto.getSourcePickUpPointId(), orderDto.getDestPickUpPointId(), orderDto.getCarId());
} }
@DeleteMapping("/order/{id}") @DeleteMapping("/order/{id}")
public Order deleteOrder(@PathVariable Long id) { public Order deleteOrder(@PathVariable String id) {
return OrderService.deleteOrder(id); return OrderService.deleteOrder(id);
} }
} }

View File

@ -13,7 +13,7 @@ public class PickUpPointController {
this.PickUpPointService = PickUpPointService; this.PickUpPointService = PickUpPointService;
} }
@GetMapping("/pickUpPoint/{id}") @GetMapping("/pickUpPoint/{id}")
public PickUpPoint getPickUpPoint(@PathVariable Long id) { public PickUpPoint getPickUpPoint(@PathVariable String id) {
return PickUpPointService.findPickUpPoint(id); return PickUpPointService.findPickUpPoint(id);
} }
@GetMapping("/pickUpPoint") @GetMapping("/pickUpPoint")
@ -24,12 +24,16 @@ public class PickUpPointController {
public PickUpPoint createPickUpPoint(@RequestBody PickUpPoint pickUpPoint) { public PickUpPoint createPickUpPoint(@RequestBody PickUpPoint pickUpPoint) {
return PickUpPointService.addPickUpPoint(pickUpPoint.getAddress()); return PickUpPointService.addPickUpPoint(pickUpPoint.getAddress());
} }
@PostMapping("/pickUpPointWithId")
public PickUpPoint createPickUpPointWithId(@RequestBody PickUpPoint pickUpPoint) {
return PickUpPointService.addPickUpPointWithId(pickUpPoint.getId(), pickUpPoint.getAddress());
}
@PutMapping("/pickUpPoint/{id}") @PutMapping("/pickUpPoint/{id}")
public PickUpPoint updatePickUpPoint(@PathVariable Long id, @RequestBody PickUpPoint pickUpPoint) { public PickUpPoint updatePickUpPoint(@PathVariable String id, @RequestBody PickUpPoint pickUpPoint) {
return PickUpPointService.updatePickUpPoint(id, pickUpPoint.getAddress()); return PickUpPointService.updatePickUpPoint(id, pickUpPoint.getAddress());
} }
@DeleteMapping("/pickUpPoint/{id}") @DeleteMapping("/pickUpPoint/{id}")
public PickUpPoint deletePickUpPoint(@PathVariable Long id) { public PickUpPoint deletePickUpPoint(@PathVariable String id) {
return PickUpPointService.deletePickUpPoint(id); return PickUpPointService.deletePickUpPoint(id);
} }
} }

View File

@ -1,22 +1,32 @@
package com.subd.subd.Dtos; package com.subd.subd.Dtos;
public class CarDto { public class CarDto {
private String id;
private String gosNumber; private String gosNumber;
private String vin; private String vin;
private Long driverId; private String driverId;
public CarDto() {} public CarDto() {}
public CarDto(String gosNumber, String vin, Long driverId) { public CarDto(String gosNumber, String vin, String driverId) {
this.gosNumber = gosNumber; this.gosNumber = gosNumber;
this.vin = vin; this.vin = vin;
this.driverId = driverId; this.driverId = driverId;
} }
public CarDto(String id, String gosNumber, String vin, String driverId) {
this.id = id;
this.gosNumber = gosNumber;
this.vin = vin;
this.driverId = driverId;
}
public String getId() {
return this.id;
}
public String getGosNumber() { public String getGosNumber() {
return this.gosNumber; return this.gosNumber;
} }
public String getVin() { public String getVin() {
return this.vin; return this.vin;
} }
public Long getDriverId() { public String getDriverId() {
return this.driverId; return this.driverId;
} }
} }

View File

@ -1,21 +1,21 @@
package com.subd.subd.Dtos; package com.subd.subd.Dtos;
import com.subd.subd.Models.PickUpPoint;
import jakarta.annotation.Nullable; import jakarta.annotation.Nullable;
import java.util.Date; import java.util.Date;
public class OrderDto { public class OrderDto {
private String id;
private Double value; private Double value;
private String status; private String status;
private Date date; private Date date;
private Long clientId; private String clientId;
private Long sourcePickUpPointId; private String sourcePickUpPointId;
@Nullable @Nullable
private Long destPickUpPointId; private String destPickUpPointId;
private Long carId; private String carId;
public OrderDto() {} public OrderDto() {}
public OrderDto(Double value, String status, Date date, Long clientId, Long sourcePickUpPointId, @Nullable Long destPickUpPointId, Long carId) { public OrderDto(Double value, String status, Date date, String clientId, String sourcePickUpPointId, @Nullable String destPickUpPointId, String carId) {
this.value = value; this.value = value;
this.status = status; this.status = status;
this.date = date; this.date = date;
@ -24,6 +24,19 @@ public class OrderDto {
this.destPickUpPointId = destPickUpPointId; this.destPickUpPointId = destPickUpPointId;
this.carId = carId; this.carId = carId;
} }
public OrderDto(String id, Double value, String status, Date date, String clientId, String sourcePickUpPointId, @Nullable String destPickUpPointId, String carId) {
this.id = id;
this.value = value;
this.status = status;
this.date = date;
this.clientId = clientId;
this.sourcePickUpPointId = sourcePickUpPointId;
this.destPickUpPointId = destPickUpPointId;
this.carId = carId;
}
public String getId() {
return this.id;
}
public Double getValue() { public Double getValue() {
return this.value; return this.value;
} }
@ -33,17 +46,17 @@ public class OrderDto {
public Date getDate() { public Date getDate() {
return this.date; return this.date;
} }
public Long getClientId() { public String getClientId() {
return this.clientId; return this.clientId;
} }
public Long getSourcePickUpPointId() { public String getSourcePickUpPointId() {
return this.sourcePickUpPointId; return this.sourcePickUpPointId;
} }
@Nullable @Nullable
public Long getDestPickUpPointId() { public String getDestPickUpPointId() {
return this.destPickUpPointId; return this.destPickUpPointId;
} }
public Long getCarId() { public String getCarId() {
return this.carId; return this.carId;
} }
} }

View File

@ -1,7 +1,7 @@
package com.subd.subd.Exceptions; package com.subd.subd.Exceptions;
public class CarNotFoundException extends RuntimeException{ public class CarNotFoundException extends RuntimeException{
public CarNotFoundException(Long id) { public CarNotFoundException(String id) {
super(String.format("Not found car with id: %s", id)); super(String.format("Not found car with id: %s", id));
} }
} }

View File

@ -1,7 +1,7 @@
package com.subd.subd.Exceptions; package com.subd.subd.Exceptions;
public class ClientNotFoundException extends RuntimeException{ public class ClientNotFoundException extends RuntimeException{
public ClientNotFoundException(Long id) { public ClientNotFoundException(String id) {
super(String.format("Not found client with id: %s", id)); super(String.format("Not found client with id: %s", id));
} }
} }

View File

@ -1,7 +1,7 @@
package com.subd.subd.Exceptions; package com.subd.subd.Exceptions;
public class DriverNotFoundException extends RuntimeException{ public class DriverNotFoundException extends RuntimeException{
public DriverNotFoundException(Long id) { public DriverNotFoundException(String id) {
super(String.format("Not found driver with id: %s", id)); super(String.format("Not found driver with id: %s", id));
} }
} }

View File

@ -1,7 +1,7 @@
package com.subd.subd.Exceptions; package com.subd.subd.Exceptions;
public class OrderNotFoundException extends RuntimeException{ public class OrderNotFoundException extends RuntimeException{
public OrderNotFoundException(Long id) { public OrderNotFoundException(String id) {
super(String.format("Not found order with id: %s", id)); super(String.format("Not found order with id: %s", id));
} }
} }

View File

@ -1,7 +1,7 @@
package com.subd.subd.Exceptions; package com.subd.subd.Exceptions;
public class PickUpPointNotFoundException extends RuntimeException{ public class PickUpPointNotFoundException extends RuntimeException{
public PickUpPointNotFoundException(Long id) { public PickUpPointNotFoundException(String id) {
super(String.format("Not found pickUpPoint with id: %s", id)); super(String.format("Not found pickUpPoint with id: %s", id));
} }
} }

View File

@ -1,35 +1,40 @@
package com.subd.subd.Models; package com.subd.subd.Models;
import com.subd.subd.Dtos.CarDto; import com.subd.subd.Dtos.CarDto;
import jakarta.persistence.*; import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.DocumentReference;
import java.util.Objects; import java.util.Objects;
@Entity @Document("Car")
@Table(name = "Car")
public class Car { public class Car {
@Id @Id
@GeneratedValue private String id;
private Long id;
private String gosNumber; private String gosNumber;
private String vin; private String vin;
@OneToOne() @DocumentReference()
@JoinColumn(name = "Driver_id", referencedColumnName = "id")
private Driver driver; private Driver driver;
Car() {} public Car() {}
public Car(String gosNumber, String vin, Driver driver) { public Car(String gosNumber, String vin, Driver driver) {
this.gosNumber = gosNumber; this.gosNumber = gosNumber;
this.vin = vin; this.vin = vin;
this.driver = driver; this.driver = driver;
} }
public Car(String id, String gosNumber, String vin, Driver driver) {
this.id = id;
this.gosNumber = gosNumber;
this.vin = vin;
this.driver = driver;
}
public Car(CarDto carDto) { public Car(CarDto carDto) {
this.gosNumber = carDto.getGosNumber(); this.gosNumber = carDto.getGosNumber();
this.vin = carDto.getVin(); this.vin = carDto.getVin();
} }
public Long getId() { public String getId() {
return this.id; return this.id;
} }
public void setId(Long id) { public void setId(String id) {
this.id = id; this.id = id;
} }
public String getGosNumber() { public String getGosNumber() {

View File

@ -1,32 +1,38 @@
package com.subd.subd.Models; package com.subd.subd.Models;
import jakarta.annotation.Nullable;
import jakarta.persistence.*; import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Unwrapped;
import org.springframework.lang.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@Entity @Document("Client")
@Table(name = "Client")
public class Client { public class Client {
@Id @Id
@GeneratedValue private String id;
private Long id;
private String name; private String name;
private String phone; private String phone;
@Nullable @Unwrapped.Nullable
private String email; private String email;
@OneToMany(cascade = {CascadeType.MERGE})
private List<Order> orders; private List<Order> orders;
Client() {} public Client() {}
public Client(String name, String phone, @Nullable String email) { public Client(String name, String phone, @Nullable String email) {
this.name = name; this.name = name;
this.phone = phone; this.phone = phone;
this.email = email; this.email = email;
} }
public Long getId() { return this.id; } public Client(String id, String name, String phone, @Nullable String email) {
public void setId(Long id) { this.id = id; } this.id = id;
this.name = name;
this.phone = phone;
this.email = email;
}
public String getId() { return this.id; }
public void setId(String id) { this.id = id; }
public String getName() { return this.name; } public String getName() { return this.name; }
public void setName(String name) { this.name = name; } public void setName(String name) { this.name = name; }
public String getPhone() { return this.phone; } public String getPhone() { return this.phone; }

View File

@ -1,32 +1,36 @@
package com.subd.subd.Models; package com.subd.subd.Models;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue; import org.springframework.data.annotation.Id;
import jakarta.persistence.Id; import org.springframework.data.mongodb.core.mapping.Document;
import jakarta.persistence.Table;
import java.util.Date; import java.util.Date;
import java.util.Objects; import java.util.Objects;
@Entity @Document("Driver")
@Table(name = "Driver")
public class Driver { public class Driver {
@Id @Id
@GeneratedValue private String id;
private Long id;
private String name; private String name;
private Date birthday; private Date birthday;
private String phone; private String phone;
private String email; private String email;
Driver() {} public Driver() {}
public Driver(String name, Date birthday, String phone, String email) { public Driver(String name, Date birthday, String phone, String email) {
this.name = name; this.name = name;
this.birthday = birthday; this.birthday = birthday;
this.phone = phone; this.phone = phone;
this.email = email; this.email = email;
} }
public Long getId() { return this.id; } public Driver(String id, String name, Date birthday, String phone, String email) {
public void setId(Long id) { this.id = id; } this.id = id;
this.name = name;
this.birthday = birthday;
this.phone = phone;
this.email = email;
}
public String getId() { return this.id; }
public void setId(String id) { this.id = id; }
public String getName() { return this.name; } public String getName() { return this.name; }
public void setName(String name) { this.name = name; } public void setName(String name) { this.name = name; }
public Date getBirthday() { return this.birthday; } public Date getBirthday() { return this.birthday; }

View File

@ -1,34 +1,32 @@
package com.subd.subd.Models; package com.subd.subd.Models;
import jakarta.annotation.Nullable;
import jakarta.persistence.*; import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.DocumentReference;
import org.springframework.data.mongodb.core.mapping.Unwrapped;
import org.springframework.lang.Nullable;
import java.util.Date; import java.util.Date;
import java.util.Objects; import java.util.Objects;
@Entity @Document("Order")
@Table(name = "\"Order\"")
public class Order { public class Order {
@Id @Id
@GeneratedValue private String id;
private Long id;
private Double value; private Double value;
private String status; private String status;
private Date date; private Date date;
@ManyToOne( cascade = {CascadeType.MERGE}, fetch = FetchType.EAGER) @DocumentReference
@JoinColumn(name = "Client_id", nullable = true)
private Client client; private Client client;
@OneToOne() @DocumentReference
@JoinColumn(name = "sourcePickUpPoint_id", referencedColumnName = "id")
private PickUpPoint sourcePickUpPoint; private PickUpPoint sourcePickUpPoint;
@Nullable @DocumentReference
@OneToOne()
@JoinColumn(name = "destPickUpPoint_id", referencedColumnName = "id")
private PickUpPoint destPickUpPoint; private PickUpPoint destPickUpPoint;
@OneToOne() @DocumentReference
@JoinColumn(name = "Car_id", referencedColumnName = "id")
private Car car; private Car car;
Order() {} public Order() {}
public Order(Double value, String status, Date date, Client client, PickUpPoint sourcePickUpPoint, @Nullable PickUpPoint destPickUpPoint, Car car) { public Order(Double value, String status, Date date, Client client, PickUpPoint sourcePickUpPoint, @Nullable PickUpPoint destPickUpPoint, Car car) {
this.value = value; this.value = value;
this.status = status; this.status = status;
@ -38,10 +36,20 @@ public class Order {
this.destPickUpPoint = destPickUpPoint; this.destPickUpPoint = destPickUpPoint;
this.car = car; this.car = car;
} }
public Long getId() { public Order(String id, Double value, String status, Date date, Client client, PickUpPoint sourcePickUpPoint, @Nullable PickUpPoint destPickUpPoint, Car car) {
this.id = id;
this.value = value;
this.status = status;
this.date = date;
this.client = client;
this.sourcePickUpPoint = sourcePickUpPoint;
this.destPickUpPoint = destPickUpPoint;
this.car = car;
}
public String getId() {
return this.id; return this.id;
} }
public void setId(Long id) { public void setId(String id) {
this.id = id; this.id = id;
} }
public Double getValue() { public Double getValue() {

View File

@ -1,28 +1,31 @@
package com.subd.subd.Models; package com.subd.subd.Models;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import java.util.Objects; import java.util.Objects;
import jakarta.persistence.*; @Document("PickUpPoint")
@Entity
@Table(name = "PickUpPoint")
public class PickUpPoint { public class PickUpPoint {
@Id @Id
@GeneratedValue private String id;
private Long id;
@Column(unique=true)
private String address; private String address;
PickUpPoint() {} public PickUpPoint() {}
public PickUpPoint(String address) { public PickUpPoint(String address) {
this.address = address; this.address = address;
} }
public Long getId() { public PickUpPoint(String id, String address) {
this.id = id;
this.address = address;
}
public String getId() {
return this.id; return this.id;
} }
public String getAddress() { public String getAddress() {
return this.address; return this.address;
} }
public void setId(Long id) { public void setId(String id) {
this.id = id; this.id = id;
} }
public void setAddress(String address) { public void setAddress(String address) {

View File

@ -1,7 +1,7 @@
package com.subd.subd.Repositories; package com.subd.subd.Repositories;
import com.subd.subd.Models.Car; import com.subd.subd.Models.Car;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.mongodb.repository.MongoRepository;
public interface CarRepository extends JpaRepository<Car, Long> { public interface CarRepository extends MongoRepository<Car, String> {
} }

View File

@ -1,7 +1,7 @@
package com.subd.subd.Repositories; package com.subd.subd.Repositories;
import com.subd.subd.Models.Client; import com.subd.subd.Models.Client;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.mongodb.repository.MongoRepository;
public interface ClientRepository extends JpaRepository<Client, Long> { public interface ClientRepository extends MongoRepository<Client, String> {
} }

View File

@ -1,7 +1,7 @@
package com.subd.subd.Repositories; package com.subd.subd.Repositories;
import com.subd.subd.Models.Driver; import com.subd.subd.Models.Driver;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.mongodb.repository.MongoRepository;
public interface DriverRepository extends JpaRepository<Driver, Long> { public interface DriverRepository extends MongoRepository<Driver, String> {
} }

View File

@ -1,21 +1,23 @@
package com.subd.subd.Repositories; package com.subd.subd.Repositories;
import com.subd.subd.Models.Order; import com.subd.subd.Models.Order;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.mongodb.repository.Query;
import org.springframework.data.repository.query.Param; import org.springframework.data.repository.query.Param;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
public interface OrderRepository extends JpaRepository<Order, Long> { public interface OrderRepository extends MongoRepository<Order, String> {
@Query(value = "SELECT \"order\".ID, \"order\".DATE, \"order\".STATUS, \"car\".GOS_NUMBER, \"driver\".NAME as driver_name, \"client\".NAME as client_name\n" + @Query(value = """
"FROM \"order\"\n" + db.Order.find({date: {$gt: ISODate("2000-01-01")}, value: {$gt: 1}, status: "accepted"}).sort({date: 1}).forEach(function(order){
"JOIN CAR ON CAR.ID = \"order\".CAR_ID\n" + var client = db.Client.findOne({_id: order.client});
"JOIN DRIVER ON CAR.DRIVER_ID = DRIVER.ID\n" + var car=db.Car.findOne({_id: order.car});
"JOIN CLIENT ON CLIENT.ID = \"order\".CLIENT_ID\n" + car.driver = db.Driver.findOne({_id: car.driver});
"WHERE \"order\".DATE > :date AND \"order\".VALUE > :value AND \"order\".STATUS like :status\n" + var sourcePickUpPoint = db.PickUpPoint.findOne({_id: order.sourcePickUpPoint});
"ORDER BY :orderBy", nativeQuery = true) var destPickUpPoint = db.PickUpPoint.findOne({_id: order.destPickUpPoint});
print(order._id, order.value, order.status, order.date, client, car, sourcePickUpPoint, destPickUpPoint);
})""")
List<Object> customAction(@Param("date") Date date, List<Object> customAction(@Param("date") Date date,
@Param("value") Double value, @Param("value") Double value,
@Param("status") String status, @Param("status") String status,

View File

@ -1,7 +1,7 @@
package com.subd.subd.Repositories; package com.subd.subd.Repositories;
import com.subd.subd.Models.PickUpPoint; import com.subd.subd.Models.PickUpPoint;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.mongodb.repository.MongoRepository;
public interface PickUpPointRepository extends JpaRepository<PickUpPoint, Long> { public interface PickUpPointRepository extends MongoRepository<PickUpPoint, String> {
} }

View File

@ -21,14 +21,21 @@ public class CarService {
this.driverRepository = driverRepository; this.driverRepository = driverRepository;
} }
@Transactional @Transactional
public Car addCar(String gosNumber, String vin, Long driverId) { public Car addCar(String gosNumber, String vin, String driverId) {
final Driver driver = driverRepository.findById(driverId) final Driver driver = driverRepository.findById(driverId)
.orElseThrow(() -> new DriverNotFoundException(driverId)); .orElseThrow(() -> new DriverNotFoundException(driverId));
final Car car = new Car(gosNumber, vin, driver); final Car car = new Car(gosNumber, vin, driver);
return carRepository.save(car); return carRepository.save(car);
} }
@Transactional
public Car addCarWithId(String id, String gosNumber, String vin, String driverId) {
final Driver driver = driverRepository.findById(driverId)
.orElseThrow(() -> new DriverNotFoundException(driverId));
final Car car = new Car(id, gosNumber, vin, driver);
return carRepository.save(car);
}
@Transactional(readOnly = true) @Transactional(readOnly = true)
public Car findCar(Long id) { public Car findCar(String id) {
final Optional<Car> car = carRepository.findById(id); final Optional<Car> car = carRepository.findById(id);
return car.orElseThrow(() -> new CarNotFoundException(id)); return car.orElseThrow(() -> new CarNotFoundException(id));
} }
@ -37,7 +44,7 @@ public class CarService {
return carRepository.findAll(); return carRepository.findAll();
} }
@Transactional @Transactional
public Car updateCar(Long id, String gosNumber, String vin, Long driverId) { public Car updateCar(String id, String gosNumber, String vin, String driverId) {
final Car currentCar = findCar(id); final Car currentCar = findCar(id);
if (gosNumber != null) { if (gosNumber != null) {
currentCar.setGosNumber(gosNumber); currentCar.setGosNumber(gosNumber);
@ -53,13 +60,13 @@ public class CarService {
return carRepository.save(currentCar); return carRepository.save(currentCar);
} }
@Transactional @Transactional
public Driver getDriver(Long carId) { public Driver getDriver(String carId) {
Car currentCar = carRepository.findById(carId) Car currentCar = carRepository.findById(carId)
.orElseThrow(() -> new CarNotFoundException(carId)); .orElseThrow(() -> new CarNotFoundException(carId));
return currentCar.getDriver(); return currentCar.getDriver();
} }
@Transactional @Transactional
public void setDriver(Long carId, Long driverId) { public void setDriver(String carId, String driverId) {
Car currentCar = carRepository.findById(carId) Car currentCar = carRepository.findById(carId)
.orElseThrow(() -> new CarNotFoundException(carId)); .orElseThrow(() -> new CarNotFoundException(carId));
Driver driver = driverRepository.findById(driverId) Driver driver = driverRepository.findById(driverId)
@ -67,7 +74,7 @@ public class CarService {
currentCar.setDriver(driver); currentCar.setDriver(driver);
} }
@Transactional @Transactional
public Car deleteCar(Long id) { public Car deleteCar(String id) {
final Car currentCar = findCar(id); final Car currentCar = findCar(id);
carRepository.delete(currentCar); carRepository.delete(currentCar);
return currentCar; return currentCar;

View File

@ -20,8 +20,13 @@ public class ClientService {
final Client client = new Client(name, phone, email); final Client client = new Client(name, phone, email);
return clientRepository.save(client); return clientRepository.save(client);
} }
@Transactional
public Client addClientWithId(String id, String name, String phone, String email) {
final Client client = new Client(id, name, phone, email);
return clientRepository.save(client);
}
@Transactional(readOnly = true) @Transactional(readOnly = true)
public Client findClient(Long id) { public Client findClient(String id) {
final Optional<Client> client = clientRepository.findById(id); final Optional<Client> client = clientRepository.findById(id);
return client.orElseThrow(() -> new ClientNotFoundException(id)); return client.orElseThrow(() -> new ClientNotFoundException(id));
} }
@ -30,7 +35,7 @@ public class ClientService {
return clientRepository.findAll(); return clientRepository.findAll();
} }
@Transactional @Transactional
public Client updateClient(Long id, String name, String phone, String email) { public Client updateClient(String id, String name, String phone, String email) {
final Client currentClient = findClient(id); final Client currentClient = findClient(id);
if (name != null) { if (name != null) {
currentClient.setName(name); currentClient.setName(name);
@ -44,7 +49,7 @@ public class ClientService {
return clientRepository.save(currentClient); return clientRepository.save(currentClient);
} }
@Transactional @Transactional
public Client deleteClient(Long id) { public Client deleteClient(String id) {
final Client currentClient = findClient(id); final Client currentClient = findClient(id);
clientRepository.delete(currentClient); clientRepository.delete(currentClient);
return currentClient; return currentClient;

View File

@ -21,8 +21,13 @@ public class DriverService {
final Driver driver = new Driver(name, birthday, phone, email); final Driver driver = new Driver(name, birthday, phone, email);
return driverRepository.save(driver); return driverRepository.save(driver);
} }
@Transactional
public Driver addDriverWithId(String id, String name, Date birthday, String phone, String email) {
final Driver driver = new Driver(id, name, birthday, phone, email);
return driverRepository.save(driver);
}
@Transactional(readOnly = true) @Transactional(readOnly = true)
public Driver findDriver(Long id) { public Driver findDriver(String id) {
final Optional<Driver> driver = driverRepository.findById(id); final Optional<Driver> driver = driverRepository.findById(id);
return driver.orElseThrow(() -> new DriverNotFoundException(id)); return driver.orElseThrow(() -> new DriverNotFoundException(id));
} }
@ -31,7 +36,7 @@ public class DriverService {
return driverRepository.findAll(); return driverRepository.findAll();
} }
@Transactional @Transactional
public Driver updateDriver(Long id, String name, Date birthday, String phone, String email) { public Driver updateDriver(String id, String name, Date birthday, String phone, String email) {
final Driver currentDriver = findDriver(id); final Driver currentDriver = findDriver(id);
if (name != null) { if (name != null) {
currentDriver.setName(name); currentDriver.setName(name);
@ -48,7 +53,7 @@ public class DriverService {
return driverRepository.save(currentDriver); return driverRepository.save(currentDriver);
} }
@Transactional @Transactional
public Driver deleteDriver(Long id) { public Driver deleteDriver(String id) {
final Driver currentDriver = findDriver(id); final Driver currentDriver = findDriver(id);
driverRepository.delete(currentDriver); driverRepository.delete(currentDriver);
return currentDriver; return currentDriver;

View File

@ -31,7 +31,7 @@ public class OrderService {
this.carRepository = carRepository; this.carRepository = carRepository;
} }
@Transactional @Transactional
public Order addOrder(Double value, String status, Date date, Long clientId, Long sourcePickUpPointId, @Nullable Long destPickUpPointId, Long carId) { public Order addOrder(Double value, String status, Date date, String clientId, String sourcePickUpPointId, @Nullable String destPickUpPointId, String carId) {
final Client client = clientRepository.findById(clientId) final Client client = clientRepository.findById(clientId)
.orElseThrow(() -> new ClientNotFoundException(clientId)); .orElseThrow(() -> new ClientNotFoundException(clientId));
final PickUpPoint sourcePickUpPoint = pickUpPointRepository.findById(sourcePickUpPointId) final PickUpPoint sourcePickUpPoint = pickUpPointRepository.findById(sourcePickUpPointId)
@ -48,8 +48,26 @@ public class OrderService {
} }
return orderRepository.save(order); return orderRepository.save(order);
} }
@Transactional
public Order addOrderWithId(String id, Double value, String status, Date date, String clientId, String sourcePickUpPointId, @Nullable String destPickUpPointId, String carId) {
final Client client = clientRepository.findById(clientId)
.orElseThrow(() -> new ClientNotFoundException(clientId));
final PickUpPoint sourcePickUpPoint = pickUpPointRepository.findById(sourcePickUpPointId)
.orElseThrow(() -> new PickUpPointNotFoundException(sourcePickUpPointId));
final Car car = carRepository.findById(carId)
.orElseThrow(() -> new CarNotFoundException(carId));
final Order order;
if (destPickUpPointId != null) {
final PickUpPoint destPickUpPoint = pickUpPointRepository.findById(destPickUpPointId)
.orElseThrow(() -> new PickUpPointNotFoundException(destPickUpPointId));
order = new Order(id, value, status, date, client, sourcePickUpPoint, destPickUpPoint, car);
} else {
order = new Order(id, value, status, date, client, sourcePickUpPoint, null, car);
}
return orderRepository.save(order);
}
@Transactional(readOnly = true) @Transactional(readOnly = true)
public Order findOrder(Long id) { public Order findOrder(String id) {
final Optional<Order> order = orderRepository.findById(id); final Optional<Order> order = orderRepository.findById(id);
return order.orElseThrow(() -> new OrderNotFoundException(id)); return order.orElseThrow(() -> new OrderNotFoundException(id));
} }
@ -58,7 +76,7 @@ public class OrderService {
return orderRepository.findAll(); return orderRepository.findAll();
} }
@Transactional(readOnly = true) @Transactional(readOnly = true)
public List<Order> findfilteredOrders(Long id, Double value, String status, Date date, Long clientId, Long sourcePickUpPointId, Long destPickUpPointId, Long carId) { public List<Order> findfilteredOrders(String id, Double value, String status, Date date, String clientId, String sourcePickUpPointId, String destPickUpPointId, String carId) {
List<Order> allOrders = orderRepository.findAll(); List<Order> allOrders = orderRepository.findAll();
List<Order> result = new ArrayList<>(); List<Order> result = new ArrayList<>();
for (Order order : allOrders) { for (Order order : allOrders) {
@ -95,7 +113,7 @@ public class OrderService {
return result; return result;
} }
@Transactional @Transactional
public Order updateOrder(Long id, Double value, String status, Date date, Long clientId, Long sourcePickUpPointId, Long destPickUpPointId, Long carId) { public Order updateOrder(String id, Double value, String status, Date date, String clientId, String sourcePickUpPointId, String destPickUpPointId, String carId) {
final Order currentOrder = findOrder(id); final Order currentOrder = findOrder(id);
if (value != null) { if (value != null) {
currentOrder.setValue(value); currentOrder.setValue(value);
@ -129,7 +147,7 @@ public class OrderService {
return orderRepository.save(currentOrder); return orderRepository.save(currentOrder);
} }
@Transactional @Transactional
public Order deleteOrder(Long id) { public Order deleteOrder(String id) {
final Order currentOrder = findOrder(id); final Order currentOrder = findOrder(id);
orderRepository.delete(currentOrder); orderRepository.delete(currentOrder);
return currentOrder; return currentOrder;

View File

@ -20,8 +20,13 @@ public class PickUpPointService {
final PickUpPoint pickUpPoint = new PickUpPoint(address); final PickUpPoint pickUpPoint = new PickUpPoint(address);
return pickUpPointRepository.save(pickUpPoint); return pickUpPointRepository.save(pickUpPoint);
} }
@Transactional
public PickUpPoint addPickUpPointWithId(String id, String address) {
final PickUpPoint pickUpPoint = new PickUpPoint(id, address);
return pickUpPointRepository.save(pickUpPoint);
}
@Transactional(readOnly = true) @Transactional(readOnly = true)
public PickUpPoint findPickUpPoint(Long id) { public PickUpPoint findPickUpPoint(String id) {
final Optional<PickUpPoint> pickUpPoint = pickUpPointRepository.findById(id); final Optional<PickUpPoint> pickUpPoint = pickUpPointRepository.findById(id);
return pickUpPoint.orElseThrow(() -> new PickUpPointNotFoundException(id)); return pickUpPoint.orElseThrow(() -> new PickUpPointNotFoundException(id));
} }
@ -30,7 +35,7 @@ public class PickUpPointService {
return pickUpPointRepository.findAll(); return pickUpPointRepository.findAll();
} }
@Transactional @Transactional
public PickUpPoint updatePickUpPoint(Long id, String address) { public PickUpPoint updatePickUpPoint(String id, String address) {
final PickUpPoint currentPickUpPoint = findPickUpPoint(id); final PickUpPoint currentPickUpPoint = findPickUpPoint(id);
if (address != null) { if (address != null) {
currentPickUpPoint.setAddress(address); currentPickUpPoint.setAddress(address);
@ -38,7 +43,7 @@ public class PickUpPointService {
return pickUpPointRepository.save(currentPickUpPoint); return pickUpPointRepository.save(currentPickUpPoint);
} }
@Transactional @Transactional
public PickUpPoint deletePickUpPoint(Long id) { public PickUpPoint deletePickUpPoint(String id) {
final PickUpPoint currentPickUpPoint = findPickUpPoint(id); final PickUpPoint currentPickUpPoint = findPickUpPoint(id);
pickUpPointRepository.delete(currentPickUpPoint); pickUpPointRepository.delete(currentPickUpPoint);
return currentPickUpPoint; return currentPickUpPoint;

View File

@ -1,10 +1,24 @@
package com.subd.subd; package com.subd.subd;
import com.subd.subd.Repositories.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
@SpringBootApplication @SpringBootApplication
@EnableMongoRepositories
public class SubdApplication { public class SubdApplication {
@Autowired
CarRepository carRepository;
@Autowired
ClientRepository clientRepository;
@Autowired
DriverRepository driverRepository;
@Autowired
OrderRepository orderRepository;
@Autowired
PickUpPointRepository pickUpPointRepository;
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(SubdApplication.class, args); SpringApplication.run(SubdApplication.class, args);
} }

View File

@ -1,7 +1,9 @@
spring.jpa.hibernate.ddl-auto=create #spring.jpa.hibernate.ddl-auto=update
spring.sql.init.mode=always #spring.sql.init.mode=always
spring.sql.init.platform=postgres #spring.sql.init.platform=postgres
spring.datasource.url=jdbc:postgresql://192.168.31.77:5432/yan #spring.datasource.url=jdbc:postgresql://192.168.0.177:5432/yan
spring.datasource.username=yan #spring.datasource.username=yan
spring.datasource.password=250303zyzf #spring.datasource.password=250303zyzf
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true #spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
spring.data.mongodb.uri=mongodb://192.168.43.105:27017/yan
spring.data.mongodb.database=yan

View File

@ -42,7 +42,7 @@
let count = document.getElementById('measureCount').value; let count = document.getElementById('measureCount').value;
this.wholeTime = 0; this.wholeTime = 0;
for (let i = 0; i < count; i++) { for (let i = 0; i < count; i++) {
const response = axios.get("http://localhost:8080/custom?date=2023-2-1&value=1000&status=delivered&orderBy=date") const response = axios.get("http://localhost:8080/custom?date=2000-2-1&value=1000&status=delivered&orderBy=date")
.then(data => { .then(data => {
this.wholeTime += data.data; this.wholeTime += data.data;
}); });

31
test.py
View File

@ -1,31 +0,0 @@
import json
import requests
urls = ["client", "driver", "pickUpPoint", "car", "order"]
for name in urls:
x = json.loads(requests.get(f'http://localhost:8081/{name}').content.decode('utf-8'))
for el in x:
if (name == "car"):
el["driverId"] = el["driver"]["id"];
y = requests.post(f'http://localhost:8080/{name}WithId', json = el)
if (y.status_code == 200):
print("ok")
else:
print("error")
elif (name == "order"):
el["carId"] = el["car"]["id"];
el["clientId"] = el["client"]["id"];
el["sourcePickUpPointId"] = el["sourcePickUpPoint"]["id"];
el["destPickUpPointId"] = el["destPickUpPoint"]["id"];
y = requests.post(f'http://localhost:8080/{name}WithId', json = el)
if (y.status_code == 200):
print("ok")
else:
print("error")
else:
y = requests.post(f'http://localhost:8080/{name}WithId', json = el)
if (y.status_code == 200):
print("ok")
else:
print("error")