Skip to content

Commit 51bce23

Browse files
Fix/add request user (#1271)
* fix(add-request-user): to add request with the user enabled = true * fix(add-request-user): to add request with the user enabled = true * fix(add-request-user): modif request
1 parent 5c53bd9 commit 51bce23

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

yaki_admin_backend/src/main/java/com/xpeho/yaki_admin_backend/data/models/UserModel.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ public UserModel(String lastName, String firstName, String email, String login,
7272
this.password = password;
7373
this.enabled = false;
7474
}
75+
7576

7677
public UserModel() {
7778
this.enabled = false;

yaki_admin_backend/src/main/java/com/xpeho/yaki_admin_backend/data/services/UserServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public Page<UserEntityWithID> findAllUsers(Pageable pageable) {
120120

121121
// Use the UserRepository to find all users, sorted by last name, and return them as a Page of UserModels.
122122
// The findAll method takes the Pageable object as a parameter, which includes the page number, page size, and sorting details.
123-
Page<UserModel> userPage = userJpaRepository.findAll(sortedByName);
123+
Page<UserModel> userPage = userJpaRepository.findAllEnabledUsers(sortedByName);
124124

125125
// Get the total number of pages in the result set. This is calculated based on the total number of items and the page size.
126126
int totalPages = userPage.getTotalPages();

yaki_admin_backend/src/main/java/com/xpeho/yaki_admin_backend/data/sources/UserJpaRepository.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
package com.xpeho.yaki_admin_backend.data.sources;
22

33
import com.xpeho.yaki_admin_backend.data.models.UserModel;
4+
import org.springframework.data.domain.Page;
5+
import org.springframework.data.domain.Pageable;
46
import org.springframework.data.jpa.repository.JpaRepository;
7+
import org.springframework.data.jpa.repository.Query;
58

69
import java.util.List;
710
import java.util.Optional;
811

912
public interface UserJpaRepository extends JpaRepository<UserModel, Integer> {
13+
@Query("""
14+
SELECT u
15+
FROM UserModel u
16+
WHERE u.enabled = true
17+
""")
18+
Page<UserModel> findAllEnabledUsers(Pageable pageable);
19+
1020
Optional<UserModel> findByLogin(String login);
1121

1222
List<UserModel> findByUserIdBetween(int idStart, int idEnd);

0 commit comments

Comments
 (0)