mirror of https://github.com/hykilpikonna/AquaDX
[chuni] Add basic support to old release
parent
44c41a3778
commit
0879a7be4a
|
@ -1,12 +1,24 @@
|
|||
package icu.samnyan.aqua.sega.aimedb.handler.Impl;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import icu.samnyan.aqua.sega.aimedb.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.aimedb.util.AimeDbUtil;
|
||||
import icu.samnyan.aqua.sega.aimedb.util.LogMapper;
|
||||
import icu.samnyan.aqua.sega.general.dao.CardRepository;
|
||||
import icu.samnyan.aqua.sega.general.model.Card;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufUtil;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Mifare Card lookup? idk
|
||||
*
|
||||
|
@ -15,15 +27,46 @@ import org.springframework.stereotype.Component;
|
|||
@Component
|
||||
public class LookupHandler implements BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(LookupHandler.class);
|
||||
|
||||
private final LogMapper logMapper;
|
||||
|
||||
private final CardRepository cardRepository;
|
||||
|
||||
@Autowired
|
||||
public LookupHandler(LogMapper logMapper) {
|
||||
public LookupHandler(LogMapper logMapper, CardRepository cardRepository) {
|
||||
this.logMapper = logMapper;
|
||||
this.cardRepository = cardRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(ChannelHandlerContext ctx, ByteBuf msg) {
|
||||
public void handle(ChannelHandlerContext ctx, ByteBuf msg) throws JsonProcessingException {
|
||||
Map<String, Object> requestMap = AimeDbUtil.getBaseInfo(msg);
|
||||
requestMap.put("type", "lookup2");
|
||||
requestMap.put("luid", ByteBufUtil.hexDump(msg.slice(0x0020, 0x002a - 0x0020)));
|
||||
|
||||
logger.info("Request: " + logMapper.write(requestMap));
|
||||
|
||||
long aimeId = -1;
|
||||
Optional<Card> card = cardRepository.findByLuid((String) requestMap.get("luid"));
|
||||
if (card.isPresent()) {
|
||||
aimeId = card.get().getExtId();
|
||||
}
|
||||
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
resultMap.put("type", "lookup");
|
||||
resultMap.put("status", 1);
|
||||
resultMap.put("aimeId", aimeId);
|
||||
resultMap.put("registerLevel", "none");
|
||||
|
||||
logger.info("Response: " + logMapper.write(resultMap));
|
||||
|
||||
ByteBuf respSrc = Unpooled.copiedBuffer(new byte[0x0130]);
|
||||
respSrc.setShortLE(0x0004, 0x0006);
|
||||
respSrc.setShortLE(0x0008, (int) resultMap.get("status"));
|
||||
respSrc.setLongLE(0x0020, (long) resultMap.get("aimeId"));
|
||||
respSrc.setByte(0x0024, 0);
|
||||
|
||||
ctx.writeAndFlush(respSrc);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -206,6 +206,14 @@ public class ChuniServletController {
|
|||
return getUserRecentRatingHandler.handle(request);
|
||||
}
|
||||
|
||||
/**
|
||||
* For older version chunithm
|
||||
*/
|
||||
@PostMapping("GetUserRecentPlayerApi")
|
||||
String getUserRecentPlayerApi(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
||||
return getUserRecentRatingHandler.handle(request);
|
||||
}
|
||||
|
||||
@PostMapping("GetUserRegionApi")
|
||||
String getUserRegion(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
||||
return getUserRegionHandler.handle(request);
|
||||
|
|
Loading…
Reference in New Issue