Compare commits

..

11 Commits

Author SHA1 Message Date
ArtemEmelyanov
772120ed1f Ну вроде сделал vue 2023-06-15 18:02:03 +04:00
ArtemEmelyanov
7de8e172de Сданная лаба 2023-04-21 13:38:51 +04:00
ArtemEmelyanov
71a1250ae1 Чуток тесты не проходят 2023-04-15 17:40:26 +04:00
ArtemEmelyanov
3ecb50cec8 Все дописано, осталось наладить связи 2023-04-15 17:09:21 +04:00
ArtemEmelyanov
97d5ae0cf4 Осталось добавить взаимодействие между сущностями 2023-04-15 15:42:27 +04:00
ArtemEmelyanov
8595331a1d ок 2023-04-14 22:00:27 +04:00
ArtemEmelyanov
4f9bba63ee Для данила 2023-03-26 12:53:15 +04:00
ArtemEmelyanov
4b71c89826 Добавлены сущности, не полностью 2023-03-20 16:04:15 +04:00
ArtemEmelyanov
63c115f8be LabWork_02 добвлен еще один тип, лаба сдана 2023-03-20 14:52:50 +04:00
ArtemEmelyanov
d80f64a86e LabWork_02 done 2023-03-11 20:38:01 +04:00
ArtemEmelyanov
035fadd9dc add frontend 2023-02-19 15:53:42 +04:00
34 changed files with 11618 additions and 2 deletions

1
.gitignore vendored
View File

@ -16,6 +16,7 @@ build/
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/
node_modules/
### IntelliJ IDEA ###
.idea

View File

@ -13,6 +13,9 @@ repositories {
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'com.h2database:h2:2.1.210'
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

BIN
data.mv.db Normal file

Binary file not shown.

9520
data.trace.db Normal file

File diff suppressed because it is too large Load Diff

75
frontend/index.html Normal file
View File

@ -0,0 +1,75 @@
<!DOCTYPE html>
<html>
<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">
</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">LabWork2</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 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 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="Method1">+</option>
<option value="Method2">-, toUpper</option>
<option value="Method3">*, toLower</option>
<option value="Method4">/, first toLower, second toUpper</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="double">Double</option>
<option value="array">Array</option>
</select>
</div>
</div>
</div>
<div class="form-group">
<label for="result">Result</label>
<input type="text" class="form-control result" id="result" readonly>
</div>
<button type="button" class="btn btn-primary btn-block" onclick="calculate()">Do</button>
</form>
</div>
</div>
</div>
</div>
</div>
<script src = "script.js"></script>
</body>
</html>

802
frontend/package-lock.json generated Normal file
View File

@ -0,0 +1,802 @@
{
"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.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==",
"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/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.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz",
"integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==",
"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
},
"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"
}
}
},
"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==",
"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"
}
},
"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.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz",
"integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==",
"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
},
"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"
}
}
}
}

15
frontend/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"
}
}

16
frontend/script.js Normal file
View File

