some add
This commit is contained in:
parent
096476287f
commit
815f40af70
@ -0,0 +1,20 @@
|
||||
package com.subd.subd.Controllers;
|
||||
|
||||
import com.subd.subd.Models.Order;
|
||||
import com.subd.subd.Repositories.OrderRepository;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
public class CustomRequest {
|
||||
private final OrderRepository orderRepository;
|
||||
public CustomRequest(OrderRepository orderRepository) {
|
||||
this.orderRepository = orderRepository;
|
||||
}
|
||||
@GetMapping("/custom")
|
||||
public List<Order> performCustomRequest() {
|
||||
return orderRepository.customAction();
|
||||
}
|
||||
}
|
@ -2,6 +2,17 @@ package com.subd.subd.Repositories;
|
||||
|
||||
import com.subd.subd.Models.Order;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface OrderRepository extends JpaRepository<Order, Long> {
|
||||
// @Query(value = "SELECT \"ORDER\".ID, \"ORDER\".DATE, \"ORDER\".STATUS, \"CAR\".GOS_NUMBER, \"DRIVER\".NAME as driver_name, \"CLIENT\".NAME as client_name FROM \"order\" " +
|
||||
// "JOIN \"CAR\" ON CAR.ID = \"ORDER\".CAR_ID " +
|
||||
// "JOIN \"DRIVER\" ON \"CAR\".DRIVER_ID = \"DRIVER\".ID " +
|
||||
// "JOIN \"CLIENT\" ON \"CLIENT\".ID = \"ORDER\".CLIENT_ID " +
|
||||
// "WHERE \"ORDER\".DATE > '2000-01-01' AND \"ORDER\".VALUE > 10000 AND \"ORDER\".STATUS like 'delivered' " +
|
||||
// "ORDER BY DATE", nativeQuery = true)
|
||||
@Query(value = "SELECT * FROM \"order\"", nativeQuery = true)
|
||||
List<Order> customAction();
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
spring.jpa.hibernate.ddl-auto=none
|
||||
spring.jpa.hibernate.ddl-auto=create
|
||||
spring.datasource.initialization-mode=always
|
||||
spring.datasource.platform=postgres
|
||||
spring.datasource.url=jdbc:postgresql://109.197.199.134:5432/subd
|
||||
spring.datasource.username=postgres
|
||||
spring.datasource.password=250303Zyzf-d-grad
|
||||
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=false
|
||||
spring.datasource.url=jdbc:postgresql://192.168.43.105:5432/subd
|
||||
spring.datasource.username=yan
|
||||
spring.datasource.password=250303zyzf
|
||||
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
|
@ -7,6 +7,7 @@
|
||||
<title>Vite App</title>
|
||||
</head>
|
||||
<body>
|
||||
<script type="module" src="/node_modules/jquery/dist/jquery.min.js"></script>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/node_modules/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script type="module" src="/src/main.js"></script>
|
||||
|
6
SUBD-front/package-lock.json
generated
6
SUBD-front/package-lock.json
generated
@ -11,6 +11,7 @@
|
||||
"axios": "^1.3.6",
|
||||
"bootstrap": "^5.2.3",
|
||||
"email-generator": "^1.0.1",
|
||||
"jquery": "^3.6.4",
|
||||
"vue": "^3.2.47",
|
||||
"vue-router": "^4.1.6"
|
||||
},
|
||||
@ -1410,6 +1411,11 @@
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/jquery": {
|
||||
"version": "3.6.4",
|
||||
"resolved": "https://registry.npmjs.org/jquery/-/jquery-3.6.4.tgz",
|
||||
"integrity": "sha512-v28EW9DWDFpzcD9O5iyJXg3R3+q+mET5JhnjJzQUZMHOv67bpSIHq81GEYpPNZHG+XXHsfSme3nxp/hndKEcsQ=="
|
||||
},
|
||||
"node_modules/js-tokens": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
|
||||
|
@ -11,6 +11,7 @@
|
||||
"axios": "^1.3.6",
|
||||
"bootstrap": "^5.2.3",
|
||||
"email-generator": "^1.0.1",
|
||||
"jquery": "^3.6.4",
|
||||
"vue": "^3.2.47",
|
||||
"vue-router": "^4.1.6"
|
||||
},
|
||||
|
@ -32,7 +32,7 @@
|
||||
if (data == "inDelivery") {
|
||||
return "В пути";
|
||||
}
|
||||
if (data == "delvered") {
|
||||
if (data == "delivered") {
|
||||
return "Доставлен";
|
||||
}
|
||||
if (data == "issued") {
|
||||
|
@ -1,4 +1,3 @@
|
||||
<!-- const emails = require('email-generator'); -->
|
||||
<script>
|
||||
import DataService from '../services/DataService';
|
||||
import Client from '../models/Client';
|
||||
@ -127,7 +126,6 @@
|
||||
this.data = [];
|
||||
this.transformer = (data) => new Car(data);
|
||||
this.data = this.transformer();
|
||||
console.log(this.data)
|
||||
for (let i = 0; i < count; i++) {
|
||||
this.data.gosNumber = generateString(6);
|
||||
this.data.vin = generateString(25);
|
||||
|
27
SUBD-front/src/components/MeasureTime.vue
Normal file
27
SUBD-front/src/components/MeasureTime.vue
Normal file
@ -0,0 +1,27 @@
|
||||
<script>
|
||||
export default {
|
||||
methods: {
|
||||
customRequest() {
|
||||
// let dataUrlPrefix = 'http://localhost:8080/';
|
||||
// const response = axios.get(this.dataUrlPrefix + 'custom');
|
||||
// response.data.map(item => console.log(item));
|
||||
$.ajax({
|
||||
url: "/src/database.php",
|
||||
type: 'get',
|
||||
data: {request: 'fetchall'},
|
||||
dataType: 'json',
|
||||
success: function (response) {
|
||||
document.getElementsByClassName('input-group')[0].innerHTML(response);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="input-group mb-3">
|
||||
<input type="text" class="form-control" required id="clientCount" placeholder="Количество клиентов">
|
||||
<button class="btn btn-primary" type="button" @click.prevent="customRequest">Сгенерировать</button>
|
||||
</div>
|
||||
</template>
|
79
SUBD-front/src/database.php
Normal file
79
SUBD-front/src/database.php
Normal file
@ -0,0 +1,79 @@
|
||||
<p>
|
||||
<?php
|
||||
|
||||
$host = "192.168.43.105";
|
||||
$user = "yan";
|
||||
$password = "250303zyzf";
|
||||
$dbname = "subd";
|
||||
$con = pg_connect("host=$host dbname=$dbname user=$user password=$password");
|
||||
|
||||
if (!$con) {
|
||||
die('Connection failed.');
|
||||
}
|
||||
|
||||
$request = "";
|
||||
if(isset($_POST['request'])){
|
||||
$request = $_POST['request'];
|
||||
}
|
||||
|
||||
// Fetch all records
|
||||
if($request == 'fetchall'){
|
||||
|
||||
$query = "SELECT "order".ID, "order".DATE, "order".STATUS, "car".GOS_NUMBER, "driver".NAME as driver_name, "client".NAME as client_name FROM "order" JOIN CAR ON CAR.ID = "order".CAR_ID JOIN DRIVER ON CAR.DRIVER_ID = DRIVER.ID JOIN CLIENT ON CLIENT.ID = "order".CLIENT_ID WHERE "order".DATE > '2000-01-01' AND "order".VALUE > 10000 AND "order".STATUS like 'delivered' ORDER BY date;";
|
||||
|
||||
$result = pg_query($con, $query);
|
||||
|
||||
$response = array();
|
||||
|
||||
while ($row = pg_fetch_assoc($result) ){
|
||||
|
||||
$id = $row['id'];
|
||||
$username = $row['username'];
|
||||
$fullname = $row['fullname'];
|
||||
$email = $row['email'];
|
||||
|
||||
$response[] = array(
|
||||
"id" => $id,
|
||||
"username" => $username,
|
||||
"fullname" => $fullname,
|
||||
"email" => $email,
|
||||
);
|
||||
}
|
||||
|
||||
echo json_encode($response);
|
||||
die;
|
||||
}
|
||||
|
||||
// Fetch record by id
|
||||
if($request == 'fetchbyid'){
|
||||
|
||||
$userid = 0;
|
||||
if(isset($_POST['userid']) && is_numeric($_POST['userid']) ){
|
||||
$userid = $_POST['userid'];
|
||||
}
|
||||
|
||||
$query = "SELECT * FROM users WHERE id=".$userid;
|
||||
$result = pg_query($con, $query);
|
||||
|
||||
$response = array();
|
||||
if (pg_numrows($result) > 0) {
|
||||
|
||||
$row = pg_fetch_assoc($result);
|
||||
|
||||
$id = $row['id'];
|
||||
$username = $row['username'];
|
||||
$fullname = $row['fullname'];
|
||||
$email = $row['email'];
|
||||
|
||||
$response[] = array(
|
||||
"id" => $id,
|
||||
"username" => $username,
|
||||
"fullname" => $fullname,
|
||||
"email" => $email,
|
||||
);
|
||||
}
|
||||
|
||||
echo json_encode($response);
|
||||
die;
|
||||
}
|
||||
</p>
|
@ -4,11 +4,13 @@ import './style.css'
|
||||
import App from './App.vue'
|
||||
import Orders from './components/Orders.vue'
|
||||
import Generator from './components/Generator.vue'
|
||||
import MeasureTime from './components/MeasureTime.vue'
|
||||
|
||||
const routes = [
|
||||
{ path: '/', redirect: '/orders' },
|
||||
{ path: '/orders', component: Orders, meta: { label: 'Заказы' }},
|
||||
{ path: '/generator', component: Generator, meta: { label: 'Генератор' }}
|
||||
{ path: '/generator', component: Generator, meta: { label: 'Генератор' }},
|
||||
{ path: '/measureTime', component: MeasureTime, meta: { label: 'Замер времени' }}
|
||||
]
|
||||
|
||||
const router = createRouter({
|
||||
|
Loading…
x
Reference in New Issue
Block a user