Skip to content

Commit

Permalink
update redis
Browse files Browse the repository at this point in the history
  • Loading branch information
nicol committed Sep 10, 2023
1 parent 98dc715 commit 814da2d
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/main/java/org/beta/RedisDAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.magic.api.interfaces.MTGSerializable;
import org.magic.api.interfaces.abstracts.extra.AbstractKeyValueDao;
import org.magic.services.TechnicalServiceManager;
import org.magic.services.tools.CryptoUtils;
import org.magic.services.tools.IDGenerator;
import org.magic.services.tools.POMReader;
import io.lettuce.core.RedisClient;
Expand Down Expand Up @@ -193,7 +194,7 @@ public List<MagicDeck> listDecks() throws SQLException {

return ret;
}

@Override
public void deleteDeck(MagicDeck d) throws SQLException {
syncCommands.del(key(d));
Expand Down Expand Up @@ -497,7 +498,7 @@ public List<MagicCollection> listCollectionFromCards(MagicCard mc) throws SQLExc

for(var collection : listCollections())
{
if(listCardsFromCollection(collection).stream().anyMatch(card->card.getId().equals(mc.getId())))
if(listCardsFromCollection(collection).stream().anyMatch(card->IDGenerator.generate(card).equals(IDGenerator.generate(mc))))
c.add(collection);
}
return c;
Expand All @@ -506,14 +507,22 @@ public List<MagicCollection> listCollectionFromCards(MagicCard mc) throws SQLExc

@Override
public List<MagicCardStock> listStocks(MagicCard mc, MagicCollection col, boolean editionStrict) throws SQLException {
// TODO Auto-generated method stub
return new ArrayList<>();

if(editionStrict)
return listStocks().stream().filter(mcs->mcs.getMagicCollection().getName().equals(col.getName())).filter(mcs->mcs.getProduct().getId().equals(mc.getId())).toList();
else
return listStocks().stream().filter(mcs->mcs.getMagicCollection().getName().equals(col.getName())).filter(mcs->mcs.getProduct().getName().equals(mc.getName())).toList();
}

@Override
public Contact getContactByLogin(String email, String password) throws SQLException {
// TODO Auto-generated method stub
return null;
var opt = listContacts().stream().filter(c->c.getEmail().equals(email) && c.getPassword().equals(IDGenerator.generateSha256(password))).findFirst();

if(opt.isPresent())
return opt.get();

throw new SQLException("No result Found");

}

@Override
Expand All @@ -532,7 +541,7 @@ public boolean enableContact(String token) throws SQLException {

@Override
public List<Announce> listAnnounces(int max, STATUS stat) throws SQLException {
return new ArrayList<>();
return new ArrayList<>();
}


Expand Down

0 comments on commit 814da2d

Please sign in to comment.