@ -0,0 +1,16 @@
'use strict'
async function calculate(){
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
let response = await fetch(`http://localhost:8080/${operator}?Type=${type}&value1=${num1}&value2=${num2}`)
let res = await response.text()
result.value = res
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
.navbar-brand{font-size:2rem;font-weight:700}.nav-link{color:#000;font-weight:700;text-transform:uppercase;transition:color .3s ease-in-out}.nav-link:hover{color:#dc3545}

BIN
frontend/vue-project/dist/favicon.ico vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

21
frontend/vue-project/dist/index.html vendored Normal file
View File

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<link rel="stylesheet" href="./src/style.css">
<script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
<link href="node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + Vue</title>
<script type="module" crossorigin src="/assets/index-11a2dcdd.js"></script>
<link rel="stylesheet" href="/assets/index-8a71c744.css">
</head>
<body>
<div id="app"></div>
</body>
</html>

6
package-lock.json generated Normal file
View File

@ -0,0 +1,6 @@
{
"name": "IP",
"lockfileVersion": 2,
"requires": true,
"packages": {}
}

View File

@ -2,12 +2,15 @@ package ru.IP_LabWorks.IP;
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 IpApplication {
public static void main(String[] args) {
SpringApplication.run(IpApplication.class, args);
}
}

View File

@ -0,0 +1,31 @@
package ru.IP_LabWorks.IP.TypeCalculator.configuration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import ru.IP_LabWorks.IP.TypeCalculator.domain.TypeInt;
import ru.IP_LabWorks.IP.TypeCalculator.domain.TypeArray;
import ru.IP_LabWorks.IP.TypeCalculator.domain.TypeDouble;
import ru.IP_LabWorks.IP.TypeCalculator.domain.TypeString;
@Configuration
public class TypeConfiguration {
@Bean(value = "int")
public TypeInt createIntType(){
return new TypeInt();
}
@Bean(value = "str")
public TypeString createStrType(){
return new TypeString();
}
@Bean(value = "double")
public TypeDouble createDoubleType(){
return new TypeDouble();
}
@Bean(value = "array")
public TypeArray createArrayType(){
return new TypeArray();
}
}

View File

@ -0,0 +1,43 @@
package ru.IP_LabWorks.IP.TypeCalculator.controllers;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import ru.IP_LabWorks.IP.TypeCalculator.service.TypeService;
@RestController
public class MainController {
private final TypeService Service;
public MainController(TypeService service) {
Service = service;
}
@GetMapping("/Method1")
public Object Method1(@RequestParam(value = "Type") String Type,
@RequestParam(value = "value1") Object value1,
@RequestParam(value = "value2") Object value2){
return Service.Method1(value1,value2,Type);
}
@GetMapping("/Method2")
public Object Method2(@RequestParam(value = "Type") String Type,
@RequestParam(value = "value1") Object value1,
@RequestParam(value = "value2") Object value2){
return Service.Method2(value1,value2,Type);
}
@GetMapping("/Method3")
public Object Method3(@RequestParam(value = "Type") String Type,
@RequestParam(value = "value1") Object value1,
@RequestParam(value = "value2") Object value2){
return Service.Method3(value1,value2,Type);
}
@GetMapping("/Method4")
public Object Method4(@RequestParam(value = "Type") String Type,
@RequestParam(value = "value1") Object value1,
@RequestParam(value = "value2") Object value2){
return Service.Method4(value1,value2,Type);
}
}

View File

@ -0,0 +1,8 @@
package ru.IP_LabWorks.IP.TypeCalculator.domain;
public interface ITypeInterface<T> {
T Method1(T value1, T value2);
T Method2(T value1, T value2);
T Method3(T value1, T value2);
T Method4(T value1, T value2);
}

View File

@ -0,0 +1,42 @@
package ru.IP_LabWorks.IP.TypeCalculator.domain;
import java.util.ArrayList;
public class TypeArray implements ITypeInterface<ArrayList<Integer>> {
@Override
public ArrayList<Integer> Method1(ArrayList<Integer> value1, ArrayList<Integer> value2) {
ArrayList<Integer> result = new ArrayList<>();
for (int i = 0; i < Math.min(value1.size(), value2.size()); ++i){
result.add(value1.get(i) + value2.get(i));
}
return result;
}
@Override
public ArrayList<Integer> Method2(ArrayList<Integer> value1, ArrayList<Integer> value2) {
ArrayList<Integer> result = new ArrayList<>();
for (int i = 0; i < Math.min(value1.size(), value2.size()); ++i){
result.add(value1.get(i) - value2.get(i));
}
return result;
}
@Override
public ArrayList<Integer> Method3(ArrayList<Integer> value1, ArrayList<Integer> value2) {
ArrayList<Integer> result = new ArrayList<>();
for (int i = 0; i < Math.min(value1.size(), value2.size()); ++i){
result.add(value1.get(i) * value2.get(i));
}
return result;
}
@Override
public ArrayList<Integer> Method4(ArrayList<Integer> value1, ArrayList<Integer> value2) {
ArrayList<Integer> result = new ArrayList<>();
for (int i = 0; i < Math.min(value1.size(), value2.size()); ++i){
result.add(value1.get(i) / value2.get(i));
}
return result;
}
}

View File

@ -0,0 +1,24 @@
package ru.IP_LabWorks.IP.TypeCalculator.domain;
public class TypeDouble implements ITypeInterface<Double> {
@Override
public Double Method1(Double value1, Double value2) {
return value1 + value2;
}
@Override
public Double Method2(Double value1, Double value2) {
return value1 - value2;
}
@Override
public Double Method3(Double value1, Double value2) {
return value1 * value2;
}
@Override
public Double Method4(Double value1, Double value2) {
return value1 / value2;
}
}

View File

@ -0,0 +1,24 @@
package ru.IP_LabWorks.IP.TypeCalculator.domain;
public class TypeInt implements ITypeInterface<Integer> {
@Override
public Integer Method1(Integer value1, Integer value2) {
return value1 + value2;
}
@Override
public Integer Method2(Integer value1, Integer value2) {
return value1 - value2;
}
@Override
public Integer Method3(Integer value1, Integer value2) {
return value1 * value2;
}
@Override
public Integer Method4(Integer value1, Integer value2) {
return value1 / value2;
}
}

View File

@ -0,0 +1,24 @@
package ru.IP_LabWorks.IP.TypeCalculator.domain;
public class TypeString implements ITypeInterface<String> {
@Override
public String Method1(String value1, String value2) {
return value1 + value2;
}
@Override
public String Method2(String value1, String value2) {
return value1.toUpperCase() + value2.toUpperCase();
}
@Override
public String Method3(String value1, String value2) {
return value1.toLowerCase() + value2.toLowerCase();
}
@Override
public String Method4(String value1, String value2) {
return value1.toLowerCase() + value2.toUpperCase();
}
}

View File

@ -0,0 +1,78 @@
package ru.IP_LabWorks.IP.TypeCalculator.service;
import ru.IP_LabWorks.IP.TypeCalculator.domain.ITypeInterface;
import org.springframework.stereotype.Service;
import org.springframework.context.ApplicationContext;
import java.util.Arrays;
import java.util.stream.Collectors;
@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 "int" -> {
try {
_value1 = Integer.valueOf(value1.toString());
_value2 = Integer.valueOf(value2.toString());
}catch (Exception ex){
_value1 = 0;
_value2 = 0;
}
}
case "double" -> {
try {
_value1 = Double.valueOf(value1.toString());
_value2 = Double.valueOf(value2.toString());
}catch (Exception ex){
_value1 = 0.0;
_value2 = 0.0;
}
}
case "str" -> {
_value1 = value1;
_value2 = value2;
}
case "array" -> {
_value1 = Arrays.stream(value1.toString().split(","))
.map(Integer::parseInt)
.collect(Collectors.toList());
_value2 = Arrays.stream(value2.toString().split(","))
.map(Integer::parseInt)
.collect(Collectors.toList());
}
}
}
public Object Method1(Object value1, Object value2, String type){
ValidateParams(value1,value2,type);
return String.format("%s", _type.Method1(_value1,_value2));
}
public Object Method2(Object value1, Object value2, String type){
ValidateParams(value1,value2,type);
return String.format("%s", _type.Method2(_value1,_value2));
}
public Object Method3(Object value1, Object value2, String type){
ValidateParams(value1,value2,type);
return String.format("%s", _type.Method3(_value1,_value2));
}
public Object Method4(Object value1, Object value2, String type){
ValidateParams(value1,value2,type);
return String.format("%s", _type.Method4(_value1,_value2));
}
}

