Compare commits
2 Commits
LabWork06M
...
LabWork04
| Author | SHA1 | Date | |
|---|---|---|---|
| b653d3808a | |||
| 6c6e8f96aa |
14
build.gradle
@@ -15,24 +15,14 @@ jar {
|
||||
enabled = false
|
||||
}
|
||||
dependencies {
|
||||
implementation(project(':front'))
|
||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
|
||||
implementation 'org.springframework.boot:spring-boot-devtools'
|
||||
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 'org.springframework.boot:spring-boot-starter-data-jpa'
|
||||
implementation 'com.h2database:h2:2.1.210'
|
||||
|
||||
implementation 'org.springframework.boot:spring-boot-starter-security'
|
||||
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6'
|
||||
|
||||
implementation 'org.hibernate.validator:hibernate-validator'
|
||||
implementation 'org.springdoc:springdoc-openapi-ui:1.6.5'
|
||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||
//implementation group: 'org.springdoc', name: 'springdoc-openapi-ui', version: '1.6.5'
|
||||
|
||||
}
|
||||
|
||||
|
||||
BIN
data.mv.db
26
front/.gitignore
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
# 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?
|
||||
|
||||
.parcel-cache
|
||||
58
front/build.gradle
Normal file
@@ -0,0 +1,58 @@
|
||||
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'
|
||||
final devHost = 'http://localhost:8080'
|
||||
final prodHost = ''
|
||||
filesMatching('index.html') {
|
||||
filter { line -> line.replaceAll(devHost, prodHost) }
|
||||
}
|
||||
}
|
||||
|
||||
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
front/img/4_popular.jpg
Normal file
|
After Width: | Height: | Size: 70 KiB |
BIN
front/img/5_popular.jpg
Normal file
|
After Width: | Height: | Size: 50 KiB |
BIN
front/img/6_popular.jpg
Normal file
|
After Width: | Height: | Size: 33 KiB |
BIN
front/img/popular_1.jpg
Normal file
|
After Width: | Height: | Size: 58 KiB |
BIN
front/img/popular_2.jpg
Normal file
|
After Width: | Height: | Size: 40 KiB |
BIN
front/img/popular_3.jpg
Normal file
|
After Width: | Height: | Size: 39 KiB |
BIN
front/img/существование.jpg
Normal file
|
After Width: | Height: | Size: 48 KiB |
16
front/index.html
Normal file
@@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<script type="module" 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>ReManga</title>
|
||||
</head>
|
||||
<body >
|
||||
<div id="app" class="d-flex flex-column h-100" ></div>
|
||||
<script type="module" src="/src/main.jsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
3026
front/package-lock.json
generated
Normal file
24
front/package.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "front",
|
||||
"version": "1.0.0",
|
||||
"source": "index.html",
|
||||
"scripts": {
|
||||
"start": "parcel --port 3000",
|
||||
"build": "npm run clean && parcel build",
|
||||
"clean": "rimraf dist"
|
||||
},
|
||||
"dependencies": {
|
||||
"bootstrap": "5.3.0-alpha2",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-router-dom": "^6.4.4",
|
||||
"@fortawesome/fontawesome-free": "^6.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^18.0.24",
|
||||
"@types/react-dom": "^18.0.8",
|
||||
"parcel": "2.8.3",
|
||||
"process": "^0.11.10",
|
||||
"rimraf": "4.4.0"
|
||||
}
|
||||
}
|
||||
45
front/src/App.jsx
Normal file
@@ -0,0 +1,45 @@
|
||||
import { useRoutes, Outlet, BrowserRouter } from 'react-router-dom';
|
||||
import Creator from './MainS/Creator';
|
||||
import Reader from './MainS/Reader';
|
||||
import Header from './components/Header';
|
||||
import Manga from './MainS/Manga';
|
||||
import CreatorAction from './Main/CreatorAction';
|
||||
import ReaderAction from './Main/ReaderAction';
|
||||
import MangaPage from './Main/MangaPage';
|
||||
import Catalog from './Main/Catalog';
|
||||
|
||||
function Router(props) {
|
||||
return useRoutes(props.rootRoute);
|
||||
}
|
||||
|
||||
export default function App() {
|
||||
const routes = [
|
||||
{ index: true, element: <Creator /> },
|
||||
{ path: 'creator', element: <Creator />, label: 'Creator' },
|
||||
{ path: 'reader', element: <Reader />, label: 'Reader' },
|
||||
{ path: 'manga', element: <Manga />, label: 'Manga' },
|
||||
{ path: 'creatorAction', element: <CreatorAction />, label: 'CreatorAction' },
|
||||
{ path: 'readerAction', element: <ReaderAction />, label: 'ReaderAction' },
|
||||
{ path: 'catalog', element: <Catalog />, label: 'Catalog' },
|
||||
{ path: 'mangapage', element: <MangaPage /> },
|
||||
];
|
||||
const links = routes.filter(route => route.hasOwnProperty('label'));
|
||||
const rootRoute = [
|
||||
{ path: '/', element: render(links), children: routes }
|
||||
];
|
||||
|
||||
function render(links) {
|
||||
return (
|
||||
<>
|
||||
<Header links={links} />
|
||||
<Outlet />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<BrowserRouter>
|
||||
<Router rootRoute={ rootRoute } />
|
||||
</BrowserRouter>
|
||||
);
|
||||
}
|
||||
9
front/src/Dto/Manga-Dto.js
Normal file
@@ -0,0 +1,9 @@
|
||||
export default class MangaDto {
|
||||
constructor(args) {
|
||||
this.id = args.id || null;
|
||||
this.creatorId = args.creatorId || 0;
|
||||
this.mangaName = args.mangaName || "";
|
||||
this.image = args.image;
|
||||
this.chapterCount = args.chapterCount || 0;
|
||||
}
|
||||
}
|
||||
53
front/src/Main/Catalog.jsx
Normal file
@@ -0,0 +1,53 @@
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import '../components/Banner/banner.css'
|
||||
import Banner from '../components/Banner/Banner.jsx'
|
||||
import { Link, NavLink } from 'react-router-dom';
|
||||
import MangaDto from "../Dto/Manga-Dto";
|
||||
|
||||
export default function Catalog() {
|
||||
|
||||
const host = "http://localhost:8080";
|
||||
|
||||
const [mangs, setMangs] = useState([]);
|
||||
|
||||
useEffect(() => {
|
||||
getMangs()
|
||||
.then(_data =>setMangs(_data));
|
||||
console.log(2);
|
||||
console.log(mangs);
|
||||
},[]);
|
||||
|
||||
const getMangs = async function () {
|
||||
const response = await fetch(host + "/manga");
|
||||
const _data = await response.json()
|
||||
console.log(_data);
|
||||
return _data;
|
||||
}
|
||||
|
||||
return (
|
||||
<article className="p-2 catalog_article">
|
||||
<Banner />
|
||||
<div className = "catalog_wrapper">
|
||||
<h1>Каталог</h1>
|
||||
{/* <h2>
|
||||
<select>
|
||||
<option value="1">По рейтингу</option>
|
||||
<option value="2">По лайкам</option>
|
||||
<option value="3">По просмотрам</option>
|
||||
<option value="4">По кол-ву глав</option>
|
||||
<option value="5">По новизне</option>
|
||||
<option value="6">По последним обновлениям</option>
|
||||
<option value="7">Рандом</option>
|
||||
</select>
|
||||
<button type="button" className="btn btn-dark">↑↓</button>
|
||||
</h2> */}
|
||||
<div className="p-2 d-flex flex-wrap">
|
||||
{mangs.map((manga, index) => (
|
||||
<NavLink key={manga.id} to={`/mangapage?id=${manga.id}`}><img src={manga.image} alt={manga.mangaName} className="slideshow"/></NavLink>
|
||||
))}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
);
|
||||
}
|
||||
198
front/src/Main/CreatorAction.jsx
Normal file
@@ -0,0 +1,198 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { NavLink } from 'react-router-dom';
|
||||
import TableCreator from '../components/Table/TableCreator';
|
||||
import MangaDto from "../Dto/Manga-Dto";
|
||||
import MangaCreatorList from "../components/List/MangaCreatorList";
|
||||
import AddMangaModal from "../components/Modal/AddMangaModal";
|
||||
import EditMangaModal from "../components/Modal/EditMangaModal";
|
||||
|
||||
export default function CreatorAction() {
|
||||
|
||||
const host = "http://localhost:8080";
|
||||
|
||||
const [creatorData, setCreatorData] = useState([]);
|
||||
|
||||
const [creatorId, setCreatorId] = useState(0);
|
||||
|
||||
const [creator, setCreator] = useState([]);
|
||||
|
||||
const [mangaId, setMangaId] = useState(0);
|
||||
|
||||
const [chapterCount, setChapterCount] = useState(0);
|
||||
|
||||
const [mangaName, setMangaName] = useState("");
|
||||
|
||||
const [mangaModel, setMangaModel] = useState(new MangaDto({}));
|
||||
|
||||
useEffect(() => {
|
||||
getCreatorData()
|
||||
.then(_data =>setCreatorData(_data));
|
||||
},[]);
|
||||
|
||||
const getCreatorData = async function () {
|
||||
const response = await fetch(host + "/creator");
|
||||
const _data = await response.json()
|
||||
return _data;
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
getCreator(creatorId)
|
||||
.then(_data =>setCreator(_data));
|
||||
},[creatorId]);
|
||||
|
||||
const getCreator = async function (id) {
|
||||
const requestParams = {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
};
|
||||
const response = await fetch(host + `/creator/` + id, requestParams);
|
||||
const _data = await response.json()
|
||||
return _data;
|
||||
}
|
||||
|
||||
const updateButton = (e) =>{
|
||||
e.preventDefault();
|
||||
update().then((result) => {
|
||||
alert(`Manga[id=${result.id}, mangaName=${result.mangaName}, chapterCount=${result.chapterCount}]`);
|
||||
getCreator(creatorId)
|
||||
.then(_data =>setCreator(_data));
|
||||
});
|
||||
}
|
||||
|
||||
const update = async function (){
|
||||
console.info('Try to update item');
|
||||
if (mangaId === 0) {
|
||||
return;
|
||||
}
|
||||
mangaModel.id = mangaId;
|
||||
mangaModel.chapterCount = chapterCount;
|
||||
mangaModel.creatorId = creatorId;
|
||||
mangaModel.image = imageURL;
|
||||
mangaModel.mangaName = mangaName;
|
||||
const requestParams = {
|
||||
method: "PUT",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(mangaModel),
|
||||
};
|
||||
const response = await fetch(host + `/manga/` + mangaModel.id, requestParams);
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
const setMangaIdButton = (id) =>{
|
||||
setMangaId(id);
|
||||
}
|
||||
|
||||
const removeButton = (id) =>{
|
||||
remove(id).then(() => {
|
||||
getCreator(creatorId)
|
||||
.then(_data =>setCreator(_data));
|
||||
});
|
||||
}
|
||||
|
||||
const remove = async function (id){
|
||||
console.info('Try to remove item');
|
||||
if (id !== 0) {
|
||||
if (!confirm('Do you really want to remove this item?')) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
const requestParams = {
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
};
|
||||
const response = await fetch(host + `/manga/` + id, requestParams);
|
||||
}
|
||||
|
||||
const createButton = (e) =>{
|
||||
e.preventDefault()
|
||||
create().then((result) => {
|
||||
alert(`Manga[id=${result.id}, mangaName=${result.mangaName}, chapterCount=${result.chapterCount}]`);
|
||||
getCreator(creatorId)
|
||||
.then(_data =>setCreator(_data));
|
||||
});
|
||||
}
|
||||
|
||||
const create = async function (){
|
||||
mangaModel.chapterCount = chapterCount;
|
||||
mangaModel.creatorId = creatorId;
|
||||
mangaModel.image = imageURL;
|
||||
mangaModel.mangaName = mangaName;
|
||||
const requestParams = {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(mangaModel),
|
||||
};
|
||||
const response = await fetch(host + `/manga`, requestParams);
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
const [imageURL, setImageURL] = useState();
|
||||
const fileReader = new FileReader();
|
||||
|
||||
fileReader.onloadend = () => {
|
||||
setImageURL(fileReader.result);
|
||||
};
|
||||
|
||||
const handleOnChange = (event) => {
|
||||
event.preventDefault();
|
||||
if (event.target.files && event.target.files.length) {
|
||||
const file = event.target.files[0];
|
||||
fileReader.readAsDataURL(file);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<main>
|
||||
<div className="container" id="root-div">
|
||||
<div className="content">
|
||||
<h1>Creator</h1>
|
||||
<form id="form">
|
||||
<div className="d-flex mt-3">
|
||||
<div className="col-sm-2 me-3">
|
||||
<select className="form-select" value={creatorId} onChange={event => setCreatorId(event.target.value)} aria-label="Default select example">
|
||||
<option value={0}>Creator</option>
|
||||
{
|
||||
creatorData.map((creatorD) =>
|
||||
<option key={creatorD.id} value={creatorD.id}>{creatorD.creatorName}</option>
|
||||
)
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
<div className="d-grid col-sm-2">
|
||||
<button type="button" className="btn btn-success" data-bs-toggle="modal" data-bs-target="#exampleModal2">Добавить</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<MangaCreatorList
|
||||
creator={creator}
|
||||
setMangaIdButton={setMangaIdButton}
|
||||
removeButton={removeButton}
|
||||
/>
|
||||
<EditMangaModal
|
||||
chapterCount={chapterCount}
|
||||
setChapterCount={setChapterCount}
|
||||
handleOnChange={handleOnChange}
|
||||
updateButton={updateButton}
|
||||
/>
|
||||
<AddMangaModal
|
||||
chapterCount={chapterCount}
|
||||
setChapterCount={setChapterCount}
|
||||
mangaName={mangaName}
|
||||
setMangaName={setMangaName}
|
||||
handleOnChange={handleOnChange}
|
||||
createButton={createButton}
|
||||
/>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
114
front/src/Main/MangaPage.jsx
Normal file
@@ -0,0 +1,114 @@
|
||||
import React, {useState, useEffect} from 'react';
|
||||
import MangaDto from '../Dto/Manga-Dto';
|
||||
import ReaderList from "../components/List/ReaderList";
|
||||
|
||||
export default function MangaPage() {
|
||||
|
||||
const [mangaModel, setMangaModel] = useState(new MangaDto({}));
|
||||
|
||||
const [readerData, setReaderData] = useState([]);
|
||||
|
||||
const host = "http://localhost:8080";
|
||||
|
||||
useEffect(() => {
|
||||
const quryString = window.location.search;
|
||||
const urlParams = new URLSearchParams(quryString);
|
||||
const id = urlParams.get('id');
|
||||
getCreator(id)
|
||||
.then(_data =>setMangaModel(_data));
|
||||
getReaderData(id)
|
||||
.then(_data =>setReaderData(_data));
|
||||
console.log(readerData);
|
||||
}, []);
|
||||
|
||||
const transformer = (mangaModel) => new MangaDto(mangaModel);
|
||||
const url = "manga/";
|
||||
|
||||
const getReaderData = async function (id) {
|
||||
const requestParams = {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
};
|
||||
const response = await fetch(host + `/manga/` + id + `/readers`, requestParams);
|
||||
const _data = await response.json()
|
||||
console.log(_data);
|
||||
return _data;
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
console.log(mangaModel);
|
||||
console.log(readerData);
|
||||
}, [mangaModel]);
|
||||
|
||||
useEffect(() => {
|
||||
console.log(readerData);
|
||||
});
|
||||
|
||||
|
||||
const getCreator = async function (id) {
|
||||
const requestParams = {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
};
|
||||
const response = await fetch(host + `/manga/` + id, requestParams);
|
||||
const _data = await response.json()
|
||||
return _data;
|
||||
}
|
||||
|
||||
|
||||
const addMangaButton = (e) =>{
|
||||
e.preventDefault()
|
||||
getReaderData(253)
|
||||
.then(_data =>setReaderData(_data));
|
||||
console.log(readerData);
|
||||
}
|
||||
|
||||
return (
|
||||
<main className="p-3">
|
||||
<div className="container d-flex" >
|
||||
<div className="d-flex flex-column">
|
||||
<img className="img_style01" style={{borderRadius: "3%"}}src={mangaModel.image} alt={mangaModel.mangaName}/>
|
||||
<button type="button" onClick={addMangaButton} className="btn btn-primary mt-3">Добавить в избранное</button>
|
||||
</div>
|
||||
<div className="container table text-white fs-4 ms-4">
|
||||
<div className="row text-white fw-bold fs-3">О манге</div>
|
||||
<div className="row">
|
||||
<div className="col-xs-6 col-sm-3">Год производства</div>
|
||||
<div className="col-xs-6 col-sm-3">1000</div>
|
||||
</div>
|
||||
<div className="row">
|
||||
<div className="col-xs-6 col-sm-3">Страна</div>
|
||||
<div className="col-xs-6 col-sm-3">Россия</div>
|
||||
</div>
|
||||
<div className="row">
|
||||
<div className="col-xs-6 col-sm-3">Жанр</div>
|
||||
<div className="col-xs-6 col-sm-3">Драма</div>
|
||||
</div>
|
||||
<div className="row">
|
||||
<div className="col-xs-6 col-sm-3">Количество глав</div>
|
||||
<div className="col-xs-6 col-sm-3">{mangaModel.chapterCount}</div>
|
||||
</div>
|
||||
<div className="row">
|
||||
<div className="col-xs-6 col-sm-3">Возраст</div>
|
||||
<div className="col-xs-6 col-sm-3">16+</div>
|
||||
</div>
|
||||
<div className="row text-white fw-bold fs-3">Описание</div>
|
||||
<div className="row">
|
||||
<div className="col-xs-6 col-sm-12">
|
||||
<p>Ким Кон Чжа спокойно живет в своей халупе, завидуя всем популярным охотникам. Однажды его желание быть лучше всех сбывается и он получает легендарный навык “Копирование способностей”... ценой своей жизни.</p>
|
||||
<p>Прежде чем он успевает понять это, его убивает охотник №1, Летний дух! Но это активирует его навык, и теперь он скопировал новый, “Путешествие во времени после смерти”.</p>
|
||||
<p>Как Ким Кон Чжа же будет использовать эти навыки, чтобы победить конкурентов и подняться на вершину?</p>
|
||||
</div>
|
||||
</div>
|
||||
<ReaderList
|
||||
readers={mangaModel.readers}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
186
front/src/Main/ReaderAction.jsx
Normal file
@@ -0,0 +1,186 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import TableReader from '../components/Table/TableReader';
|
||||
import { NavLink } from 'react-router-dom';
|
||||
import MangaReaderList from "../components/List/MangaReaderList";
|
||||
import AddMangaReaderModal from "../components/Modal/AddMangaReaderModal";
|
||||
|
||||
export default function ReaderAction() {
|
||||
|
||||
const host = "http://localhost:8080";
|
||||
|
||||
const [mangaData, setMangaData] = useState([]);
|
||||
|
||||
const [readerData, setReaderData] = useState([]);
|
||||
|
||||
const [readerId, setReaderId] = useState(0);
|
||||
|
||||
const [reader, setReader] = useState([]);
|
||||
|
||||
const [mangaId, setMangaId] = useState(0);
|
||||
|
||||
const [chapterCount, setChapterCount] = useState(0);
|
||||
|
||||
const [mangaName, setMangaName] = useState("");
|
||||
|
||||
useEffect(() => {
|
||||
const quryString = window.location.search;
|
||||
const urlParams = new URLSearchParams(quryString);
|
||||
const id = urlParams.get('id');
|
||||
setReaderId(id);
|
||||
getReaderData()
|
||||
.then(_data =>setReaderData(_data));
|
||||
getMangaData()
|
||||
.then(_data =>setMangaData(_data));
|
||||
console.log(2);
|
||||
console.log(readerData);
|
||||
},[]);
|
||||
|
||||
const getReaderData = async function () {
|
||||
const response = await fetch(host + "/reader");
|
||||
const _data = await response.json()
|
||||
console.log(_data);
|
||||
return _data;
|
||||
}
|
||||
|
||||
const getMangaData = async function () {
|
||||
const response = await fetch(host + "/manga");
|
||||
const _data = await response.json()
|
||||
console.log(_data);
|
||||
return _data;
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
console.log(readerId);
|
||||
getReader(readerId)
|
||||
.then(_data =>setReader(_data));
|
||||
console.log(readerId);
|
||||
},[readerId]);
|
||||
|
||||
const getReader = async function (id) {
|
||||
const requestParams = {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
};
|
||||
const response = await fetch(host + `/reader/` + id, requestParams);
|
||||
const _data = await response.json()
|
||||
return _data;
|
||||
}
|
||||
|
||||
const updateButton = (e) =>{
|
||||
e.preventDefault();
|
||||
update().then((result) => {
|
||||
alert(`Manga[id=${result.id}, mangaName=${result.mangaName}, chapterCount=${result.chapterCount}]`);
|
||||
getReader(readerId)
|
||||
.then(_data =>setReader(_data));
|
||||
});
|
||||
console.log(readerId);
|
||||
|
||||
console.log(readerId);
|
||||
console.log(reader);
|
||||
}
|
||||
|
||||
const update = async function (){
|
||||
console.info('Try to update item');
|
||||
if (mangaId === 0) {
|
||||
return;
|
||||
}
|
||||
const requestParams = {
|
||||
method: "PUT",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
};
|
||||
const response = await fetch(host + `/manga/${mangaId}?chapterCount=${chapterCount}`, requestParams);
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
const setMangaIdButton = (id) =>{
|
||||
setMangaId(id);
|
||||
}
|
||||
|
||||
const removeButton = (id) =>{
|
||||
remove(id).then((result) => {
|
||||
getReader(readerId)
|
||||
.then(_data =>setReader(_data));
|
||||
});
|
||||
}
|
||||
|
||||
const remove = async function (id){
|
||||
console.info('Try to remove item');
|
||||
if (!confirm('Do you really want to remove this item?')) {
|
||||
console.info('Canceled');
|
||||
return;
|
||||
}
|
||||
const requestParams = {
|
||||
method: "PUT",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
};
|
||||
console.log(host + `/reader/${readerId}/removeManga?mangaId=${id}`, requestParams);
|
||||
const response = await fetch(host + `/reader/${readerId}/removeManga?mangaId=${id}`, requestParams);
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
|
||||
const addMangaButton = (e) =>{
|
||||
e.preventDefault()
|
||||
addManga().then((result) => {
|
||||
alert(`Manga[id=${result.id}, mangaName=${result.mangaName}, chapterCount=${result.chapterCount}]`);
|
||||
console.log(result);
|
||||
getReader(readerId)
|
||||
.then(_data =>setReader(_data));
|
||||
});
|
||||
}
|
||||
|
||||
const addManga = async function (){
|
||||
const requestParams = {
|
||||
method: "PUT",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
};
|
||||
console.log(host + `/reader/${readerId}/addManga?mangaId=${mangaId}`, requestParams);
|
||||
const response = await fetch(host + `/reader/${readerId}/addManga?mangaId=${mangaId}`, requestParams);
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
return (
|
||||
<main>
|
||||
<div className="container" id="root-div">
|
||||
<div className="content">
|
||||
<h1>Reader</h1>
|
||||
<form id="form">
|
||||
<div className="d-flex mt-3">
|
||||
<div className="col-sm-2 me-3">
|
||||
<select className="form-select" value={readerId} onChange={event => setReaderId(event.target.value)} aria-label="Default select example">
|
||||
<option value={0}>Reader</option>
|
||||
{
|
||||
readerData.map((readerD) =>
|
||||
<option key={readerD.id} value={readerD.id}>{readerD.readerName}</option>
|
||||
)
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
<div className="d-grid col-sm-2">
|
||||
<button type="button" className="btn btn-success" data-bs-toggle="modal" data-bs-target="#exampleModal2">Добавить</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<MangaReaderList
|
||||
reader={reader}
|
||||
removeButton={removeButton}
|
||||
/>
|
||||
<AddMangaReaderModal
|
||||
mangaId={mangaId}
|
||||
setMangaId={setMangaId}
|
||||
mangaData={mangaData}
|
||||
addMangaButton={addMangaButton}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
177
front/src/MainS/Creator.jsx
Normal file
@@ -0,0 +1,177 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import TableCreator from '../components/Table/TableCreator';
|
||||
import MangaDto from '../Dto/Manga-Dto';
|
||||
|
||||
export default function Creator() {
|
||||
|
||||
const host = "http://localhost:8080";
|
||||
|
||||
const [creatorId, setCreatorId] = useState(0);
|
||||
|
||||
const [creatorName, setCreatorName] = useState("");
|
||||
|
||||
const [password, setPassword] = useState("");
|
||||
|
||||
const [mangaModel, setMangaModel] = useState(new MangaDto({}));
|
||||
|
||||
const [data, setData] = useState([]);
|
||||
|
||||
|
||||
const table = document.getElementById("tbody");
|
||||
|
||||
useEffect(() => {
|
||||
getData()
|
||||
.then(_data =>setData(_data)) ;
|
||||
console.log(2);
|
||||
},[]);
|
||||
|
||||
|
||||
const getData = async function () {
|
||||
const response = await fetch(host + "/creator");
|
||||
const _data = await response.json()
|
||||
console.log(data);
|
||||
return _data;
|
||||
|
||||
//table.innerHTML = "";
|
||||
// data.forEach(Creator => {
|
||||
// let temp = "<select>";
|
||||
// Creator.mangas.forEach(Manga => {
|
||||
// temp += `<option>${Manga.mangaName + " " + Manga.chapterCount}</option>>`
|
||||
// })
|
||||
// temp += "</select>"
|
||||
// table.innerHTML +=
|
||||
// `<tr>
|
||||
// <th scope="row">${Creator.id}</th>
|
||||
// <td>${Creator.creatorName}</td>
|
||||
// <td>${Creator.hashedPassword}</td>
|
||||
// <td>${temp}</td>
|
||||
// </tr>`;
|
||||
// })
|
||||
}
|
||||
|
||||
const create = async function (){
|
||||
const requestParams = {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
};
|
||||
const response = await fetch(host + `/creator?creatorName=${creatorName}&password=${password}`, requestParams);
|
||||
getData();
|
||||
}
|
||||
|
||||
const remove = async function (){
|
||||
console.info('Try to remove item');
|
||||
if (creatorId !== 0) {
|
||||
if (!confirm('Do you really want to remove this item?')) {
|
||||
console.info('Canceled');
|
||||
return;
|
||||
}
|
||||
}
|
||||
const requestParams = {
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
};
|
||||
const response = await fetch(host + `/creator/` + creatorId, requestParams);
|
||||
console.log("REMOVE");
|
||||
getData();
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
const removeAll = async function (){
|
||||
console.info('Try to remove item');
|
||||
if (!confirm('Do you really want to remove this item?')) {
|
||||
console.info('Canceled');
|
||||
return;
|
||||
}
|
||||
const requestParams = {
|
||||
method: "DELETE",
|
||||
};
|
||||
await fetch(host + `/creator/`, requestParams);
|
||||
}
|
||||
|
||||
const update = async function (){
|
||||
console.info('Try to update item');
|
||||
if (creatorId === 0 || creatorName == null || password === 0) {
|
||||
return;
|
||||
}
|
||||
const requestParams = {
|
||||
method: "PUT",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
};
|
||||
const response = await fetch(host + `/creator/${creatorId}?creatorName=${creatorName}&password=${password}`, requestParams);
|
||||
getData();
|
||||
return await response.json();
|
||||
}
|
||||
const createButton = (e) =>{
|
||||
e.preventDefault()
|
||||
create();
|
||||
}
|
||||
|
||||
const removeButton = (e) =>{
|
||||
e.preventDefault()
|
||||
remove();
|
||||
}
|
||||
|
||||
const updateButton = (e) =>{
|
||||
e.preventDefault()
|
||||
update();
|
||||
}
|
||||
|
||||
return (
|
||||
<main>
|
||||
<div className="container" id="root-div">
|
||||
<div className="content">
|
||||
<h1>Creator</h1>
|
||||
<form id="form">
|
||||
<div className="d-flex justify-content-evenly mt-3">
|
||||
<div className="col-sm-2">
|
||||
<label htmlFor="creatorId" className="form-label">creatorId</label>
|
||||
<input type='number' value = {creatorId} onChange={event => setCreatorId(event.target.value)} className="form-control"/>
|
||||
</div>
|
||||
<div className="col-sm-2">
|
||||
<label htmlFor="creatorName" className="form-label">creatorName</label>
|
||||
<input type='text' value = {creatorName} onChange={event => setCreatorName(event.target.value)} className="form-control"/>
|
||||
</div>
|
||||
<div className="col-sm-2">
|
||||
<label htmlFor="password" className="form-label">password</label>
|
||||
<input type='text' value = {password} onChange={event => setPassword(event.target.value)} className="form-control"/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="row mt-3">
|
||||
<div className="d-grid col-sm-3 mx-auto">
|
||||
<button type="submit" onClick={createButton} className="btn btn-success">Добавить</button>
|
||||
</div>
|
||||
<div className="d-grid col-sm-3 mx-auto">
|
||||
<button type="submit" onClick={updateButton} className="btn btn-success" id="btnUpdate" >Обновить</button>
|
||||
</div>
|
||||
<div className="d-grid col-sm-3 mx-auto">
|
||||
<button id="btnRemove" onClick={removeButton} className="btn btn-success">Удалить</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div className="row table-responsive text-white">
|
||||
|
||||
<table className="table mt-3 text-white">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">#</th>
|
||||
<th scope="col">CreatorName</th>
|
||||
<th scope="col">Password</th>
|
||||
<th scope="col">Mangs</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<TableCreator items = {data}/>
|
||||
{/* <tbody id="tbody">
|
||||
</tbody> */}
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
171
front/src/MainS/Manga.jsx
Normal file
@@ -0,0 +1,171 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import TableManga from '../components/Table/TableManga';
|
||||
|
||||
export default function Manga() {
|
||||
|
||||
const host = "http://localhost:8080";
|
||||
|
||||
const [creatorId, setCreatorId] = useState(0);
|
||||
|
||||
const [mangaId, setMangaId] = useState(0);
|
||||
|
||||
const [mangaName, setMangaName] = useState("");
|
||||
|
||||
const [chapterCount, setChapterCount] = useState(0);
|
||||
|
||||
|
||||
const [data, setData] = useState([]);
|
||||
|
||||
|
||||
const table = document.getElementById("tbody");
|
||||
|
||||
useEffect(() => {
|
||||
getData();
|
||||
},[]);
|
||||
|
||||
|
||||
const getData = async function () {
|
||||
const response = await fetch(host + "/manga");
|
||||
setData(await response.json())
|
||||
console.log(data);
|
||||
//table.innerHTML = "";
|
||||
// data.forEach(Manga => {
|
||||
// let temp = "<select>";
|
||||
// Manga.mangas.forEach(Manga => {
|
||||
// temp += `<option>${Manga.mangaName + " " + Manga.chapterCount}</option>>`
|
||||
// })
|
||||
// temp += "</select>"
|
||||
// table.innerHTML +=
|
||||
// `<tr>
|
||||
// <th scope="row">${Manga.id}</th>
|
||||
// <td>${Manga.mangaName}</td>
|
||||
// <td>${Manga.hashedPassword}</td>
|
||||
// <td>${temp}</td>
|
||||
// </tr>`;
|
||||
// })
|
||||
}
|
||||
|
||||
const create = async function (){
|
||||
const requestParams = {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
};
|
||||
const response = await fetch(host + `/manga?creatorId=${creatorId}&chapterCount=${chapterCount}&mangaName=${mangaName}`, requestParams);
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
const remove = async function (){
|
||||
console.info('Try to remove item');
|
||||
if (mangaId !== 0) {
|
||||
if (!confirm('Do you really want to remove this item?')) {
|
||||
console.info('Canceled');
|
||||
return;
|
||||
}
|
||||
}
|
||||
const requestParams = {
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
};
|
||||
const response = await fetch(host + `/manga/` + mangaIdInput.value, requestParams);
|
||||
console.log("REMOVE");
|
||||
getData();
|
||||
}
|
||||
|
||||
const update = async function (){
|
||||
console.info('Try to update item');
|
||||
if (mangaId === 0 || mangaName == null || password === 0) {
|
||||
return;
|
||||
}
|
||||
const requestParams = {
|
||||
method: "PUT",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
};
|
||||
const response = await fetch(host + `/manga/${mangaIdInput.value}?chapterCount=${chapterCountInput.value}`, requestParams);
|
||||
return await response.json();
|
||||
}
|
||||
const createButton = (e) =>{
|
||||
e.preventDefault()
|
||||
create().then((result) => {
|
||||
getData();
|
||||
alert(`Manga[id=${result.id}, mangaName=${result.mangaName}, chapterCount=${result.chapterCount}]`);
|
||||
});
|
||||
}
|
||||
|
||||
const removeButton = (e) =>{
|
||||
e.preventDefault()
|
||||
remove();
|
||||
getData();
|
||||
}
|
||||
|
||||
const updateButton = (e) =>{
|
||||
e.preventDefault()
|
||||
update();
|
||||
getData();
|
||||
}
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<main>
|
||||
<div className="container" id="root-div">
|
||||
<div className="content">
|
||||
<h1>Manga</h1>
|
||||
<form id="form">
|
||||
<div className="d-flex justify-content-evenly mt-3">
|
||||
<div className="col-sm-2">
|
||||
<label htmlFor="mangaId" className="form-label">creatorId</label>
|
||||
<input type='number' value = {creatorId} onChange={event => setCreatorId(event.target.value)} className="form-control"/>
|
||||
</div>
|
||||
<div className="col-sm-2">
|
||||
<label htmlFor="mangaId" className="form-label">mangaId</label>
|
||||
<input type='number' value = {mangaId} onChange={event => setMangaId(event.target.value)} className="form-control"/>
|
||||
</div>
|
||||
<div className="col-sm-2">
|
||||
<label htmlFor="mangaName" className="form-label">mangaName</label>
|
||||
<input type='text' value = {mangaName} onChange={event => setMangaName(event.target.value)} className="form-control"/>
|
||||
</div>
|
||||
<div className="col-sm-2">
|
||||
<label htmlFor="chapterCount" className="form-label">chapterCount</label>
|
||||
<input type='number' value = {chapterCount} onChange={event => setChapterCount(event.target.value)} className="form-control"/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="row mt-3">
|
||||
<div className="d-grid col-sm-3 mx-auto">
|
||||
<button type="submit" onClick={createButton} className="btn btn-success">Добавить</button>
|
||||
</div>
|
||||
<div className="d-grid col-sm-3 mx-auto">
|
||||
<button type="submit" onClick={updateButton} className="btn btn-success" id="btnUpdate" >Обновить</button>
|
||||
</div>
|
||||
<div className="d-grid col-sm-3 mx-auto">
|
||||
<button id="btnRemove" onClick={removeButton} className="btn btn-success">Удалить</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div className="row table-responsive text-white">
|
||||
|
||||
<table className="table mt-3 text-white">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">#</th>
|
||||
<th scope="col">mangaName</th>
|
||||
<th scope="col">chapterCount</th>
|
||||
<th scope="col">mangaId</th>
|
||||
<th scope="col">readers</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<TableManga items = {data}/>
|
||||
{/* <tbody id="tbody">
|
||||
</tbody> */}
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
222
front/src/MainS/Reader.jsx
Normal file
@@ -0,0 +1,222 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import TableReader from '../components/Table/TableReader';
|
||||
import MyModal from "../components/Modal/MyModal";
|
||||
import EditReaderForm from "../components/Form/EditReaderForm";
|
||||
|
||||
export default function ReaderS() {
|
||||
|
||||
const host = "http://localhost:8080";
|
||||
|
||||
const [readerId, setReaderId] = useState(0);
|
||||
|
||||
const [mangaId, setMangaId] = useState(0);
|
||||
|
||||
const [readerName, setReaderName] = useState("");
|
||||
|
||||
const [password, setPassword] = useState("");
|
||||
|
||||
const [modal, setModal] = useState(false);
|
||||
|
||||
const [data, setData] = useState([]);
|
||||
|
||||
|
||||
|
||||
|
||||
const table = document.getElementById("tbody");
|
||||
|
||||
useEffect(() => {
|
||||
getData();
|
||||
console.log(2);
|
||||
},[]);
|
||||
|
||||
|
||||
const getData = async function () {
|
||||
const response = await fetch(host + "/reader");
|
||||
setData(await response.json())
|
||||
console.log(data);
|
||||
}
|
||||
|
||||
const create = async function (){
|
||||
const requestParams = {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
};
|
||||
const response = await fetch(host + `/reader?readerName=${readerName}&password=${password}`, requestParams);
|
||||
getData();
|
||||
}
|
||||
|
||||
const remove = async function (id){
|
||||
console.info('Try to remove item');
|
||||
if (id !== 0) {
|
||||
if (!confirm('Do you really want to remove this item?')) {
|
||||
console.info('Canceled');
|
||||
return;
|
||||
}
|
||||
}
|
||||
const requestParams = {
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
};
|
||||
const response = await fetch(host + `/reader/` + id, requestParams);
|
||||
getData();
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
const removeAll = async function (){
|
||||
console.info('Try to remove item');
|
||||
if (!confirm('Do you really want to remove this item?')) {
|
||||
console.info('Canceled');
|
||||
return;
|
||||
}
|
||||
const requestParams = {
|
||||
method: "DELETE",
|
||||
};
|
||||
await fetch(host + `/reader/`, requestParams);
|
||||
getData();
|
||||
}
|
||||
|
||||
const update = async function (){
|
||||
console.info('Try to update item');
|
||||
if (readerId === 0 || readerName == null || password === 0) {
|
||||
return;
|
||||
}
|
||||
const requestParams = {
|
||||
method: "PUT",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
};
|
||||
const response = await fetch(host + `/reader/${readerId}?readerName=${readerName}&password=${password}`, requestParams);
|
||||
getData();
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
const removeManga = async function (){
|
||||
console.info('Try to remove item');
|
||||
if (!confirm('Do you really want to remove this item?')) {
|
||||
console.info('Canceled');
|
||||
return;
|
||||
}
|
||||
const requestParams = {
|
||||
method: "PUT",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
};
|
||||
console.log(host + `/reader/${readerId}/removeManga?mangaId=${mangaId}`, requestParams);
|
||||
const response = await fetch(host + `/reader/${readerId}/removeManga?mangaId=${mangaId}`, requestParams);
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
const addManga = async function () {
|
||||
const requestParams = {
|
||||
method: "PUT",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
};
|
||||
console.log(host + `/reader/${readerId}/addManga?mangaId=${mangaId}`, requestParams);
|
||||
const response = await fetch(host + `/reader/${readerId}/addManga?mangaId=${mangaId}`, requestParams);
|
||||
return await response.json();
|
||||
}
|
||||
const createButton = (e) =>{
|
||||
e.preventDefault()
|
||||
create();
|
||||
}
|
||||
|
||||
const removeButton = (id) =>{
|
||||
remove(id);
|
||||
|
||||
}
|
||||
|
||||
const updateButton = (e) =>{
|
||||
e.preventDefault()
|
||||
update();
|
||||
}
|
||||
|
||||
const removeMangaButton = (e) =>{
|
||||
e.preventDefault()
|
||||
removeManga();
|
||||
}
|
||||
|
||||
const addMangaButton = (e) =>{
|
||||
e.preventDefault()
|
||||
addManga();
|
||||
}
|
||||
|
||||
const setModal_Click = (e) =>{
|
||||
e.preventDefault()
|
||||
setModal(true)
|
||||
//setData({type:'', name:'', description:'' })
|
||||
}
|
||||
|
||||
return (
|
||||
<main>
|
||||
<div className="container" id="root-div">
|
||||
<div className="content">
|
||||
<h1>Reader</h1>
|
||||
<form id="form">
|
||||
<div className="d-flex justify-content-evenly mt-3">
|
||||
<div className="col-sm-2">
|
||||
<label htmlFor="readerId" className="form-label">readerId</label>
|
||||
<input type='number' value = {readerId} onChange={event => setReaderId(event.target.value)} className="form-control"/>
|
||||
</div>
|
||||
<div className="col-sm-2">
|
||||
<label htmlFor="mangaId" className="form-label">mangaId</label>
|
||||
<input type='number' value = {mangaId} onChange={event => setMangaId(event.target.value)} className="form-control"/>
|
||||
</div>
|
||||
<div className="col-sm-2">
|
||||
<label htmlFor="readerName" className="form-label">readerName</label>
|
||||
<input type='text' value = {readerName} onChange={event => setReaderName(event.target.value)} className="form-control"/>
|
||||
</div>
|
||||
<div className="col-sm-2">
|
||||
<label htmlFor="password" className="form-label">password</label>
|
||||
<input type='text' value = {password} onChange={event => setPassword(event.target.value)} className="form-control"/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="row m-3">
|
||||
<div className="d-grid col-sm-3 m-3 mx-auto">
|
||||
<button onClick={createButton} className="btn btn-success">Добавить</button>
|
||||
</div>
|
||||
<div className="d-grid col-sm-3 m-3 mx-auto">
|
||||
<button onClick={updateButton} className="btn btn-success">Обновить</button>
|
||||
</div>
|
||||
<div className="d-grid col-sm-2 m-3 mx-auto">
|
||||
<button onClick={removeMangaButton} className="btn btn-success">Удалить мангу</button>
|
||||
</div>
|
||||
<div className="d-grid col-sm-2 m-3 mx-auto">
|
||||
<button onClick={addMangaButton} className="btn btn-success">Добавить мангу</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div className="row table-responsive text-white">
|
||||
|
||||
<table className="table mt-3 text-white">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">#</th>
|
||||
<th scope="col">readerName</th>
|
||||
<th scope="col">Password</th>
|
||||
<th scope="col">Mangs</th>
|
||||
<th scope="col"></th>
|
||||
<th scope="col"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<TableReader
|
||||
items = {data}
|
||||
remove ={removeButton}
|
||||
update ={updateButton}
|
||||
/>
|
||||
{/* <tbody id="tbody">
|
||||
</tbody> */}
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
46
front/src/components/Banner/Banner.jsx
Normal file
@@ -0,0 +1,46 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import React from 'react'
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import banner1 from "../../../img/popular_1.jpg";
|
||||
import banner2 from "../../../img/popular_2.jpg";
|
||||
import banner3 from "../../../img/popular_3.jpg"
|
||||
|
||||
export default function Banner() {
|
||||
const length = 3;
|
||||
var old = length - 1;
|
||||
var current = 0;
|
||||
const navigate = useNavigate();
|
||||
const [bannerState, setBannerState] = useState(["show", "hide", "hide"]);
|
||||
|
||||
useEffect(() => {
|
||||
const timer = window.setInterval(() => {
|
||||
setBannerState([
|
||||
...bannerState,
|
||||
(bannerState[current] = "show"),
|
||||
(bannerState[old] = "hide"),
|
||||
]);
|
||||
//setBannerState([...bannerState, ]);
|
||||
|
||||
console.info("Banner changed");
|
||||
|
||||
old = current;
|
||||
current++;
|
||||
|
||||
if (current === length) {
|
||||
current = 0;
|
||||
}
|
||||
}, 2000);
|
||||
|
||||
return () => {
|
||||
window.clearInterval(timer);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="d-flex align-items-center flex-column" id="banner">
|
||||
<a className={bannerState[0]} style={{ cursor: "pointer" }}><img src={banner1}/></a>
|
||||
<a className={bannerState[1]} style={{ cursor: "pointer" }}><img src={banner2}/></a>
|
||||
<a className={bannerState[2]} style={{ cursor: "pointer" }}><img src={banner3}/></a>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
65
front/src/components/Banner/banner.css
Normal file
@@ -0,0 +1,65 @@
|
||||
|
||||
|
||||
#banner {
|
||||
margin: 15px;
|
||||
}
|
||||
|
||||
@keyframes newAnim {
|
||||
from { opacity: 0; }
|
||||
to { opacity: 1; }
|
||||
}
|
||||
|
||||
#banner img {
|
||||
max-width: 90%;
|
||||
border-radius: 5px;
|
||||
animation: newAnim 1s forwards;
|
||||
}
|
||||
|
||||
#banner a.show {
|
||||
text-align: center;
|
||||
display: block;
|
||||
}
|
||||
|
||||
#banner a.hide {
|
||||
display: none;
|
||||
}
|
||||
|
||||
img.show {
|
||||
max-height: 200px;
|
||||
width: auto;
|
||||
opacity: 1;
|
||||
transition: opacity 1s, visibility 0s;
|
||||
}
|
||||
|
||||
img.hide {
|
||||
max-height: 0;
|
||||
width: 0;
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
transition: opacity 1s, visibility 0s 1s;
|
||||
}
|
||||
|
||||
@media (max-width: 700px){
|
||||
#banner{width: 0px;}
|
||||
#banner_2{width: 0px;}
|
||||
#banner img.show {
|
||||
height: 0;
|
||||
width: 0;
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
transition: opacity 1s, visibility 0s 1s;
|
||||
}
|
||||
#banner h3{
|
||||
font-size: 0em;
|
||||
}
|
||||
#banner_2 h3{
|
||||
font-size: 0em;
|
||||
}
|
||||
#banner_2 img.show {
|
||||
height: 0;
|
||||
width: 0;
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
transition: opacity 1s, visibility 0s 1s;
|
||||
}
|
||||
}
|
||||
43
front/src/components/Form/EditReaderForm.jsx
Normal file
@@ -0,0 +1,43 @@
|
||||
import React from 'react';
|
||||
|
||||
const EditReaderForm =(props) => {
|
||||
|
||||
const types = ([
|
||||
{name:'Манга'},
|
||||
{name:'Манхва'},
|
||||
{name:'Маньхуа'},
|
||||
])
|
||||
|
||||
function done(e) {
|
||||
e.preventDefault();
|
||||
// if (formRef.current.checkValidity()) {
|
||||
// props.onDone();
|
||||
// props.setModalEdit();
|
||||
// props.setData({type:'', name:'', description:'' })
|
||||
// }else {
|
||||
// formRef.current.reportValidity();
|
||||
// props.setData({type:'', name:'', description:'' })
|
||||
// }
|
||||
}
|
||||
|
||||
const formRef = React.createRef();
|
||||
|
||||
return (
|
||||
<form id="frm-items" ref={formRef} className="row g-3 text-dark">
|
||||
<div className="col-md-3 ">
|
||||
</div>
|
||||
<div className="col-sm-2">
|
||||
<label htmlFor="readerName" className="form-label">readerName</label>
|
||||
<input type='text' value = {props.readerName} onChange={event => props.setReaderName(event.target.value)} className="form-control"/>
|
||||
</div>
|
||||
<div className="col-sm-2">
|
||||
<label htmlFor="password" className="form-label">password</label>
|
||||
<input type='text' value = {props.password} onChange={event => props.setPassword(event.target.value)} className="form-control"/>
|
||||
</div>
|
||||
<div className="col-md-3">
|
||||
<button onClick={() => props.update(item.id)} id="btn-add-item" className="btn btn-primary" type="submit">Изменить</button>
|
||||
</div>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
export default EditReaderForm
|
||||
27
front/src/components/Header.jsx
Normal file
@@ -0,0 +1,27 @@
|
||||
import { NavLink } from 'react-router-dom';
|
||||
|
||||
export default function Header(props) {
|
||||
return (
|
||||
<nav className="navbar navbar-expand-lg 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="collapse navbar-collapse" id="navbarNav">
|
||||
<ul className="navbar-nav">
|
||||
{props.links.map(route =>
|
||||
<li key={route.path}
|
||||
className="nav-item">
|
||||
<NavLink className="nav-link" to={route.path}>
|
||||
{route.label}
|
||||
</NavLink>
|
||||
</li>
|
||||
)}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav >
|
||||
);
|
||||
}
|
||||
36
front/src/components/List/MangaCreatorList.jsx
Normal file
@@ -0,0 +1,36 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { NavLink } from 'react-router-dom';
|
||||
import TableCreator from '../Table/TableCreator';
|
||||
import MangaDto from "../../Dto/Manga-Dto";
|
||||
|
||||
export default function MangaCreatorList(props) {
|
||||
|
||||
|
||||
return (
|
||||
<div className="row table-responsive text-white">
|
||||
{
|
||||
props.creator.mangas?.map((manga) =>
|
||||
<div key={manga.id} className="d-flex flex-row flex-wrap flex-grow-1 align-items-center mt-3">
|
||||
<div className="me-3">
|
||||
<NavLink to={`/mangapage?id=${manga.id}`} ><img src={manga.image} alt={manga.mangaName} className="slideshow" /></NavLink>
|
||||
</div>
|
||||
<div>
|
||||
<div className="pt-3 description d-flex flex-column justify-content-start mb-3 fs-6 fw-bold">
|
||||
<NavLink className="text-white fs-5 unic_class fw-bold pt-3 mb-3"
|
||||
to={`/mangapage?id=${manga.id}`}>Название: {manga.mangaName}
|
||||
</NavLink>
|
||||
<p>Глав: {manga.chapterCount}</p>
|
||||
</div>
|
||||
<div>
|
||||
<button type="button" className="btn btn-primary" onClick = {() => props.setMangaIdButton(manga.id)} data-bs-toggle="modal" data-bs-target="#exampleModal">
|
||||
<i className="fas fa-edit"></i>
|
||||
</button>
|
||||
<button className="delete bg-danger p-2 px-2 mx-2 border border-0 rounded text-white fw-bold" onClick = {() => props.removeButton(manga.id)} type="button">Удалить</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
33
front/src/components/List/MangaReaderList.jsx
Normal file
@@ -0,0 +1,33 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { NavLink } from 'react-router-dom';
|
||||
import TableCreator from '../Table/TableCreator';
|
||||
import MangaDto from "../../Dto/Manga-Dto";
|
||||
|
||||
export default function MangaReaderList(props) {
|
||||
|
||||
|
||||
return (
|
||||
<div className="row table-responsive text-white">
|
||||
{
|
||||
props.reader.mangas?.map((manga) =>
|
||||
<div key={manga.id} className="d-flex flex-row flex-wrap flex-grow-1 align-items-center mt-3">
|
||||
<div className="me-3">
|
||||
<NavLink to={`/mangapage?id=${manga.id}`} ><img src={manga.image} alt={manga.mangaName} className="slideshow" /></NavLink>
|
||||
</div>
|
||||
<div>
|
||||
<div className="pt-3 description d-flex flex-column justify-content-start mb-3 fs-6 fw-bold">
|
||||
<NavLink className="text-white fs-5 unic_class fw-bold pt-3 mb-3"
|
||||
to={`/mangapage?id=${manga.id}`}>Название: {manga.mangaName}
|
||||
</NavLink>
|
||||
<p>Глав: {manga.chapterCount}</p>
|
||||
</div>
|
||||
<div>
|
||||
<button className="delete bg-danger p-2 px-2 mx-2 border border-0 rounded text-white fw-bold" onClick = {() => props.removeButton(manga.id)} type="button">Удалить</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
24
front/src/components/List/ReaderList.jsx
Normal file
@@ -0,0 +1,24 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { NavLink } from 'react-router-dom';
|
||||
|
||||
export default function ReaderList(props) {
|
||||
|
||||
|
||||
return (
|
||||
<div className="row table-responsive text-white">
|
||||
{
|
||||
props.readers?.map((reader) =>
|
||||
<div key={reader.id} className="d-flex flex-row flex-wrap flex-grow-1 align-items-center mt-3">
|
||||
<div>
|
||||
<div className="pt-3 description d-flex flex-column justify-content-start mb-3 fs-6 fw-bold">
|
||||
<NavLink className="text-white fs-5 fw-bold pt-3 mb-3"
|
||||
to={`/readeraction?id=${reader.id}`}>Имя пользователя: {reader.readerName}
|
||||
</NavLink>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
49
front/src/components/Modal/AddMangaModal.jsx
Normal file
@@ -0,0 +1,49 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { NavLink } from 'react-router-dom';
|
||||
import TableCreator from '../Table/TableCreator';
|
||||
import MangaDto from "../../Dto/Manga-Dto";
|
||||
|
||||
export default function AddMangaModal(props) {
|
||||
|
||||
|
||||
return (
|
||||
<div className="modal fade text-black" id="exampleModal2" tabIndex="-1" aria-labelledby="exampleModalLabel2" aria-hidden="true">
|
||||
<div className="modal-dialog">
|
||||
<div className="modal-content">
|
||||
<div className="modal-header">
|
||||
<h5 className="modal-title" id="exampleModalLabel2">Создание манги</h5>
|
||||
<button type="button" className="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div>
|
||||
<label htmlFor="chapterCount" className="form-label">chapterCount</label>
|
||||
<input type='number' value = {props.chapterCount} onChange={event => props.setChapterCount(event.target.value)} className="form-control"/>
|
||||
</div>
|
||||
<div>
|
||||
<label htmlFor="mangaName" className="form-label">mangaName</label>
|
||||
<input type='text' value = {props.mangaName} onChange={event => props.setMangaName(event.target.value)} className="form-control"/>
|
||||
</div>
|
||||
<div>
|
||||
<label
|
||||
htmlFor="file-loader-button"
|
||||
className="form-label">
|
||||
Загрузить файл
|
||||
</label>
|
||||
<input
|
||||
id="file-loader-button"
|
||||
type="file"
|
||||
className="form-control text-white"
|
||||
onChange={props.handleOnChange}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="modal-footer">
|
||||
<button type="button" className="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||
<button type="button" onClick={props.createButton} className="btn btn-primary" data-bs-dismiss="modal">Save changes</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
37
front/src/components/Modal/AddMangaReaderModal.jsx
Normal file
@@ -0,0 +1,37 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { NavLink } from 'react-router-dom';
|
||||
import TableCreator from '../Table/TableCreator';
|
||||
import MangaDto from "../../Dto/Manga-Dto";
|
||||
|
||||
export default function AddMangaReaderModal(props) {
|
||||
|
||||
|
||||
return (
|
||||
<div className="modal fade text-black" id="exampleModal2" tabIndex="-1" aria-labelledby="exampleModalLabel2" aria-hidden="true">
|
||||
<div className="modal-dialog">
|
||||
<div className="modal-content">
|
||||
<div className="modal-header">
|
||||
<h5 className="modal-title" id="exampleModalLabel2">Добавление манги к читателю</h5>
|
||||
<button type="button" className="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div>
|
||||
<select className="form-select" value={props.mangaId} onChange={event => props.setMangaId(event.target.value)} aria-label="Default select example">
|
||||
<option value={0}>Manga</option>
|
||||
{
|
||||
props.mangaData.map((mangaD) =>
|
||||
<option key={mangaD.id} value={mangaD.id}>{mangaD.mangaName}</option>
|
||||
)
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div className="modal-footer">
|
||||
<button type="button" className="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||
<button type="button" onClick={props.addMangaButton} className="btn btn-primary" data-bs-dismiss="modal">Save changes</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
44
front/src/components/Modal/EditMangaModal.jsx
Normal file
@@ -0,0 +1,44 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { NavLink } from 'react-router-dom';
|
||||
import TableCreator from '../Table/TableCreator';
|
||||
import MangaDto from "../../Dto/Manga-Dto";
|
||||
|
||||
export default function EditMangaModal(props) {
|
||||
|
||||
return (
|
||||
<div className="modal fade text-black" id="exampleModal" tabIndex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
||||
<div className="modal-dialog">
|
||||
<div className="modal-content">
|
||||
<div className="modal-header">
|
||||
<h5 className="modal-title" id="exampleModalLabel">Изменение манги</h5>
|
||||
<button type="button" className="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div>
|
||||
<label htmlFor="chapterCount" className="form-label">chapterCount</label>
|
||||
<input type='number' value={props.chapterCount} onChange={event => props.setChapterCount(event.target.value)} className="form-control"/>
|
||||
</div>
|
||||
<div>
|
||||
<label
|
||||
htmlFor="file-loader-button"
|
||||
className="form-label">
|
||||
Загрузить файл
|
||||
</label>
|
||||
<input
|
||||
id="file-loader-button"
|
||||
type="file"
|
||||
className="form-control text-white"
|
||||
onChange={props.handleOnChange}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="modal-footer">
|
||||
<button type="button" className="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||
<button type="button" onClick={props.updateButton} className="btn btn-primary" data-bs-dismiss="modal">Save changes</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
23
front/src/components/Modal/MyModal.jsx
Normal file
@@ -0,0 +1,23 @@
|
||||
import cl from './MyModal.module.css';
|
||||
import React from 'react'
|
||||
const MyModal = (props) => {
|
||||
|
||||
const rootClasses = [cl.myModal]
|
||||
if(props.visible){
|
||||
rootClasses.push(cl.active);
|
||||
}
|
||||
|
||||
const setVisibleFunc = () =>{
|
||||
props.setVisible(false)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={rootClasses.join(' ')} onClick={() => setVisibleFunc()}>
|
||||
<div className={cl.MyModalContent} onClick={(e) => e.stopPropagation()}>
|
||||
{props.children}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default MyModal
|
||||
20
front/src/components/Modal/MyModal.module.css
Normal file
@@ -0,0 +1,20 @@
|
||||
.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;
|
||||
min-width:250px;
|
||||
}
|
||||
.myModal.active{
|
||||
display:flex;
|
||||
Justify-content:center;
|
||||
align-items:center;
|
||||
}
|
||||
26
front/src/components/Table/TableCreator.jsx
Normal file
@@ -0,0 +1,26 @@
|
||||
import { useState } from 'react';
|
||||
|
||||
|
||||
export default function TableCreator(props) {
|
||||
|
||||
return (
|
||||
<tbody>
|
||||
{
|
||||
props.items.map((item, index) =>
|
||||
<tr key={item.id}>
|
||||
<td>{item.id}</td>
|
||||
<td>{item.creatorName}</td>
|
||||
<td>{item.hashedPassword}</td>
|
||||
<td>
|
||||
<select className="form-select" aria-label="Default select example">{item.mangas.map(manga =>
|
||||
<option key={manga.mangaName } >{manga.mangaName + " " +manga.chapterCount}</option>)}
|
||||
</select>
|
||||
</td>
|
||||
|
||||
|
||||
</tr>
|
||||
)
|
||||
}
|
||||
</tbody >
|
||||
);
|
||||
}
|
||||
25
front/src/components/Table/TableManga.jsx
Normal file
@@ -0,0 +1,25 @@
|
||||
import { useState } from 'react';
|
||||
|
||||
|
||||
export default function TableManga(props) {
|
||||
|
||||
return (
|
||||
<tbody>
|
||||
{
|
||||
props.items.map((item, index) =>
|
||||
<tr key={item.id} >
|
||||
<td>{item.id}</td>
|
||||
<td>{item.mangaName}</td>
|
||||
<td>{item.chapterCount}</td>
|
||||
<td>{item.creatorId}</td>
|
||||
<td>
|
||||
<select className="form-select" aria-label="Default select example">{item.readers.map(reader =>
|
||||
<option key={reader.id}>{reader.readerName}</option>)}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
)
|
||||
}
|
||||
</tbody >
|
||||
);
|
||||
}
|
||||
27
front/src/components/Table/TableReader.jsx
Normal file
@@ -0,0 +1,27 @@
|
||||
import { useState } from 'react';
|
||||
|
||||
|
||||
export default function TableReader(props) {
|
||||
|
||||
return (
|
||||
<tbody>
|
||||
{
|
||||
props.items.map((item) =>
|
||||
<tr key={item.id}>
|
||||
<td>{item.id}</td>
|
||||
<td>{item.readerName}</td>
|
||||
<td>{item.hashedPassword}</td>
|
||||
<td>
|
||||
<select className="form-select" aria-label="Default select example">{item.mangas.map(manga =>
|
||||
<option key={manga.id}>{manga.mangaName}</option>)}
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<button onClick={() => props.remove(item.id)} className="btn btn-success">Удалить</button>
|
||||
</td>
|
||||
</tr>
|
||||
)
|
||||
}
|
||||
</tbody >
|
||||
);
|
||||
}
|
||||
8
front/src/main.jsx
Normal file
@@ -0,0 +1,8 @@
|
||||
import React from 'react'
|
||||
import ReactDOM from 'react-dom/client'
|
||||
import App from './App'
|
||||
import './style.css'
|
||||
|
||||
ReactDOM.createRoot(document.getElementById('app')).render(
|
||||
<App />
|
||||
)
|
||||
107
front/src/style.css
Normal file
@@ -0,0 +1,107 @@
|
||||
html,
|
||||
body {
|
||||
background-color: #000000;
|
||||
color: #ffffff;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
font-family: sans-serif;
|
||||
line-height: 1.15;
|
||||
height: 100%;
|
||||
}
|
||||
header {
|
||||
background-color: #3c3c3c;
|
||||
color: #ffffff;
|
||||
}
|
||||
header a {
|
||||
color: #ffffff;
|
||||
text-decoration: none;
|
||||
margin: 0 0.5em;
|
||||
}
|
||||
header a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
#logo {
|
||||
margin-left: 0.5em;
|
||||
}
|
||||
article a {
|
||||
color: #ffffff;
|
||||
text-decoration: none;
|
||||
margin: 0.5em 0.5em;
|
||||
}
|
||||
header a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 1.25em;
|
||||
}
|
||||
h3 {
|
||||
font-size: 1.1em;
|
||||
}
|
||||
footer {
|
||||
background-color: #9c9c9c;
|
||||
color: #ffffff;
|
||||
height: 32px;
|
||||
padding: 0.5em;
|
||||
}
|
||||
.manga_pages{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
.catalog_wrapper{
|
||||
display: flex;
|
||||
width: 73%;
|
||||
flex-direction: column;
|
||||
}
|
||||
.catalog_article{
|
||||
display: flex;
|
||||
}
|
||||
.poster{
|
||||
width:140px;
|
||||
}
|
||||
th {
|
||||
border: 0px solid rgb(255, 255, 255);
|
||||
}
|
||||
.added_manga{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
@media (min-width: 992px) {
|
||||
.manga_pages img{
|
||||
max-width: 900px;
|
||||
width: auto;
|
||||
height: auto;
|
||||
}
|
||||
}
|
||||
.flex_grow {
|
||||
flex-grow: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
@media (min-width: 1024px){
|
||||
.article_1 {
|
||||
max-width: -webkit-calc(1600px + (100vw/64*7)*2);
|
||||
max-width: -moz-calc(1600px + (100vw/64*7)*2);
|
||||
max-width: calc(1600px + (100vw/64*7)*2);
|
||||
padding-left: -webkit-calc(100vw/64*7);
|
||||
padding-left: -moz-calc(100vw/64*7);
|
||||
padding-left: calc(100vw/64*7);
|
||||
padding-right: -webkit-calc(100vw/64*7);
|
||||
padding-right: -moz-calc(100vw/64*7);
|
||||
padding-right: calc(100vw/64*7);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.registration_div {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.slideshow{
|
||||
height: 250px;
|
||||
width: auto;/*maintain aspect ratio*/
|
||||
max-width:180px;
|
||||
border-radius: 7%;
|
||||
}
|
||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
6
gradlew
vendored
@@ -205,6 +205,12 @@ set -- \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
|
||||
14
gradlew.bat
vendored
@@ -14,7 +14,7 @@
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@@ -25,7 +25,7 @@
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
@@ -75,13 +75,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
rootProject.name = 'app'
|
||||
include 'front'
|
||||
|
||||
@@ -3,9 +3,11 @@ package com.LabWork.app;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
|
||||
@SpringBootApplication
|
||||
public class AppApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(AppApplication.class, args);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.LabWork.app.MangaStore.configuration;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
|
||||
@Configuration
|
||||
public class PasswordEncoderConfiguration {
|
||||
@Bean
|
||||
public PasswordEncoder createPasswordEncoder() {
|
||||
return new BCryptPasswordEncoder();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
package com.LabWork.app.MangaStore.configuration;
|
||||
|
||||
import com.LabWork.app.MangaStore.controller.User.UserSignupMvcController;
|
||||
import com.LabWork.app.MangaStore.model.Default.UserRole;
|
||||
import com.LabWork.app.MangaStore.service.UserService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer;
|
||||
import org.springframework.security.web.SecurityFilterChain;
|
||||
|
||||
@Configuration
|
||||
@EnableWebSecurity
|
||||
@EnableGlobalMethodSecurity(securedEnabled = true)
|
||||
public class SecurityConfiguration {
|
||||
private final Logger log = LoggerFactory.getLogger(SecurityConfiguration.class);
|
||||
private static final String LOGIN_URL = "/login";
|
||||
private final UserService userService;
|
||||
|
||||
public SecurityConfiguration(UserService userService) {
|
||||
this.userService = userService;
|
||||
createAdminOnStartup();
|
||||
}
|
||||
|
||||
private void createAdminOnStartup() {
|
||||
final String admin = "admin";
|
||||
if (userService.findByLogin(admin) == null) {
|
||||
log.info("Admin user successfully created");
|
||||
userService.createUser(admin, admin, admin, UserRole.ADMIN);
|
||||
}
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
||||
http.headers().frameOptions().sameOrigin().and()
|
||||
.cors().and()
|
||||
.csrf().disable()
|
||||
.authorizeHttpRequests()
|
||||
.requestMatchers(UserSignupMvcController.SIGNUP_URL).permitAll()
|
||||
.requestMatchers(HttpMethod.GET, LOGIN_URL).permitAll()
|
||||
.anyRequest().authenticated()
|
||||
.and()
|
||||
.formLogin()
|
||||
.loginPage(LOGIN_URL).permitAll()
|
||||
.and()
|
||||
.logout().permitAll();
|
||||
return http.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuthenticationManager authenticationManagerBean(HttpSecurity http) throws Exception {
|
||||
AuthenticationManagerBuilder authenticationManagerBuilder = http
|
||||
.getSharedObject(AuthenticationManagerBuilder.class);
|
||||
authenticationManagerBuilder.userDetailsService(userService);
|
||||
return authenticationManagerBuilder.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public WebSecurityCustomizer webSecurityCustomizer() {
|
||||
return web -> web.ignoring()
|
||||
.requestMatchers("/css/**")
|
||||
.requestMatchers("/js/**")
|
||||
.requestMatchers("/templates/**")
|
||||
.requestMatchers("/webjars/**")
|
||||
.requestMatchers("/vk.jpg");
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.LabWork.app.MangaStore.configuration;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.servlet.config.annotation.*;
|
||||
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
||||
|
||||
@Configuration
|
||||
public class WebConfiguration implements WebMvcConfigurer {
|
||||
public static final String REST_API = "/api";
|
||||
|
||||
@Override
|
||||
public void addViewControllers(ViewControllerRegistry registry) {
|
||||
WebMvcConfigurer.super.addViewControllers(registry);
|
||||
registry.addViewController("login");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configurePathMatch(PathMatchConfigurer configurer) {
|
||||
configurer.setUseTrailingSlashMatch(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**").allowedMethods("*");
|
||||
}
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
package com.LabWork.app.MangaStore.controller.Creator;
|
||||
|
||||
import com.LabWork.app.MangaStore.model.Dto.CreatorMangaDto;
|
||||
import com.LabWork.app.MangaStore.model.Dto.SupportDto.MangaDto;
|
||||
import com.LabWork.app.MangaStore.service.CreatorService;
|
||||
import com.LabWork.app.MangaStore.service.MangaService;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import com.LabWork.app.MangaStore.model.Default.UserRole;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.security.access.annotation.Secured;
|
||||
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 java.io.IOException;
|
||||
import java.security.Principal;
|
||||
import java.util.Base64;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/creatorAction")
|
||||
@Secured({UserRole.AsString.ADMIN})
|
||||
public class CreatorActionMvcController {
|
||||
private final CreatorService creatorService;
|
||||
private static final Logger log = LoggerFactory.getLogger(CreatorActionMvcController.class);
|
||||
private final MangaService mangaService;
|
||||
|
||||
public CreatorActionMvcController(CreatorService creatorService, MangaService mangaService) {
|
||||
this.creatorService = creatorService;
|
||||
this.mangaService = mangaService;
|
||||
}
|
||||
|
||||
@GetMapping()
|
||||
public String getCreator(Model model, Principal principal) {
|
||||
model.addAttribute("creators",
|
||||
creatorService.findAllCreators().stream()
|
||||
.map(CreatorMangaDto::new)
|
||||
.toList());
|
||||
CreatorMangaDto currentCreator = new CreatorMangaDto(creatorService.findByLogin(principal.getName()));
|
||||
model.addAttribute("currentCreator", currentCreator);
|
||||
return "creatorAction";
|
||||
}
|
||||
|
||||
@GetMapping("/edit/{id}")
|
||||
public String editManga(@PathVariable Long id, Model model, Principal principal) {
|
||||
if (principal.getName().equals(principal.getName())) {
|
||||
model.addAttribute("Id", id);
|
||||
model.addAttribute("mangaDto", new MangaDto(mangaService.findManga(id)));
|
||||
model.addAttribute("controller", "manga/");
|
||||
return "creatorAction-edit";
|
||||
}
|
||||
return "creatorAction";
|
||||
}
|
||||
|
||||
@GetMapping("/create")
|
||||
public String createManga(Model model, Principal principal) {
|
||||
model.addAttribute("mangaDto", new MangaDto());
|
||||
model.addAttribute("controller", "creator/");
|
||||
return "creatorAction-edit";
|
||||
}
|
||||
|
||||
@PostMapping( "/creator")
|
||||
public String saveManga(@RequestParam("multipartFile") MultipartFile multipartFile,
|
||||
@ModelAttribute @Valid MangaDto mangaDto,
|
||||
BindingResult bindingResult,
|
||||
Model model,
|
||||
Principal principal) throws IOException {
|
||||
if (bindingResult.hasErrors()) {
|
||||
model.addAttribute("errors", bindingResult.getAllErrors());
|
||||
return "creatorAction-edit";
|
||||
}
|
||||
mangaDto.setImage("data:" + multipartFile.getContentType() + ";base64," + Base64.getEncoder().encodeToString(multipartFile.getBytes()));
|
||||
mangaDto.setLogin(principal.getName());
|
||||
mangaService.addManga(mangaDto);
|
||||
return "redirect:/creatorAction";
|
||||
}
|
||||
|
||||
@PostMapping( "/manga/{mangaId}")
|
||||
public String updateManga(@PathVariable(value = "mangaId", required = false) Long mangaId, @RequestParam("multipartFile") MultipartFile multipartFile,
|
||||
@ModelAttribute @Valid MangaDto mangaDto,
|
||||
BindingResult bindingResult,
|
||||
Model model,
|
||||
Principal principal) throws IOException {
|
||||
if (bindingResult.hasErrors()) {
|
||||
model.addAttribute("errors", bindingResult.getAllErrors());
|
||||
return "creatorAction-edit";
|
||||
}
|
||||
mangaDto.setImage("data:" + multipartFile.getContentType() + ";base64," + Base64.getEncoder().encodeToString(multipartFile.getBytes()));
|
||||
mangaService.updateManga(mangaId, mangaDto.getChapterCount(), mangaDto.getImage());
|
||||
return "redirect:/creatorAction";
|
||||
}
|
||||
|
||||
@PostMapping("/delete/{mangaId}")
|
||||
public String deleteCreator(@PathVariable Long mangaId, Principal principal) {
|
||||
Long creatorId = mangaService.findManga(mangaId).getCreatorId();
|
||||
mangaService.deleteManga(mangaId);
|
||||
if (creatorId != null){
|
||||
return "redirect:/creatorAction";
|
||||
} else {
|
||||
return "redirect:/creatorAction";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.LabWork.app.MangaStore.controller;
|
||||
|
||||
import com.LabWork.app.MangaStore.model.Dto.CreatorMangaDto;
|
||||
import com.LabWork.app.MangaStore.service.CreatorService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/creator")
|
||||
public class CreatorController {
|
||||
private final CreatorService creatorService;
|
||||
|
||||
public CreatorController(CreatorService creatorService) {
|
||||
this.creatorService = creatorService;
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public CreatorMangaDto getCreator(@PathVariable Long id) {
|
||||
return new CreatorMangaDto(creatorService.findCreator(id));
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public List<CreatorMangaDto> getCreators() {
|
||||
return creatorService.findAllCreators().stream()
|
||||
.map(CreatorMangaDto::new)
|
||||
.toList();
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public CreatorMangaDto createCreator(@RequestParam("creatorName") String creatorName,
|
||||
@RequestParam("password") String password) {
|
||||
return new CreatorMangaDto(creatorService.addCreator(creatorName, password));
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public CreatorMangaDto updateCreator(@PathVariable Long id,
|
||||
@RequestParam("creatorName") String creatorName,
|
||||
@RequestParam("password") String password) {
|
||||
return new CreatorMangaDto(creatorService.updateCreator(id, creatorName, password));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public CreatorMangaDto deleteCreator(@PathVariable Long id) {
|
||||
//creatorService.deleteAllCreators();
|
||||
return new CreatorMangaDto(creatorService.deleteCreator(id));
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
public void deleteAllCreator() {
|
||||
creatorService.deleteAllCreators();
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package com.LabWork.app.MangaStore.controller.Manga;
|
||||
|
||||
import com.LabWork.app.MangaStore.model.Dto.MangaReaderDto;
|
||||
import com.LabWork.app.MangaStore.model.Dto.ReaderMangaDto;
|
||||
import com.LabWork.app.MangaStore.model.Dto.SupportDto.MangaDto;
|
||||
import com.LabWork.app.MangaStore.service.MangaService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/manga")
|
||||
public class MangaMvcController {
|
||||
private final MangaService mangaService;
|
||||
|
||||
public MangaMvcController(MangaService mangaService) {
|
||||
this.mangaService = mangaService;
|
||||
}
|
||||
|
||||
@GetMapping()
|
||||
public String getMangaAndReaders(Model model) {
|
||||
model.addAttribute("mangaList", mangaService.findAllMangas().stream()
|
||||
.map(x -> new MangaDto(x))
|
||||
.toList());
|
||||
return "catalog";
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public String getMangaAndReaders(@PathVariable Long id, Model model) {
|
||||
model.addAttribute("manga", new MangaReaderDto(mangaService.findManga(id), mangaService.getReader(id)));
|
||||
model.addAttribute("readers", mangaService.getReader(id).stream()
|
||||
.map(x -> new ReaderMangaDto(x))
|
||||
.toList());
|
||||
return "mangaPage";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.LabWork.app.MangaStore.controller;
|
||||
|
||||
|
||||
import com.LabWork.app.MangaStore.model.Dto.MangaReaderDto;
|
||||
import com.LabWork.app.MangaStore.model.Dto.ReaderMangaDto;
|
||||
import com.LabWork.app.MangaStore.model.Dto.SupportDto.MangaDto;
|
||||
import com.LabWork.app.MangaStore.service.CreatorService;
|
||||
import com.LabWork.app.MangaStore.service.MangaService;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/manga")
|
||||
public class MangaController {
|
||||
private final MangaService mangaService;
|
||||
private final CreatorService creatorService;
|
||||
public MangaController(MangaService mangaService,
|
||||
CreatorService creatorService) {
|
||||
this.mangaService = mangaService;
|
||||
this.creatorService = creatorService;
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public MangaReaderDto getManga(@PathVariable Long id) {
|
||||
return new MangaReaderDto(mangaService.findManga(id), mangaService.getReader(id));
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public List<MangaReaderDto> getMangas() {
|
||||
return mangaService.findAllMangas().stream()
|
||||
.map(x -> new MangaReaderDto(x, mangaService.getReader(x.getId())))
|
||||
.toList();
|
||||
}
|
||||
|
||||
@GetMapping("/{id}/readers")
|
||||
public List<ReaderMangaDto> getReaders(@PathVariable Long id) {
|
||||
return mangaService.getReader(id).stream()
|
||||
.map(x -> new ReaderMangaDto(x))
|
||||
.toList();
|
||||
}
|
||||
/*
|
||||
@PostMapping
|
||||
public MangaReaderDto createManga(@RequestParam("creatorId") Long creatorId,
|
||||
@RequestParam("chapterCount") Integer chapterCount,
|
||||
@RequestParam("mangaName") String mangaName) {
|
||||
return new MangaReaderDto(mangaService.addManga(creatorId, chapterCount, mangaName), mangaService.getReader(creatorId));
|
||||
}*/
|
||||
|
||||
/* @PutMapping("/{id}")
|
||||
public MangaReaderDto updateManga(@PathVariable Long id,
|
||||
@RequestParam("chapterCount") Integer chapterCount) {
|
||||
return new MangaReaderDto(mangaService.updateManga(id, chapterCount), mangaService.getReader(id));
|
||||
}*/
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public MangaDto deleteManga(@PathVariable Long id) {
|
||||
return new MangaDto(mangaService.deleteManga(id));
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public MangaDto createManga(@RequestBody @Valid MangaDto mangaDto) {
|
||||
return new MangaDto(creatorService.addManga(mangaDto));
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public MangaDto updateManga(@RequestBody @Valid MangaDto mangaDto) {
|
||||
return new MangaDto(mangaService.updateManga(mangaDto));
|
||||
}
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
package com.LabWork.app.MangaStore.controller.Reader;
|
||||
|
||||
import com.LabWork.app.MangaStore.model.Dto.CreatorMangaDto;
|
||||
import com.LabWork.app.MangaStore.model.Dto.ReaderMangaDto;
|
||||
import com.LabWork.app.MangaStore.model.Dto.SupportDto.MangaDto;
|
||||
import com.LabWork.app.MangaStore.service.ReaderService;
|
||||
import com.LabWork.app.MangaStore.service.MangaService;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import com.LabWork.app.MangaStore.model.Default.UserRole;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.security.access.annotation.Secured;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.security.Principal;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/readerAction")
|
||||
@Secured({UserRole.AsString.USER})
|
||||
public class ReaderActionMvcController {
|
||||
private final ReaderService readerService;
|
||||
private static final Logger log = LoggerFactory.getLogger(ReaderActionMvcController.class);
|
||||
private final MangaService mangaService;
|
||||
|
||||
public ReaderActionMvcController(ReaderService readerService, MangaService mangaService) {
|
||||
this.readerService = readerService;
|
||||
this.mangaService = mangaService;
|
||||
}
|
||||
|
||||
@GetMapping()
|
||||
public String getReader(Model model, Principal principal) {
|
||||
model.addAttribute("readers",
|
||||
readerService.findAllReaders().stream()
|
||||
.map(ReaderMangaDto::new)
|
||||
.toList());
|
||||
ReaderMangaDto currentReader = new ReaderMangaDto(readerService.findByLogin(principal.getName()));
|
||||
model.addAttribute("readerId", currentReader.getId());
|
||||
model.addAttribute("reader", new ReaderMangaDto(readerService.findReader(currentReader.getId())));
|
||||
model.addAttribute("MangaDto", new MangaDto());
|
||||
model.addAttribute("mangaList", mangaService.findAllMangas());
|
||||
return "readerAction";
|
||||
}
|
||||
|
||||
/* @GetMapping()
|
||||
public String getReader(@RequestParam(value = "readerId", required = false) Long readerId, Model model) {
|
||||
model.addAttribute("readers",
|
||||
readerService.findAllReaders().stream()
|
||||
.map(ReaderMangaDto::new)
|
||||
.toList());
|
||||
if (readerId != null){
|
||||
model.addAttribute("readerId", readerId);
|
||||
model.addAttribute("reader", new ReaderMangaDto(readerService.findReader(readerId)));
|
||||
} else {
|
||||
model.addAttribute("readerId", 0);
|
||||
model.addAttribute("reader", new ReaderMangaDto());
|
||||
}
|
||||
model.addAttribute("MangaDto", new MangaDto());
|
||||
model.addAttribute("mangaList", mangaService.findAllMangas());
|
||||
return "readerAction";
|
||||
}*/
|
||||
|
||||
@PostMapping("/manga")
|
||||
public String saveManga(@RequestParam("mangaId") Long mangaId,
|
||||
@ModelAttribute @Valid MangaDto MangaDto,
|
||||
BindingResult bindingResult,
|
||||
Model model,
|
||||
Principal principal){
|
||||
if (bindingResult.hasErrors()) {
|
||||
model.addAttribute("errors", bindingResult.getAllErrors());
|
||||
return "readerAction";
|
||||
}
|
||||
readerService.addManga(mangaId, principal.getName());
|
||||
return "redirect:/readerAction";
|
||||
}
|
||||
|
||||
@PostMapping("/removeManga/{mangaId}")
|
||||
public String removeManga(@PathVariable Long mangaId, Principal principal) {
|
||||
readerService.removeManga(mangaId, principal.getName());
|
||||
return "redirect:/readerAction/?readerLogin=" + principal.getName();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.LabWork.app.MangaStore.controller;
|
||||
|
||||
|
||||
import com.LabWork.app.MangaStore.model.Dto.ReaderMangaDto;
|
||||
import com.LabWork.app.MangaStore.model.Dto.SupportDto.MangaDto;
|
||||
import com.LabWork.app.MangaStore.service.CreatorService;
|
||||
import com.LabWork.app.MangaStore.service.MangaService;
|
||||
import com.LabWork.app.MangaStore.service.ReaderService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/reader")
|
||||
public class ReaderController {
|
||||
private final ReaderService readerService;
|
||||
private final MangaService mangaService;
|
||||
|
||||
public ReaderController(ReaderService readerService,
|
||||
MangaService mangaService) {
|
||||
this.readerService = readerService;
|
||||
this.mangaService = mangaService;
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ReaderMangaDto getReader(@PathVariable Long id) {
|
||||
return new ReaderMangaDto(readerService.findReader(id));
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public List<ReaderMangaDto> getReaders() {
|
||||
return readerService.findAllReaders().stream()
|
||||
.map(ReaderMangaDto::new)
|
||||
.toList();
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public ReaderMangaDto createReader(@RequestParam("readerName") String readerName,
|
||||
@RequestParam("password") String password) {
|
||||
return new ReaderMangaDto(readerService.addReader(readerName, password));
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public ReaderMangaDto updateReader(@PathVariable Long id,
|
||||
@RequestParam("readerName") String readerName,
|
||||
@RequestParam("password") String password) {
|
||||
return new ReaderMangaDto(readerService.updateReader(id, readerName, password));
|
||||
}
|
||||
|
||||
@PutMapping("/{id}/addManga")
|
||||
public MangaDto addManga(@PathVariable Long id,
|
||||
@RequestParam("mangaId") Long mangaId) {
|
||||
return new MangaDto(mangaService.addMangaToReader(mangaId, id));
|
||||
}
|
||||
|
||||
@PutMapping("/{id}/removeManga")
|
||||
public MangaDto removeManga(@PathVariable Long id,
|
||||
@RequestParam("mangaId") Long mangaId) {
|
||||
return new MangaDto(mangaService.removeMangaToReader(mangaId, id));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public ReaderMangaDto deleteReader(@PathVariable Long id) {
|
||||
return new ReaderMangaDto(readerService.deleteReader(id));
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package com.LabWork.app.MangaStore.controller.User;
|
||||
|
||||
import com.LabWork.app.MangaStore.model.Dto.UserDto;
|
||||
import com.LabWork.app.MangaStore.model.Default.UserRole;
|
||||
import com.LabWork.app.MangaStore.service.UserService;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.security.access.annotation.Secured;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/users")
|
||||
public class UserMvcController {
|
||||
private final UserService userService;
|
||||
|
||||
public UserMvcController(UserService userService) {
|
||||
this.userService = userService;
|
||||
}
|
||||
|
||||
@Secured({UserRole.AsString.ADMIN})
|
||||
@GetMapping
|
||||
public String getUsers(@RequestParam(defaultValue = "1") int page,
|
||||
@RequestParam(defaultValue = "5") int size,
|
||||
Model model) {
|
||||
final Page<UserDto> users = userService.findAllPages(page, size)
|
||||
.map(UserDto::new);
|
||||
model.addAttribute("users", users);
|
||||
final int totalPages = users.getTotalPages();
|
||||
final List<Integer> pageNumbers = IntStream.rangeClosed(1, totalPages)
|
||||
.boxed()
|
||||
.toList();
|
||||
model.addAttribute("pages", pageNumbers);
|
||||
model.addAttribute("totalPages", totalPages);
|
||||
return "users";
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package com.LabWork.app.MangaStore.controller.User;
|
||||
|
||||
import com.LabWork.app.MangaStore.model.Default.User;
|
||||
import com.LabWork.app.MangaStore.model.Dto.UserSignupDto;
|
||||
import com.LabWork.app.MangaStore.service.UserService;
|
||||
import com.LabWork.app.MangaStore.util.validation.ValidationException;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
@Controller
|
||||
@RequestMapping(UserSignupMvcController.SIGNUP_URL)
|
||||
public class UserSignupMvcController {
|
||||
public static final String SIGNUP_URL = "/signup";
|
||||
|
||||
private final UserService userService;
|
||||
|
||||
public UserSignupMvcController(UserService userService) {
|
||||
this.userService = userService;
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public String showSignupForm(Model model) {
|
||||
model.addAttribute("userDto", new UserSignupDto());
|
||||
return "signup";
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public String signup(@ModelAttribute("userDto") @Valid UserSignupDto userSignupDto,
|
||||
BindingResult bindingResult,
|
||||
Model model) {
|
||||
if (bindingResult.hasErrors()) {
|
||||
model.addAttribute("errors", bindingResult.getAllErrors());
|
||||
return "signup";
|
||||
}
|
||||
try {
|
||||
final User user = userService.createUser(
|
||||
userSignupDto.getLogin(), userSignupDto.getPassword(), userSignupDto.getPasswordConfirm(), userSignupDto.getUserRole());
|
||||
return "redirect:/login?created=" + user.getLogin();
|
||||
} catch (ValidationException e) {
|
||||
model.addAttribute("errors", e.getMessage());
|
||||
return "signup";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.LabWork.app.MangaStore.model.Default;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -9,11 +10,16 @@ import java.util.Objects;
|
||||
@Entity
|
||||
public class Creator {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@OneToOne(fetch = FetchType.EAGER)
|
||||
@MapsId
|
||||
private User user;
|
||||
@NotBlank(message = "creatorName can't be null or empty")
|
||||
@Column
|
||||
private String creatorName;
|
||||
|
||||
@NotBlank(message = "hashedPassword can't be null or empty")
|
||||
@Column
|
||||
private String hashedPassword;
|
||||
|
||||
@OneToMany(fetch = FetchType.EAGER, mappedBy = "creator", cascade = CascadeType.REMOVE)
|
||||
private List<Manga> mangas;
|
||||
@@ -21,9 +27,9 @@ public class Creator {
|
||||
public Creator() {
|
||||
}
|
||||
|
||||
public Creator(User user) {
|
||||
this.user = user;
|
||||
this.id = user.getId();
|
||||
public Creator(String creatorName, String hashedPassword) {
|
||||
this.creatorName = creatorName;
|
||||
this.hashedPassword = hashedPassword;
|
||||
this.mangas = new ArrayList<>();
|
||||
}
|
||||
|
||||
@@ -35,11 +41,25 @@ public class Creator {
|
||||
return mangas;
|
||||
}
|
||||
|
||||
public String getCreatorName() {
|
||||
return creatorName;
|
||||
}
|
||||
|
||||
public String getHashedPassword() {
|
||||
return hashedPassword;
|
||||
}
|
||||
|
||||
public void setMangas(List<Manga> mangas) {
|
||||
this.mangas = mangas;
|
||||
}
|
||||
|
||||
public User getUser() { return user; }
|
||||
public void setCreatorName(String creatorName) {
|
||||
this.creatorName = creatorName;
|
||||
}
|
||||
|
||||
public void setHashedPassword(String hashedPassword) {
|
||||
this.hashedPassword = hashedPassword;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
@@ -58,6 +78,8 @@ public class Creator {
|
||||
public String toString() {
|
||||
return "Creator{" +
|
||||
"id=" + id +
|
||||
", creatorName='" + creatorName + '\'' +
|
||||
", hashedPassword='" + hashedPassword + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,16 +25,19 @@ public class Manga {
|
||||
@JoinColumn(name="creator_fk")
|
||||
private Creator creator;
|
||||
|
||||
private Long creatorId;
|
||||
|
||||
@Lob
|
||||
private byte[] image;
|
||||
public Manga() {
|
||||
}
|
||||
|
||||
public Manga(Creator creator, String mangaName, Integer chapterCount, String image) {
|
||||
public Manga(Creator creator, String mangaName, Integer chapterCount) {
|
||||
this.creator = creator;
|
||||
this.creatorId = creatorId;
|
||||
this.mangaName = mangaName;
|
||||
this.chapterCount = chapterCount;
|
||||
this.image = image.getBytes();
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
public Manga(Creator creator, MangaDto mangaDto) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.LabWork.app.MangaStore.model.Default;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import org.hibernate.annotations.Cascade;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -9,11 +10,14 @@ import java.util.Objects;
|
||||
@Entity
|
||||
public class Reader {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@OneToOne(fetch = FetchType.LAZY)
|
||||
@MapsId
|
||||
private User user;
|
||||
@Column
|
||||
private String readerName;
|
||||
|
||||
@Column
|
||||
private String hashedPassword;
|
||||
|
||||
@ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.MERGE)
|
||||
/*@Cascade(value = org.hibernate.annotations.CascadeType.DELETE_ORPHAN)*/
|
||||
@@ -23,15 +27,9 @@ public class Reader {
|
||||
public Reader() {
|
||||
}
|
||||
|
||||
public Reader(String creatorName, String hashedPassword) {
|
||||
this.user = user;
|
||||
this.id = user.getId();
|
||||
this.mangas = new ArrayList<>();
|
||||
}
|
||||
|
||||
public Reader(User user) {
|
||||
this.user = user;
|
||||
this.id = user.getId();
|
||||
public Reader(String readerName, String hashedPassword) {
|
||||
this.readerName = readerName;
|
||||
this.hashedPassword = hashedPassword;
|
||||
this.mangas = new ArrayList<>();
|
||||
}
|
||||
|
||||
@@ -39,12 +37,20 @@ public class Reader {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getReaderName() { return readerName; }
|
||||
|
||||
public void setReaderName(String readerName) { this.readerName = readerName; }
|
||||
|
||||
public String getHashedPassword() { return hashedPassword; }
|
||||
|
||||
public void setHashedPassword(String hashedPassword) { this.hashedPassword = hashedPassword; }
|
||||
|
||||
public List<Manga> getMangas() { return mangas; }
|
||||
|
||||
public void setMangas(List<Manga> mangas) { this.mangas = mangas; }
|
||||
|
||||
public User getUser() { return user; }
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
@@ -62,6 +68,8 @@ public class Reader {
|
||||
public String toString() {
|
||||
return "Reader{" +
|
||||
"id=" + id +
|
||||
", readerName='" + readerName + '\'' +
|
||||
", hashedPassword='" + hashedPassword + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
package com.LabWork.app.MangaStore.model.Default;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name = "users")
|
||||
public class User {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private Long id;
|
||||
@Column(nullable = false, unique = true, length = 64)
|
||||
@NotBlank
|
||||
@Size(min = 3, max = 64)
|
||||
private String login;
|
||||
@Column(nullable = false, length = 64)
|
||||
@NotBlank
|
||||
@Size(min = 6, max = 64)
|
||||
private String password;
|
||||
private UserRole role;
|
||||
|
||||
public User() {
|
||||
}
|
||||
|
||||
public User(String login, String password) {
|
||||
this(login, password, UserRole.USER);
|
||||
}
|
||||
|
||||
public User(String login, String password, UserRole role) {
|
||||
this.login = login;
|
||||
this.password = password;
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getLogin() {
|
||||
return login;
|
||||
}
|
||||
|
||||
public void setLogin(String login) {
|
||||
this.login = login;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public UserRole getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
@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) && Objects.equals(login, user.login);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, login);
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.LabWork.app.MangaStore.model.Default;
|
||||
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
|
||||
public enum UserRole implements GrantedAuthority {
|
||||
ADMIN,
|
||||
USER;
|
||||
|
||||
private static final String PREFIX = "ROLE_";
|
||||
|
||||
@Override
|
||||
public String getAuthority() {
|
||||
return PREFIX + this.name();
|
||||
}
|
||||
|
||||
public static final class AsString {
|
||||
public static final String ADMIN = PREFIX + "ADMIN";
|
||||
public static final String USER = PREFIX + "USER";
|
||||
}
|
||||
}
|
||||
@@ -6,18 +6,15 @@ import com.LabWork.app.MangaStore.model.Dto.SupportDto.MangaDto;
|
||||
import java.util.List;
|
||||
|
||||
public class CreatorMangaDto {
|
||||
private long id;
|
||||
private String creatorName;
|
||||
private String hashedPassword;
|
||||
private List<MangaDto> mangas;
|
||||
|
||||
public CreatorMangaDto() {
|
||||
}
|
||||
private final long id;
|
||||
private final String creatorName;
|
||||
private final String hashedPassword;
|
||||
private final List<MangaDto> mangas;
|
||||
|
||||
public CreatorMangaDto(Creator creator) {
|
||||
this.id = creator.getId();
|
||||
this.creatorName = creator.getUser().getLogin();
|
||||
this.hashedPassword = creator.getUser().getPassword();
|
||||
this.creatorName = creator.getCreatorName();
|
||||
this.hashedPassword = creator.getHashedPassword();
|
||||
this.mangas = creator.getMangas().stream()
|
||||
.map(x -> new MangaDto(x))
|
||||
.toList();
|
||||
@@ -36,16 +33,4 @@ public class CreatorMangaDto {
|
||||
}
|
||||
|
||||
public List<MangaDto> getMangas() { return mangas; }
|
||||
|
||||
public void setCreatorName(String creatorName) {
|
||||
this.creatorName = creatorName;
|
||||
}
|
||||
|
||||
public void setHashedPassword(String hashedPassword) {
|
||||
this.hashedPassword = hashedPassword;
|
||||
}
|
||||
|
||||
public void setMangas(List<MangaDto> mangas) {
|
||||
this.mangas = mangas;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,24 +3,20 @@ package com.LabWork.app.MangaStore.model.Dto;
|
||||
import com.LabWork.app.MangaStore.model.Default.Creator;
|
||||
import com.LabWork.app.MangaStore.model.Default.Manga;
|
||||
import com.LabWork.app.MangaStore.model.Default.Reader;
|
||||
import com.LabWork.app.MangaStore.model.Dto.SupportDto.MangaDto;
|
||||
import com.LabWork.app.MangaStore.model.Dto.SupportDto.ReaderDto;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
public class MangaReaderDto {
|
||||
private Long id;
|
||||
private final Long id;
|
||||
|
||||
private Long creatorId;
|
||||
private String mangaName;
|
||||
private Integer chapterCount;
|
||||
private List<ReaderDto> readers;
|
||||
private final Long creatorId;
|
||||
private final String mangaName;
|
||||
private final Integer chapterCount;
|
||||
private final List<ReaderDto> readers;
|
||||
private String image;
|
||||
|
||||
public MangaReaderDto() {
|
||||
}
|
||||
|
||||
public MangaReaderDto(Manga manga, List<Reader> listReader) {
|
||||
this.id = manga.getId();
|
||||
this.creatorId = manga.getCreator().getId();
|
||||
@@ -56,21 +52,4 @@ public class MangaReaderDto {
|
||||
return creatorId;
|
||||
}
|
||||
|
||||
public void setImage(String image) {
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
public void setMangaName(String mangaName) {
|
||||
this.mangaName = mangaName;
|
||||
}
|
||||
|
||||
public void setReaders(List<ReaderDto> readers) {
|
||||
this.readers = readers;
|
||||
}
|
||||
|
||||
public void setChapterCount(Integer chapterCount) {
|
||||
this.chapterCount = chapterCount;
|
||||
}
|
||||
|
||||
public void setCreatorIdString(Long creatorId) {this.creatorId = creatorId;}
|
||||
}
|
||||
|
||||
@@ -14,13 +14,10 @@ public class ReaderMangaDto {
|
||||
|
||||
private List<MangaDto> mangas;
|
||||
|
||||
public ReaderMangaDto() {
|
||||
}
|
||||
|
||||
public ReaderMangaDto(Reader reader) {
|
||||
this.id = reader.getId();
|
||||
this.readerName = reader.getUser().getLogin();
|
||||
this.hashedPassword = reader.getUser().getPassword();
|
||||
this.readerName = reader.getReaderName();
|
||||
this.hashedPassword = reader.getHashedPassword();
|
||||
this.mangas = reader.getMangas().stream()
|
||||
.map(y -> new MangaDto(y))
|
||||
.toList();
|
||||
@@ -36,16 +33,4 @@ public class ReaderMangaDto {
|
||||
|
||||
public List<MangaDto> getMangas() { return mangas; }
|
||||
|
||||
public void setReaderName(String readerName) {
|
||||
this.readerName = readerName;
|
||||
}
|
||||
|
||||
public void setHashedPassword(String hashedPassword) {
|
||||
this.hashedPassword = hashedPassword;
|
||||
}
|
||||
|
||||
public void setMangas(List<MangaDto> mangas) {
|
||||
this.mangas = mangas;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,19 +14,16 @@ public class MangaDto {
|
||||
private Integer chapterCount;
|
||||
private String image;
|
||||
|
||||
private String login;
|
||||
|
||||
public MangaDto() {
|
||||
}
|
||||
|
||||
public MangaDto(Manga manga) {
|
||||
this.id = manga.getId();
|
||||
this.creatorId = manga.getCreator().getId();
|
||||
this.mangaName = manga.getMangaName();
|
||||
this.chapterCount = manga.getChapterCount();
|
||||
this.login = null;
|
||||
this.image = new String(manga.getImage(), StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
public MangaDto() {
|
||||
}
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
@@ -47,27 +44,4 @@ public class MangaDto {
|
||||
return image;
|
||||
}
|
||||
|
||||
public String getLogin() {
|
||||
return login;
|
||||
}
|
||||
|
||||
public void setMangaName(String mangaName) {
|
||||
this.mangaName = mangaName;
|
||||
}
|
||||
|
||||
public void setChapterCount(Integer chapterCount) {
|
||||
this.chapterCount = chapterCount;
|
||||
}
|
||||
|
||||
public void setCreatorId(Long creatorId) {
|
||||
this.creatorId = creatorId;
|
||||
}
|
||||
|
||||
public void setImage(String image) {this.image = image;}
|
||||
|
||||
public void setLogin(String login) {
|
||||
this.login = login;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -11,13 +11,10 @@ public class ReaderDto {
|
||||
|
||||
private String hashedPassword;
|
||||
|
||||
public ReaderDto() {
|
||||
}
|
||||
|
||||
public ReaderDto(Reader reader) {
|
||||
this.id = reader.getId();
|
||||
this.readerName = reader.getUser().getLogin();
|
||||
this.hashedPassword = reader.getUser().getPassword();
|
||||
this.readerName = reader.getReaderName();
|
||||
this.hashedPassword = reader.getHashedPassword();
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
@@ -27,12 +24,4 @@ public class ReaderDto {
|
||||
public String getReaderName() { return readerName; }
|
||||
|
||||
public String getHashedPassword() { return hashedPassword; }
|
||||
|
||||
public void setrRaderName(String readerName) {
|
||||
this.readerName = readerName;
|
||||
}
|
||||
|
||||
public void setHashedPassword(String hashedPassword) {
|
||||
this.hashedPassword = hashedPassword;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.LabWork.app.MangaStore.model.Dto;
|
||||
|
||||
import com.LabWork.app.MangaStore.model.Default.User;
|
||||
import com.LabWork.app.MangaStore.model.Default.UserRole;
|
||||
|
||||
public class UserDto {
|
||||
private final long id;
|
||||
private final String login;
|
||||
private final UserRole role;
|
||||
|
||||
public UserDto(User user) {
|
||||
this.id = user.getId();
|
||||
this.login = user.getLogin();
|
||||
this.role = user.getRole();
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getLogin() {
|
||||
return login;
|
||||
}
|
||||
|
||||
public UserRole getRole() {
|
||||
return role;
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package com.LabWork.app.MangaStore.model.Dto;
|
||||
|
||||
import com.LabWork.app.MangaStore.model.Default.UserRole;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
public class UserSignupDto {
|
||||
@NotBlank
|
||||
@Size(min = 3, max = 64)
|
||||
private String login;
|
||||
@NotBlank
|
||||
@Size(min = 6, max = 64)
|
||||
private String password;
|
||||
@NotBlank
|
||||
@Size(min = 6, max = 64)
|
||||
private String passwordConfirm;
|
||||
|
||||
private UserRole userRole;
|
||||
|
||||
public String getLogin() {
|
||||
return login;
|
||||
}
|
||||
|
||||
public void setLogin(String login) {
|
||||
this.login = login;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getPasswordConfirm() {
|
||||
return passwordConfirm;
|
||||
}
|
||||
|
||||
public void setPasswordConfirm(String passwordConfirm) {
|
||||
this.passwordConfirm = passwordConfirm;
|
||||
}
|
||||
|
||||
public UserRole getUserRole() {
|
||||
return userRole;
|
||||
}
|
||||
|
||||
public void setUserRole(String userRole) {
|
||||
|
||||
if (userRole.equals("creator"))this.userRole = UserRole.ADMIN;
|
||||
else this.userRole = UserRole.USER;
|
||||
}
|
||||
}
|
||||
@@ -3,10 +3,12 @@ package com.LabWork.app.MangaStore.service;
|
||||
import com.LabWork.app.MangaStore.model.Default.Creator;
|
||||
import com.LabWork.app.MangaStore.model.Default.Manga;
|
||||
import com.LabWork.app.MangaStore.model.Default.Reader;
|
||||
import com.LabWork.app.MangaStore.model.Dto.SupportDto.MangaDto;
|
||||
import com.LabWork.app.MangaStore.service.Exception.MangaNotFoundException;
|
||||
import com.LabWork.app.MangaStore.service.Repository.CreatorRepository;
|
||||
import com.LabWork.app.MangaStore.service.Exception.CreatorNotFoundException;
|
||||
import com.LabWork.app.MangaStore.model.Default.User;
|
||||
import com.LabWork.app.MangaStore.service.Repository.UserRepository;
|
||||
import com.LabWork.app.MangaStore.service.Repository.MangaRepository;
|
||||
import com.LabWork.app.MangaStore.service.Repository.ReaderRepository;
|
||||
import com.LabWork.app.MangaStore.util.validation.ValidatorUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -16,18 +18,17 @@ import java.util.Optional;
|
||||
@Service
|
||||
public class CreatorService {
|
||||
private final CreatorRepository creatorRepository;
|
||||
|
||||
private final UserRepository userRepository;
|
||||
private final MangaService mangaService;
|
||||
private final MangaRepository mangaRepository;
|
||||
private final ValidatorUtil validatorUtil;
|
||||
|
||||
public CreatorService(CreatorRepository creatorRepository,
|
||||
MangaService mangaService,
|
||||
ValidatorUtil validatorUtil,
|
||||
UserRepository userRepository) {
|
||||
MangaRepository mangaRepository) {
|
||||
this.creatorRepository = creatorRepository;
|
||||
this.userRepository = userRepository;
|
||||
this.mangaService = mangaService;
|
||||
this.mangaRepository = mangaRepository;
|
||||
this.validatorUtil = validatorUtil;
|
||||
}
|
||||
|
||||
@@ -37,17 +38,56 @@ public class CreatorService {
|
||||
return creator.orElseThrow(() -> new CreatorNotFoundException(id));
|
||||
}
|
||||
|
||||
public Creator findByLogin(String login) {
|
||||
return findCreator(userRepository.findOneByLoginIgnoreCase(login).getId());
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public List<Creator> findAllCreators() { return creatorRepository.findAll(); }
|
||||
|
||||
@Transactional
|
||||
public Creator addCreator(User user) {
|
||||
final Creator creator = new Creator(user);
|
||||
public Creator addCreator(String creatorName, String password) {
|
||||
final Creator creator = new Creator(creatorName, password);
|
||||
validatorUtil.validate(creator);
|
||||
return creatorRepository.save(creator);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Creator updateCreator(Long id, String creatorName, String password) {
|
||||
final Creator currentCreator = findCreator(id);
|
||||
currentCreator.setCreatorName(creatorName);
|
||||
currentCreator.setHashedPassword(password);
|
||||
validatorUtil.validate(currentCreator);
|
||||
return currentCreator;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Creator deleteCreator(Long id) {
|
||||
final Creator currentCreator = findCreator(id);
|
||||
List<Manga> listManga = currentCreator.getMangas();
|
||||
for (Manga manga : listManga){
|
||||
for (final Reader reader :mangaService.getReader(manga.getId())){
|
||||
reader.getMangas().remove(manga);
|
||||
}
|
||||
}
|
||||
creatorRepository.delete(currentCreator);
|
||||
return currentCreator;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void deleteAllCreators() {
|
||||
creatorRepository.deleteAll();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Manga addManga(Long creatorId, Integer chapterCount, String mangaName) {
|
||||
final Creator currentCreator = findCreator(creatorId);
|
||||
final Manga manga = new Manga(currentCreator, mangaName, chapterCount);
|
||||
validatorUtil.validate(manga);
|
||||
return mangaRepository.save(manga);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Manga addManga(MangaDto mangaDto) {
|
||||
final Creator currentCreator = findCreator(mangaDto.getCreatorId());
|
||||
final Manga manga = new Manga(currentCreator, mangaDto);
|
||||
validatorUtil.validate(manga);
|
||||
return mangaRepository.save(manga);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import com.LabWork.app.MangaStore.service.Repository.MangaRepository;
|
||||
import com.LabWork.app.MangaStore.service.Exception.CreatorNotFoundException;
|
||||
import com.LabWork.app.MangaStore.service.Exception.MangaNotFoundException;
|
||||
import com.LabWork.app.MangaStore.service.Repository.ReaderRepository;
|
||||
import com.LabWork.app.MangaStore.service.Repository.UserRepository;
|
||||
import com.LabWork.app.MangaStore.util.validation.ValidatorUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -18,21 +17,15 @@ import java.util.Optional;
|
||||
@Service
|
||||
public class MangaService {
|
||||
public final MangaRepository mangaRepository;
|
||||
public final CreatorRepository creatorRepository;
|
||||
public final UserRepository userRepository;
|
||||
public final ReaderService readerService;
|
||||
private final ValidatorUtil validatorUtil;
|
||||
|
||||
public MangaService(MangaRepository mangaRepository,
|
||||
CreatorRepository creatorRepository,
|
||||
ReaderService readerService,
|
||||
ValidatorUtil validatorUtil,
|
||||
UserRepository userRepository) {
|
||||
ValidatorUtil validatorUtil) {
|
||||
this.mangaRepository = mangaRepository;
|
||||
this.readerService = readerService;
|
||||
this.creatorRepository = creatorRepository;
|
||||
this.validatorUtil = validatorUtil;
|
||||
this.userRepository = userRepository;
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
@@ -40,9 +33,6 @@ public class MangaService {
|
||||
final Optional<Manga> manga = mangaRepository.findById(id);
|
||||
return manga.orElseThrow(() -> new MangaNotFoundException(id));
|
||||
}
|
||||
public Creator findCreatorByLogin(String login) {
|
||||
return findCreator(userRepository.findOneByLoginIgnoreCase(login).getId());
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public List<Reader> getReader(Long id) {
|
||||
@@ -56,25 +46,19 @@ public class MangaService {
|
||||
return mangaRepository.findAll();
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public Creator findCreator(Long id) {
|
||||
final Optional<Creator> creator = creatorRepository.findById(id);
|
||||
return creator.orElseThrow(() -> new CreatorNotFoundException(id));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Manga addManga(MangaDto mangaDto) {
|
||||
final Creator currentCreator = findCreatorByLogin(mangaDto.getLogin());
|
||||
final Manga manga = new Manga(currentCreator, mangaDto);
|
||||
validatorUtil.validate(manga);
|
||||
return mangaRepository.save(manga);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Manga updateManga(Long id, Integer chapterCount, String Image) {
|
||||
public Manga updateManga(Long id, Integer chapterCount) {
|
||||
final Manga currentManga = findManga(id);
|
||||
currentManga.setChapterCount(chapterCount);
|
||||
currentManga.setImage(Image.getBytes());
|
||||
validatorUtil.validate(currentManga);
|
||||
return currentManga;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Manga updateManga(MangaDto mangaDto) {
|
||||
final Manga currentManga = findManga(mangaDto.getId());
|
||||
currentManga.setChapterCount(mangaDto.getChapterCount());
|
||||
currentManga.setImage(mangaDto.getImage().getBytes());
|
||||
validatorUtil.validate(currentManga);
|
||||
return currentManga;
|
||||
}
|
||||
@@ -89,4 +73,30 @@ public class MangaService {
|
||||
mangaRepository.delete(currentManga);
|
||||
return currentManga;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void deleteAllMangas() {
|
||||
mangaRepository.deleteAll();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Manga addMangaToReader(Long mangaId, Long readerId) {
|
||||
final Manga manga = findManga(mangaId);
|
||||
final Reader reader = readerService.findReader(readerId);
|
||||
validatorUtil.validate(reader);
|
||||
if (reader.getMangas().contains(manga))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
reader.getMangas().add(manga);
|
||||
return manga;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Manga removeMangaToReader(Long mangaId, Long readerId) {
|
||||
final Reader currentReader = readerService.findReader(readerId);
|
||||
final Manga currentManga = findManga(mangaId);
|
||||
currentReader.getMangas().remove(currentManga);
|
||||
return currentManga;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,10 @@ package com.LabWork.app.MangaStore.service;
|
||||
|
||||
import com.LabWork.app.MangaStore.model.Default.Manga;
|
||||
import com.LabWork.app.MangaStore.model.Default.Reader;
|
||||
import com.LabWork.app.MangaStore.service.Exception.CreatorNotFoundException;
|
||||
import com.LabWork.app.MangaStore.service.Repository.MangaRepository;
|
||||
import com.LabWork.app.MangaStore.service.Repository.ReaderRepository;
|
||||
import com.LabWork.app.MangaStore.service.Exception.MangaNotFoundException;
|
||||
import com.LabWork.app.MangaStore.service.Exception.ReaderNotFoundException;
|
||||
import com.LabWork.app.MangaStore.model.Default.User;
|
||||
import com.LabWork.app.MangaStore.service.Repository.UserRepository;
|
||||
import com.LabWork.app.MangaStore.util.validation.ValidatorUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -19,18 +16,12 @@ import java.util.Optional;
|
||||
@Service
|
||||
public class ReaderService {
|
||||
private final ReaderRepository readerRepository;
|
||||
private final UserRepository userRepository;
|
||||
private final MangaRepository mangaRepository;
|
||||
private final ValidatorUtil validatorUtil;
|
||||
|
||||
public ReaderService(ReaderRepository readerRepository,
|
||||
ValidatorUtil validatorUtil,
|
||||
UserRepository userRepository,
|
||||
MangaRepository mangaRepository) {
|
||||
ValidatorUtil validatorUtil) {
|
||||
this.readerRepository = readerRepository;
|
||||
this.mangaRepository = mangaRepository;
|
||||
this.validatorUtil = validatorUtil;
|
||||
this.userRepository = userRepository;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@@ -39,46 +30,37 @@ public class ReaderService {
|
||||
return reader.orElseThrow(() -> new ReaderNotFoundException(id));
|
||||
}
|
||||
|
||||
public Reader findByLogin(String login) {
|
||||
return findReader(userRepository.findOneByLoginIgnoreCase(login).getId());
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public List<Reader> findAllReaders() {
|
||||
return readerRepository.findAll();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Reader addReader(User user) {
|
||||
final Reader reader = new Reader(user);
|
||||
public Reader addReader(String readerName, String password) {
|
||||
final Reader reader = new Reader(readerName, password);
|
||||
validatorUtil.validate(reader);
|
||||
return readerRepository.save(reader);
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public Manga findManga(Long id) {
|
||||
final Optional<Manga> manga = mangaRepository.findById(id);
|
||||
return manga.orElseThrow(() -> new MangaNotFoundException(id));
|
||||
@Transactional
|
||||
public Reader updateReader(Long id, String readername, String password) {
|
||||
final Reader currentReader = findReader(id);
|
||||
currentReader.setReaderName(readername);
|
||||
currentReader.setHashedPassword(password);
|
||||
validatorUtil.validate(currentReader);
|
||||
return currentReader;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Manga addManga(Long mangaId, String readerLogin) {
|
||||
final Manga manga = findManga(mangaId);
|
||||
final Reader reader = findByLogin(readerLogin);
|
||||
validatorUtil.validate(reader);
|
||||
if (reader.getMangas().contains(manga))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
reader.getMangas().add(manga);
|
||||
return manga;
|
||||
public Reader deleteReader(Long id) {
|
||||
final Reader currentReader = findReader(id);
|
||||
currentReader.getMangas().clear();
|
||||
readerRepository.delete(currentReader);
|
||||
return currentReader;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Manga removeManga(Long mangaId, String readerLogin) {
|
||||
final Reader currentReader = findByLogin(readerLogin);
|
||||
final Manga currentManga = findManga(mangaId);
|
||||
currentReader.getMangas().remove(currentManga);
|
||||
return currentManga;
|
||||
public void deleteAllReaders() {
|
||||
readerRepository.deleteAll();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.LabWork.app.MangaStore.service.Repository;
|
||||
|
||||
import com.LabWork.app.MangaStore.model.Default.User;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
|
||||
public interface UserRepository extends JpaRepository<User, Long> {
|
||||
User findOneByLoginIgnoreCase(String login);
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
package com.LabWork.app.MangaStore.service;
|
||||
|
||||
import com.LabWork.app.MangaStore.service.CreatorService;
|
||||
import com.LabWork.app.MangaStore.service.ReaderService;
|
||||
import com.LabWork.app.MangaStore.model.Default.UserRole;
|
||||
import com.LabWork.app.MangaStore.util.validation.ValidationException;
|
||||
import com.LabWork.app.MangaStore.util.validation.ValidatorUtil;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.LabWork.app.MangaStore.model.Default.User;
|
||||
import com.LabWork.app.MangaStore.service.Repository.UserRepository;
|
||||
import java.util.Collections;
|
||||
import java.util.Objects;
|
||||
|
||||
@Service
|
||||
public class UserService implements UserDetailsService {
|
||||
private final UserRepository userRepository;
|
||||
private final ReaderService readerService;
|
||||
private final CreatorService creatorService;
|
||||
private final PasswordEncoder passwordEncoder;
|
||||
private final ValidatorUtil validatorUtil;
|
||||
|
||||
public UserService(UserRepository userRepository,
|
||||
CreatorService creatorService,
|
||||
ReaderService readerService,
|
||||
PasswordEncoder passwordEncoder,
|
||||
ValidatorUtil validatorUtil) {
|
||||
this.userRepository = userRepository;
|
||||
this.readerService = readerService;
|
||||
this.creatorService = creatorService;
|
||||
this.passwordEncoder = passwordEncoder;
|
||||
this.validatorUtil = validatorUtil;
|
||||
}
|
||||
|
||||
public Page<User> findAllPages(int page, int size) {
|
||||
return userRepository.findAll(PageRequest.of(page - 1, size, Sort.by("id").ascending()));
|
||||
}
|
||||
|
||||
public User findByLogin(String login) {
|
||||
return userRepository.findOneByLoginIgnoreCase(login);
|
||||
}
|
||||
|
||||
public User createUser(String login, String password, String passwordConfirm, UserRole role) {
|
||||
if (findByLogin(login) != null) {
|
||||
throw new ValidationException(String.format("User '%s' already exists", login));
|
||||
}
|
||||
final User user = new User(login, passwordEncoder.encode(password), role);
|
||||
validatorUtil.validate(user);
|
||||
if (!Objects.equals(password, passwordConfirm)) {
|
||||
throw new ValidationException("Passwords not equals");
|
||||
}
|
||||
userRepository.save(user);
|
||||
if (user.getRole() == UserRole.ADMIN) creatorService.addCreator(user);
|
||||
else readerService.addReader(user);
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||||
final User userEntity = findByLogin(username);
|
||||
if (userEntity == null) {
|
||||
throw new UsernameNotFoundException(username);
|
||||
}
|
||||
return new org.springframework.security.core.userdetails.User(
|
||||
userEntity.getLogin(), userEntity.getPassword(), Collections.singleton(userEntity.getRole()));
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/*@ControllerAdvice*/
|
||||
@ControllerAdvice
|
||||
public class AdviceController {
|
||||
@ExceptionHandler({
|
||||
CreatorNotFoundException.class,
|
||||
|
||||
@@ -3,11 +3,7 @@ package com.LabWork.app.MangaStore.util.validation;
|
||||
import java.util.Set;
|
||||
|
||||
public class ValidationException extends RuntimeException {
|
||||
public <T> ValidationException(Set<String> errors) {
|
||||
public ValidationException(Set<String> errors) {
|
||||
super(String.join("\n", errors));
|
||||
}
|
||||
|
||||
public <T> ValidationException(String error) {
|
||||
super(error);
|
||||
}
|
||||
}
|
||||
|
||||
30
src/main/java/com/LabWork/app/WebConfiguration.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package com.LabWork.app;
|
||||
|
||||
import org.springframework.boot.web.server.ErrorPage;
|
||||
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
|
||||
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.ViewControllerRegistration;
|
||||
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
public class WebConfiguration implements WebMvcConfigurer {
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**").allowedMethods("*");
|
||||
}
|
||||
@Override
|
||||
public void addViewControllers(ViewControllerRegistry registry) {
|
||||
ViewControllerRegistration registration = registry.addViewController("/notFound");
|
||||
registration.setViewName("forward:/index.html");
|
||||
registration.setStatusCode(HttpStatus.OK);
|
||||
|
||||
// Alternative way (404 error hits the console):
|
||||
// > registry.addViewController("/notFound").setViewName("forward:/index.html");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
spring.main.banner-mode=off
|
||||
server.port=8080
|
||||
#server.port=8080
|
||||
spring.datasource.url=jdbc:h2:file:./data
|
||||
spring.datasource.driverClassName=org.h2.Driver
|
||||
spring.datasource.username=sa
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
html,
|
||||
body {
|
||||
background-color: #000000;
|
||||
color: #ffffff;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
font-family: sans-serif;
|
||||
line-height: 1.15;
|
||||
height: 100%;
|
||||
}
|
||||
header {
|
||||
background-color: #3c3c3c;
|
||||
color: #ffffff;
|
||||
}
|
||||
header a {
|
||||
color: #ffffff;
|
||||
text-decoration: none;
|
||||
margin: 0 0.5em;
|
||||
}
|
||||
header a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
#logo {
|
||||
margin-left: 0.5em;
|
||||
}
|
||||
article a {
|
||||
color: #ffffff;
|
||||
text-decoration: none;
|
||||
margin: 0.5em 0.5em;
|
||||
}
|
||||
header a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 1.25em;
|
||||
}
|
||||
h3 {
|
||||
font-size: 1.1em;
|
||||
}
|
||||
footer {
|
||||
background-color: #9c9c9c;
|
||||
color: #ffffff;
|
||||
height: 32px;
|
||||
padding: 0.5em;
|
||||
}
|
||||
.manga_pages{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
.catalog_wrapper{
|
||||
display: flex;
|
||||
width: 73%;
|
||||
flex-direction: column;
|
||||
}
|
||||
.catalog_article{
|
||||
display: flex;
|
||||
}
|
||||
.poster{
|
||||
width:140px;
|
||||
}
|
||||
th {
|
||||
border: 0px solid rgb(255, 255, 255);
|
||||
}
|
||||
.added_manga{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
@media (min-width: 992px) {
|
||||
.manga_pages img{
|
||||
max-width: 900px;
|
||||
width: auto;
|
||||
height: auto;
|
||||
}
|
||||
}
|
||||
.flex_grow {
|
||||
flex-grow: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
@media (min-width: 1024px){
|
||||
.article_1 {
|
||||
max-width: -webkit-calc(1600px + (100vw/64*7)*2);
|
||||
max-width: -moz-calc(1600px + (100vw/64*7)*2);
|
||||
max-width: calc(1600px + (100vw/64*7)*2);
|
||||
padding-left: -webkit-calc(100vw/64*7);
|
||||
padding-left: -moz-calc(100vw/64*7);
|
||||
padding-left: calc(100vw/64*7);
|
||||
padding-right: -webkit-calc(100vw/64*7);
|
||||
padding-right: -moz-calc(100vw/64*7);
|
||||
padding-right: calc(100vw/64*7);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.registration_div {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.slideshow{
|
||||
height: 250px;
|
||||
width: auto;/*maintain aspect ratio*/
|
||||
max-width:180px;
|
||||
border-radius: 7%;
|
||||
}
|
||||
|
||||
.table > :not(:first-child) {
|
||||
border-top: 0;
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
<?xml version="1.0" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
|
||||
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
|
||||
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
|
||||
width="1280.000000pt" height="1280.000000pt" viewBox="0 0 1280.000000 1280.000000"
|
||||
preserveAspectRatio="xMidYMid meet">
|
||||
<metadata>
|
||||
Created by potrace 1.15, written by Peter Selinger 2001-2017
|
||||
</metadata>
|
||||
<g transform="translate(0.000000,1280.000000) scale(0.100000,-0.100000)"
|
||||
fill="#000000" stroke="none">
|
||||
<path d="M6090 12534 c-883 -44 -1693 -246 -2418 -604 -635 -313 -1146 -683
|
||||
-1683 -1220 -1069 -1067 -1655 -2308 -1794 -3795 -22 -238 -30 -735 -16 -980
|
||||
78 -1331 506 -2470 1306 -3470 280 -349 669 -743 1015 -1026 886 -725 1894
|
||||
-1159 3035 -1308 299 -39 429 -46 870 -46 460 1 593 9 955 61 1137 162 2166
|
||||
630 3055 1390 193 164 595 566 759 759 605 708 1027 1507 1251 2368 309 1191
|
||||
269 2518 -110 3662 -317 956 -904 1845 -1705 2581 -1050 964 -2228 1484 -3640
|
||||
1609 -167 15 -721 27 -880 19z m-141 -848 c-2 -2 -53 -25 -114 -50 -560 -238
|
||||
-1123 -701 -1404 -1153 -235 -379 -358 -823 -380 -1369 -32 -790 142 -1362
|
||||
564 -1852 156 -181 413 -398 660 -558 228 -147 595 -288 1140 -439 704 -195
|
||||
876 -254 1145 -391 69 -35 159 -85 200 -112 41 -27 116 -72 165 -102 395 -233
|
||||
696 -560 910 -987 122 -245 201 -498 247 -793 18 -114 18 -599 0 -740 -23
|
||||
-182 -62 -360 -113 -516 -190 -578 -549 -979 -1124 -1255 -378 -182 -772 -281
|
||||
-1360 -341 -73 -8 -274 -13 -515 -13 -415 0 -507 7 -785 56 -678 122 -1390
|
||||
456 -1991 934 -1176 936 -1894 2146 -2088 3518 -44 309 -51 415 -51 792 0 377
|
||||
7 487 51 793 137 964 544 1858 1207 2652 909 1089 2055 1733 3377 1899 91 11
|
||||
181 22 200 24 19 2 41 5 49 5 8 1 12 0 10 -2z m576 -1850 c126 -41 218 -98
|
||||
316 -195 74 -73 93 -100 132 -181 25 -52 51 -120 58 -150 20 -82 17 -300 -5
|
||||
-380 -55 -201 -203 -378 -391 -470 -100 -49 -182 -69 -310 -76 -220 -12 -403
|
||||
54 -568 206 -91 84 -156 184 -193 296 -27 83 -29 100 -29 239 1 143 2 154 32
|
||||
232 87 228 281 414 508 486 77 24 90 26 235 23 114 -3 148 -8 215 -30z"/>
|
||||
<path d="M6130 4301 c-162 -35 -293 -106 -419 -225 -116 -112 -199 -251 -242
|
||||
-411 -32 -115 -32 -345 0 -460 85 -311 327 -549 639 -627 121 -31 313 -30 427
|
||||
1 255 69 477 256 595 503 145 302 87 700 -137 939 -131 138 -252 215 -420 265
|
||||
-120 36 -317 43 -443 15z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -1,19 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
layout:decorate="~{default}">
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<div layout:fragment="content">
|
||||
<article class="p-2 catalog_article">
|
||||
<div class = "catalog_wrapper">
|
||||
<h1>Каталог</h1>
|
||||
<div class="p-2 d-flex flex-wrap">
|
||||
<a th:each="manga: ${mangaList}" th:href="@{/manga/{id}(id=${manga.id})}"><img th:src="${manga.image}" class="slideshow"/></a>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,58 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
layout:decorate="~{default}">
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<div layout:fragment="content">
|
||||
<div th:text="${errors}" class="margin-bottom alert-danger"></div>
|
||||
<form th:if="${controller != 'creator/'}" action="#" th:action="@{/creatorAction/manga/{id}(id=${id})}" th:object="${mangaDto}" enctype="multipart/form-data" method="post">
|
||||
<div class="mb-3" th:if="${controller == 'creator/'}">
|
||||
<label for="mangaNameU" class="form-label">mangaName</label>
|
||||
<input id="mangaNameU" type='text' class="form-control" th:field="${mangaDto.mangaName}" required="true"/>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="chapterCountU" class="form-label">chapterCount</label>
|
||||
<input id="chapterCountU" type='number' class="form-control" th:field="${mangaDto.chapterCount}" required="true"/>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="multipartFileU" class="form-label">image</label>
|
||||
<input type="file" id="multipartFileU" th:name="multipartFile" accept="image/png, image/jpeg" class="form-control" 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="@{/creator}">
|
||||
Назад
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
||||
<form th:if="${controller == 'creator/'}" action="#" th:action="@{/creatorAction/creator}" th:object="${mangaDto}" enctype="multipart/form-data" method="post">
|
||||
<div class="mb-3" th:if="${controller == 'creator/'}">
|
||||
<label for="mangaName" class="form-label">mangaName</label>
|
||||
<input id="mangaName" type='text' class="form-control" th:field="${mangaDto.mangaName}" required="true"/>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="chapterCount" class="form-label">chapterCount</label>
|
||||
<input id="chapterCount" type='number' class="form-control" th:field="${mangaDto.chapterCount}" required="true"/>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="multipartFile" class="form-label">image</label>
|
||||
<input type="file" id="multipartFile" th:name="multipartFile" accept="image/png, image/jpeg" class="form-control" 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="@{/creator}">
|
||||
Назад
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,67 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
xmlns:th="http://www.thymeleaf.org"
|
||||
layout:decorate="~{default}">
|
||||
<head>
|
||||
<script type="text/javascript" src="/webjars/jquery/3.6.0/jquery.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container" id="root-div" layout:fragment="content">
|
||||
<div class="content">
|
||||
<h1>Creator</h1>
|
||||
<form id="form mb-3">
|
||||
<div class="d-flex mt-3">
|
||||
<div class="d-grid col-sm-2">
|
||||
<a class="btn btn-success"
|
||||
th:href="@{/creatorAction/create}">
|
||||
<i class="fa-solid fa-plus"></i> Добавить
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div th:text="${errors}" class="margin-bottom alert-danger"></div>
|
||||
<div class="row table-responsive text-white">
|
||||
<div th:each="manga, iterator: ${currentCreator?.mangas}" class="d-flex flex-row flex-wrap flex-grow-1 align-items-center mt-3">
|
||||
<div class="me-3">
|
||||
<a th:href="@{/manga/{id}(id=${manga.id})}"><img th:src="${manga.image}" th:alt="${manga.mangaName}" class="slideshow"/></a>
|
||||
</div>
|
||||
<div>
|
||||
<div class="pt-3 description d-flex flex-column justify-content-start mb-3 fs-6 fw-bold">
|
||||
<h4>Название манги: <a class="text-white fs-5 unic_class fw-bold pt-3 mb-3" th:href="@{/mangapage/{id}(id=${manga.id})}" th:text="${manga.mangaName}"></a></h4>
|
||||
<h4>
|
||||
Количество глав:
|
||||
<span th:text="${manga.chapterCount}"/>
|
||||
</h4>
|
||||
</div>
|
||||
<div>
|
||||
<a class="btn btn-primary" th:href="@{/creatorAction/edit/{id}(id=${manga.id})}">
|
||||
<i class="fas fa-edit"></i>
|
||||
</a>
|
||||
</button>
|
||||
<button type="button" class="delete bg-danger p-2 px-2 mx-2 border border-0 rounded text-white fw-bold"
|
||||
th:attr="onclick=|confirm('Удалить запись?') && document.getElementById('remove-${manga.id}').click()|">
|
||||
<i class="fa fa-trash" aria-hidden="true"></i> Удалить
|
||||
</button>
|
||||
<form th:action="@{/creatorAction/delete/{id}(id=${manga.id})}" method="post">
|
||||
<button th:id="'remove-' + ${manga.id}" type="submit" style="display: none">
|
||||
Удалить
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<th:block layout:fragment="scripts">
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#creatorId').on('change', function() {
|
||||
this.form.submit();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</th:block>
|
||||
</html>
|
||||
@@ -1,55 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru"
|
||||
xmlns:th="http://www.thymeleaf.org"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>ReManga</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<script type="text/javascript" src="/webjars/bootstrap/5.1.3/js/bootstrap.bundle.min.js"></script>
|
||||
<link rel="icon" href="/favicon.svg">
|
||||
<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="/css/style.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar navbar-expand-lg navbar-dark">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="/">
|
||||
<i class="fa-solid fa-yin-yang"></i>
|
||||
ReManga
|
||||
</a>
|
||||
<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" sec:authorize="!isAuthenticated()">
|
||||
<a class="nav-link" href="/login">Вход</a>
|
||||
</ul>
|
||||
<ul class="navbar-nav" sec:authorize="isAuthenticated()">
|
||||
<a class="nav-link" href="/">Index</a>
|
||||
<!--(login=${#authentication.name})-->
|
||||
<a class="nav-link" sec:authorize="hasRole('ROLE_ADMIN')" th:href="@{/creatorAction(login=${#authentication.name})}">CreatorAction</a>
|
||||
<a class="nav-link" sec:authorize="hasRole('ROLE_USER')" th:href="@{/readerAction(readerLogin=${#authentication.name})}">ReaderAction</a>
|
||||
<a sec:authorize="hasRole('ROLE_USER')" class="nav-link" href="/users">Users</a>
|
||||
<a class="nav-link" href="/manga">Catalog</a>
|
||||
<a class="nav-link" href="/swagger-ui/index.html">Документация REST API</a>
|
||||
<a class="nav-link" href="/h2-console/">Консоль H2</a>
|
||||
<a class="nav-link" href="/logout">
|
||||
Выход (<span th:text="${#authentication.name}"></span>)
|
||||
</a>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div class="container-fluid">
|
||||
<div class="container container-padding" layout:fragment="content">
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<th:block layout:fragment="scripts">
|
||||
</th:block>
|
||||
</html>
|
||||
@@ -1,13 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
layout:decorate="~{default}">
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<div layout:fragment="content">
|
||||
<div><span th:text="${error}"></span></div>
|
||||
<a href="/">На главную</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,14 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
layout:decorate="~{default}">
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<div layout:fragment="content_header" th:text="'Главная'"></div>
|
||||
<div layout:fragment="content">
|
||||
<div>It's works!</div>
|
||||
<a href="123">ERROR</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,31 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
layout:decorate="~{default}">
|
||||
<body>
|
||||
<div class="container" layout:fragment="content">
|
||||
<div th:if="${param.error}" class="alert alert-danger margin-bottom">
|
||||
Пользователь не найден или пароль указан не верно
|
||||
</div>
|
||||
<div th:if="${param.logout}" class="alert alert-success margin-bottom">
|
||||
Выход успешно произведен
|
||||
</div>
|
||||
<div th:if="${param.created}" class="alert alert-success margin-bottom">
|
||||
Пользователь '<span th:text="${param.created}"></span>' успешно создан
|
||||
</div>
|
||||
<form th:action="@{/login}" method="post" class="container-padding">
|
||||
<div class="mb-3">
|
||||
<input type="text" name="username" id="username" class="form-control"
|
||||
placeholder="Логин" required="true" autofocus="true"/>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<input type="password" name="password" id="password" class="form-control"
|
||||
placeholder="Пароль" required="true"/>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-success button-fixed">Войти</button>
|
||||
<a class="btn btn-primary button-fixed" href="/signup">Регистрация</a>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<!DOCTYPE html>
|
||||
@@ -1,57 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
layout:decorate="~{default}">
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<div layout:fragment="content">
|
||||
<div class="container d-flex" >
|
||||
<div class="d-flex flex-column">
|
||||
<img class="img_style01" style={{borderRadius:"3%"}} th:src="${manga.image}" th:alt="${manga.mangaName}"/>
|
||||
</div>
|
||||
<div class="container table text-white fs-4 ms-4">
|
||||
<div class="row text-white fw-bold fs-3">О манге</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-6 col-sm-3">Год производства</div>
|
||||
<div class="col-xs-6 col-sm-3">1000</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-6 col-sm-3">Страна</div>
|
||||
<div class="col-xs-6 col-sm-3">Россия</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-6 col-sm-3">Жанр</div>
|
||||
<div class="col-xs-6 col-sm-3">Драма</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-6 col-sm-3">Количество глав</div>
|
||||
<div class="col-xs-6 col-sm-3" th:text="${manga.chapterCount}"></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-6 col-sm-3">Возраст</div>
|
||||
<div class="col-xs-6 col-sm-3">16+</div>
|
||||
</div>
|
||||
<div class="row text-white fw-bold fs-3">Описание</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-6 col-sm-12">
|
||||
<p>Ким Кон Чжа спокойно живет в своей халупе, завидуя всем популярным охотникам. Однажды его желание быть лучше всех сбывается и он получает легендарный навык “Копирование способностей”... ценой своей жизни.</p>
|
||||
<p>Прежде чем он успевает понять это, его убивает охотник №1, Летний дух! Но это активирует его навык, и теперь он скопировал новый, “Путешествие во времени после смерти”.</p>
|
||||
<p>Как Ким Кон Чжа же будет использовать эти навыки, чтобы победить конкурентов и подняться на вершину?</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row table-responsive text-white">
|
||||
<div th:each="reader: ${readers}" class="d-flex flex-row flex-wrap flex-grow-1 align-items-center mt-3">
|
||||
<div>
|
||||
<div class="pt-3 description mb-3 fs-6 fw-bold">
|
||||
Имя пользователя:
|
||||
<a th:href="@{/readerAction/(readerLogin=${reader.readerName})}" th:text="${reader.readerName}"></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,72 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
xmlns:th="http://www.thymeleaf.org"
|
||||
layout:decorate="~{default}">
|
||||
<head>
|
||||
<script type="text/javascript" src="/webjars/jquery/3.6.0/jquery.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container" id="root-div" layout:fragment="content">
|
||||
<div class="content">
|
||||
<h1>Reader</h1>
|
||||
<div class="d-flex mt-3">
|
||||
<div class="d-grid col-sm-2">
|
||||
<div th:text="${errors}" class="margin-bottom alert-danger"></div>
|
||||
<form action="#" th:action="@{/readerAction/manga}" method="post">
|
||||
<div class="mb-3">
|
||||
<label for="mangaId" class="form-label">Манга</label>
|
||||
<select th:name="mangaId" id="mangaId" class="form-select">
|
||||
<option th:each="manga: ${mangaList}" th:value="${manga.id}" th:text="${manga.mangaName}"/>
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<button type="submit" class="btn btn-primary button-fixed">
|
||||
<i class="fa-solid fa-plus">Добавить</i>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div th:text="${errors}" class="margin-bottom alert-danger"></div>
|
||||
<div class="row table-responsive text-white">
|
||||
<div th:each="manga: ${reader?.mangas}" class="d-flex flex-row flex-wrap flex-grow-1 align-items-center mt-3">
|
||||
<div class="me-3">
|
||||
<a th:href="@{/manga/{id}(id=${manga.id})}"><img th:src="${manga.image}" th:alt="${manga.mangaName}" class="slideshow"/></a>
|
||||
</div>
|
||||
<div>
|
||||
<div class="pt-3 description d-flex flex-column justify-content-start mb-3 fs-6 fw-bold">
|
||||
<h4>Название манги: <a class="text-white fs-5 unic_class fw-bold pt-3 mb-3" th:href="@{/mangapage/{id}(id=${manga.id})}" th:text="${manga.mangaName}"></a></h4>
|
||||
<h4>
|
||||
Количество глав:
|
||||
<span th:text="${manga.chapterCount}"/>
|
||||
</h4>
|
||||
</div>
|
||||
<div>
|
||||
</button>
|
||||
<button type="button" class="delete bg-danger p-2 px-2 mx-2 border border-0 rounded text-white fw-bold"
|
||||
th:attr="onclick=|confirm('Удалить запись?') && document.getElementById('remove-${manga.id}').click()|">
|
||||
<i class="fa fa-trash" aria-hidden="true"></i> Удалить
|
||||
</button>
|
||||
<form th:action="@{'/readerAction/' + 'removeManga/' + ${manga.id}}" method="post">
|
||||
<button th:id="'remove-' + ${manga.id}" type="submit" style="display: none">
|
||||
Удалить
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<th:block layout:fragment="scripts">
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#readerId').on('change', function() {
|
||||
this.form.submit();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</th:block>
|
||||
</html>
|
||||
@@ -1,35 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
layout:decorate="~{default}">
|
||||
<body>
|
||||
<div class="container container-padding" layout:fragment="content">
|
||||
<div th:if="${errors}" th:text="${errors}" class="margin-bottom alert alert-danger"></div>
|
||||
<form action="#" th:action="@{/signup}" th:object="${userDto}" method="post">
|
||||
<div class="mb-3">
|
||||
<input type="text" class="form-control" th:field="${userDto.login}"
|
||||
placeholder="Логин" required="true" autofocus="true" maxlength="64"/>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<input type="password" class="form-control" th:field="${userDto.password}"
|
||||
placeholder="Пароль" required="true" minlength="6" maxlength="64"/>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<input type="password" class="form-control" th:field="${userDto.passwordConfirm}"
|
||||
placeholder="Пароль (подтверждение)" required="true" minlength="6" maxlength="64"/>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<button type="submit" class="btn btn-success button-fixed">Создать</button>
|
||||
<a class="btn btn-primary button-fixed" href="/login">Назад</a>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="userRole" class="form-label">Роль</label>
|
||||
<select th:field="${userDto.userRole}" id="userRole" class="form-select">
|
||||
<option th:value="'creator'" th:text="creator"></option>
|
||||
<option th:value="'reader'" th:text="reader"></option>
|
||||
</select>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,37 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
layout:decorate="~{default}">
|
||||
<body>
|
||||
<div class="container" layout:fragment="content">
|
||||
<div class="table-responsive">
|
||||
<table class="table text-white">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">#</th>
|
||||
<th scope="col">ID</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"></th>
|
||||
<td th:text="${user.id}"></td>
|
||||
<td th:text="${user.login}" style="width: 60%"></td>
|
||||
<td th:text="${user.role}" style="width: 20%"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div th:if="${totalPages > 0}" class="pagination text-white">
|
||||
<span style="float: left; padding: 5px 5px;">Страницы:</span>
|
||||
<a th:each="page : ${pages}"
|
||||
th:href="@{/users(page=${page}, size=${users.size})}"
|
||||
th:text="${page}"
|
||||
th:class="${page == users.number + 1} ? active">
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,12 +1,62 @@
|
||||
package com.LabWork.app;
|
||||
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class AppApplicationTests {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(AppApplicationTests.class, args);
|
||||
}
|
||||
|
||||
/* @Autowired
|
||||
MethodService methodService;
|
||||
|
||||
@Test
|
||||
void testMethodSumInt() {
|
||||
final String res = methodService.Sum(1, 2, "int");
|
||||
Assertions.assertEquals(3, Integer.parseInt(res));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMethodSumString() {
|
||||
final String res = methodService.Sum("1", "2", "string");
|
||||
Assertions.assertEquals("12", res);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMethodMinusInt() {
|
||||
final String res = methodService.Difference(1, 2, "int");
|
||||
Assertions.assertEquals(-1, Integer.parseInt(res));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMethodMinusString() {
|
||||
final String res = methodService.Difference("214324", "4", "string");
|
||||
Assertions.assertEquals("2132", res);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMethodMultInt() {
|
||||
final String res = methodService.Multiplication(1, 2, "int");
|
||||
Assertions.assertEquals(2, Integer.parseInt(res));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMethodMultString() {
|
||||
final String res = methodService.Multiplication("1", "2", "string");
|
||||
Assertions.assertEquals("11", res);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMethodContainsInt() {
|
||||
final String res = methodService.Contains(123, 2, "int");
|
||||
Assertions.assertEquals(61, Integer.parseInt(res));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMethodContainsString() {
|
||||
final String res = methodService.Contains("1", "2", "string");
|
||||
Assertions.assertEquals("false", res);
|
||||
}*/
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/*
|
||||
package com.LabWork.app;
|
||||
|
||||
import com.LabWork.app.MangaStore.model.Default.Creator;
|
||||
@@ -33,12 +32,12 @@ public class ReMangaTest {
|
||||
mangaService.deleteAllMangas();
|
||||
creatorService.deleteAllCreators();
|
||||
Creator c1 = creatorService.addCreator("first_C", "1");
|
||||
Manga m1 = mangaService.addManga(c1.getId(), 0, "Vagabond", "1");
|
||||
Manga m2 = mangaService.addManga(c1.getId(), 10, "Berserk", "1");
|
||||
Manga m1 = creatorService.addManga(c1.getId(), 0, "Vagabond");
|
||||
Manga m2 = creatorService.addManga(c1.getId(), 10, "Berserk");
|
||||
Reader r1 = readerService.addReader("first_R", "1");
|
||||
|
||||
readerService.addManga(m1.getId(), r1.getId());
|
||||
readerService.addManga(m2.getId(), r1.getId());
|
||||
mangaService.addMangaToReader(m1.getId(), r1.getId());
|
||||
mangaService.addMangaToReader(m2.getId(), r1.getId());
|
||||
|
||||
Reader r11 = readerService.findReader(r1.getId());
|
||||
readerService.deleteReader(r11.getId());
|
||||
@@ -55,13 +54,13 @@ public class ReMangaTest {
|
||||
mangaService.deleteAllMangas();
|
||||
creatorService.deleteAllCreators();
|
||||
Creator c1 = creatorService.addCreator("first_C", "1");
|
||||
Manga m1 = mangaService.addManga(c1.getId(), 0, "vagabond", "1");
|
||||
Manga m1 = creatorService.addManga(c1.getId(), 0, "vagabond");
|
||||
Reader r1 = readerService.addReader("first_R", "1");
|
||||
Reader r2 = readerService.addReader("2", "2");
|
||||
Reader r3 = readerService.addReader("3", "3");
|
||||
|
||||
readerService.addManga(m1.getId(), r1.getId());
|
||||
readerService.addManga(m1.getId(), r2.getId());
|
||||
mangaService.addMangaToReader(m1.getId(), r1.getId());
|
||||
mangaService.addMangaToReader(m1.getId(), r2.getId());
|
||||
|
||||
log.info(r1.getMangas().toString());
|
||||
|
||||
@@ -94,9 +93,9 @@ public class ReMangaTest {
|
||||
mangaService.deleteAllMangas();
|
||||
creatorService.deleteAllCreators();
|
||||
Creator c1 = creatorService.addCreator("first", "1");
|
||||
Manga m1 = mangaService.addManga(c1.getId(), 0, "Vagabond", "1");
|
||||
Manga m2 = mangaService.addManga(c1.getId(), 10, "Berserk", "1");
|
||||
Manga m3 = mangaService.addManga(c1.getId(), 0, "Manga_3", "1");
|
||||
Manga m1 = creatorService.addManga(c1.getId(), 0, "Vagabond");
|
||||
Manga m2 = creatorService.addManga(c1.getId(), 10, "Berserk");
|
||||
Manga m3 = creatorService.addManga(c1.getId(), 0, "Manga_3");
|
||||
Creator c2 = creatorService.findCreator(c1.getId());
|
||||
Assertions.assertEquals(3, c2.getMangas().size());
|
||||
readerService.deleteAllReaders();
|
||||
@@ -104,7 +103,6 @@ public class ReMangaTest {
|
||||
creatorService.deleteAllCreators();
|
||||
}
|
||||
|
||||
*/
|
||||
/* @Test
|
||||
void testCreatorAddManga() {
|
||||
readerService.deleteAllReaders();
|
||||
@@ -121,10 +119,8 @@ public class ReMangaTest {
|
||||
log.info(m1.getCreator().toString());
|
||||
log.info(c1.toString());
|
||||
Assertions.assertEquals(c1.getCreatorName(), m1.getCreator().getCreatorName());
|
||||
}*//*
|
||||
}*/
|
||||
|
||||
|
||||
*/
|
||||
/* //бесполезня штука
|
||||
@Test
|
||||
void testCreatorDeleteManga() {
|
||||
@@ -151,11 +147,8 @@ public class ReMangaTest {
|
||||
|
||||
Assertions.assertEquals(1, c1.getMangas().size());
|
||||
|
||||
}*//*
|
||||
|
||||
*/
|
||||
/*тестстим работоспособность гита*//*
|
||||
|
||||
}*/
|
||||
/*тестстим работоспособность гита*/
|
||||
@Test
|
||||
void testCreatorUpdated() {
|
||||
readerService.deleteAllReaders();
|
||||
@@ -194,8 +187,8 @@ public class ReMangaTest {
|
||||
mangaService.deleteAllMangas();
|
||||
creatorService.deleteAllCreators();
|
||||
Creator c1 = creatorService.addCreator("first", "1");
|
||||
Manga m1 = mangaService.addManga(c1.getId(), 0, "Vagabond", "1");
|
||||
Manga m2 = mangaService.addManga(c1.getId(), 10, "Berserk", "1");
|
||||
Manga m1 = creatorService.addManga(c1.getId(), 0, "Vagabond");
|
||||
Manga m2 = creatorService.addManga(c1.getId(), 10, "Berserk");
|
||||
creatorService.deleteCreator(c1.getId());
|
||||
log.info(mangaService.findAllMangas().toString());
|
||||
Assertions.assertEquals(0, mangaService.findAllMangas().size());
|
||||
@@ -224,11 +217,11 @@ public class ReMangaTest {
|
||||
mangaService.deleteAllMangas();
|
||||
creatorService.deleteAllCreators();
|
||||
Creator c1 = creatorService.addCreator("first", "1");
|
||||
Manga m1 = mangaService.addManga(c1.getId(), 0, "Vagabond", "1");
|
||||
Manga m2 = mangaService.addManga(c1.getId(), 10, "Berserk", "1");
|
||||
Manga m1 = creatorService.addManga(c1.getId(), 0, "Vagabond");
|
||||
Manga m2 = creatorService.addManga(c1.getId(), 10, "Berserk");
|
||||
Reader r1 = readerService.addReader("1", "1");
|
||||
readerService.addManga(m1.getId(), r1.getId());
|
||||
readerService.addManga(m2.getId(), r1.getId());
|
||||
mangaService.addMangaToReader(m1.getId(), r1.getId());
|
||||
mangaService.addMangaToReader(m2.getId(), r1.getId());
|
||||
creatorService.deleteCreator(c1.getId());
|
||||
log.info(mangaService.findAllMangas().toString());
|
||||
Assertions.assertEquals(0, mangaService.findAllMangas().size());
|
||||
@@ -243,8 +236,8 @@ public class ReMangaTest {
|
||||
mangaService.deleteAllMangas();
|
||||
creatorService.deleteAllCreators();
|
||||
Creator c1 = creatorService.addCreator("first", "1");
|
||||
Manga m1 = mangaService.addManga(c1.getId(), 0, "Vagabond", "1");
|
||||
Manga m2 = mangaService.addManga(c1.getId(), 10, "Berserk", "1");
|
||||
Manga m1 = creatorService.addManga(c1.getId(), 0, "Vagabond");
|
||||
Manga m2 = creatorService.addManga(c1.getId(), 10, "Berserk");
|
||||
c1 = creatorService.findCreator(c1.getId());
|
||||
m1 = mangaService.findManga(m1.getId());
|
||||
log.info(c1.getMangas().toString());
|
||||
@@ -261,8 +254,8 @@ public class ReMangaTest {
|
||||
mangaService.deleteAllMangas();
|
||||
creatorService.deleteAllCreators();
|
||||
Creator c1 = creatorService.addCreator("first", "1");
|
||||
Manga m1 = mangaService.addManga(c1.getId(), 0, "Vagabond", "1");
|
||||
Manga m2 = mangaService.updateManga(m1.getId(), 10, "1");
|
||||
Manga m1 = creatorService.addManga(c1.getId(), 0, "Vagabond");
|
||||
Manga m2 = mangaService.updateManga(m1.getId(), 10);
|
||||
m2 = mangaService.findManga(m2.getId());
|
||||
c1 = creatorService.findCreator(c1.getId());
|
||||
log.info(m2.toString());
|
||||
@@ -281,12 +274,12 @@ public class ReMangaTest {
|
||||
mangaService.deleteAllMangas();
|
||||
creatorService.deleteAllCreators();
|
||||
Creator c1 = creatorService.addCreator("first", "1");
|
||||
Manga m1 = mangaService.addManga(c1.getId(), 0, "Vagabond", "1");
|
||||
Manga m2 = mangaService.addManga(c1.getId(), 10, "Berserk", "1");
|
||||
Manga m1 = creatorService.addManga(c1.getId(), 0, "Vagabond");
|
||||
Manga m2 = creatorService.addManga(c1.getId(), 10, "Berserk");
|
||||
Reader r1 = readerService.addReader("reader1", "password1");
|
||||
|
||||
readerService.addManga(m1.getId(), r1.getId());
|
||||
readerService.addManga(m2.getId(), r1.getId());
|
||||
mangaService.addMangaToReader(m1.getId(), r1.getId());
|
||||
mangaService.addMangaToReader(m2.getId(), r1.getId());
|
||||
mangaService.deleteManga(m1.getId());
|
||||
r1 = readerService.findReader(r1.getId());
|
||||
|
||||
@@ -306,8 +299,8 @@ public class ReMangaTest {
|
||||
mangaService.deleteAllMangas();
|
||||
creatorService.deleteAllCreators();
|
||||
Creator c1 = creatorService.addCreator("first", "1");
|
||||
Manga m1 = mangaService.addManga(c1.getId(), 0, "Vagabond", "1");
|
||||
Manga m2 = mangaService.addManga(c1.getId(), 10, "Berserk", "1");
|
||||
Manga m1 = creatorService.addManga(c1.getId(), 0, "Vagabond");
|
||||
Manga m2 = creatorService.addManga(c1.getId(), 10, "Berserk");
|
||||
mangaService.deleteAllMangas();
|
||||
Assertions.assertEquals(0, mangaService.findAllMangas().size());
|
||||
readerService.deleteAllReaders();
|
||||
@@ -321,12 +314,12 @@ public class ReMangaTest {
|
||||
mangaService.deleteAllMangas();
|
||||
creatorService.deleteAllCreators();
|
||||
Creator c1 = creatorService.addCreator("first_C", "1");
|
||||
Manga m1 = mangaService.addManga(c1.getId(), 0, "vagabond", "1");
|
||||
Manga m2 = mangaService.addManga(c1.getId(), 10, "Berserk", "1");
|
||||
Manga m1 = creatorService.addManga(c1.getId(), 0, "vagabond");
|
||||
Manga m2 = creatorService.addManga(c1.getId(), 10, "Berserk");
|
||||
Reader r1 = readerService.addReader("first_R", "1");
|
||||
|
||||
readerService.addManga(m1.getId(), r1.getId());
|
||||
readerService.addManga(m2.getId(), r1.getId());
|
||||
mangaService.addMangaToReader(m1.getId(), r1.getId());
|
||||
mangaService.addMangaToReader(m2.getId(), r1.getId());
|
||||
|
||||
log.info(r1.getMangas().toString());
|
||||
|
||||
@@ -365,15 +358,15 @@ public class ReMangaTest {
|
||||
mangaService.deleteAllMangas();
|
||||
creatorService.deleteAllCreators();
|
||||
Creator c1 = creatorService.addCreator("first_C", "1");
|
||||
Manga m1 = mangaService.addManga(c1.getId(), 0, "Vagabond", "1");
|
||||
Manga m2 = mangaService.addManga(c1.getId(), 10, "Berserk", "1");
|
||||
Manga m1 = creatorService.addManga(c1.getId(), 0, "Vagabond");
|
||||
Manga m2 = creatorService.addManga(c1.getId(), 10, "Berserk");
|
||||
Reader r1 = readerService.addReader("first_R", "1");
|
||||
|
||||
readerService.addManga(m1.getId(), r1.getId());
|
||||
readerService.addManga(m2.getId(), r1.getId());
|
||||
mangaService.addMangaToReader(m1.getId(), r1.getId());
|
||||
mangaService.addMangaToReader(m2.getId(), r1.getId());
|
||||
|
||||
Reader r11 = readerService.findReader(r1.getId());
|
||||
readerService.removeManga(m1.getId(), r11.getId());
|
||||
mangaService.removeMangaToReader(m1.getId(), r11.getId());
|
||||
Reader r12 = readerService.findReader(r11.getId());
|
||||
|
||||
Manga m11 = mangaService.findManga(m1.getId());
|
||||
@@ -391,13 +384,13 @@ public class ReMangaTest {
|
||||
mangaService.deleteAllMangas();
|
||||
creatorService.deleteAllCreators();
|
||||
Creator c1 = creatorService.addCreator("first_C", "1");
|
||||
Manga m1 = mangaService.addManga(c1.getId(), 0, "Vagabond", "1");
|
||||
Manga m2 = mangaService.addManga(c1.getId(), 10, "Berserk", "1");
|
||||
Manga m1 = creatorService.addManga(c1.getId(), 0, "Vagabond");
|
||||
Manga m2 = creatorService.addManga(c1.getId(), 10, "Berserk");
|
||||
Reader r1 = readerService.addReader("first_R", "1");
|
||||
Reader r2 = readerService.addReader("2_R", "2");
|
||||
|
||||
readerService.addManga(m1.getId(), r1.getId());
|
||||
readerService.addManga(m2.getId(), r1.getId());
|
||||
mangaService.addMangaToReader(m1.getId(), r1.getId());
|
||||
mangaService.addMangaToReader(m2.getId(), r1.getId());
|
||||
|
||||
Reader r11 = readerService.findReader(r1.getId());
|
||||
readerService.deleteReader(r11.getId());
|
||||
@@ -417,12 +410,12 @@ public class ReMangaTest {
|
||||
mangaService.deleteAllMangas();
|
||||
creatorService.deleteAllCreators();
|
||||
Creator c1 = creatorService.addCreator("first_C", "1");
|
||||
Manga m1 = mangaService.addManga(c1.getId(), 0, "Vagabond", "1");
|
||||
Manga m2 = mangaService.addManga(c1.getId(), 10, "Berserk", "1");
|
||||
Manga m1 = creatorService.addManga(c1.getId(), 0, "Vagabond");
|
||||
Manga m2 = creatorService.addManga(c1.getId(), 10, "Berserk");
|
||||
Reader r1 = readerService.addReader("first_R", "1");
|
||||
|
||||
readerService.addManga(m1.getId(), r1.getId());
|
||||
readerService.addManga(m2.getId(), r1.getId());
|
||||
mangaService.addMangaToReader(m1.getId(), r1.getId());
|
||||
mangaService.addMangaToReader(m2.getId(), r1.getId());
|
||||
|
||||
Reader r11 = readerService.updateReader(r1.getId(), "reader", "password");
|
||||
r11 = readerService.findReader(r11.getId());
|
||||
@@ -436,4 +429,3 @@ public class ReMangaTest {
|
||||
creatorService.deleteAllCreators();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||