Compare commits

...

No commits in common. "main" and "Lab_3" have entirely different histories.
main ... Lab_3

36 changed files with 3746 additions and 24 deletions

56
.gitignore vendored
View File

@ -1,26 +1,38 @@
# ---> Java
# Compiled class file
*.class
HELP.md
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
# Log file
*.log
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/
# BlueJ files
*.ctxt
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
### VS Code ###
.vscode/
/front/node_modules/

View File

@ -1,2 +0,0 @@
# Pibd-22_Presnyakova.V.V_IP

28
build.gradle Normal file
View File

@ -0,0 +1,28 @@
plugins {
id 'java'
id 'org.springframework.boot' version '2.7.8'
id 'io.spring.dependency-management' version '1.0.15.RELEASE'
}
group = 'ru.ulstu.is'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'com.h2database:h2:2.1.210'
implementation group: 'org.springdoc', name: 'springdoc-openapi-ui', version: '1.6.5'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation 'org.springframework.boot:spring-boot-starter-validation'
}
tasks.named('test') {
useJUnitPlatform()
}

BIN
data.mv.db Normal file

Binary file not shown.

1112
data.trace.db Normal file

File diff suppressed because it is too large Load Diff

82
front/index.html Normal file
View File

@ -0,0 +1,82 @@
<!DOCTYPE html>
<html xmlns:background="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8">
<title>Calculator</title>
<!-- Подключаем Bootstrap CSS -->
<script src="/node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="/node_modules/bootstrap/dist/css/bootstrap.min.css">
<style>
.btn{
background: aquamarine;
}
</style>
</head>
<body>
<div class="container mt-4">
<div class="row justify-content-center">
<div class="col-lg-6">
<div class="card shadow-lg">
<div class="card-header">
<h3 class="text-center font-weight-light my-2">IP</h3>
</div>
<div class="card-body">
<form>
<div class="form-row">
<div class="col">
<div class="form-group">
<label for="input1">Value 1</label>
<input type="text" class="form-control" id="input1" placeholder="Enter Value 1">
</div>
</div>
<div class="col">
<div class="form-group">
<label for="input2">Value 2</label>
<input type="text" class="form-control" id="input2" placeholder="Enter Value 2">
</div>
</div>
<div class="col">
<div class="form-group">
<label for="operator">Method</label>
<select class="form-control" id="operator">
<option value="Sum">+</option>
<option value="Min">-</option>
<option value="Mul">*</option>
<option value="Del">/</option>
</select>
</div>
</div>
<div class="col">
<div class="form-group">
<label for="operator">Type</label>
<select class="form-control" id="Type">
<option value="int">Integer</option>
<option value="str">String</option>
<option value="arr">Array</option>
</select>
</div>
</div>
<button type="button" class="btn" onclick="getResult()">Result</button>
</div>
<div class="form-group">
<label for="result">Result</label>
<input type="text" class="form-control result" id="result" readonly>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<script src = "script.js"></script>
</body>
</html>

804
front/package-lock.json generated Normal file
View File