View File

@ -0,0 +1,86 @@
package ru.IP_LabWorks.IP.University.Model;
import jakarta.persistence.*;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;
import javax.swing.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@Entity
@Table(name = "groups")
public class Group {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
@OneToMany(orphanRemoval = true, fetch = FetchType.EAGER, mappedBy = "group")
@OnDelete(action = OnDeleteAction.CASCADE)
private List<Student> students;
@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinTable(name = "subject_group",
joinColumns = {@JoinColumn(name = "group_id")},
inverseJoinColumns = {@JoinColumn(name = "subject_id")})
private List<Subject> subjects;
public Group() {
this.students = new ArrayList<>();
}
public Group(String name) {
this.name = name;
this.students = new ArrayList<>();
}
public Long getId() { return id; }
public String getName() { return name; }
public void setName(String name) { this.name = name; }
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Group group = (Group) o;
return Objects.equals(id, group.id);
}
@Override
public int hashCode() {
return Objects.hash(id);
}
@Override
public String toString() {
return "Group{" +
"id=" + id +
", name='" + name + '\'' +
'}';
}
public void setStudent(Student student){
this.students.add(student);
if(student.getGroup() != this){
student.setGroup(this);
}
}
public List<Student> getStudents(){
return students;
}
public void setStudents(List<Student> students) {
this.students = students;
}
public List<Subject> getSubjects(){
return subjects;
}
public void setSubjects(List<Subject> subjects) {
this.subjects = subjects;
}
}

