La table SQL OnlineShopHistory gère maintenant les sources inconnus (NULL) et les ID de transaction
This commit is contained in:
parent
786d15ff9c
commit
fe8cbf2a55
@ -6,6 +6,7 @@ public class OnlineShopHistoryElement extends SQLElement {
|
|||||||
|
|
||||||
|
|
||||||
private long time;// timestamp en millisecondes
|
private long time;// timestamp en millisecondes
|
||||||
|
private String transactionId;
|
||||||
private SourceType sourceType;// enum(REAL_MONEY, BAMBOU)
|
private SourceType sourceType;// enum(REAL_MONEY, BAMBOU)
|
||||||
private String sourcePlayerId;// l'id du joueur duquel vient l'élément source
|
private String sourcePlayerId;// l'id du joueur duquel vient l'élément source
|
||||||
private double sourceQuantity;// la quantité d'entrée (en euro, ou bambou)
|
private double sourceQuantity;// la quantité d'entrée (en euro, ou bambou)
|
||||||
@ -15,11 +16,10 @@ public class OnlineShopHistoryElement extends SQLElement {
|
|||||||
private double destQuantity;// la quantité de sortie (bambou, ou 1 pour l'achat d'un grade)
|
private double destQuantity;// la quantité de sortie (bambou, ou 1 pour l'achat d'un grade)
|
||||||
private String destName;// le nom désignant la destination ("bambou", le nom du grade)
|
private String destName;// le nom désignant la destination ("bambou", le nom du grade)
|
||||||
|
|
||||||
public OnlineShopHistoryElement(long t, SourceType st, UUID sPID, double sQtt, String sN, DestType dt, UUID dPID, double dQtt, String dN) {
|
public OnlineShopHistoryElement(long t, SourceType st, double sQtt, String sN, DestType dt, UUID dPID, double dQtt, String dN) {
|
||||||
super("pandacube_onlineshop_history");
|
super("pandacube_onlineshop_history");
|
||||||
setTime(t);
|
setTime(t);
|
||||||
setSourceType(st);
|
setSourceType(st);
|
||||||
setSourcePlayerId(sPID);
|
|
||||||
setSourceQuantity(sQtt);
|
setSourceQuantity(sQtt);
|
||||||
setSourceName(sN);
|
setSourceName(sN);
|
||||||
setDestType(dt);
|
setDestType(dt);
|
||||||
@ -28,11 +28,10 @@ public class OnlineShopHistoryElement extends SQLElement {
|
|||||||
setDestName(dN);
|
setDestName(dN);
|
||||||
}
|
}
|
||||||
|
|
||||||
OnlineShopHistoryElement(int id, long t, String st, String sPID, double sQtt, String sN, String dt, String dPID, double dQtt, String dN) {
|
OnlineShopHistoryElement(int id, long t, String st, double sQtt, String sN, String dt, String dPID, double dQtt, String dN) {
|
||||||
super("pandacube_onlineshop_history", id);
|
super("pandacube_onlineshop_history", id);
|
||||||
setTime(t);
|
setTime(t);
|
||||||
setSourceType(SourceType.valueOf(st));
|
setSourceType(SourceType.valueOf(st));
|
||||||
sourcePlayerId = sPID;
|
|
||||||
setSourceQuantity(sQtt);
|
setSourceQuantity(sQtt);
|
||||||
setSourceName(sN);
|
setSourceName(sN);
|
||||||
setDestType(DestType.valueOf(dt));
|
setDestType(DestType.valueOf(dt));
|
||||||
@ -45,6 +44,7 @@ public class OnlineShopHistoryElement extends SQLElement {
|
|||||||
protected String[] getValues() {
|
protected String[] getValues() {
|
||||||
return new String[] {
|
return new String[] {
|
||||||
Long.toString(time),
|
Long.toString(time),
|
||||||
|
transactionId,
|
||||||
sourceType.name(),
|
sourceType.name(),
|
||||||
sourcePlayerId,
|
sourcePlayerId,
|
||||||
Double.toString(sourceQuantity),
|
Double.toString(sourceQuantity),
|
||||||
@ -61,6 +61,7 @@ public class OnlineShopHistoryElement extends SQLElement {
|
|||||||
protected String[] getFieldsName() {
|
protected String[] getFieldsName() {
|
||||||
return new String[] {
|
return new String[] {
|
||||||
"time",
|
"time",
|
||||||
|
"transactionId",
|
||||||
"sourceType",
|
"sourceType",
|
||||||
"sourcePlayerId",
|
"sourcePlayerId",
|
||||||
"sourceQuantity",
|
"sourceQuantity",
|
||||||
@ -74,6 +75,7 @@ public class OnlineShopHistoryElement extends SQLElement {
|
|||||||
|
|
||||||
|
|
||||||
public long getTime() { return time; }
|
public long getTime() { return time; }
|
||||||
|
public String getTransactionId() { return transactionId; }
|
||||||
public SourceType getSourceType() { return sourceType; }
|
public SourceType getSourceType() { return sourceType; }
|
||||||
public UUID getSourcePlayerId() { return UUID.fromString(sourcePlayerId); }
|
public UUID getSourcePlayerId() { return UUID.fromString(sourcePlayerId); }
|
||||||
public double getSourceQuantity() { return sourceQuantity; }
|
public double getSourceQuantity() { return sourceQuantity; }
|
||||||
@ -90,14 +92,12 @@ public class OnlineShopHistoryElement extends SQLElement {
|
|||||||
|
|
||||||
|
|
||||||
public void setTime(long t) { time = t; }
|
public void setTime(long t) { time = t; }
|
||||||
|
public void setTransactionId(String t) { transactionId = t; }
|
||||||
public void setSourceType(SourceType st) {
|
public void setSourceType(SourceType st) {
|
||||||
if (st == null) throw new IllegalArgumentException("sourceType can't be null");
|
if (st == null) throw new IllegalArgumentException("sourceType can't be null");
|
||||||
sourceType = st;
|
sourceType = st;
|
||||||
}
|
}
|
||||||
public void setSourcePlayerId(UUID pId) {
|
public void setSourcePlayerId(UUID pId) { sourcePlayerId = pId.toString(); }
|
||||||
if (pId == null) throw new IllegalArgumentException("sourcePlayerId can't be null");
|
|
||||||
sourcePlayerId = pId.toString();
|
|
||||||
}
|
|
||||||
public void setSourceQuantity(double qtt) { sourceQuantity = qtt; }
|
public void setSourceQuantity(double qtt) { sourceQuantity = qtt; }
|
||||||
public void setSourceName(String name) {
|
public void setSourceName(String name) {
|
||||||
if (name == null) throw new IllegalArgumentException("sourceName can't be null");
|
if (name == null) throw new IllegalArgumentException("sourceName can't be null");
|
||||||
|
@ -2,6 +2,7 @@ package fr.pandacube.java.util.db;
|
|||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class OnlineShopHistoryTable extends SQLTable<OnlineShopHistoryElement> {
|
public class OnlineShopHistoryTable extends SQLTable<OnlineShopHistoryElement> {
|
||||||
|
|
||||||
@ -13,8 +14,9 @@ public class OnlineShopHistoryTable extends SQLTable<OnlineShopHistoryElement> {
|
|||||||
protected String createTableParameters() {
|
protected String createTableParameters() {
|
||||||
return "id INT AUTO_INCREMENT PRIMARY KEY,"
|
return "id INT AUTO_INCREMENT PRIMARY KEY,"
|
||||||
+ "time BIGINT NOT NULL,"
|
+ "time BIGINT NOT NULL,"
|
||||||
|
+ "transactionId VARCHAR(255) NULL,"
|
||||||
+ "sourceType ENUM('REAL_MONEY', 'BAMBOU') NOT NULL,"
|
+ "sourceType ENUM('REAL_MONEY', 'BAMBOU') NOT NULL,"
|
||||||
+ "sourcePlayerId CHAR(36) NOT NULL,"
|
+ "sourcePlayerId CHAR(36) NULL,"
|
||||||
+ "sourceQuantity DOUBLE NOT NULL,"
|
+ "sourceQuantity DOUBLE NOT NULL,"
|
||||||
+ "sourceName VARCHAR(64) NOT NULL,"
|
+ "sourceName VARCHAR(64) NOT NULL,"
|
||||||
+ "destType ENUM('BAMBOU', 'GRADE') NOT NULL,"
|
+ "destType ENUM('BAMBOU', 'GRADE') NOT NULL,"
|
||||||
@ -29,14 +31,16 @@ public class OnlineShopHistoryTable extends SQLTable<OnlineShopHistoryElement> {
|
|||||||
sqlResult.getInt("id"),
|
sqlResult.getInt("id"),
|
||||||
sqlResult.getLong("time"),
|
sqlResult.getLong("time"),
|
||||||
sqlResult.getString("sourceType"),
|
sqlResult.getString("sourceType"),
|
||||||
sqlResult.getString("sourcePlayerId"),
|
|
||||||
sqlResult.getDouble("sourceQuantity"),
|
sqlResult.getDouble("sourceQuantity"),
|
||||||
sqlResult.getString("sourceName"),
|
sqlResult.getString("sourceName"),
|
||||||
sqlResult.getString("destType"),
|
sqlResult.getString("destType"),
|
||||||
sqlResult.getString("destPlayerId"),
|
sqlResult.getString("destPlayerId"),
|
||||||
sqlResult.getDouble("destQuantity"),
|
sqlResult.getDouble("destQuantity"),
|
||||||
sqlResult.getString("destName"));
|
sqlResult.getString("destName"));
|
||||||
|
el.setTransactionId(sqlResult.getString("transactionId"));
|
||||||
|
String sourcePlayerId = sqlResult.getString("sourcePlayerId");
|
||||||
|
if (sourcePlayerId != null)
|
||||||
|
el.setSourcePlayerId(UUID.fromString(sourcePlayerId));
|
||||||
return el;
|
return el;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user