Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Samuel Dudík
PA165 Winery Management System
Commits
24bc3d38
Commit
24bc3d38
authored
May 14, 2022
by
xkorenk
Browse files
working ProductReview
parent
359f95e2
Pipeline
#139084
passed with stages
in 2 minutes and 31 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
winery/webapp/src/main/java/cz/muni/fi/pa165/winery/webapp/controllers/ProductReviewController.java
View file @
24bc3d38
...
...
@@ -116,10 +116,20 @@ public class ProductReviewController extends ControllerBase{
}
var
dto
=
viewModel
.
toDto
(
getCurrentUser
().
getId
());
productReviewService
.
create
(
dto
);
var
reviews
=
productReviewService
.
getAllByBottle
(
dto
.
getWineBottleId
());
List
<
Long
>
users
=
reviews
.
stream
()
.
map
(
x
->
x
.
getUserId
())
.
distinct
()
.
collect
(
Collectors
.
toList
());
if
(!
users
.
contains
(
dto
.
getUserId
())){
productReviewService
.
create
(
dto
);
viewModel
.
setSuccess
(
true
);
}
else
{
viewModel
.
setExists
(
true
);
}
initializeViewModel
(
viewModel
);
viewModel
.
setSuccess
(
true
);
return
view
(
viewModel
);
}
...
...
winery/webapp/src/main/java/cz/muni/fi/pa165/winery/webapp/models/productReview/ProductReviewUpsertViewModel.java
View file @
24bc3d38
...
...
@@ -32,6 +32,8 @@ public class ProductReviewUpsertViewModel extends ViewModelBase {
private
boolean
success
;
private
boolean
exists
;
/**
* grade of wine
*/
...
...
winery/webapp/src/main/resources/templates/productreview/add.html
View file @
24bc3d38
...
...
@@ -9,10 +9,7 @@
<div
class=
"container px-4 px-lg-5"
>
<main
role=
"main"
class=
"pb-3"
>
<h1>
<span>
Review - Add
</span>
<span
th:text=
"${model.currentUser.id}"
></span>
</h1>
<h1>
Review - Add
</h1>
<a
class=
"btn btn-secondary"
th:href=
"@{/productreview}"
>
Back
</a>
<div
th:if=
"${model.success}"
>
...
...
@@ -21,8 +18,14 @@
</div>
</div>
<div
th:if=
"${model.exists}"
>
<div
class=
"alert alert-success"
role=
"alert"
>
This user already created review for this product
</div>
</div>
<form
th:action=
"@{/productreview/add}"
th:object=
"${model}"
method=
"post"
>
<input
type=
"hidden"
th:field=
"*{
u
serId}"
th:value=
"*{currentUser.id}"
>
<input
type=
"hidden"
th:field=
"*{
U
serId}"
>
<div
class=
"form-group"
>
<label
th:for=
"*{wineBottleId}"
th:value=
"*{wineBottleId}"
>
Bottle
</label>
<select
class=
"form-control"
th:field=
"*{wineBottleId}"
>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment