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) @CheckWebAccess(auth_method = AuthMethod.STEAM64)
@WaitAfterNext(order = "banlist") @WaitAfterNext(order = "banlist")
@CollectStatistic @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<>( return new ResponseEntity<>(
banRepository.getBans(pageable, banRepository.getBans(pageable,
banSearchFilter.getBan_ids(), banSearchFilter.getBan_ids(),
banSearchFilter.getAccounts(profileService), banSearchFilter.getAccounts(profileService),
banSearchFilter.getBeginTimestamp(), banSearchFilter.getBeginUnixTime(),
banSearchFilter.getEndTimestamp(), banSearchFilter.getEndUnixTime(),
banSearchFilter.getActiveObj(),
banSearchFilter.getActive(), banSearchFilter.getActive(),
banSearchFilter.getAdminIds(profileService)) banSearchFilter.getAdminIds(profileService))
, HttpStatus.OK); , HttpStatus.OK);

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

@ -1,11 +1,10 @@
package app.entities.db; package app.entities.db;
import app.entities.db.converter.SteamIdSteam64Converter;
import app.entities.other.SteamID;
import app.utils.SteamIDConverter; import app.utils.SteamIDConverter;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.Column; import jakarta.persistence.*;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.Data; import lombok.Data;
import java.sql.ResultSet; import java.sql.ResultSet;
@ -42,7 +41,15 @@ public class AdminInfo {
@Column(name = "steam3", nullable = false) @Column(name = "steam3", nullable = false)
@JsonIgnore @JsonIgnore
String steam3; String steam3;
@Transient
String steam_url; String steam_url;
@JsonIgnore
@Column(name = "steam3", insertable = false, updatable = false)
@Convert(converter = SteamIdSteam64Converter.class)
SteamID steamID;
@JsonIgnore @JsonIgnore
@Column(name = "permition", nullable = false) @Column(name = "permition", nullable = false)
int permition; int permition;
@ -70,4 +77,8 @@ public class AdminInfo {
public 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 { public class Ban {
@Id @Id
@Column(name = "id") @Column(name = "id")
int id; private int id;
@Column(name = "steam_id", length = 32) @Column(name = "steam_id", length = 32)
String steam_id; private String steam_id;
@Column(name = "account_id") @Column(name = "account_id")
Long account_id; private Long account_id;
@Column(name = "player_name", length = 65) @Column(name = "player_name", length = 65)
String player_name; private String player_name;
@Column(name = "ban_length") @Column(name = "ban_length")
int ban_length; private int ban_length;
@Transient @Transient
Long ban_length_seconds; private Long ban_length_seconds;
@Column(name = "ban_reason", length = 100) @Column(name = "ban_reason", length = 100)
String ban_reason; private String ban_reason;
@Column(name = "banned_by", length = 100) @Column(name = "banned_by", length = 100)
String banned_by; private String banned_by;
@Column(name = "banned_by_id") @Column(name = "banned_by_id")
String banned_by_id; private String banned_by_id;
@Column(name = "ip", length = 15) @Column(name = "ip", length = 15)
String ip; private String ip;
@Column(name = "timestamp") @Column(name = "timestamp")
Timestamp timestamp; private Timestamp timestamp;
@Transient @Transient
Long ban_utime; private Long ban_utime;
@Column(name = "active") @Column(name = "active")
boolean active; private Boolean active;
@Column(name = "unbanned_by_id", length = 32) @Column(name = "unbanned_by_id", length = 32)
String unbanned_by_id; private String unbanned_by_id;
@Column(name = "unbanned_timestamp") @Column(name = "unbanned_timestamp")
Timestamp unbanned_timestamp; private Timestamp unbanned_timestamp;
@ManyToOne @ManyToOne
@JoinColumn(name = "banned_by_id", referencedColumnName = "steam3", insertable=false, updatable=false) @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; return ban_ids == null || ban_ids.isEmpty() ? null : ban_ids;
} }
public boolean getActive() { public Boolean getActive() {
return active != null && active; return active;
}
public Integer getActiveObj() {
return active == null?null:1;
} }
public List<String> getAdminIds(ProfileService profileService) { 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 " + @Query(value = "select b from Ban b where " +
"(:ban_ids is null or b.id in :ban_ids) and " + "(:ban_ids is null or b.id in :ban_ids) and " +
"(:account_ids is null or b.account_id in :account_ids) and " + "(:account_ids is null or b.account_id in :account_ids) and " +
"(:begin_date is null or b.timestamp >= :begin_date) and " + "(:begin_date is null or DATE_PART('EPOCH', b.timestamp) >= :begin_date) and " +
"(:end_date is null or :end_date <= b.timestamp) and " + "(:end_date is null or :end_date <= DATE_PART('EPOCH', b.timestamp)) and " +
"(:active_null is null or b.active = :active) and " + "(:active is null or b.active = :active) and " +
"(:admin_ids is null or b.unbanned_by_id in :admin_ids)") "(:admin_ids is null or b.unbanned_by_id in :admin_ids)")
Page<Ban> getBans(Pageable pageable, Page<Ban> getBans(Pageable pageable,
@Param(value = "ban_ids")List<Long> ban_ids, @Param(value = "ban_ids")List<Long> ban_ids,
@Param(value = "account_ids") List<Long> account_ids, @Param(value = "account_ids") List<Long> account_ids,
@Param(value = "begin_date") Timestamp begin_date, @Param(value = "begin_date") Long begin_date,
@Param(value = "end_date") Timestamp end_date, @Param(value = "end_date") Long end_date,
@Param(value = "active_null") Integer active_null, @Param(value = "active") Boolean active,
@Param(value = "active") boolean active,
@Param(value = "admin_ids") List<String> admin_ids); @Param(value = "admin_ids") List<String> admin_ids);
} }

Loading…
Cancel
Save