View File

@ -0,0 +1,77 @@
package ru.IP_LabWorks.IP.University.Model;
import jakarta.persistence.*;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;
import java.time.LocalDate;
import java.time.Period;
import java.util.Objects;
@Entity
@Table(name = "students")
public class Student {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
private LocalDate birthDate;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "group_id")
private Group group;
public Student() {
}
public Student(String name, LocalDate birthDate) {
this.name = name;
this.birthDate = birthDate;
}
public Long getId() { return id; }
public String getName() { return name; }
public void setName(String name) { this.name = name; }
public LocalDate getBirthDate() { return birthDate;}
public void setBirthDate(LocalDate birthDate) { this.birthDate = birthDate; }
public Integer getAge() {
if (birthDate == null) {
return 0;
}
return Period.between(birthDate, LocalDate.now()).getYears();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Student student = (Student) o;
return Objects.equals(id, student.id);
}
@Override
public int hashCode() {
return Objects.hash(id);
}
@Override
public String toString() {
return "Student{" +
"id=" + id +
", name='" + name + '\'' +
", birthDate='" + birthDate + '\'' +
", age='" + getAge() + '\'' +
'}';
}
public Group getGroup() {
return group;
}
public void setGroup(Group group) {
this.group = group;
if(!group.getStudents().contains(this)){
group.getStudents().add(this);
}
}
}

View File

@ -0,0 +1,64 @@
package ru.IP_LabWorks.IP.University.Model;
import jakarta.persistence.*;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;
import javax.swing.*;
import java.util.List;
import java.util.Objects;
@Entity
@Table(name = "subjects")
public class Subject {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinTable(name = "subject_group",
joinColumns = {@JoinColumn(name = "subject_id")},
inverseJoinColumns = {@JoinColumn(name = "group_id")})
private List<Group> groups;
public Subject() {
}
public Subject(String name) {
this.name = name;
}
public Long getId() { return id; }
public String getName() { return name; }
public void setName(String name) { this.name = name; }
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Subject subject = (Subject) o;
return Objects.equals(id, subject.id);
}
@Override
public int hashCode() {
return Objects.hash(id);
}
@Override
public String toString() {
return "Subject{" +
"id=" + id +
", name='" + name + '\'' +
'}';
}
public List<Group> getGroups(){
return groups;
}
public void setGroups(List<Group> groups) {
this.groups = groups;
}
}

View File

@ -0,0 +1,91 @@
package ru.IP_LabWorks.IP.University.Service;
import jakarta.persistence.EntityManager;
import jakarta.persistence.EntityNotFoundException;
import jakarta.persistence.PersistenceContext;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import ru.IP_LabWorks.IP.University.Model.Group;
import ru.IP_LabWorks.IP.University.Model.Student;
import java.util.List;
@Service
public class GroupService {
@PersistenceContext
private EntityManager em;
@Transactional
public Group addGroup(String name){
if (!StringUtils.hasText(name)) {
throw new IllegalArgumentException("Group name is null or empty");
}
final Group group = new Group(name);
em.persist(group);
return group;
}
@Transactional(readOnly = true)
public Group findGroup(Long id){
final Group group = em.find(Group.class, id);
if (group == null) {
throw new EntityNotFoundException(String.format("Group with id [%s] is not found", id));
}
return group;
}
@Transactional(readOnly = true)
public List<Group> findAllGroups() {
return em.createQuery("select s from Group s", Group.class).getResultList();
}
@Transactional
public Group updateGroup(Long id, String name) {
if (!StringUtils.hasText(name)) {
throw new IllegalArgumentException("Group name is null or empty");
}
final Group currentGroup = findGroup(id);
currentGroup.setName(name);
return em.merge(currentGroup);
}
@Transactional
public Group deleteGroup(Long id) {
final Group currentGroup = findGroup(id);
em.remove(currentGroup);
return currentGroup;
}
@Transactional
public void deleteAllGroups() {
em.createQuery("delete from Group").executeUpdate();
}
@Transactional
public void addStudentToGroup(Long groupId, Long studentId) {
Group group = findGroup(groupId);
Student student = em.find(Student.class, studentId);
if (group == null || student == null) {
throw new EntityNotFoundException("Group or Student not found");
}
student.setGroup(group);
em.merge(student);
}
@Transactional
public void removeStudentFromGroup(Long groupId, Long studentId) {
Group group = findGroup(groupId);
Student student = em.find(Student.class, studentId);
group.getStudents().remove(student);
}
@Transactional(readOnly = true)
public List<Student> findStudentsInGroup(Long groupId) {
Group group = findGroup(groupId);
if (group == null) {
throw new EntityNotFoundException("Group not found");
}
return group.getStudents();
}
}