@ -0,0 +1,804 @@
{
"name": "IP",
"version": "1.0.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "IP",
"version": "1.0.0",
"dependencies": {
"bootstrap": "5.2.1"
},
"devDependencies": {
"http-server": "^14.1.1"
}
},
"node_modules/@popperjs/core": {
"version": "2.11.7",
"resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.7.tgz",
"integrity": "sha512-Cr4OjIkipTtcXKjAsm8agyleBuDHvxzeBoa1v543lbv1YaIwQjESsVcmjiWiPEbC1FIeHOG/Op9kdCmAmiS3Kw==",
"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==",
"dev": true,
"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==",
"dev": true,
"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==",
"dev": true,
"dependencies": {
"safe-buffer": "5.1.2"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/bootstrap": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.2.1.tgz",
"integrity": "sha512-UQi3v2NpVPEi1n35dmRRzBJFlgvWHYwyem6yHhuT6afYF+sziEt46McRbT//kVXZ7b1YUYEVGdXEH74Nx3xzGA==",
"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==",
"dev": true,
"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==",
"dev": true,
"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==",
"dev": true,
"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==",
"dev": true
},
"node_modules/corser": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/corser/-/corser-2.0.1.tgz",
"integrity": "sha512-utCYNzRSQIZNPIcGZdQc92UVJYAhtGAteCFg0yRaFm8f0P+CPtyGyHXJcGXnffjCybUCEx3FQ2G7U3/o9eIkVQ==",
"dev": true,
"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==",
"dev": true,
"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==",
"dev": true
},
"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==",
"dev": true,
"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==",
"dev": true
},
"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==",
"dev": true,
"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==",
"dev": true,
"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==",
"dev": true,
"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==",
"dev": true,
"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==",
"dev": true,
"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==",
"dev": true,
"dependencies": {
"whatwg-encoding": "^2.0.0"
},
"engines": {
"node": ">=12"
}
},
"node_modules/html-encoding-sniffer/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==",
"dev": true,
"dependencies": {
"iconv-lite": "0.6.3"
},
"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==",
"dev": true,
"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==",
"dev": true,
"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==",
"dev": true,
"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==",
"dev": true
},
"node_modules/mime": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
"dev": true,
"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==",
"dev": true,
"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==",
"dev": true,
"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==",
"dev": true
},
"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==",
"dev": true,
"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==",
"dev": true,
"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==",
"dev": true,
"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==",
"dev": true,
"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==",
"dev": true
},
"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==",
"dev": true
},
"node_modules/safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
"dev": true
},
"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==",
"dev": true
},
"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==",
"dev": true,
"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==",
"dev": true,
"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==",
"dev": true,
"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==",
"dev": true
}
},
"dependencies": {
"@popperjs/core": {
"version": "2.11.7",
"resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.7.tgz",
"integrity": "sha512-Cr4OjIkipTtcXKjAsm8agyleBuDHvxzeBoa1v543lbv1YaIwQjESsVcmjiWiPEbC1FIeHOG/Op9kdCmAmiS3Kw==",
"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==",
"dev": true,
"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==",
"dev": true,
"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==",
"dev": true,
"requires": {
"safe-buffer": "5.1.2"
}
},
"bootstrap": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.2.1.tgz",
"integrity": "sha512-UQi3v2NpVPEi1n35dmRRzBJFlgvWHYwyem6yHhuT6afYF+sziEt46McRbT//kVXZ7b1YUYEVGdXEH74Nx3xzGA==",
"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==",
"dev": true,
"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==",
"dev": true,
"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==",
"dev": true,
"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==",
"dev": true
},
"corser": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/corser/-/corser-2.0.1.tgz",
"integrity": "sha512-utCYNzRSQIZNPIcGZdQc92UVJYAhtGAteCFg0yRaFm8f0P+CPtyGyHXJcGXnffjCybUCEx3FQ2G7U3/o9eIkVQ==",
"dev": true
},
"debug": {
"version": "3.2.7",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz",
"integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==",
"dev": true,
"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==",
"dev": true
},
"follow-redirects": {
"version": "1.15.2",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz",
"integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==",
"dev": true
},
"function-bind": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==",
"dev": true
},
"get-intrinsic": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.0.tgz",
"integrity": "sha512-L049y6nFOuom5wGyRc3/gdTLO94dySVKRACj1RmJZBQXlbTMhtNIgkWkUHq+jYmZvKf14EW1EoJnnjbmoHij0Q==",
"dev": true,
"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==",
"dev": true,
"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==",
"dev": true
},
"has-symbols": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz",
"integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==",
"dev": true
},
"he": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz",
"integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==",
"dev": true
},
"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==",
"dev": true,
"requires": {
"whatwg-encoding": "^2.0.0"
},
"dependencies": {
"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==",
"dev": true,
"requires": {
"iconv-lite": "0.6.3"
}
}
}
},
"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==",
"dev": true,
"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==",
"dev": true,
"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==",
"dev": true,
"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==",
"dev": true
},
"mime": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
"dev": true
},
"minimist": {
"version": "1.2.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz",
"integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==",
"dev": true
},
"mkdirp": {
"version": "0.5.6",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz",
"integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==",
"dev": true,
"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==",
"dev": true
},
"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==",
"dev": true
},
"opener": {
"version": "1.5.2",
"resolved": "https://registry.npmjs.org/opener/-/opener-1.5.2.tgz",
"integrity": "sha512-ur5UIdyw5Y7yEj9wLzhqXiy6GZ3Mwx0yGI+5sMn2r0N0v3cKJvUmFH5yPP+WXh9e0xfyzyJX95D8l088DNFj7A==",
"dev": true
},
"portfinder": {
"version": "1.0.32",
"resolved": "https://registry.npmjs.org/portfinder/-/portfinder-1.0.32.tgz",
"integrity": "sha512-on2ZJVVDXRADWE6jnQaX0ioEylzgBpQk8r55NE4wjXW1ZxO+BgDlY6DXwj20i0V8eB4SenDQ00WEaxfiIQPcxg==",
"dev": true,
"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==",
"dev": true,
"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==",
"dev": true
},
"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==",
"dev": true
},
"safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
"dev": true
},
"secure-compare": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/secure-compare/-/secure-compare-3.0.1.tgz",
"integrity": "sha512-AckIIV90rPDcBcglUwXPF3kg0P0qmPsPXAj6BBEENQE1p5yA1xfmDJzfi1Tappj37Pv2mVbKpL3Z1T+Nn7k1Qw==",
"dev": true
},
"side-channel": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz",
"integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==",
"dev": true,
"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==",
"dev": true,
"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==",
"dev": true,
"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==",
"dev": true
}
}
}

15
front/package.json Normal file
View File

@ -0,0 +1,15 @@
{
"name": "IP",
"version": "1.0.0",
"main": "index.html",
"scripts": {
"start": "http-server -p 3001 ./",
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"bootstrap": "5.2.1"
},
"devDependencies": {
"http-server": "^14.1.1"
}
}

17
front/script.js Normal file
View File

@ -0,0 +1,17 @@
'use strict'
function getResult() {
let num1 = document.getElementById("input1").value
let num2 = document.getElementById("input2").value
let operator = document.getElementById("operator").value
let result = document.getElementById("result")
let type = document.getElementById("Type").value
fetch(`http://localhost:8080/${operator}?Type=${type}&value1=${num1}&value2=${num2}`)
.then(response => response.text())
.then(data => {
result.value = data
})
}

BIN
gradle/wrapper/gradle-wrapper.jar vendored Normal file

Binary file not shown.

View File

@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

240
gradlew vendored Normal file
View File

