added EP rejected posts for admin
This commit is contained in:
@@ -5,18 +5,25 @@ import com.krylov.refound.entity.User;
|
||||
import com.krylov.refound.enums.PostStatus;
|
||||
import com.krylov.refound.enums.PostType;
|
||||
import jakarta.persistence.criteria.Join;
|
||||
import java.util.Set;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
public class PostSpecification {
|
||||
|
||||
/**
|
||||
* Поиск для админской ленты: видимы все объявления, включая MODERATION и REJECTED.
|
||||
* Поиск для админской ленты: видны только статусы из {@code allowedStatuses},
|
||||
* параметр {@code status} сужает выборку внутри них. {@code allowedStatuses == null}
|
||||
* снимает ограничение по статусу (все объявления, включая MODERATION и REJECTED).
|
||||
* Совпадение ищется по названию, описанию, городу, району и данным владельца.
|
||||
*/
|
||||
public static Specification<Post> adminSearch(String search, PostType type, PostStatus status) {
|
||||
public static Specification<Post> adminSearch(
|
||||
String search, PostType type, PostStatus status, Set<PostStatus> allowedStatuses) {
|
||||
return Specification.allOf(
|
||||
(root, query, cb) -> type == null ? cb.conjunction() : cb.equal(root.get("type"), type),
|
||||
(root, query, cb) -> allowedStatuses == null || allowedStatuses.isEmpty()
|
||||
? cb.conjunction()
|
||||
: root.get("status").in(allowedStatuses),
|
||||
(root, query, cb) -> status == null ? cb.conjunction() : cb.equal(root.get("status"), status),
|
||||
(root, query, cb) -> {
|
||||
if (!StringUtils.hasText(search)) {
|
||||
|
||||
Reference in New Issue
Block a user