From fe8cbf2a55b3a887dd27611befc5e7221d8eed49 Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Thu, 26 May 2016 12:41:29 +0200 Subject: [PATCH] =?UTF-8?q?La=20table=20SQL=20OnlineShopHistory=20g=C3=A8r?= =?UTF-8?q?e=20maintenant=20les=20sources=20inconnus=20(NULL)=20et=20les?= =?UTF-8?q?=20ID=20de=20transaction?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/util/db/OnlineShopHistoryElement.java | 16 ++++++++-------- .../java/util/db/OnlineShopHistoryTable.java | 10 +++++++--- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/fr/pandacube/java/util/db/OnlineShopHistoryElement.java b/src/fr/pandacube/java/util/db/OnlineShopHistoryElement.java index 009aa2d..ac148af 100644 --- a/src/fr/pandacube/java/util/db/OnlineShopHistoryElement.java +++ b/src/fr/pandacube/java/util/db/OnlineShopHistoryElement.java @@ -6,6 +6,7 @@ public class OnlineShopHistoryElement extends SQLElement { private long time;// timestamp en millisecondes + private String transactionId; private SourceType sourceType;// enum(REAL_MONEY, BAMBOU) 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) @@ -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 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"); setTime(t); setSourceType(st); - setSourcePlayerId(sPID); setSourceQuantity(sQtt); setSourceName(sN); setDestType(dt); @@ -28,11 +28,10 @@ public class OnlineShopHistoryElement extends SQLElement { 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); setTime(t); setSourceType(SourceType.valueOf(st)); - sourcePlayerId = sPID; setSourceQuantity(sQtt); setSourceName(sN); setDestType(DestType.valueOf(dt)); @@ -45,6 +44,7 @@ public class OnlineShopHistoryElement extends SQLElement { protected String[] getValues() { return new String[] { Long.toString(time), + transactionId, sourceType.name(), sourcePlayerId, Double.toString(sourceQuantity), @@ -61,6 +61,7 @@ public class OnlineShopHistoryElement extends SQLElement { protected String[] getFieldsName() { return new String[] { "time", + "transactionId", "sourceType", "sourcePlayerId", "sourceQuantity", @@ -74,6 +75,7 @@ public class OnlineShopHistoryElement extends SQLElement { public long getTime() { return time; } + public String getTransactionId() { return transactionId; } public SourceType getSourceType() { return sourceType; } public UUID getSourcePlayerId() { return UUID.fromString(sourcePlayerId); } public double getSourceQuantity() { return sourceQuantity; } @@ -90,14 +92,12 @@ public class OnlineShopHistoryElement extends SQLElement { public void setTime(long t) { time = t; } + public void setTransactionId(String t) { transactionId = t; } public void setSourceType(SourceType st) { if (st == null) throw new IllegalArgumentException("sourceType can't be null"); sourceType = st; } - public void setSourcePlayerId(UUID pId) { - if (pId == null) throw new IllegalArgumentException("sourcePlayerId can't be null"); - sourcePlayerId = pId.toString(); - } + public void setSourcePlayerId(UUID pId) { sourcePlayerId = pId.toString(); } public void setSourceQuantity(double qtt) { sourceQuantity = qtt; } public void setSourceName(String name) { if (name == null) throw new IllegalArgumentException("sourceName can't be null"); diff --git a/src/fr/pandacube/java/util/db/OnlineShopHistoryTable.java b/src/fr/pandacube/java/util/db/OnlineShopHistoryTable.java index 7e43b90..d95dfeb 100644 --- a/src/fr/pandacube/java/util/db/OnlineShopHistoryTable.java +++ b/src/fr/pandacube/java/util/db/OnlineShopHistoryTable.java @@ -2,6 +2,7 @@ package fr.pandacube.java.util.db; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.UUID; public class OnlineShopHistoryTable extends SQLTable { @@ -13,8 +14,9 @@ public class OnlineShopHistoryTable extends SQLTable { protected String createTableParameters() { return "id INT AUTO_INCREMENT PRIMARY KEY," + "time BIGINT NOT NULL," + + "transactionId VARCHAR(255) NULL," + "sourceType ENUM('REAL_MONEY', 'BAMBOU') NOT NULL," - + "sourcePlayerId CHAR(36) NOT NULL," + + "sourcePlayerId CHAR(36) NULL," + "sourceQuantity DOUBLE NOT NULL," + "sourceName VARCHAR(64) NOT NULL," + "destType ENUM('BAMBOU', 'GRADE') NOT NULL," @@ -29,14 +31,16 @@ public class OnlineShopHistoryTable extends SQLTable { sqlResult.getInt("id"), sqlResult.getLong("time"), sqlResult.getString("sourceType"), - sqlResult.getString("sourcePlayerId"), sqlResult.getDouble("sourceQuantity"), sqlResult.getString("sourceName"), sqlResult.getString("destType"), sqlResult.getString("destPlayerId"), sqlResult.getDouble("destQuantity"), sqlResult.getString("destName")); - + el.setTransactionId(sqlResult.getString("transactionId")); + String sourcePlayerId = sqlResult.getString("sourcePlayerId"); + if (sourcePlayerId != null) + el.setSourcePlayerId(UUID.fromString(sourcePlayerId)); return el; }