Merge pull request #7834 from deathbeam/add-loot-tracker-offset
Add offset to loot tracker API
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user