loot tracker service: remove type argument from delete

The client does not track type and eventId so it cannot use it
This commit is contained in:
Adam
2018-12-28 17:03:53 -05:00
parent 15985db678
commit 1af1601b3e
2 changed files with 7 additions and 10 deletions

View File

@@ -31,7 +31,6 @@ import java.util.Collection;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import net.runelite.http.api.loottracker.LootRecord; import net.runelite.http.api.loottracker.LootRecord;
import net.runelite.http.api.loottracker.LootRecordType;
import net.runelite.http.service.account.AuthFilter; import net.runelite.http.service.account.AuthFilter;
import net.runelite.http.service.account.beans.SessionEntry; import net.runelite.http.service.account.beans.SessionEntry;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -81,7 +80,7 @@ public class LootTrackerController
@DeleteMapping @DeleteMapping
public void deleteLoot(HttpServletRequest request, HttpServletResponse response, public void deleteLoot(HttpServletRequest request, HttpServletResponse response,
@RequestParam(required = false) LootRecordType type, @RequestParam(required = false) String eventId) throws IOException @RequestParam(required = false) String eventId) throws IOException
{ {
SessionEntry e = auth.handle(request, response); SessionEntry e = auth.handle(request, response);
if (e == null) if (e == null)
@@ -90,6 +89,6 @@ public class LootTrackerController
return; return;
} }
service.delete(e.getUser(), type, eventId); service.delete(e.getUser(), eventId);
} }
} }

View File

@@ -30,7 +30,6 @@ import java.util.Collection;
import java.util.List; import java.util.List;
import net.runelite.http.api.loottracker.GameItem; import net.runelite.http.api.loottracker.GameItem;
import net.runelite.http.api.loottracker.LootRecord; import net.runelite.http.api.loottracker.LootRecord;
import net.runelite.http.api.loottracker.LootRecordType;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
@@ -70,7 +69,7 @@ public class LootTrackerService
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";
private static final String DELETE_LOOT_ACCOUNT = "DELETE FROM kills WHERE accountId = :accountId"; private static final String DELETE_LOOT_ACCOUNT = "DELETE FROM kills WHERE accountId = :accountId";
private static final String DELETE_LOOT_ACCOUNT_TYPE = "DELETE FROM kills WHERE accountId = :accountId AND type = :type AND eventId = :eventId"; private static final String DELETE_LOOT_ACCOUNT_EVENTID = "DELETE FROM kills WHERE accountId = :accountId AND eventId = :eventId";
private final Sql2o sql2o; private final Sql2o sql2o;
@@ -164,21 +163,20 @@ public class LootTrackerService
return lootRecords; return lootRecords;
} }
public void delete(int accountId, LootRecordType type, String eventId) public void delete(int accountId, String eventId)
{ {
try (Connection con = sql2o.open()) try (Connection con = sql2o.open())
{ {
if (eventId == null && type == null) if (eventId == null)
{ {
con.createQuery(DELETE_LOOT_ACCOUNT) con.createQuery(DELETE_LOOT_ACCOUNT)
.addParameter("accountId", accountId) .addParameter("accountId", accountId)
.executeUpdate(); .executeUpdate();
} }
else if (eventId != null && type != null) else
{ {
con.createQuery(DELETE_LOOT_ACCOUNT_TYPE) con.createQuery(DELETE_LOOT_ACCOUNT_EVENTID)
.addParameter("accountId", accountId) .addParameter("accountId", accountId)
.addParameter("type", type)
.addParameter("eventId", eventId) .addParameter("eventId", eventId)
.executeUpdate(); .executeUpdate();
} }