check if article.image is null
This commit is contained in:
parent
1a1502b38c
commit
38fcda708f
@ -208,7 +208,10 @@ public class InternArticleController {
|
|||||||
public long id;
|
public long id;
|
||||||
|
|
||||||
void addListedArticle(Article article, int stock) {
|
void addListedArticle(Article article, int stock) {
|
||||||
|
|
||||||
|
if (article.image != null) {
|
||||||
this.imgPath = article.image.path;
|
this.imgPath = article.image.path;
|
||||||
|
}
|
||||||
this.title = article.title;
|
this.title = article.title;
|
||||||
this.price_netto = String.format("%.2f", ((float) article.shopPricePerUnitNetCent / 100));
|
this.price_netto = String.format("%.2f", ((float) article.shopPricePerUnitNetCent / 100));
|
||||||
this.price = String.format("%.2f", ((float) article.getPriceGross() / 100));
|
this.price = String.format("%.2f", ((float) article.getPriceGross() / 100));
|
||||||
@ -338,7 +341,9 @@ public class InternArticleController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void addArticle(Article article, int stock) {
|
void addArticle(Article article, int stock) {
|
||||||
|
if (article.image != null) {
|
||||||
this.imgPath = article.image.path;
|
this.imgPath = article.image.path;
|
||||||
|
}
|
||||||
this.title = article.title;
|
this.title = article.title;
|
||||||
this.price_netto = String.format("%.2f", ((float) article.shopPricePerUnitNetCent / 100));
|
this.price_netto = String.format("%.2f", ((float) article.shopPricePerUnitNetCent / 100));
|
||||||
this.price = String.format("%.2f", ((float) article.getPriceGross() / 100));
|
this.price = String.format("%.2f", ((float) article.getPriceGross() / 100));
|
||||||
|
@ -100,8 +100,11 @@ public class ShopArticleController {
|
|||||||
@PathVariable("id") Long id
|
@PathVariable("id") Long id
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
Article article = articleRepository.findArticleById(id);
|
Article article = articleRepository.findArticleById(id);
|
||||||
|
|
||||||
|
if(article.image != null) {
|
||||||
InputStream in = new FileInputStream(article.image.path);
|
InputStream in = new FileInputStream(article.image.path);
|
||||||
response.setContentType(MediaType.IMAGE_JPEG_VALUE);
|
response.setContentType(MediaType.IMAGE_JPEG_VALUE);
|
||||||
IOUtils.copy(in, response.getOutputStream());
|
IOUtils.copy(in, response.getOutputStream());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user