Вроде готовая 4
BIN
data.mv.db
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 |
@@ -6,6 +6,7 @@
|
|||||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||||
<script type="module" src="/node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
|
<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/bootstrap/dist/css/bootstrap.min.css">
|
||||||
|
<link rel="stylesheet" href="/node_modules/@fortawesome/fontawesome-free/css/all.min.css">
|
||||||
<title>ReManga</title>
|
<title>ReManga</title>
|
||||||
</head>
|
</head>
|
||||||
<body >
|
<body >
|
||||||
|
|||||||
10
front/package-lock.json
generated
@@ -8,6 +8,7 @@
|
|||||||
"name": "front",
|
"name": "front",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@fortawesome/fontawesome-free": "^6.2.1",
|
||||||
"bootstrap": "5.3.0-alpha2",
|
"bootstrap": "5.3.0-alpha2",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
@@ -118,6 +119,15 @@
|
|||||||
"node": ">=4"
|
"node": ">=4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@fortawesome/fontawesome-free": {
|
||||||
|
"version": "6.4.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-6.4.0.tgz",
|
||||||
|
"integrity": "sha512-0NyytTlPJwB/BF5LtRV8rrABDbe3TdTXqNB3PdZ+UUUZAEIrdOJdmABqKjt4AXwIoJNaRVVZEXxpNrqvE1GAYQ==",
|
||||||
|
"hasInstallScript": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@jridgewell/gen-mapping": {
|
"node_modules/@jridgewell/gen-mapping": {
|
||||||
"version": "0.3.2",
|
"version": "0.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz",
|
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz",
|
||||||
|
|||||||
@@ -11,7 +11,8 @@
|
|||||||
"bootstrap": "5.3.0-alpha2",
|
"bootstrap": "5.3.0-alpha2",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"react-router-dom": "^6.4.4"
|
"react-router-dom": "^6.4.4",
|
||||||
|
"@fortawesome/fontawesome-free": "^6.2.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/react": "^18.0.24",
|
"@types/react": "^18.0.24",
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
import { useRoutes, Outlet, BrowserRouter } from 'react-router-dom';
|
import { useRoutes, Outlet, BrowserRouter } from 'react-router-dom';
|
||||||
import Creator from './components/Creator';
|
import Creator from './MainS/Creator';
|
||||||
import Reader from './components/Reader';
|
import Reader from './MainS/Reader';
|
||||||
import Header from './components/Header';
|
import Header from './components/Header';
|
||||||
import Manga from './components/Manga';
|
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) {
|
function Router(props) {
|
||||||
return useRoutes(props.rootRoute);
|
return useRoutes(props.rootRoute);
|
||||||
@@ -14,6 +18,10 @@ export default function App() {
|
|||||||
{ path: 'creator', element: <Creator />, label: 'Creator' },
|
{ path: 'creator', element: <Creator />, label: 'Creator' },
|
||||||
{ path: 'reader', element: <Reader />, label: 'Reader' },
|
{ path: 'reader', element: <Reader />, label: 'Reader' },
|
||||||
{ path: 'manga', element: <Manga />, label: 'Manga' },
|
{ 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 links = routes.filter(route => route.hasOwnProperty('label'));
|
||||||
const rootRoute = [
|
const rootRoute = [
|
||||||
|
|||||||
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>
|
||||||
|
);
|
||||||
|
}
|
||||||
81
front/src/Main/MangaPage.jsx
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
import React, {useState, useEffect} from 'react';
|
||||||
|
import MangaDto from '../Dto/Manga-Dto';
|
||||||
|
|
||||||
|
export default function MangaPage() {
|
||||||
|
|
||||||
|
const [mangaModel, setMangaModel] = useState(new MangaDto({}));
|
||||||
|
|
||||||
|
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));
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const transformer = (mangaModel) => new MangaDto(mangaModel);
|
||||||
|
const url = "manga/";
|
||||||
|
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
console.log(mangaModel);
|
||||||
|
}, [mangaModel]);
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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" 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>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
);
|
||||||
|
}
|
||||||
182
front/src/Main/ReaderAction.jsx
Normal file
@@ -0,0 +1,182 @@
|
|||||||
|
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(() => {
|
||||||
|
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>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import TableCreator from './TableCreator';
|
import TableCreator from '../components/Table/TableCreator';
|
||||||
|
import MangaDto from '../Dto/Manga-Dto';
|
||||||
|
|
||||||
export default function Creator() {
|
export default function Creator() {
|
||||||
|
|
||||||
@@ -11,6 +12,7 @@ export default function Creator() {
|
|||||||
|
|
||||||
const [password, setPassword] = useState("");
|
const [password, setPassword] = useState("");
|
||||||
|
|
||||||
|
const [mangaModel, setMangaModel] = useState(new MangaDto({}));
|
||||||
|
|
||||||
const [data, setData] = useState([]);
|
const [data, setData] = useState([]);
|
||||||
|
|
||||||
@@ -154,7 +156,7 @@ export default function Creator() {
|
|||||||
</form>
|
</form>
|
||||||
<div className="row table-responsive text-white">
|
<div className="row table-responsive text-white">
|
||||||
|
|
||||||
<table className="table mt-3">
|
<table className="table mt-3 text-white">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col">#</th>
|
<th scope="col">#</th>
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import TableManga from './TableManga';
|
import TableManga from '../components/Table/TableManga';
|
||||||
|
|
||||||
export default function Manga() {
|
export default function Manga() {
|
||||||
|
|
||||||
@@ -149,7 +149,7 @@ export default function Manga() {
|
|||||||
</form>
|
</form>
|
||||||
<div className="row table-responsive text-white">
|
<div className="row table-responsive text-white">
|
||||||
|
|
||||||
<table className="table mt-3">
|
<table className="table mt-3 text-white">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col">#</th>
|
<th scope="col">#</th>
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import TableReader from './TableReader';
|
import TableReader from '../components/Table/TableReader';
|
||||||
|
import MyModal from "../components/Modal/MyModal";
|
||||||
|
import EditReaderForm from "../components/Form/EditReaderForm";
|
||||||
|
|
||||||
export default function Reader() {
|
export default function ReaderS() {
|
||||||
|
|
||||||
const host = "http://localhost:8080";
|
const host = "http://localhost:8080";
|
||||||
|
|
||||||
@@ -13,10 +15,13 @@ export default function Reader() {
|
|||||||
|
|
||||||
const [password, setPassword] = useState("");
|
const [password, setPassword] = useState("");
|
||||||
|
|
||||||
|
const [modal, setModal] = useState(false);
|
||||||
|
|
||||||
const [data, setData] = useState([]);
|
const [data, setData] = useState([]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const table = document.getElementById("tbody");
|
const table = document.getElementById("tbody");
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -29,21 +34,6 @@ export default function Reader() {
|
|||||||
const response = await fetch(host + "/reader");
|
const response = await fetch(host + "/reader");
|
||||||
setData(await response.json())
|
setData(await response.json())
|
||||||
console.log(data);
|
console.log(data);
|
||||||
//table.innerHTML = "";
|
|
||||||
// data.forEach(Reader => {
|
|
||||||
// let temp = "<select>";
|
|
||||||
// Reader.mangas.forEach(Manga => {
|
|
||||||
// temp += `<option>${Manga.mangaName + " " + Manga.chapterCount}</option>>`
|
|
||||||
// })
|
|
||||||
// temp += "</select>"
|
|
||||||
// table.innerHTML +=
|
|
||||||
// `<tr>
|
|
||||||
// <th scope="row">${Reader.id}</th>
|
|
||||||
// <td>${Reader.readerName}</td>
|
|
||||||
// <td>${Reader.hashedPassword}</td>
|
|
||||||
// <td>${temp}</td>
|
|
||||||
// </tr>`;
|
|
||||||
// })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const create = async function (){
|
const create = async function (){
|
||||||
@@ -57,9 +47,9 @@ export default function Reader() {
|
|||||||
getData();
|
getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
const remove = async function (){
|
const remove = async function (id){
|
||||||
console.info('Try to remove item');
|
console.info('Try to remove item');
|
||||||
if (readerId !== 0) {
|
if (id !== 0) {
|
||||||
if (!confirm('Do you really want to remove this item?')) {
|
if (!confirm('Do you really want to remove this item?')) {
|
||||||
console.info('Canceled');
|
console.info('Canceled');
|
||||||
return;
|
return;
|
||||||
@@ -71,7 +61,7 @@ export default function Reader() {
|
|||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const response = await fetch(host + `/reader/` + readerId, requestParams);
|
const response = await fetch(host + `/reader/` + id, requestParams);
|
||||||
getData();
|
getData();
|
||||||
return await response.json();
|
return await response.json();
|
||||||
}
|
}
|
||||||
@@ -138,9 +128,8 @@ export default function Reader() {
|
|||||||
create();
|
create();
|
||||||
}
|
}
|
||||||
|
|
||||||
const removeButton = (e) =>{
|
const removeButton = (id) =>{
|
||||||
e.preventDefault()
|
remove(id);
|
||||||
remove();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,7 +148,11 @@ export default function Reader() {
|
|||||||
addManga();
|
addManga();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const setModal_Click = (e) =>{
|
||||||
|
e.preventDefault()
|
||||||
|
setModal(true)
|
||||||
|
//setData({type:'', name:'', description:'' })
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main>
|
<main>
|
||||||
@@ -192,9 +185,6 @@ export default function Reader() {
|
|||||||
<div className="d-grid col-sm-3 m-3 mx-auto">
|
<div className="d-grid col-sm-3 m-3 mx-auto">
|
||||||
<button onClick={updateButton} className="btn btn-success">Обновить</button>
|
<button onClick={updateButton} className="btn btn-success">Обновить</button>
|
||||||
</div>
|
</div>
|
||||||
<div className="d-grid col-sm-3 m-3 mx-auto">
|
|
||||||
<button onClick={removeButton} className="btn btn-success">Удалить</button>
|
|
||||||
</div>
|
|
||||||
<div className="d-grid col-sm-2 m-3 mx-auto">
|
<div className="d-grid col-sm-2 m-3 mx-auto">
|
||||||
<button onClick={removeMangaButton} className="btn btn-success">Удалить мангу</button>
|
<button onClick={removeMangaButton} className="btn btn-success">Удалить мангу</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -205,16 +195,22 @@ export default function Reader() {
|
|||||||
</form>
|
</form>
|
||||||
<div className="row table-responsive text-white">
|
<div className="row table-responsive text-white">
|
||||||
|
|
||||||
<table className="table mt-3">
|
<table className="table mt-3 text-white">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col">#</th>
|
<th scope="col">#</th>
|
||||||
<th scope="col">readerName</th>
|
<th scope="col">readerName</th>
|
||||||
<th scope="col">Password</th>
|
<th scope="col">Password</th>
|
||||||
<th scope="col">Mangs</th>
|
<th scope="col">Mangs</th>
|
||||||
|
<th scope="col"></th>
|
||||||
|
<th scope="col"></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<TableReader items = {data}/>
|
<TableReader
|
||||||
|
items = {data}
|
||||||
|
remove ={removeButton}
|
||||||
|
update ={updateButton}
|
||||||
|
/>
|
||||||
{/* <tbody id="tbody">
|
{/* <tbody id="tbody">
|
||||||
</tbody> */}
|
</tbody> */}
|
||||||
</table>
|
</table>
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
import { useEffect, useState } from "react";
|
|
||||||
|
|
||||||
export default function Adding() {
|
|
||||||
|
|
||||||
const [outcome, setOutcome] = useState(0);
|
|
||||||
|
|
||||||
const [first, setFirst] = useState(0);
|
|
||||||
|
|
||||||
const [second, setSecond] = useState(0);
|
|
||||||
|
|
||||||
const sum = (e) =>{
|
|
||||||
e.preventDefault()
|
|
||||||
fetch('http://localhost:8080/sum?first=' + first + '&second=' + second)
|
|
||||||
.then(response=>response.text())
|
|
||||||
.then(result=>setOutcome(result))
|
|
||||||
}
|
|
||||||
|
|
||||||
const ras = (e) =>{
|
|
||||||
e.preventDefault()
|
|
||||||
fetch('http://localhost:8080/ras?first=' + first + '&second=' + second)
|
|
||||||
.then(response=>response.text())
|
|
||||||
.then(result=>setOutcome(result))
|
|
||||||
}
|
|
||||||
const del = (e) =>{
|
|
||||||
e.preventDefault()
|
|
||||||
fetch('http://localhost:8080/del?first=' + first + '&second=' + second)
|
|
||||||
.then(response=>response.text())
|
|
||||||
.then(result=>setOutcome(result))
|
|
||||||
}
|
|
||||||
const pros = (e) =>{
|
|
||||||
e.preventDefault()
|
|
||||||
fetch('http://localhost:8080/pros?first=' + first + '&second=' + second)
|
|
||||||
.then(response=>response.text())
|
|
||||||
.then(result=>setOutcome(result))
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<main className="flex-shrink-0">
|
|
||||||
<div className="p-2">
|
|
||||||
<form>
|
|
||||||
<div className="form-group">
|
|
||||||
<label>Первое число</label>
|
|
||||||
<input type='number' value = {first} onChange={event => setFirst(event.target.value)} className="form-control"/>
|
|
||||||
</div>
|
|
||||||
<div className="form-group">
|
|
||||||
<label >Второе число</label>
|
|
||||||
<input type='number' value = {second} onChange={event => setSecond(event.target.value)} className="form-control"/>
|
|
||||||
</div>
|
|
||||||
<button onClick={sum} type="submit" className="btn btn-primary">Sum</button>
|
|
||||||
<button onClick={ras} type="submit" className="btn btn-primary">-</button>
|
|
||||||
<button onClick={del} type="submit" className="btn btn-primary">/</button>
|
|
||||||
<button onClick={pros} type="submit" className="btn btn-primary">*</button>
|
|
||||||
{outcome}
|
|
||||||
</form>
|
|
||||||
</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
|
||||||
@@ -2,7 +2,7 @@ import { NavLink } from 'react-router-dom';
|
|||||||
|
|
||||||
export default function Header(props) {
|
export default function Header(props) {
|
||||||
return (
|
return (
|
||||||
<nav className="navbar navbar-expand-lg bg-light">
|
<nav className="navbar navbar-expand-lg navbar-dark">
|
||||||
<div className="container-fluid">
|
<div className="container-fluid">
|
||||||
<button className="navbar-toggler" type="button"
|
<button className="navbar-toggler" type="button"
|
||||||
data-bs-toggle="collapse" data-bs-target="#navbarNav"
|
data-bs-toggle="collapse" data-bs-target="#navbarNav"
|
||||||
|
|||||||
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>
|
||||||
|
);
|
||||||
|
}
|
||||||
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;
|
||||||
|
}
|
||||||
@@ -12,7 +12,7 @@ export default function TableCreator(props) {
|
|||||||
<td>{item.creatorName}</td>
|
<td>{item.creatorName}</td>
|
||||||
<td>{item.hashedPassword}</td>
|
<td>{item.hashedPassword}</td>
|
||||||
<td>
|
<td>
|
||||||
<select>{item.mangas.map(manga =>
|
<select className="form-select" aria-label="Default select example">{item.mangas.map(manga =>
|
||||||
<option key={manga.mangaName } >{manga.mangaName + " " +manga.chapterCount}</option>)}
|
<option key={manga.mangaName } >{manga.mangaName + " " +manga.chapterCount}</option>)}
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
@@ -1,20 +1,20 @@
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
|
|
||||||
|
|
||||||
export default function TableCreator(props) {
|
export default function TableManga(props) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<tbody>
|
<tbody>
|
||||||
{
|
{
|
||||||
props.items.map((item, index) =>
|
props.items.map((item, index) =>
|
||||||
<tr key={item.id}>
|
<tr key={item.id} >
|
||||||
<td>{item.id}</td>
|
<td>{item.id}</td>
|
||||||
<td>{item.mangaName}</td>
|
<td>{item.mangaName}</td>
|
||||||
<td>{item.chapterCount}</td>
|
<td>{item.chapterCount}</td>
|
||||||
<td>{item.creatorId}</td>
|
<td>{item.creatorId}</td>
|
||||||
<td>
|
<td>
|
||||||
<select>{item.readers.map(reader =>
|
<select className="form-select" aria-label="Default select example">{item.readers.map(reader =>
|
||||||
<option key={reader}>{reader}</option>)}
|
<option key={reader.id}>{reader.readerName}</option>)}
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -6,16 +6,19 @@ export default function TableReader(props) {
|
|||||||
return (
|
return (
|
||||||
<tbody>
|
<tbody>
|
||||||
{
|
{
|
||||||
props.items.map((item, index) =>
|
props.items.map((item) =>
|
||||||
<tr key={item.id}>
|
<tr key={item.id}>
|
||||||
<td>{item.id}</td>
|
<td>{item.id}</td>
|
||||||
<td>{item.readerName}</td>
|
<td>{item.readerName}</td>
|
||||||
<td>{item.hashedPassword}</td>
|
<td>{item.hashedPassword}</td>
|
||||||
<td>
|
<td>
|
||||||
<select>{item.mangas.map(manga =>
|
<select className="form-select" aria-label="Default select example">{item.mangas.map(manga =>
|
||||||
<option key={manga}>{manga}</option>)}
|
<option key={manga.id}>{manga.mangaName}</option>)}
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
<button onClick={() => props.remove(item.id)} className="btn btn-success">Удалить</button>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* html,
|
html,
|
||||||
body {
|
body {
|
||||||
background-color: #000000;
|
background-color: #000000;
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
@@ -31,9 +31,7 @@ article a {
|
|||||||
header a:hover {
|
header a:hover {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
h1 {
|
|
||||||
font-size: 1.5em;
|
|
||||||
}
|
|
||||||
h2 {
|
h2 {
|
||||||
font-size: 1.25em;
|
font-size: 1.25em;
|
||||||
}
|
}
|
||||||
@@ -99,4 +97,11 @@ th {
|
|||||||
.registration_div {
|
.registration_div {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
} */
|
}
|
||||||
|
|
||||||
|
.slideshow{
|
||||||
|
height: 250px;
|
||||||
|
width: auto;/*maintain aspect ratio*/
|
||||||
|
max-width:180px;
|
||||||
|
border-radius: 7%;
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ package com.LabWork.app.MangaStore.controller;
|
|||||||
import com.LabWork.app.MangaStore.model.Dto.MangaReaderDto;
|
import com.LabWork.app.MangaStore.model.Dto.MangaReaderDto;
|
||||||
import com.LabWork.app.MangaStore.model.Dto.SupportDto.MangaDto;
|
import com.LabWork.app.MangaStore.model.Dto.SupportDto.MangaDto;
|
||||||
import com.LabWork.app.MangaStore.service.MangaService;
|
import com.LabWork.app.MangaStore.service.MangaService;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -28,22 +29,32 @@ public class MangaController {
|
|||||||
.map(x -> new MangaReaderDto(x, mangaService.getReader(x.getId())))
|
.map(x -> new MangaReaderDto(x, mangaService.getReader(x.getId())))
|
||||||
.toList();
|
.toList();
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public MangaReaderDto createManga(@RequestParam("creatorId") Long creatorId,
|
public MangaReaderDto createManga(@RequestParam("creatorId") Long creatorId,
|
||||||
@RequestParam("chapterCount") Integer chapterCount,
|
@RequestParam("chapterCount") Integer chapterCount,
|
||||||
@RequestParam("mangaName") String mangaName) {
|
@RequestParam("mangaName") String mangaName) {
|
||||||
return new MangaReaderDto(mangaService.addManga(creatorId, chapterCount, mangaName), mangaService.getReader(creatorId));
|
return new MangaReaderDto(mangaService.addManga(creatorId, chapterCount, mangaName), mangaService.getReader(creatorId));
|
||||||
}
|
}*/
|
||||||
|
|
||||||
@PutMapping("/{id}")
|
/* @PutMapping("/{id}")
|
||||||
public MangaReaderDto updateManga(@PathVariable Long id,
|
public MangaReaderDto updateManga(@PathVariable Long id,
|
||||||
@RequestParam("chapterCount") Integer chapterCount) {
|
@RequestParam("chapterCount") Integer chapterCount) {
|
||||||
return new MangaReaderDto(mangaService.updateManga(id, chapterCount), mangaService.getReader(id));
|
return new MangaReaderDto(mangaService.updateManga(id, chapterCount), mangaService.getReader(id));
|
||||||
}
|
}*/
|
||||||
|
|
||||||
@DeleteMapping("/{id}")
|
@DeleteMapping("/{id}")
|
||||||
public MangaDto deleteManga(@PathVariable Long id) {
|
public MangaDto deleteManga(@PathVariable Long id) {
|
||||||
return new MangaDto(mangaService.deleteManga(id));
|
return new MangaDto(mangaService.deleteManga(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping
|
||||||
|
public MangaDto createManga(@RequestBody @Valid MangaDto mangaDto) {
|
||||||
|
return new MangaDto(mangaService.addManga(mangaDto));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/{id}")
|
||||||
|
public MangaDto updateManga(@RequestBody @Valid MangaDto mangaDto) {
|
||||||
|
return new MangaDto(mangaService.updateManga(mangaDto));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.LabWork.app.MangaStore.controller;
|
|||||||
|
|
||||||
|
|
||||||
import com.LabWork.app.MangaStore.model.Dto.ReaderMangaDto;
|
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.ReaderService;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@@ -42,15 +43,15 @@ public class ReaderController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/{id}/addManga")
|
@PutMapping("/{id}/addManga")
|
||||||
public ReaderMangaDto addManga(@PathVariable Long id,
|
public MangaDto addManga(@PathVariable Long id,
|
||||||
@RequestParam("mangaId") Long mangaId) {
|
@RequestParam("mangaId") Long mangaId) {
|
||||||
return new ReaderMangaDto(readerService.addManga(mangaId, id));
|
return new MangaDto(readerService.addManga(mangaId, id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/{id}/removeManga")
|
@PutMapping("/{id}/removeManga")
|
||||||
public ReaderMangaDto removeManga(@PathVariable Long id,
|
public MangaDto removeManga(@PathVariable Long id,
|
||||||
@RequestParam("mangaId") Long mangaId) {
|
@RequestParam("mangaId") Long mangaId) {
|
||||||
return new ReaderMangaDto(readerService.removeManga(mangaId, id));
|
return new MangaDto(readerService.removeManga(mangaId, id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/{id}")
|
@DeleteMapping("/{id}")
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.LabWork.app.MangaStore.model.Default;
|
package com.LabWork.app.MangaStore.model.Default;
|
||||||
|
|
||||||
|
import com.LabWork.app.MangaStore.model.Dto.SupportDto.MangaDto;
|
||||||
import com.LabWork.app.MangaStore.service.CreatorService;
|
import com.LabWork.app.MangaStore.service.CreatorService;
|
||||||
import com.LabWork.app.MangaStore.service.MangaService;
|
import com.LabWork.app.MangaStore.service.MangaService;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
@@ -24,13 +25,34 @@ public class Manga {
|
|||||||
@JoinColumn(name="creator_fk")
|
@JoinColumn(name="creator_fk")
|
||||||
private Creator creator;
|
private Creator creator;
|
||||||
|
|
||||||
|
private Long creatorId;
|
||||||
|
|
||||||
|
@Lob
|
||||||
|
private byte[] image;
|
||||||
public Manga() {
|
public Manga() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Manga(Creator creator, String mangaName, Integer chapterCount) {
|
public Manga(Creator creator, String mangaName, Integer chapterCount) {
|
||||||
this.creator = creator;
|
this.creator = creator;
|
||||||
|
this.creatorId = creatorId;
|
||||||
this.mangaName = mangaName;
|
this.mangaName = mangaName;
|
||||||
this.chapterCount = chapterCount;
|
this.chapterCount = chapterCount;
|
||||||
|
this.image = image;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Manga(Creator creator, MangaDto mangaDto) {
|
||||||
|
this.creator = creator;
|
||||||
|
this.mangaName = mangaDto.getMangaName();
|
||||||
|
this.chapterCount = mangaDto.getChapterCount();
|
||||||
|
this.image = mangaDto.getImage().getBytes();
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getImage() {
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImage(byte[] image) {
|
||||||
|
this.image = image;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.LabWork.app.MangaStore.model.Default.Manga;
|
|||||||
import com.LabWork.app.MangaStore.model.Default.Reader;
|
import com.LabWork.app.MangaStore.model.Default.Reader;
|
||||||
import com.LabWork.app.MangaStore.model.Dto.SupportDto.ReaderDto;
|
import com.LabWork.app.MangaStore.model.Dto.SupportDto.ReaderDto;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class MangaReaderDto {
|
public class MangaReaderDto {
|
||||||
@@ -13,14 +14,15 @@ public class MangaReaderDto {
|
|||||||
private final Long creatorId;
|
private final Long creatorId;
|
||||||
private final String mangaName;
|
private final String mangaName;
|
||||||
private final Integer chapterCount;
|
private final Integer chapterCount;
|
||||||
|
|
||||||
private final List<ReaderDto> readers;
|
private final List<ReaderDto> readers;
|
||||||
|
private String image;
|
||||||
|
|
||||||
public MangaReaderDto(Manga manga, List<Reader> listReader) {
|
public MangaReaderDto(Manga manga, List<Reader> listReader) {
|
||||||
this.id = manga.getId();
|
this.id = manga.getId();
|
||||||
this.creatorId = manga.getCreator().getId();
|
this.creatorId = manga.getCreator().getId();
|
||||||
this.mangaName = manga.getMangaName();
|
this.mangaName = manga.getMangaName();
|
||||||
this.chapterCount = manga.getChapterCount();
|
this.chapterCount = manga.getChapterCount();
|
||||||
|
this.image = new String(manga.getImage(), StandardCharsets.UTF_8);
|
||||||
this.readers = listReader.stream()
|
this.readers = listReader.stream()
|
||||||
.map(y -> new ReaderDto(y))
|
.map(y -> new ReaderDto(y))
|
||||||
.toList();
|
.toList();
|
||||||
@@ -30,6 +32,10 @@ public class MangaReaderDto {
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getImage() {
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
public String getMangaName() {
|
public String getMangaName() {
|
||||||
return mangaName;
|
return mangaName;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,29 @@
|
|||||||
package com.LabWork.app.MangaStore.model.Dto.SupportDto;
|
package com.LabWork.app.MangaStore.model.Dto.SupportDto;
|
||||||
|
|
||||||
|
import com.LabWork.app.MangaStore.model.Default.Creator;
|
||||||
import com.LabWork.app.MangaStore.model.Default.Manga;
|
import com.LabWork.app.MangaStore.model.Default.Manga;
|
||||||
import com.LabWork.app.MangaStore.model.Default.Reader;
|
import com.LabWork.app.MangaStore.model.Default.Reader;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class MangaDto {
|
public class MangaDto {
|
||||||
private final Long id;
|
private Long id;
|
||||||
|
private Long creatorId;
|
||||||
private final Long creatorId;
|
private String mangaName;
|
||||||
private final String mangaName;
|
private Integer chapterCount;
|
||||||
private final Integer chapterCount;
|
private String image;
|
||||||
|
|
||||||
public MangaDto(Manga manga) {
|
public MangaDto(Manga manga) {
|
||||||
this.id = manga.getId();
|
this.id = manga.getId();
|
||||||
this.creatorId = manga.getCreator().getId();
|
this.creatorId = manga.getCreator().getId();
|
||||||
this.mangaName = manga.getMangaName();
|
this.mangaName = manga.getMangaName();
|
||||||
this.chapterCount = manga.getChapterCount();
|
this.chapterCount = manga.getChapterCount();
|
||||||
|
this.image = new String(manga.getImage(), StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MangaDto() {
|
||||||
|
}
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@@ -35,4 +40,8 @@ public class MangaDto {
|
|||||||
return creatorId;
|
return creatorId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getImage() {
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.LabWork.app.MangaStore.service;
|
|||||||
import com.LabWork.app.MangaStore.model.Default.Creator;
|
import com.LabWork.app.MangaStore.model.Default.Creator;
|
||||||
import com.LabWork.app.MangaStore.model.Default.Manga;
|
import com.LabWork.app.MangaStore.model.Default.Manga;
|
||||||
import com.LabWork.app.MangaStore.model.Default.Reader;
|
import com.LabWork.app.MangaStore.model.Default.Reader;
|
||||||
|
import com.LabWork.app.MangaStore.model.Dto.SupportDto.MangaDto;
|
||||||
import com.LabWork.app.MangaStore.service.Repository.CreatorRepository;
|
import com.LabWork.app.MangaStore.service.Repository.CreatorRepository;
|
||||||
import com.LabWork.app.MangaStore.service.Repository.MangaRepository;
|
import com.LabWork.app.MangaStore.service.Repository.MangaRepository;
|
||||||
import com.LabWork.app.MangaStore.service.Exception.CreatorNotFoundException;
|
import com.LabWork.app.MangaStore.service.Exception.CreatorNotFoundException;
|
||||||
@@ -75,12 +76,31 @@ public class MangaService {
|
|||||||
return mangaRepository.save(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);
|
||||||
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Manga updateManga(Long id, Integer chapterCount) {
|
public Manga updateManga(Long id, Integer chapterCount) {
|
||||||
final Manga currentManga = findManga(id);
|
final Manga currentManga = findManga(id);
|
||||||
currentManga.setChapterCount(chapterCount);
|
currentManga.setChapterCount(chapterCount);
|
||||||
validatorUtil.validate(currentManga);
|
validatorUtil.validate(currentManga);
|
||||||
return mangaRepository.save(currentManga);
|
mangaRepository.save(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);
|
||||||
|
mangaRepository.save(currentManga);
|
||||||
|
return currentManga;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class ReaderService {
|
|||||||
|
|
||||||
//СКОРЕЕ ВСЕГО НЕ БУДЕТ РАБОТАТЬ
|
//СКОРЕЕ ВСЕГО НЕ БУДЕТ РАБОТАТЬ
|
||||||
@Transactional
|
@Transactional
|
||||||
public Reader addManga(Long mangaId, Long readerId) {
|
public Manga addManga(Long mangaId, Long readerId) {
|
||||||
final Manga manga = findManga(mangaId);
|
final Manga manga = findManga(mangaId);
|
||||||
final Reader reader = findReader(readerId);
|
final Reader reader = findReader(readerId);
|
||||||
validatorUtil.validate(reader);
|
validatorUtil.validate(reader);
|
||||||
@@ -62,19 +62,21 @@ public class ReaderService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
reader.getMangas().add(manga);
|
reader.getMangas().add(manga);
|
||||||
|
readerRepository.save(reader);
|
||||||
/* manga.getReaders().add(reader);*/
|
/* manga.getReaders().add(reader);*/
|
||||||
return readerRepository.save(reader);
|
return manga;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Reader removeManga(Long mangaId, Long readerId) {
|
public Manga removeManga(Long mangaId, Long readerId) {
|
||||||
//em.createNativeQuery("delete from Mangas_Readers where MANGA_FK = " + manga.getId() + " AND READER_FK = "+ readerId).executeUpdate();
|
//em.createNativeQuery("delete from Mangas_Readers where MANGA_FK = " + manga.getId() + " AND READER_FK = "+ readerId).executeUpdate();
|
||||||
final Reader currentReader = findReader(readerId);
|
final Reader currentReader = findReader(readerId);
|
||||||
final Manga currentManga = findManga(mangaId);
|
final Manga currentManga = findManga(mangaId);
|
||||||
currentReader.getMangas().remove(currentManga);
|
currentReader.getMangas().remove(currentManga);
|
||||||
/* currentManga.getReaders().remove(currentReader);*/
|
/* currentManga.getReaders().remove(currentReader);*/
|
||||||
mangaRepository.save(currentManga);
|
mangaRepository.save(currentManga);
|
||||||
return readerRepository.save(currentReader);
|
readerRepository.save(currentReader);
|
||||||
|
return currentManga;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
package com.LabWork.app;
|
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.context.annotation.Configuration;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@@ -10,4 +16,18 @@ public class WebConfiguration implements WebMvcConfigurer {
|
|||||||
public void addCorsMappings(CorsRegistry registry) {
|
public void addCorsMappings(CorsRegistry registry) {
|
||||||
registry.addMapping("/**").allowedMethods("*");
|
registry.addMapping("/**").allowedMethods("*");
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public void addViewControllers(ViewControllerRegistry registry) {
|
||||||
|
registry.addViewController("/notFound").setViewName("forward:/index.html");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public WebServerFactoryCustomizer<ConfigurableServletWebServerFactory> containerCustomizer() {
|
||||||
|
return container -> {
|
||||||
|
container.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND,
|
||||||
|
"/notFound"));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||