@ -0,0 +1,240 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
APP_NAME="Gradle"
APP_BASE_NAME=${0##*/}
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"

91
gradlew.bat vendored Normal file
View File

@ -0,0 +1,91 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

1
settings.gradle Normal file
View File

@ -0,0 +1 @@
rootProject.name = 'sbapp'

View File

@ -0,0 +1,16 @@
package ru.ulstu.is.sbapp;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
public class SbappApplication {
public static void main(String[] args) {
SpringApplication.run(SbappApplication.class, args);
}
}

View File

@ -0,0 +1,15 @@
package ru.ulstu.is.sbapp;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebConfiguration implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry){
registry.addMapping("/**").allowedMethods("*");
}
}

View File

@ -0,0 +1,27 @@
package ru.ulstu.is.sbapp.configuration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import ru.ulstu.is.sbapp.domain.TypeInt;
import ru.ulstu.is.sbapp.domain.TypeString;
import ru.ulstu.is.sbapp.domain.TypeArray;
@Configuration
public class TypeConfiguration {
@Bean(value = "int")
public TypeInt createIntType(){
return new TypeInt();
}
@Bean(value = "str")
public TypeString createStrType(){
return new TypeString();
}
@Bean(value = "arr")
public TypeArray createArrayType(){
return new TypeArray();
}
}

View File

@ -0,0 +1,44 @@
package ru.ulstu.is.sbapp.controllers;
import org.springframework.stereotype.Service;
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.service.TypeService;
@RestController
public class MainController {
private final TypeService Service;
public MainController(TypeService service) {
Service = service;
}
@GetMapping("/Sum")
public Object Sum(@RequestParam(value = "Type") String Type,
@RequestParam(value = "value1") Object value1,
@RequestParam(value = "value2") Object value2){
return Service.Sum(value1,value2,Type);
}
@GetMapping("/Min")
public Object Min(@RequestParam(value = "Type") String Type,
@RequestParam(value = "value1") Object value1,
@RequestParam(value = "value2") Object value2){
return Service.Min(value1,value2,Type);
}
@GetMapping("/Mul")
public Object Mul(@RequestParam(value = "Type") String Type,
@RequestParam(value = "value1") Object value1,
@RequestParam(value = "value2") Object value2){
return Service.Mul(value1,value2,Type);
}
@GetMapping("/Del")
public Object Del(@RequestParam(value = "Type") String Type,
@RequestParam(value = "value1") Object value1,
@RequestParam(value = "value2") Object value2){
return Service.Del(value1,value2,Type);
}
}

View File

@ -0,0 +1,8 @@
package ru.ulstu.is.sbapp.domain;
public interface ITypeInterface<T> {
T Sum(T value1, T value2);
T Min(T value1, T value2);
T Mul(T value1, T value2);
T Del(T value1, T value2);
}

View File

@ -0,0 +1,39 @@
package ru.ulstu.is.sbapp.domain;
public class TypeArray implements ITypeInterface<int[]>{
@Override
public int[] Sum(int[] value1, int[] value2) {
int [] ans = new int[Math.min(value1.length, value2.length)];
for (int i = 0; i < Math.min(value1.length, value2.length); i ++){
ans[i] = value1[i] + value2[i];
}
return ans;
}
@Override
public int[] Min(int[] value1, int[] value2) {
int [] ans = new int[Math.min(value1.length, value2.length)];
for (int i = 0; i < Math.min(value1.length, value2.length); i ++){
ans[i] = value1[i] - value2[i];
}
return ans;
}
@Override
public int[] Mul(int[] value1, int[] value2) {
int [] ans = new int[Math.min(value1.length, value2.length)];
for (int i = 0; i < Math.min(value1.length, value2.length); i ++){
ans[i] = value1[i] * value2[i];
}
return ans;
}
@Override
public int[] Del(int[] value1, int[] value2) {
int [] ans = new int[Math.min(value1.length, value2.length)];
for (int i = 0; i < Math.min(value1.length, value2.length); i ++){
ans[i] = value1[i] / value2[i];
}
return ans;
}
}

View File

@ -0,0 +1,23 @@
package ru.ulstu.is.sbapp.domain;
public class TypeInt implements ITypeInterface<Integer>{
@Override
public Integer Sum(Integer value1, Integer value2) {
return value1 + value2;
}
@Override
public Integer Min(Integer value1, Integer value2) {
return value1 - value2;
}
@Override
public Integer Mul(Integer value1, Integer value2) {
return value1 * value2;
}
@Override
public Integer Del(Integer value1, Integer value2) {
return value1 / value2;
}
}

View File

@ -0,0 +1,38 @@
package ru.ulstu.is.sbapp.domain;
public class TypeString implements ITypeInterface<String>{
@Override
public String Sum(String value1, String value2) {
return value1 + value2;
}
@Override
public String Min(String value1, String value2) {
if (value1.length() < value2.length()){
String temp = value1;
value1 = value2;
value2 = temp;
}
return value1.substring(value2.length());
}
@Override
public String Mul(String value1, String value2) {
value1 = value1 + value2;
String ans = "";
for (int i = 0; i < value2.length(); i ++){
ans = Sum(ans,value1);
}
return ans;
}
@Override
public String Del(String value1, String value2) {
if (value1.length() < value2.length()){
String temp = value1;
value1 = value2;
value2 = temp;
}
return value1.replaceAll(value2, "");
}
}

View File

@ -0,0 +1,31 @@
package ru.ulstu.is.sbapp.repair.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import ru.ulstu.is.sbapp.repair.service.Order_FavorService;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.Date;
import java.util.Map;
@RestController
public class ReportController {
private final Order_FavorService orderFavorService;
@Autowired
public ReportController(Order_FavorService orderFavorService) {
this.orderFavorService = orderFavorService;
}
@GetMapping("/report")
public Map<String, Integer> GetReport (@RequestParam(value = "from") Object value1,
@RequestParam(value = "to") Object value2) throws ParseException {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
Date d1 = formatter.parse(value1.toString());
Date d2 = formatter.parse(value2.toString());
return orderFavorService.makereport(d1, d2);
}
}

View File

@ -0,0 +1,94 @@
package ru.ulstu.is.sbapp.repair.model;
import org.springframework.cache.interceptor.CacheableOperation;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@Entity
@Table(name = "components")
public class Component {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(name = "name")
private String componentName;
@Column(name = "amount")
private Integer amount;
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinColumn(name = "component_fk")
private List<Component_Favor> favorsListFromComponents;
public Component() {
favorsListFromComponents = new ArrayList<>();
}
public Component(String componentName, Integer amount) {
this.componentName = componentName;
this.amount = amount;
favorsListFromComponents = new ArrayList<>();
}
public Long getId() {
return id;
}
public String getComponentName() {
return componentName;
}
public void setComponentName(String componentName) {
this.componentName = componentName;
}
public Integer getAmount() {
return amount;
}
public void setAmount(Integer amount) {
this.amount = amount;
}
public List<Component_Favor> getFavors() {
return favorsListFromComponents;
}
public void addFavor(Component_Favor favor) {
if (favorsListFromComponents == null)
favorsListFromComponents = new ArrayList<>();
if (!favorsListFromComponents.contains(favor)){
favorsListFromComponents.add(favor);
}
/*
if (!favor.getComponents().contains(this)) {
favor.addComponent(this);
}*/
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Component component = (Component) o;
return Objects.equals(id, component.id);
}
@Override
public int hashCode() {
return Objects.hash(id);
}
@Override
public String toString() {
return "Component{" +
"id=" + id +
", componentName='" + componentName + '\'' +
", amount='" + amount + '\'' +
'}';
}
}

View File

@ -0,0 +1,68 @@
package ru.ulstu.is.sbapp.repair.model;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@Entity
@Table(name = "components_favors")
public class Component_Favor {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(name = "amount")
private Integer amount;
public Component_Favor() {
}
public Component_Favor(Integer amount) {
this.amount = amount;
}
public Long getId() {
return id;
}
public Integer getAmount() {
return amount;
}
public void setAmount(Integer amount) {
this.amount = amount;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Component_Favor cf = (Component_Favor) o;
return Objects.equals(id, cf.id);
}
/*
public void addComponent(Component component){
if (componentsList == null)
componentsList = new ArrayList<>();
if (!componentsList.contains(component)){
componentsList.add(component);
}
if (!component.getFavors().contains(this)) {
component.addFavor(this);
}
}
*/
@Override
public int hashCode() {
return Objects.hash(id);
}
@Override
public String toString() {
return "Product{" +
"id=" + id +
'}';
}
}

View File

@ -0,0 +1,126 @@
package ru.ulstu.is.sbapp.repair.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@Entity
@Table(name = "favors")
public class Favor {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(name = "name")
private String favorName;
@Column(name = "price")
private Integer price;
@OneToMany (cascade = CascadeType.ALL)
@JoinColumn(name = "favor_fk")
private List<Order_Favor> ordersList;
@OneToMany (cascade = CascadeType.ALL)
@LazyCollection(LazyCollectionOption.FALSE)
@JoinColumn(name = "favor_fk")
private List<Component_Favor> componentsList;
public Favor() {
componentsList = new ArrayList<>();
ordersList = new ArrayList<>();
}
public Favor(String favorName, Integer price) {
this.favorName = favorName;
this.price = price;
componentsList = new ArrayList<>();
ordersList = new ArrayList<>();
}
public Long getId() {
return id;
}
public String getFavorName() {
return favorName;
}
public void setFavorName(String favorName) {
this.favorName = favorName;
}
public Integer getPrice() {
return price;
}
public void setPrice(Integer price) {
this.price = price;
}
public List<Order_Favor> getOrders() {
return ordersList;
}
public List<Component_Favor> getComponents() {return componentsList;}
public void addOrder(Order_Favor of) {
if (ordersList == null)
ordersList = new ArrayList<>();
if (!ordersList.contains(of)){
ordersList.add(of);
of.setFavor_id(this);
}
}
public void addCF(Component_Favor cf) {
if (componentsList == null)
componentsList = new ArrayList<>();
if (!componentsList.contains(cf)){
componentsList.add(cf);
}
/*
if (!order.getFavorsList().contains(this)) {
order.addFavor(this);
}*/
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Favor favor = (Favor) o;
return Objects.equals(id, favor.id);
}
/*
public void addComponent(Component component){
if (componentsList == null)
componentsList = new ArrayList<>();
if (!componentsList.contains(component)){
componentsList.add(component);
}
if (!component.getFavors().contains(this)) {
component.addFavor(this);
}
}
*/
@Override
public int hashCode() {
return Objects.hash(id);
}
@Override
public String toString() {
return "Product{" +
"id=" + id +
", productName='" + favorName + '\'' +
", price='" + price + '\'' +
'}';
}
}

