Add offset to loot tracker API

Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
Tomas Slusny
2019-02-12 22:49:01 +01:00
parent 8c8e967111
commit d2713c2138
2 changed files with 5 additions and 4 deletions

View File

@@ -66,7 +66,7 @@ public class LootTrackerController
}
@RequestMapping
public Collection<LootRecord> getLootRecords(HttpServletRequest request, HttpServletResponse response, @RequestParam(value = "count", defaultValue = "1024") int count) throws IOException
public Collection<LootRecord> getLootRecords(HttpServletRequest request, HttpServletResponse response, @RequestParam(value = "count", defaultValue = "1024") int count, @RequestParam(value = "start", defaultValue = "0") int start) throws IOException
{
SessionEntry e = auth.handle(request, response);
if (e == null)
@@ -75,7 +75,7 @@ public class LootTrackerController
return null;
}
return service.get(e.getUser(), count);
return service.get(e.getUser(), count, start);
}
@DeleteMapping

View File

@@ -66,7 +66,7 @@ public class LootTrackerService
private static final String INSERT_KILL_QUERY = "INSERT INTO kills (accountId, type, eventId) VALUES (:accountId, :type, :eventId)";
private static final String INSERT_DROP_QUERY = "INSERT INTO drops (killId, itemId, itemQuantity) VALUES (LAST_INSERT_ID(), :itemId, :itemQuantity)";
private static final String SELECT_LOOT_QUERY = "SELECT killId,time,type,eventId,itemId,itemQuantity FROM kills JOIN drops ON drops.killId = kills.id WHERE accountId = :accountId ORDER BY TIME DESC LIMIT :limit";
private static final String SELECT_LOOT_QUERY = "SELECT killId,time,type,eventId,itemId,itemQuantity FROM kills JOIN drops ON drops.killId = kills.id WHERE accountId = :accountId ORDER BY TIME DESC LIMIT :limit OFFSET :offset";
private static final String DELETE_LOOT_ACCOUNT = "DELETE FROM kills WHERE accountId = :accountId";
private static final String DELETE_LOOT_ACCOUNT_EVENTID = "DELETE FROM kills WHERE accountId = :accountId AND eventId = :eventId";
@@ -119,7 +119,7 @@ public class LootTrackerService
}
}
public Collection<LootRecord> get(int accountId, int limit)
public Collection<LootRecord> get(int accountId, int limit, int offset)
{
List<LootResult> lootResults;
@@ -128,6 +128,7 @@ public class LootTrackerService
lootResults = con.createQuery(SELECT_LOOT_QUERY)
.addParameter("accountId", accountId)
.addParameter("limit", limit)
.addParameter("offset", offset)
.executeAndFetch(LootResult.class);
}