Кроме map

This commit is contained in:
maxnes3 2023-05-13 20:54:03 +04:00
parent 3a9239b77e
commit b7efb56646
5 changed files with 6 additions and 41 deletions

View File

@ -107,7 +107,7 @@ public class AuthorService {
@Transactional
public void addBookToAuthor(Long id, Long bookId){
Optional<Author> author = authorRepository.findById(id);
if (author.isPresent()){
if (author.isPresent() && !author.get().getBooks().contains(bookRepository.findById(bookId).get())){
author.get().addBook(bookRepository.findById(bookId).get());
}
authorRepository.save(author.get());
@ -116,7 +116,7 @@ public class AuthorService {
@Transactional
public void removeBookFromAuthor(Long id, Long bookId){
Optional<Author> author = authorRepository.findById(id);
if(author.isPresent()){
if(author.isPresent() && author.get().getBooks().contains(bookRepository.findById(bookId).get())){
author.get().removeBook(bookRepository.findById(bookId).get());
}
authorRepository.save(author.get());

View File

@ -112,7 +112,7 @@ public class BookService {
@Transactional
public void addGenreToBook(Long id, Long genreId){
Optional<Book> book = bookRepository.findById(id);
if (book.isPresent()){
if (book.isPresent() && !book.get().getGenres().contains(genreRepository.findById(genreId).get())){
book.get().addGenre(genreRepository.findById(genreId).get());
}
bookRepository.save(book.get());
@ -121,7 +121,7 @@ public class BookService {
@Transactional
public void removeGenreFromBook(Long id, Long genreId){
Optional<Book> book = bookRepository.findById(id);
if(book.isPresent()){
if(book.isPresent() && book.get().getGenres().contains(genreRepository.findById(genreId).get())){
book.get().removeGenre(genreRepository.findById(genreId).get());
}
bookRepository.save(book.get());

View File

@ -11,8 +11,8 @@
<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
<div class="navbar-nav">
<a class="nav-link active" aria-current="page" href="/authors">Authors</a>
<a class="nav-link" href="/books">Books</a>
<a class="nav-link" href="/genres">Genres</a>
<a class="nav-link active" href="/books">Books</a>
<a class="nav-link active" href="/genres">Genres</a>
</div>
</div>
</div>

View File

@ -4,7 +4,6 @@ import axios from "axios";
import Header from '../components/Header.vue';
import Footer from '../components/Footer.vue';
import Author from '../models/Author';
import Book from '../models/Book';
export default{
components:{
Header,

View File

@ -33,40 +33,6 @@ export default{
<template>
<Header></Header>
<main class="container" style="margin-top: 50pt;">
<div class="input-group mb-2 my-5">
<span class="input-group-text bg-primary text-white" id="basic-addon1"><strong>Действие:</strong></span>
<select class="form-select" aria-label="Default select example" v-model="action">
<option value="+">Plus(+)</option>
<option value="-">Minus(-)</option>
<option value="*">Multi(*)</option>
<option value=":">Div(\)</option>
</select>
</div>
<div class="input-group mb-2">
<span class="input-group-text bg-primary text-white" id="basic-addon1"><strong>Тип данных:</strong></span>
<select class="form-select" aria-label="Default select example" v-model="type">
<option value="int">Integer{}</option>
<option value="string">String"_"</option>
<option value="array">Array[]</option>
</select>
</div>
<div class="input-group mb-2">
<span class="input-group-text bg-primary text-white" id="basic-addon1"><strong>Аргумент1:</strong></span>
<input type="text" class="form-control" placeholder="Введите превую строку" v-model="str_1">
</div>
<div class="input-group mb-2">
<span class="input-group-text bg-primary text-white" id="basic-addon1"><strong>Аргумент2:</strong></span>
<input type="text" class="form-control" placeholder="Введите вторую строку" v-model="str_2">
</div>
<div class="input-group mb-2">
<span class="input-group-text bg-success text-white" id="basic-addon1"><strong>Вывод:</strong></span>
<input type="text" class="form-control" placeholder="Выводит рузультат здесь" v-model="result" readonly>
</div>
<div class="mb-2 d-flex justify-content-center">
<button type="submit" class="btn btn-success" @click.prevent="GetRepuest"><strong>GET</strong></button>
</div>
</main>
<Footer></Footer>
</template>