11 changed files with 106 additions and 26 deletions
@ -1,5 +1,6 @@ |
|||
package app.entities.db; |
|||
package app.entities.db.ban; |
|||
|
|||
import app.entities.db.AdminInfo; |
|||
import app.entities.other.SteamID; |
|||
import app.services.db.PermitionService; |
|||
import app.utils.CryptedCookie; |
@ -0,0 +1,35 @@ |
|||
package app.entities.db.ban; |
|||
|
|||
import app.entities.SearchFilter; |
|||
import app.services.ProfileService; |
|||
|
|||
import java.util.List; |
|||
import java.util.Objects; |
|||
|
|||
public class BanSearchFilter extends SearchFilter { |
|||
private List<Long> ban_ids; |
|||
private Boolean active; |
|||
private List<String> admin_ids; |
|||
|
|||
public BanSearchFilter() { |
|||
} |
|||
|
|||
public List<Long> getBan_ids() { |
|||
return ban_ids == null || ban_ids.isEmpty() ? null : ban_ids; |
|||
} |
|||
|
|||
public Boolean getActive() { |
|||
return active; |
|||
} |
|||
|
|||
public List<String> getAdminIds(ProfileService profileService) { |
|||
if (admin_ids == null || admin_ids.isEmpty()) return null; |
|||
|
|||
List<String> filtered = admin_ids.stream() |
|||
.map(profileService::GetSteamIDFromAnyData) |
|||
.filter(Objects::nonNull) |
|||
.map(sId -> sId.steam3) |
|||
.toList(); |
|||
return filtered.isEmpty() ? null : filtered; |
|||
} |
|||
} |
@ -0,0 +1,29 @@ |
|||
package app.repositories; |
|||
|
|||
import app.entities.db.ban.Ban; |
|||
import org.springframework.data.domain.Page; |
|||
import org.springframework.data.domain.Pageable; |
|||
import org.springframework.data.jpa.repository.Query; |
|||
import org.springframework.data.repository.PagingAndSortingRepository; |
|||
import org.springframework.data.repository.query.Param; |
|||
|
|||
import java.sql.Timestamp; |
|||
import java.util.List; |
|||
|
|||
public interface BanRepository extends PagingAndSortingRepository<Ban, Long> { |
|||
|
|||
@Query(value = "select b from Ban b where " + |
|||
"(:ban_ids is null or b.id in :ban_ids) and " + |
|||
"(:account_ids is null or b.account_id in :accounts_ids) and " + |
|||
"(:begin_date is null or b.timestamp >= :begin_date) and " + |
|||
"(:end_date is null or :end_date <= b.timestamp) and " + |
|||
"(:active is null or b.active = :active) and " + |
|||
"(:admin_ids is null or b.unbanned_by_id in :admin_ids)") |
|||
Page<Ban> getBans(Pageable pageable, |
|||
@Param(value = "ban_ids")List<Long> ban_ids, |
|||
@Param(value = "account_ids") List<Long> account_ids, |
|||
@Param(value = "begin_date") Timestamp begin_date, |
|||
@Param(value = "end_date") Timestamp end_date, |
|||
@Param(value = "active") Boolean active, |
|||
@Param(value = "admin_ids") List<String> admin_ids); |
|||
} |
Loading…
Reference in new issue