Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public final class Constants {
public static final String SUCCESS_STRING = "success";

public final static String WISHLIST_CONST = "wishlist";
public final static String SHOPPING_CART_CONST = "shopping-cart";
public final static String SHOPPING_CART_CONST = "корзина";
public final static String ORDERS_CONST = "orders";
public final static String ID_CONST = "id";
public final static String NAME_CONST = "name";
Expand All @@ -34,10 +34,10 @@ public final class Constants {
public static final String WISHLIST_NOT_FOUND_EXCEPTION_MESSAGE = "Wishlist with this id does not exist!";
public static final String ROLE_NOT_FOUND_EXCEPTION_MESSAGE = "Role with this name does not exist!";
public static final String DUPLICATE_USER_EXCEPTION_MESSAGE = "User with this username already exists!";
public static final String DUPLICATE_EMAIL_EXCEPTION_MESSAGE = "User with this email already exists!";
public static final String DUPLICATE_EMAIL_EXCEPTION_MESSAGE = "User with this email address already exists!";
public final static String CANT_FIND_USER_WITH_THIS_ID_EXCEPTION_MESSAGE = "Can't find user with this id!";
public final static String EMPTY_LIST_NAME = "emptyList";
public final static String EMPTY_LIST_SINGULAR_MESSAGE = "Your %s is empty!";
public final static String EMPTY_LIST_SINGULAR_MESSAGE = "Ваша %s пустая!";
public final static String EMPTY_LIST_PLURAL_MESSAGE = "Your %s are empty!";
public final static String EMPTY_MODERATOR_ORDERS_MESSAGE = "There are currently no orders!";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@ public interface UserService extends UserDetailsService {

void setRole(String id, String role);

void existsByUsername(String username);
boolean existsByUsername(String username);

void existsByEmail(String email);

boolean existsByEmailAddress(String email);


UserServiceModel addMoneyToBalance(UserServiceModel userServiceModel, BigDecimal moneyToAdd);

UserServiceModel updateMoneyAfterCheckout(UserServiceModel userServiceModel, BigDecimal orderTotalPrice);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,13 @@ public void setRole(String id, String role) {
}

@Override
public void existsByUsername(String username) {
public boolean existsByUsername(String username) {
boolean b = false;
if (this.userRepository.existsByUsername(username)) {
throw new DuplicateUsernameException(DUPLICATE_USER_EXCEPTION_MESSAGE);
b = true;
// throw new DuplicateUsernameException(DUPLICATE_USER_EXCEPTION_MESSAGE);
}
return b;
}

@Override
Expand All @@ -152,6 +155,11 @@ public void existsByEmail(String email) {
}
}

@Override
public boolean existsByEmailAddress(String email) {
return this.userRepository.existsByEmail(email);
}

@Override
public UserServiceModel addMoneyToBalance(UserServiceModel userServiceModel, BigDecimal moneyToAdd) {
User user = this.modelMapper.map(userServiceModel, User.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class UserController extends BaseController {
private final ModelMapper modelMapper;
private final UserEditProfileValidator userEditProfileValidator;


@Autowired
public UserController(UserService userService, CategoryService categoryService, CloudinaryService cloudinaryService, RecaptchaService recaptchaService, ModelMapper modelMapper, UserEditProfileValidator userEditProfileValidator) {
this.userService = userService;
Expand All @@ -56,6 +57,7 @@ public UserController(UserService userService, CategoryService categoryService,
this.userEditProfileValidator = userEditProfileValidator;
}


@GetMapping("/register")
@PreAuthorize(IS_ANONYMOUS)
@PageTitle(REGISTER_PAGE_TITLE)
Expand All @@ -70,13 +72,26 @@ public ModelAndView registerConfirm(@ModelAttribute(name = MODEL_ATTRIBUTE) User
ModelAndView modelAndView,
HttpServletRequest request) {

this.userService.existsByUsername(model.getUsername());
this.userService.existsByEmail(model.getEmail());
// this.userService.existsByUsername(model.getUsername());
// this.userService.existsByEmail(model.getEmail());

if ( this.userService.existsByUsername(model.getUsername())) {
modelAndView.addObject("duplicateUser", DUPLICATE_USER_EXCEPTION_MESSAGE);
return view("/users/register", modelAndView);
}

if (!model.getPassword().equals(model.getConfirmPassword())) {
modelAndView.addObject(PASSWORDS_DONT_MATCH_ATTRIBUTE, PASSWORDS_DONT_MATCH_MESSAGE);
return view("/users/register", modelAndView);
}


if (this.userService.existsByEmailAddress(model.getEmail())) {
modelAndView.addObject("duplicateEmailAddress", DUPLICATE_EMAIL_EXCEPTION_MESSAGE);
return view("/users/register", modelAndView);
}


if (this.recaptchaService.verifyRecaptcha(request.getRemoteAddr(), gRecaptchaResponse) == null) {
modelAndView.addObject(RECAPTCHA_ERROR_ATTRIBUTE, RECAPTCHA_ERROR_MESSAGE);
return view("/users/register", modelAndView);
Expand Down
19 changes: 0 additions & 19 deletions src/main/resources/application.properties

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/resources/static/css/bootstrap.min.css

Large diffs are not rendered by default.

105 changes: 94 additions & 11 deletions src/main/resources/static/css/style.css
Original file line number Diff line number Diff line change
@@ -1,14 +1,36 @@
hr.hr-2 {
height: 2px;
.ul-nav-bar {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: rgba(0, 0, 0, 0.95);
}

hr {
.ul-nav-bar1 {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: rgba(249, 249, 234, 0.95);
}

color: #123455;
.box{
width: 300px;
padding: 40px;
position: absolute;
top: 40%;
left: 40%;
transform: translater(-50%, -50%);
background: none;
text-align: center;

}

.form-group input[type = "text"]{
.box h1{
color: white;
text-transform: uppercase;
font-weight: 500;
}
.inputU input[type = "text"]{
border: 0;
background: none;
display: block;
Expand All @@ -23,8 +45,22 @@ hr {
transition: 0.50s;

}
.inputE input[type = "email"]{
border: 0;
background: none;
display: block;
margin: 20px auto;
text-align: center ;
border: 2px solid #3498db;
padding: 14px 10px;
width: 200px;
outline: none;
color: white;
border-radius: 24px;
transition: 0.50s;

.form-group1 input[type="password"]{
}
.inputP input[type="password"]{
border: 0;
background: none;
display: block;
Expand All @@ -40,7 +76,11 @@ hr {

}

.button-holder d-flex justify-content-center input[type = "submit"]{
.inputU input[type = "text"]:focus, .inputP input[type="password"]:focus {
width: 280px;
border-color: #2aee2a;
}
.box input[type = "submit"]{
border: 0;
background: none;
display: block;
Expand All @@ -54,11 +94,55 @@ hr {
transition: 0.150s;
}

.noneNavBar .authenNavBar {
overflow: hidden;
background-color: #0009;
}
.noneNavBar a {
float: left;
display: block;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
.authenNavBar a {
float: left;
display: block;
color: #000000;
text-align: center;
padding: 14px 14px;
text-decoration: none;
}


.authenNavBar h6 {
float: left;
display: block;
color: #000000;
text-align: center;
padding: 14px 2px;
text-decoration: none;
}

video {
width: 100% !important;
height: 100% !important;
}

hr.hr-2 {
height: 2px;
}

hr {
color: #123455;
}

.logout-button {
background: transparent;
border: none;
font-weight: bold;
color: rgba(0, 0, 0, 1) !important;
color: rgb(0, 0, 0) !important;
}

.logout-button:hover {
Expand Down Expand Up @@ -93,5 +177,4 @@ img.img-thumbnail {

.btn-width-wishlist {
margin: 2px;
}

}
20 changes: 10 additions & 10 deletions src/main/resources/templates/cart/details-cart.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
<th:block th:include="~{/fragments/navbar}"></th:block>
</header>
<main class="mt-3">
<h1 class="text-center text-dark">Shopping Cart</h1>
<h1 class="text-center text-dark">Корзина</h1>
<hr class="hr-2 bg-dark w-75">
<table class="table table-hover w-75 mx-auto">
<thead class="thead-light">
<tr class="row mx-auto">
<th class="col-md-2 text-center">Image</th>
<th class="col-md-3 text-center">Name</th>
<th class="col-md-2 text-center">Description</th>
<th class="col-md-2 text-center">Price</th>
<th class="col-md-1 text-center">Quantity</th>
<th class="col-md-2 text-center">Actions</th>
<th class="col-md-2 text-center">Изображения</th>
<th class="col-md-3 text-center">Наименования</th>
<th class="col-md-2 text-center">Характеристики</th>
<th class="col-md-2 text-center">Цена</th>
<th class="col-md-1 text-center">Количество</th>
<th class="col-md-2 text-center">Действия</th>
</tr>
</thead>
<tbody>
Expand All @@ -35,7 +35,7 @@ <h1 class="text-center text-dark">Shopping Cart</h1>
<td class="col-md-2 text-center">
<form th:action="@{/cart/remove-product}" th:method="delete">
<div class="button-holder d-flex justify-content-center">
<button type="submit" class="btn btn-danger">Remove from cart</button>
<button type="submit" class="btn btn-danger">Удалить из корзины</button>
<input type="hidden" name="id" th:value="*{product.id}">
</div>
</form>
Expand All @@ -56,12 +56,12 @@ <h3 style="color: red" th:text="${notEnoughMoneyMessage}"></h3>
</div>

<div class="text-center">
<h3 style="color: green" th:text="|Total Price: ${totalPrice} $|"></h3>
<h3 style="color: green" th:text="|Итоговая сумма: ${totalPrice} $|"></h3>
</div>

<form th:action="@{/cart/checkout-cart}" th:method="post">
<div class="button-holder d-flex justify-content-center mt-4">
<button type="submit" class="btn btn-success">Order</button>
<button type="submit" class="btn btn-success">Оплатить</button>
</div>
</form>
</main>
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/templates/categories/add-category.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@
<th:block th:include="~{/fragments/navbar}"></th:block>
</header>
<main class="mt-3">
<h1 class="text-center text-dark">Add Category</h1>
<h1 class="text-center text-dark">Добавить Категорию</h1>
<hr class="hr-2 bg-dark w-25">
<form id="add-category-form" class="form w-25 mx-auto" th:action="@{/categories/add-category}" th:method="post" th:object="${model}">
<div class="form-group">
<label for="add-category-name" class="font-weight-bold">Name</label>
<label for="add-category-name" class="font-weight-bold">Наименование</label>
<input type="text" class="form-control text-center" id="add-category-name" name="name" required>
<th:block th:if="${#fields.hasErrors('name')}">
<small style="color: red" th:errors="*{name}"></small>
</th:block>
</div>
<hr class="hr-2 bg-dark">
<div class="button-holder d-flex justify-content-center">
<button type="submit" class="btn btn-success">Add Category</button>
<button type="submit" class="btn btn-success">Добавить</button>
</div>
</form>
</main>
Expand Down
10 changes: 5 additions & 5 deletions src/main/resources/templates/categories/all-categories.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
<th:block th:include="~{/fragments/navbar}"></th:block>
</header>
<main class="mt-3">
<h1 class="text-center text-dark">All Categories</h1>
<h1 class="text-center text-dark">Все категории</h1>
<hr class="hr-2 bg-dark w-75">
<table class="table table-hover w-75 mx-auto">
<thead class="thead-light">
<tr class="row mx-auto">
<th class="col-md-2 text-center">#</th>
<th class="col-md-5 text-center">Name</th>
<th class="col-md-5 text-center">Actions</th>
<th class="col-md-5 text-center">Наименование</th>
<th class="col-md-5 text-center">Действия</th>
</tr>
</thead>
<tbody>
Expand All @@ -26,8 +26,8 @@ <h1 class="text-center text-dark">All Categories</h1>
<th class="col-md-2 text-center" th:text="${iter.index + 1}"></th>
<td class="col-md-5 text-center" th:text="${category.name}"></td>
<td class="col-md-5 text-center">
<a th:href="@{/categories/edit-category/{id}(id=${category.id})}" class="btn btn-success btn-width-categories">Edit</a>
<a th:href="@{/categories/delete-category/{id}(id=${category.id})}" class="btn btn-danger btn-width-categories">Delete</a>
<a th:href="@{/categories/edit-category/{id}(id=${category.id})}" class="btn btn-success btn-width-categories">Изменить</a>
<a th:href="@{/categories/delete-category/{id}(id=${category.id})}" class="btn btn-danger btn-width-categories">Удалить</a>
</td>
</tr>
</th:block>
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/templates/categories/delete-category.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
<th:block th:include="~{/fragments/navbar}"></th:block>
</header>
<main class="mt-3">
<h1 class="text-center text-dark">Delete Category</h1>
<h1 class="text-center text-dark">Удалить категорию</h1>
<hr class="hr-2 bg-dark w-25">
<form id="delete-category-form" class="form w-25 mx-auto" th:action="@{/categories/delete-category/{id}(id=${category.id})}" th:method="delete">
<div class="form-group">
<label for="delete-category-name" class="font-weight-bold">Name</label>
<label for="delete-category-name" class="font-weight-bold">Наименование</label>
<input type="text" class="form-control text-center" id="delete-category-name" name="name" th:value="${category.name}" readonly>
</div>
<hr class="hr-2 bg-dark">
<div class="button-holder d-flex justify-content-center">
<button type="submit" class="btn btn-danger">Delete Category</button>
<button type="submit" class="btn btn-danger">Удалить</button>
</div>
</form>
</main>
Expand Down
Loading