Browse Source

пельмень апдейт 3.5.7a

master
gsd 1 month ago
parent
commit
bf189e52db
  1. 9
      src/main/java/app/controllers/user/PublicController.java
  2. 19
      src/main/java/app/entities/db/AdminInfo.java
  3. 30
      src/main/java/app/entities/db/ban/Ban.java
  4. 8
      src/main/java/app/entities/db/ban/BanSearchFilter.java
  5. 13
      src/main/java/app/repositories/BanRepository.java

9
src/main/java/app/controllers/user/PublicController.java

@ -61,14 +61,15 @@ public class PublicController {
@CheckWebAccess(auth_method = AuthMethod.STEAM64)
@WaitAfterNext(order = "banlist")
@CollectStatistic
public ResponseEntity<Page<Ban>> getBanListWithFilters(Pageable pageable, @RequestBody BanSearchFilter banSearchFilter) {
public ResponseEntity<Page<Ban>> getBanListWithFilters(Pageable pageable, @RequestBody(required = false) BanSearchFilter banSearchFilter) {
if (banSearchFilter == null) banSearchFilter = new BanSearchFilter();
return new ResponseEntity<>(
banRepository.getBans(pageable,
banSearchFilter.getBan_ids(),
banSearchFilter.getAccounts(profileService),
banSearchFilter.getBeginTimestamp(),
banSearchFilter.getEndTimestamp(),
banSearchFilter.getActiveObj(),
banSearchFilter.getBeginUnixTime(),
banSearchFilter.getEndUnixTime(),
banSearchFilter.getActive(),
banSearchFilter.getAdminIds(profileService))
, HttpStatus.OK);

19
src/main/java/app/entities/db/AdminInfo.java

@ -1,11 +1,10 @@
package app.entities.db;
import app.entities.db.converter.SteamIdSteam64Converter;
import app.entities.other.SteamID;
import app.utils.SteamIDConverter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import jakarta.persistence.*;
import lombok.Data;
import java.sql.ResultSet;
@ -42,7 +41,15 @@ public class AdminInfo {
@Column(name = "steam3", nullable = false)
@JsonIgnore
String steam3;
@Transient
String steam_url;
@JsonIgnore
@Column(name = "steam3", insertable = false, updatable = false)
@Convert(converter = SteamIdSteam64Converter.class)
SteamID steamID;
@JsonIgnore
@Column(name = "permition", nullable = false)
int permition;
@ -70,4 +77,8 @@ public class AdminInfo {
public AdminInfo() {
}
public String getSteam_url() {
return steam_url == null ? steamID.community_url : steam_url;
}
}

30
src/main/java/app/entities/db/ban/Ban.java

@ -37,35 +37,35 @@ CREATE TABLE `light_bans` (
public class Ban {
@Id
@Column(name = "id")
int id;
private int id;
@Column(name = "steam_id", length = 32)
String steam_id;
private String steam_id;
@Column(name = "account_id")
Long account_id;
private Long account_id;
@Column(name = "player_name", length = 65)
String player_name;
private String player_name;
@Column(name = "ban_length")
int ban_length;
private int ban_length;
@Transient
Long ban_length_seconds;
private Long ban_length_seconds;
@Column(name = "ban_reason", length = 100)
String ban_reason;
private String ban_reason;
@Column(name = "banned_by", length = 100)
String banned_by;
private String banned_by;
@Column(name = "banned_by_id")
String banned_by_id;
private String banned_by_id;
@Column(name = "ip", length = 15)
String ip;
private String ip;
@Column(name = "timestamp")
Timestamp timestamp;
private Timestamp timestamp;
@Transient
Long ban_utime;
private Long ban_utime;
@Column(name = "active")
boolean active;
private Boolean active;
@Column(name = "unbanned_by_id", length = 32)
String unbanned_by_id;
private String unbanned_by_id;
@Column(name = "unbanned_timestamp")
Timestamp unbanned_timestamp;
private Timestamp unbanned_timestamp;
@ManyToOne
@JoinColumn(name = "banned_by_id", referencedColumnName = "steam3", insertable=false, updatable=false)

8
src/main/java/app/entities/db/ban/BanSearchFilter.java

@ -18,12 +18,8 @@ public class BanSearchFilter extends SearchFilter {
return ban_ids == null || ban_ids.isEmpty() ? null : ban_ids;
}
public boolean getActive() {
return active != null && active;
}
public Integer getActiveObj() {
return active == null?null:1;
public Boolean getActive() {
return active;
}
public List<String> getAdminIds(ProfileService profileService) {

13
src/main/java/app/repositories/BanRepository.java

@ -15,16 +15,15 @@ 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 :account_ids) and " +
"(:begin_date is null or b.timestamp >= :begin_date) and " +
"(:end_date is null or :end_date <= b.timestamp) and " +
"(:active_null is null or b.active = :active) and " +
"(:begin_date is null or DATE_PART('EPOCH', b.timestamp) >= :begin_date) and " +
"(:end_date is null or :end_date <= DATE_PART('EPOCH', 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_null") Integer active_null,
@Param(value = "active") boolean active,
@Param(value = "begin_date") Long begin_date,
@Param(value = "end_date") Long end_date,
@Param(value = "active") Boolean active,
@Param(value = "admin_ids") List<String> admin_ids);
}

Loading…
Cancel
Save