View File

@ -0,0 +1,71 @@
package ru.ulstu.is.sbapp.repair.model;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
@Entity
@Table(name = "orders")
public class Order {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(name = "date")
private Date date;
@OneToMany (cascade = CascadeType.ALL)
@JoinColumn(name = "order_fk")
private List<Order_Favor> favorsList;
public Order(){
}
public Order(Date date) {
this.date = date;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Order order)) return false;
return Objects.equals(getId(), order.getId()) && Objects.equals(getDate(), order.getDate());
}
public List<Order_Favor> getFavorsList() {
return favorsList;
}
public void addFavor(Order_Favor of){
if (favorsList == null)
favorsList = new ArrayList<>();
if (!favorsList.contains(of)) {
favorsList.add(of);
of.setOrder_id(this);
}
//favor.addOrder(this);
}
@Override
public int hashCode() {
return Objects.hash(getId(), getDate());
}
}

View File

@ -0,0 +1,89 @@
package ru.ulstu.is.sbapp.repair.model;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@Entity
@Table(name = "orders_favors")
public class Order_Favor {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(name = "amount")
private Integer amount;
@ManyToOne
private Order Order_id;
@ManyToOne
private Favor Favor_id;
public Order_Favor() {
}
public Order_Favor(Integer amount) {
this.amount = amount;
}
public Long getId() {
return id;
}
public Integer getAmount() {
return amount;
}
public void setAmount(Integer amount) {
this.amount = amount;
}
public Favor getFavor_id() {
return Favor_id;
}
public void setFavor_id(Favor favor_id) {
Favor_id = favor_id;
}
public Order getOrder_id() {
return Order_id;
}
public void setOrder_id(Order order_id) {
Order_id = order_id;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Order_Favor of = (Order_Favor) o;
return Objects.equals(id, of.id);
}
/*
public void addComponent(Component component){
if (componentsList == null)
componentsList = new ArrayList<>();
if (!componentsList.contains(component)){
componentsList.add(component);
}
if (!component.getFavors().contains(this)) {
component.addFavor(this);
}
}
*/
@Override
public int hashCode() {
return Objects.hash(id);
}
@Override
public String toString() {
return "Product{" +
"id=" + id +
'}';
}
}

View File

@ -0,0 +1,68 @@
package ru.ulstu.is.sbapp.repair.service;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import ru.ulstu.is.sbapp.repair.model.Component;
import javax.persistence.EntityManager;
import javax.persistence.EntityNotFoundException;
import javax.persistence.PersistenceContext;
import java.util.ArrayList;
import java.util.List;
@Service
public class ComponentService {
@PersistenceContext
private EntityManager em;
@Transactional
public Component addComponent(String componentName, Integer amount) {
if (!StringUtils.hasText(componentName) || amount == 0) {
throw new IllegalArgumentException("Component is null or empty");
}
final Component component = new Component(componentName, amount);
em.persist(component);
return component;
}
@Transactional(readOnly = true)
public Component findComponent(Long id) {
final Component component = em.find(Component.class, id);
if (component == null) {
throw new EntityNotFoundException(String.format("Component with id [%s] is not found", id));
}
return component;
}
@Transactional(readOnly = true)
public List<Component> findAllComponent() {
return em.createQuery("select c from Component c", Component.class)
.getResultList();
}
@Transactional
public Component updateComponent(Long id, String componentName, Integer amount) {
if (!StringUtils.hasText(componentName) || amount == 0) {
throw new IllegalArgumentException("Component is null or empty");
}
final Component currentComponent = findComponent(id);
currentComponent.setComponentName(componentName);
currentComponent.setAmount(amount);
return em.merge(currentComponent);
}
@Transactional
public Component deleteComponent(Long id) {
final Component currentComponent = findComponent(id);
em.remove(currentComponent);
return currentComponent;
}
@Transactional
public void deleteAllComponent() {
em.createQuery("delete from Component").executeUpdate();
}
}

View File

@ -0,0 +1,65 @@
package ru.ulstu.is.sbapp.repair.service;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import ru.ulstu.is.sbapp.repair.model.Component;
import ru.ulstu.is.sbapp.repair.model.Component_Favor;
import ru.ulstu.is.sbapp.repair.model.Favor;
import javax.persistence.EntityManager;
import javax.persistence.EntityNotFoundException;
import javax.persistence.PersistenceContext;
import java.util.List;
@Service
public class Component_FavorService {
@PersistenceContext
private EntityManager em;
@Transactional
public Component_Favor addComponent_Favor(Integer amount) {
if (amount == 0) {
throw new IllegalArgumentException("amount cant be 0");
}
final Component_Favor cf = new Component_Favor(amount);
em.persist(cf);
return cf;
}
@Transactional(readOnly = true)
public Component_Favor findComponent_Favor(Long id) {
final Component_Favor cf = em.find(Component_Favor.class, id);
if (cf == null) {
throw new EntityNotFoundException(String.format("cf with id [%s] is not found", id));
}
return cf;
}
@Transactional(readOnly = true)
public List<Component_Favor> findAllComponentFavors() {
return em.createQuery("select p from Component_Favor p", Component_Favor.class).getResultList();
}
@Transactional
public Component_Favor updateComponentFavor(Long id, Integer amount) {
if (amount == 0) {
throw new IllegalArgumentException("amount = 0");
}
final Component_Favor cf = findComponent_Favor(id);
cf.setAmount(amount);
em.merge(cf);
return cf;
}
@Transactional
public Component_Favor deleteFavor(Long id) {
final Component_Favor cf = findComponent_Favor(id);
em.remove(cf);
return cf;
}
@Transactional
public void deleteAllComponentFavor() {
em.createQuery("delete from Component_Favor ").executeUpdate();
}
}

