Compare commits
66 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0b9e283f67 | |||
| b9dd9c6d9b | |||
| 1f973eec1d | |||
| bbf08f2a71 | |||
| 02342f4b1d | |||
| 50946a1014 | |||
| 2a9507f646 | |||
| 32f3e9483f | |||
| 620d48c88d | |||
| 48558c6fc8 | |||
| 7e0c1e988e | |||
| bcac1c3159 | |||
| cf4869f664 | |||
| cbd7fa1127 | |||
| f0784bdfcb | |||
| c61553b284 | |||
| dcb1c381c9 | |||
| a22ff8d8bb | |||
| ee165d350a | |||
| 62627de1ee | |||
| 58188e1dbe | |||
| 23af234a27 | |||
| 534654ffd5 | |||
| bd695a00ba | |||
| 4977f33ed1 | |||
| 12d79028c6 | |||
| d45c220d50 | |||
| 3acc25cbc6 | |||
| 6aa51bc74e | |||
| ab9181004e | |||
| e40639a883 | |||
| 18ee5ece77 | |||
| 26f94dab02 | |||
| 9cd8ce211d | |||
| c88068f489 | |||
| 688fd255c6 | |||
| 4b9638ad2f | |||
| 62d5bd2394 | |||
| 1335f82494 | |||
| eecfe393e4 | |||
| 6a071071e2 | |||
| 419eb0b15a | |||
| 08dad1b6a4 | |||
| 0c1764ab47 | |||
| ee923e986d | |||
| cbf337eea6 | |||
| 33f6f1dd21 | |||
| 55b8db56c7 | |||
| b016ee75a3 | |||
| 32498b023a | |||
| c1a8b9fe81 | |||
| 45a590f145 | |||
| 071d001e08 | |||
| 2cb40754c1 | |||
| ca9a45d0b8 | |||
| b620bbf62d | |||
| 6bee6f84ee | |||
| b24242b20f | |||
| 903e6051e8 | |||
| 5ca10677cf | |||
| b43f9e4ffa | |||
| 58bf3c0d25 | |||
| a55af823c6 | |||
| c65125a48e | |||
| f0e3f4374b | |||
| 0df1eca957 |
2
.gitignore
vendored
@@ -5,6 +5,8 @@ build/
|
|||||||
!**/src/main/**/build/
|
!**/src/main/**/build/
|
||||||
!**/src/test/**/build/
|
!**/src/test/**/build/
|
||||||
node_modules
|
node_modules
|
||||||
|
data.mv.db
|
||||||
|
data.trace.db
|
||||||
### STS ###
|
### STS ###
|
||||||
.apt_generated
|
.apt_generated
|
||||||
.classpath
|
.classpath
|
||||||
|
|||||||
24
FrontEnd/.gitignore
vendored
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
pnpm-debug.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
node_modules
|
||||||
|
dist
|
||||||
|
dist-ssr
|
||||||
|
*.local
|
||||||
|
|
||||||
|
# Editor directories and files
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/extensions.json
|
||||||
|
.idea
|
||||||
|
.DS_Store
|
||||||
|
*.suo
|
||||||
|
*.ntvs*
|
||||||
|
*.njsproj
|
||||||
|
*.sln
|
||||||
|
*.sw?
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
|
|
||||||
<link href="node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet" />
|
|
||||||
<link href="node_modules/@fortawesome/fontawesome-free/css/all.min.css" rel="stylesheet" />
|
|
||||||
<link rel="stylesheet" href="main.css"/>
|
|
||||||
<title>LabWork1</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<header>
|
|
||||||
<h1 class="text-white mx-2">Добро пожаловать</h1>
|
|
||||||
</header>
|
|
||||||
<article>
|
|
||||||
<div class="m-2">
|
|
||||||
<input type="text" class="form-control my-2" id="number-1" aria-describedby="basic-addon3">
|
|
||||||
<input type="text" class="form-control" id="number-2" aria-describedby="basic-addon3">
|
|
||||||
<div class="my-2">
|
|
||||||
<button id="sum" type="button" class="btn btn-dark">+</button>
|
|
||||||
<button id="dif" type="button" class="btn btn-dark">-</button>
|
|
||||||
<button id="com" type="button" class="btn btn-dark">*</button>
|
|
||||||
<button id="div" type="button" class="btn btn-dark">/</button>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<select id="SelectId">
|
|
||||||
<option value="int">int</option>
|
|
||||||
<option value="string">str</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<p id="Conclusion">Вывод:</p>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
<footer><p class="text-white mx-2">Просто сайтик</p></footer>
|
|
||||||
<script src="Script.js"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
BIN
FrontEnd/Ped.pdf
Normal file
BIN
FrontEnd/Rasp(1-4).pdf
Normal file
BIN
FrontEnd/Rasp(5-11).pdf
Normal file
@@ -1,35 +0,0 @@
|
|||||||
let number1_input=document.getElementById("number-1");
|
|
||||||
let number2_input=document.getElementById("number-2");
|
|
||||||
let button_sum=document.getElementById("sum");
|
|
||||||
let button_dif=document.getElementById("dif");
|
|
||||||
let button_com=document.getElementById("com");
|
|
||||||
let button_div=document.getElementById("div");
|
|
||||||
let Conclusion=document.getElementById("Conclusion");
|
|
||||||
let Select=document.getElementById("SelectId")
|
|
||||||
|
|
||||||
button_sum.onclick=function(event){
|
|
||||||
executeRequest("sum");
|
|
||||||
};
|
|
||||||
button_dif.onclick=function(event){
|
|
||||||
executeRequest("dif")
|
|
||||||
};
|
|
||||||
button_com.onclick=function(event){
|
|
||||||
executeRequest("com")
|
|
||||||
};
|
|
||||||
button_div.onclick=function(event){
|
|
||||||
executeRequest("div")
|
|
||||||
};
|
|
||||||
|
|
||||||
function executeRequest(operationAddress) {
|
|
||||||
let numOne = number1_input.value;
|
|
||||||
let numTwo = number2_input.value;
|
|
||||||
let selecttype=Select.value;
|
|
||||||
console.log(`http://localhost:8080/${operationAddress}?firstObj=${numOne}&secondObj=${numTwo}&type=${selecttype}`)
|
|
||||||
fetch(`http://localhost:8080/${operationAddress}?firstObj=${numOne}&secondObj=${numTwo}&type=${selecttype}`)
|
|
||||||
.then((response) => {
|
|
||||||
return response.text()
|
|
||||||
})
|
|
||||||
.then((data) => {
|
|
||||||
Conclusion.innerHTML="Вывод: " + data;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
53
FrontEnd/build.gradle
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
import com.github.gradle.node.util.PlatformHelper
|
||||||
|
import groovy.text.SimpleTemplateEngine
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id 'java'
|
||||||
|
id 'com.github.node-gradle.node' version '3.5.1'
|
||||||
|
id "de.undercouch.download" version '5.3.1'
|
||||||
|
}
|
||||||
|
|
||||||
|
node {
|
||||||
|
version = '18.15.0'
|
||||||
|
download = true
|
||||||
|
}
|
||||||
|
|
||||||
|
jar.dependsOn 'npmBuild'
|
||||||
|
|
||||||
|
clean.dependsOn 'npmClean'
|
||||||
|
|
||||||
|
nodeSetup.dependsOn 'downloadNode'
|
||||||
|
|
||||||
|
jar {
|
||||||
|
from 'dist'
|
||||||
|
into 'static'
|
||||||
|
}
|
||||||
|
|
||||||
|
task downloadNode(type: Download) {
|
||||||
|
final helper = new PlatformHelper()
|
||||||
|
final templateData = [
|
||||||
|
"url" : node.distBaseUrl.get(),
|
||||||
|
"version": node.version.get(),
|
||||||
|
"os" : helper.osName,
|
||||||
|
"arch" : helper.osArch,
|
||||||
|
"ext" : helper.windows ? 'zip' : 'tar.gz'
|
||||||
|
]
|
||||||
|
final urlTemplate = '${url}/v${version}/node-v${version}-${os}-${arch}.${ext}'
|
||||||
|
final engine = new SimpleTemplateEngine()
|
||||||
|
final url = engine.createTemplate(urlTemplate).make(templateData).toString()
|
||||||
|
final String destDir = '.gradle/'
|
||||||
|
file(destDir).mkdirs()
|
||||||
|
src url
|
||||||
|
dest destDir
|
||||||
|
overwrite false
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.register('npmBuild', NpmTask) {
|
||||||
|
dependsOn npmInstall
|
||||||
|
args = ['run-script', 'build']
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.register('npmClean', NpmTask) {
|
||||||
|
dependsOn npmInstall
|
||||||
|
args = ['run-script', 'clean']
|
||||||
|
}
|
||||||
BIN
FrontEnd/img/6666.png
Normal file
|
After Width: | Height: | Size: 60 KiB |
BIN
FrontEnd/img/Emblema.png
Normal file
|
After Width: | Height: | Size: 77 KiB |
BIN
FrontEnd/img/Rasp.png
Normal file
|
After Width: | Height: | Size: 67 KiB |
BIN
FrontEnd/img/Shkola.jpg
Normal file
|
After Width: | Height: | Size: 166 KiB |
BIN
FrontEnd/img/banner1.png
Normal file
|
After Width: | Height: | Size: 522 KiB |
BIN
FrontEnd/img/banner2.png
Normal file
|
After Width: | Height: | Size: 903 KiB |
BIN
FrontEnd/img/banner3.png
Normal file
|
After Width: | Height: | Size: 471 KiB |
BIN
FrontEnd/img/icon.png
Normal file
|
After Width: | Height: | Size: 54 KiB |
BIN
FrontEnd/img/owl.png
Normal file
|
After Width: | Height: | Size: 147 KiB |
16
FrontEnd/index.html
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="ru">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<link rel="icon" type="image/svg+xml" href="img/icon.png" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<script src="/node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
|
||||||
|
<link rel="stylesheet" href="/node_modules/bootstrap/dist/css/bootstrap.min.css">
|
||||||
|
<link rel="stylesheet" href="/node_modules/@fortawesome/fontawesome-free/css/all.min.css">
|
||||||
|
<title>МБОУ средняя общеобразовательная школа №10</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="app"></div>
|
||||||
|
<script type="module" src="/src/main.jsx"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
18
FrontEnd/js/banner.js
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
|
console.info('Loaded');
|
||||||
|
const banners = document.querySelectorAll("#banner img");
|
||||||
|
var old = banners.length - 1;
|
||||||
|
var current = 0;
|
||||||
|
function loop() {
|
||||||
|
banners[current].setAttribute('className', 'show');
|
||||||
|
banners[old].setAttribute('className', 'hide');
|
||||||
|
console.info('Banner changed');
|
||||||
|
old = current;
|
||||||
|
current++;
|
||||||
|
if (current === banners.length) {
|
||||||
|
current = 0;
|
||||||
|
}
|
||||||
|
setTimeout(loop, 5000);
|
||||||
|
}
|
||||||
|
loop();
|
||||||
|
});
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
html
|
|
||||||
{
|
|
||||||
min-height: 100vh;
|
|
||||||
}
|
|
||||||
body
|
|
||||||
{
|
|
||||||
display: grid;
|
|
||||||
grid-template-rows:auto 1fr auto;
|
|
||||||
min-height: 100vh;
|
|
||||||
}
|
|
||||||
header
|
|
||||||
{
|
|
||||||
background-color: black;
|
|
||||||
}
|
|
||||||
footer
|
|
||||||
{
|
|
||||||
background-color: black;
|
|
||||||
}
|
|
||||||
2142
FrontEnd/package-lock.json
generated
@@ -1,18 +1,26 @@
|
|||||||
{
|
{
|
||||||
"name": "frontend",
|
"name": "spa-react",
|
||||||
|
"private": true,
|
||||||
|
"source": "index.html",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "",
|
"type": "module",
|
||||||
"main": "index.js",
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "http-server -p 3000 ./",
|
"start": "vite",
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"build": "vite build",
|
||||||
},
|
"preview": "vite preview"
|
||||||
"author": "",
|
|
||||||
"license": "ISC",
|
|
||||||
"devDependencies": {
|
|
||||||
"http-server":"^14.1.1"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bootstrap":"^5.2.3"
|
"react": "^18.2.0",
|
||||||
|
"react-dom": "^18.2.0",
|
||||||
|
"react-router-dom": "^6.4.4",
|
||||||
|
"axios": "^1.1.3",
|
||||||
|
"bootstrap": "^5.2.2",
|
||||||
|
"@fortawesome/fontawesome-free": "^6.2.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/react": "^18.0.24",
|
||||||
|
"@types/react-dom": "^18.0.8",
|
||||||
|
"vite": "^3.2.3",
|
||||||
|
"@vitejs/plugin-react": "^2.2.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
1
FrontEnd/public/favicon.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Pro 6.2.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. --><path d="M96 0C43 0 0 43 0 96V416c0 53 43 96 96 96H384h32c17.7 0 32-14.3 32-32s-14.3-32-32-32V384c17.7 0 32-14.3 32-32V32c0-17.7-14.3-32-32-32H384 96zm0 384H352v64H96c-17.7 0-32-14.3-32-32s14.3-32 32-32zm32-240c0-8.8 7.2-16 16-16H336c8.8 0 16 7.2 16 16s-7.2 16-16 16H144c-8.8 0-16-7.2-16-16zm16 48H336c8.8 0 16 7.2 16 16s-7.2 16-16 16H144c-8.8 0-16-7.2-16-16s7.2-16 16-16z"/></svg>
|
||||||
|
After Width: | Height: | Size: 611 B |
48
FrontEnd/src/App.jsx
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
|
||||||
|
import { useRoutes, Outlet, BrowserRouter } from 'react-router-dom';
|
||||||
|
import Header from './components/common/Header';
|
||||||
|
import Catalogs from './components/catalogs/MainPage';
|
||||||
|
import CatalogGroups from './components/catalogs/Autorize';
|
||||||
|
import CatalogStudents from './components/catalogs/News';
|
||||||
|
import Post from './components/catalogs/Post';
|
||||||
|
import Reports from './components/catalogs/RezhimRaboty';
|
||||||
|
import ReportGroupStudents from './components/catalogs/Raspisanie';
|
||||||
|
import Footer from './components/common/Footer';
|
||||||
|
|
||||||
|
function Router(props) {
|
||||||
|
return useRoutes(props.rootRoute);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function App() {
|
||||||
|
const routes = [
|
||||||
|
{ index: true, element: <Catalogs /> },
|
||||||
|
{ path: 'Main_page', element: <Catalogs />, label: 'Главная' },
|
||||||
|
{ path: 'News', element: <CatalogStudents/>, label:'Новости' },
|
||||||
|
{ path: 'Autorize', element: <CatalogGroups />, label:'Авторизация'},
|
||||||
|
{ path: 'RezhimRaboty', element: <Reports />, label: 'Режим работы' },
|
||||||
|
{ path: 'Raspisanie', element: <ReportGroupStudents />,label:'Расписание' },
|
||||||
|
{ path: 'Post', element: <Post/>}
|
||||||
|
];
|
||||||
|
const links = routes.filter(route => route.hasOwnProperty('label'));
|
||||||
|
const rootRoute = [
|
||||||
|
{ path: '/', element: render(links), children: routes }
|
||||||
|
];
|
||||||
|
|
||||||
|
function render(links) {
|
||||||
|
return (
|
||||||
|
<div className='body_app'>
|
||||||
|
<Header links={links} />
|
||||||
|
<div className="d-flex text-white bg-info bg-gradient fw-bold">
|
||||||
|
<Outlet />
|
||||||
|
</div>
|
||||||
|
<Footer links={links}/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<BrowserRouter>
|
||||||
|
<Router rootRoute={ rootRoute } />
|
||||||
|
</BrowserRouter>
|
||||||
|
);
|
||||||
|
}
|
||||||
22
FrontEnd/src/ModalEdit.module.css
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
.myModal {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
right: 0;
|
||||||
|
left: 0;
|
||||||
|
display: none;
|
||||||
|
background: rgba(0,0,0, 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
.myModalContent {
|
||||||
|
padding: 25px;
|
||||||
|
background: white;
|
||||||
|
border-radius: 16px;
|
||||||
|
max-width: 600px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.myModal.active {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
146
FrontEnd/src/components/catalogs/Autorize.jsx
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
import React from "react";
|
||||||
|
import { useState } from 'react';
|
||||||
|
import {useEffect} from 'react';
|
||||||
|
import UserDto from '../../models/UserDto';
|
||||||
|
export default function CatalogGroups(props) {
|
||||||
|
const formRef = React.createRef();
|
||||||
|
const [output, setOutput] = useState([]);
|
||||||
|
const FirstInput = document.getElementById("validationCustom01");
|
||||||
|
const LastInput = document.getElementById("validationCustom02");
|
||||||
|
const emailInput = document.getElementById("validationCustomMail");
|
||||||
|
const getAll = async function () {
|
||||||
|
const requestUrl = "http://localhost:8080/user";
|
||||||
|
const response = await fetch(requestUrl);
|
||||||
|
const users = await response.json();
|
||||||
|
setOutput(users);
|
||||||
|
}
|
||||||
|
useEffect(() => {
|
||||||
|
getAll();
|
||||||
|
}, []);
|
||||||
|
const remove = async function(id){
|
||||||
|
const requestParams = {
|
||||||
|
method: "DELETE",
|
||||||
|
headers:{
|
||||||
|
"Content-Type":"application/json",
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const requestUrl = "http://localhost:8080" + "/user/" + id;
|
||||||
|
const response=await fetch(requestUrl,requestParams);
|
||||||
|
return await response.json;
|
||||||
|
};
|
||||||
|
const create = async function (firstName, lastName,Email) {
|
||||||
|
const requestParams = {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const response = await fetch("http://localhost:8080" + `/user?firstName=${firstName}&lastName=${lastName}&email=${Email}`, requestParams);
|
||||||
|
return await response.json();
|
||||||
|
}
|
||||||
|
const refresh = async function(id,firstName, lastName,Email)
|
||||||
|
{
|
||||||
|
const requestParams={
|
||||||
|
method:"PUT",
|
||||||
|
headers:{
|
||||||
|
"Content-Type":"application/json",
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const response=await fetch(`http://localhost:8080/user/${id}?firstName=${firstName}&lastName=${lastName}&email=${Email}`,requestParams);
|
||||||
|
return await response.json();
|
||||||
|
}
|
||||||
|
const add_but = function(event)
|
||||||
|
{
|
||||||
|
event.preventDefault();
|
||||||
|
create(FirstInput.value, LastInput.value,emailInput.value).then((result) => {
|
||||||
|
getAll();
|
||||||
|
FirstInput.value = "";
|
||||||
|
LastInput.value = "";
|
||||||
|
emailInput.value="";
|
||||||
|
alert(`User[id=${result.id}, firstName=${result.firstName}, lastName=${result.lastName},email=${result.email}]`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const edit_btn = function(id,event)
|
||||||
|
{
|
||||||
|
console.log("Обновление")
|
||||||
|
refresh(id,FirstInput.value, LastInput.value,emailInput.value).then((result)=>{
|
||||||
|
getAll();
|
||||||
|
FirstInput.value = "";
|
||||||
|
LastInput.value = "";
|
||||||
|
emailInput.value="";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const rem_but = function(id,event)
|
||||||
|
{
|
||||||
|
console.log("Удаление")
|
||||||
|
remove(id).then((result)=>{
|
||||||
|
getAll();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="p-2">
|
||||||
|
<form className="row g-3 needs-validation">
|
||||||
|
<div className="col-md-4">
|
||||||
|
<label className="form-label" htmlFor="validationCustom01">Имя</label>
|
||||||
|
<input className="form-control" id="validationCustom01" type="text" defaultValue="" required/>
|
||||||
|
<div className="valid-feedback">Отлично!</div>
|
||||||
|
<div className="invalid-feedback">Введите имя!</div>
|
||||||
|
</div>
|
||||||
|
<div className="col-md-4">
|
||||||
|
<label className="form-label" htmlFor="validationCustom02">Фамилия</label>
|
||||||
|
<input className="form-control" id="validationCustom02" type="text" defaultValue="" required/>
|
||||||
|
<div className="valid-feedback">Отлично! </div>
|
||||||
|
<div className="invalid-feedback">Введите Фамилию!</div>
|
||||||
|
</div>
|
||||||
|
<div className="col-md-4">
|
||||||
|
<label className="form-label" htmlFor="validationCustomMail">Почта</label>
|
||||||
|
<div className="input-group has-validation">
|
||||||
|
<input className="form-control" id="validationCustomMail" type="email" aria-describedby="inputGroupPrepend" required/>
|
||||||
|
<div className="valid-feedback">Отлично!</div>
|
||||||
|
<div className="invalid-feedback">Введите почту!</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="col-12">
|
||||||
|
<div className="form=check">
|
||||||
|
<input className="form-check-input" id="invalidCheck" type="checkbox" defaultValue="" required/>
|
||||||
|
<label className="form-check-label" htmlFor="invalidCheck">Согласие на обработку персональных данных</label>
|
||||||
|
<div className="valid-feedback">Отлично!</div>
|
||||||
|
<div className="invalid-feedback">Введите пароль!</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="col-12 d-flex">
|
||||||
|
<div className="d-grid col-sm-4 mx-auto">
|
||||||
|
<button type="button" id="add_btn" className="btn btn-outline-light btn-lg float-end" onClick={add_but}>Add</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<div className="row table-responsive mx-2">
|
||||||
|
<table className="table mt-3">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">#</th>
|
||||||
|
<th scope="col">Last Name</th>
|
||||||
|
<th scope="col">First Name</th>
|
||||||
|
<th scope="col">Email</th>
|
||||||
|
<th scope="col"></th>
|
||||||
|
<th scope="col"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="tbody">
|
||||||
|
{output.map((user) => (
|
||||||
|
<tr key={user.id}>
|
||||||
|
<th scope="row">{user.id}</th>
|
||||||
|
<td>{user.firstName}</td>
|
||||||
|
<td>{user.lastName}</td>
|
||||||
|
<td>{user.email}</td>
|
||||||
|
<td><button type="button" className="btn btn-outline-light text-center mx-2" onClick={(e) => edit_btn(user.id, e)}><i className="fa-sharp fa-solid fa-pen"></i></button></td>
|
||||||
|
<td><button type="button" className="btn btn-outline-light text-center mx-2" onClick={(e) => rem_but(user.id, e)}><i className="fa-sharp fa-solid fa-trash"></i></button></td>
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
150
FrontEnd/src/components/catalogs/Catalog.jsx
Normal file
@@ -0,0 +1,150 @@
|
|||||||
|
import { useState, useEffect } from "react";
|
||||||
|
import Toolbar from "../common/Toolbar";
|
||||||
|
import Table from "../common/Card";
|
||||||
|
import Modal from "../common/Modal";
|
||||||
|
|
||||||
|
export default function Catalog(props) {
|
||||||
|
const [items, setItems] = useState([]);
|
||||||
|
const [modalHeader, setModalHeader] = useState('');
|
||||||
|
const [modalConfirm, setModalConfirm] = useState('');
|
||||||
|
const [modalVisible, setModalVisible] = useState(false);
|
||||||
|
const [isEdit, setEdit] = useState(false);
|
||||||
|
const [userId,setUserId] = useState(0);
|
||||||
|
const [value,setvalue]=useState('');
|
||||||
|
useEffect(() => {
|
||||||
|
loadItems();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(()=>
|
||||||
|
{
|
||||||
|
loadItems();
|
||||||
|
},[userId])
|
||||||
|
|
||||||
|
|
||||||
|
useEffect(()=>
|
||||||
|
{
|
||||||
|
loadItems2();
|
||||||
|
},[value])
|
||||||
|
const setUserIDd = async function(id)
|
||||||
|
{
|
||||||
|
setUserId(id);
|
||||||
|
}
|
||||||
|
const loadItems = async function() {
|
||||||
|
const requestUrl = `http://localhost:8080/user/${userId}/posts`;
|
||||||
|
const response = await fetch(requestUrl);
|
||||||
|
const posts = await response.json();
|
||||||
|
setItems(posts);
|
||||||
|
}
|
||||||
|
|
||||||
|
const loadItems2 = async function() {
|
||||||
|
const requestUrl = `http://localhost:8080/post/filteredposts?Text=${value}`;
|
||||||
|
const response = await fetch(requestUrl);
|
||||||
|
const posts = await response.json();
|
||||||
|
console.log(posts);
|
||||||
|
setItems(posts);
|
||||||
|
}
|
||||||
|
|
||||||
|
const saveItem = async function() {
|
||||||
|
if (!isEdit) {
|
||||||
|
const requestUrl = `http://localhost:8080/user/${userId}/Post`;
|
||||||
|
const temppost=JSON.stringify(props.data)
|
||||||
|
const requestParams = {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: temppost,
|
||||||
|
};
|
||||||
|
await fetch(requestUrl,requestParams).then(() => loadItems());
|
||||||
|
|
||||||
|
} else {
|
||||||
|
const requestUrl = "http://localhost:8080/post/"+props.data.id;
|
||||||
|
const temppost=JSON.stringify(props.data)
|
||||||
|
const requestParams = {
|
||||||
|
method: "PUT",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: temppost,
|
||||||
|
};
|
||||||
|
await fetch(requestUrl,requestParams).then(() => loadItems());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleAdd() {
|
||||||
|
setEdit(false);
|
||||||
|
setModalHeader('Добавление элемента');
|
||||||
|
setModalConfirm('Добавить');
|
||||||
|
setModalVisible(true);
|
||||||
|
props.onAdd();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const edit = async function(editedId) {
|
||||||
|
const requestUrl = "http://localhost:8080/post/"+editedId;
|
||||||
|
const requestParams = {
|
||||||
|
mode: 'cors'
|
||||||
|
}
|
||||||
|
await fetch(requestUrl,requestParams)
|
||||||
|
.then(data => {
|
||||||
|
setEdit(true);
|
||||||
|
setModalHeader('Редактирование элемента');
|
||||||
|
setModalConfirm('Сохранить');
|
||||||
|
setModalVisible(true);
|
||||||
|
//props.onEdit(data);
|
||||||
|
return data.json();
|
||||||
|
}).then(data =>{
|
||||||
|
props.onEdit(data);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleRemove = async function(id) {
|
||||||
|
if (confirm('Удалить выбранные элементы?')) {
|
||||||
|
const requestUrl = `http://localhost:8080/user/${userId}/Post/`+id;
|
||||||
|
const requestParams = {
|
||||||
|
method: "DELETE",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
await fetch(requestUrl,requestParams).then(()=>loadItems());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function handleModalHide() {
|
||||||
|
setModalVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleModalDone() {
|
||||||
|
saveItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className="mx-3 my-2"><input type="text" id="search" className="form-control" required onChange={(event)=> setvalue(event.target.value)}/></div>
|
||||||
|
<Toolbar
|
||||||
|
onAdd={handleAdd}
|
||||||
|
getUser={setUserIDd}
|
||||||
|
/>
|
||||||
|
<Table
|
||||||
|
headers={props.headers}
|
||||||
|
items={items}
|
||||||
|
value={value}
|
||||||
|
userId={userId}
|
||||||
|
selectable={true}
|
||||||
|
onEdit={edit}
|
||||||
|
onRemove={handleRemove}/>
|
||||||
|
<Modal
|
||||||
|
header={modalHeader}
|
||||||
|
confirm={modalConfirm}
|
||||||
|
visible={modalVisible}
|
||||||
|
onHide={handleModalHide}
|
||||||
|
onDone={handleModalDone}>
|
||||||
|
{props.children}
|
||||||
|
</Modal>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
23
FrontEnd/src/components/catalogs/MainPage.jsx
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { useEffect } from "react";
|
||||||
|
import { useState } from "react";
|
||||||
|
import Banner from '../common/Banner'
|
||||||
|
|
||||||
|
export default function Catalogs(props) {
|
||||||
|
return (
|
||||||
|
<div className="container-fluid">
|
||||||
|
<Banner />
|
||||||
|
<div className="lp"><img className="img-fluid img-school float-start my-2" src="img/Shkola.jpg" alt="shkola"/>
|
||||||
|
<div>
|
||||||
|
<p className="fs-4">Мы расположены по адресу: 423228, г. Нижневратовск, ул. Корзинова, д. 37</p>
|
||||||
|
<div>
|
||||||
|
<div className="fs-4">Контактные телефоны
|
||||||
|
<p>(8228) 13-77-85</p>
|
||||||
|
<p>(8800) 55-53-50</p>
|
||||||
|
<p>факс (8911) 22-44-96</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div><a className="fs-4" href="mailto:Nizhnev.school10@mail.ru">email: Nizhnev.school10@mail.ru</a>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
61
FrontEnd/src/components/catalogs/News.jsx
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
import { useState, useEffect } from 'react';
|
||||||
|
import Catalog from './Catalog';
|
||||||
|
import New from '../../models/NewDto';
|
||||||
|
|
||||||
|
export default function News(props) {
|
||||||
|
const url = 'post/';
|
||||||
|
const transformer = (data) => new New(data);
|
||||||
|
const catalogStudHeaders = [
|
||||||
|
{ name: 'image', label: 'Картинка' },
|
||||||
|
{ name: 'heading', label: 'Заголовок' },
|
||||||
|
{ name: 'content', label: 'Новости' },
|
||||||
|
];
|
||||||
|
|
||||||
|
const [data, setData] = useState(new New());
|
||||||
|
const fileReader=new FileReader();
|
||||||
|
fileReader.onloadend=()=>{
|
||||||
|
const tempval=fileReader.result;
|
||||||
|
setData({ ...data, ['image']: tempval})
|
||||||
|
}
|
||||||
|
const handleOnChange=(event)=>{
|
||||||
|
event.preventDefault();
|
||||||
|
const file=event.target.files[0];
|
||||||
|
fileReader.readAsDataURL(file);
|
||||||
|
};
|
||||||
|
|
||||||
|
function handleOnAdd() {
|
||||||
|
setData(new New());
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleOnEdit(data) {
|
||||||
|
setData(new New(data));
|
||||||
|
}
|
||||||
|
function handleFormChange(event) {
|
||||||
|
setData({ ...data, [event.target.id]: event.target.value })
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Catalog
|
||||||
|
headers={catalogStudHeaders}
|
||||||
|
url={url}
|
||||||
|
transformer={transformer}
|
||||||
|
data={data}
|
||||||
|
onAdd={handleOnAdd}
|
||||||
|
onEdit={handleOnEdit}>
|
||||||
|
<div className="mb-3 text-black">
|
||||||
|
<label htmlFor="image" className="form-label">Изображение</label>
|
||||||
|
<input type="file" id="image" className="form-control" required onChange={handleOnChange}/>
|
||||||
|
</div>
|
||||||
|
<div className="mb-3">
|
||||||
|
<label htmlFor="heading" className="form-label text-black">Заголовок</label>
|
||||||
|
<input type="text" id="heading" className="form-control" required
|
||||||
|
value={data.heading} onChange={handleFormChange}/>
|
||||||
|
</div>
|
||||||
|
<div className="mb-3">
|
||||||
|
<label htmlFor="content" className="form-label text-black">Содержание</label>
|
||||||
|
<input type="text" id="content" className="form-control" required
|
||||||
|
value={data.content} onChange={handleFormChange}/>
|
||||||
|
</div>
|
||||||
|
</Catalog>
|
||||||
|
);
|
||||||
|
}
|
||||||
159
FrontEnd/src/components/catalogs/Post.jsx
Normal file
@@ -0,0 +1,159 @@
|
|||||||
|
import React from "react";
|
||||||
|
import { useState } from 'react';
|
||||||
|
import {useEffect} from 'react';
|
||||||
|
import New from '../../models/NewDto';
|
||||||
|
import TableComment from "../common/TableComment";
|
||||||
|
|
||||||
|
export default function Post(props) {
|
||||||
|
useEffect(() => {
|
||||||
|
getAll();
|
||||||
|
}, []);
|
||||||
|
const [output, setOutput] = useState([]);
|
||||||
|
const [userId,setUserId] = useState();
|
||||||
|
const commentInput = document.getElementById("commentText");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const getAll = async function () {
|
||||||
|
const queryString=window.location.search;
|
||||||
|
const urlParams=new URLSearchParams(queryString);
|
||||||
|
const id=urlParams.get('id');
|
||||||
|
getCurrentPost(id).then(curPost => setad(curPost));
|
||||||
|
getComments(id)
|
||||||
|
|
||||||
|
const requestUrl = "http://localhost:8080/user";
|
||||||
|
const response = await fetch(requestUrl);
|
||||||
|
const users = await response.json();
|
||||||
|
setOutput(users);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const refresh = async function(id,text)
|
||||||
|
{
|
||||||
|
const requestParams={
|
||||||
|
method:"PUT",
|
||||||
|
headers:{
|
||||||
|
"Content-Type":"application/json",
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const response=await fetch(`http://localhost:8080/comment/${id}?Text=${text}`,requestParams);
|
||||||
|
return await response.json();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const create = async function (text, id) {
|
||||||
|
const requestParams = {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const response = await fetch(`http://localhost:8080/post/${ad.id}/Comment/${id}?Text=${text}`,requestParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const getCurrentPost = async function (id) {
|
||||||
|
const requestUrl = "http://localhost:8080/post/"+id;
|
||||||
|
const response = await fetch(requestUrl);
|
||||||
|
const product = await response.json();
|
||||||
|
return product;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const remove = async function(id){
|
||||||
|
const requestParams = {
|
||||||
|
method: "DELETE",
|
||||||
|
headers:{
|
||||||
|
"Content-Type":"application/json",
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const requestUrl = `http://localhost:8080/post/${ad.id}/Comment/${id}`;
|
||||||
|
const response=await fetch(requestUrl,requestParams);
|
||||||
|
return await response.json;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
function getuser(){
|
||||||
|
var selectBox = document.getElementById("selectBox");
|
||||||
|
var selectedValue = selectBox.options[selectBox.selectedIndex].value;
|
||||||
|
setUserId(selectedValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const getComments = async function(id)
|
||||||
|
{
|
||||||
|
const requesturl = "http://localhost:8080/post/"+id+"/comments"
|
||||||
|
const response = await fetch(requesturl);
|
||||||
|
const comments = await response.json();
|
||||||
|
setComments(comments);
|
||||||
|
}
|
||||||
|
const [ad, setad] = useState([]);
|
||||||
|
const [comments,setComments] = useState([]);
|
||||||
|
|
||||||
|
|
||||||
|
const rem_but = function(id,event)
|
||||||
|
{
|
||||||
|
remove(id).then((result)=>{
|
||||||
|
getAll();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const add_but = function(event)
|
||||||
|
{
|
||||||
|
event.preventDefault();
|
||||||
|
create(commentInput.value, userId).then((result) => {
|
||||||
|
getAll();
|
||||||
|
commentInput.value = "";
|
||||||
|
alert(`Comment[id=${result.id}, text=${result.firstName}]`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const edit_btn = function(id,event)
|
||||||
|
{
|
||||||
|
console.log("Обновление")
|
||||||
|
refresh(id, commentInput.value).then((result)=>{
|
||||||
|
getAll();
|
||||||
|
commentInput.value = "";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return(
|
||||||
|
<div>
|
||||||
|
<div className="da d-flex my-2">
|
||||||
|
<div><img className="imga img-fluid float-start mx-2" style={{width: "500px" ,height: "300px" }} src={ad.image}/></div>
|
||||||
|
<div className="container-fluid my-2 mx-1">
|
||||||
|
<h1>{ad.heading}</h1>
|
||||||
|
<p>{ad.content}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="d-flex mx-2">
|
||||||
|
<select id="selectBox" onChange={getuser}>
|
||||||
|
<option disabled value="">Выбор...</option>
|
||||||
|
{
|
||||||
|
output.map((client) => (
|
||||||
|
<option className='text-black' key={client.id} value={client.id}>{client.firstName}</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
<input className="form-control" id="commentText" type="text" defaultValue="" required/>
|
||||||
|
<button type="button" className="btn btn-primary" onClick={(e)=>add_but(e)}>
|
||||||
|
+
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div className="row table-responsive mx-2">
|
||||||
|
<TableComment
|
||||||
|
comments={comments}
|
||||||
|
onRemove={rem_but}
|
||||||
|
onEdit={edit_btn}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
13
FrontEnd/src/components/catalogs/Raspisanie.jsx
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
|
||||||
|
export default function ReportGroupStudents(props) {
|
||||||
|
return (
|
||||||
|
<div className="container-fluid justify-content-center align-items-center d-flex flex-column my-2">
|
||||||
|
<div>
|
||||||
|
<h6>Расписание<img className="pdf-size " src="img/Rasp.png" alt="Rasp"/></h6>
|
||||||
|
</div>
|
||||||
|
<div> <a href="Rasp(1-4).pdf" target="_blank"><img className="pdf-size" src="img/6666.png"/></a><a href="Rasp(1-4).pdf" target="_blank">Расписание 1 - 4 кл. (.pdf)</a></div><br/><br/>
|
||||||
|
<div> <a href="Rasp(5-11).pdf" target="_blank"><img className="pdf-size" src="img/6666.png"/></a><a href="Rasp(5-11).pdf" target="_blank">Расписание 5 - 11 кл. (.pdf)</a></div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
135
FrontEnd/src/components/catalogs/RezhimRaboty.jsx
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
|
||||||
|
|
||||||
|
export default function Reports(props) {
|
||||||
|
return (
|
||||||
|
<div className="container-fluid my-2">
|
||||||
|
<div className="float-start me-5">
|
||||||
|
<h3 className="text-wrap">Расписание звонков</h3>
|
||||||
|
<table className="Vnov1 float-start table-bordered">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th colSpan="2">1 смена</th>
|
||||||
|
<th colSpan="2">2 смена</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td> </td>
|
||||||
|
<td> </td>
|
||||||
|
<td></td>
|
||||||
|
<td> </td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>1 урок</td>
|
||||||
|
<td>8.00-8.45</td>
|
||||||
|
<td>0 урок</td>
|
||||||
|
<td>12.55-13.40</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td> </td>
|
||||||
|
<td> </td>
|
||||||
|
<td> </td>
|
||||||
|
<td> </td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>2 урок </td>
|
||||||
|
<td>8.55-9.40 </td>
|
||||||
|
<td>1 урок </td>
|
||||||
|
<td>13.50-14.35</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td> </td>
|
||||||
|
<td> </td>
|
||||||
|
<td> </td>
|
||||||
|
<td> </td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>3 урок </td>
|
||||||
|
<td>10.00-10.45</td>
|
||||||
|
<td>2 урок</td>
|
||||||
|
<td>14.50-15.35</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td> </td>
|
||||||
|
<td> </td>
|
||||||
|
<td> </td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>4 урок</td>
|
||||||
|
<td>11.05-11.50</td>
|
||||||
|
<td>3 урок</td>
|
||||||
|
<td>12.00-12.45</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td> </td>
|
||||||
|
<td> </td>
|
||||||
|
<td> </td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>5 урок</td>
|
||||||
|
<td>12.00-12.45</td>
|
||||||
|
<td>4 урок</td>
|
||||||
|
<td>16.45-17.30</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td> </td>
|
||||||
|
<td> </td>
|
||||||
|
<td> </td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>6 урок</td>
|
||||||
|
<td>12.55-13.40 </td>
|
||||||
|
<td>5 урок</td>
|
||||||
|
<td>17.40-18.25 </td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td> </td>
|
||||||
|
<td> </td>
|
||||||
|
<td> </td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>7 урок</td>class
|
||||||
|
<td>13.50-14.35</td>
|
||||||
|
<td> </td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h3>Режим работы ОУ:
|
||||||
|
<div className="align-items-justify text-wrap fs-5">Учебный год в МБОУ средняя общеобразовательная школа №10 начинается 2 сентября, состоит из 3-х триместров, включает каникулы по графику. МБОУ средняя общеобразовательная школа №10 работает в две смены. Школа работает в течение 5 дней в неделю с понедельника по пятницу, выходной день – суббота и воскресенье — в 1-11 классах. Продолжительность учебного года – 33 учебных недели для учащихся 1-х классов, 34 учебных недель для учащихся 2-11 классов. Для учащихся, обучающихся на дому, продолжительность учебного года составляет 34 недели. Начало учебных занятий в 8-00.
|
||||||
|
<table className="table-bordered">
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
<th>Триместр</th>
|
||||||
|
<th>Дата начала/дата окончания</th>
|
||||||
|
<th colSpan="2">Каникулы</th>
|
||||||
|
<tr>
|
||||||
|
<td>I</td>
|
||||||
|
<td>02.09.2022 - 19.11.2022</td>
|
||||||
|
<td>08.10.2022 - 13.10.2022</td>
|
||||||
|
<td>20.11.2022 - 25.11.2022</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>II</td>
|
||||||
|
<td>26.11.2022 - 19.02.2023</td>
|
||||||
|
<td>28.12.2022 - 07.01.2023 </td>
|
||||||
|
<td>20.02.2023 - 25.02.2023</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>III</td>
|
||||||
|
<td>26.02.2023 - 29.05.2023</td>
|
||||||
|
<td>10.04.2023 - 15.04.2023</td>
|
||||||
|
<td>30.05.2023 - 31.08.2023</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
24
FrontEnd/src/components/common/Banner.jsx
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import { useState, useEffect } from 'react';
|
||||||
|
import '../../style.css'
|
||||||
|
export default function Banner(props) {
|
||||||
|
const[bannerNum,setBanner]=useState(['show','hide','hide']);
|
||||||
|
useEffect(() => {
|
||||||
|
const length=3;
|
||||||
|
var old = length-1;
|
||||||
|
var current = 0;
|
||||||
|
const timer = window.setInterval(()=>{
|
||||||
|
setBanner([...bannerNum, bannerNum[current] = 'show', bannerNum[old] = 'hide']);
|
||||||
|
old = current;
|
||||||
|
current++;
|
||||||
|
if (current ===length) {
|
||||||
|
current = 0;
|
||||||
|
}
|
||||||
|
},5000);
|
||||||
|
return()=>{
|
||||||
|
window.clearInterval(timer);
|
||||||
|
}
|
||||||
|
},[]);
|
||||||
|
return(
|
||||||
|
<div id="banner"><img className={bannerNum[0]} src="img/banner1.png"/><img className={bannerNum[1]} src="img/banner2.png"/><img className={bannerNum[2]} src="img/banner3.png"/></div>
|
||||||
|
);
|
||||||
|
}
|
||||||
98
FrontEnd/src/components/common/Card.jsx
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import ModalEdit from './ModalComment';
|
||||||
|
import TablePostAndComment from './TablePostAndComment';
|
||||||
|
export default function Card(props) {
|
||||||
|
|
||||||
|
function edit(id) {
|
||||||
|
props.onEdit(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
function remove(id) {
|
||||||
|
props.onRemove(id);
|
||||||
|
}
|
||||||
|
useEffect(() => {
|
||||||
|
getAll();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const [clients, setClientst] = useState([]);
|
||||||
|
const getAll = async function () {
|
||||||
|
const requestUrl = "http://localhost:8080/user";
|
||||||
|
const response = await fetch(requestUrl);
|
||||||
|
const users = await response.json();
|
||||||
|
setClientst(users);
|
||||||
|
}
|
||||||
|
const [modalTable, setModalTable] = useState(false);
|
||||||
|
const [currEditItem, setCurrEditItem] = useState(0);
|
||||||
|
const [text, setText] = useState('');
|
||||||
|
function handleEdit(id) {
|
||||||
|
console.info("Start edit script");
|
||||||
|
setCurrEditItem(id);
|
||||||
|
setModalTable(true)
|
||||||
|
console.info('End edit script');
|
||||||
|
};
|
||||||
|
const handleSubmitEdit = async (e, id) => {
|
||||||
|
console.info('Start synchronize edit');
|
||||||
|
e.preventDefault(); // страница перестает перезагружаться
|
||||||
|
const requestUrl = `http://localhost:8080/post/${id}/Comment/${props.userId}?Text=${text}`;
|
||||||
|
const requestParams = {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
await fetch(requestUrl,requestParams);
|
||||||
|
setText('');
|
||||||
|
setModalTable(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="container-fluid mt-3">
|
||||||
|
{
|
||||||
|
props.items.map((item, index) =>
|
||||||
|
<div key={item.id}
|
||||||
|
className="card border-dark mb-3 d-flex flex-row text-black justify-content-between">
|
||||||
|
<div className=''>
|
||||||
|
<img className="col" style={{width: "300px" ,height: "200px" }} src={item.image}/>
|
||||||
|
</div>
|
||||||
|
<div className='d-flex flex-grow-1 flex-column'>
|
||||||
|
<div className='flex-grow-1 mx-2'>
|
||||||
|
{
|
||||||
|
props.headers.map(header =>
|
||||||
|
header.name == "image" ? null :
|
||||||
|
<div className="" key={item.id + header.name}>{item[header.name]}</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
<div className="d-flex flex-row justify-content-end ">
|
||||||
|
<button type="button" className="btn btn-outline-primary text-center mx-2" data-bs-toggle="modal" data-bs-target="#redact" onClick={(e) => edit(item.id, e)}>
|
||||||
|
<i className="fa-sharp fa-solid fa-pen"></i>
|
||||||
|
</button>
|
||||||
|
<button href="#"
|
||||||
|
className="btn btn-outline-primary mx-3"
|
||||||
|
onClick={(e) => remove(item.id, e)}><i className="fa-sharp fa-solid fa-trash"></i></button>
|
||||||
|
<a href={`/Post?id=${item.id}`} className='btn btn-outline-primary mx-2'><i className="fa-solid fa-envelopes-bulk"></i></a>
|
||||||
|
</div>
|
||||||
|
<TablePostAndComment
|
||||||
|
comments={item.comments}
|
||||||
|
value={props.value}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
<ModalEdit visible={modalTable} setVisible={setModalTable}>
|
||||||
|
<form className="g-3 fs-4 description fw-bold container" id="frm-items-edit" onSubmit={(e) => handleSubmitEdit(e, currEditItem)}>
|
||||||
|
<div className="row">
|
||||||
|
<label className="form-label" htmlFor="priceEdit">Комментарий</label>
|
||||||
|
<input value={text} onChange={e => setText(e.target.value)} className="form-control" name='priceEdit' id="priceEdit" type="text" placeholder="Введите содержимое комментария" required />
|
||||||
|
</div>
|
||||||
|
<div className="text-center mt-3">
|
||||||
|
<button className="btn btn-primary mx-1" type="submit" id="buttonSaveChanges">Сохранить изменения</button>
|
||||||
|
<button className="btn btn-secondary mx-1" type="button" data-bs-dismiss="modal" onClick={() => setModalTable(false)}>Отмена</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</ModalEdit>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
7
FrontEnd/src/components/common/Footer.jsx
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
import { NavLink } from 'react-router-dom';
|
||||||
|
|
||||||
|
export default function Footer(props) {
|
||||||
|
return (
|
||||||
|
<footer className="container-fluid d-flex text-white bg-primary bg-gradient mt-auto">© 2022 МОУ "СОШ №10"</footer>
|
||||||
|
);
|
||||||
|
}
|
||||||
30
FrontEnd/src/components/common/Header.jsx
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import { NavLink } from 'react-router-dom';
|
||||||
|
|
||||||
|
export default function Header(props) {
|
||||||
|
return (
|
||||||
|
<header className="fs-4 fw-bold p-1 text-white bg-primary bg-gradient">
|
||||||
|
<div><img className="img-fluid float-start" src="../img/Emblema.png" alt="Emblema"/>
|
||||||
|
<p className="fs-5 Cont">Муниципальное бюджетное общеобразовательное учреждение средняя общеобразовательная школа №10</p>
|
||||||
|
</div>
|
||||||
|
<nav className="navbar navbar-expand-md navbar-dark">
|
||||||
|
<div className="container-fluid">
|
||||||
|
<button className="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation"> <span className="navbar-toggler-icon"></span></button>
|
||||||
|
<div className="navbar-collapse collapse justify-content-end" id="navbarNav">
|
||||||
|
<nav className="headers-problem navbar navbar-expand-lg d-flex">
|
||||||
|
{
|
||||||
|
props.links.map(route =>
|
||||||
|
<button key={route.path}
|
||||||
|
className="btn btn-outline-light mx-1">
|
||||||
|
<NavLink className="nav-link" to={route.path}>
|
||||||
|
{route.label}
|
||||||
|
</NavLink>
|
||||||
|
</button>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
);
|
||||||
|
}
|
||||||
46
FrontEnd/src/components/common/Modal.jsx
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
import React from "react";
|
||||||
|
|
||||||
|
export default function Modal(props) {
|
||||||
|
const formRef = React.createRef();
|
||||||
|
|
||||||
|
function hide() {
|
||||||
|
props.onHide();
|
||||||
|
}
|
||||||
|
|
||||||
|
function done(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
if (formRef.current.checkValidity()) {
|
||||||
|
props.onDone();
|
||||||
|
hide();
|
||||||
|
} else {
|
||||||
|
formRef.current.reportValidity();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="modal fade show" tabIndex="-1" aria-hidden="true"
|
||||||
|
style={{ display: props.visible ? 'block' : 'none' }}>
|
||||||
|
<div className="modal-dialog">
|
||||||
|
<div className="modal-content">
|
||||||
|
<div className="modal-header">
|
||||||
|
<h1 className="modal-title fs-5" id="exampleModalLabel">{props.header}</h1>
|
||||||
|
<button className="btn-close" type="button" aria-label="Close"
|
||||||
|
onClick={hide}></button>
|
||||||
|
</div>
|
||||||
|
<div className="modal-body">
|
||||||
|
<form ref={formRef} onSubmit={done}>
|
||||||
|
{props.children}
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div className="modal-footer">
|
||||||
|
<button className="btn btn-secondary" type="button" onClick={hide}>Закрыть</button>
|
||||||
|
<button className="btn btn-primary" type="button" onClick={done}>
|
||||||
|
{props.confirm}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
18
FrontEnd/src/components/common/ModalComment.jsx
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import { React } from 'react'
|
||||||
|
import classes from '../../ModalEdit.module.css'
|
||||||
|
|
||||||
|
export default function ModalEdit({children, visible, setVisible}) {
|
||||||
|
|
||||||
|
const rootClasses = [classes.myModal]
|
||||||
|
if (visible) {
|
||||||
|
rootClasses.push(classes.active);
|
||||||
|
}
|
||||||
|
//onClick={()=>setVisible(false)}
|
||||||
|
return (
|
||||||
|
<div className={rootClasses.join(' ')} >
|
||||||
|
<div className={classes.myModalContent}>
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
34
FrontEnd/src/components/common/TableComment.jsx
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
export default function TableComment(props) {
|
||||||
|
function edit(id,e) {
|
||||||
|
props.onEdit(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
function remove(id,e) {
|
||||||
|
props.onRemove(id,e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return(
|
||||||
|
<table className="table mt-3">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">#</th>
|
||||||
|
<th scope="col">Text</th>
|
||||||
|
<th scope="col"></th>
|
||||||
|
<th scope="col"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="tbody">
|
||||||
|
{props.comments.map((comment) => (
|
||||||
|
<tr key={comment.id}>
|
||||||
|
{console.log(comment.user)}
|
||||||
|
<th scope="row">{comment.user}</th>
|
||||||
|
<td>{comment.text}</td>
|
||||||
|
<td><button type="button" className="btn btn-outline-light text-center mx-2" onClick={(e) => edit(comment.id, e)}><i className="fa-sharp fa-solid fa-pen"></i></button></td>
|
||||||
|
<td><button type="button" className="btn btn-outline-light text-center mx-2" onClick={(e) => remove(comment.id, e)}><i className="fa-sharp fa-solid fa-trash"></i></button></td>
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
);
|
||||||
|
}
|
||||||
26
FrontEnd/src/components/common/TablePostAndComment.jsx
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
export default function TablePostAndComment(props) {
|
||||||
|
const filteredads=props.comments.filter(ads=>{
|
||||||
|
return ads.text.includes(props.value);
|
||||||
|
})
|
||||||
|
return(
|
||||||
|
<table className="table mt-3">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col"></th>
|
||||||
|
<th scope="col"></th>
|
||||||
|
<th scope="col"></th>
|
||||||
|
<th scope="col"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="tbody">
|
||||||
|
{filteredads.map((comment) => (
|
||||||
|
<tr key={comment.id}>
|
||||||
|
{console.log(comment.user)}
|
||||||
|
<th scope="row">{comment.user}</th>
|
||||||
|
<td>{comment.text}</td>
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
);
|
||||||
|
}
|
||||||
43
FrontEnd/src/components/common/Toolbar.jsx
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
import { useState } from 'react';
|
||||||
|
import {useEffect} from 'react';
|
||||||
|
|
||||||
|
export default function Toolbar(props) {
|
||||||
|
function add() {
|
||||||
|
props.onAdd();
|
||||||
|
}
|
||||||
|
const [clients, setClientst] = useState([]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
getAll();
|
||||||
|
}, []);
|
||||||
|
const getAll = async function () {
|
||||||
|
const requestUrl = "http://localhost:8080/user";
|
||||||
|
const response = await fetch(requestUrl);
|
||||||
|
const users = await response.json();
|
||||||
|
setClientst(users);
|
||||||
|
}
|
||||||
|
function getuser(){
|
||||||
|
var selectBox = document.getElementById("selectBox");
|
||||||
|
var selectedValue = selectBox.options[selectBox.selectedIndex].value;
|
||||||
|
props.getUser(selectedValue);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<div className="d-flex float-start my-2">
|
||||||
|
<div className="mx-1">
|
||||||
|
<select id="selectBox" onChange={getuser}>
|
||||||
|
<option disabled value="">Выбор...</option>
|
||||||
|
{
|
||||||
|
clients.map((client) => (
|
||||||
|
<option className='text-black' key={client.id} value={client.id}>{client.firstName}</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<button type="button" className="btn btn-primary" onClick={add}>
|
||||||
|
+
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div >
|
||||||
|
);
|
||||||
|
}
|
||||||
10
FrontEnd/src/main.jsx
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import ReactDOM from 'react-dom/client'
|
||||||
|
import App from './App'
|
||||||
|
import './style.css'
|
||||||
|
|
||||||
|
ReactDOM.createRoot(document.getElementById('app')).render(
|
||||||
|
<React.StrictMode>
|
||||||
|
<App />
|
||||||
|
</React.StrictMode>
|
||||||
|
)
|
||||||
6
FrontEnd/src/models/CommentDto.js
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
export default class CommentDto {
|
||||||
|
constructor(args) {
|
||||||
|
this.id = args.id || null;
|
||||||
|
this.text = args.text;
|
||||||
|
}
|
||||||
|
}
|
||||||
9
FrontEnd/src/models/NewDto.js
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
export default class NewDto {
|
||||||
|
constructor(data) {
|
||||||
|
this.id = data?.id || null;
|
||||||
|
this.image = data?.image;
|
||||||
|
this.heading = data?.heading;
|
||||||
|
this.content = data?.content;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
8
FrontEnd/src/models/UserDto.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
export default class BuyerDto {
|
||||||
|
constructor(args) {
|
||||||
|
this.id = args.id || null;
|
||||||
|
this.firstName = args.firstName;
|
||||||
|
this.lastName = args.lastName;
|
||||||
|
this.email = args.email;
|
||||||
|
}
|
||||||
|
}
|
||||||
146
FrontEnd/src/style.css
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
html
|
||||||
|
{
|
||||||
|
min-height: 100vh;
|
||||||
|
}
|
||||||
|
header .img-fluid
|
||||||
|
{
|
||||||
|
width:232px;
|
||||||
|
height:100px;
|
||||||
|
}
|
||||||
|
|
||||||
|
article .img-fluid
|
||||||
|
{
|
||||||
|
height:250px;
|
||||||
|
}
|
||||||
|
article .img-fluid1
|
||||||
|
{
|
||||||
|
height:100%;
|
||||||
|
width: 96%;
|
||||||
|
}
|
||||||
|
.owl
|
||||||
|
{
|
||||||
|
width:300px;
|
||||||
|
}
|
||||||
|
.pdf-size
|
||||||
|
{
|
||||||
|
width:70px;
|
||||||
|
}
|
||||||
|
body
|
||||||
|
{
|
||||||
|
min-height: 100vh;
|
||||||
|
}
|
||||||
|
.body_app
|
||||||
|
{
|
||||||
|
display: grid;
|
||||||
|
grid-template-rows:auto 1fr auto;
|
||||||
|
min-height: 100vh;
|
||||||
|
}
|
||||||
|
.lp
|
||||||
|
{
|
||||||
|
padding-left: 30px;
|
||||||
|
}
|
||||||
|
.img-school
|
||||||
|
{
|
||||||
|
margin-right: 1em;
|
||||||
|
float: start;
|
||||||
|
|
||||||
|
}
|
||||||
|
.Vnov
|
||||||
|
{
|
||||||
|
margin-right: 1em;
|
||||||
|
}
|
||||||
|
.Vnov1
|
||||||
|
{
|
||||||
|
margin-right: 1em;
|
||||||
|
}
|
||||||
|
.Cont
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@media only screen and (max-width: 800px) {
|
||||||
|
.owl {
|
||||||
|
display:none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media only screen and (max-width: 1164px) {
|
||||||
|
.img-school
|
||||||
|
{
|
||||||
|
margin-right: 170px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media only screen and (max-width: 554px) {
|
||||||
|
.img-school
|
||||||
|
{
|
||||||
|
height: 20% !important;
|
||||||
|
width: 75%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media only screen and (max-width: 727px) {
|
||||||
|
.headers-problem
|
||||||
|
{
|
||||||
|
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
.navbar
|
||||||
|
{
|
||||||
|
align-items: flex-start !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@media only screen and (max-width: 959px) {
|
||||||
|
.navbar
|
||||||
|
{
|
||||||
|
float:left !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media only screen and (max-width: 463px) {
|
||||||
|
.Vnov
|
||||||
|
{
|
||||||
|
margin-right: 140px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media only screen and (max-width: 575px) {
|
||||||
|
.Vnov1
|
||||||
|
{
|
||||||
|
margin-right: 200px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media only screen and (max-width: 585px) {
|
||||||
|
.Cont
|
||||||
|
{
|
||||||
|
margin-right: 200px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#banner {
|
||||||
|
margin: 15px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
#banner img {
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#banner img.show {
|
||||||
|
height: 40%;
|
||||||
|
width: 60%;
|
||||||
|
opacity: 1;
|
||||||
|
transition: opacity 1s, visibility 0s;
|
||||||
|
}
|
||||||
|
|
||||||
|
#banner img.hide {
|
||||||
|
height: 0;
|
||||||
|
width: 0;
|
||||||
|
opacity: 0;
|
||||||
|
visibility: hidden;
|
||||||
|
transition: opacity 1s, visibility 0s 1s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Pole_height
|
||||||
|
{
|
||||||
|
height: 80px;
|
||||||
|
}
|
||||||
7
FrontEnd/vite.config.js
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
import { defineConfig } from 'vite'
|
||||||
|
import react from '@vitejs/plugin-react'
|
||||||
|
|
||||||
|
// https://vitejs.dev/config/
|
||||||
|
export default defineConfig({
|
||||||
|
plugins: [react()]
|
||||||
|
})
|
||||||
20
build.gradle
@@ -4,17 +4,33 @@ plugins {
|
|||||||
id 'io.spring.dependency-management' version '1.1.0'
|
id 'io.spring.dependency-management' version '1.1.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
group = 'ru.ulstu.is'
|
group = 'np'
|
||||||
version = '0.0.1-SNAPSHOT'
|
version = '0.0.1-SNAPSHOT'
|
||||||
sourceCompatibility = '17'
|
sourceCompatibility = '17'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
jar {
|
||||||
|
enabled = false
|
||||||
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||||
|
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
|
||||||
|
implementation 'org.springframework.boot:spring-boot-devtools'
|
||||||
|
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
|
||||||
|
implementation 'nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect'
|
||||||
|
|
||||||
|
implementation 'org.webjars:bootstrap:5.1.3'
|
||||||
|
implementation 'org.webjars:jquery:3.6.0'
|
||||||
|
implementation 'org.webjars:font-awesome:6.1.0'
|
||||||
|
|
||||||
|
implementation 'com.h2database:h2:2.1.210'
|
||||||
|
implementation 'org.hibernate.validator:hibernate-validator'
|
||||||
|
implementation 'org.springdoc:springdoc-openapi-ui:1.6.5'
|
||||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||||
|
//implementation group: 'org.springdoc', name: 'springdoc-openapi-ui', version: '1.6.5'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.named('test') {
|
tasks.named('test') {
|
||||||
|
|||||||
452
data.trace.db
Normal file
@@ -0,0 +1,452 @@
|
|||||||
|
2023-03-27 16:52:44 jdbc[3]: exception
|
||||||
|
org.h2.jdbc.JdbcSQLSyntaxErrorException: Синтаксическая ошибка в выражении SQL "create table [*]user (id bigint not null, email varchar(255), first_name varchar(255), last_name varchar(255), primary key (id))"; ожидалось "identifier"
|
||||||
|
Syntax error in SQL statement "create table [*]user (id bigint not null, email varchar(255), first_name varchar(255), last_name varchar(255), primary key (id))"; expected "identifier"; SQL statement:
|
||||||
|
create table user (id bigint not null, email varchar(255), first_name varchar(255), last_name varchar(255), primary key (id)) [42001-210]
|
||||||
|
2023-03-27 16:52:44 jdbc[3]: exception
|
||||||
|
org.h2.jdbc.JdbcSQLSyntaxErrorException: Синтаксическая ошибка в выражении SQL "alter table if exists comment add constraint FK8kcum44fvpupyw6f5baccx25c foreign key (user_id) references [*]user"; ожидалось "identifier"
|
||||||
|
Syntax error in SQL statement "alter table if exists comment add constraint FK8kcum44fvpupyw6f5baccx25c foreign key (user_id) references [*]user"; expected "identifier"; SQL statement:
|
||||||
|
alter table if exists comment add constraint FK8kcum44fvpupyw6f5baccx25c foreign key (user_id) references user [42001-210]
|
||||||
|
2023-03-27 16:52:44 jdbc[3]: exception
|
||||||
|
org.h2.jdbc.JdbcSQLSyntaxErrorException: Синтаксическая ошибка в выражении SQL "alter table if exists post add constraint FK72mt33dhhs48hf9gcqrq4fxte foreign key (user_id) references [*]user"; ожидалось "identifier"
|
||||||
|
Syntax error in SQL statement "alter table if exists post add constraint FK72mt33dhhs48hf9gcqrq4fxte foreign key (user_id) references [*]user"; expected "identifier"; SQL statement:
|
||||||
|
alter table if exists post add constraint FK72mt33dhhs48hf9gcqrq4fxte foreign key (user_id) references user [42001-210]
|
||||||
|
2023-03-27 21:45:28 database: wrong user or password; user: "SA"
|
||||||
|
org.h2.message.DbException: Неверное имя пользователя или пароль
|
||||||
|
Wrong user name or password [28000-210]
|
||||||
|
at org.h2.message.DbException.get(DbException.java:227)
|
||||||
|
at org.h2.message.DbException.get(DbException.java:203)
|
||||||
|
at org.h2.message.DbException.get(DbException.java:192)
|
||||||
|
at org.h2.engine.Engine.openSession(Engine.java:154)
|
||||||
|
at org.h2.engine.Engine.openSession(Engine.java:222)
|
||||||
|
at org.h2.engine.Engine.createSession(Engine.java:201)
|
||||||
|
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:338)
|
||||||
|
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:122)
|
||||||
|
at org.h2.util.JdbcUtils.getConnection(JdbcUtils.java:288)
|
||||||
|
at org.h2.server.web.WebServer.getConnection(WebServer.java:807)
|
||||||
|
at org.h2.server.web.WebApp.login(WebApp.java:1033)
|
||||||
|
at org.h2.server.web.WebApp.process(WebApp.java:226)
|
||||||
|
at org.h2.server.web.WebApp.processRequest(WebApp.java:176)
|
||||||
|
at org.h2.server.web.JakartaWebServlet.doGet(JakartaWebServlet.java:129)
|
||||||
|
at org.h2.server.web.JakartaWebServlet.doPost(JakartaWebServlet.java:166)
|
||||||
|
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:731)
|
||||||
|
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:814)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:223)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
|
||||||
|
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
|
||||||
|
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
|
||||||
|
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
|
||||||
|
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
|
||||||
|
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
|
||||||
|
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
|
||||||
|
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
|
||||||
|
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:177)
|
||||||
|
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
|
||||||
|
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)
|
||||||
|
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:119)
|
||||||
|
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
|
||||||
|
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
|
||||||
|
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357)
|
||||||
|
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:400)
|
||||||
|
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
|
||||||
|
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:859)
|
||||||
|
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1734)
|
||||||
|
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
|
||||||
|
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
|
||||||
|
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
|
||||||
|
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
|
||||||
|
at java.base/java.lang.Thread.run(Thread.java:833)
|
||||||
|
Caused by: org.h2.jdbc.JdbcSQLInvalidAuthorizationSpecException: Неверное имя пользователя или пароль
|
||||||
|
Wrong user name or password [28000-210]
|
||||||
|
at org.h2.message.DbException.getJdbcSQLException(DbException.java:529)
|
||||||
|
at org.h2.message.DbException.getJdbcSQLException(DbException.java:496)
|
||||||
|
... 50 more
|
||||||
|
2023-03-27 21:45:50 database: wrong user or password; user: "SA"
|
||||||
|
org.h2.message.DbException: Неверное имя пользователя или пароль
|
||||||
|
Wrong user name or password [28000-210]
|
||||||
|
at org.h2.message.DbException.get(DbException.java:227)
|
||||||
|
at org.h2.message.DbException.get(DbException.java:203)
|
||||||
|
at org.h2.message.DbException.get(DbException.java:192)
|
||||||
|
at org.h2.engine.Engine.openSession(Engine.java:154)
|
||||||
|
at org.h2.engine.Engine.openSession(Engine.java:222)
|
||||||
|
at org.h2.engine.Engine.createSession(Engine.java:201)
|
||||||
|
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:338)
|
||||||
|
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:122)
|
||||||
|
at org.h2.util.JdbcUtils.getConnection(JdbcUtils.java:288)
|
||||||
|
at org.h2.server.web.WebServer.getConnection(WebServer.java:807)
|
||||||
|
at org.h2.server.web.WebApp.login(WebApp.java:1033)
|
||||||
|
at org.h2.server.web.WebApp.process(WebApp.java:226)
|
||||||
|
at org.h2.server.web.WebApp.processRequest(WebApp.java:176)
|
||||||
|
at org.h2.server.web.JakartaWebServlet.doGet(JakartaWebServlet.java:129)
|
||||||
|
at org.h2.server.web.JakartaWebServlet.doPost(JakartaWebServlet.java:166)
|
||||||
|
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:731)
|
||||||
|
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:814)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:223)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
|
||||||
|
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
|
||||||
|
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
|
||||||
|
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
|
||||||
|
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
|
||||||
|
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
|
||||||
|
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
|
||||||
|
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
|
||||||
|
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:177)
|
||||||
|
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
|
||||||
|
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)
|
||||||
|
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:119)
|
||||||
|
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
|
||||||
|
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
|
||||||
|
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357)
|
||||||
|
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:400)
|
||||||
|
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
|
||||||
|
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:859)
|
||||||
|
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1734)
|
||||||
|
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
|
||||||
|
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
|
||||||
|
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
|
||||||
|
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
|
||||||
|
at java.base/java.lang.Thread.run(Thread.java:833)
|
||||||
|
Caused by: org.h2.jdbc.JdbcSQLInvalidAuthorizationSpecException: Неверное имя пользователя или пароль
|
||||||
|
Wrong user name or password [28000-210]
|
||||||
|
at org.h2.message.DbException.getJdbcSQLException(DbException.java:529)
|
||||||
|
at org.h2.message.DbException.getJdbcSQLException(DbException.java:496)
|
||||||
|
... 50 more
|
||||||
|
2023-04-10 17:11:04 database: wrong user or password; user: "SA"
|
||||||
|
org.h2.message.DbException: Неверное имя пользователя или пароль
|
||||||
|
Wrong user name or password [28000-210]
|
||||||
|
at org.h2.message.DbException.get(DbException.java:227)
|
||||||
|
at org.h2.message.DbException.get(DbException.java:203)
|
||||||
|
at org.h2.message.DbException.get(DbException.java:192)
|
||||||
|
at org.h2.engine.Engine.openSession(Engine.java:154)
|
||||||
|
at org.h2.engine.Engine.openSession(Engine.java:222)
|
||||||
|
at org.h2.engine.Engine.createSession(Engine.java:201)
|
||||||
|
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:338)
|
||||||
|
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:122)
|
||||||
|
at org.h2.util.JdbcUtils.getConnection(JdbcUtils.java:288)
|
||||||
|
at org.h2.server.web.WebServer.getConnection(WebServer.java:807)
|
||||||
|
at org.h2.server.web.WebApp.login(WebApp.java:1033)
|
||||||
|
at org.h2.server.web.WebApp.process(WebApp.java:226)
|
||||||
|
at org.h2.server.web.WebApp.processRequest(WebApp.java:176)
|
||||||
|
at org.h2.server.web.JakartaWebServlet.doGet(JakartaWebServlet.java:129)
|
||||||
|
at org.h2.server.web.JakartaWebServlet.doPost(JakartaWebServlet.java:166)
|
||||||
|
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:731)
|
||||||
|
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:814)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:223)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
|
||||||
|
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
|
||||||
|
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
|
||||||
|
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
|
||||||
|
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
|
||||||
|
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
|
||||||
|
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
|
||||||
|
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
|
||||||
|
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:177)
|
||||||
|
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
|
||||||
|
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)
|
||||||
|
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:119)
|
||||||
|
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
|
||||||
|
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
|
||||||
|
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357)
|
||||||
|
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:400)
|
||||||
|
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
|
||||||
|
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:859)
|
||||||
|
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1734)
|
||||||
|
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
|
||||||
|
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
|
||||||
|
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
|
||||||
|
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
|
||||||
|
at java.base/java.lang.Thread.run(Thread.java:833)
|
||||||
|
Caused by: org.h2.jdbc.JdbcSQLInvalidAuthorizationSpecException: Неверное имя пользователя или пароль
|
||||||
|
Wrong user name or password [28000-210]
|
||||||
|
at org.h2.message.DbException.getJdbcSQLException(DbException.java:529)
|
||||||
|
at org.h2.message.DbException.getJdbcSQLException(DbException.java:496)
|
||||||
|
... 50 more
|
||||||
|
2023-04-21 13:55:26 database: wrong user or password; user: "SA"
|
||||||
|
org.h2.message.DbException: Неверное имя пользователя или пароль
|
||||||
|
Wrong user name or password [28000-210]
|
||||||
|
at org.h2.message.DbException.get(DbException.java:227)
|
||||||
|
at org.h2.message.DbException.get(DbException.java:203)
|
||||||
|
at org.h2.message.DbException.get(DbException.java:192)
|
||||||
|
at org.h2.engine.Engine.openSession(Engine.java:154)
|
||||||
|
at org.h2.engine.Engine.openSession(Engine.java:222)
|
||||||
|
at org.h2.engine.Engine.createSession(Engine.java:201)
|
||||||
|
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:338)
|
||||||
|
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:122)
|
||||||
|
at org.h2.util.JdbcUtils.getConnection(JdbcUtils.java:288)
|
||||||
|
at org.h2.server.web.WebServer.getConnection(WebServer.java:807)
|
||||||
|
at org.h2.server.web.WebApp.login(WebApp.java:1033)
|
||||||
|
at org.h2.server.web.WebApp.process(WebApp.java:226)
|
||||||
|
at org.h2.server.web.WebApp.processRequest(WebApp.java:176)
|
||||||
|
at org.h2.server.web.JakartaWebServlet.doGet(JakartaWebServlet.java:129)
|
||||||
|
at org.h2.server.web.JakartaWebServlet.doPost(JakartaWebServlet.java:166)
|
||||||
|
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:731)
|
||||||
|
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:814)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:223)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
|
||||||
|
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
|
||||||
|
at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:66)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
|
||||||
|
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
|
||||||
|
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
|
||||||
|
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
|
||||||
|
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
|
||||||
|
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
|
||||||
|
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
|
||||||
|
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:177)
|
||||||
|
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
|
||||||
|
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)
|
||||||
|
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:119)
|
||||||
|
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
|
||||||
|
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
|
||||||
|
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357)
|
||||||
|
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:400)
|
||||||
|
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
|
||||||
|
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:859)
|
||||||
|
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1734)
|
||||||
|
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
|
||||||
|
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
|
||||||
|
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
|
||||||
|
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
|
||||||
|
at java.base/java.lang.Thread.run(Thread.java:833)
|
||||||
|
Caused by: org.h2.jdbc.JdbcSQLInvalidAuthorizationSpecException: Неверное имя пользователя или пароль
|
||||||
|
Wrong user name or password [28000-210]
|
||||||
|
at org.h2.message.DbException.getJdbcSQLException(DbException.java:529)
|
||||||
|
at org.h2.message.DbException.getJdbcSQLException(DbException.java:496)
|
||||||
|
... 53 more
|
||||||
|
2023-04-22 11:20:00 jdbc[13]: exception
|
||||||
|
org.h2.jdbc.JdbcSQLDataException: Невозможно преобразование строки в тип "TIMESTAMP"
|
||||||
|
Cannot parse "TIMESTAMP" constant ; SQL statement:
|
||||||
|
INSERT INTO "PUBLIC"."COMMENT"("ID","DATE_OF_ADD","TEXT","POST_ID","USER_ID")VALUES(?,?,?,?,?) [22007-210]
|
||||||
|
at org.h2.message.DbException.getJdbcSQLException(DbException.java:525)
|
||||||
|
at org.h2.message.DbException.getJdbcSQLException(DbException.java:496)
|
||||||
|
at org.h2.message.DbException.get(DbException.java:216)
|
||||||
|
at org.h2.value.ValueTimestamp.parse(ValueTimestamp.java:88)
|
||||||
|
at org.h2.value.Value.convertToTimestamp(Value.java:1980)
|
||||||
|
at org.h2.value.Value.convertTo(Value.java:1153)
|
||||||
|
at org.h2.value.Value.convertForAssignTo(Value.java:1092)
|
||||||
|
at org.h2.table.Column.validateConvertUpdateSequence(Column.java:369)
|
||||||
|
at org.h2.table.Table.convertInsertRow(Table.java:931)
|
||||||
|
at org.h2.command.dml.Insert.insertRows(Insert.java:167)
|
||||||
|
at org.h2.command.dml.Insert.update(Insert.java:135)
|
||||||
|
at org.h2.command.dml.DataChangeStatement.update(DataChangeStatement.java:61)
|
||||||
|
at org.h2.command.CommandContainer.update(CommandContainer.java:174)
|
||||||
|
at org.h2.command.Command.executeUpdate(Command.java:252)
|
||||||
|
at org.h2.jdbc.JdbcPreparedStatement.executeUpdateInternal(JdbcPreparedStatement.java:209)
|
||||||
|
at org.h2.jdbc.JdbcPreparedStatement.executeUpdate(JdbcPreparedStatement.java:169)
|
||||||
|
at org.h2.result.UpdatableRow.insertRow(UpdatableRow.java:334)
|
||||||
|
at org.h2.jdbc.JdbcResultSet.insertRow(JdbcResultSet.java:3335)
|
||||||
|
at org.h2.server.web.WebApp.editResult(WebApp.java:1159)
|
||||||
|
at org.h2.server.web.WebApp.process(WebApp.java:250)
|
||||||
|
at org.h2.server.web.WebApp.processRequest(WebApp.java:176)
|
||||||
|
at org.h2.server.web.JakartaWebServlet.doGet(JakartaWebServlet.java:129)
|
||||||
|
at org.h2.server.web.JakartaWebServlet.doPost(JakartaWebServlet.java:166)
|
||||||
|
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:731)
|
||||||
|
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:814)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:223)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
|
||||||
|
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
|
||||||
|
at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:66)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
|
||||||
|
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
|
||||||
|
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
|
||||||
|
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
|
||||||
|
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
|
||||||
|
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
|
||||||
|
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
|
||||||
|
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:177)
|
||||||
|
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
|
||||||
|
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)
|
||||||
|
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:119)
|
||||||
|
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
|
||||||
|
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
|
||||||
|
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357)
|
||||||
|
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:400)
|
||||||
|
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
|
||||||
|
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:859)
|
||||||
|
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1734)
|
||||||
|
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
|
||||||
|
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
|
||||||
|
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
|
||||||
|
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
|
||||||
|
at java.base/java.lang.Thread.run(Thread.java:833)
|
||||||
|
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 0
|
||||||
|
at java.base/java.lang.StringLatin1.charAt(StringLatin1.java:48)
|
||||||
|
at java.base/java.lang.String.charAt(String.java:1513)
|
||||||
|
at org.h2.util.DateTimeUtils.parseDateValue(DateTimeUtils.java:166)
|
||||||
|
at org.h2.util.DateTimeUtils.parseTimestamp(DateTimeUtils.java:338)
|
||||||
|
at org.h2.value.ValueTimestamp.parse(ValueTimestamp.java:86)
|
||||||
|
... 57 more
|
||||||
|
2023-04-22 11:20:00 jdbc[13]: exception
|
||||||
|
org.h2.jdbc.JdbcSQLDataException: Невозможно преобразование строки в тип "TIMESTAMP"
|
||||||
|
Cannot parse "TIMESTAMP" constant ; SQL statement:
|
||||||
|
INSERT INTO "PUBLIC"."COMMENT"("ID","DATE_OF_ADD","TEXT","POST_ID","USER_ID")VALUES(?,?,?,?,?) [22007-210]
|
||||||
|
at org.h2.message.DbException.getJdbcSQLException(DbException.java:525)
|
||||||
|
at org.h2.message.DbException.getJdbcSQLException(DbException.java:496)
|
||||||
|
at org.h2.message.DbException.get(DbException.java:216)
|
||||||
|
at org.h2.value.ValueTimestamp.parse(ValueTimestamp.java:88)
|
||||||
|
at org.h2.value.Value.convertToTimestamp(Value.java:1980)
|
||||||
|
at org.h2.value.Value.convertTo(Value.java:1153)
|
||||||
|
at org.h2.value.Value.convertForAssignTo(Value.java:1092)
|
||||||
|
at org.h2.table.Column.validateConvertUpdateSequence(Column.java:369)
|
||||||
|
at org.h2.table.Table.convertInsertRow(Table.java:931)
|
||||||
|
at org.h2.command.dml.Insert.insertRows(Insert.java:167)
|
||||||
|
at org.h2.command.dml.Insert.update(Insert.java:135)
|
||||||
|
at org.h2.command.dml.DataChangeStatement.update(DataChangeStatement.java:61)
|
||||||
|
at org.h2.command.CommandContainer.update(CommandContainer.java:174)
|
||||||
|
at org.h2.command.Command.executeUpdate(Command.java:252)
|
||||||
|
at org.h2.jdbc.JdbcPreparedStatement.executeUpdateInternal(JdbcPreparedStatement.java:209)
|
||||||
|
at org.h2.jdbc.JdbcPreparedStatement.executeUpdate(JdbcPreparedStatement.java:169)
|
||||||
|
at org.h2.result.UpdatableRow.insertRow(UpdatableRow.java:334)
|
||||||
|
at org.h2.jdbc.JdbcResultSet.insertRow(JdbcResultSet.java:3335)
|
||||||
|
at org.h2.server.web.WebApp.editResult(WebApp.java:1159)
|
||||||
|
at org.h2.server.web.WebApp.process(WebApp.java:250)
|
||||||
|
at org.h2.server.web.WebApp.processRequest(WebApp.java:176)
|
||||||
|
at org.h2.server.web.JakartaWebServlet.doGet(JakartaWebServlet.java:129)
|
||||||
|
at org.h2.server.web.JakartaWebServlet.doPost(JakartaWebServlet.java:166)
|
||||||
|
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:731)
|
||||||
|
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:814)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:223)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
|
||||||
|
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
|
||||||
|
at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:66)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
|
||||||
|
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
|
||||||
|
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
|
||||||
|
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
|
||||||
|
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
|
||||||
|
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
|
||||||
|
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
|
||||||
|
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:177)
|
||||||
|
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
|
||||||
|
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)
|
||||||
|
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:119)
|
||||||
|
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
|
||||||
|
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
|
||||||
|
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357)
|
||||||
|
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:400)
|
||||||
|
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
|
||||||
|
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:859)
|
||||||
|
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1734)
|
||||||
|
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
|
||||||
|
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
|
||||||
|
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
|
||||||
|
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
|
||||||
|
at java.base/java.lang.Thread.run(Thread.java:833)
|
||||||
|
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 0
|
||||||
|
at java.base/java.lang.StringLatin1.charAt(StringLatin1.java:48)
|
||||||
|
at java.base/java.lang.String.charAt(String.java:1513)
|
||||||
|
at org.h2.util.DateTimeUtils.parseDateValue(DateTimeUtils.java:166)
|
||||||
|
at org.h2.util.DateTimeUtils.parseTimestamp(DateTimeUtils.java:338)
|
||||||
|
at org.h2.value.ValueTimestamp.parse(ValueTimestamp.java:86)
|
||||||
|
... 57 more
|
||||||
|
2023-04-22 12:15:44 database: wrong user or password; user: "SA"
|
||||||
|
org.h2.message.DbException: Неверное имя пользователя или пароль
|
||||||
|
Wrong user name or password [28000-210]
|
||||||
|
at org.h2.message.DbException.get(DbException.java:227)
|
||||||
|
at org.h2.message.DbException.get(DbException.java:203)
|
||||||
|
at org.h2.message.DbException.get(DbException.java:192)
|
||||||
|
at org.h2.engine.Engine.openSession(Engine.java:154)
|
||||||
|
at org.h2.engine.Engine.openSession(Engine.java:222)
|
||||||
|
at org.h2.engine.Engine.createSession(Engine.java:201)
|
||||||
|
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:338)
|
||||||
|
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:122)
|
||||||
|
at org.h2.util.JdbcUtils.getConnection(JdbcUtils.java:288)
|
||||||
|
at org.h2.server.web.WebServer.getConnection(WebServer.java:807)
|
||||||
|
at org.h2.server.web.WebApp.login(WebApp.java:1033)
|
||||||
|
at org.h2.server.web.WebApp.process(WebApp.java:226)
|
||||||
|
at org.h2.server.web.WebApp.processRequest(WebApp.java:176)
|
||||||
|
at org.h2.server.web.JakartaWebServlet.doGet(JakartaWebServlet.java:129)
|
||||||
|
at org.h2.server.web.JakartaWebServlet.doPost(JakartaWebServlet.java:166)
|
||||||
|
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:731)
|
||||||
|
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:814)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:223)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
|
||||||
|
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
|
||||||
|
at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:66)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
|
||||||
|
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
|
||||||
|
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
|
||||||
|
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
|
||||||
|
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
|
||||||
|
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
|
||||||
|
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
|
||||||
|
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
|
||||||
|
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:177)
|
||||||
|
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
|
||||||
|
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)
|
||||||
|
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:119)
|
||||||
|
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
|
||||||
|
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
|
||||||
|
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357)
|
||||||
|
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:400)
|
||||||
|
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
|
||||||
|
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:859)
|
||||||
|
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1734)
|
||||||
|
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
|
||||||
|
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
|
||||||
|
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
|
||||||
|
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
|
||||||
|
at java.base/java.lang.Thread.run(Thread.java:833)
|
||||||
|
Caused by: org.h2.jdbc.JdbcSQLInvalidAuthorizationSpecException: Неверное имя пользователя или пароль
|
||||||
|
Wrong user name or password [28000-210]
|
||||||
|
at org.h2.message.DbException.getJdbcSQLException(DbException.java:529)
|
||||||
|
at org.h2.message.DbException.getJdbcSQLException(DbException.java:496)
|
||||||
|
... 53 more
|
||||||
BIN
reports/Отчёт 3.docx
Normal file
BIN
reports/Отчёт 4.docx
Normal file
BIN
reports/Отчёт 5.docx
Normal file
@@ -1 +1,2 @@
|
|||||||
rootProject.name = 'sbapp'
|
rootProject.name = 'sbapp'
|
||||||
|
include 'FrontEnd'
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package ru.ulstu.is.sbapp.Comment.controller;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import ru.ulstu.is.sbapp.Comment.model.CommentDto;
|
||||||
|
import ru.ulstu.is.sbapp.Comment.service.CommentService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/comment")
|
||||||
|
public class CommentController {
|
||||||
|
private final CommentService commentService;
|
||||||
|
public CommentController(CommentService commentService) {
|
||||||
|
this.commentService = commentService;
|
||||||
|
}
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
public CommentDto getComment(@PathVariable Long id) {
|
||||||
|
return new CommentDto(commentService.findComment(id));
|
||||||
|
}
|
||||||
|
@GetMapping
|
||||||
|
public List<CommentDto> getComments() {
|
||||||
|
return commentService.findAllComments().stream()
|
||||||
|
.map(CommentDto::new)
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
@PostMapping
|
||||||
|
public CommentDto createComment(@RequestParam("Text") String Text){
|
||||||
|
return new CommentDto(commentService.addComment(Text));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/{id}")
|
||||||
|
public CommentDto updateComment(@PathVariable Long id,
|
||||||
|
@RequestParam("Text") String Text){
|
||||||
|
return new CommentDto(commentService.updateComment(id,Text));
|
||||||
|
}
|
||||||
|
@DeleteMapping("/{id}")
|
||||||
|
public CommentDto deleteComment(@PathVariable Long id) {
|
||||||
|
return new CommentDto(commentService.deleteComment(id));
|
||||||
|
}
|
||||||
|
}
|
||||||
81
src/main/java/ru/ulstu/is/sbapp/Comment/model/Comment.java
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
package ru.ulstu.is.sbapp.Comment.model;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import ru.ulstu.is.sbapp.Post.model.Post;
|
||||||
|
import ru.ulstu.is.sbapp.User.model.User;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
public class Comment {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
@NotBlank(message = "Text cannot be null")
|
||||||
|
private String Text;
|
||||||
|
|
||||||
|
@ManyToOne(fetch = FetchType.EAGER,cascade = CascadeType.MERGE)
|
||||||
|
private Post post;
|
||||||
|
|
||||||
|
@ManyToOne(fetch = FetchType.EAGER,cascade = CascadeType.MERGE)
|
||||||
|
private User user;
|
||||||
|
|
||||||
|
public Comment()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Comment(String text)
|
||||||
|
{
|
||||||
|
this.Text=text;
|
||||||
|
}
|
||||||
|
public Long getId()
|
||||||
|
{
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
public String getText() {return Text;}
|
||||||
|
public void setText(String text){this.Text=text;}
|
||||||
|
public User getUser()
|
||||||
|
{
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
public Post getPost()
|
||||||
|
{
|
||||||
|
return post;
|
||||||
|
}
|
||||||
|
public void setPost(Post post, User user){
|
||||||
|
if(post!=null)
|
||||||
|
{
|
||||||
|
post.getComments().add(this);
|
||||||
|
this.post = post;
|
||||||
|
|
||||||
|
this.user = user;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
Comment comment = (Comment) o;
|
||||||
|
return Objects.equals(id, comment.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Comment{" +
|
||||||
|
"id=" + id +
|
||||||
|
", Text='" + Text + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package ru.ulstu.is.sbapp.Comment.model;
|
||||||
|
|
||||||
|
|
||||||
|
public class CommentDto {
|
||||||
|
private Long id;
|
||||||
|
private String Text;
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
private Long postId;
|
||||||
|
public CommentDto(){}
|
||||||
|
public CommentDto(Comment comment)
|
||||||
|
{
|
||||||
|
this.id= comment.getId();
|
||||||
|
this.Text=comment.getText();
|
||||||
|
this.userName=comment.getUser().getFirstName() + " " + comment.getUser().getLastName();
|
||||||
|
this.postId=comment.getPost().getId();
|
||||||
|
}
|
||||||
|
public Long getId()
|
||||||
|
{
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
public String getText() {return Text;}
|
||||||
|
|
||||||
|
public String getUser()
|
||||||
|
{
|
||||||
|
return userName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getPostId()
|
||||||
|
{
|
||||||
|
return postId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setText(String text) {
|
||||||
|
Text = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserName(String userName) {
|
||||||
|
this.userName = userName;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package ru.ulstu.is.sbapp.Comment.repository;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import ru.ulstu.is.sbapp.Comment.model.Comment;
|
||||||
|
|
||||||
|
public interface CommentRepository extends JpaRepository<Comment, Long> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package ru.ulstu.is.sbapp.Comment.service;
|
||||||
|
|
||||||
|
public class CommentNotFoundException extends RuntimeException{
|
||||||
|
public CommentNotFoundException(Long id) {
|
||||||
|
super(String.format("Comment with id [%s] is not found", id));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
package ru.ulstu.is.sbapp.Comment.service;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
|
||||||
|
import ru.ulstu.is.sbapp.Comment.model.Comment;
|
||||||
|
import ru.ulstu.is.sbapp.Comment.repository.CommentRepository;
|
||||||
|
import ru.ulstu.is.sbapp.Util.validation.ValidatorUtil;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class CommentService {
|
||||||
|
private final CommentRepository commentRepository;
|
||||||
|
private final ValidatorUtil validatorUtil;
|
||||||
|
|
||||||
|
public CommentService(CommentRepository commentRepository, ValidatorUtil validatorUtil)
|
||||||
|
{
|
||||||
|
this.commentRepository=commentRepository;
|
||||||
|
this.validatorUtil=validatorUtil;
|
||||||
|
}
|
||||||
|
@Transactional
|
||||||
|
public Comment addComment(String Text) {
|
||||||
|
final Comment comment = new Comment(Text);
|
||||||
|
validatorUtil.validate(comment);
|
||||||
|
return commentRepository.save(comment);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void saveComment(Comment comment) {
|
||||||
|
commentRepository.save(comment);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(readOnly = true)
|
||||||
|
public Comment findComment(Long id) {
|
||||||
|
final Optional<Comment> client = commentRepository.findById(id);
|
||||||
|
return client.orElseThrow(() -> new CommentNotFoundException(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(readOnly = true)
|
||||||
|
public List<Comment> findAllComments() {
|
||||||
|
return commentRepository.findAll();
|
||||||
|
}
|
||||||
|
@Transactional
|
||||||
|
public Comment updateComment(Long id,String Text) {
|
||||||
|
final Comment currentComment = findComment(id);
|
||||||
|
currentComment.setText(Text);
|
||||||
|
validatorUtil.validate(currentComment);
|
||||||
|
return commentRepository.save(currentComment);
|
||||||
|
}
|
||||||
|
@Transactional
|
||||||
|
public Comment deleteComment(Long id) {
|
||||||
|
final Comment currentComment = findComment(id);
|
||||||
|
commentRepository.delete(currentComment);
|
||||||
|
return currentComment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void deleteAllComments() {
|
||||||
|
commentRepository.deleteAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
package ru.ulstu.is.sbapp.Post.controller;
|
||||||
|
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import ru.ulstu.is.sbapp.Comment.model.CommentDto;
|
||||||
|
import ru.ulstu.is.sbapp.Post.model.PostDto;
|
||||||
|
import ru.ulstu.is.sbapp.Post.service.PostService;
|
||||||
|
import ru.ulstu.is.sbapp.WebConfiguration;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(WebConfiguration.REST_API + "/post")
|
||||||
|
public class PostController {
|
||||||
|
private final PostService postService;
|
||||||
|
public PostController(PostService postService) {
|
||||||
|
this.postService = postService;
|
||||||
|
}
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
public PostDto getPost(@PathVariable Long id) {
|
||||||
|
return new PostDto(postService.findPost(id));
|
||||||
|
}
|
||||||
|
@GetMapping
|
||||||
|
public List<PostDto> getPosts() {
|
||||||
|
return postService.findAllPosts().stream()
|
||||||
|
.map(PostDto::new)
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
@GetMapping("/{id}/comments")
|
||||||
|
public List<CommentDto> getComments(@PathVariable Long id) {
|
||||||
|
return postService.GetPostComments(id).stream()
|
||||||
|
.map(CommentDto::new)
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
@PostMapping
|
||||||
|
public PostDto createPost(@RequestBody @Valid PostDto postDto){
|
||||||
|
return new PostDto(postService.addPost(postDto));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/{id}")
|
||||||
|
public PostDto updatePost(@PathVariable Long id,
|
||||||
|
@RequestBody @Valid PostDto postDto){
|
||||||
|
return new PostDto(postService.updatePost(id,postDto));
|
||||||
|
}
|
||||||
|
@PostMapping("/{id}/Comment/{userId}")
|
||||||
|
public void addComment(@PathVariable Long id,
|
||||||
|
@PathVariable Long userId,
|
||||||
|
@RequestParam("Text") String Text) {
|
||||||
|
postService.addCommentToPost(id, userId,Text);
|
||||||
|
}
|
||||||
|
@DeleteMapping("/{id}/Comment/{commentId}")
|
||||||
|
public void removeComment(@PathVariable Long id,
|
||||||
|
@PathVariable Long commentId)
|
||||||
|
{
|
||||||
|
postService.removeCommentFromPost(id,commentId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@DeleteMapping("/{id}")
|
||||||
|
public void deletePost(@PathVariable Long id) {
|
||||||
|
postService.deletePost(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping
|
||||||
|
public void deleteall()
|
||||||
|
{
|
||||||
|
postService.deleteAllPosts();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/filteredposts")
|
||||||
|
public List<PostDto> getPostsAndComments(@RequestParam("Text") String Text){
|
||||||
|
return postService.getPostsAndComments(Text).stream()
|
||||||
|
.map(PostDto::new)
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,181 @@
|
|||||||
|
package ru.ulstu.is.sbapp.Post.controller;
|
||||||
|
|
||||||
|
import jakarta.servlet.ServletRegistration;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.validation.BindingResult;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import ru.ulstu.is.sbapp.Comment.model.CommentDto;
|
||||||
|
import ru.ulstu.is.sbapp.Comment.service.CommentService;
|
||||||
|
import ru.ulstu.is.sbapp.Post.model.PostDto;
|
||||||
|
import ru.ulstu.is.sbapp.Post.service.PostService;
|
||||||
|
import ru.ulstu.is.sbapp.User.model.UserDto;
|
||||||
|
import ru.ulstu.is.sbapp.User.service.UserService;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Base64;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/post")
|
||||||
|
public class PostMvcController {
|
||||||
|
private final PostService postService;
|
||||||
|
private final UserService userService;
|
||||||
|
private final CommentService commentService;
|
||||||
|
public PostMvcController(PostService postService,UserService userService,CommentService commentService)
|
||||||
|
{
|
||||||
|
this.postService = postService;
|
||||||
|
this.userService = userService;
|
||||||
|
this.commentService=commentService;
|
||||||
|
}
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
public String getPost(@PathVariable Long id,Model model)
|
||||||
|
{
|
||||||
|
model.addAttribute("post",
|
||||||
|
new PostDto(postService.findPost(id)));
|
||||||
|
model.addAttribute("users",
|
||||||
|
userService.findAllUsers().stream()
|
||||||
|
.map(UserDto::new)
|
||||||
|
.toList());
|
||||||
|
model.addAttribute("comments",
|
||||||
|
postService.GetPostComments(id).stream()
|
||||||
|
.map(CommentDto::new)
|
||||||
|
.toList());
|
||||||
|
return "post-page";
|
||||||
|
}
|
||||||
|
@GetMapping
|
||||||
|
public String getPosts(Model model) {
|
||||||
|
model.addAttribute("posts",
|
||||||
|
postService.findAllPosts().stream()
|
||||||
|
.map(PostDto::new)
|
||||||
|
.toList());
|
||||||
|
model.addAttribute("users",
|
||||||
|
userService.findAllUsers().stream()
|
||||||
|
.map(UserDto::new)
|
||||||
|
.toList());
|
||||||
|
return "post";
|
||||||
|
}
|
||||||
|
@GetMapping("/filter")
|
||||||
|
public String getFileteredPosts(@RequestParam(value = "searchValue") String searchValue,Model model)
|
||||||
|
{
|
||||||
|
model.addAttribute("posts",
|
||||||
|
postService.getPostsAndComments(searchValue).stream()
|
||||||
|
.map(PostDto::new)
|
||||||
|
.toList());
|
||||||
|
model.addAttribute("users",
|
||||||
|
userService.findAllUsers().stream()
|
||||||
|
.map(UserDto::new)
|
||||||
|
.toList());
|
||||||
|
return "post";
|
||||||
|
}
|
||||||
|
@GetMapping(value = {"/edit", "/edit/{id}"})
|
||||||
|
public String editPost(@PathVariable(required = false) Long id,
|
||||||
|
Model model) {
|
||||||
|
if (id == null || id <= 0) {
|
||||||
|
model.addAttribute("postDto", new PostDto());
|
||||||
|
model.addAttribute("users",
|
||||||
|
userService.findAllUsers().stream()
|
||||||
|
.map(UserDto::new)
|
||||||
|
.toList());
|
||||||
|
return "post-create";
|
||||||
|
} else {
|
||||||
|
model.addAttribute("postId", id);
|
||||||
|
model.addAttribute("postDto", new PostDto(postService.findPost(id)));
|
||||||
|
return "post-edit";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(value = {"/user/", "/{id}"})
|
||||||
|
public String savePost(@PathVariable(required = false) Long id,
|
||||||
|
@RequestParam(value = "userId",required = false) Long userId,
|
||||||
|
@RequestParam(value = "multipartFile") MultipartFile multipartFile,
|
||||||
|
@ModelAttribute @Valid PostDto postDto,
|
||||||
|
BindingResult bindingResult,
|
||||||
|
Model model) throws IOException {
|
||||||
|
if (bindingResult.hasErrors()) {
|
||||||
|
model.addAttribute("errors", bindingResult.getAllErrors());
|
||||||
|
return "post-edit";
|
||||||
|
}
|
||||||
|
if (id == null || id <= 0 && userId!=null) {
|
||||||
|
postDto.setImage("data:" + multipartFile.getContentType() + ";base64," + Base64.getEncoder().encodeToString(multipartFile.getBytes()));
|
||||||
|
userService.addNewPost(userId,postDto);
|
||||||
|
} else {
|
||||||
|
postDto.setImage("data:" + multipartFile.getContentType() + ";base64," + Base64.getEncoder().encodeToString(multipartFile.getBytes()));
|
||||||
|
postService.updatePost(id, postDto);
|
||||||
|
}
|
||||||
|
return "redirect:/post";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/delete/{postId}")
|
||||||
|
public String deletePost(
|
||||||
|
@PathVariable Long postId) {
|
||||||
|
postService.deletePost(postId);
|
||||||
|
return "redirect:/post";
|
||||||
|
}
|
||||||
|
@PostMapping("/deleteComment/{postId}/{commentId}")
|
||||||
|
public String deleteComment(@PathVariable Long postId,
|
||||||
|
@PathVariable Long commentId) {
|
||||||
|
postService.removeCommentFromPost(postId,commentId);
|
||||||
|
return "redirect:/post/{postId}";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/userPosts")
|
||||||
|
public String getUserPosts(@RequestParam(value = "userId") Long userId,Model model)
|
||||||
|
{
|
||||||
|
model.addAttribute("posts",
|
||||||
|
userService.GetUserPosts(userId).stream()
|
||||||
|
.map(PostDto::new)
|
||||||
|
.toList());
|
||||||
|
model.addAttribute("users",
|
||||||
|
userService.findAllUsers().stream()
|
||||||
|
.map(UserDto::new)
|
||||||
|
.toList());
|
||||||
|
return "post";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping(value = {"/addComment/{postId}", "/editComment/{id}"})
|
||||||
|
public String editComment(@PathVariable(required = false) Long id,
|
||||||
|
@PathVariable(required = false) Long postId,
|
||||||
|
Model model) {
|
||||||
|
if (id == null || id <= 0) {
|
||||||
|
model.addAttribute("postId", postId);
|
||||||
|
model.addAttribute("users",
|
||||||
|
userService.findAllUsers().stream()
|
||||||
|
.map(UserDto::new)
|
||||||
|
.toList());
|
||||||
|
model.addAttribute("commentDto", new CommentDto());
|
||||||
|
return "comment-create.html";
|
||||||
|
} else {
|
||||||
|
model.addAttribute("id", id);
|
||||||
|
model.addAttribute("commentDto", new CommentDto(commentService.findComment(id)));
|
||||||
|
return "comment-edit";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@PostMapping(value = {"/comment/{postId}/user", "/comment/{id}"})
|
||||||
|
public String saveComment(@PathVariable(required = false) Long id,
|
||||||
|
@RequestParam(value = "userId",required = false) Long userId,
|
||||||
|
@PathVariable(required = false) Long postId,
|
||||||
|
@ModelAttribute @Valid CommentDto commentDto,
|
||||||
|
BindingResult bindingResult,
|
||||||
|
Model model,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
if (bindingResult.hasErrors()) {
|
||||||
|
model.addAttribute("errors", bindingResult.getAllErrors());
|
||||||
|
return "comment-edit";
|
||||||
|
}
|
||||||
|
if (id == null || id <= 0 && userId!=null) {
|
||||||
|
postService.addCommentToPost(postId,userId,commentDto.getText());
|
||||||
|
return "redirect:/post/"+ postId;
|
||||||
|
} else {
|
||||||
|
commentService.updateComment(id, commentDto.getText());
|
||||||
|
return "redirect:/post";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
108
src/main/java/ru/ulstu/is/sbapp/Post/model/Post.java
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
package ru.ulstu.is.sbapp.Post.model;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import ru.ulstu.is.sbapp.Comment.model.Comment;
|
||||||
|
import ru.ulstu.is.sbapp.User.model.User;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
public class Post {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Column
|
||||||
|
@NotBlank(message = "heading cannot be null")
|
||||||
|
private String heading;
|
||||||
|
|
||||||
|
@NotBlank(message = "content cannot be null")
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
@Lob
|
||||||
|
private byte[] image;
|
||||||
|
|
||||||
|
@ManyToOne(fetch = FetchType.EAGER,cascade = CascadeType.MERGE)
|
||||||
|
private User user;
|
||||||
|
|
||||||
|
@OneToMany(mappedBy = "post",fetch = FetchType.EAGER,cascade = {CascadeType.MERGE,CascadeType.REMOVE},orphanRemoval = true)
|
||||||
|
private List<Comment> comments=new ArrayList<>();
|
||||||
|
|
||||||
|
public Post(){}
|
||||||
|
public Post(String Heading, String Content,byte[] image)
|
||||||
|
{
|
||||||
|
this.heading = Heading;
|
||||||
|
this.content = Content;
|
||||||
|
this.image=image;
|
||||||
|
}
|
||||||
|
public Post(PostDto postDto) {
|
||||||
|
this.heading = postDto.getHeading();
|
||||||
|
this.content = postDto.getContent();
|
||||||
|
this.image = postDto.getImage().getBytes();
|
||||||
|
}
|
||||||
|
public Long getId()
|
||||||
|
{
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
public String getHeading()
|
||||||
|
{
|
||||||
|
return heading;
|
||||||
|
}
|
||||||
|
public String getContent()
|
||||||
|
{
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
public void setHeading(String Heading){
|
||||||
|
this.heading =Heading;
|
||||||
|
}
|
||||||
|
public void setContent(String Content)
|
||||||
|
{
|
||||||
|
this.content = Content;
|
||||||
|
}
|
||||||
|
public void setUser(User user) {
|
||||||
|
this.user = user;
|
||||||
|
}
|
||||||
|
public User getUser()
|
||||||
|
{
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
public byte[] getImage() {
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImage(byte[] image) {
|
||||||
|
this.image = image;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteUser() {
|
||||||
|
this.user = null;
|
||||||
|
}
|
||||||
|
public List<Comment> getComments()
|
||||||
|
{
|
||||||
|
return comments;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
Post post = (Post) o;
|
||||||
|
return Objects.equals(id, post.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Post{" +
|
||||||
|
"id=" + id +
|
||||||
|
", heading='" + heading + '\'' +
|
||||||
|
", content ='" + content + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
78
src/main/java/ru/ulstu/is/sbapp/Post/model/PostDto.java
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
package ru.ulstu.is.sbapp.Post.model;
|
||||||
|
|
||||||
|
import ru.ulstu.is.sbapp.Comment.model.CommentDto;
|
||||||
|
import ru.ulstu.is.sbapp.Post.model.Post;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class PostDto {
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String heading;
|
||||||
|
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
private Long userId;
|
||||||
|
private List<CommentDto> comments = new ArrayList<>();
|
||||||
|
private String image;
|
||||||
|
|
||||||
|
|
||||||
|
public PostDto(){}
|
||||||
|
public PostDto(Post post) {
|
||||||
|
this.id = post.getId();
|
||||||
|
this.heading = post.getHeading();
|
||||||
|
this.content = post.getContent();
|
||||||
|
this.image = new String(post.getImage(), StandardCharsets.UTF_8);
|
||||||
|
if (post.getComments() != null) {
|
||||||
|
comments = post.getComments().stream()
|
||||||
|
.map(CommentDto::new).toList();
|
||||||
|
}
|
||||||
|
userId=post.getUser().getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Long getId()
|
||||||
|
{
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
public String getHeading()
|
||||||
|
{
|
||||||
|
return heading;
|
||||||
|
}
|
||||||
|
public String getContent()
|
||||||
|
{
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getUserId(){return userId;}
|
||||||
|
|
||||||
|
public List<CommentDto> getComments()
|
||||||
|
{
|
||||||
|
return comments;
|
||||||
|
}
|
||||||
|
public String getImage() {
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHeading(String Heading)
|
||||||
|
{
|
||||||
|
this.heading=Heading;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContent(String content) {
|
||||||
|
this.content = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setComments(List<CommentDto> comments) {
|
||||||
|
this.comments = comments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImage(String image) {
|
||||||
|
this.image = image;
|
||||||
|
}
|
||||||
|
public void setUserId(Long id){this.userId=id;}
|
||||||
|
|
||||||
|
public void setId(Long id){this.id=id;}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package ru.ulstu.is.sbapp.Post.repository;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Modifying;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import ru.ulstu.is.sbapp.Comment.model.Comment;
|
||||||
|
import ru.ulstu.is.sbapp.Post.model.Post;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public interface PostRepository extends JpaRepository<Post, Long>{
|
||||||
|
@Query("Select c from Comment c where post.id = :id")
|
||||||
|
List<Comment> getPostComments(Long id);
|
||||||
|
|
||||||
|
@Query("Select p from Post p join p.comments c Where p.content Like concat('%', :text, '%') or c.Text Like concat('%', :text, '%')")
|
||||||
|
List<Post> getPostsAndComments(String text);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package ru.ulstu.is.sbapp.Post.service;
|
||||||
|
|
||||||
|
public class PostNotFoundException extends RuntimeException{
|
||||||
|
public PostNotFoundException(Long id) {
|
||||||
|
super(String.format("Post with id [%s] is not found", id));
|
||||||
|
}
|
||||||
|
}
|
||||||
106
src/main/java/ru/ulstu/is/sbapp/Post/service/PostService.java
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
package ru.ulstu.is.sbapp.Post.service;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import ru.ulstu.is.sbapp.Comment.model.Comment;
|
||||||
|
import ru.ulstu.is.sbapp.Comment.service.CommentService;
|
||||||
|
import ru.ulstu.is.sbapp.Post.model.PostDto;
|
||||||
|
import ru.ulstu.is.sbapp.Post.model.Post;
|
||||||
|
import ru.ulstu.is.sbapp.Post.repository.PostRepository;
|
||||||
|
import ru.ulstu.is.sbapp.User.service.UserService;
|
||||||
|
import ru.ulstu.is.sbapp.Util.validation.ValidatorUtil;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class PostService {
|
||||||
|
private final PostRepository postRepository;
|
||||||
|
private final CommentService commentService;
|
||||||
|
private final UserService userService;
|
||||||
|
private final ValidatorUtil validatorUtil;
|
||||||
|
|
||||||
|
public PostService(PostRepository postRepository, CommentService commentService, ValidatorUtil validatorUtil, UserService userService)
|
||||||
|
{
|
||||||
|
this.postRepository=postRepository;
|
||||||
|
this.commentService = commentService;
|
||||||
|
this.validatorUtil=validatorUtil;
|
||||||
|
this.userService = userService;
|
||||||
|
}
|
||||||
|
@Transactional
|
||||||
|
public Post addPost(PostDto postDto) {
|
||||||
|
final Post post = new Post(postDto);
|
||||||
|
validatorUtil.validate(post);
|
||||||
|
return postRepository.save(post);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void savePost(Post post) {
|
||||||
|
postRepository.save(post);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(readOnly = true)
|
||||||
|
public Post findPost(Long id) {
|
||||||
|
final Optional<Post> post = postRepository.findById(id);
|
||||||
|
return post.orElseThrow(() -> new PostNotFoundException(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(readOnly = true)
|
||||||
|
public List<Post> findAllPosts() {
|
||||||
|
return postRepository.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public Post updatePost(Long id, PostDto postDto) {
|
||||||
|
final Post currentPost = findPost(id);
|
||||||
|
currentPost.setHeading(postDto.getHeading());
|
||||||
|
currentPost.setContent(postDto.getContent());
|
||||||
|
currentPost.setImage(postDto.getImage().getBytes(StandardCharsets.UTF_8));
|
||||||
|
validatorUtil.validate(currentPost);
|
||||||
|
return postRepository.save(currentPost);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public List<Comment> GetPostComments(Long id)
|
||||||
|
{
|
||||||
|
return postRepository.getPostComments(id);
|
||||||
|
}
|
||||||
|
@Transactional
|
||||||
|
public void deletePost(Long id) {
|
||||||
|
postRepository.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void deleteAllPosts() {
|
||||||
|
commentService.deleteAllComments();
|
||||||
|
postRepository.deleteAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void addCommentToPost(Long id, Long userId, String text){
|
||||||
|
Optional<Post> optionalPost = postRepository.findById(id);
|
||||||
|
if(optionalPost.isPresent()) {
|
||||||
|
Comment comment = new Comment(text);
|
||||||
|
comment.setPost(optionalPost.get(), userService.findUser(userId));
|
||||||
|
commentService.saveComment(comment);
|
||||||
|
}
|
||||||
|
postRepository.save(optionalPost.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void removeCommentFromPost(Long id, Long commentId){
|
||||||
|
Comment optionalComment = commentService.findComment(commentId);
|
||||||
|
optionalComment.setPost(null, null);
|
||||||
|
Optional <Post> postOptional = postRepository.findById(id);
|
||||||
|
postOptional.get().getComments().remove(optionalComment);
|
||||||
|
commentService.deleteComment(commentId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public List<Post> getPostsAndComments(String text)
|
||||||
|
{
|
||||||
|
return postRepository.getPostsAndComments(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,17 +2,10 @@ package ru.ulstu.is.sbapp;
|
|||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@RestController
|
|
||||||
public class SbappApplication {
|
public class SbappApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(SbappApplication.class, args);
|
SpringApplication.run(SbappApplication.class, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
package ru.ulstu.is.sbapp.User.controller;
|
||||||
|
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import ru.ulstu.is.sbapp.Post.model.PostDto;
|
||||||
|
import ru.ulstu.is.sbapp.User.model.UserDto;
|
||||||
|
import ru.ulstu.is.sbapp.User.service.UserService;
|
||||||
|
import ru.ulstu.is.sbapp.WebConfiguration;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(WebConfiguration.REST_API + "/user")
|
||||||
|
public class UserController {
|
||||||
|
private final UserService userService;
|
||||||
|
public UserController(UserService userService) {
|
||||||
|
this.userService = userService;
|
||||||
|
}
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
public UserDto getUser(@PathVariable Long id) {
|
||||||
|
return new UserDto(userService.findUser(id));
|
||||||
|
}
|
||||||
|
@GetMapping
|
||||||
|
public List<UserDto> getUsers() {
|
||||||
|
return userService.findAllUsers().stream()
|
||||||
|
.map(UserDto::new)
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
@GetMapping("/{id}/posts")
|
||||||
|
public List<PostDto> getPosts(@PathVariable Long id) {
|
||||||
|
return userService.GetUserPosts(id).stream()
|
||||||
|
.map(PostDto::new)
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
@PostMapping
|
||||||
|
public UserDto createUser(@RequestParam("firstName") String firstName,
|
||||||
|
@RequestParam("lastName") String lastname,
|
||||||
|
@RequestParam("email") String email) {
|
||||||
|
return new UserDto(userService.addUser(firstName, lastname,email));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/{id}")
|
||||||
|
public UserDto updateClient(@PathVariable Long id,
|
||||||
|
@RequestParam("firstName") String firstName,
|
||||||
|
@RequestParam("lastName") String lastname,
|
||||||
|
@RequestParam("email") String email){
|
||||||
|
return new UserDto(userService.updateUser(id, firstName, lastname,email));
|
||||||
|
}
|
||||||
|
@PostMapping("/{id}/Post")
|
||||||
|
public void addPost(@PathVariable Long id,
|
||||||
|
@RequestBody @Valid PostDto postDto) {
|
||||||
|
userService.addNewPost(id, postDto);
|
||||||
|
}
|
||||||
|
@DeleteMapping("/{id}/Post/{postId}")
|
||||||
|
public void removePost(@PathVariable Long id,
|
||||||
|
@PathVariable Long postId)
|
||||||
|
{
|
||||||
|
userService.deletePost(id,postId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@DeleteMapping("/{id}")
|
||||||
|
public void deleteUser(@PathVariable Long id) {
|
||||||
|
userService.deleteUser(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
package ru.ulstu.is.sbapp.User.controller;
|
||||||
|
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.validation.BindingResult;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import ru.ulstu.is.sbapp.User.model.UserDto;
|
||||||
|
import ru.ulstu.is.sbapp.User.service.UserService;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/user")
|
||||||
|
public class UserMvcController {
|
||||||
|
private final UserService userService;
|
||||||
|
public UserMvcController(UserService userService)
|
||||||
|
{
|
||||||
|
this.userService=userService;
|
||||||
|
}
|
||||||
|
@GetMapping
|
||||||
|
public String getUsers(Model model) {
|
||||||
|
model.addAttribute("users",
|
||||||
|
userService.findAllUsers().stream()
|
||||||
|
.map(UserDto::new)
|
||||||
|
.toList());
|
||||||
|
return "user";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping(value = {"/edit", "/edit/{id}"})
|
||||||
|
public String editUser(@PathVariable(required = false) Long id,
|
||||||
|
Model model) {
|
||||||
|
if (id == null || id <= 0) {
|
||||||
|
model.addAttribute("userDto", new UserDto());
|
||||||
|
} else {
|
||||||
|
model.addAttribute("userId", id);
|
||||||
|
model.addAttribute("userDto", new UserDto(userService.findUser(id)));
|
||||||
|
}
|
||||||
|
return "user-edit";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(value = {"/", "/{id}"})
|
||||||
|
public String saveUser(@PathVariable(required = false) Long id,
|
||||||
|
@ModelAttribute @Valid UserDto userDto,
|
||||||
|
BindingResult bindingResult,
|
||||||
|
Model model) {
|
||||||
|
if (bindingResult.hasErrors()) {
|
||||||
|
model.addAttribute("errors", bindingResult.getAllErrors());
|
||||||
|
return "user-edit";
|
||||||
|
}
|
||||||
|
if (id == null || id <= 0) {
|
||||||
|
userService.addUser(userDto.getFirstName(), userDto.getLastName(),userDto.getEmail());
|
||||||
|
} else {
|
||||||
|
userService.updateUser(id, userDto.getFirstName(), userDto.getLastName(),userDto.getEmail());
|
||||||
|
}
|
||||||
|
return "redirect:/user";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/delete/{id}")
|
||||||
|
public String deleteUser(@PathVariable Long id) {
|
||||||
|
userService.deleteUser(id);
|
||||||
|
return "redirect:/user";
|
||||||
|
}
|
||||||
|
}
|
||||||
107
src/main/java/ru/ulstu/is/sbapp/User/model/User.java
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
package ru.ulstu.is.sbapp.User.model;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import ru.ulstu.is.sbapp.Comment.model.Comment;
|
||||||
|
import ru.ulstu.is.sbapp.Post.model.Post;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name="tab_user")
|
||||||
|
public class User {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
@Column()
|
||||||
|
@NotBlank(message = "firstName cannot be null")
|
||||||
|
private String firstName;
|
||||||
|
@NotBlank(message = "lastName cannot be null")
|
||||||
|
private String lastName;
|
||||||
|
|
||||||
|
@NotBlank(message = "email cannot be null")
|
||||||
|
private String email;
|
||||||
|
|
||||||
|
@OneToMany(mappedBy ="user",cascade = {CascadeType.MERGE,CascadeType.REMOVE},fetch = FetchType.EAGER)
|
||||||
|
private List<Post> posts =new ArrayList<>();
|
||||||
|
|
||||||
|
@OneToMany(mappedBy ="user",cascade = {CascadeType.MERGE,CascadeType.REMOVE},fetch = FetchType.EAGER)
|
||||||
|
private List<Comment> comments =new ArrayList<>();
|
||||||
|
|
||||||
|
public User() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public User(String firstName, String lastName, String email) {
|
||||||
|
this.firstName = firstName;
|
||||||
|
this.lastName = lastName;
|
||||||
|
this.email=email;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFirstName() {
|
||||||
|
return firstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFirstName(String firstName) {
|
||||||
|
this.firstName = firstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLastName() {
|
||||||
|
return lastName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastName(String lastName) {
|
||||||
|
this.lastName = lastName;
|
||||||
|
}
|
||||||
|
public List<Post> getPosts()
|
||||||
|
{
|
||||||
|
return posts;
|
||||||
|
}
|
||||||
|
public List<Comment> getComments()
|
||||||
|
{
|
||||||
|
return comments;
|
||||||
|
}
|
||||||
|
public void addNewPost(Post post) {
|
||||||
|
posts.add(post);
|
||||||
|
post.setUser(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmail()
|
||||||
|
{
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
public void setEmail(String email){
|
||||||
|
this.email=email;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
User user = (User) o;
|
||||||
|
return Objects.equals(id, user.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Client{" +
|
||||||
|
"id=" + id +
|
||||||
|
", firstName='" + firstName + '\'' +
|
||||||
|
", lastName='" + lastName + '\'' +
|
||||||
|
", email='" + email + '\'' +
|
||||||
|
", posts=" + posts +'\''+
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
79
src/main/java/ru/ulstu/is/sbapp/User/model/UserDto.java
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
package ru.ulstu.is.sbapp.User.model;
|
||||||
|
|
||||||
|
import ru.ulstu.is.sbapp.Comment.model.Comment;
|
||||||
|
import ru.ulstu.is.sbapp.Post.model.Post;
|
||||||
|
import ru.ulstu.is.sbapp.User.model.User;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class UserDto {
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String firstName;
|
||||||
|
|
||||||
|
private String lastName;
|
||||||
|
|
||||||
|
private String email;
|
||||||
|
|
||||||
|
private List<Post> posts = new ArrayList<>();
|
||||||
|
|
||||||
|
private List<Comment> comments = new ArrayList<>();
|
||||||
|
|
||||||
|
public UserDto(){}
|
||||||
|
public UserDto(User user) {
|
||||||
|
this.id=user.getId();
|
||||||
|
this.firstName = user.getFirstName();
|
||||||
|
this.lastName = user.getLastName();
|
||||||
|
this.email= user.getEmail();
|
||||||
|
}
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFirstName() {
|
||||||
|
return firstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLastName() {
|
||||||
|
return lastName;
|
||||||
|
}
|
||||||
|
public List<Post> getPosts()
|
||||||
|
{
|
||||||
|
return posts;
|
||||||
|
}
|
||||||
|
public List<Comment> getComments()
|
||||||
|
{
|
||||||
|
return comments;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getEmail()
|
||||||
|
{
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
public void setEmail(String email)
|
||||||
|
{
|
||||||
|
this.email=email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFirstName(String firstName) {
|
||||||
|
this.firstName = firstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastName(String lastName) {
|
||||||
|
this.lastName = lastName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setComments(List<Comment> comments) {
|
||||||
|
this.comments = comments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPosts(List<Post> posts) {
|
||||||
|
this.posts = posts;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package ru.ulstu.is.sbapp.User.repository;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Modifying;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import ru.ulstu.is.sbapp.Post.model.Post;
|
||||||
|
import ru.ulstu.is.sbapp.User.model.User;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface UserRepository extends JpaRepository<User, Long> {
|
||||||
|
@Query("Select p from Post p where user.id = :id")
|
||||||
|
List<Post> getUsersPosts(Long id);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package ru.ulstu.is.sbapp.User.service;
|
||||||
|
|
||||||
|
public class UserNotFoundException extends RuntimeException{
|
||||||
|
public UserNotFoundException(Long id) {
|
||||||
|
super(String.format("User with id [%s] is not found", id));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
package ru.ulstu.is.sbapp.User.service;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import ru.ulstu.is.sbapp.Comment.service.CommentService;
|
||||||
|
import ru.ulstu.is.sbapp.Post.model.PostDto;
|
||||||
|
import ru.ulstu.is.sbapp.Post.model.Post;
|
||||||
|
import ru.ulstu.is.sbapp.Post.repository.PostRepository;
|
||||||
|
import ru.ulstu.is.sbapp.User.model.User;
|
||||||
|
|
||||||
|
import ru.ulstu.is.sbapp.User.repository.UserRepository;
|
||||||
|
import ru.ulstu.is.sbapp.Util.validation.ValidatorUtil;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class UserService {
|
||||||
|
|
||||||
|
private final UserRepository userRepository;
|
||||||
|
|
||||||
|
private final PostRepository postRepository;
|
||||||
|
|
||||||
|
private final CommentService commentService;
|
||||||
|
private final ValidatorUtil validatorUtil;
|
||||||
|
|
||||||
|
public UserService(UserRepository userRepository, ValidatorUtil validatorUtil, PostRepository postRepository, CommentService commentService)
|
||||||
|
{
|
||||||
|
this.userRepository=userRepository;
|
||||||
|
this.validatorUtil=validatorUtil;
|
||||||
|
this.postRepository = postRepository;
|
||||||
|
this.commentService = commentService;
|
||||||
|
}
|
||||||
|
@Transactional
|
||||||
|
public User addUser(String firstName, String lastName, String email) {
|
||||||
|
final User user = new User(firstName, lastName, email);
|
||||||
|
validatorUtil.validate(user);
|
||||||
|
return userRepository.save(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public User findUser(Long id) {
|
||||||
|
final Optional<User> user = userRepository.findById(id);
|
||||||
|
return user.orElseThrow(() -> new UserNotFoundException(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(readOnly = true)
|
||||||
|
public List<User> findAllUsers() {
|
||||||
|
return userRepository.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public User updateUser(Long id, String firstName, String lastName, String email) {
|
||||||
|
final User currentUser = findUser(id);
|
||||||
|
currentUser.setFirstName(firstName);
|
||||||
|
currentUser.setLastName(lastName);
|
||||||
|
currentUser.setEmail(email);
|
||||||
|
validatorUtil.validate(currentUser);
|
||||||
|
return userRepository.save(currentUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void deleteUser(Long id) {
|
||||||
|
userRepository.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void addNewPost(Long id, PostDto postDto)
|
||||||
|
{
|
||||||
|
Optional<User> currentUser = userRepository.findById(id);
|
||||||
|
if(currentUser.isPresent())
|
||||||
|
{
|
||||||
|
Post post = new Post(postDto);
|
||||||
|
post.setUser(currentUser.get());
|
||||||
|
postRepository.save(post);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Transactional
|
||||||
|
public void deleteAllUsers() {
|
||||||
|
commentService.deleteAllComments();
|
||||||
|
userRepository.deleteAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public List<Post> GetUserPosts(Long id)
|
||||||
|
{
|
||||||
|
return userRepository.getUsersPosts(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void deletePost(Long id, Long postId) {
|
||||||
|
postRepository.deleteById(postId);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package ru.ulstu.is.sbapp.Util.error;
|
||||||
|
|
||||||
|
import org.springframework.context.support.DefaultMessageSourceResolvable;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||||
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||||
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
|
import ru.ulstu.is.sbapp.Comment.service.CommentNotFoundException;
|
||||||
|
import ru.ulstu.is.sbapp.Post.service.PostNotFoundException;
|
||||||
|
import ru.ulstu.is.sbapp.User.service.UserNotFoundException;
|
||||||
|
import ru.ulstu.is.sbapp.Util.validation.ValidationException;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@ControllerAdvice
|
||||||
|
public class AdviceController {
|
||||||
|
@ExceptionHandler({
|
||||||
|
CommentNotFoundException.class,
|
||||||
|
UserNotFoundException.class,
|
||||||
|
PostNotFoundException.class,
|
||||||
|
ValidationException.class
|
||||||
|
})
|
||||||
|
public ResponseEntity<Object> handleException(Throwable e) {
|
||||||
|
return new ResponseEntity<>(e.getMessage(), HttpStatus.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||||
|
public ResponseEntity<Object> handleBindException(MethodArgumentNotValidException e) {
|
||||||
|
final ValidationException validationException = new ValidationException(
|
||||||
|
e.getBindingResult().getAllErrors().stream()
|
||||||
|
.map(DefaultMessageSourceResolvable::getDefaultMessage)
|
||||||
|
.collect(Collectors.toSet()));
|
||||||
|
return handleException(validationException);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ExceptionHandler(Exception.class)
|
||||||
|
public ResponseEntity<Object> handleUnknownException(Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package ru.ulstu.is.sbapp.Util.validation;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class ValidationException extends RuntimeException {
|
||||||
|
public ValidationException(Set<String> errors) {
|
||||||
|
super(String.join("\n", errors));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package ru.ulstu.is.sbapp.Util.validation;
|
||||||
|
|
||||||
|
import jakarta.validation.ConstraintViolation;
|
||||||
|
import jakarta.validation.Validation;
|
||||||
|
import jakarta.validation.Validator;
|
||||||
|
import jakarta.validation.ValidatorFactory;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class ValidatorUtil {
|
||||||
|
private final Validator validator;
|
||||||
|
|
||||||
|
public ValidatorUtil() {
|
||||||
|
try (ValidatorFactory factory = Validation.buildDefaultValidatorFactory()) {
|
||||||
|
this.validator = factory.getValidator();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> void validate(T object) {
|
||||||
|
final Set<ConstraintViolation<T>> errors = validator.validate(object);
|
||||||
|
if (!errors.isEmpty()) {
|
||||||
|
throw new ValidationException(errors.stream()
|
||||||
|
.map(ConstraintViolation::getMessage)
|
||||||
|
.collect(Collectors.toSet()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,12 +2,20 @@ package ru.ulstu.is.sbapp;
|
|||||||
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
@Configuration
|
@Configuration
|
||||||
public class WebConfiguration implements WebMvcConfigurer {
|
public class WebConfiguration implements WebMvcConfigurer {
|
||||||
|
public static final String REST_API = "/api";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addCorsMappings(CorsRegistry registry)
|
public void addViewControllers(ViewControllerRegistry registry) {
|
||||||
{
|
WebMvcConfigurer.super.addViewControllers(registry);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addCorsMappings(CorsRegistry registry) {
|
||||||
registry.addMapping("/**").allowedMethods("*");
|
registry.addMapping("/**").allowedMethods("*");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,52 +0,0 @@
|
|||||||
package ru.ulstu.is.sbapp.speaker.controller;
|
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import ru.ulstu.is.sbapp.speaker.service.MethodService;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
public class UserController {
|
|
||||||
private final MethodService methodService;
|
|
||||||
public UserController(MethodService methodService)
|
|
||||||
{
|
|
||||||
this.methodService=methodService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/sum")
|
|
||||||
public String sum(@RequestParam(value = "firstObj",defaultValue = "0") String firstObj,
|
|
||||||
@RequestParam(value = "secondObj",defaultValue = "0") String secondObj,
|
|
||||||
@RequestParam(value = "type",defaultValue = "int")String type)
|
|
||||||
{
|
|
||||||
Object a = firstObj;
|
|
||||||
Object b = secondObj;
|
|
||||||
return methodService.Sum(a,b,type);
|
|
||||||
}
|
|
||||||
@GetMapping("/dif")
|
|
||||||
public String dif(@RequestParam(value = "firstObj",defaultValue = "0") String firstObj,
|
|
||||||
@RequestParam(value = "secondObj",defaultValue = "0") String secondObj,
|
|
||||||
@RequestParam(value = "type",defaultValue = "int")String type)
|
|
||||||
{
|
|
||||||
Object a = firstObj;
|
|
||||||
Object b = secondObj;
|
|
||||||
return methodService.Dif(a,b,type);
|
|
||||||
}
|
|
||||||
@GetMapping("/com")
|
|
||||||
public String com(@RequestParam(value = "firstObj",defaultValue = "0") String firstObj,
|
|
||||||
@RequestParam(value = "secondObj",defaultValue = "0") String secondObj,
|
|
||||||
@RequestParam(value = "type",defaultValue = "int")String type)
|
|
||||||
{
|
|
||||||
Object a = firstObj;
|
|
||||||
Object b = secondObj;
|
|
||||||
return methodService.Com(a,b,type);
|
|
||||||
}
|
|
||||||
@GetMapping("/div")
|
|
||||||
public String div(@RequestParam(value = "firstObj",defaultValue = "0") String firstObj,
|
|
||||||
@RequestParam(value = "secondObj",defaultValue = "0") String secondObj,
|
|
||||||
@RequestParam(value = "type",defaultValue = "int")String type)
|
|
||||||
{
|
|
||||||
Object a = firstObj;
|
|
||||||
Object b = secondObj;
|
|
||||||
return methodService.Div(a,b,type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package ru.ulstu.is.sbapp.speaker.domain;
|
|
||||||
|
|
||||||
public interface IMethods<T> {
|
|
||||||
T Sum(T firstObj,T secondObj);
|
|
||||||
T Dif (T firstObj, T secondObj);
|
|
||||||
T Com(T firstObj,T secondObj);
|
|
||||||
T Div (T firstObj, T secondObj);
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
package ru.ulstu.is.sbapp.speaker.domain;
|
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
@Component(value = "int")
|
|
||||||
public class MethodInteger implements IMethods<Integer> {
|
|
||||||
@Override
|
|
||||||
public Integer Sum(Integer firstObj, Integer secondObj) {
|
|
||||||
return firstObj + secondObj;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public Integer Dif(Integer firstObj, Integer secondObj) {
|
|
||||||
return firstObj -secondObj;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public Integer Com(Integer firstObj, Integer secondObj) {
|
|
||||||
return firstObj * secondObj;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public Integer Div(Integer firstObj, Integer secondObj) {
|
|
||||||
int num = secondObj;
|
|
||||||
if (num == 0){
|
|
||||||
return null;
|
|
||||||
}else{
|
|
||||||
return firstObj / num;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
package ru.ulstu.is.sbapp.speaker.domain;
|
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
@Component(value = "string")
|
|
||||||
public class MethodString implements IMethods<String> {
|
|
||||||
@Override
|
|
||||||
public String Sum(String firstObj,String secondObj)
|
|
||||||
{
|
|
||||||
return firstObj.concat(secondObj);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public String Dif(String firstObj,String secondObj)
|
|
||||||
{
|
|
||||||
if(firstObj.contains(secondObj))
|
|
||||||
{
|
|
||||||
return firstObj.replace(secondObj,"");
|
|
||||||
}
|
|
||||||
return (firstObj);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public String Com(String firstObj,String secondObj)
|
|
||||||
{
|
|
||||||
String res = (firstObj);
|
|
||||||
for (int i = 0; i < (secondObj).length(); i++) {
|
|
||||||
res = Sum(res, firstObj);
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public String Div(String firstObj,String secondObj)
|
|
||||||
{
|
|
||||||
if (firstObj.contains(secondObj)){
|
|
||||||
return "true";
|
|
||||||
}else{
|
|
||||||
return "false";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
package ru.ulstu.is.sbapp.speaker.service;
|
|
||||||
|
|
||||||
import org.springframework.context.ApplicationContext;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import ru.ulstu.is.sbapp.speaker.domain.IMethods;
|
|
||||||
import ru.ulstu.is.sbapp.speaker.domain.MethodInteger;
|
|
||||||
import ru.ulstu.is.sbapp.speaker.domain.MethodString;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class MethodService {
|
|
||||||
private final ApplicationContext applicationContext;
|
|
||||||
public MethodService(ApplicationContext applicationContext)
|
|
||||||
{
|
|
||||||
this.applicationContext=applicationContext;
|
|
||||||
}
|
|
||||||
public String Sum(Object firstObj,Object secondObj,String type)
|
|
||||||
{
|
|
||||||
final IMethods method=(IMethods) applicationContext.getBean(type);
|
|
||||||
if (method instanceof MethodString){
|
|
||||||
return String.format("%s", method.Sum(firstObj,secondObj));
|
|
||||||
}else{
|
|
||||||
return String.format("%s", method.Sum(Integer.parseInt(firstObj.toString()),Integer.parseInt(secondObj.toString())));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public String Com(Object firstObj,Object secondObj,String type)
|
|
||||||
{
|
|
||||||
final IMethods method=(IMethods) applicationContext.getBean(type);
|
|
||||||
if (method instanceof MethodString){
|
|
||||||
return String.format("%s", method.Com(firstObj,secondObj));
|
|
||||||
}else{
|
|
||||||
return String.format("%s", method.Com(Integer.parseInt(firstObj.toString()),Integer.parseInt(secondObj.toString())));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public String Dif(Object firstObj,Object secondObj,String type)
|
|
||||||
{
|
|
||||||
final IMethods method=(IMethods) applicationContext.getBean(type);
|
|
||||||
if (method instanceof MethodString){
|
|
||||||
return String.format("%s", method.Dif(firstObj,secondObj));
|
|
||||||
}else{
|
|
||||||
return String.format("%s", method.Dif(Integer.parseInt(firstObj.toString()),Integer.parseInt(secondObj.toString())));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public String Div(Object firstObj,Object secondObj,String type)
|
|
||||||
{
|
|
||||||
final IMethods method=(IMethods) applicationContext.getBean(type);
|
|
||||||
if (method instanceof MethodString){
|
|
||||||
return String.format("%s", method.Div(firstObj,secondObj));
|
|
||||||
}else{
|
|
||||||
return String.format("%s", method.Div(Integer.parseInt(firstObj.toString()),Integer.parseInt(secondObj.toString())));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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
|
||||||
|
|||||||
1
src/main/resources/public/favicon.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Pro 6.2.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. --><path d="M96 0C43 0 0 43 0 96V416c0 53 43 96 96 96H384h32c17.7 0 32-14.3 32-32s-14.3-32-32-32V384c17.7 0 32-14.3 32-32V32c0-17.7-14.3-32-32-32H384 96zm0 384H352v64H96c-17.7 0-32-14.3-32-32s14.3-32 32-32zm32-240c0-8.8 7.2-16 16-16H336c8.8 0 16 7.2 16 16s-7.2 16-16 16H144c-8.8 0-16-7.2-16-16zm16 48H336c8.8 0 16 7.2 16 16s-7.2 16-16 16H144c-8.8 0-16-7.2-16-16s7.2-16 16-16z"/></svg>
|
||||||
|
After Width: | Height: | Size: 611 B |
BIN
src/main/resources/public/img/Emblema.png
Normal file
|
After Width: | Height: | Size: 77 KiB |
146
src/main/resources/public/style.css
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
html
|
||||||
|
{
|
||||||
|
min-height: 100vh;
|
||||||
|
}
|
||||||
|
header .img-fluid
|
||||||
|
{
|
||||||
|
width:232px;
|
||||||
|
height:100px;
|
||||||
|
}
|
||||||
|
|
||||||
|
article .img-fluid
|
||||||
|
{
|
||||||
|
height:250px;
|
||||||
|
}
|
||||||
|
article .img-fluid1
|
||||||
|
{
|
||||||
|
height:100%;
|
||||||
|
width: 96%;
|
||||||
|
}
|
||||||
|
.owl
|
||||||
|
{
|
||||||
|
width:300px;
|
||||||
|
}
|
||||||
|
.pdf-size
|
||||||
|
{
|
||||||
|
width:70px;
|
||||||
|
}
|
||||||
|
body
|
||||||
|
{
|
||||||
|
min-height: 100vh;
|
||||||
|
}
|
||||||
|
.body_app
|
||||||
|
{
|
||||||
|
display: grid;
|
||||||
|
grid-template-rows:auto 1fr auto;
|
||||||
|
min-height: 100vh;
|
||||||
|
}
|
||||||
|
.lp
|
||||||
|
{
|
||||||
|
padding-left: 30px;
|
||||||
|
}
|
||||||
|
.img-school
|
||||||
|
{
|
||||||
|
margin-right: 1em;
|
||||||
|
float: start;
|
||||||
|
|
||||||
|
}
|
||||||
|
.Vnov
|
||||||
|
{
|
||||||
|
margin-right: 1em;
|
||||||
|
}
|
||||||
|
.Vnov1
|
||||||
|
{
|
||||||
|
margin-right: 1em;
|
||||||
|
}
|
||||||
|
.Cont
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@media only screen and (max-width: 800px) {
|
||||||
|
.owl {
|
||||||
|
display:none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media only screen and (max-width: 1164px) {
|
||||||
|
.img-school
|
||||||
|
{
|
||||||
|
margin-right: 170px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media only screen and (max-width: 554px) {
|
||||||
|
.img-school
|
||||||
|
{
|
||||||
|
height: 20% !important;
|
||||||
|
width: 75%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media only screen and (max-width: 727px) {
|
||||||
|
.headers-problem
|
||||||
|
{
|
||||||
|
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
.navbar
|
||||||
|
{
|
||||||
|
align-items: flex-start !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@media only screen and (max-width: 959px) {
|
||||||
|
.navbar
|
||||||
|
{
|
||||||
|
float:left !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media only screen and (max-width: 463px) {
|
||||||
|
.Vnov
|
||||||
|
{
|
||||||
|
margin-right: 140px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media only screen and (max-width: 575px) {
|
||||||
|
.Vnov1
|
||||||
|
{
|
||||||
|
margin-right: 200px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media only screen and (max-width: 585px) {
|
||||||
|
.Cont
|
||||||
|
{
|
||||||
|
margin-right: 200px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#banner {
|
||||||
|
margin: 15px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
#banner img {
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#banner img.show {
|
||||||
|
height: 40%;
|
||||||
|
width: 60%;
|
||||||
|
opacity: 1;
|
||||||
|
transition: opacity 1s, visibility 0s;
|
||||||
|
}
|
||||||
|
|
||||||
|
#banner img.hide {
|
||||||
|
height: 0;
|
||||||
|
width: 0;
|
||||||
|
opacity: 0;
|
||||||
|
visibility: hidden;
|
||||||
|
transition: opacity 1s, visibility 0s 1s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Pole_height
|
||||||
|
{
|
||||||
|
height: 80px;
|
||||||
|
}
|
||||||
35
src/main/resources/templates/comment-create.html
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en"
|
||||||
|
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||||
|
layout:decorate="~{default}" xmlns:th="http://www.w3.org/1999/xhtml">
|
||||||
|
<head>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div layout:fragment="content">
|
||||||
|
<div class="mx-auto my-3">
|
||||||
|
<div th:text="${errors}" class="margin-bottom alert-danger"></div>
|
||||||
|
<form action="#" th:action="@{'/post/comment/' + ${postId} + '/user'}" th:object="${commentDto}" method="post">
|
||||||
|
<div class="mb-3 my-2">
|
||||||
|
<label for="selectBox" class="form-label">Пользователь</label>
|
||||||
|
<select th:name="userId" id="selectBox" class="form-select">
|
||||||
|
<option th:each="value: ${users}" th:selected="${selectBox} == ${value}" th:value="${value.id}">
|
||||||
|
<span th:text="${value.firstName}"></span>
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<div>
|
||||||
|
<input class="form-control" id="commentText" th:field="${commentDto.text}" type="text" defaultValue="" required/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<button type="submit" class="btn btn-primary button-fixed">
|
||||||
|
Добавить
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
27
src/main/resources/templates/comment-edit.html
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en"
|
||||||
|
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||||
|
layout:decorate="~{default}" xmlns:th="http://www.w3.org/1999/xhtml">
|
||||||
|
<head>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div layout:fragment="content">
|
||||||
|
<div class="mx-auto my-3">
|
||||||
|
<div th:text="${errors}" class="margin-bottom alert-danger"></div>
|
||||||
|
<form action="#" th:action="@{/post/comment/{id}(id=${id})}" th:object="${commentDto}" method="post">
|
||||||
|
<div class="mb-3">
|
||||||
|
<div>
|
||||||
|
<input class="form-control" id="commentText" th:field="${commentDto.text}" type="text" defaultValue="" required/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<button type="submit" class="btn btn-primary button-fixed">
|
||||||
|
Обновить
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
45
src/main/resources/templates/default.html
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
<html lang="ru"
|
||||||
|
xmlns:th="http://www.thymeleaf.org"
|
||||||
|
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8"/>
|
||||||
|
<title>Школа</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||||
|
<link rel="icon" href="/favicon.svg">
|
||||||
|
<script type="text/javascript" src="/webjars/bootstrap/5.1.3/js/bootstrap.bundle.min.js"></script>
|
||||||
|
<link rel="stylesheet" href="/webjars/bootstrap/5.1.3/css/bootstrap.min.css"/>
|
||||||
|
<link rel="stylesheet" href="/webjars/font-awesome/6.1.0/css/all.min.css"/>
|
||||||
|
<link rel="stylesheet" href="/style.css"/>
|
||||||
|
</head>
|
||||||
|
<body class="body_app">
|
||||||
|
<header class="fs-4 fw-bold p-1 text-white bg-primary bg-gradient">
|
||||||
|
<div><img class="img-fluid float-start" src="/img/Emblema.png" alt="Emblema"/>
|
||||||
|
<p class="fs-5 Cont">Муниципальное бюджетное общеобразовательное учреждение средняя общеобразовательная школа №10</p>
|
||||||
|
</div>
|
||||||
|
<nav class="navbar navbar-expand-md navbar-dark">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation"> <span className="navbar-toggler-icon"></span></button>
|
||||||
|
<nav class="headers-problem navbar navbar-expand-lg d-flex">
|
||||||
|
<button class="navbar-toggler" type="button"
|
||||||
|
data-bs-toggle="collapse" data-bs-target="#navbarNav"
|
||||||
|
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<div class="collapse navbar-collapse" id="navbarNav">
|
||||||
|
<ul class="navbar-nav">
|
||||||
|
<a class="btn btn-outline-light mx-1" href="/user"> Авторизация </a>
|
||||||
|
<a class="btn btn-outline-light mx-1" href="/post">Новости</a>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
<div class="d-flex text-white bg-info bg-gradient fw-bold">
|
||||||
|
<div class="container container-padding" layout:fragment="content">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
<th:block layout:fragment="scripts">
|
||||||
|
</th:block>
|
||||||
|
</html>
|
||||||
13
src/main/resources/templates/error.html
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en"
|
||||||
|
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||||
|
layout:decorate="~{default}" xmlns:th="http://www.w3.org/1999/xhtml">
|
||||||
|
<head>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div layout:fragment="content">
|
||||||
|
<div><span th:text="${error}"></span></div>
|
||||||
|
<a href="/">На главную</a>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
42
src/main/resources/templates/post-create.html
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en"
|
||||||
|
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||||
|
layout:decorate="~{default}" xmlns:th="http://www.w3.org/1999/xhtml">
|
||||||
|
<head>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div layout:fragment="content">
|
||||||
|
<div th:text="${errors}" class="margin-bottom alert-danger"></div>
|
||||||
|
<form action="#" th:action="@{/post/user/}" th:object="${postDto}" method="post" enctype="multipart/form-data">
|
||||||
|
<div class="mb-3 my-2">
|
||||||
|
<label for="selectBox" class="form-label">Пользователь</label>
|
||||||
|
<select th:name="userId" id="selectBox" class="form-select">
|
||||||
|
<option th:each="value: ${users}" th:selected="${selectBox} == ${value}" th:value="${value.id}">
|
||||||
|
<span th:text="${value.firstName}"></span>
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="image" class="form-label">Картинка</label>
|
||||||
|
<input type="file" th:name="multipartFile" class="form-control" id="image" required="true">
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="heading" class="form-label">Заголовок</label>
|
||||||
|
<input type="text" class="form-control" id="heading" th:field="${postDto.heading}" required="true">
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="content" class="form-label">Содержание</label>
|
||||||
|
<input type="text" class="form-control" id="content" th:field="${postDto.content}" required="true">
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<button type="submit" class="btn btn-primary button-fixed">
|
||||||
|
<span>Добавить</span>
|
||||||
|
</button>
|
||||||
|
<a class="btn btn-secondary button-fixed" th:href="@{/post}">
|
||||||
|
Назад
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
34
src/main/resources/templates/post-edit.html
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en"
|
||||||
|
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||||
|
layout:decorate="~{default}" xmlns:th="http://www.w3.org/1999/xhtml">
|
||||||
|
<head>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div layout:fragment="content">
|
||||||
|
<div th:text="${errors}" class="margin-bottom alert-danger"></div>
|
||||||
|
<form action="#" th:action="@{/post/{id}(id=${id})}" th:object="${postDto}" method="post" enctype="multipart/form-data">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="image" class="form-label">Картинка</label>
|
||||||
|
<input type="file" th:name="multipartFile" class="form-control" id="image" required="true">
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="heading" class="form-label">Заголовок</label>
|
||||||
|
<input type="text" class="form-control" id="heading" th:field="${postDto.heading}" required="true">
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="content" class="form-label">Содержание</label>
|
||||||
|
<input type="text" class="form-control" id="content" th:field="${postDto.content}" required="true">
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<button type="submit" class="btn btn-primary button-fixed">
|
||||||
|
<span th:if="${id != null}">Обновить</span>
|
||||||
|
</button>
|
||||||
|
<a class="btn btn-secondary button-fixed" th:href="@{/post}">
|
||||||
|
Назад
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
68
src/main/resources/templates/post-page.html
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en"
|
||||||
|
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||||
|
layout:decorate="~{default}" xmlns:th="http://www.w3.org/1999/xhtml">
|
||||||
|
<head>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div layout:fragment="content">
|
||||||
|
<div class="da d-flex my-2">
|
||||||
|
<div><img class="imga img-fluid float-start mx-2" style="width:500px;height:300px" th:src="${post.image}"/></div>
|
||||||
|
<div class="container-fluid my-2 mx-1">
|
||||||
|
<h1 th:text="${post.heading}"></h1>
|
||||||
|
<p>[[${post.content}]]</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!--Вот тут кнопка для добавления комментариев (для будущего тебя)-->
|
||||||
|
<a class="btn btn-outline-primary text-center mx-2"
|
||||||
|
th:href="@{/post/addComment/{postId}(postId=${post.id})}">
|
||||||
|
+
|
||||||
|
</a>
|
||||||
|
<div className="d-flex mx-2">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">#</th>
|
||||||
|
<th scope="col">Пользователь</th>
|
||||||
|
<th scope="col">Содержимое</th>
|
||||||
|
<th scope="col"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr th:each="comment, iterator: ${comments}">
|
||||||
|
<th scope="row" th:text="${iterator.index} + 1"/>
|
||||||
|
<td th:text="${comment.user}" style="width: 60%"/>
|
||||||
|
<td th:text="${comment.text}" style="width: 60%"/>
|
||||||
|
<td style="width: 10%">
|
||||||
|
<div class="btn-group" role="group" aria-label="Basic example">
|
||||||
|
<!--НУЖНО СДЕЛАТЬ!!!-->
|
||||||
|
<a class="btn btn-outline-light text-center mx-2" th:href="@{/post/editComment/{id}(id=${comment.id})}">
|
||||||
|
<i class="fa fa-pencil" aria-hidden="true"></i> Изменить
|
||||||
|
</a>
|
||||||
|
<button type="button" class="btn btn-outline-light text-center mx-2"
|
||||||
|
th:attr="onclick=|confirm('Удалить запись?') && document.getElementById('remove-${comment.id}').click()|">
|
||||||
|
<i class="fa fa-trash" aria-hidden="true"></i> Удалить
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<form th:action="@{'/post/deleteComment/' + ${comment.postId} + '/' + ${comment.id}}" method="post">
|
||||||
|
<button th:id="'remove-' + ${comment.id}" type="submit" style="display: none">
|
||||||
|
Удалить
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
<th:block layout:fragment="scripts">
|
||||||
|
<script>
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</th:block>
|
||||||
|
</html>
|
||||||
99
src/main/resources/templates/post.html
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en"
|
||||||
|
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||||
|
layout:decorate="~{default}" xmlns:th="http://www.w3.org/1999/xhtml">
|
||||||
|
<head>
|
||||||
|
<script type="text/javascript" src="/webjars/jquery/3.6.0/jquery.min.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div layout:fragment="content">
|
||||||
|
<div class="d-flex float-start my-1">
|
||||||
|
<form th:action="@{/post/filter}" class="d-flex">
|
||||||
|
<div class="mx-3"><input type="text" th:name="searchValue" id="search" class="form-control" required /></div>
|
||||||
|
<button type="submit" class="btn btn-outline-primary text-center mx-2">
|
||||||
|
<i class="fa-solid fa-magnifying-glass"></i>
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
<form th:action="@{/post/userPosts}" id="myForm" class="d-flex">
|
||||||
|
<div class="mx-3">
|
||||||
|
<select id="selectBox" th:name="userId">
|
||||||
|
<option value="" disabled selected>Select your option</option>
|
||||||
|
<option th:each="value: ${users}" th:selected="${selectBox} == ${value}" th:text="${value.firstName}" th:value="${value.Id}">
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<div>
|
||||||
|
<a class="btn btn-outline-primary text-center mx-2"
|
||||||
|
th:href="@{/post/edit}">
|
||||||
|
<!--Сам понимаешь что здесь надо сделать-->
|
||||||
|
+
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="my-5">
|
||||||
|
<!--здесь тоже надо сделать нормальный вывод-->
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div th:each="post, iterator: ${posts}" class="card border-dark mb-3 d-flex flex-row text-black justify-content-between">
|
||||||
|
<div>
|
||||||
|
<img class="col" style="width:300px;height:200px" th:src="${post.image}"/>
|
||||||
|
</div>
|
||||||
|
<div class="d-flex flex-grow-1 flex-column">
|
||||||
|
<div class="flex-grow-1 mx-2">
|
||||||
|
<h th:text="${post.heading}"></h>
|
||||||
|
</div>
|
||||||
|
<div class="flex-grow-1 mx-2">
|
||||||
|
<p th:text="${post.content}"></p>
|
||||||
|
</div>
|
||||||
|
<div class="flex-grow-1 mx-2">
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">#</th>
|
||||||
|
<th scope="col">Пользователь</th>
|
||||||
|
<th scope="col">Текст</th>
|
||||||
|
<th scope="col"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr th:each="comment, iterator: ${post.comments}">
|
||||||
|
<th scope="row" th:text="${iterator.index} + 1"/>
|
||||||
|
<td th:text="${comment.user}" style="width: 60%"/>
|
||||||
|
<td th:text="${comment.text}" style="width: 60%"/>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div class="d-flex flex-row justify-content-end ">
|
||||||
|
<a class="btn btn-outline-primary text-center mx-2"
|
||||||
|
th:href="@{/post/edit/{id}(id=${post.id})}">
|
||||||
|
<i class="fa fa-pencil" aria-hidden="true"></i> Изменить
|
||||||
|
</a>
|
||||||
|
<button type="button" class="btn btn-outline-primary text-center mx-2"
|
||||||
|
th:attr="onclick=|confirm('Удалить запись?') && document.getElementById('remove-${post.id}').click()|">
|
||||||
|
<i class="fa fa-trash" aria-hidden="true"></i> Удалить
|
||||||
|
</button>
|
||||||
|
<form th:action="@{'/post/delete/' + ${post.id}}" method="post">
|
||||||
|
<button th:id="'remove-' + ${post.id}" type="submit" style="display: none">
|
||||||
|
Удалить
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
<a th:href=@{/post/{id}(id=${post.id})} class='btn btn-outline-primary mx-2'><i class="fa-solid fa-envelopes-bulk"></i></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
<th:block layout:fragment="scripts">
|
||||||
|
<script>
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('#selectBox').on('change', function() {
|
||||||
|
this.form.submit();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</th:block>
|
||||||
|
</html>
|
||||||
35
src/main/resources/templates/user-edit.html
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en"
|
||||||
|
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||||
|
layout:decorate="~{default}" xmlns:th="http://www.w3.org/1999/xhtml">
|
||||||
|
<head>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div layout:fragment="content">
|
||||||
|
<div th:text="${errors}" class="margin-bottom alert-danger"></div>
|
||||||
|
<form action="#" th:action="@{/user/{id}(id=${id})}" th:object="${userDto}" method="post">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="firstName" class="form-label">Имя</label>
|
||||||
|
<input type="text" class="form-control" id="firstName" th:field="${userDto.firstName}" required="true">
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="lastName" class="form-label">Фамилия</label>
|
||||||
|
<input type="text" class="form-control" id="lastName" th:field="${userDto.lastName}" required="true">
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="email" class="form-label">Почта</label>
|
||||||
|
<input type="text" class="form-control" id="email" th:field="${userDto.email}" required="true">
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<button type="submit" class="btn btn-primary button-fixed">
|
||||||
|
<span th:if="${id == null}">Добавить</span>
|
||||||
|
<span th:if="${id != null}">Обновить</span>
|
||||||
|
</button>
|
||||||
|
<a class="btn btn-secondary button-fixed" th:href="@{/user}">
|
||||||
|
Назад
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
55
src/main/resources/templates/user.html
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en"
|
||||||
|
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||||
|
layout:decorate="~{default}" xmlns:th="http://www.w3.org/1999/xhtml">
|
||||||
|
<head>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div layout:fragment="content">
|
||||||
|
<div>
|
||||||
|
<a class="btn btn-outline-light text-center mx-2 my-2"
|
||||||
|
th:href="@{/user/edit}">
|
||||||
|
<i class="fa-solid fa-plus"></i>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">#</th>
|
||||||
|
<th scope="col">ID</th>
|
||||||
|
<th scope="col">Имя</th>
|
||||||
|
<th scope="col">Почта</th>
|
||||||
|
<th scope="col"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr th:each="user, iterator: ${users}">
|
||||||
|
<th scope="row" th:text="${iterator.index} + 1"/>
|
||||||
|
<td th:text="${user.id}"/>
|
||||||
|
<td th:text="${user.firstName} + ' ' + ${user.lastName}" style="width: 60%"/>
|
||||||
|
<td th:text="${user.email}" style="width: 60%"/>
|
||||||
|
<td style="width: 10%">
|
||||||
|
<div class="btn-group" role="group" aria-label="Basic example">
|
||||||
|
<a class="btn btn-outline-light text-center mx-2"
|
||||||
|
th:href="@{/user/edit/{id}(id=${user.id})}">
|
||||||
|
<i class="fa fa-pencil" aria-hidden="true"></i> Изменить
|
||||||
|
</a>
|
||||||
|
<button type="button" class="btn btn-outline-light text-center mx-2"
|
||||||
|
th:attr="onclick=|confirm('Удалить запись?') && document.getElementById('remove-${user.id}').click()|">
|
||||||
|
<i class="fa fa-trash" aria-hidden="true"></i> Удалить
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<form th:action="@{/user/delete/{id}(id=${user.id})}" method="post">
|
||||||
|
<button th:id="'remove-' + ${user.id}" type="submit" style="display: none">
|
||||||
|
Удалить
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
112
src/test/java/ru/ulstu/is/sbapp/JpaClientTests.java
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
/*
|
||||||
|
package ru.ulstu.is.sbapp;
|
||||||
|
|
||||||
|
import jakarta.persistence.EntityNotFoundException;
|
||||||
|
import org.junit.jupiter.api.Assertions;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import ru.ulstu.is.sbapp.Comment.model.Comment;
|
||||||
|
import ru.ulstu.is.sbapp.Post.model.Post;
|
||||||
|
import ru.ulstu.is.sbapp.Post.service.PostNotFoundException;
|
||||||
|
import ru.ulstu.is.sbapp.Post.service.PostService;
|
||||||
|
import ru.ulstu.is.sbapp.User.model.User;
|
||||||
|
import ru.ulstu.is.sbapp.User.service.UserNotFoundException;
|
||||||
|
import ru.ulstu.is.sbapp.User.service.UserService;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@SpringBootTest
|
||||||
|
public class JpaClientTests {
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(JpaClientTests.class);
|
||||||
|
@Autowired
|
||||||
|
private UserService userService;
|
||||||
|
@Autowired
|
||||||
|
private PostService postService;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testClientCreate() {
|
||||||
|
userService.deleteAllUsers();
|
||||||
|
final User user = userService.addUser("Pasha","Sorokin","sorokin.zxcv@gmail.com");
|
||||||
|
log.info("testUserCreate: " + user.toString());
|
||||||
|
Assertions.assertNotNull(user.getId());
|
||||||
|
|
||||||
|
userService.deleteAllUsers();
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
void testReadClient()
|
||||||
|
{
|
||||||
|
userService.deleteAllUsers();
|
||||||
|
final User user = userService.addUser("Pasha","Sorokin","sorokin.zxcv@gmail.com");
|
||||||
|
log.info("testUserRead[0]: " + user.toString());
|
||||||
|
final User curuser=userService.findUser(user.getId());
|
||||||
|
log.info("testUserRead[1]: " + curuser.toString());
|
||||||
|
Assertions.assertEquals(user, curuser);
|
||||||
|
userService.deleteAllUsers();
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
void testClientReadNotFound() {
|
||||||
|
userService.deleteAllUsers();
|
||||||
|
Assertions.assertThrows(UserNotFoundException.class, () -> userService.findUser(-1L));
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
void testClientReadAll() {
|
||||||
|
userService.deleteAllUsers();
|
||||||
|
userService.addUser("Pupa","Lupa","sasdfdsf@gmail.com");
|
||||||
|
userService.addUser("Pasha","Sorokin","sorokin.zxcv@gmail.com");
|
||||||
|
final List<User> users = userService.findAllUsers();
|
||||||
|
log.info("testUserReadAll: " + users.toString());
|
||||||
|
Assertions.assertEquals(users.size(), 2);
|
||||||
|
|
||||||
|
userService.deleteAllUsers();
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
void testClientReadAllEmpty() {
|
||||||
|
userService.deleteAllUsers();
|
||||||
|
final List<User> users = userService.findAllUsers();
|
||||||
|
log.info("testUserReadAllEmpty: " + users.toString());
|
||||||
|
Assertions.assertEquals(users.size(), 0);
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
void testDeletePostwithcomments()
|
||||||
|
{
|
||||||
|
final User user = userService.addUser("Pasha","Sorokin","sorokin.zxcv@gmail.com");
|
||||||
|
final User user12 = userService.addUser("Anton","Sorokin","zxcv@gmail.com");
|
||||||
|
userService.addNewPost(user.getId(),"text","tezt");
|
||||||
|
final List<Post> post = postService.findAllPosts();
|
||||||
|
final Post post1 = post.get(0);
|
||||||
|
postService.addCommentToPost(post1.getId(),user12.getId(),"Da");
|
||||||
|
userService.deleteUser(user.getId());
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
void testAddAndDeletePost()
|
||||||
|
{
|
||||||
|
postService.deleteAllPosts();
|
||||||
|
userService.deleteAllUsers();
|
||||||
|
final User user = userService.addUser("Pasha","Sorokin","sorokin.zxcv@gmail.com");
|
||||||
|
final User user12 = userService.addUser("Anton","Sorokin","zxcv@gmail.com");
|
||||||
|
userService.addNewPost(user.getId(),"Text1","Text2"); //post
|
||||||
|
userService.addNewPost(user.getId(),"Привет","Да"); //post1
|
||||||
|
final List<Post> posts =postService.findAllPosts();
|
||||||
|
final User user1 = userService.findUser(user.getId());
|
||||||
|
final List<Post> posts1 = user1.getPosts();
|
||||||
|
log.info("testAddAndDeletePost :: ADD " + posts.toString() + " and " + posts1.toString());
|
||||||
|
Assertions.assertEquals(posts.get(0).getUser(), user);
|
||||||
|
Assertions.assertEquals(posts.toString(), posts1.toString());
|
||||||
|
log.info("testAddAndDeletePost :: Delete ");
|
||||||
|
userService.deletePost(user.getId(),posts.get(0).getId());
|
||||||
|
final User us = userService.findUser(user.getId());
|
||||||
|
Assertions.assertThrows(PostNotFoundException.class, () -> postService.findPost(posts.get(0).getId()));
|
||||||
|
final List<Post> postss =postService.findAllPosts();
|
||||||
|
log.info(us.getPosts().toString());
|
||||||
|
log.info(postss.toString());
|
||||||
|
userService.deleteAllUsers();
|
||||||
|
postService.deleteAllPosts();
|
||||||
|
}
|
||||||
|
//посты и коментарии содержащие определенный текст
|
||||||
|
|
||||||
|
}.
|
||||||
|
*/
|
||||||
86
src/test/java/ru/ulstu/is/sbapp/JpaCommentTest.java
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
/*
|
||||||
|
package ru.ulstu.is.sbapp;
|
||||||
|
|
||||||
|
import jakarta.persistence.EntityNotFoundException;
|
||||||
|
import org.junit.jupiter.api.Assertions;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import ru.ulstu.is.sbapp.Comment.model.CommentDto;
|
||||||
|
import ru.ulstu.is.sbapp.Comment.model.Comment;
|
||||||
|
import ru.ulstu.is.sbapp.Comment.service.CommentNotFoundException;
|
||||||
|
import ru.ulstu.is.sbapp.Comment.service.CommentService;
|
||||||
|
import ru.ulstu.is.sbapp.User.service.UserService;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@SpringBootTest
|
||||||
|
public class JpaCommentTest {
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(JpaCommentTest.class);
|
||||||
|
@Autowired
|
||||||
|
private CommentService commentService;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testTidingCreate()
|
||||||
|
{
|
||||||
|
commentService.deleteAllComments();
|
||||||
|
final Comment comment=commentService.addComment("Net");
|
||||||
|
log.info("testCommentCreate: " + comment.toString());
|
||||||
|
Assertions.assertNotNull(comment.getId());
|
||||||
|
commentService.deleteAllComments();
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
void testTidingRead()
|
||||||
|
{
|
||||||
|
commentService.deleteAllComments();
|
||||||
|
final Comment comment=commentService.addComment("Net");
|
||||||
|
log.info("testCommentRead[0]: " + comment.toString());
|
||||||
|
final Comment findComment=commentService.findComment(comment.getId());
|
||||||
|
log.info("testCommentRead[1]: " + findComment.toString());
|
||||||
|
Assertions.assertEquals(comment, findComment);
|
||||||
|
|
||||||
|
commentService.deleteAllComments();
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
void testTidingReadNotFound() {
|
||||||
|
commentService.deleteAllComments();
|
||||||
|
Assertions.assertThrows(CommentNotFoundException.class, () -> commentService.findComment(-1L));
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
void testAllTidingRead()
|
||||||
|
{
|
||||||
|
commentService.deleteAllComments();
|
||||||
|
commentService.addComment("Net");
|
||||||
|
commentService.addComment("yep");
|
||||||
|
final List<Comment> comments = commentService.findAllComments();
|
||||||
|
log.info("testAllCommentRead: " + comments.toString());
|
||||||
|
Assertions.assertEquals(comments.size(), 2);
|
||||||
|
|
||||||
|
commentService.deleteAllComments();
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
void testTidingReadAllEmpty() {
|
||||||
|
commentService.deleteAllComments();
|
||||||
|
final List<Comment> comments = commentService.findAllComments();
|
||||||
|
log.info("testCommentReadAllEmpty: " + comments.toString());
|
||||||
|
Assertions.assertEquals(comments.size(), 0);
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
void testUpdateTiding()
|
||||||
|
{
|
||||||
|
commentService.deleteAllComments();
|
||||||
|
final Comment comment=commentService.addComment("Net");
|
||||||
|
log.info("testUpdateComment: " + comment.toString());
|
||||||
|
commentService.updateComment(comment.getId(),"Ladno");
|
||||||
|
final Comment comment1=commentService.findComment(comment.getId());
|
||||||
|
log.info("testUpdateComment: " + comment1.toString());
|
||||||
|
Assertions.assertEquals(comment1.getText(), "Ladno");
|
||||||
|
commentService.deleteAllComments();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
155
src/test/java/ru/ulstu/is/sbapp/JpaPostTests.java
Normal file
@@ -0,0 +1,155 @@
|
|||||||
|
/*
|
||||||
|
package ru.ulstu.is.sbapp;
|
||||||
|
|
||||||
|
import jakarta.persistence.EntityNotFoundException;
|
||||||
|
import org.junit.jupiter.api.Assertions;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import ru.ulstu.is.sbapp.Comment.model.Comment;
|
||||||
|
import ru.ulstu.is.sbapp.Comment.service.CommentService;
|
||||||
|
import ru.ulstu.is.sbapp.Post.model.Post;
|
||||||
|
import ru.ulstu.is.sbapp.Post.service.PostNotFoundException;
|
||||||
|
import ru.ulstu.is.sbapp.Post.service.PostService;
|
||||||
|
import ru.ulstu.is.sbapp.User.model.User;
|
||||||
|
import ru.ulstu.is.sbapp.User.service.UserService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@SpringBootTest
|
||||||
|
public class JpaPostTests {
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(JpaPostTests.class);
|
||||||
|
@Autowired
|
||||||
|
private CommentService commentService;
|
||||||
|
@Autowired
|
||||||
|
private UserService userService;
|
||||||
|
@Autowired
|
||||||
|
private PostService postService;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void TestAddPost(){
|
||||||
|
postService.deleteAllPosts();
|
||||||
|
final Post post = postService.addPost("Test","Test");
|
||||||
|
Assertions.assertNotNull(post.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void TestFindPost(){
|
||||||
|
postService.deleteAllPosts();
|
||||||
|
final Post post = postService.addPost("Test","Test");
|
||||||
|
final Post findPost = postService.findPost(post.getId());
|
||||||
|
Assertions.assertEquals(post, findPost);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void TestPostReadNotFound(){
|
||||||
|
postService.deleteAllPosts();
|
||||||
|
Assertions.assertThrows(PostNotFoundException.class, () -> postService.findPost(-1L));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void TestFindAllPost(){
|
||||||
|
postService.deleteAllPosts();
|
||||||
|
final Post firstPost = postService.addPost("Test1","Test1");
|
||||||
|
final Post secondPost = postService.addPost("Test2","Test2");
|
||||||
|
final List<Post> posts = postService.findAllPosts();
|
||||||
|
Assertions.assertEquals(posts.size(), 2);
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
void TestPostReadAllEmpty() {
|
||||||
|
postService.deleteAllPosts();
|
||||||
|
final List<Post> posts = postService.findAllPosts();
|
||||||
|
Assertions.assertEquals(posts.size(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void TestPostUpdate(){
|
||||||
|
postService.deleteAllPosts();
|
||||||
|
Post post = postService.addPost("Test1", "Test1");
|
||||||
|
post = postService.updatePost(post.getId(), "Test2", "Test2");
|
||||||
|
Assertions.assertEquals(post.getHeading(), "Test2");
|
||||||
|
Assertions.assertEquals(post.getContent(), "Test2");
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
void TestDeleteAllPosts()
|
||||||
|
{
|
||||||
|
log.info("Удаление всех постов");
|
||||||
|
Post post = postService.addPost("Test1", "Test1");
|
||||||
|
Post post2 = postService.addPost("Test1", "Test1");
|
||||||
|
List<Post> posts1 = postService.findAllPosts();
|
||||||
|
log.info(posts1.toString());
|
||||||
|
postService.deleteAllPosts();
|
||||||
|
List<Post> posts = postService.findAllPosts();
|
||||||
|
log.info(posts.toString());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void TestDeletePost(){
|
||||||
|
postService.deleteAllPosts();
|
||||||
|
final Post post = postService.addPost("Test","Test");
|
||||||
|
postService.deletePost(post.getId());
|
||||||
|
Assertions.assertThrows(PostNotFoundException.class, () -> postService.findPost(1L));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void TestAddComment()
|
||||||
|
{
|
||||||
|
log.info("Добавление комментария");
|
||||||
|
postService.deleteAllPosts();
|
||||||
|
userService.deleteAllUsers();
|
||||||
|
final User user = userService.addUser("Pasha","Sorokin","sorokin.zxcv@gmail.com");
|
||||||
|
userService.addNewPost(user.getId(),"Text1","Text2");
|
||||||
|
final User user2=userService.findUser(user.getId());
|
||||||
|
log.info(user2.getPosts().toString());
|
||||||
|
final List<Post> posts = postService.findAllPosts();
|
||||||
|
final Post post2=postService.findPost(posts.get(0).getId());
|
||||||
|
log.info(post2.toString());
|
||||||
|
postService.addCommentToPost(posts.get(0).getId(),user.getId(),"Крутой пост");
|
||||||
|
final List<Comment> comments = commentService.findAllComments();
|
||||||
|
log.info(comments.toString());
|
||||||
|
final User user1=userService.findUser(user.getId());
|
||||||
|
log.info(user1.getComments().toString());
|
||||||
|
final Post post1=postService.findPost(posts.get(0).getId());
|
||||||
|
log.info(post1.getComments().toString());
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
void TestDeleteCommentFromPost()
|
||||||
|
{
|
||||||
|
log.info("Удаление коммента");
|
||||||
|
postService.deleteAllPosts();
|
||||||
|
userService.deleteAllUsers();
|
||||||
|
final User user = userService.addUser("Pasha","Sorokin","sorokin.zxcv@gmail.com");
|
||||||
|
userService.addNewPost(user.getId(),"Text1","Text2");
|
||||||
|
final User user2=userService.findUser(user.getId());
|
||||||
|
log.info("Посты юзера (добавили)"+user2.getPosts().toString());
|
||||||
|
final List<Post> posts = postService.findAllPosts();
|
||||||
|
final Post post2=postService.findPost(posts.get(0).getId());
|
||||||
|
log.info("Пост который добавили"+post2.toString());
|
||||||
|
postService.addCommentToPost(posts.get(0).getId(),user.getId(),"Крутой пост");
|
||||||
|
postService.addCommentToPost(posts.get(0).getId(),user.getId(),"Пост плохой");
|
||||||
|
final List<Comment> comments = commentService.findAllComments();
|
||||||
|
log.info("Добавили коммент"+comments.toString());
|
||||||
|
final User user1=userService.findUser(user.getId());
|
||||||
|
log.info("Комменты юзера"+user1.getComments().toString());
|
||||||
|
final Post post1=postService.findPost(posts.get(0).getId());
|
||||||
|
log.info("Комменты к посту"+post1.getComments().toString());
|
||||||
|
Comment comment1 = commentService.findComment(comments.get(0).getId());
|
||||||
|
log.info("Удаляем коммент");
|
||||||
|
postService.removeCommentFromPost(posts.get(0).getId(),comment1.getId());
|
||||||
|
final User user3=userService.findUser(user.getId());
|
||||||
|
log.info(user3.getPosts().toString());
|
||||||
|
log.info("Комменты юзера после удаления"+user3.getComments().toString());
|
||||||
|
final Post post3 = postService.findPost(posts.get(0).getId());
|
||||||
|
log.info(post3.toString());
|
||||||
|
log.info(post3.getComments().toString());
|
||||||
|
final List<Comment> comment4=commentService.findAllComments();
|
||||||
|
log.info(comment4.toString());
|
||||||
|
commentService.deleteAllComments();
|
||||||
|
postService.deleteAllPosts();
|
||||||
|
userService.deleteAllUsers();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||