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.
 
 
 
 

120 lines
3.2 KiB

package app.entities.db;
import app.entities.server.ServerDB;
import com.fasterxml.jackson.annotation.JsonGetter;
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;
import java.sql.Timestamp;
/*
CREATE TABLE `user_connections` (
`id` int(11) NOT NULL,
`player_name` varchar(64) NOT NULL,
`steam_id` varchar(32) NOT NULL,
`connect_ip` varchar(15) NOT NULL,
`account_id` bigint(20) NOT NULL,
`timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
`map` varchar(128) NOT NULL,
`connection_type` varchar(10) NOT NULL,
`connect_duration` int(11) NOT NULL,
`reason` varchar(256) 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_connections")
public class Gametime {
@JsonIgnore
@Id
@Column(name = "id")
private Long id;
@Column(name = "migration_id")
private Long migrationId;
@JsonIgnore
@ManyToOne
@JoinColumn(name = "srv_id", referencedColumnName = "srv_id")
private ServerDB serverDB;
@Column(name = "player_name", length = 64)
private String player_name;
@JsonIgnore
@Column(name = "steam_id", length = 64)
private String steam_id;
@Column(name = "connect_ip", length = 15)
@JsonIgnore
private String connect_ip;
@Column(name = "account_id")
@JsonIgnore
private Long account_id;
@Column(name = "timestamp")
@JsonIgnore
private Timestamp timestamp;
@Column(name = "map", length = 128)
@JsonIgnore
private String map;
@Column(name = "connection_type", length = 10)
@JsonIgnore
private String connection_type;
@Column(name = "connect_duration")
private Long connect_duration;
@Column(name = "reason", length = 256)
private String reason;
public Gametime(Object[] obj) {
id = (long) obj[0];
player_name = (String) obj[1];
steam_id = (String) obj[2];
connect_ip = (String) obj[3];
account_id = (long) obj[4];
timestamp = (Timestamp) obj[5];
map = (String) obj[6];
connection_type = (String) obj[7];
connect_duration = (long) obj[8];
reason = (String) obj[9];
}
public Gametime(ResultSet rs) throws SQLException {
id = rs.getLong("id");
player_name = rs.getString("player_name");
steam_id = rs.getString("steam_id");
connect_ip = rs.getString("connect_ip");
account_id = rs.getLong("account_id");
timestamp = rs.getTimestamp("timestamp");
map = rs.getString("map");
connection_type = rs.getString("connection_type");
connect_duration = rs.getLong("connect_duration");
reason = rs.getString("reason");
}
public Gametime() {
}
@JsonGetter
public String getMap() {
return map.replace("workshop/","").split(".ugc", 2)[0];
}
@JsonGetter
public Long getUtime() {
return timestamp.toInstant().getEpochSecond();
}
}