View File

@ -0,0 +1,77 @@
package ru.IP_LabWorks.IP.University.Service;
import jakarta.persistence.EntityManager;
import jakarta.persistence.EntityNotFoundException;
import jakarta.persistence.PersistenceContext;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import ru.IP_LabWorks.IP.University.Model.Group;
import ru.IP_LabWorks.IP.University.Model.Student;
import java.time.LocalDate;
import java.util.List;
@Service
public class StudentService {
@PersistenceContext
private EntityManager em;
@Transactional
public Student addStudent(String name, LocalDate date){
if (!StringUtils.hasText(name) || !StringUtils.hasText(String.valueOf(date))) {
throw new IllegalArgumentException("Student name or date is null or empty");
}
final Student student = new Student(name, date);
em.persist(student);
return student;
}
@Transactional(readOnly = true)
public Student findStudent(Long id) {
final Student student = em.find(Student.class, id);
if (student == null) {
throw new EntityNotFoundException(String.format("Student with id [%s] is not found", id));
}
return student;
}
@Transactional(readOnly = true)
public List<Student> findAllStudents() {
return em.createQuery("select s from Student s", Student.class).getResultList();
}
@Transactional
public Student updateStudent(Long id, String name, LocalDate date) {
if (!StringUtils.hasText(name) || !StringUtils.hasText(String.valueOf(date))) {
throw new IllegalArgumentException("Student name or date is null or empty");
}
final Student currentStudent = findStudent(id);
currentStudent.setName(name);
currentStudent.setBirthDate(date);
return em.merge(currentStudent);
}
@Transactional
public Student deleteStudent(Long id) {
final Student currentStudent = findStudent(id);
em.remove(currentStudent);
return currentStudent;
}
@Transactional
public void deleteAllStudent() {
em.createQuery("delete from Student").executeUpdate();
}
@Transactional
public void AddStudentToGroup(Long idStudent, Long idGroup){
Student student = findStudent(idStudent);
Group group = em.find(Group.class, idGroup);
if (group == null || student == null) {
throw new EntityNotFoundException("Group or Student not found");
}
student.setGroup(group);
em.merge(student);
}
}

View File

@ -0,0 +1,90 @@
package ru.IP_LabWorks.IP.University.Service;
import jakarta.persistence.EntityManager;
import jakarta.persistence.EntityNotFoundException;
import jakarta.persistence.PersistenceContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import ru.IP_LabWorks.IP.University.Model.Group;
import ru.IP_LabWorks.IP.University.Model.Student;
import ru.IP_LabWorks.IP.University.Model.Subject;
import java.util.List;
@Service
public class SubjectService {
@PersistenceContext
private EntityManager em;
@Transactional
public Subject addSubject(String name){
if (!StringUtils.hasText(name)) {
throw new IllegalArgumentException("Subject name is null or empty");
}
final Subject subject = new Subject(name);
em.persist(subject);
return subject;
}
@Transactional(readOnly = true)
public Subject findSubject(Long id){
final Subject subject = em.find(Subject.class, id);
if (subject == null) {
throw new EntityNotFoundException(String.format("Subject with id [%s] is not found", id));
}
return subject;
}
@Transactional(readOnly = true)
public List<Subject> findAllSubjects() {
return em.createQuery("select s from Subject s", Subject.class).getResultList();
}
@Transactional
public Subject updateSubject(Long id, String name) {
if (!StringUtils.hasText(name)) {
throw new IllegalArgumentException("Subject name is null or empty");
}
final Subject currentSubject = findSubject(id);
currentSubject.setName(name);
return em.merge(currentSubject);
}
@Transactional
public Subject deleteSubject(Long id) {
final Subject currentSubject = findSubject(id);
em.remove(currentSubject);
return currentSubject;
}
@Transactional
public void deleteAllSubjects() {
em.createQuery("delete from Subject").executeUpdate();
}
@Transactional
public void addGroupToSubject(Long subjectId, Long groupId) {
Subject subject = findSubject(subjectId);
Group group = em.find(Group.class, groupId);
subject.getGroups().add(group);
em.merge(subject);
em.merge(group);
}
@Transactional
public void removeGroupFromSubject(Long subjectId, Long groupId) {
Subject subject = findSubject(subjectId);
Group group = em.find(Group.class, groupId);
subject.getGroups().remove(group);
em.merge(subject);
em.merge(group);
}
@Transactional(readOnly = true)
public List<Group> findGroupsBySubject(Long subjectId) {
Subject subject = findSubject(subjectId);
return subject.getGroups();
}
}