View File

@ -0,0 +1,96 @@
package ru.ulstu.is.sbapp.repair.service;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import ru.ulstu.is.sbapp.repair.model.Component;
import ru.ulstu.is.sbapp.repair.model.Component_Favor;
import ru.ulstu.is.sbapp.repair.model.Favor;
import ru.ulstu.is.sbapp.repair.model.Order;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.EntityNotFoundException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
@Service
public class FavorService {
@PersistenceContext
private EntityManager em;
@Transactional
public Favor addFavor(String favorName, Integer price) {
if (!StringUtils.hasText(favorName) || price == 0) {
throw new IllegalArgumentException("Favor name is null or empty");
}
final Favor favor = new Favor(favorName, price);
em.persist(favor);
return favor;
}
@Transactional(readOnly = true)
public Favor findFavor(Long id) {
final Favor favor = em.find(Favor.class, id);
if (favor == null) {
throw new EntityNotFoundException(String.format("Favor with id [%s] is not found", id));
}
return favor;
}
@Transactional(readOnly = true)
public List<Favor> findAllFavor() {
return em.createQuery("select p from Favor p", Favor.class)
.getResultList();
}
@Transactional
public Favor updateFavor(Long id, String favorName, Integer price) {
if (!StringUtils.hasText(favorName) || price == 0) {
throw new IllegalArgumentException("Favor name is null or empty");
}
final Favor currentFavor = findFavor(id);
currentFavor.setFavorName(favorName);
currentFavor.setPrice(price);
em.merge(currentFavor);
return currentFavor;
}
@Transactional
public Favor deleteFavor(Long id) {
final Favor currentFavor = findFavor(id);
em.remove(currentFavor);
return currentFavor;
}
@Transactional
public Favor addComponentToFavor(Long id, Component component, Component_Favor cf){
final Favor currentFavor = findFavor(id);
if (currentFavor == null){
throw new IllegalArgumentException("Favor with id: " + id + " not found");
}
if (component == null){
throw new IllegalArgumentException("favor not found");
}
//currentFavor.addComponent(component);
//component.addFavor(currentFavor);
//final Component_Favor cf = new Component_Favor(amount);
currentFavor.addCF(cf);
component.addFavor(cf);
em.merge(component);
return em.merge(currentFavor);
}
@Transactional
public void deleteAllFavor() {
em.createQuery("delete from Favor").executeUpdate();
}
}

View File

@ -0,0 +1,98 @@
package ru.ulstu.is.sbapp.repair.service;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import ru.ulstu.is.sbapp.repair.model.Favor;
import ru.ulstu.is.sbapp.repair.model.Order;
import ru.ulstu.is.sbapp.repair.model.Order_Favor;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.EntityNotFoundException;
import java.text.SimpleDateFormat;
import java.util.*;
@Service
public class OrderService {
@PersistenceContext
private EntityManager em;
@Transactional
public Order addOrder(String date) {
if (!StringUtils.hasText(date)) {
throw new IllegalArgumentException("Order is null or empty");
}
Date correctDate = getDate(date);
final Order order = new Order(correctDate);
em.persist(order);
return order;
}
public Date getDate(String date) {
SimpleDateFormat format = new SimpleDateFormat();
format.applyPattern("dd.MM.yyyy");
Date newDate;
try {
newDate = format.parse(date);
} catch (Exception exception) {
newDate = new Date();
}
return newDate;
}
@Transactional(readOnly = true)
public Order findOrder(Long id) {
final Order order = em.find(Order.class, id);
if (order == null) {
throw new EntityNotFoundException(String.format("Order with id [%s] is not found", id));
}
return order;
}
@Transactional(readOnly = true)
public List<Order> findAllOrders() {
return em.createQuery("select o from Order o", Order.class)
.getResultList();
}
@Transactional
public Order updateOrder(Long id, String date, Integer price, Integer[] count, List<Favor> favors) {
if (!StringUtils.hasText(date) || price == 0 || count.length == 0 || Arrays.stream(count).filter(c -> c == 0).toList().size() != 0 || favors.size() == 0 || favors.stream().filter(Objects::isNull).toList().size() != 0 || count.length != favors.size()) {
throw new IllegalArgumentException("Order is null or empty");
}
final Order currentOrder = findOrder(id);
currentOrder.setDate(getDate(date));
em.merge(currentOrder);
return currentOrder;
}
@Transactional
public Order deleteOrder(Long id) {
final Order currentOrder = findOrder(id);
em.remove(currentOrder);
return currentOrder;
}
@Transactional
public Order addFavorToOrder(Long id, Favor favor, Order_Favor of){
final Order currentOrder = findOrder(id);
if (currentOrder == null){
throw new IllegalArgumentException("Order with id: " + id + " not found");
}
if (favor == null){
throw new IllegalArgumentException("favor not found");
}
currentOrder.addFavor(of);
favor.addOrder(of);
em.merge(favor);
return em.merge(currentOrder);
}
@Transactional
public void deleteAllOrder() {
em.createQuery("delete from Order").executeUpdate();
}
}

