Mise à jour des tables SQL pour la prise en charges de la boutique en ligne
This commit is contained in:
parent
491d495b35
commit
8b1f18fc1b
129
src/fr/pandacube/java/util/db/OnlineShopHistoryElement.java
Normal file
129
src/fr/pandacube/java/util/db/OnlineShopHistoryElement.java
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
package fr.pandacube.java.util.db;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class OnlineShopHistoryElement extends SQLElement {
|
||||||
|
|
||||||
|
|
||||||
|
private long time;// timestamp en millisecondes
|
||||||
|
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)
|
||||||
|
private String sourceName;// le nom désignant la source ("euro", "bambou", ...)
|
||||||
|
private DestType destType;// enum(BAMBOU, GRADE)
|
||||||
|
private String destPlayerId;// l'id du joueur qui reçoit l'élément obtenu après cette transaction
|
||||||
|
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) {
|
||||||
|
super("pandacube_onlineshop_history");
|
||||||
|
setTime(t);
|
||||||
|
setSourceType(st);
|
||||||
|
setSourcePlayerId(sPID);
|
||||||
|
setSourceQuantity(sQtt);
|
||||||
|
setSourceName(sN);
|
||||||
|
setDestType(dt);
|
||||||
|
setDestPlayerId(dPID);
|
||||||
|
setDestQuantity(dQtt);
|
||||||
|
setDestName(dN);
|
||||||
|
}
|
||||||
|
|
||||||
|
OnlineShopHistoryElement(int id, long t, String st, String sPID, 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));
|
||||||
|
destPlayerId = dPID;
|
||||||
|
setDestQuantity(dQtt);
|
||||||
|
setDestName(dN);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String[] getValues() {
|
||||||
|
return new String[] {
|
||||||
|
Long.toString(time),
|
||||||
|
sourceType.name(),
|
||||||
|
sourcePlayerId,
|
||||||
|
Double.toString(sourceQuantity),
|
||||||
|
sourceName,
|
||||||
|
destType.name(),
|
||||||
|
destPlayerId,
|
||||||
|
Double.toString(destQuantity),
|
||||||
|
destName
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String[] getFieldsName() {
|
||||||
|
return new String[] {
|
||||||
|
"time",
|
||||||
|
"sourceType",
|
||||||
|
"sourcePlayerId",
|
||||||
|
"sourceQuantity",
|
||||||
|
"sourceName",
|
||||||
|
"destType",
|
||||||
|
"destPlayerId",
|
||||||
|
"destQuantity",
|
||||||
|
"destName"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public long getTime() { return time; }
|
||||||
|
public SourceType getSourceType() { return sourceType; }
|
||||||
|
public UUID getSourcePlayerId() { return UUID.fromString(sourcePlayerId); }
|
||||||
|
public double getSourceQuantity() { return sourceQuantity; }
|
||||||
|
public String getSourceName() { return sourceName; }
|
||||||
|
public DestType getDestType() { return destType; }
|
||||||
|
public UUID getDestPlayerId() { return UUID.fromString(destPlayerId); }
|
||||||
|
public double getDestQuantity() { return destQuantity; }
|
||||||
|
public String getDestName() { return destName; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void setTime(long t) { time = 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 setSourceQuantity(double qtt) { sourceQuantity = qtt; }
|
||||||
|
public void setSourceName(String name) {
|
||||||
|
if (name == null) throw new IllegalArgumentException("sourceName can't be null");
|
||||||
|
sourceName = name;
|
||||||
|
}
|
||||||
|
public void setDestType(DestType st) {
|
||||||
|
if (st == null) throw new IllegalArgumentException("destType can't be null");
|
||||||
|
destType = st;
|
||||||
|
}
|
||||||
|
public void setDestPlayerId(UUID pId) {
|
||||||
|
if (pId == null) throw new IllegalArgumentException("destPlayerId can't be null");
|
||||||
|
destPlayerId = pId.toString();
|
||||||
|
}
|
||||||
|
public void setDestQuantity(double qtt) { destQuantity = qtt; }
|
||||||
|
public void setDestName(String name) {
|
||||||
|
if (name == null) throw new IllegalArgumentException("destName can't be null");
|
||||||
|
destName = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static enum SourceType {
|
||||||
|
REAL_MONEY, BAMBOU
|
||||||
|
}
|
||||||
|
|
||||||
|
public static enum DestType {
|
||||||
|
BAMBOU, GRADE
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
43
src/fr/pandacube/java/util/db/OnlineShopHistoryTable.java
Normal file
43
src/fr/pandacube/java/util/db/OnlineShopHistoryTable.java
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
package fr.pandacube.java.util.db;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
public class OnlineShopHistoryTable extends SQLTable<OnlineShopHistoryElement> {
|
||||||
|
|
||||||
|
public OnlineShopHistoryTable() throws SQLException {
|
||||||
|
super("pandacube_onlineshop_history");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String createTableParameters() {
|
||||||
|
return "id INT AUTO_INCREMENT PRIMARY KEY,"
|
||||||
|
+ "time BIGINT NOT NULL,"
|
||||||
|
+ "sourceType ENUM('REAL_MONEY', 'BAMBOU') NOT NULL,"
|
||||||
|
+ "sourcePlayerId CHAR(36) NOT NULL,"
|
||||||
|
+ "sourceQuantity DOUBLE NOT NULL,"
|
||||||
|
+ "sourceName VARCHAR(64) NOT NULL,"
|
||||||
|
+ "destType ENUM('BAMBOU', 'GRADE') NOT NULL,"
|
||||||
|
+ "destPlayerId CHAR(36) NOT NULL,"
|
||||||
|
+ "destQuantity DOUBLE NOT NULL,"
|
||||||
|
+ "destName VARCHAR(64) NOT NULL";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected OnlineShopHistoryElement getElementInstance(ResultSet sqlResult) throws SQLException {
|
||||||
|
OnlineShopHistoryElement el = new OnlineShopHistoryElement(
|
||||||
|
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"));
|
||||||
|
|
||||||
|
return el;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -23,6 +23,8 @@ public class PlayerElement extends SQLElement {
|
|||||||
private Long banTimeout = null;
|
private Long banTimeout = null;
|
||||||
private Long muteTimeout = null;
|
private Long muteTimeout = null;
|
||||||
private boolean isWhitelisted = false;
|
private boolean isWhitelisted = false;
|
||||||
|
private long bambou = 0;
|
||||||
|
private String grade = "default";
|
||||||
|
|
||||||
public PlayerElement(UUID pId, String dispName, long firstTimeIG, long lastWebAct, String onlineInServer) {
|
public PlayerElement(UUID pId, String dispName, long firstTimeIG, long lastWebAct, String onlineInServer) {
|
||||||
super("pandacube_player");
|
super("pandacube_player");
|
||||||
@ -33,7 +35,7 @@ public class PlayerElement extends SQLElement {
|
|||||||
setFirstTimeInGame(firstTimeIG);
|
setFirstTimeInGame(firstTimeIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected PlayerElement(int id, String pId, String dispName, long firstTimeIG, long lastWebAct, String onlineInServer) {
|
PlayerElement(int id, String pId, String dispName, long firstTimeIG, long lastWebAct, String onlineInServer) {
|
||||||
super("pandacube_player", id);
|
super("pandacube_player", id);
|
||||||
setPlayerId(UUID.fromString(pId));
|
setPlayerId(UUID.fromString(pId));
|
||||||
setOnlineInServer(onlineInServer);
|
setOnlineInServer(onlineInServer);
|
||||||
@ -62,7 +64,9 @@ public class PlayerElement extends SQLElement {
|
|||||||
Integer.toString(lastYearCelebratedBirthday),
|
Integer.toString(lastYearCelebratedBirthday),
|
||||||
(banTimeout!=null)?banTimeout.toString():null,
|
(banTimeout!=null)?banTimeout.toString():null,
|
||||||
(muteTimeout!=null)?muteTimeout.toString():null,
|
(muteTimeout!=null)?muteTimeout.toString():null,
|
||||||
isWhitelisted?"1":"0"
|
isWhitelisted?"1":"0",
|
||||||
|
Long.toString(bambou),
|
||||||
|
grade
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +90,9 @@ public class PlayerElement extends SQLElement {
|
|||||||
"lastYearCelebratedBirthday",
|
"lastYearCelebratedBirthday",
|
||||||
"banTimeout",
|
"banTimeout",
|
||||||
"muteTimeout",
|
"muteTimeout",
|
||||||
"isWhitelisted"
|
"isWhitelisted",
|
||||||
|
"bambou",
|
||||||
|
"grade"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,6 +114,8 @@ public class PlayerElement extends SQLElement {
|
|||||||
public Long getBanTimeout() { return banTimeout; }
|
public Long getBanTimeout() { return banTimeout; }
|
||||||
public Long getMuteTimeout() { return muteTimeout; }
|
public Long getMuteTimeout() { return muteTimeout; }
|
||||||
public boolean isWhitelisted() { return isWhitelisted; }
|
public boolean isWhitelisted() { return isWhitelisted; }
|
||||||
|
public long getBambou() { return bambou; }
|
||||||
|
public String getGrade() { return grade; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -160,4 +168,12 @@ public class PlayerElement extends SQLElement {
|
|||||||
|
|
||||||
public void setWhitelisted(boolean w) { isWhitelisted = w; }
|
public void setWhitelisted(boolean w) { isWhitelisted = w; }
|
||||||
|
|
||||||
|
public void setBambou(long b) { bambou = b; }
|
||||||
|
|
||||||
|
public void setGrade(String g) {
|
||||||
|
if (g == null || g.equals(""))
|
||||||
|
g = "default";
|
||||||
|
grade = g;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,9 @@ public class PlayerTable extends SQLTable<PlayerElement> {
|
|||||||
+ "lastYearCelebratedBirthday INT NOT NULL DEFAULT 0,"
|
+ "lastYearCelebratedBirthday INT NOT NULL DEFAULT 0,"
|
||||||
+ "banTimeout BIGINT NULL,"
|
+ "banTimeout BIGINT NULL,"
|
||||||
+ "muteTimeout BIGINT NULL,"
|
+ "muteTimeout BIGINT NULL,"
|
||||||
+ "isWhitelisted TINYINT NOT NULL DEFAULT 0";
|
+ "isWhitelisted TINYINT NOT NULL DEFAULT 0,"
|
||||||
|
+ "bambou BIGINT NOT NULL DEFAULT 0,"
|
||||||
|
+ "grade VARCHAR(36) NOT NULL DEFAULT 'default'";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -55,6 +57,8 @@ public class PlayerTable extends SQLTable<PlayerElement> {
|
|||||||
el.setVanish(sqlResult.getBoolean("isVanish"));
|
el.setVanish(sqlResult.getBoolean("isVanish"));
|
||||||
el.setBirthday(sqlResult.getDate("birthday"));
|
el.setBirthday(sqlResult.getDate("birthday"));
|
||||||
el.setLastYearCelebratedBirthday(sqlResult.getInt("lastYearCelebratedBirthday"));
|
el.setLastYearCelebratedBirthday(sqlResult.getInt("lastYearCelebratedBirthday"));
|
||||||
|
el.setBambou(sqlResult.getLong("bambou"));
|
||||||
|
el.setGrade(sqlResult.getString("grade"));
|
||||||
|
|
||||||
long longVal;
|
long longVal;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user