You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

127 lines
3.6 KiB

package app.entities.killfeed;
import app.entities.server.ServerDB;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.*;
import lombok.Data;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import java.sql.ResultSet;
import java.sql.SQLException;
/*
CREATE TABLE user_killfeed (
id bigint(11) NOT NULL,
attacker_id int(11) NOT NULL,
victim_id int(11) NOT NULL,
assister_id int(11) NOT NULL,
utime bigint(20) NOT NULL,
weapon_name varchar(128) NOT NULL,
weapon_id int(11) NOT NULL,
weapon_classname varchar(128) NOT NULL,
weapon_index int(11) NOT NULL,
custom_kill int(11) NOT NULL,
crit_type int(11) NOT NULL,
server_id varchar(32) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
*/
@Data
@Entity
@Cacheable
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
@Table(schema = "tf2_facti13", name = "user_killfeed")
public class KillsInFeed {
@Id
private Long id;
@Column(name = "attacker_id")
private Long attacker_id = -1L;
@Transient
private String attacker_name;
@Column(name = "victim_id")
private Long victim_id = -1L;
@Transient
private String victim_name;
@Column(name = "assister_id")
private Long assister_id = -1L;
@Transient
private String assister_name;
@Column(name = "utime")
private long utime;
@Column(name = "weapon_name", length = 128)
private String weapon_name;
@JsonIgnore
@Column(name = "weapon_id")
private Long weapon_id;
@Column(name = "weapon_classname")
private String weapon_classname;
@JsonIgnore
@Column(name = "weapon_index")
private Long weapon_index;
@JsonIgnore
@Column(name = "custom_kill")
private Long custom_kill;
@JsonIgnore
@Column(name = "crit_type")
private Long crit_type;
@Column(name = "server_id")
private String server_id;
@JsonIgnore
@ManyToOne
@JoinColumn(name = "server_id", referencedColumnName = "srv_id", insertable = false, updatable = false)
private ServerDB serverDB;
@JsonIgnore
@ManyToOne
@JoinColumn(name = "weapon_id", referencedColumnName = "id", insertable = false, updatable = false)
private TF2iDBItem tf2iDBItem;
public KillsInFeed(Object obj) {
this.attacker_id = (long) ((Object[]) obj)[0];
this.victim_id = (long) ((Object[]) obj)[1];
this.assister_id = (long) ((Object[]) obj)[2];
this.utime = (long) ((Object[]) obj)[3];
this.weapon_name = (String) ((Object[]) obj)[4];
this.server_id = (String) ((Object[]) obj)[5];
this.weapon_classname = (String) ((Object[]) obj)[6];
}
public KillsInFeed(ResultSet rs) throws SQLException {
assister_id = rs.getLong(1);
victim_id = rs.getLong(2);
assister_id = rs.getLong(3);
utime = rs.getLong(4);
weapon_name = rs.getString(5);
server_id = rs.getString(6);
weapon_classname = rs.getString(7);
}
public KillsInFeed() {
}
public String getWeapon_name(){
//obj_sentrygun
if (this.weapon_classname.contains("obj_sentrygun"))
return "Турель " + (this.weapon_classname.replace("obj_sentrygun", "").isEmpty()?"1":this.weapon_classname.replace("obj_sentrygun", "")) + " уровня";
return this.tf2iDBItem == null ? this.weapon_name : this.tf2iDBItem.getName();
}
public String getServerName() {
return this.serverDB == null ? "" : this.serverDB.getName();
}
}