LabWork04 33
This commit is contained in:
parent
98d5474e3c
commit
5d16b4a2cd
@ -6,7 +6,7 @@ plugins {
|
|||||||
|
|
||||||
group = 'ru.ulstu.is'
|
group = 'ru.ulstu.is'
|
||||||
version = '0.0.1-SNAPSHOT'
|
version = '0.0.1-SNAPSHOT'
|
||||||
sourceCompatibility = '17'
|
sourceCompatibility = '19'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
@ -21,7 +21,7 @@ dependencies {
|
|||||||
|
|
||||||
implementation group: 'org.springdoc', name: 'springdoc-openapi-ui', version: '1.6.5'
|
implementation group: 'org.springdoc', name: 'springdoc-openapi-ui', version: '1.6.5'
|
||||||
|
|
||||||
implementation 'org.hibernate.validator:hibernate-validator:7.0.1.Final'
|
implementation 'org.hibernate.validator:hibernate-validator:6.0.17.Final'
|
||||||
|
|
||||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||||
}
|
}
|
||||||
|
@ -1,46 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<link rel="stylesheet" href="./node_modules/bootstrap/dist/css/bootstrap.min.css">
|
|
||||||
<title>Document</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<form class="" id="form">
|
|
||||||
<h2>Калькулятор</h2>
|
|
||||||
<div class="container row">
|
|
||||||
<div class="form-group col-3">
|
|
||||||
<label>num1</label>
|
|
||||||
<input name="num1" class="form-control col-3" placeholder="Первый аргумент">
|
|
||||||
</div>
|
|
||||||
<div class="form-group col-3">
|
|
||||||
<label>Оператор</label>
|
|
||||||
<select name="selected" id="inputState" class="form-control">
|
|
||||||
<option selected>+</option>
|
|
||||||
<option>-</option>
|
|
||||||
<option>*</option>
|
|
||||||
<option>/</option>
|
|
||||||
</select>
|
|
||||||
<label>Тип данных</label>
|
|
||||||
<select name="type" class="form-control">
|
|
||||||
<option selected>Int</option>
|
|
||||||
<option>String</option>
|
|
||||||
<option>FloatArray</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div class="form-group col-3">
|
|
||||||
<label>num2</label>
|
|
||||||
<input name="num2" type="number" class="form-control col-3" placeholder="Второй аргумент">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<button type="submit" class="btn btn-primary m-3">Посчитать</button>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<h2 class="text" id="res"></h2>
|
|
||||||
|
|
||||||
<script src="./node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
|
|
||||||
<script src="../js/script.js"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,59 +0,0 @@
|
|||||||
let form = document.getElementById("form");
|
|
||||||
let info = document.getElementById("res");
|
|
||||||
|
|
||||||
|
|
||||||
form.onsubmit = async (e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
if(form.num1.value === "") return;
|
|
||||||
if(form.num2.value === "") return;
|
|
||||||
|
|
||||||
let index = form.selected.selectedIndex;
|
|
||||||
let indexType = form.type.selectedIndex;
|
|
||||||
|
|
||||||
let op = form.selected.options[index].textContent;
|
|
||||||
let type = form.type.options[indexType].textContent;
|
|
||||||
let res = "";
|
|
||||||
|
|
||||||
function calc() {
|
|
||||||
switch(op) {
|
|
||||||
case "+":
|
|
||||||
return "sum";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "-":
|
|
||||||
return "diff";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "*":
|
|
||||||
return "mul";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "/":
|
|
||||||
return "div";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function typeOfCalc() {
|
|
||||||
switch(type) {
|
|
||||||
case "Int":
|
|
||||||
return "int";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "String":
|
|
||||||
return "string";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "FloatArray":
|
|
||||||
return "floatArray";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (form.num2.value == 0 && calc(op) == "divide") return;
|
|
||||||
res = await fetch(`http://localhost:8080/${calc()}?num1=${form.num1.value}&num2=${form.num2.value}&operationType=${typeOfCalc()}`)
|
|
||||||
res = await res.text();
|
|
||||||
|
|
||||||
info.textContent = res;
|
|
||||||
}
|
|
723
frontend/package-lock.json
generated
723
frontend/package-lock.json
generated
@ -1,723 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "frontend",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"lockfileVersion": 2,
|
|
||||||
"requires": true,
|
|
||||||
"packages": {
|
|
||||||
"": {
|
|
||||||
"name": "frontend",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"license": "ISC",
|
|
||||||
"dependencies": {
|
|
||||||
"bootstrap": "^5.2.3",
|
|
||||||
"http-server": "^14.1.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@popperjs/core": {
|
|
||||||
"version": "2.11.6",
|
|
||||||
"resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.6.tgz",
|
|
||||||
"integrity": "sha512-50/17A98tWUfQ176raKiOGXuYpLyyVMkxxG6oylzL3BPOlA6ADGdK7EYunSa4I064xerltq9TGXs8HmOk5E+vw==",
|
|
||||||
"peer": true,
|
|
||||||
"funding": {
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/popperjs"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/ansi-styles": {
|
|
||||||
"version": "4.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
|
|
||||||
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
|
|
||||||
"dependencies": {
|
|
||||||
"color-convert": "^2.0.1"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=8"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/async": {
|
|
||||||
"version": "2.6.4",
|
|
||||||
"resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz",
|
|
||||||
"integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==",
|
|
||||||
"dependencies": {
|
|
||||||
"lodash": "^4.17.14"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/basic-auth": {
|
|
||||||
"version": "2.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz",
|
|
||||||
"integrity": "sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg==",
|
|
||||||
"dependencies": {
|
|
||||||
"safe-buffer": "5.1.2"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.8"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/bootstrap": {
|
|
||||||
"version": "5.2.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.2.3.tgz",
|
|
||||||
"integrity": "sha512-cEKPM+fwb3cT8NzQZYEu4HilJ3anCrWqh3CHAok1p9jXqMPsPTBhU25fBckEJHJ/p+tTxTFTsFQGM+gaHpi3QQ==",
|
|
||||||
"funding": [
|
|
||||||
{
|
|
||||||
"type": "github",
|
|
||||||
"url": "https://github.com/sponsors/twbs"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/bootstrap"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"peerDependencies": {
|
|
||||||
"@popperjs/core": "^2.11.6"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/call-bind": {
|
|
||||||
"version": "1.0.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz",
|
|
||||||
"integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==",
|
|
||||||
"dependencies": {
|
|
||||||
"function-bind": "^1.1.1",
|
|
||||||
"get-intrinsic": "^1.0.2"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ljharb"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/chalk": {
|
|
||||||
"version": "4.1.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
|
|
||||||
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
|
|
||||||
"dependencies": {
|
|
||||||
"ansi-styles": "^4.1.0",
|
|
||||||
"supports-color": "^7.1.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=10"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/chalk/chalk?sponsor=1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/color-convert": {
|
|
||||||
"version": "2.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
|
|
||||||
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
|
|
||||||
"dependencies": {
|
|
||||||
"color-name": "~1.1.4"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=7.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/color-name": {
|
|
||||||
"version": "1.1.4",
|
|
||||||
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
|
|
||||||
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
|
|
||||||
},
|
|
||||||
"node_modules/corser": {
|
|
||||||
"version": "2.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/corser/-/corser-2.0.1.tgz",
|
|
||||||
"integrity": "sha512-utCYNzRSQIZNPIcGZdQc92UVJYAhtGAteCFg0yRaFm8f0P+CPtyGyHXJcGXnffjCybUCEx3FQ2G7U3/o9eIkVQ==",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.4.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/debug": {
|
|
||||||
"version": "3.2.7",
|
|
||||||
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz",
|
|
||||||
"integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==",
|
|
||||||
"dependencies": {
|
|
||||||
"ms": "^2.1.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/eventemitter3": {
|
|
||||||
"version": "4.0.7",
|
|
||||||
"resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz",
|
|
||||||
"integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw=="
|
|
||||||
},
|
|
||||||
"node_modules/follow-redirects": {
|
|
||||||
"version": "1.15.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz",
|
|
||||||
"integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==",
|
|
||||||
"funding": [
|
|
||||||
{
|
|
||||||
"type": "individual",
|
|
||||||
"url": "https://github.com/sponsors/RubenVerborgh"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">=4.0"
|
|
||||||
},
|
|
||||||
"peerDependenciesMeta": {
|
|
||||||
"debug": {
|
|
||||||
"optional": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/function-bind": {
|
|
||||||
"version": "1.1.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
|
|
||||||
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
|
|
||||||
},
|
|
||||||
"node_modules/get-intrinsic": {
|
|
||||||
"version": "1.2.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.0.tgz",
|
|
||||||
"integrity": "sha512-L049y6nFOuom5wGyRc3/gdTLO94dySVKRACj1RmJZBQXlbTMhtNIgkWkUHq+jYmZvKf14EW1EoJnnjbmoHij0Q==",
|
|
||||||
"dependencies": {
|
|
||||||
"function-bind": "^1.1.1",
|
|
||||||
"has": "^1.0.3",
|
|
||||||
"has-symbols": "^1.0.3"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ljharb"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/has": {
|
|
||||||
"version": "1.0.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
|
|
||||||
"integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
|
|
||||||
"dependencies": {
|
|
||||||
"function-bind": "^1.1.1"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.4.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/has-flag": {
|
|
||||||
"version": "4.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
|
|
||||||
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=8"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/has-symbols": {
|
|
||||||
"version": "1.0.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz",
|
|
||||||
"integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.4"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ljharb"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/he": {
|
|
||||||
"version": "1.2.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz",
|
|
||||||
"integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==",
|
|
||||||
"bin": {
|
|
||||||
"he": "bin/he"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/html-encoding-sniffer": {
|
|
||||||
"version": "3.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-3.0.0.tgz",
|
|
||||||
"integrity": "sha512-oWv4T4yJ52iKrufjnyZPkrN0CH3QnrUqdB6In1g5Fe1mia8GmF36gnfNySxoZtxD5+NmYw1EElVXiBk93UeskA==",
|
|
||||||
"dependencies": {
|
|
||||||
"whatwg-encoding": "^2.0.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=12"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/http-proxy": {
|
|
||||||
"version": "1.18.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/http-proxy/-/http-proxy-1.18.1.tgz",
|
|
||||||
"integrity": "sha512-7mz/721AbnJwIVbnaSv1Cz3Am0ZLT/UBwkC92VlxhXv/k/BBQfM2fXElQNC27BVGr0uwUpplYPQM9LnaBMR5NQ==",
|
|
||||||
"dependencies": {
|
|
||||||
"eventemitter3": "^4.0.0",
|
|
||||||
"follow-redirects": "^1.0.0",
|
|
||||||
"requires-port": "^1.0.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=8.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/http-server": {
|
|
||||||
"version": "14.1.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/http-server/-/http-server-14.1.1.tgz",
|
|
||||||
"integrity": "sha512-+cbxadF40UXd9T01zUHgA+rlo2Bg1Srer4+B4NwIHdaGxAGGv59nYRnGGDJ9LBk7alpS0US+J+bLLdQOOkJq4A==",
|
|
||||||
"dependencies": {
|
|
||||||
"basic-auth": "^2.0.1",
|
|
||||||
"chalk": "^4.1.2",
|
|
||||||
"corser": "^2.0.1",
|
|
||||||
"he": "^1.2.0",
|
|
||||||
"html-encoding-sniffer": "^3.0.0",
|
|
||||||
"http-proxy": "^1.18.1",
|
|
||||||
"mime": "^1.6.0",
|
|
||||||
"minimist": "^1.2.6",
|
|
||||||
"opener": "^1.5.1",
|
|
||||||
"portfinder": "^1.0.28",
|
|
||||||
"secure-compare": "3.0.1",
|
|
||||||
"union": "~0.5.0",
|
|
||||||
"url-join": "^4.0.1"
|
|
||||||
},
|
|
||||||
"bin": {
|
|
||||||
"http-server": "bin/http-server"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=12"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/iconv-lite": {
|
|
||||||
"version": "0.6.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
|
|
||||||
"integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==",
|
|
||||||
"dependencies": {
|
|
||||||
"safer-buffer": ">= 2.1.2 < 3.0.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=0.10.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/lodash": {
|
|
||||||
"version": "4.17.21",
|
|
||||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
|
||||||
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
|
|
||||||
},
|
|
||||||
"node_modules/mime": {
|
|
||||||
"version": "1.6.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
|
|
||||||
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
|
|
||||||
"bin": {
|
|
||||||
"mime": "cli.js"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=4"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/minimist": {
|
|
||||||
"version": "1.2.8",
|
|
||||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz",
|
|
||||||
"integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==",
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ljharb"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/mkdirp": {
|
|
||||||
"version": "0.5.6",
|
|
||||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz",
|
|
||||||
"integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==",
|
|
||||||
"dependencies": {
|
|
||||||
"minimist": "^1.2.6"
|
|
||||||
},
|
|
||||||
"bin": {
|
|
||||||
"mkdirp": "bin/cmd.js"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/ms": {
|
|
||||||
"version": "2.1.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
|
||||||
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
|
|
||||||
},
|
|
||||||
"node_modules/object-inspect": {
|
|
||||||
"version": "1.12.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.3.tgz",
|
|
||||||
"integrity": "sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g==",
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ljharb"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/opener": {
|
|
||||||
"version": "1.5.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/opener/-/opener-1.5.2.tgz",
|
|
||||||
"integrity": "sha512-ur5UIdyw5Y7yEj9wLzhqXiy6GZ3Mwx0yGI+5sMn2r0N0v3cKJvUmFH5yPP+WXh9e0xfyzyJX95D8l088DNFj7A==",
|
|
||||||
"bin": {
|
|
||||||
"opener": "bin/opener-bin.js"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/portfinder": {
|
|
||||||
"version": "1.0.32",
|
|
||||||
"resolved": "https://registry.npmjs.org/portfinder/-/portfinder-1.0.32.tgz",
|
|
||||||
"integrity": "sha512-on2ZJVVDXRADWE6jnQaX0ioEylzgBpQk8r55NE4wjXW1ZxO+BgDlY6DXwj20i0V8eB4SenDQ00WEaxfiIQPcxg==",
|
|
||||||
"dependencies": {
|
|
||||||
"async": "^2.6.4",
|
|
||||||
"debug": "^3.2.7",
|
|
||||||
"mkdirp": "^0.5.6"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.12.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/qs": {
|
|
||||||
"version": "6.11.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.11.1.tgz",
|
|
||||||
"integrity": "sha512-0wsrzgTz/kAVIeuxSjnpGC56rzYtr6JT/2BwEvMaPhFIoYa1aGO8LbzuU1R0uUYQkLpWBTOj0l/CLAJB64J6nQ==",
|
|
||||||
"dependencies": {
|
|
||||||
"side-channel": "^1.0.4"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=0.6"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ljharb"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/requires-port": {
|
|
||||||
"version": "1.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
|
|
||||||
"integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ=="
|
|
||||||
},
|
|
||||||
"node_modules/safe-buffer": {
|
|
||||||
"version": "5.1.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
|
|
||||||
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
|
|
||||||
},
|
|
||||||
"node_modules/safer-buffer": {
|
|
||||||
"version": "2.1.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
|
||||||
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
|
|
||||||
},
|
|
||||||
"node_modules/secure-compare": {
|
|
||||||
"version": "3.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/secure-compare/-/secure-compare-3.0.1.tgz",
|
|
||||||
"integrity": "sha512-AckIIV90rPDcBcglUwXPF3kg0P0qmPsPXAj6BBEENQE1p5yA1xfmDJzfi1Tappj37Pv2mVbKpL3Z1T+Nn7k1Qw=="
|
|
||||||
},
|
|
||||||
"node_modules/side-channel": {
|
|
||||||
"version": "1.0.4",
|
|
||||||
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz",
|
|
||||||
"integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==",
|
|
||||||
"dependencies": {
|
|
||||||
"call-bind": "^1.0.0",
|
|
||||||
"get-intrinsic": "^1.0.2",
|
|
||||||
"object-inspect": "^1.9.0"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ljharb"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/supports-color": {
|
|
||||||
"version": "7.2.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
|
|
||||||
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
|
|
||||||
"dependencies": {
|
|
||||||
"has-flag": "^4.0.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=8"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/union": {
|
|
||||||
"version": "0.5.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/union/-/union-0.5.0.tgz",
|
|
||||||
"integrity": "sha512-N6uOhuW6zO95P3Mel2I2zMsbsanvvtgn6jVqJv4vbVcz/JN0OkL9suomjQGmWtxJQXOCqUJvquc1sMeNz/IwlA==",
|
|
||||||
"dependencies": {
|
|
||||||
"qs": "^6.4.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.8.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/url-join": {
|
|
||||||
"version": "4.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/url-join/-/url-join-4.0.1.tgz",
|
|
||||||
"integrity": "sha512-jk1+QP6ZJqyOiuEI9AEWQfju/nB2Pw466kbA0LEZljHwKeMgd9WrAEgEGxjPDD2+TNbbb37rTyhEfrCXfuKXnA=="
|
|
||||||
},
|
|
||||||
"node_modules/whatwg-encoding": {
|
|
||||||
"version": "2.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-2.0.0.tgz",
|
|
||||||
"integrity": "sha512-p41ogyeMUrw3jWclHWTQg1k05DSVXPLcVxRTYsXUk+ZooOCZLcoYgPZ/HL/D/N+uQPOtcp1me1WhBEaX02mhWg==",
|
|
||||||
"dependencies": {
|
|
||||||
"iconv-lite": "0.6.3"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=12"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"@popperjs/core": {
|
|
||||||
"version": "2.11.6",
|
|
||||||
"resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.6.tgz",
|
|
||||||
"integrity": "sha512-50/17A98tWUfQ176raKiOGXuYpLyyVMkxxG6oylzL3BPOlA6ADGdK7EYunSa4I064xerltq9TGXs8HmOk5E+vw==",
|
|
||||||
"peer": true
|
|
||||||
},
|
|
||||||
"ansi-styles": {
|
|
||||||
"version": "4.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
|
|
||||||
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
|
|
||||||
"requires": {
|
|
||||||
"color-convert": "^2.0.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"async": {
|
|
||||||
"version": "2.6.4",
|
|
||||||
"resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz",
|
|
||||||
"integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==",
|
|
||||||
"requires": {
|
|
||||||
"lodash": "^4.17.14"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"basic-auth": {
|
|
||||||
"version": "2.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz",
|
|
||||||
"integrity": "sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg==",
|
|
||||||
"requires": {
|
|
||||||
"safe-buffer": "5.1.2"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"bootstrap": {
|
|
||||||
"version": "5.2.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.2.3.tgz",
|
|
||||||
"integrity": "sha512-cEKPM+fwb3cT8NzQZYEu4HilJ3anCrWqh3CHAok1p9jXqMPsPTBhU25fBckEJHJ/p+tTxTFTsFQGM+gaHpi3QQ==",
|
|
||||||
"requires": {}
|
|
||||||
},
|
|
||||||
"call-bind": {
|
|
||||||
"version": "1.0.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz",
|
|
||||||
"integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==",
|
|
||||||
"requires": {
|
|
||||||
"function-bind": "^1.1.1",
|
|
||||||
"get-intrinsic": "^1.0.2"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"chalk": {
|
|
||||||
"version": "4.1.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
|
|
||||||
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
|
|
||||||
"requires": {
|
|
||||||
"ansi-styles": "^4.1.0",
|
|
||||||
"supports-color": "^7.1.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"color-convert": {
|
|
||||||
"version": "2.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
|
|
||||||
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
|
|
||||||
"requires": {
|
|
||||||
"color-name": "~1.1.4"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"color-name": {
|
|
||||||
"version": "1.1.4",
|
|
||||||
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
|
|
||||||
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
|
|
||||||
},
|
|
||||||
"corser": {
|
|
||||||
"version": "2.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/corser/-/corser-2.0.1.tgz",
|
|
||||||
"integrity": "sha512-utCYNzRSQIZNPIcGZdQc92UVJYAhtGAteCFg0yRaFm8f0P+CPtyGyHXJcGXnffjCybUCEx3FQ2G7U3/o9eIkVQ=="
|
|
||||||
},
|
|
||||||
"debug": {
|
|
||||||
"version": "3.2.7",
|
|
||||||
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz",
|
|
||||||
"integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==",
|
|
||||||
"requires": {
|
|
||||||
"ms": "^2.1.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"eventemitter3": {
|
|
||||||
"version": "4.0.7",
|
|
||||||
"resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz",
|
|
||||||
"integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw=="
|
|
||||||
},
|
|
||||||
"follow-redirects": {
|
|
||||||
"version": "1.15.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz",
|
|
||||||
"integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA=="
|
|
||||||
},
|
|
||||||
"function-bind": {
|
|
||||||
"version": "1.1.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
|
|
||||||
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
|
|
||||||
},
|
|
||||||
"get-intrinsic": {
|
|
||||||
"version": "1.2.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.0.tgz",
|
|
||||||
"integrity": "sha512-L049y6nFOuom5wGyRc3/gdTLO94dySVKRACj1RmJZBQXlbTMhtNIgkWkUHq+jYmZvKf14EW1EoJnnjbmoHij0Q==",
|
|
||||||
"requires": {
|
|
||||||
"function-bind": "^1.1.1",
|
|
||||||
"has": "^1.0.3",
|
|
||||||
"has-symbols": "^1.0.3"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"has": {
|
|
||||||
"version": "1.0.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
|
|
||||||
"integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
|
|
||||||
"requires": {
|
|
||||||
"function-bind": "^1.1.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"has-flag": {
|
|
||||||
"version": "4.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
|
|
||||||
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ=="
|
|
||||||
},
|
|
||||||
"has-symbols": {
|
|
||||||
"version": "1.0.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz",
|
|
||||||
"integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A=="
|
|
||||||
},
|
|
||||||
"he": {
|
|
||||||
"version": "1.2.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz",
|
|
||||||
"integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw=="
|
|
||||||
},
|
|
||||||
"html-encoding-sniffer": {
|
|
||||||
"version": "3.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-3.0.0.tgz",
|
|
||||||
"integrity": "sha512-oWv4T4yJ52iKrufjnyZPkrN0CH3QnrUqdB6In1g5Fe1mia8GmF36gnfNySxoZtxD5+NmYw1EElVXiBk93UeskA==",
|
|
||||||
"requires": {
|
|
||||||
"whatwg-encoding": "^2.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"http-proxy": {
|
|
||||||
"version": "1.18.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/http-proxy/-/http-proxy-1.18.1.tgz",
|
|
||||||
"integrity": "sha512-7mz/721AbnJwIVbnaSv1Cz3Am0ZLT/UBwkC92VlxhXv/k/BBQfM2fXElQNC27BVGr0uwUpplYPQM9LnaBMR5NQ==",
|
|
||||||
"requires": {
|
|
||||||
"eventemitter3": "^4.0.0",
|
|
||||||
"follow-redirects": "^1.0.0",
|
|
||||||
"requires-port": "^1.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"http-server": {
|
|
||||||
"version": "14.1.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/http-server/-/http-server-14.1.1.tgz",
|
|
||||||
"integrity": "sha512-+cbxadF40UXd9T01zUHgA+rlo2Bg1Srer4+B4NwIHdaGxAGGv59nYRnGGDJ9LBk7alpS0US+J+bLLdQOOkJq4A==",
|
|
||||||
"requires": {
|
|
||||||
"basic-auth": "^2.0.1",
|
|
||||||
"chalk": "^4.1.2",
|
|
||||||
"corser": "^2.0.1",
|
|
||||||
"he": "^1.2.0",
|
|
||||||
"html-encoding-sniffer": "^3.0.0",
|
|
||||||
"http-proxy": "^1.18.1",
|
|
||||||
"mime": "^1.6.0",
|
|
||||||
"minimist": "^1.2.6",
|
|
||||||
"opener": "^1.5.1",
|
|
||||||
"portfinder": "^1.0.28",
|
|
||||||
"secure-compare": "3.0.1",
|
|
||||||
"union": "~0.5.0",
|
|
||||||
"url-join": "^4.0.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"iconv-lite": {
|
|
||||||
"version": "0.6.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
|
|
||||||
"integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==",
|
|
||||||
"requires": {
|
|
||||||
"safer-buffer": ">= 2.1.2 < 3.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"lodash": {
|
|
||||||
"version": "4.17.21",
|
|
||||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
|
||||||
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
|
|
||||||
},
|
|
||||||
"mime": {
|
|
||||||
"version": "1.6.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
|
|
||||||
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg=="
|
|
||||||
},
|
|
||||||
"minimist": {
|
|
||||||
"version": "1.2.8",
|
|
||||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz",
|
|
||||||
"integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA=="
|
|
||||||
},
|
|
||||||
"mkdirp": {
|
|
||||||
"version": "0.5.6",
|
|
||||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz",
|
|
||||||
"integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==",
|
|
||||||
"requires": {
|
|
||||||
"minimist": "^1.2.6"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"ms": {
|
|
||||||
"version": "2.1.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
|
||||||
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
|
|
||||||
},
|
|
||||||
"object-inspect": {
|
|
||||||
"version": "1.12.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.3.tgz",
|
|
||||||
"integrity": "sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g=="
|
|
||||||
},
|
|
||||||
"opener": {
|
|
||||||
"version": "1.5.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/opener/-/opener-1.5.2.tgz",
|
|
||||||
"integrity": "sha512-ur5UIdyw5Y7yEj9wLzhqXiy6GZ3Mwx0yGI+5sMn2r0N0v3cKJvUmFH5yPP+WXh9e0xfyzyJX95D8l088DNFj7A=="
|
|
||||||
},
|
|
||||||
"portfinder": {
|
|
||||||
"version": "1.0.32",
|
|
||||||
"resolved": "https://registry.npmjs.org/portfinder/-/portfinder-1.0.32.tgz",
|
|
||||||
"integrity": "sha512-on2ZJVVDXRADWE6jnQaX0ioEylzgBpQk8r55NE4wjXW1ZxO+BgDlY6DXwj20i0V8eB4SenDQ00WEaxfiIQPcxg==",
|
|
||||||
"requires": {
|
|
||||||
"async": "^2.6.4",
|
|
||||||
"debug": "^3.2.7",
|
|
||||||
"mkdirp": "^0.5.6"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"qs": {
|
|
||||||
"version": "6.11.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.11.1.tgz",
|
|
||||||
"integrity": "sha512-0wsrzgTz/kAVIeuxSjnpGC56rzYtr6JT/2BwEvMaPhFIoYa1aGO8LbzuU1R0uUYQkLpWBTOj0l/CLAJB64J6nQ==",
|
|
||||||
"requires": {
|
|
||||||
"side-channel": "^1.0.4"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"requires-port": {
|
|
||||||
"version": "1.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
|
|
||||||
"integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ=="
|
|
||||||
},
|
|
||||||
"safe-buffer": {
|
|
||||||
"version": "5.1.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
|
|
||||||
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
|
|
||||||
},
|
|
||||||
"safer-buffer": {
|
|
||||||
"version": "2.1.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
|
||||||
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
|
|
||||||
},
|
|
||||||
"secure-compare": {
|
|
||||||
"version": "3.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/secure-compare/-/secure-compare-3.0.1.tgz",
|
|
||||||
"integrity": "sha512-AckIIV90rPDcBcglUwXPF3kg0P0qmPsPXAj6BBEENQE1p5yA1xfmDJzfi1Tappj37Pv2mVbKpL3Z1T+Nn7k1Qw=="
|
|
||||||
},
|
|
||||||
"side-channel": {
|
|
||||||
"version": "1.0.4",
|
|
||||||
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz",
|
|
||||||
"integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==",
|
|
||||||
"requires": {
|
|
||||||
"call-bind": "^1.0.0",
|
|
||||||
"get-intrinsic": "^1.0.2",
|
|
||||||
"object-inspect": "^1.9.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"supports-color": {
|
|
||||||
"version": "7.2.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
|
|
||||||
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
|
|
||||||
"requires": {
|
|
||||||
"has-flag": "^4.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"union": {
|
|
||||||
"version": "0.5.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/union/-/union-0.5.0.tgz",
|
|
||||||
"integrity": "sha512-N6uOhuW6zO95P3Mel2I2zMsbsanvvtgn6jVqJv4vbVcz/JN0OkL9suomjQGmWtxJQXOCqUJvquc1sMeNz/IwlA==",
|
|
||||||
"requires": {
|
|
||||||
"qs": "^6.4.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"url-join": {
|
|
||||||
"version": "4.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/url-join/-/url-join-4.0.1.tgz",
|
|
||||||
"integrity": "sha512-jk1+QP6ZJqyOiuEI9AEWQfju/nB2Pw466kbA0LEZljHwKeMgd9WrAEgEGxjPDD2+TNbbb37rTyhEfrCXfuKXnA=="
|
|
||||||
},
|
|
||||||
"whatwg-encoding": {
|
|
||||||
"version": "2.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-2.0.0.tgz",
|
|
||||||
"integrity": "sha512-p41ogyeMUrw3jWclHWTQg1k05DSVXPLcVxRTYsXUk+ZooOCZLcoYgPZ/HL/D/N+uQPOtcp1me1WhBEaX02mhWg==",
|
|
||||||
"requires": {
|
|
||||||
"iconv-lite": "0.6.3"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "frontend",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"description": "",
|
|
||||||
"main": "index.js",
|
|
||||||
"scripts": {
|
|
||||||
"start": "http-server -p 3000 -c-1 -o ./"
|
|
||||||
},
|
|
||||||
"author": "",
|
|
||||||
"license": "ISC",
|
|
||||||
"dependencies": {
|
|
||||||
"bootstrap": "^5.2.3",
|
|
||||||
"http-server": "^14.1.1"
|
|
||||||
}
|
|
||||||
}
|
|
24
frontend/spa-vue/.gitignore
vendored
Normal file
24
frontend/spa-vue/.gitignore
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
pnpm-debug.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
node_modules
|
||||||
|
dist
|
||||||
|
dist-ssr
|
||||||
|
*.local
|
||||||
|
|
||||||
|
# Editor directories and files
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/extensions.json
|
||||||
|
.idea
|
||||||
|
.DS_Store
|
||||||
|
*.suo
|
||||||
|
*.ntvs*
|
||||||
|
*.njsproj
|
||||||
|
*.sln
|
||||||
|
*.sw?
|
7
frontend/spa-vue/README.md
Normal file
7
frontend/spa-vue/README.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# Vue 3 + Vite
|
||||||
|
|
||||||
|
This template should help get you started developing with Vue 3 in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
|
||||||
|
|
||||||
|
## Recommended IDE Setup
|
||||||
|
|
||||||
|
- [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
|
35
frontend/spa-vue/data.json
Normal file
35
frontend/spa-vue/data.json
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
{
|
||||||
|
"Devices": [
|
||||||
|
{
|
||||||
|
"name": "Компьютер"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Телефон"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Видеокарта"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Products": [
|
||||||
|
{
|
||||||
|
"type": "Компьютер",
|
||||||
|
"price": 435,
|
||||||
|
"count": 345,
|
||||||
|
"id": 5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 9,
|
||||||
|
"type": "123123",
|
||||||
|
"price": 324,
|
||||||
|
"count": 124124,
|
||||||
|
"ame": "345345"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 10,
|
||||||
|
"type": "123123",
|
||||||
|
"price": 2342,
|
||||||
|
"count": 123,
|
||||||
|
"ame": "123"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
14
frontend/spa-vue/index.html
Normal file
14
frontend/spa-vue/index.html
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>Главная страница</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="app"></div>
|
||||||
|
<script type="module" src="/src/main.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
4977
frontend/spa-vue/package-lock.json
generated
Normal file
4977
frontend/spa-vue/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
26
frontend/spa-vue/package.json
Normal file
26
frontend/spa-vue/package.json
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"name": "spa-vue",
|
||||||
|
"private": true,
|
||||||
|
"version": "1.0.0",
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"dev": "vite",
|
||||||
|
"fake-server": "json-server --watch data.json -p 8079",
|
||||||
|
"start": "npm-run-all --parallel dev fake-server",
|
||||||
|
"build": "vite build",
|
||||||
|
"preview": "vite preview"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"vue": "^3.2.41",
|
||||||
|
"vue-router": "^4.1.6",
|
||||||
|
"axios": "^1.1.3",
|
||||||
|
"bootstrap": "^5.2.2",
|
||||||
|
"@fortawesome/fontawesome-free": "^6.2.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"vite": "^3.2.3",
|
||||||
|
"@vitejs/plugin-vue": "^3.2.0",
|
||||||
|
"npm-run-all": "^4.1.5",
|
||||||
|
"json-server": "^0.17.1"
|
||||||
|
}
|
||||||
|
}
|
17
frontend/spa-vue/src/App.vue
Normal file
17
frontend/spa-vue/src/App.vue
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<script>
|
||||||
|
import Header from "./components/Header.vue";
|
||||||
|
export default{
|
||||||
|
components:{
|
||||||
|
Header
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Header></Header>
|
||||||
|
<router-view>
|
||||||
|
|
||||||
|
</router-view>
|
||||||
|
</template>
|
||||||
|
|
14
frontend/spa-vue/src/banner.css
Normal file
14
frontend/spa-vue/src/banner.css
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#banner {
|
||||||
|
margin: 15px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
flex-direction: column;
|
||||||
|
min-height: 300px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#banner img {
|
||||||
|
border-radius: 15px;
|
||||||
|
width: 100%;
|
||||||
|
max-height: 500px;
|
||||||
|
max-width: 70%;
|
||||||
|
}
|
41
frontend/spa-vue/src/components/Header.vue
Normal file
41
frontend/spa-vue/src/components/Header.vue
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<template>
|
||||||
|
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="collapse navbar-collapse" id="navbarNav">
|
||||||
|
<ul class="navbar-nav justify-content-center">
|
||||||
|
<li class="nav-item">
|
||||||
|
<router-link to="/manufacturer" class="nav-link">Производители</router-link>
|
||||||
|
<router-link to="/category" class="nav-link">Категории</router-link>
|
||||||
|
<router-link to="/product" class="nav-link">Продукты</router-link>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.navbar-brand {
|
||||||
|
font-size: 2rem;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-link {
|
||||||
|
color: black;
|
||||||
|
font-weight: bold;
|
||||||
|
text-transform: uppercase;
|
||||||
|
transition: color 0.3s ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-link:hover {
|
||||||
|
color: #dc3545;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
|
||||||
|
}
|
||||||
|
</script>
|
7
frontend/spa-vue/src/main.js
Normal file
7
frontend/spa-vue/src/main.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import { createApp } from 'vue'
|
||||||
|
import './styles.css'
|
||||||
|
import './banner.css'
|
||||||
|
import App from './App.vue'
|
||||||
|
import router from "./routes.js"
|
||||||
|
|
||||||
|
createApp(App).use(router).mount('#app')
|
6
frontend/spa-vue/src/models/Category.js
Normal file
6
frontend/spa-vue/src/models/Category.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
export default class Category{
|
||||||
|
constructor(data) {
|
||||||
|
this.id = data?.id;
|
||||||
|
this.name = data?.name;
|
||||||
|
}
|
||||||
|
}
|
7
frontend/spa-vue/src/models/Manufacturer.js
Normal file
7
frontend/spa-vue/src/models/Manufacturer.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
export default class Manufacturer{
|
||||||
|
constructor(data) {
|
||||||
|
this.id = data?.id;
|
||||||
|
this.name = data?.name;
|
||||||
|
this.address = data?.address;
|
||||||
|
}
|
||||||
|
}
|
9
frontend/spa-vue/src/models/Product.js
Normal file
9
frontend/spa-vue/src/models/Product.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
export default class Product{
|
||||||
|
constructor(data){
|
||||||
|
this.id = data?.id;
|
||||||
|
this.name = data?.name;
|
||||||
|
this.price = data?.price;
|
||||||
|
this.photo = data?.photo;
|
||||||
|
this.category_id = data?.category_id;
|
||||||
|
}
|
||||||
|
}
|
193
frontend/spa-vue/src/pages/categories.vue
Normal file
193
frontend/spa-vue/src/pages/categories.vue
Normal file
@ -0,0 +1,193 @@
|
|||||||
|
<template>
|
||||||
|
<div class="container mt-4">
|
||||||
|
<h1 class="text-center mb-4">Categories Table</h1>
|
||||||
|
<button class="btn btn-primary mr-2" @click="openModal('create')">Добавить</button>
|
||||||
|
<table class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Название</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr v-for="categor in categories" :key="categor.id">
|
||||||
|
<td>{{ categor.name }}</td>
|
||||||
|
<td>
|
||||||
|
<td>
|
||||||
|
<button class="btn btn-primary mr-2" @click="openModal('edit', categor)">Изменить</button>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<button class="btn btn-danger" @click="deleteCategory(categor.id)">Удалить</button>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<button class="btn btn-primary mr-2" @click="OpenModelForProducts();getProductsFromCategory(categor.id)">Просмотр продуктов</button>
|
||||||
|
</td>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div class="modal" tabindex="-1" id="editModal">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title">Категория</h5>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<form>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="name">Название:</label>
|
||||||
|
<input type="text" class="form-control" id="name" name="name" v-model="editedCategory.name">
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="editModal" @click="closeModal()">Закрыть</button>
|
||||||
|
<button type="button" class="btn btn-primary" v-if="editedCategory.status === 'create'" @click="addCategory(editedCategory)">Создать</button>
|
||||||
|
<button type="button" class="btn btn-primary" v-else @click="editCategory(editedCategory)">Сохранить</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- Модальное окно для просмотра студентов в группе-->
|
||||||
|
<div class="modal" tabindex="-1" id="ModelForProducts">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title">Продукты</h5>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<form>
|
||||||
|
<div class="form-group">
|
||||||
|
<table class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Название</th>
|
||||||
|
<th>Цена</th>
|
||||||
|
<th>Фото</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr v-for="prod in products" :key="prod.id">
|
||||||
|
<td>{{ prod.name }}</td>
|
||||||
|
<td>{{ prod.price }}</td>
|
||||||
|
<td>{{ prod.photo }}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="ModelForStudents" @click="closeModelForProducts()">Закрыть</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
import 'axios';
|
||||||
|
import axios from "axios";
|
||||||
|
import Category from "../models/Category"
|
||||||
|
import Product from '../models/Product';
|
||||||
|
export default {
|
||||||
|
created() {
|
||||||
|
this.getCategories();
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
const addModal = document.getElementById('editModal');
|
||||||
|
addModal.addEventListener('shown.bs.modal', function () {
|
||||||
|
})
|
||||||
|
const ModelForProducts = document.getElementById('ModelForProducts');
|
||||||
|
addModal.addEventListener('shown.bs.modal', function () {
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
data() {
|
||||||
|
return{
|
||||||
|
categories: [],
|
||||||
|
URL: "http://localhost:8080/",
|
||||||
|
category: new Category(),
|
||||||
|
editedCategory: new Category(),
|
||||||
|
products: [],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
getCategories(){
|
||||||
|
axios.get(this.URL + "category")
|
||||||
|
.then(response => {
|
||||||
|
this.categories = response.data;
|
||||||
|
console.log(response.data);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.log(error);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
addCategory(category) {
|
||||||
|
console.log(category);
|
||||||
|
axios
|
||||||
|
.post(this.URL + "category", category)
|
||||||
|
.then(() => {
|
||||||
|
this.getCategories();
|
||||||
|
this.closeModal();
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.log(error);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
deleteCategory(id){
|
||||||
|
axios.delete(this.URL + `category/${id}`)
|
||||||
|
.then(() =>{
|
||||||
|
this.getCategories();
|
||||||
|
})
|
||||||
|
},
|
||||||
|
openModal(status, category = null) {
|
||||||
|
if (status === "create") {
|
||||||
|
this.editedCategory = new Category();
|
||||||
|
this.editedCategory.status = "create";
|
||||||
|
} else if (status === "edit" && category) {
|
||||||
|
this.editedCategory = { ...category };
|
||||||
|
this.editedCategory.status = "edit";
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById("editModal").style.display = "block";
|
||||||
|
},
|
||||||
|
closeModal() {
|
||||||
|
document.getElementById("editModal").style.display = "none";
|
||||||
|
},
|
||||||
|
editCategory(category) {
|
||||||
|
axios.put(this.URL + `category/${category.id}`, category)
|
||||||
|
.then(() => {
|
||||||
|
const index = this.categories.findIndex((s) => s.id === category.id);
|
||||||
|
if (index !== -1) {
|
||||||
|
this.categories[index] = { ...category };
|
||||||
|
}
|
||||||
|
this.closeModal();
|
||||||
|
this.getCategories();
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.log(error);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
getProductsFromCategory(category_id){
|
||||||
|
axios.get(this.URL + `group/${category_id}/products`)
|
||||||
|
.then(response => {
|
||||||
|
this.products = response.data;
|
||||||
|
console.log(response.data);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.log(error);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
OpenModelForProducts() {
|
||||||
|
document.getElementById("ModelForProducts").style.display = "block";
|
||||||
|
},
|
||||||
|
closeModelForProducts() {
|
||||||
|
document.getElementById("ModelForProducts").style.display = "none";
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style>
|
||||||
|
|
||||||
|
</style>
|
134
frontend/spa-vue/src/pages/manufacturers.vue
Normal file
134
frontend/spa-vue/src/pages/manufacturers.vue
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
<template>
|
||||||
|
<div class="container mt-4">
|
||||||
|
<h1 class="text-center mb-4">Manufacturer Table</h1>
|
||||||
|
<button class="btn btn-primary mr-2" @click="openModal('create')">Добавить</button>
|
||||||
|
<table class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Имя</th>
|
||||||
|
<th>Адресс</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr v-for="manufs in manufacturers" :key="manufs.id">
|
||||||
|
<td>{{ manufs.name }}</td>
|
||||||
|
<td>{{ manufs.address }}</td>
|
||||||
|
<td>
|
||||||
|
<td>
|
||||||
|
<button class="btn btn-primary mr-2" @click="openModal('edit', manufs)">Изменить</button>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<button class="btn btn-danger" @click="deleteManufacturer(manufs.id)">Удалить</button>
|
||||||
|
</td>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div class="modal" tabindex="-1" id="editModal">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title">Производитель</h5>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<form>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="name">Имя:</label>
|
||||||
|
<input type="text" class="form-control" id="name" name="name" v-model="manufacturer.name">
|
||||||
|
<label for="adress">Адресс:</label>
|
||||||
|
<input type="text" class="form-control" id="adress" name="address" v-model="manufacturer.address">
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="editModal" @click="closeModal()">Закрыть</button>
|
||||||
|
<button type="button" class="btn btn-primary" v-if="manufacturer.status === 'create'" @click="addManufacturer(manufacturer)">Создать</button>
|
||||||
|
<button type="button" class="btn btn-primary" v-else @click="editManufacturer(manufacturer)">Сохранить</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import 'axios';
|
||||||
|
import axios from "axios";
|
||||||
|
import Manufacturer from "../models/Manufacturer"
|
||||||
|
export default {
|
||||||
|
created() {
|
||||||
|
this.getManufacturers();
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
const addModal = document.getElementById('editModal');
|
||||||
|
addModal.addEventListener('shown.bs.modal', function () {
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
data() {
|
||||||
|
return{
|
||||||
|
manufacturers: [],
|
||||||
|
URL: "http://localhost:8080/",
|
||||||
|
manufacturer: new Manufacturer(),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
getManufacturers(){
|
||||||
|
axios.get(this.URL + "manufacturer")
|
||||||
|
.then(response => {
|
||||||
|
this.manufacturers = response.data;
|
||||||
|
console.log(response.data);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.log(error);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
addManufacturer(manufacturer){
|
||||||
|
console.log(this.manufacturers);
|
||||||
|
axios.post(this.URL + "manufacturer", manufacturer)
|
||||||
|
.then(() => {
|
||||||
|
this.getManufacturers();
|
||||||
|
this.closeModal();
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.log(error);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
deleteManufacturer(id){
|
||||||
|
axios.delete(this.URL + `manufacturer/${id}`)
|
||||||
|
.then(() =>{
|
||||||
|
this.getManufacturers();
|
||||||
|
})
|
||||||
|
},
|
||||||
|
editManufacturer(manufacturer){
|
||||||
|
axios.put(this.URL + `manufacturer/${manufacturer.id}`, manufacturer)
|
||||||
|
.then(() =>{
|
||||||
|
const index = this.manufacturers.findIndex((m) => m.id === manufacturer.id);
|
||||||
|
if (index !== -1) {
|
||||||
|
this.manufacturers[index] = { ...manufacturer };
|
||||||
|
}
|
||||||
|
this.closeModal();
|
||||||
|
this.getManufacturers();
|
||||||
|
})
|
||||||
|
this.closeModal();
|
||||||
|
},
|
||||||
|
openModal(status, manufacturer = null) {
|
||||||
|
if (status === "create") {
|
||||||
|
this.manufacturer = new Manufacturer();
|
||||||
|
this.manufacturer.status = "create";
|
||||||
|
} else if (status === "edit" && manufacturer) {
|
||||||
|
this.manufacturer = { ...manufacturer };
|
||||||
|
this.manufacturer.status = "edit";
|
||||||
|
}
|
||||||
|
document.getElementById("editModal").style.display = "block";
|
||||||
|
},
|
||||||
|
closeModal() {
|
||||||
|
document.getElementById("editModal").style.display = "none";
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style>
|
||||||
|
|
||||||
|
</style>
|
184
frontend/spa-vue/src/pages/products.vue
Normal file
184
frontend/spa-vue/src/pages/products.vue
Normal file
@ -0,0 +1,184 @@
|
|||||||
|
<template>
|
||||||
|
<div class="container mt-4">
|
||||||
|
<h1 class="text-center mb-4">Product Table</h1>
|
||||||
|
<button class="btn btn-primary mr-2" @click="openModal('create')">Добавить</button>
|
||||||
|
<table class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Название</th>
|
||||||
|
<th>Цена</th>
|
||||||
|
<th>Фото</th>
|
||||||
|
<th>Категория</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr v-for="prdct in products" :key="prdct.id">
|
||||||
|
<td>{{ prdct.name }}</td>
|
||||||
|
<td>{{ prdct.price }}</td>
|
||||||
|
<td>{{ prdct.photo }}</td>
|
||||||
|
<td>{{ prdct.category_id }}</td>
|
||||||
|
<td>
|
||||||
|
<td>
|
||||||
|
<button class="btn btn-primary mr-2" @click="openModal('edit', prdct)">Изменить</button>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<button class="btn btn-danger" @click="deleteProduct(prdct.id)">Удалить</button>
|
||||||
|
</td>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<!-- Модальное окно для добавления и изменения-->
|
||||||
|
<div class="modal" tabindex="-1" id="editModal">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title">Продукт</h5>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<form>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="name">Имя:</label>
|
||||||
|
<input type="text" class="form-control" id="name" name="name" v-model="product.name">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="price">Цена:</label>
|
||||||
|
<input type="text" class="form-control" id="price" name="price" v-model="product.price">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<input class="form-control" type="file" id="cover" name="cover" @change="toBase64">
|
||||||
|
<img :src="product.photo" class="img-thumbnail"/>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="category">Категория:</label>
|
||||||
|
<select v-model="product.category_id" class="form-control">
|
||||||
|
<option v-for="(category, index) in categories" :key="index" :value="category.id">
|
||||||
|
{{ category.name }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="editModal" @click="closeModal">Закрыть</button>
|
||||||
|
<button type="button" class="btn btn-primary" v-if="product.status === 'create'" @click="addProduct">Создать</button>
|
||||||
|
<button type="button" class="btn btn-primary" v-else @click="editProduct(product)">Сохранить</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
import 'axios';
|
||||||
|
import axios from "axios";
|
||||||
|
import Product from "../models/Product";
|
||||||
|
export default {
|
||||||
|
created() {
|
||||||
|
this.getProducts();
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
const addModal = document.getElementById('editModal');
|
||||||
|
addModal.addEventListener('shown.bs.modal', function () {
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
data() {
|
||||||
|
return{
|
||||||
|
products: [],
|
||||||
|
categories: [],
|
||||||
|
URL: "http://localhost:8080/",
|
||||||
|
product: new Product(),
|
||||||
|
editedProduct: new Product(),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
getProducts(){
|
||||||
|
axios.get(this.URL + "product")
|
||||||
|
.then(response => {
|
||||||
|
this.products = response.data;
|
||||||
|
console.log(response.data);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.log(error);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
getCategories(){
|
||||||
|
axios.get(this.URL + "category")
|
||||||
|
.then(response => {
|
||||||
|
this.categories = response.data;
|
||||||
|
console.log(response.data);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.log(error);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
addProduct(){
|
||||||
|
this.product.price = parseInt(this.product.price);
|
||||||
|
console.log(this.product);
|
||||||
|
axios.post(this.URL + "product", this.product)
|
||||||
|
.then(() => {
|
||||||
|
this.getProducts();
|
||||||
|
this.closeModal();
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.log(error);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
deleteProduct(id){
|
||||||
|
axios.delete(this.URL + `product/${id}`)
|
||||||
|
.then(() =>{
|
||||||
|
this.getProducts();
|
||||||
|
})
|
||||||
|
},
|
||||||
|
async editProduct(product){
|
||||||
|
await this.toBase64();
|
||||||
|
axios.put(this.URL + `product/${product.id}`, product)
|
||||||
|
.then(() =>{
|
||||||
|
const index = this.products.findIndex((s) => s.id === product.id);
|
||||||
|
if (index !== -1) {
|
||||||
|
this.products[index] = { ...product };
|
||||||
|
}
|
||||||
|
this.closeModal();
|
||||||
|
this.getProducts();
|
||||||
|
})
|
||||||
|
this.closeModal();
|
||||||
|
},
|
||||||
|
openModal(status, product = null) {
|
||||||
|
this.getCategories();
|
||||||
|
if (status === "create") {
|
||||||
|
this.product = new Product();
|
||||||
|
this.product.status = "create";
|
||||||
|
} else if (status === "edit" && product) {
|
||||||
|
this.product = { ...product };
|
||||||
|
this.product.status = "edit";
|
||||||
|
}
|
||||||
|
document.getElementById("editModal").style.display = "block";
|
||||||
|
},
|
||||||
|
closeModal() {
|
||||||
|
document.getElementById("editModal").style.display = "none";
|
||||||
|
},
|
||||||
|
async toBase64(){
|
||||||
|
var file = document.getElementById("cover").files[0];
|
||||||
|
var reader = new FileReader();
|
||||||
|
var phototemp = this.product;
|
||||||
|
reader.readAsDataURL(file);
|
||||||
|
await new Promise((resolve, reject) => {
|
||||||
|
reader.onload = function () {
|
||||||
|
phototemp.photo = reader.result;
|
||||||
|
console.log("phototemp: " + phototemp);
|
||||||
|
resolve();
|
||||||
|
};
|
||||||
|
reader.onerror = function (error) {
|
||||||
|
console.log('Error: ', error);
|
||||||
|
reject(error);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style>
|
||||||
|
|
||||||
|
</style>
|
18
frontend/spa-vue/src/routes.js
Normal file
18
frontend/spa-vue/src/routes.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import manufacturers from './pages/manufacturers.vue'
|
||||||
|
import categories from './pages/categories.vue'
|
||||||
|
import products from './pages/products.vue'
|
||||||
|
import {createRouter, createWebHistory} from "vue-router"
|
||||||
|
|
||||||
|
const routes = [
|
||||||
|
{path: '/manufacturer', component: manufacturers},
|
||||||
|
{path: '/category', component: categories},
|
||||||
|
{path: '/product', component: products},
|
||||||
|
]
|
||||||
|
|
||||||
|
const router = createRouter({
|
||||||
|
history: createWebHistory(),
|
||||||
|
linkActiveClass: 'active',
|
||||||
|
routes
|
||||||
|
})
|
||||||
|
|
||||||
|
export default router;
|
42
frontend/spa-vue/src/services/DataService.js
Normal file
42
frontend/spa-vue/src/services/DataService.js
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
import axios from 'axios';
|
||||||
|
|
||||||
|
function toJSON(data) {
|
||||||
|
const jsonObj = {};
|
||||||
|
const fields = Object.getOwnPropertyNames(data);
|
||||||
|
for (const field of fields) {
|
||||||
|
if (data[field] === undefined) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
jsonObj[field.substring(1)] = data[field];
|
||||||
|
}
|
||||||
|
return jsonObj;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class DataService {
|
||||||
|
static dataUrlPrefix = 'http://localhost:8079/';
|
||||||
|
|
||||||
|
static async readAll(url, transformer) {
|
||||||
|
const response = await axios.get(this.dataUrlPrefix + url);
|
||||||
|
return response.data.map(item => transformer(item));
|
||||||
|
}
|
||||||
|
|
||||||
|
static async read(url, transformer) {
|
||||||
|
const response = await axios.get(this.dataUrlPrefix + url);
|
||||||
|
return transformer(response.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static async create(url, data) {
|
||||||
|
const response = await axios.post(this.dataUrlPrefix + url, toJSON(data));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static async update(url, data) {
|
||||||
|
const response = await axios.put(this.dataUrlPrefix + url, toJSON(data));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static async delete(url) {
|
||||||
|
const response = await axios.delete(this.dataUrlPrefix + url);
|
||||||
|
return response.data.id;
|
||||||
|
}
|
||||||
|
}
|
89
frontend/spa-vue/src/style.css
Normal file
89
frontend/spa-vue/src/style.css
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
:root {
|
||||||
|
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
|
||||||
|
line-height: 1.5;
|
||||||
|
font-weight: 400;
|
||||||
|
|
||||||
|
color-scheme: light dark;
|
||||||
|
color: rgba(255, 255, 255, 0.87);
|
||||||
|
background-color: #242424;
|
||||||
|
|
||||||
|
font-synthesis: none;
|
||||||
|
text-rendering: optimizeLegibility;
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
-moz-osx-font-smoothing: grayscale;
|
||||||
|
-webkit-text-size-adjust: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
font-weight: 500;
|
||||||
|
color: #646cff;
|
||||||
|
text-decoration: inherit;
|
||||||
|
}
|
||||||
|
a:hover {
|
||||||
|
color: #535bf2;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
font-weight: 500;
|
||||||
|
color: #646cff;
|
||||||
|
text-decoration: inherit;
|
||||||
|
}
|
||||||
|
a:hover {
|
||||||
|
color: #535bf2;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
display: flex;
|
||||||
|
place-items: center;
|
||||||
|
min-width: 320px;
|
||||||
|
min-height: 100vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
font-size: 3.2em;
|
||||||
|
line-height: 1.1;
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
border-radius: 8px;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
padding: 0.6em 1.2em;
|
||||||
|
font-size: 1em;
|
||||||
|
font-weight: 500;
|
||||||
|
font-family: inherit;
|
||||||
|
background-color: #1a1a1a;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: border-color 0.25s;
|
||||||
|
}
|
||||||
|
button:hover {
|
||||||
|
border-color: #646cff;
|
||||||
|
}
|
||||||
|
button:focus,
|
||||||
|
button:focus-visible {
|
||||||
|
outline: 4px auto -webkit-focus-ring-color;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card {
|
||||||
|
padding: 2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
#app {
|
||||||
|
max-width: 1280px;
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: 2rem;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: light) {
|
||||||
|
:root {
|
||||||
|
color: #213547;
|
||||||
|
background-color: #ffffff;
|
||||||
|
}
|
||||||
|
a:hover {
|
||||||
|
color: #747bff;
|
||||||
|
}
|
||||||
|
button {
|
||||||
|
background-color: #f9f9f9;
|
||||||
|
}
|
||||||
|
}
|
136
frontend/spa-vue/src/styles.css
Normal file
136
frontend/spa-vue/src/styles.css
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
html {
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav {
|
||||||
|
font-size: 25px;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav a {
|
||||||
|
color: white;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar-nav .nav-link {
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card {
|
||||||
|
transition: 0.3s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card:hover {
|
||||||
|
box-shadow: 0px 0px 3px 4px gray;
|
||||||
|
transform: scale(1.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
#brands {
|
||||||
|
margin-top: 5rem;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
#main {
|
||||||
|
margin-top: 5rem;
|
||||||
|
margin-bottom: 5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
#lc_main {
|
||||||
|
padding-top: 2rem;
|
||||||
|
padding-bottom: 2rem;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
#cart_main {
|
||||||
|
margin-top: 2rem;
|
||||||
|
margin-bottom: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
#secondStr {
|
||||||
|
padding-top: 1rem;
|
||||||
|
padding-bottom: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#firstRow {
|
||||||
|
padding: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
#catalog_main .btn {
|
||||||
|
background: orange;
|
||||||
|
border: 2px solid darkgray;
|
||||||
|
}
|
||||||
|
|
||||||
|
#catalog_main .btn:hover {
|
||||||
|
background: lightgreen;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#catalog_main .card {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
padding: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
#catalog_main {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#footer_catalog {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
#information_main {
|
||||||
|
padding-top: 3rem;
|
||||||
|
padding-left: 1rem;
|
||||||
|
padding-right: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
#information_main {
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#information_main .card {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#main {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
#registrationForm {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
#submitBtn {
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
max-width: 200px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input.error {
|
||||||
|
border-color: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
.checkbox__input.error + .checkbox__label {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
#frm-items {
|
||||||
|
padding: 32px;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tbl {
|
||||||
|
padding-left: 32px;
|
||||||
|
padding-right: 32px;
|
||||||
|
}
|
7
frontend/spa-vue/vite.config.js
Normal file
7
frontend/spa-vue/vite.config.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import { defineConfig } from 'vite'
|
||||||
|
import vue from '@vitejs/plugin-vue'
|
||||||
|
|
||||||
|
// https://vitejs.dev/config/
|
||||||
|
export default defineConfig({
|
||||||
|
plugins: [vue()],
|
||||||
|
})
|
@ -0,0 +1,48 @@
|
|||||||
|
package ru.ulstu.is.sbapp.HardwareShop.controller;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import ru.ulstu.is.sbapp.HardwareShop.models.Category;
|
||||||
|
import ru.ulstu.is.sbapp.HardwareShop.services.CategoryService;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import javax.xml.crypto.dsig.CanonicalizationMethod;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/category")
|
||||||
|
public class CategoryController {
|
||||||
|
private final CategoryService categoryService;
|
||||||
|
|
||||||
|
public CategoryController(CategoryService categoryService) {
|
||||||
|
this.categoryService = categoryService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
public CategoryDTO getCategory(@PathVariable Long id) {
|
||||||
|
return new CategoryDTO(categoryService.findCategory(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
public List<CategoryDTO> getCategories() {
|
||||||
|
return categoryService.findAllCategories().stream()
|
||||||
|
.map(CategoryDTO::new)
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping
|
||||||
|
public CategoryDTO createCategory(@RequestBody @Valid CategoryDTO categoryDTO) throws IOException {
|
||||||
|
return new CategoryDTO(categoryService.addCategory(categoryDTO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/{id}")
|
||||||
|
public CategoryDTO updateCategory(@PathVariable Long id, @RequestBody @Valid CategoryDTO categoryDTO) {
|
||||||
|
return new CategoryDTO(categoryService.updateCategory(id, categoryDTO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/{id}")
|
||||||
|
public CategoryDTO deleteCategory(@PathVariable Long id) {
|
||||||
|
return new CategoryDTO(categoryService.deleteCategory(id));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package ru.ulstu.is.sbapp.HardwareShop.controller;
|
||||||
|
|
||||||
|
import ru.ulstu.is.sbapp.HardwareShop.models.Category;
|
||||||
|
import ru.ulstu.is.sbapp.HardwareShop.models.Product;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
public class CategoryDTO {
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public CategoryDTO() {}
|
||||||
|
|
||||||
|
public CategoryDTO(Category category) {
|
||||||
|
this.id = category.getId();
|
||||||
|
this.name = category.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
package ru.ulstu.is.sbapp.HardwareShop.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springframework.boot.web.servlet.ServletComponentScan;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import ru.ulstu.is.sbapp.HardwareShop.services.ManufacturerService;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/manufacturer")
|
||||||
|
public class ManufacturerController {
|
||||||
|
private final ManufacturerService manufacturerService;
|
||||||
|
|
||||||
|
public ManufacturerController(ManufacturerService manufacturerService) {
|
||||||
|
this.manufacturerService = manufacturerService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
public ManufacturerDTO getManufacturer(@PathVariable Long id) {
|
||||||
|
return new ManufacturerDTO(manufacturerService.findManufacturer(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping()
|
||||||
|
public List<ManufacturerDTO> getManufacturers() {
|
||||||
|
return manufacturerService.findAllManufacturers().stream()
|
||||||
|
.map(ManufacturerDTO::new)
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping
|
||||||
|
public ManufacturerDTO createManufacturer(@RequestBody @Valid ManufacturerDTO manufacturerDTO) throws IOException {
|
||||||
|
return new ManufacturerDTO(manufacturerService.addManufacturer(manufacturerDTO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/{id}")
|
||||||
|
public ManufacturerDTO updateManufacturer(@PathVariable Long id, @RequestBody @Valid ManufacturerDTO manufacturerDTO) throws IOException {
|
||||||
|
return new ManufacturerDTO(manufacturerService.updateManufacturer(id, manufacturerDTO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/{id}")
|
||||||
|
public ManufacturerDTO deleteManufacturer(@PathVariable Long id) {
|
||||||
|
return new ManufacturerDTO(manufacturerService.deleteManufacturer(id));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
package ru.ulstu.is.sbapp.HardwareShop.controller;
|
||||||
|
|
||||||
|
import ru.ulstu.is.sbapp.HardwareShop.models.Manufacturer;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
public class ManufacturerDTO {
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String address;
|
||||||
|
|
||||||
|
public ManufacturerDTO() {}
|
||||||
|
|
||||||
|
public ManufacturerDTO(Manufacturer manufacturer) {
|
||||||
|
this.id = manufacturer.getId();
|
||||||
|
this.name = manufacturer.getName();
|
||||||
|
this.address = manufacturer.getAddress();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAddress() {
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
}
|
@ -1,37 +1,62 @@
|
|||||||
package ru.ulstu.is.sbapp.HardwareShop.controller;
|
package ru.ulstu.is.sbapp.HardwareShop.controller;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.parameters.RequestBody;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import ru.ulstu.is.sbapp.HardwareShop.models.Product;
|
import ru.ulstu.is.sbapp.HardwareShop.models.Product;
|
||||||
|
import ru.ulstu.is.sbapp.HardwareShop.services.ManufacturerService;
|
||||||
import ru.ulstu.is.sbapp.HardwareShop.services.ProductService;
|
import ru.ulstu.is.sbapp.HardwareShop.services.ProductService;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/product")
|
@RequestMapping("/product")
|
||||||
public class ProductController {
|
public class ProductController {
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private final ProductService productService;
|
private final ProductService productService;
|
||||||
|
|
||||||
public ProductController(ProductService productService) {
|
public ProductController(ProductService productService) {
|
||||||
this.productService = productService;
|
this.productService = productService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/test")
|
@GetMapping("/{id}")
|
||||||
public String test() {
|
public ProductDTO getProduct(@PathVariable Long id) {
|
||||||
return "Test";
|
return new ProductDTO(productService.findProduct(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/uploadImage")
|
@GetMapping
|
||||||
public Product createProduct(@RequestParam Integer price, @RequestParam MultipartFile file) {
|
public List<ProductDTO> getProducts() {
|
||||||
try {
|
return productService.findAllProducts().stream()
|
||||||
byte[] byteImage = file.getBytes();
|
.map(ProductDTO::new)
|
||||||
return productService.addProduct(price, byteImage);
|
.toList();
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping
|
||||||
|
public ProductDTO createProduct(@RequestBody @Valid ProductDTO productDTO) throws IOException{
|
||||||
|
return new ProductDTO(productService.addProduct(productDTO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/{id}")
|
||||||
|
public ProductDTO updateProduct(@PathVariable Long id, @RequestBody @Valid ProductDTO productDTO) {
|
||||||
|
return new ProductDTO(productService.updateProduct(id, productDTO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/{id}/{manufacturer}")
|
||||||
|
public void addManufacturer(@PathVariable Long id, @PathVariable Long manufacturer_id) {
|
||||||
|
productService.addManufacturersToProduct(id, manufacturer_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/{id}")
|
||||||
|
public ProductDTO deleteProduct(@PathVariable Long id) {
|
||||||
|
return new ProductDTO(productService.deleteProduct(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping
|
||||||
|
public void deleteAll() {
|
||||||
|
productService.deleteAllProducts();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,53 @@
|
|||||||
|
package ru.ulstu.is.sbapp.HardwareShop.controller;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import ru.ulstu.is.sbapp.HardwareShop.models.Product;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
public class ProductDTO {
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private Integer price;
|
||||||
|
|
||||||
|
|
||||||
|
private String photo;
|
||||||
|
|
||||||
|
private Long category_id;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public ProductDTO() {}
|
||||||
|
|
||||||
|
public ProductDTO(Product product) {
|
||||||
|
this.id = product.getId();
|
||||||
|
this.name = product.getName();
|
||||||
|
this.price = product.getPrice();
|
||||||
|
this.photo = new String(product.getPhoto(), StandardCharsets.UTF_8);
|
||||||
|
this.category_id = product.getCategory().getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() { return name; }
|
||||||
|
|
||||||
|
public Integer getPrice() {
|
||||||
|
return price;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPhoto() {
|
||||||
|
return photo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getCategory_id() {
|
||||||
|
return category_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPhoto(String photo) { this.photo = photo; }
|
||||||
|
|
||||||
|
public void setName(String name) { this.name = name; }
|
||||||
|
|
||||||
|
public void setPrice(Integer price) { this.price = price; }
|
||||||
|
}
|
@ -1,5 +1,8 @@
|
|||||||
package ru.ulstu.is.sbapp.HardwareShop.models;
|
package ru.ulstu.is.sbapp.HardwareShop.models;
|
||||||
|
|
||||||
|
import ru.ulstu.is.sbapp.HardwareShop.controller.CategoryDTO;
|
||||||
|
import ru.ulstu.is.sbapp.HardwareShop.controller.ProductDTO;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@ -21,6 +24,10 @@ public class Category {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Category(CategoryDTO categoryDTO){
|
||||||
|
this.name = categoryDTO.getName();
|
||||||
|
}
|
||||||
|
|
||||||
public Long getId() { return id;}
|
public Long getId() { return id;}
|
||||||
|
|
||||||
public String getName() { return name; }
|
public String getName() { return name; }
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package ru.ulstu.is.sbapp.HardwareShop.models;
|
package ru.ulstu.is.sbapp.HardwareShop.models;
|
||||||
|
|
||||||
|
import ru.ulstu.is.sbapp.HardwareShop.controller.CategoryDTO;
|
||||||
|
import ru.ulstu.is.sbapp.HardwareShop.controller.ManufacturerDTO;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@ -28,6 +31,11 @@ public class Manufacturer {
|
|||||||
this.address = address;
|
this.address = address;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Manufacturer(ManufacturerDTO manufacturerDTO){
|
||||||
|
this.name = manufacturerDTO.getName();
|
||||||
|
this.address = manufacturerDTO.getAddress();
|
||||||
|
}
|
||||||
|
|
||||||
public Long getId() { return id;}
|
public Long getId() { return id;}
|
||||||
|
|
||||||
public String getName() { return name; }
|
public String getName() { return name; }
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package ru.ulstu.is.sbapp.HardwareShop.models;
|
package ru.ulstu.is.sbapp.HardwareShop.models;
|
||||||
|
|
||||||
|
import ru.ulstu.is.sbapp.HardwareShop.controller.ProductDTO;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
@ -25,6 +27,9 @@ public class Product {
|
|||||||
@Column
|
@Column
|
||||||
private Integer price;
|
private Integer price;
|
||||||
|
|
||||||
|
@Column
|
||||||
|
private String name;
|
||||||
|
|
||||||
@Lob
|
@Lob
|
||||||
private byte[] photo;
|
private byte[] photo;
|
||||||
|
|
||||||
@ -32,10 +37,17 @@ public class Product {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Product(Integer price, byte[] photo)
|
public Product(Integer price, byte[] photo, String name)
|
||||||
{
|
{
|
||||||
this.price = price;
|
this.price = price;
|
||||||
this.photo = photo;
|
this.photo = photo;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Product(ProductDTO productDTO){
|
||||||
|
this.price = productDTO.getPrice();
|
||||||
|
this.photo = productDTO.getPhoto().getBytes();
|
||||||
|
this.name = productDTO.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getId() { return id; }
|
public Long getId() { return id; }
|
||||||
@ -44,6 +56,10 @@ public class Product {
|
|||||||
|
|
||||||
public byte[] getPhoto() { return photo; }
|
public byte[] getPhoto() { return photo; }
|
||||||
|
|
||||||
|
public String getName() { return name; }
|
||||||
|
|
||||||
|
public void setName() { this.name = name; }
|
||||||
|
|
||||||
public void setPrice(Integer price) { this.price = price; }
|
public void setPrice(Integer price) { this.price = price; }
|
||||||
|
|
||||||
public void setPhoto(byte[] photo) { this.photo = photo; }
|
public void setPhoto(byte[] photo) { this.photo = photo; }
|
||||||
@ -52,9 +68,7 @@ public class Product {
|
|||||||
|
|
||||||
public Category getCategory() { return category; }
|
public Category getCategory() { return category; }
|
||||||
|
|
||||||
public void addCategory(Category category) {
|
public void setCategory(Category category) { this.category = category; }
|
||||||
this.category = category;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addManufacturer(Manufacturer manufacturer) {
|
public void addManufacturer(Manufacturer manufacturer) {
|
||||||
manufacturerList.add(manufacturer);
|
manufacturerList.add(manufacturer);
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
package ru.ulstu.is.sbapp.HardwareShop.repository;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import ru.ulstu.is.sbapp.HardwareShop.models.Category;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface CategoryRepository extends JpaRepository<Category, Long> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
package ru.ulstu.is.sbapp.HardwareShop.repository;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import ru.ulstu.is.sbapp.HardwareShop.models.Manufacturer;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface ManufacturerRepository extends JpaRepository<Manufacturer, Long> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package ru.ulstu.is.sbapp.HardwareShop.repository;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import ru.ulstu.is.sbapp.HardwareShop.models.Manufacturer;
|
||||||
|
import ru.ulstu.is.sbapp.HardwareShop.models.Product;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface ProductRepository extends JpaRepository<Product, Long> {
|
||||||
|
@Query("Select manufacturerList from Product where id =:id")
|
||||||
|
List<Manufacturer> getManufacturers(Long id);
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package ru.ulstu.is.sbapp.HardwareShop.services;
|
||||||
|
|
||||||
|
public class CategoryNotFoundException extends RuntimeException {
|
||||||
|
public CategoryNotFoundException(Long id) {
|
||||||
|
super(String.format("Category with id [%s] is not found", id));
|
||||||
|
}
|
||||||
|
}
|
@ -1,64 +1,92 @@
|
|||||||
package ru.ulstu.is.sbapp.HardwareShop.services;
|
package ru.ulstu.is.sbapp.HardwareShop.services;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
import ru.ulstu.is.sbapp.HardwareShop.controller.CategoryDTO;
|
||||||
|
import ru.ulstu.is.sbapp.HardwareShop.controller.ProductDTO;
|
||||||
import ru.ulstu.is.sbapp.HardwareShop.models.Category;
|
import ru.ulstu.is.sbapp.HardwareShop.models.Category;
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.EntityNotFoundException;
|
import javax.persistence.EntityNotFoundException;
|
||||||
import javax.persistence.PersistenceContext;
|
import javax.persistence.PersistenceContext;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import ru.ulstu.is.sbapp.HardwareShop.models.Product;
|
||||||
|
import ru.ulstu.is.sbapp.HardwareShop.repository.CategoryRepository;
|
||||||
|
import ru.ulstu.is.sbapp.Util.Validation.ValidatorUtil;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class CategoryService {
|
public class CategoryService {
|
||||||
@PersistenceContext
|
@Autowired
|
||||||
private EntityManager em;
|
private final CategoryRepository categoryRepository;
|
||||||
|
@Autowired
|
||||||
|
private final ValidatorUtil validatorUtil;
|
||||||
|
|
||||||
|
public CategoryService(CategoryRepository categoryRepository, ValidatorUtil validatorUtil) {
|
||||||
|
this.categoryRepository = categoryRepository;
|
||||||
|
this.validatorUtil = validatorUtil;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public Category addCategory(CategoryDTO categoryDTO) throws IOException {
|
||||||
|
final Category category = new Category(categoryDTO);
|
||||||
|
validatorUtil.validate(category);
|
||||||
|
return categoryRepository.save(category);
|
||||||
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Category addCategory(String name) {
|
public Category addCategory(String name) {
|
||||||
if (!StringUtils.hasText(name)) {
|
|
||||||
throw new IllegalArgumentException("Category name is null or empty");
|
|
||||||
}
|
|
||||||
final Category category = new Category(name);
|
final Category category = new Category(name);
|
||||||
em.persist(category);
|
validatorUtil.validate(category);
|
||||||
return category;
|
return categoryRepository.save(category);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void saveCategory(Category category) {
|
||||||
|
categoryRepository.save(category);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public Category findCategory(Long id) {
|
public Category findCategory(Long id) {
|
||||||
final Category category = em.find(Category.class, id);
|
final Optional<Category> client = categoryRepository.findById(id);
|
||||||
if (category == null) {
|
return client.orElseThrow(() -> new CategoryNotFoundException(id));
|
||||||
throw new EntityNotFoundException(String.format("Category with id [%s] is not found", id));
|
|
||||||
}
|
|
||||||
return category;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public List<Category> findAllCategories() {
|
public List<Category> findAllCategories() {
|
||||||
return em.createQuery("select s from Category s", Category.class)
|
return categoryRepository.findAll();
|
||||||
.getResultList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Category updateCategory(Long id, String name) {
|
public Category updateCategory(Long id, String name) {
|
||||||
if (!StringUtils.hasText(name)) {
|
|
||||||
throw new IllegalArgumentException("Category name is null or empty");
|
|
||||||
}
|
|
||||||
final Category currentCategory = findCategory(id);
|
final Category currentCategory = findCategory(id);
|
||||||
currentCategory.setName(name);
|
currentCategory.setName(name);
|
||||||
return em.merge(currentCategory);
|
validatorUtil.validate(currentCategory);
|
||||||
|
return categoryRepository.save(currentCategory);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public Category updateCategory(Long id, CategoryDTO categoryDTO) {
|
||||||
|
final Category currentCategory = findCategory(id);
|
||||||
|
currentCategory.setName(categoryDTO.getName());
|
||||||
|
validatorUtil.validate(currentCategory);
|
||||||
|
return categoryRepository.save(currentCategory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Category deleteCategory(Long id) {
|
public Category deleteCategory(Long id) {
|
||||||
final Category currentCategory = findCategory(id);
|
final Category currentCategory = findCategory(id);
|
||||||
em.remove(currentCategory);
|
categoryRepository.delete(currentCategory);
|
||||||
return currentCategory;
|
return currentCategory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void deleteAllCategories() {
|
public void deleteAllCategories() {
|
||||||
em.createQuery("delete from Category").executeUpdate();
|
categoryRepository.deleteAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
package ru.ulstu.is.sbapp.HardwareShop.services;
|
||||||
|
|
||||||
|
public class ManufacturerNotFoundException extends RuntimeException {
|
||||||
|
public ManufacturerNotFoundException(Long id) {
|
||||||
|
super(String.format("Manufacturer with id [%s] is not found", id));
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,11 @@
|
|||||||
package ru.ulstu.is.sbapp.HardwareShop.services;
|
package ru.ulstu.is.sbapp.HardwareShop.services;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
import ru.ulstu.is.sbapp.HardwareShop.controller.ManufacturerDTO;
|
||||||
|
import ru.ulstu.is.sbapp.HardwareShop.controller.ProductDTO;
|
||||||
|
import ru.ulstu.is.sbapp.HardwareShop.models.Category;
|
||||||
import ru.ulstu.is.sbapp.HardwareShop.models.Manufacturer;
|
import ru.ulstu.is.sbapp.HardwareShop.models.Manufacturer;
|
||||||
|
|
||||||
|
|
||||||
@ -9,58 +13,85 @@ import javax.persistence.EntityManager;
|
|||||||
import javax.persistence.EntityNotFoundException;
|
import javax.persistence.EntityNotFoundException;
|
||||||
import javax.persistence.PersistenceContext;
|
import javax.persistence.PersistenceContext;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import ru.ulstu.is.sbapp.HardwareShop.models.Product;
|
||||||
|
import ru.ulstu.is.sbapp.HardwareShop.repository.ManufacturerRepository;
|
||||||
|
import ru.ulstu.is.sbapp.Util.Validation.ValidatorUtil;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class ManufacturerService {
|
public class ManufacturerService {
|
||||||
@PersistenceContext
|
@Autowired
|
||||||
private EntityManager em;
|
private final ManufacturerRepository manufacturerRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private final ValidatorUtil validatorUtil;
|
||||||
|
|
||||||
|
public ManufacturerService(ManufacturerRepository manufacturerRepository, ValidatorUtil validatorUtil) {
|
||||||
|
this.manufacturerRepository = manufacturerRepository;
|
||||||
|
this.validatorUtil = validatorUtil;
|
||||||
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Manufacturer addManufacturer(String name, String address) {
|
public Manufacturer addManufacturer(String name, String address) {
|
||||||
if (!StringUtils.hasText(name) || !StringUtils.hasText(address)) {
|
|
||||||
throw new IllegalArgumentException("Manufacturer name or address is null or empty");
|
|
||||||
}
|
|
||||||
final Manufacturer manufacturer = new Manufacturer(name, address);
|
final Manufacturer manufacturer = new Manufacturer(name, address);
|
||||||
em.persist(manufacturer);
|
validatorUtil.validate(manufacturer);
|
||||||
return manufacturer;
|
return manufacturerRepository.save(manufacturer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public Manufacturer addManufacturer(ManufacturerDTO manufacturerDTO) throws IOException {
|
||||||
|
final Manufacturer manufacturer = new Manufacturer(manufacturerDTO);
|
||||||
|
validatorUtil.validate(manufacturer);
|
||||||
|
return manufacturerRepository.save(manufacturer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void saveManufacturer(Manufacturer manufacturer) {
|
||||||
|
manufacturerRepository.save(manufacturer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public Manufacturer findManufacturer(Long id) {
|
public Manufacturer findManufacturer(Long id) {
|
||||||
final Manufacturer manufacturer = em.find(Manufacturer.class, id);
|
final Optional<Manufacturer> client = manufacturerRepository.findById(id);
|
||||||
if (manufacturer == null) {
|
return client.orElseThrow(() -> new ManufacturerNotFoundException(id));
|
||||||
throw new EntityNotFoundException(String.format("Manufacturer with id [%s] is not found", id));
|
|
||||||
}
|
|
||||||
return manufacturer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public List<Manufacturer> findAllManufacturers() {
|
public List<Manufacturer> findAllManufacturers() {
|
||||||
return em.createQuery("select s from Manufacturer s", Manufacturer.class)
|
return manufacturerRepository.findAll();
|
||||||
.getResultList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Manufacturer updateManufacturer(Long id, String name, String address) {
|
public Manufacturer updateManufacturer(Long id, String name, String address) {
|
||||||
if (!StringUtils.hasText(name) || !StringUtils.hasText(address)) {
|
|
||||||
throw new IllegalArgumentException("Manufacturer name or address is null or empty");
|
|
||||||
}
|
|
||||||
final Manufacturer currentManufacturer = findManufacturer(id);
|
final Manufacturer currentManufacturer = findManufacturer(id);
|
||||||
currentManufacturer.setName(name);
|
currentManufacturer.setName(name);
|
||||||
currentManufacturer.setName(address);
|
currentManufacturer.setAddress(address);
|
||||||
return em.merge(currentManufacturer);
|
validatorUtil.validate(currentManufacturer);
|
||||||
|
return manufacturerRepository.save(currentManufacturer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public Manufacturer updateManufacturer(Long id, ManufacturerDTO manufacturerDTO) {
|
||||||
|
final Manufacturer currentManufacturer = findManufacturer(id);
|
||||||
|
currentManufacturer.setName(manufacturerDTO.getName());
|
||||||
|
currentManufacturer.setAddress(manufacturerDTO.getAddress());
|
||||||
|
validatorUtil.validate(currentManufacturer);
|
||||||
|
return manufacturerRepository.save(currentManufacturer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Manufacturer deleteManufacturer(Long id) {
|
public Manufacturer deleteManufacturer(Long id) {
|
||||||
final Manufacturer currentManufacturer = findManufacturer(id);
|
final Manufacturer currentManufacturer = findManufacturer(id);
|
||||||
em.remove(currentManufacturer);
|
manufacturerRepository.delete(currentManufacturer);
|
||||||
return currentManufacturer;
|
return currentManufacturer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void deleteAllManufacturers() {
|
public void deleteAllManufacturers() {
|
||||||
em.createQuery("delete from Manufacturer").executeUpdate();
|
manufacturerRepository.deleteAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
package ru.ulstu.is.sbapp.HardwareShop.services;
|
||||||
|
|
||||||
|
public class ProductNotFoundException extends RuntimeException {
|
||||||
|
public ProductNotFoundException(Long id) {
|
||||||
|
super(String.format("Product with id [%s] is not found", id));
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,10 @@
|
|||||||
package ru.ulstu.is.sbapp.HardwareShop.services;
|
package ru.ulstu.is.sbapp.HardwareShop.services;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import ru.ulstu.is.sbapp.HardwareShop.controller.ProductDTO;
|
||||||
import ru.ulstu.is.sbapp.HardwareShop.models.Manufacturer;
|
import ru.ulstu.is.sbapp.HardwareShop.models.Manufacturer;
|
||||||
import ru.ulstu.is.sbapp.HardwareShop.models.Product;
|
import ru.ulstu.is.sbapp.HardwareShop.models.Product;
|
||||||
|
|
||||||
@ -10,77 +12,117 @@ import javax.persistence.EntityManager;
|
|||||||
import javax.persistence.EntityNotFoundException;
|
import javax.persistence.EntityNotFoundException;
|
||||||
import javax.persistence.PersistenceContext;
|
import javax.persistence.PersistenceContext;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import ru.ulstu.is.sbapp.HardwareShop.repository.ManufacturerRepository;
|
||||||
|
import ru.ulstu.is.sbapp.HardwareShop.repository.ProductRepository;
|
||||||
|
import ru.ulstu.is.sbapp.Util.Validation.ValidatorUtil;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class ProductService {
|
public class ProductService {
|
||||||
@PersistenceContext
|
@Autowired
|
||||||
private EntityManager em;
|
private final ProductRepository productRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private final ManufacturerService manufacturerService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private final CategoryService categoryService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private final ValidatorUtil validatorUtil;
|
||||||
|
|
||||||
|
public ProductService(ProductRepository productRepository, ValidatorUtil validatorUtil, ManufacturerService manufacturerService, CategoryService categoryService) {
|
||||||
|
this.productRepository = productRepository;
|
||||||
|
this.validatorUtil = validatorUtil;
|
||||||
|
this.manufacturerService = manufacturerService;
|
||||||
|
this.categoryService = categoryService;
|
||||||
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Product addProduct(Integer price, byte[] image) {
|
public Product addProduct(ProductDTO productDTO) throws IOException {
|
||||||
if (price == 0) {
|
final Product product = new Product(productDTO);
|
||||||
throw new IllegalArgumentException("Product price equal 0");
|
product.setCategory(categoryService.findCategory(productDTO.getCategory_id()));
|
||||||
|
validatorUtil.validate(product);
|
||||||
|
return productRepository.save(product);
|
||||||
}
|
}
|
||||||
final Product product = new Product(price, image);
|
|
||||||
em.persist(product);
|
@Transactional
|
||||||
return product;
|
public Product addProduct(Integer price, byte[] image, String name) {
|
||||||
|
final Product product = new Product(price, image, name);
|
||||||
|
validatorUtil.validate(product);
|
||||||
|
return productRepository.save(product);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public Product findProduct(Long id) {
|
public Product findProduct(Long id) {
|
||||||
final Product product = em.find(Product.class, id);
|
final Optional<Product> post = productRepository.findById(id);
|
||||||
if (product == null) {
|
return post.orElseThrow(() -> new ProductNotFoundException(id));
|
||||||
throw new EntityNotFoundException(String.format("Product with id [%s] is not found", id));
|
|
||||||
}
|
}
|
||||||
return product;
|
|
||||||
|
@Transactional
|
||||||
|
public void saveProduct(Product product) {
|
||||||
|
productRepository.save(product);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public List<Product> findAllProducts() {
|
public List<Product> findAllProducts() {
|
||||||
return em.createQuery("select s from Product s", Product.class)
|
return productRepository.findAll();
|
||||||
.getResultList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Product updateProduct(Long id, Integer price) {
|
public Product updateProduct(Long id, ProductDTO productDTO) {
|
||||||
if (price == 0) {
|
final Product currentProduct = findProduct(id);
|
||||||
throw new IllegalArgumentException("Product price equal 0");
|
currentProduct.setPrice(productDTO.getPrice());
|
||||||
|
/*currentProduct.setPhoto(productDTO.getPhoto().getBytes(StandardCharsets.UTF_8));*/
|
||||||
|
validatorUtil.validate(currentProduct);
|
||||||
|
return productRepository.save(currentProduct);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public Product updateProduct(Long id, Integer price, byte[] image) {
|
||||||
final Product currentProduct = findProduct(id);
|
final Product currentProduct = findProduct(id);
|
||||||
currentProduct.setPrice(price);
|
currentProduct.setPrice(price);
|
||||||
return em.merge(currentProduct);
|
/*currentProduct.setPhoto(image);*/
|
||||||
|
validatorUtil.validate(currentProduct);
|
||||||
|
return productRepository.save(currentProduct);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Product deleteProduct(Long id) {
|
public Product deleteProduct(Long id) {
|
||||||
final Product currentProduct = findProduct(id);
|
final Product currentProduct = findProduct(id);
|
||||||
em.remove(currentProduct);
|
productRepository.delete(currentProduct);
|
||||||
return currentProduct;
|
return currentProduct;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void deleteAllProducts() {
|
public void deleteAllProducts() {
|
||||||
em.createQuery("delete from Product").executeUpdate();
|
productRepository.deleteAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void addManufacturersToProduct(Long id, Manufacturer manufacturer) {
|
public void addManufacturersToProduct(Long id, Long manufacturer_id) {
|
||||||
final Product product = findProduct(id);
|
final Product currentProduct = findProduct(id);
|
||||||
if (product == null) {
|
final Manufacturer manufacturer = manufacturerService.findManufacturer(manufacturer_id);
|
||||||
throw new IllegalArgumentException("Product with id " + id + " not found");
|
currentProduct.addManufacturer(manufacturer);
|
||||||
}
|
validatorUtil.validate(currentProduct);
|
||||||
product.addManufacturer(manufacturer);
|
productRepository.save(currentProduct);
|
||||||
em.merge(product);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void removeManufacturersToProduct(Long id, Manufacturer manufacturer) {
|
public void removeManufacturersToProduct(Long id, Long manufacturer_id) {
|
||||||
final Product product = findProduct(id);
|
final Product currentProduct = findProduct(id);
|
||||||
if (product == null) {
|
currentProduct.removeManufacturer(manufacturerService.findManufacturer(manufacturer_id));
|
||||||
throw new IllegalArgumentException("Product with id " + id + " not found");
|
validatorUtil.validate(currentProduct);
|
||||||
|
productRepository.save(currentProduct);
|
||||||
}
|
}
|
||||||
product.removeManufacturer(manufacturer);
|
|
||||||
em.merge(product);
|
@Transactional
|
||||||
|
public List getProductManufacturers(Long id){
|
||||||
|
List manufacturers = productRepository.getManufacturers(id);
|
||||||
|
return manufacturers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
package ru.ulstu.is.sbapp.Util.Errors;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||||
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
|
import org.springframework.context.support.DefaultMessageSourceResolvable;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||||
|
|
||||||
|
import ru.ulstu.is.sbapp.Util.Validation.ValidationException;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@ControllerAdvice
|
||||||
|
public class AdviceController {
|
||||||
|
@ExceptionHandler({
|
||||||
|
ValidationException.class
|
||||||
|
})
|
||||||
|
public ResponseEntity<Object> handleException(Throwable e) {
|
||||||
|
return new ResponseEntity<>(e.getMessage(), HttpStatus.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||||
|
public ResponseEntity<Object> handleBindException(MethodArgumentNotValidException e) {
|
||||||
|
final ValidationException validationException = new ValidationException(
|
||||||
|
e.getBindingResult().getAllErrors().stream()
|
||||||
|
.map(DefaultMessageSourceResolvable::getDefaultMessage)
|
||||||
|
.collect(Collectors.toSet()));
|
||||||
|
return handleException(validationException);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ExceptionHandler(Exception.class)
|
||||||
|
public ResponseEntity<Object> handleUnknownException(Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package ru.ulstu.is.sbapp.Util.Validation;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class ValidationException extends RuntimeException {
|
||||||
|
public ValidationException(Set<String> errors) {
|
||||||
|
super(String.join("\n", errors));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package ru.ulstu.is.sbapp.Util.Validation;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.validation.ConstraintViolation;
|
||||||
|
import javax.validation.Validation;
|
||||||
|
import javax.validation.Validator;
|
||||||
|
import javax.validation.ValidatorFactory;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class ValidatorUtil {
|
||||||
|
private final Validator validator;
|
||||||
|
|
||||||
|
public ValidatorUtil() {
|
||||||
|
try (ValidatorFactory factory = Validation.buildDefaultValidatorFactory()) {
|
||||||
|
this.validator = factory.getValidator();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> void validate(T object) {
|
||||||
|
final Set<ConstraintViolation<T>> errors = validator.validate(object);
|
||||||
|
if (!errors.isEmpty()) {
|
||||||
|
throw new ValidationException(errors.stream()
|
||||||
|
.map(ConstraintViolation::getMessage)
|
||||||
|
.collect(Collectors.toSet()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,21 +0,0 @@
|
|||||||
package ru.ulstu.is.sbapp.calc.configuration;
|
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import ru.ulstu.is.sbapp.calc.domain.FloatArrayCalculator;
|
|
||||||
import ru.ulstu.is.sbapp.calc.domain.IntCalculator;
|
|
||||||
import ru.ulstu.is.sbapp.calc.domain.StringCalculator;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
public class TypeConfiguration {
|
|
||||||
@Bean(value = "int")
|
|
||||||
public IntCalculator createIntType() {
|
|
||||||
return new IntCalculator();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean(value = "string")
|
|
||||||
public StringCalculator createStringCalculator() { return new StringCalculator(); }
|
|
||||||
|
|
||||||
@Bean(value = "floatArray")
|
|
||||||
public FloatArrayCalculator createfloatArrayCalculator() { return new FloatArrayCalculator(); }
|
|
||||||
}
|
|
@ -1,33 +0,0 @@
|
|||||||
package ru.ulstu.is.sbapp.calc.controller;
|
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import ru.ulstu.is.sbapp.calc.service.CalculatorService;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
public class CalculatorController {
|
|
||||||
private final CalculatorService calculatorService;
|
|
||||||
|
|
||||||
public CalculatorController(CalculatorService calculatorService) { this.calculatorService = calculatorService; }
|
|
||||||
|
|
||||||
@GetMapping("/sum")
|
|
||||||
public Object sum(@RequestParam Object num1, @RequestParam int num2, @RequestParam(value = "operationType") String operationType) {
|
|
||||||
return calculatorService.getSum(num1, num2, operationType);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/diff")
|
|
||||||
public Object diff(@RequestParam Object num1, @RequestParam int num2, @RequestParam(value = "operationType") String operationType) {
|
|
||||||
return calculatorService.getDiff(num1, num2, operationType);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/mul")
|
|
||||||
public Object mul(@RequestParam Object num1, @RequestParam int num2, @RequestParam(value = "operationType") String operationType) {
|
|
||||||
return calculatorService.getMul(num1, num2, operationType);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/div")
|
|
||||||
public Object div(@RequestParam Object num1, @RequestParam int num2, @RequestParam(value = "operationType") String operationType) {
|
|
||||||
return calculatorService.getDiv(num1, num2, operationType);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
package ru.ulstu.is.sbapp.calc.domain;
|
|
||||||
|
|
||||||
public interface Calculator<T> {
|
|
||||||
public T sum(T num1, int num2);
|
|
||||||
public T diff(T num1, int num2);
|
|
||||||
public T multiply(T num1, int num2);
|
|
||||||
public T divide(T num1, int num2);
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
package ru.ulstu.is.sbapp.calc.domain;
|
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class FloatArrayCalculator implements Calculator<ArrayList<Float>>{
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ArrayList<Float> sum(ArrayList<Float> num1, int num2) {
|
|
||||||
ArrayList<Float> res = new ArrayList<>();
|
|
||||||
for (int i = 0; i < num1.size(); ++i) {
|
|
||||||
res.add(num1.get(i) + Float.parseFloat(Integer.toString(num2)));
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ArrayList<Float> diff(ArrayList<Float> num1, int num2) {
|
|
||||||
ArrayList<Float> res = new ArrayList<>();
|
|
||||||
for (int i = 0; i < num1.size(); ++i) {
|
|
||||||
res.add(num1.get(i) - Float.parseFloat(Integer.toString(num2)));
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ArrayList<Float> multiply(ArrayList<Float> num1, int num2) {
|
|
||||||
ArrayList<Float> res = new ArrayList<>();
|
|
||||||
for (int i = 0; i < num1.size(); ++i) {
|
|
||||||
res.add(num1.get(i) * Float.parseFloat(Integer.toString(num2)));
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ArrayList<Float> divide(ArrayList<Float> num1, int num2) {
|
|
||||||
ArrayList<Float> res = new ArrayList<>();
|
|
||||||
for (int i = 0; i < num1.size(); ++i) {
|
|
||||||
res.add(num1.get(i) / Float.parseFloat(Integer.toString(num2)));
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
package ru.ulstu.is.sbapp.calc.domain;
|
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
|
|
||||||
public class IntCalculator implements Calculator<Integer>{
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer sum(Integer num1, int num2) {
|
|
||||||
return num1 + num2;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer diff(Integer num1, int num2) {
|
|
||||||
return num1 - num2;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer multiply(Integer num1, int num2) {
|
|
||||||
return num1 * num2;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer divide(Integer num1, int num2) {
|
|
||||||
return num1 / num2;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
package ru.ulstu.is.sbapp.calc.domain;
|
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
public class StringCalculator implements Calculator<String>{
|
|
||||||
@Override
|
|
||||||
public String sum(String num1, int num2) {
|
|
||||||
return num1.concat(String.format(String.valueOf(num2)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String diff(String num1, int num2) {
|
|
||||||
String res = "";
|
|
||||||
if (num1.length() <= num2) {
|
|
||||||
return "Длинна первого аргумента меньше значения второго.";
|
|
||||||
}
|
|
||||||
for (int i = 0; i < num1.length() - num2; ++i) {
|
|
||||||
res += num1.charAt(i);
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String multiply(String num1, int num2) {
|
|
||||||
String res = "";
|
|
||||||
for (int i = 0; i < num2; ++i) {
|
|
||||||
res += num1;
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String divide(String num1, int num2) {
|
|
||||||
String res = "";
|
|
||||||
int len = num1.length() / num2;
|
|
||||||
if (len == 0) {
|
|
||||||
return "Длинна первого аргумента слишком маленькая относительно значения второго.";
|
|
||||||
}
|
|
||||||
for (int i = 0; i < len; ++i) {
|
|
||||||
res += num1.charAt(i);
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,69 +0,0 @@
|
|||||||
package ru.ulstu.is.sbapp.calc.service;
|
|
||||||
|
|
||||||
import org.springframework.context.ApplicationContext;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import ru.ulstu.is.sbapp.calc.domain.Calculator;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class CalculatorService {
|
|
||||||
private final ApplicationContext applicationContext;
|
|
||||||
|
|
||||||
public CalculatorService(ApplicationContext applicationContext) { this.applicationContext = applicationContext; }
|
|
||||||
|
|
||||||
private Calculator _calculator;
|
|
||||||
Object arg1 = "";
|
|
||||||
|
|
||||||
private void Num1Type(Object num1, int num2, String operationType) {
|
|
||||||
_calculator = (Calculator) applicationContext.getBean(operationType);
|
|
||||||
switch (operationType) {
|
|
||||||
case "int" -> {
|
|
||||||
try {
|
|
||||||
arg1 = Integer.valueOf(num1.toString());
|
|
||||||
}
|
|
||||||
catch (Exception ex) {
|
|
||||||
arg1 = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
case "floatArray" -> {
|
|
||||||
try {
|
|
||||||
arg1 = Arrays.stream(num1.toString().split(";"))
|
|
||||||
.map(Float::parseFloat)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (Exception ex) {
|
|
||||||
arg1 = num1.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
case "string" -> {
|
|
||||||
arg1 = num1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getSum(Object num1, int num2, String operationType) {
|
|
||||||
Num1Type(num1, num2, operationType);
|
|
||||||
return _calculator.sum(arg1, num2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getDiff(Object num1, int num2, String operationType) {
|
|
||||||
Num1Type(num1, num2, operationType);
|
|
||||||
return _calculator.diff(arg1, num2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getMul(Object num1, int num2, String operationType) {
|
|
||||||
Num1Type(num1, num2, operationType);
|
|
||||||
return _calculator.multiply(arg1, num2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getDiv(Object num1, int num2, String operationType) {
|
|
||||||
Num1Type(num1, num2, operationType);
|
|
||||||
return _calculator.divide(arg1, num2);
|
|
||||||
}
|
|
||||||
}
|
|
@ -51,7 +51,7 @@ public class JpaProductTests {
|
|||||||
String strImage;
|
String strImage;
|
||||||
strImage = ("data:" + localFile.getContentType() + ";base64," + Base64.getEncoder().encodeToString(localFile.getBytes()));
|
strImage = ("data:" + localFile.getContentType() + ";base64," + Base64.getEncoder().encodeToString(localFile.getBytes()));
|
||||||
productService.deleteAllProducts();
|
productService.deleteAllProducts();
|
||||||
final Product product = productService.addProduct(15000, strImage.getBytes());
|
final Product product = productService.addProduct(15000, strImage.getBytes(), "1412");
|
||||||
log.info(product.toString());
|
log.info(product.toString());
|
||||||
Assertions.assertNotNull(product.getId());
|
Assertions.assertNotNull(product.getId());
|
||||||
Assertions.assertNotNull(product.getPhoto());
|
Assertions.assertNotNull(product.getPhoto());
|
||||||
|
Loading…
Reference in New Issue
Block a user