View File

@ -0,0 +1,87 @@
package ru.ulstu.is.sbapp.repair.service;
import org.aspectj.weaver.ast.Or;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import ru.ulstu.is.sbapp.repair.model.Component_Favor;
import ru.ulstu.is.sbapp.repair.model.Order_Favor;
import javax.persistence.EntityManager;
import javax.persistence.EntityNotFoundException;
import javax.persistence.PersistenceContext;
import javax.persistence.Tuple;
import java.time.LocalDate;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
public class Order_FavorService {
@PersistenceContext
private EntityManager em;
@Transactional
public Order_Favor addOrder_Favor(Integer amount) {
if (amount == 0) {
throw new IllegalArgumentException("amount cant be 0");
}
final Order_Favor cf = new Order_Favor(amount);
em.persist(cf);
return cf;
}
@Transactional(readOnly = true)
public Order_Favor findOrder_Favor(Long id) {
final Order_Favor cf = em.find(Order_Favor.class, id);
if (cf == null) {
throw new EntityNotFoundException(String.format("cf with id [%s] is not found", id));
}
return cf;
}
@Transactional(readOnly = true)
public List<Order_Favor> findAllOrderFavors() {
return em.createQuery("select p from Order_Favor p", Order_Favor.class).getResultList();
}
@Transactional
public Order_Favor updateOrderFavor(Long id, Integer amount) {
if (amount == 0) {
throw new IllegalArgumentException("amount = 0");
}
final Order_Favor cf = findOrder_Favor(id);
cf.setAmount(amount);
em.merge(cf);
return cf;
}
@Transactional
public Order_Favor deleteFavor(Long id) {
final Order_Favor cf = findOrder_Favor(id);
em.remove(cf);
return cf;
}
@Transactional
public void deleteAllComponentFavor() {
em.createQuery("delete from Order_Favor ").executeUpdate();
}
@Transactional
public Map<String, Integer> makereport(Date d1, Date d2){
//s = em.createQuery("SELECT sum(off.amount) * f.price from Order_Favor off join off.Favor_id f join off.Order_id o where o.date > '2023-02-01' and o.date < '2023-03-01' group by f.favorName").getResultList().toString();
//String s1 = em.createQuery("SELECT f.favorName from Order_Favor off join off.Favor_id f join off.Order_id o where o.date > '2023-02-01' and o.date < '2023-03-01' group by f.favorName").getResultList().toString();
//String s1 = em.createQuery("SELECT off.amount from Order_Favor off join off.Favor_id f join off.Order_id o where o.date > '2023-02-01' and o.date < '2023-03-01' group by f.favorName").getResultList().toString();
//s = em.createQuery("SELECT f.favorName from Order_Favor off join off.Favor_id f join off.Order_id o where o.date > :d1 ").setParameter("d1", new Date(2023, 2, 1)).getResultList().toString();
//s = em.createQuery("SELECT f.favorName, f.price, count(f.favorName) as count, count(f.favorName) * f.price as total from Order_Favor of join Order o on o.id = of.Order_id join Favor f on f.id = of.Favor_id where o.date > '01.02.2023' and o.date < '01.03.2023' group by f.favorName").getResultList().toString();
//s = em.createQuery("SELECT count(f.favorName) * f.price from Favor f group by favorName").getResultList().toString();
Map<String, Integer> answ = em.createQuery("SELECT f.favorName as n, sum(off.amount) * f.price as s from Order_Favor off join off.Favor_id f join off.Order_id o where o.date > :date1 and o.date < :date2 group by f.favorName", Tuple.class).setParameter("date1", d1).setParameter("date2", d2).getResultStream().collect(Collectors.toMap(tuple -> ((String)tuple.get("n")).toString(), tuple -> ((Number) tuple.get("s")).intValue()));
//String ans = em.createQuery("SELECT f.favorName, sum(off.amount) * f.price from Order_Favor off join off.Favor_id f join off.Order_id o where o.date > '2023-02-01' and o.date < '2023-03-01' group by f.favorName").getResultList().toString();
return answ;
}
}

View File

@ -0,0 +1,70 @@
package ru.ulstu.is.sbapp.service;
import org.springframework.stereotype.Service;
import org.springframework.context.ApplicationContext;
import ru.ulstu.is.sbapp.domain.ITypeInterface;
import java.util.Arrays;
@Service
public class TypeService {
private final ApplicationContext applicationContext;
private ITypeInterface _type;
private Object _value1;
private Object _value2;
public TypeService(ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
}
private void ValidateParams(Object value1, Object value2, String type){
_type = (ITypeInterface)applicationContext.getBean(type);
switch (type) {
case "arr" ->{
try {
_value1 = Arrays.stream(value1.toString().split(",")).mapToInt(Integer::valueOf).toArray();
_value2 = Arrays.stream(value2.toString().split(",")).mapToInt(Integer::valueOf).toArray();
}catch (Exception ex){
_value1 = new int[] {0};
_value2 = new int[] {0};
}
}
case "int" -> {
try {
_value1 = Integer.valueOf(value1.toString());
_value2 = Integer.valueOf(value2.toString());
}catch (Exception ex){
_value1 = 0;
_value2 = 0;
}
}
case "str" -> {
_value1 = value1;
_value2 = value2;
}
}
}
public Object Sum(Object value1, Object value2, String type){
ValidateParams(value1,value2,type);
return _type.Sum(_value1,_value2);
}
public Object Min(Object value1, Object value2, String type){
ValidateParams(value1,value2,type);
return _type.Min(_value1,_value2);
}
public Object Mul(Object value1, Object value2, String type){
ValidateParams(value1,value2,type);
return _type.Mul(_value1,_value2);
}
public Object Del(Object value1, Object value2, String type){
ValidateParams(value1,value2,type);
return _type.Del(_value1,_value2);
}
}

