-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix : fix UserAdmissionRepository findAllWithName method(#745)
- Loading branch information
Showing
1 changed file
with
28 additions
and
27 deletions.
There are no files selected for viewing
55 changes: 28 additions & 27 deletions
55
src/main/java/net/causw/adapter/persistence/repository/user/UserAdmissionRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,29 @@ | ||
package net.causw.adapter.persistence.repository.user; | ||
|
||
import net.causw.adapter.persistence.user.UserAdmission; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
import java.util.Optional; | ||
|
||
public interface UserAdmissionRepository extends JpaRepository<UserAdmission, String> { | ||
Optional<UserAdmission> findByUser_Id(String userId); | ||
|
||
Boolean existsByUser_Id(String userId); | ||
|
||
@Query(value = "SELECT * " + | ||
"FROM tb_user_admission AS ua " + | ||
"LEFT JOIN tb_user AS u ON ua.user_id = u.id " + | ||
"WHERE u.state = :user_state ORDER BY ua.created_at DESC", nativeQuery = true) | ||
Page<UserAdmission> findAll(@Param("user_state") String userState, Pageable pageable); | ||
|
||
@Query(value = "SELECT ua.id AS id, ua.user_id,ua.image,ua.reject_reason,ua.description,ua.updated_at,ua.created_at, u.name, u.state " + | ||
"FROM tb_user_admission AS ua " + | ||
"LEFT JOIN tb_user AS u ON ua.user_id = u.id " + | ||
"WHERE u.state = :user_state AND (:name IS NULL OR u.name LIKE %:name%) ORDER BY ua.created_at DESC", nativeQuery = true) | ||
Page<UserAdmission> findAllWithName(@Param("user_state") String userState, @Param("name") String name, Pageable pageable); | ||
package net.causw.adapter.persistence.repository.user; | ||
|
||
import net.causw.adapter.persistence.user.UserAdmission; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
import java.util.Optional; | ||
|
||
public interface UserAdmissionRepository extends JpaRepository<UserAdmission, String> { | ||
Optional<UserAdmission> findByUser_Id(String userId); | ||
|
||
Boolean existsByUser_Id(String userId); | ||
|
||
@Query(value = "SELECT * " + | ||
"FROM tb_user_admission AS ua " + | ||
"LEFT JOIN tb_user AS u ON ua.user_id = u.id " + | ||
"WHERE u.state = :user_state ORDER BY ua.created_at DESC", nativeQuery = true) | ||
Page<UserAdmission> findAll(@Param("user_state") String userState, Pageable pageable); | ||
|
||
@Query(value = "SELECT ua.id AS id, ua.user_id,uai.uuid_file_id AS user_admission_attach_image ,ua.description,ua.updated_at,ua.created_at, u.name, u.state " + | ||
"FROM tb_user_admission AS ua " + | ||
"LEFT JOIN tb_user AS u ON ua.user_id = u.id " + | ||
"LEFT JOIN tb_user_admission_attach_image_uuid_file AS uai ON ua.id = uai.user_admission_id " + | ||
"WHERE u.state = :user_state AND (:name IS NULL OR u.name LIKE %:name%) ORDER BY ua.created_at DESC", nativeQuery = true) | ||
Page<UserAdmission> findAllWithName(@Param("user_state") String userState, @Param("name") String name, Pageable pageable); | ||
} |