View File

@ -0,0 +1,13 @@
package ru.IP_LabWorks.IP;
import org.springframework.context.annotation.Configuration;
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

@ -1 +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,78 @@
package ru.IP_LabWorks.IP;
import jakarta.persistence.EntityNotFoundException;
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.IP_LabWorks.IP.University.Model.Group;
import ru.IP_LabWorks.IP.University.Model.Student;
import ru.IP_LabWorks.IP.University.Service.GroupService;
import ru.IP_LabWorks.IP.University.Service.StudentService;
import java.time.LocalDate;
import java.util.List;
@SpringBootTest
public class GroupServiceTests {
@Autowired
private GroupService groupService;
@Autowired
private StudentService studentService;
@Test
void TestAddGroup(){
groupService.deleteAllGroups();
final Group group = groupService.addGroup("ПИбд-21");
Assertions.assertNotNull(group.getId());
}
@Test
void TestFindGroup(){
groupService.deleteAllGroups();
final Group group = groupService.addGroup("ПИбд-21");
final Group findGroup = groupService.findGroup(group.getId());
Assertions.assertEquals(group, findGroup);
}
@Test
void TestFindAllGroup(){
groupService.deleteAllGroups();
final Group group1 = groupService.addGroup("ПИбд-21");
final Group group2 = groupService.addGroup("ПИбд-22");
final List<Group> groups = groupService.findAllGroups();
Assertions.assertEquals(groups.size(), 2);
}
@Test
void TestUpdateGroup(){
groupService.deleteAllGroups();
Group group = groupService.addGroup("ПИбд-21");
group = groupService.updateGroup(group.getId(), "ПИбд-22");
Assertions.assertEquals(group.getName(), "ПИбд-22");
}
@Test
void TestDeleteGroup(){
groupService.deleteAllGroups();
Group group = groupService.addGroup("ПИбд-21");
groupService.deleteGroup(group.getId());
Assertions.assertThrows(EntityNotFoundException.class, () -> {
groupService.findGroup(group.getId());
});
}
@Test
void TestFindStudentsInGroup(){
studentService.deleteAllStudent();
groupService.deleteAllGroups();
Student student1 = studentService.addStudent("Марков Данил Павлович", LocalDate.of(2003,8,19));
Student student2 = studentService.addStudent("Емельянов Артём Сергеевич", LocalDate.of(2003,7,26));
Group group = groupService.addGroup("ПИбд-21");
groupService.addStudentToGroup(group.getId(), student1.getId());
groupService.addStudentToGroup(group.getId(), student2.getId());
final List<Student> students = groupService.findStudentsInGroup(group.getId());
Assertions.assertEquals(students.size(), 2);
}
}

View File

