1
0
mirror of https://github.com/fabianonline/telegram_backup.git synced 2025-06-29 11:56:26 +00:00

Expanded Message model by getId(); added tests for both supported api layers.

This commit is contained in:
2017-02-25 11:46:00 +01:00
parent 3d2b07eae9
commit b26df3639e
3 changed files with 56 additions and 5 deletions

View File

@ -8,18 +8,24 @@ public class Message {
protected static String tableName = "messages";
private JsonObject json;
private String message = null;
private Integer id = null;
public Message(String json) {
this.json = new JsonParser().parse(json).getAsJsonObject();
}
public static Message get(int id) {
String json = Database.getInstance().queryString("SELECT json FROM " + tableName + " WHERE id=" + id);
return new Message(json);
}
public String getMessage() {
if (message != null) return message;
return message = json.getAsJsonPrimitive("message").getAsString();
if (message==null) message=json.getAsJsonPrimitive("message").getAsString();
return message;
}
public int getId() {
if (id==null) id=json.getAsJsonPrimitive("id").getAsInt();
return id;
}
}