сущности готовы
This commit is contained in:
parent
402b25c5cc
commit
10ba7def55
@ -15,6 +15,7 @@ repositories {
|
||||
dependencies {
|
||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||
developmentOnly 'org.springframework.boot:spring-boot-devtools'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
|
||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,4 @@
|
||||
package ru.ip.labworks.labworks.bookshop.controller;
|
||||
|
||||
public class BookController {
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package ru.ip.labworks.labworks.bookshop.controller;
|
||||
|
||||
public class GenreController {
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package ru.ip.labworks.labworks.bookshop.model;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.*;
|
||||
|
||||
@Entity
|
||||
public class Book {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private Long id;
|
||||
private String name;
|
||||
private Date release;
|
||||
@ManyToMany
|
||||
@JoinTable(name = "books_genres",
|
||||
joinColumns = @JoinColumn(name = "book_fk"),
|
||||
inverseJoinColumns = @JoinColumn(name = "genre_fk"))
|
||||
private List<Genre> genres;
|
||||
|
||||
public Book(){}
|
||||
public Book(String name,Date release){
|
||||
this.name = name;
|
||||
this.release = release;
|
||||
}
|
||||
|
||||
public Long getId(){return id;}
|
||||
|
||||
public String getName(){return name;}
|
||||
public void setName(String name){this.name = name;}
|
||||
|
||||
public Date getRelease(){return release;}
|
||||
public void setRelease(Date release){this.release = release;}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Book book = (Book) o;
|
||||
return Objects.equals(id, book.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Book{" +
|
||||
"id=" + id +
|
||||
", name='" + name + '\'' +
|
||||
", release='" + release + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package ru.ip.labworks.labworks.bookshop.model;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.*;
|
||||
|
||||
@Entity
|
||||
public class Genre {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private Long id;
|
||||
private String name;
|
||||
@ManyToMany(mappedBy = "genres")
|
||||
private List<Book> books;
|
||||
|
||||
public Genre(){}
|
||||
public Genre(String name){
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Long getId(){return id;}
|
||||
|
||||
public String getName(){return name;}
|
||||
public void setName(String name){this.name = name;}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Genre genre = (Genre) o;
|
||||
return Objects.equals(id, genre.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Genre{" +
|
||||
"id=" + id +
|
||||
", name='" + name + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package ru.ip.labworks.labworks.bookshop.service;
|
||||
|
||||
public class BookService {
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package ru.ip.labworks.labworks.bookshop.service;
|
||||
|
||||
public class GenreService {
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
package ru.ip.labworks.labworks.controller;
|
||||
package ru.ip.labworks.labworks.calculator.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import ru.ip.labworks.labworks.service.CalculatorService;
|
||||
import ru.ip.labworks.labworks.calculator.service.CalculatorService;
|
||||
|
||||
@RestController
|
||||
public class UserController {
|
@ -1,4 +1,4 @@
|
||||
package ru.ip.labworks.labworks.domain;
|
||||
package ru.ip.labworks.labworks.calculator.domain;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package ru.ip.labworks.labworks.domain;
|
||||
package ru.ip.labworks.labworks.calculator.domain;
|
||||
|
||||
public interface ITypeCalculator<T> {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package ru.ip.labworks.labworks.domain;
|
||||
package ru.ip.labworks.labworks.calculator.domain;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package ru.ip.labworks.labworks.domain;
|
||||
package ru.ip.labworks.labworks.calculator.domain;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
@ -1,8 +1,8 @@
|
||||
package ru.ip.labworks.labworks.service;
|
||||
package ru.ip.labworks.labworks.calculator.service;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.ip.labworks.labworks.domain.ITypeCalculator;
|
||||
import ru.ip.labworks.labworks.calculator.domain.ITypeCalculator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
@ -5,7 +5,7 @@ import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import ru.ip.labworks.labworks.service.CalculatorService;
|
||||
import ru.ip.labworks.labworks.calculator.service.CalculatorService;
|
||||
|
||||
@SpringBootTest
|
||||
class LabworksApplicationTests {
|
||||
|
Loading…
x
Reference in New Issue
Block a user