@ -1,13 +1,113 @@
package ru.IP_LabWorks.IP;
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.IP_LabWorks.IP.TypeCalculator.service.TypeService;
@SpringBootTest
class IpApplicationTests {
@Autowired
TypeService Service;
@Test
void contextLoads() {
}
@Test
void testIntPlus() {
final String res = (String) Service.Method1( "100", "10", "int");
Assertions.assertEquals("110", res);
}
@Test
void testIntMinus() {
final String res = (String)Service.Method2( "100", "10", "int");
Assertions.assertEquals("90", res);
}
@Test
void testIntMultiply() {
final String res = (String)Service.Method3( "100", "10", "int");
Assertions.assertEquals("1000", res);
}
@Test
void testIntDivision() {
final String res = (String)Service.Method4( "100", "10", "int");
Assertions.assertEquals("10", res);
}
@Test
void testStringPlus() {
final String res = (String)Service.Method1( "abc", "dfe", "str");
Assertions.assertEquals("abcdfe", res);
}
@Test
void testStringtoUpper() {
final String res = (String)Service.Method2( "abc", "dfe", "str");
Assertions.assertEquals("ABCDFE", res);
}
@Test
void testStringtoLower() {
final String res = (String)Service.Method3( "abc", "dfe", "str");
Assertions.assertEquals("abcdfe", res);
}
@Test
void testStringStrange() {
final String res = (String)Service.Method4( "abc", "dfe", "str");
Assertions.assertEquals("abcDFE", res);
}
@Test
void testDoublePlus() {
final String res = (String)Service.Method1( "1.01", "2.76", "double");
Assertions.assertEquals("3.7699999999999996", res);
}
@Test
void testDoubleMinus() {
final String res = (String)Service.Method2( "1.01", "2.76", "double");
Assertions.assertEquals("-1.7499999999999998", res);
}
@Test
void testDoubleMyltiply() {
final String res = (String)Service.Method3( "1.01", "2.76", "double");
Assertions.assertEquals("2.7876", res);
}
@Test
void testDoubleDivision() {
final String res = (String)Service.Method4( "1.01", "2.76", "double");
Assertions.assertEquals("0.36594202898550726", res);
}
@Test
void testArrayPlus(){
final String res = (String)Service.Method1( "1,2,3", "1,2,3", "array");
Assertions.assertEquals("[2, 4, 6]", res);
}
@Test
void testArrayMinus(){
final String res = (String)Service.Method2( "1,2,3", "1,2,3", "array");
Assertions.assertEquals("[0, 0, 0]", res);
}
@Test
void testArrayMult(){
final String res = (String)Service.Method3( "1,2,3", "1,2,3", "array");
Assertions.assertEquals("[1, 4, 9]", res);
}
@Test
void testArrayDiv(){
final String res = (String)Service.Method4( "1,2,3", "1,2,3", "array");
Assertions.assertEquals("[1, 1, 1]", res);
}
}

View File

@ -0,0 +1,79 @@
package ru.IP_LabWorks.IP;
import jakarta.persistence.EntityNotFoundException;
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.IP_LabWorks.IP.University.Model.Group;
import ru.IP_LabWorks.IP.University.Model.Student;
import ru.IP_LabWorks.IP.University.Service.GroupService;
import ru.IP_LabWorks.IP.University.Service.StudentService;
import java.time.LocalDate;
import java.util.List;
@SpringBootTest
public class StudentServiceTests {
@Autowired
private StudentService studentService;
@Autowired
private GroupService groupService;
@Test
void TestAddStudent(){
studentService.deleteAllStudent();
final Student student = studentService.addStudent("Марков Данил Павлович", LocalDate.of(2003,8,19));
Assertions.assertNotNull(student.getId());
}
@Test
void TestFindStudent(){
studentService.deleteAllStudent();
final Student student = studentService.addStudent("Марков Данил Павлович", LocalDate.of(2003,8,19));
final Student findStudent = studentService.findStudent(student.getId());
Assertions.assertEquals(student, findStudent);
}
@Test
void TestFindAllStudent(){
studentService.deleteAllStudent();
final Student student1 = studentService.addStudent("Марков Данил Павлович", LocalDate.of(2003,8,19));
final Student student2 = studentService.addStudent("Емельянов Артём Сергеевич", LocalDate.of(2003,7,26));
final List<Student> students = studentService.findAllStudents();
Assertions.assertEquals(students.size(), 2);
}
@Test
void TestUpdateStudent(){
studentService.deleteAllStudent();
Student student = studentService.addStudent("Марков Данил Павлович", LocalDate.of(2003,8,19));
student = studentService.updateStudent(student.getId(), "Емельянов Артём Сергеевич", LocalDate.of(2003,7,26));
Assertions.assertEquals(student.getName(), "Емельянов Артём Сергеевич");
}
@Test
void TestDeleteStudent(){
studentService.deleteAllStudent();
Student student = studentService.addStudent("Марков Данил Павлович", LocalDate.of(2003,8,19));
studentService.deleteStudent(student.getId());
Assertions.assertThrows(EntityNotFoundException.class, () -> {
studentService.findStudent(student.getId());
});
}
@Test
void TestAddStudentToGroup(){
studentService.deleteAllStudent();
groupService.deleteAllGroups();
Student student = studentService.addStudent("Марков Данил Павлович", LocalDate.of(2003,8,19));
Group group = groupService.addGroup("ПИбд-21");
studentService.AddStudentToGroup(student.getId(), group.getId());
Assertions.assertEquals(group,studentService.findStudent(student.getId()).getGroup());
}
}

