Fix Repo Entities
This commit is contained in:
@@ -21,8 +21,9 @@ public class ArticleConfiguration {
|
|||||||
@Column(name = "id", nullable = false)
|
@Column(name = "id", nullable = false)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Column(name = "articleId", nullable = false)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
private Long articleId;
|
@JoinColumn(name = "articleId", referencedColumnName = "id", nullable = false)
|
||||||
|
private Article article;
|
||||||
|
|
||||||
@Column(name = "name", nullable = false)
|
@Column(name = "name", nullable = false)
|
||||||
private String name;
|
private String name;
|
||||||
|
|||||||
@@ -18,8 +18,9 @@ public class Image {
|
|||||||
@Column(name = "id", nullable = false)
|
@Column(name = "id", nullable = false)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Column(name = "articleId", nullable = false)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
private Long articleId;
|
@JoinColumn(name = "articleId", referencedColumnName = "id", nullable = false)
|
||||||
|
private Article article;
|
||||||
|
|
||||||
@Column(name = "uri", nullable = false)
|
@Column(name = "uri", nullable = false)
|
||||||
private String uri;
|
private String uri;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ public class Order {
|
|||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
@MapsId("customerId")
|
@JoinColumn(name = "customerId")
|
||||||
private Customer customer;
|
private Customer customer;
|
||||||
|
|
||||||
@Column(name = "time")
|
@Column(name = "time")
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public class Review {
|
|||||||
private String content;
|
private String content;
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
@MapsId("articleId")
|
@JoinColumn(name = "articleId", referencedColumnName = "id", nullable = false)
|
||||||
private Article article;
|
private Article article;
|
||||||
|
|
||||||
@PositiveOrZero
|
@PositiveOrZero
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package de.htwsaar.webshop.service.impl;
|
|||||||
import de.htwsaar.webshop.model.ImageModel;
|
import de.htwsaar.webshop.model.ImageModel;
|
||||||
import de.htwsaar.webshop.repository.ImageRepository;
|
import de.htwsaar.webshop.repository.ImageRepository;
|
||||||
import de.htwsaar.webshop.repository.entities.Image;
|
import de.htwsaar.webshop.repository.entities.Image;
|
||||||
import de.htwsaar.webshop.service.ArticleService;
|
|
||||||
import de.htwsaar.webshop.service.ImageService;
|
import de.htwsaar.webshop.service.ImageService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -15,12 +14,10 @@ import java.util.List;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class ImageServiceImpl implements ImageService {
|
public class ImageServiceImpl implements ImageService {
|
||||||
private final ImageRepository imageRepository;
|
private final ImageRepository imageRepository;
|
||||||
private final ArticleService articleService;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public ImageServiceImpl(ImageRepository imageRepository, ArticleService articleService) {
|
public ImageServiceImpl(ImageRepository imageRepository) {
|
||||||
this.imageRepository = imageRepository;
|
this.imageRepository = imageRepository;
|
||||||
this.articleService = articleService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -46,7 +43,7 @@ public class ImageServiceImpl implements ImageService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ImageModel from(Image image) {
|
public ImageModel from(Image image) {
|
||||||
return new ImageModel(articleService.findById(image.getArticleId()).getUuid(), image.getUri());
|
return new ImageModel(image.getArticle().getUuid(), image.getUri());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user