View File

@ -0,0 +1,11 @@
spring.main.banner-mode=off
#server.port=8080
spring.datasource.url=jdbc:h2:file:./data
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=password
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.jpa.hibernate.ddl-auto=update
spring.h2.console.enabled=true
spring.h2.console.settings.trace=false
spring.h2.console.settings.web-allow-others=false

View File

@ -0,0 +1,133 @@
package ru.ulstu.is.sbapp;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import ru.ulstu.is.sbapp.repair.model.*;
import ru.ulstu.is.sbapp.repair.service.*;
import javax.persistence.EntityNotFoundException;
import java.util.List;
@SpringBootTest
class SbappApplicationTests {
@Autowired
private ComponentService componentService;
@Autowired
private FavorService favorService;
@Autowired
private OrderService orderService;
@Autowired
private Component_FavorService cfService;
@Autowired
private Order_FavorService ofService;
@Test
void testReport(){
ofService.deleteAllComponentFavor();
cfService.deleteAllComponentFavor();
componentService.deleteAllComponent();
orderService.deleteAllOrder();
favorService.deleteAllFavor();
final Favor favor = favorService.addFavor("Favor1", 100);
final Favor favor1 = favorService.addFavor("Favor2", 200);
final Favor favor2 = favorService.addFavor("Favor3", 300);
final Order order0 = orderService.addOrder("11.02.2023");
final Order order1 = orderService.addOrder("12.02.2023");
final Order order2 = orderService.addOrder("13.02.2023");
final Order_Favor of = ofService.addOrder_Favor(10);
final Order_Favor of1 = ofService.addOrder_Favor(11);
final Order_Favor of2 = ofService.addOrder_Favor(12);
final Order_Favor of3 = ofService.addOrder_Favor(13);
orderService.addFavorToOrder(order0.getId(), favor, of);
orderService.addFavorToOrder(order0.getId(), favor1, of1);
orderService.addFavorToOrder(order1.getId(), favor, of2);
orderService.addFavorToOrder(order1.getId(), favor2, of3);
//final List<Order_Favor> lst = ofService.makereport();
//Assertions.assertEquals(lst.get(0).getAmount(), 10);
}
@Test
void testOrder(){
cfService.deleteAllComponentFavor();
ofService.deleteAllComponentFavor();
componentService.deleteAllComponent();
orderService.deleteAllOrder();
favorService.deleteAllFavor();
final Favor favor = favorService.addFavor("Favor1", 100);
final Order order0 = orderService.addOrder("11.02.2023");
final Order order1 = orderService.findOrder(order0.getId());
Assertions.assertEquals(order0, order1);
final Order_Favor of = ofService.addOrder_Favor(10);
orderService.addFavorToOrder(order0.getId(), favor, of);
Assertions.assertEquals(favorService.findFavor(favor.getId()).getOrders().size(), 1);
Assertions.assertEquals(orderService.findOrder(order0.getId()).getFavorsList().size(), 1);
orderService.deleteOrder(order0.getId());
Assertions.assertThrows(EntityNotFoundException.class, () -> orderService.findOrder(order0.getId()));
}
@Test
void testFavor(){
cfService.deleteAllComponentFavor();
ofService.deleteAllComponentFavor();
componentService.deleteAllComponent();
orderService.deleteAllOrder();
favorService.deleteAllFavor();
final Component component = componentService.addComponent("Favor1", 100);
final Favor favor0 = favorService.addFavor("fvr", 100);
final Favor favor1 = favorService.findFavor(favor0.getId());
Assertions.assertEquals(favor0, favor1);
final Component_Favor cf = cfService.addComponent_Favor(10);
favorService.addComponentToFavor(favor0.getId(), component, cf);
Assertions.assertEquals(favorService.findFavor(favor0.getId()).getComponents().size(), 1);
Assertions.assertEquals(componentService.findComponent(component.getId()).getFavors().size(), 1);
favorService.deleteFavor(favor0.getId());
Assertions.assertThrows(EntityNotFoundException.class, () -> favorService.findFavor(favor0.getId()));
}
@Test
void testComponent(){
cfService.deleteAllComponentFavor();
ofService.deleteAllComponentFavor();
favorService.deleteAllFavor();
componentService.deleteAllComponent();
orderService.deleteAllOrder();
final Component component0 = componentService.addComponent("comp", 111);
final Component component1 = componentService.findComponent(component0.getId());
Assertions.assertEquals(component0, component1);
componentService.deleteComponent(component0.getId());
Assertions.assertThrows(EntityNotFoundException.class, () -> componentService.findComponent(component0.getId()));
}
}