View File

@ -0,0 +1,107 @@
package ru.IP_LabWorks.IP;
import jakarta.persistence.EntityNotFoundException;
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.IP_LabWorks.IP.University.Model.Group;
import ru.IP_LabWorks.IP.University.Model.Subject;
import ru.IP_LabWorks.IP.University.Service.GroupService;
import ru.IP_LabWorks.IP.University.Service.SubjectService;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
@SpringBootTest
public class SubjectServiceTests {
@Autowired
private SubjectService subjectService;
@Autowired
private GroupService groupService;
@Test
void TestAddSubject(){
subjectService.deleteAllSubjects();
final Subject subject = subjectService.addSubject("Философия");
Assertions.assertNotNull(subject.getId());
}
@Test
void TestFindSubject(){
subjectService.deleteAllSubjects();
final Subject subject = subjectService.addSubject("Философия");
final Subject findSubject = subjectService.findSubject(subject.getId());
assertEquals(subject, findSubject);
}
@Test
void TestFindAllSubject(){
subjectService.deleteAllSubjects();
final Subject subject1 = subjectService.addSubject("Философия");
final Subject subject2 = subjectService.addSubject("Математика");
final List<Subject> subjects = subjectService.findAllSubjects();
assertEquals(subjects.size(), 2);
}
@Test
void TestUpdateSubject(){
subjectService.deleteAllSubjects();
Subject subject = subjectService.addSubject("Философия");
subject = subjectService.updateSubject(subject.getId(), "Математика");
assertEquals(subject.getName(), "Математика");
}
@Test
void TestDeleteSubject(){
subjectService.deleteAllSubjects();
Subject subject = subjectService.addSubject("Математика");
subjectService.deleteSubject(subject.getId());
Assertions.assertThrows(EntityNotFoundException.class, () -> {
subjectService.findSubject(subject.getId());
});
}
@Test
void testAddAndFindGroupsInSubject() {
subjectService.deleteAllSubjects();
groupService.deleteAllGroups();
Subject subject = subjectService.addSubject("Math");
Group group1 = groupService.addGroup("PIBD-21");
Group group2 = groupService.addGroup("PIBD-22");
subjectService.addGroupToSubject(subject.getId(), group1.getId());
subjectService.addGroupToSubject(subject.getId(), group2.getId());
List<Group> groups = subjectService.findGroupsBySubject(subject.getId());
System.out.println(groups);
assertEquals(2, groups.size());
}
@Test
void testRemoveGroupFromSubject() {
subjectService.deleteAllSubjects();
groupService.deleteAllGroups();
Subject subject = subjectService.addSubject("Math");
Group group1 = groupService.addGroup("PIBD-21");
Group group2 = groupService.addGroup("PIBD-22");
subjectService.addGroupToSubject(subject.getId(), group1.getId());
subjectService.addGroupToSubject(subject.getId(), group2.getId());
List<Group> groupsBeforeRemove = subjectService.findGroupsBySubject(subject.getId());
assertEquals(2, groupsBeforeRemove.size());
subjectService.removeGroupFromSubject(subject.getId(), group1.getId());
List<Group> groupsAfterRemove = subjectService.findGroupsBySubject(subject.getId());
assertEquals(1, groupsAfterRemove.size());
assertTrue(groupsAfterRemove.contains(group2));
}
}