mirror of https://github.com/hykilpikonna/AquaDX
[O] Ongeki: Static and game handlers
parent
e58e84da35
commit
90f8cd8c65
|
@ -0,0 +1,61 @@
|
|||
package icu.samnyan.aqua.sega.ongeki
|
||||
|
||||
import ext.empty
|
||||
import ext.int
|
||||
import ext.parsing
|
||||
import ext.plus
|
||||
import icu.samnyan.aqua.sega.ongeki.model.GameEventItem
|
||||
|
||||
fun OngekiController.ongekiInit() {
|
||||
fun <T> List<T>.staticLst(key: String) = mapOf("length" to size, key to this)
|
||||
|
||||
// Has type, but type is always 1
|
||||
"GetGameEvent".static {
|
||||
gdb.event.findAll().map { GameEventItem(it.id, 1, "2005-01-01 00:00:00.0", "2099-01-01 05:00:00.0") }
|
||||
.staticLst("gameEventList") + mapOf("type" to 1)
|
||||
}
|
||||
|
||||
"GetGamePoint".static { gdb.point.findAll().staticLst("gamePointList") }
|
||||
"GetGamePresent".static { gdb.present.findAll().staticLst("gamePresentList") }
|
||||
"GetGameReward".static { gdb.reward.findAll().staticLst("gameRewardList") }
|
||||
|
||||
// Dummy endpoints
|
||||
"GetGameTechMusic".static { empty.staticLst("gameTechMusicList") }
|
||||
"GetGameMessage" { mapOf("type" to data["type"], "length" to 0, "gameMessageList" to empty) }
|
||||
"GetGameMusicReleaseState".static { mapOf("techScore" to 0, "cardNum" to 0) }
|
||||
|
||||
"GetGameIdlist" {
|
||||
// type 1: Music NG List, 2: Music Recommend List
|
||||
val type = parsing { data["type"]!!.int }
|
||||
empty.staticLst("gameIdlistList") + mapOf("type" to type)
|
||||
}
|
||||
|
||||
"GetGameRanking" {
|
||||
// type 1: Music current ranking, 2: Music past ranking
|
||||
val type = parsing { data["type"]!!.int }
|
||||
empty.staticLst("gameRankingList") + mapOf("type" to type)
|
||||
}
|
||||
|
||||
"GetGameSetting" {
|
||||
val ver = (data["version"] ?: "1.50.00")
|
||||
mapOf(
|
||||
"isAou" to false,
|
||||
"isDumpUpload" to false,
|
||||
"gameSetting" to mapOf(
|
||||
"dataVersion" to ver,
|
||||
"onlineDataVersion" to ver,
|
||||
"isMaintenance" to false,
|
||||
"requestInterval" to 10,
|
||||
"rebootStartTime" to "2020-01-01 23:59:00.0",
|
||||
"rebootEndTime" to "2020-01-01 23:59:00.0",
|
||||
"isBackgroundDistribute" to false,
|
||||
"maxCountCharacter" to 50,
|
||||
"maxCountCard" to 300,
|
||||
"maxCountItem" to 300,
|
||||
"maxCountMusic" to 50,
|
||||
"maxCountMusicItem" to 300,
|
||||
"maxCountRivalMusic" to 300
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
package icu.samnyan.aqua.sega.ongeki
|
||||
|
||||
import ext.*
|
||||
import icu.samnyan.aqua.net.db.AquaUserServices
|
||||
import icu.samnyan.aqua.net.utils.simpleDescribe
|
||||
import icu.samnyan.aqua.sega.allnet.TokenChecker
|
||||
import icu.samnyan.aqua.sega.general.GameMusicPopularity
|
||||
import icu.samnyan.aqua.sega.general.MeowApi
|
||||
import icu.samnyan.aqua.sega.general.RequestContext
|
||||
import icu.samnyan.aqua.sega.util.jackson.BasicMapper
|
||||
import icu.samnyan.aqua.spring.Metrics
|
||||
import jakarta.servlet.http.HttpServletRequest
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
import kotlin.collections.set
|
||||
|
||||
@Suppress("unused")
|
||||
@RestController
|
||||
@API("/g/ongeki/{version}", "/g/ongeki")
|
||||
class OngekiController(
|
||||
val mapper: BasicMapper,
|
||||
val db: OngekiUserRepos,
|
||||
val gdb: OngekiGameRepos,
|
||||
val us: AquaUserServices,
|
||||
val pop: GameMusicPopularity,
|
||||
): MeowApi({ _, resp -> if (resp is String) resp else mapper.write(resp) }) {
|
||||
|
||||
val log = logger()
|
||||
|
||||
val noopEndpoint = setOf("ExtendLockTimeApi", "GameLoginApi", "GameLogoutApi", "RegisterPromotionCardApi",
|
||||
"UpsertClientBookkeepingApi", "UpsertClientDevelopApi", "UpsertClientErrorApi", "UpsertClientSettingApi",
|
||||
"UpsertClientTestmodeApi", "UpsertUserGplogApi", "Ping")
|
||||
|
||||
init { ongekiInit() }
|
||||
val handlers = initH
|
||||
|
||||
@API("/{endpoint}", "/MatchingServer/{endpoint}")
|
||||
fun handle(@PV endpoint: Str, @RB data: MutableMap<Str, Any>, @PV version: Str, req: HttpServletRequest): Any {
|
||||
val ctx = RequestContext(req, data)
|
||||
val api = endpoint
|
||||
data["version"] = version
|
||||
|
||||
// if (api.startsWith("CM") && api !in handlers) api = api.removePrefix("CM")
|
||||
val token = TokenChecker.getCurrentSession()?.token?.substring(0, 6) ?: "NO-TOKEN"
|
||||
log.info("Ongeki < $api : ${data.toJson()} : [$token]")
|
||||
|
||||
val noop = """{"returnCode":"1","apiName":"${api.substringBefore("Api").firstCharLower()}"}"""
|
||||
if (api !in noopEndpoint && !handlers.containsKey(api)) {
|
||||
log.warn("Ongeki > $api not found")
|
||||
return noop
|
||||
}
|
||||
|
||||
// Only record the counter metrics if the API is known.
|
||||
Metrics.counter("aquadx_ongeki_api_call", "api" to api).increment()
|
||||
if (api in noopEndpoint) {
|
||||
log.info("Ongeki > $api no-op")
|
||||
return noop
|
||||
}
|
||||
|
||||
return try {
|
||||
Metrics.timer("aquadx_ongeki_api_latency", "api" to api).recordCallable {
|
||||
serialize(api, handlers[api]!!(ctx) ?: noop).also {
|
||||
if (api !in setOf("GetUserItemApi", "GetGameEventApi"))
|
||||
log.info("Ongeki > $api : $it")
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Metrics.counter(
|
||||
"aquadx_ongeki_api_error",
|
||||
"api" to api, "error" to e.simpleDescribe()
|
||||
).increment()
|
||||
throw e
|
||||
}
|
||||
}
|
||||
}
|
|
@ -19,16 +19,6 @@ import java.util.Map;
|
|||
@RequestMapping("/g/ongeki")
|
||||
@AllArgsConstructor
|
||||
public class OngekiController {
|
||||
|
||||
private final GetGameEventHandler getGameEventHandler;
|
||||
private final GetGameIdlistHandler getGameIdlistHandler;
|
||||
private final GetGameMessageHandler getGameMessageHandler;
|
||||
private final GetGamePointHandler getGamePointHandler;
|
||||
private final GetGamePresentHandler getGamePresentHandler;
|
||||
private final GetGameTechMusicHandler getGameTechMusicHandler;
|
||||
private final GetGameRankingHandler getGameRankingHandler;
|
||||
private final GetGameRewardHandler getGameRewardHandler;
|
||||
private final GetGameSettingHandler getGameSettingHandler;
|
||||
private final GetUserActivityHandler getUserActivityHandler;
|
||||
private final GetUserBossHandler getUserBossHandler;
|
||||
private final GetUserBpBaseHandler getUserBpBaseHandler;
|
||||
|
@ -65,57 +55,6 @@ public class OngekiController {
|
|||
private final UpsertUserAllHandler upsertUserAllHandler;
|
||||
private final GetClientBookkeepingHandler getClientBookkeepingHandler;
|
||||
private final GetClientTestmodeHandler getClientTestmodeHandler;
|
||||
private final GetGameMusicReleaseStateHandler getGameMusicReleaseStateHandler;
|
||||
|
||||
@PostMapping("ExtendLockTimeApi")
|
||||
public String extendLockTime(@ModelAttribute Map<String, Object> request) {
|
||||
return "{\"returnCode\":1,\"apiName\":\"extendLockTime\"}";
|
||||
}
|
||||
|
||||
@PostMapping("GameLoginApi")
|
||||
public String gameLogin(@ModelAttribute Map<String, Object> request) {
|
||||
return "{\"returnCode\":1,\"apiName\":\"gameLogin\"}";
|
||||
}
|
||||
|
||||
@PostMapping("GameLogoutApi")
|
||||
public String gameLogout(@ModelAttribute Map<String, Object> request) {
|
||||
return "{\"returnCode\":1,\"apiName\": \"gameLogout\"}";
|
||||
}
|
||||
|
||||
@PostMapping("GetGameEventApi")
|
||||
public String getGameEvent(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
||||
return getGameEventHandler.handle(request);
|
||||
}
|
||||
|
||||
@PostMapping("GetGameIdlistApi")
|
||||
public String getGameIdList(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
||||
return getGameIdlistHandler.handle(request);
|
||||
}
|
||||
|
||||
@PostMapping("GetGameMessageApi")
|
||||
public String getGameMessage(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
||||
return getGameMessageHandler.handle(request);
|
||||
}
|
||||
|
||||
@PostMapping("GetGamePointApi")
|
||||
public String getGamePoint(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
||||
return getGamePointHandler.handle(request);
|
||||
}
|
||||
|
||||
@PostMapping("GetGamePresentApi")
|
||||
public String getGamePresent(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
||||
return getGamePresentHandler.handle(request);
|
||||
}
|
||||
|
||||
@PostMapping("GetGameTechMusicApi")
|
||||
public String getGameTechMusic(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
||||
return getGameTechMusicHandler.handle(request);
|
||||
}
|
||||
|
||||
@PostMapping("GetGameMusicReleaseStateApi")
|
||||
public String GetGameMusicReleaseState(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
||||
return getGameMusicReleaseStateHandler.handle(request);
|
||||
}
|
||||
|
||||
@PostMapping("GetUserTechEventApi")
|
||||
public String getUserTechEvent(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
||||
|
@ -127,21 +66,6 @@ public class OngekiController {
|
|||
return getUserTechEventRankingHandler.handle(request);
|
||||
}
|
||||
|
||||
@PostMapping("GetGameRankingApi")
|
||||
public String getGameRanking(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
||||
return getGameRankingHandler.handle(request);
|
||||
}
|
||||
|
||||
@PostMapping("GetGameRewardApi")
|
||||
public String getGameReward(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
||||
return getGameRewardHandler.handle(request);
|
||||
}
|
||||
|
||||
@PostMapping("GetGameSettingApi")
|
||||
public String getGameSetting(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
||||
return getGameSettingHandler.handle(request);
|
||||
}
|
||||
|
||||
@PostMapping("GetUserActivityApi")
|
||||
public String getUserActivity(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
||||
return getUserActivityHandler.handle(request);
|
||||
|
@ -307,49 +231,8 @@ public class OngekiController {
|
|||
return getClientTestmodeHandler.handle(request);
|
||||
}
|
||||
|
||||
@PostMapping("RegisterPromotionCardApi")
|
||||
public String registerPromotionCard(@ModelAttribute Map<String, Object> request) {
|
||||
return "{\"returnCode\":1,\"apiName\":\"registerPromotionCard\"}";
|
||||
}
|
||||
|
||||
@PostMapping("UpsertClientBookkeepingApi")
|
||||
public String upsertClientBookkeeping(@ModelAttribute Map<String, Object> request) {
|
||||
return "{\"returnCode\":1},\"apiName\":\"upsertClientBookkeeping\"";
|
||||
}
|
||||
|
||||
@PostMapping("UpsertClientDevelopApi")
|
||||
public String upsertClientDevelop(@ModelAttribute Map<String, Object> request) {
|
||||
return "{\"returnCode\":1},\"apiName\":\"upsertClientDevelop\"";
|
||||
}
|
||||
|
||||
@PostMapping("UpsertClientErrorApi")
|
||||
public String upsertClientError(@ModelAttribute Map<String, Object> request) {
|
||||
return "{\"returnCode\":1,\"apiName\":\"upsertClientError\"}";
|
||||
}
|
||||
|
||||
@PostMapping("UpsertClientSettingApi")
|
||||
public String upsertClientSetting(@ModelAttribute Map<String, Object> request) {
|
||||
return "{\"returnCode\":1,\"apiName\":\"upsertClientSetting\"}";
|
||||
}
|
||||
|
||||
@PostMapping("UpsertClientTestmodeApi")
|
||||
public String upsertClientTestmode(@ModelAttribute Map<String, Object> request) {
|
||||
return "{\"returnCode\":1,\"apiName\":\"upsertClientTestmode\"}";
|
||||
}
|
||||
|
||||
@PostMapping("UpsertUserGplogApi")
|
||||
public String upsertUserGplog(@ModelAttribute Map<String, Object> request) {
|
||||
return "{\"returnCode\":1,\"apiName\":\"upsertUserGplog\"}";
|
||||
}
|
||||
|
||||
@PostMapping("UpsertUserAllApi")
|
||||
public String upsertUserAll(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
||||
return upsertUserAllHandler.handle(request);
|
||||
}
|
||||
|
||||
@PostMapping("Ping")
|
||||
String ping(@ModelAttribute Map<String, Object> request) {
|
||||
return "{\"returnCode\":\"1\"}";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
package icu.samnyan.aqua.sega.ongeki.controller;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@RestControllerAdvice(basePackages = "icu.samnyan.aqua.sega.ongeki")
|
||||
public class OngekiControllerAdvice {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(OngekiControllerAdvice.class);
|
||||
|
||||
|
||||
/**
|
||||
* Get the map object from json string
|
||||
*
|
||||
* @param request HttpServletRequest
|
||||
*/
|
||||
@ModelAttribute
|
||||
public Map<String, Object> preHandle(HttpServletRequest request) throws IOException {
|
||||
byte[] src = request.getInputStream().readAllBytes();
|
||||
String outputString = new String(src, StandardCharsets.UTF_8).trim();
|
||||
logger.info("Request " + request.getRequestURI() + ": " + outputString);
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
return mapper.readValue(outputString, new TypeReference<>() {
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
package icu.samnyan.aqua.sega.ongeki.handler.impl;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import icu.samnyan.aqua.sega.ongeki.OgkGameEventRepo;
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.ongeki.model.GameEvent;
|
||||
import icu.samnyan.aqua.sega.ongeki.model.GameEventItem;
|
||||
import icu.samnyan.aqua.sega.util.jackson.BasicMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component("OngekiGetGameEventHandler")
|
||||
public class GetGameEventHandler implements BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GetGameEventHandler.class);
|
||||
|
||||
private final BasicMapper mapper;
|
||||
|
||||
private final OgkGameEventRepo gameEventRepository;
|
||||
|
||||
@Autowired
|
||||
public GetGameEventHandler(BasicMapper mapper, OgkGameEventRepo gameEventRepository) {
|
||||
this.mapper = mapper;
|
||||
this.gameEventRepository = gameEventRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(Map<String, ?> request) throws JsonProcessingException {
|
||||
Integer type = (Integer) request.get("type");
|
||||
|
||||
List<GameEvent> eventIdList = gameEventRepository.findAll();
|
||||
List<GameEventItem> eventList = new ArrayList<>();
|
||||
eventIdList.forEach(x -> eventList.add(new GameEventItem(
|
||||
x.getId(),
|
||||
type,
|
||||
"2005-01-01 00:00:00.0",
|
||||
"2099-01-01 05:00:00.0"
|
||||
)));
|
||||
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||
resultMap.put("type", type);
|
||||
resultMap.put("length", eventList.size());
|
||||
resultMap.put("gameEventList", eventList);
|
||||
|
||||
String json = mapper.write(resultMap);
|
||||
logger.info("Response: {} events", eventList.size());
|
||||
return json;
|
||||
}
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
package icu.samnyan.aqua.sega.ongeki.handler.impl;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import icu.samnyan.aqua.sega.general.dao.PropertyEntryRepository;
|
||||
import icu.samnyan.aqua.sega.general.model.PropertyEntry;
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.ongeki.model.GameIdListItem;
|
||||
import icu.samnyan.aqua.sega.util.jackson.BasicMapper;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component("OngekiGetGameIdlistHandler")
|
||||
public class GetGameIdlistHandler implements BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GetGameIdlistHandler.class);
|
||||
|
||||
private final BasicMapper mapper;
|
||||
|
||||
private final PropertyEntryRepository propertyEntryRepository;
|
||||
|
||||
@Autowired
|
||||
public GetGameIdlistHandler(BasicMapper mapper, PropertyEntryRepository propertyEntryRepository) {
|
||||
this.mapper = mapper;
|
||||
this.propertyEntryRepository = propertyEntryRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(Map<String, ?> request) throws JsonProcessingException {
|
||||
Integer type = (Integer) request.get("type");
|
||||
|
||||
Optional<PropertyEntry> propertyEntryOptional;
|
||||
if(type == 1) {
|
||||
propertyEntryOptional = propertyEntryRepository.findByPropertyKey("ongeki_music_ng_list");
|
||||
} else if(type == 2) {
|
||||
propertyEntryOptional = propertyEntryRepository.findByPropertyKey("ongeki_music_recommend_list");
|
||||
} else {
|
||||
propertyEntryOptional = Optional.empty();
|
||||
}
|
||||
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||
resultMap.put("type", type);
|
||||
|
||||
if (propertyEntryOptional.isPresent()) {
|
||||
String value = propertyEntryOptional.get().getPropertyValue();
|
||||
|
||||
if(StringUtils.isNotBlank(value) && value.contains(",")) {
|
||||
String[] ids = value.split(",");
|
||||
List<GameIdListItem> idList = new LinkedList<>();
|
||||
|
||||
for (String id : ids) {
|
||||
try {
|
||||
idList.add(new GameIdListItem(Integer.parseInt(id), type));
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
}
|
||||
resultMap.put("length", idList.size());
|
||||
resultMap.put("gameIdlistList", idList);
|
||||
|
||||
} else {
|
||||
resultMap.put("length", 0);
|
||||
resultMap.put("gameIdlistList", new List[]{});
|
||||
}
|
||||
} else {
|
||||
resultMap.put("length", 0);
|
||||
resultMap.put("gameIdlistList", new List[]{});
|
||||
}
|
||||
|
||||
String json = mapper.write(resultMap);
|
||||
logger.info("Response: " + json);
|
||||
return json;
|
||||
}
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
package icu.samnyan.aqua.sega.ongeki.handler.impl;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.util.jackson.BasicMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component("OngekiGetGameMessageHHandler")
|
||||
public class GetGameMessageHandler implements BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GetGameMessageHandler.class);
|
||||
|
||||
private final BasicMapper mapper;
|
||||
|
||||
@Autowired
|
||||
public GetGameMessageHandler(BasicMapper mapper) {
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String handle(Map<String, ?> request) throws JsonProcessingException {
|
||||
Integer type = (Integer) request.get("type");
|
||||
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||
resultMap.put("type", type);
|
||||
resultMap.put("length", 0);
|
||||
resultMap.put("gameMessageList", new List[]{});
|
||||
|
||||
String json = mapper.write(resultMap);
|
||||
|
||||
logger.info("Response: " + json);
|
||||
return json;
|
||||
}
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
package icu.samnyan.aqua.sega.ongeki.handler.impl;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
|
||||
import icu.samnyan.aqua.sega.ongeki.OgkUserKopRepo;
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.util.jackson.BasicMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component("OngekiGetGameMusicReleaseStateHandler")
|
||||
public class GetGameMusicReleaseStateHandler implements BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GetGameMusicReleaseStateHandler.class);
|
||||
|
||||
private final BasicMapper mapper;
|
||||
|
||||
@Autowired
|
||||
public GetGameMusicReleaseStateHandler(BasicMapper mapper, OgkUserKopRepo userKopRepository) {
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(Map<String, ?> request) throws JsonProcessingException {
|
||||
|
||||
// TODO: Find out what this does
|
||||
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||
resultMap.put("techScore", 0);
|
||||
resultMap.put("cardNum", 0);
|
||||
|
||||
String json = mapper.write(resultMap);
|
||||
|
||||
logger.info("Response: " + json);
|
||||
return json;
|
||||
}
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
package icu.samnyan.aqua.sega.ongeki.handler.impl;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import icu.samnyan.aqua.sega.ongeki.OgkGamePointRepo;
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.ongeki.model.GamePoint;
|
||||
import icu.samnyan.aqua.sega.util.jackson.BasicMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component("OngekiGetGamePointHandler")
|
||||
public class GetGamePointHandler implements BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GetGamePointHandler.class);
|
||||
|
||||
private final BasicMapper mapper;
|
||||
|
||||
private final OgkGamePointRepo gamePointRepository;
|
||||
|
||||
@Autowired
|
||||
public GetGamePointHandler(BasicMapper mapper, OgkGamePointRepo gamePointRepository) {
|
||||
this.mapper = mapper;
|
||||
this.gamePointRepository = gamePointRepository;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String handle(Map<String, ?> request) throws JsonProcessingException {
|
||||
// This value is always false
|
||||
Boolean isAllGP = (Boolean) request.get("isAllGP");
|
||||
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||
|
||||
List<GamePoint> gpList = gamePointRepository.findAll();
|
||||
|
||||
resultMap.put("length", gpList.size());
|
||||
resultMap.put("gamePointList", gpList);
|
||||
|
||||
String json = mapper.write(resultMap);
|
||||
|
||||
logger.info("Response: " + json);
|
||||
return json;
|
||||
}
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
package icu.samnyan.aqua.sega.ongeki.handler.impl;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import icu.samnyan.aqua.sega.ongeki.OgkGamePresentRepo;
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.ongeki.model.GamePresent;
|
||||
import icu.samnyan.aqua.sega.util.jackson.BasicMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component("OngekiGetGamePresentHandler")
|
||||
public class GetGamePresentHandler implements BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GetGamePresentHandler.class);
|
||||
|
||||
private final BasicMapper mapper;
|
||||
|
||||
private final OgkGamePresentRepo gamePresentRepository;
|
||||
|
||||
@Autowired
|
||||
public GetGamePresentHandler(BasicMapper mapper, OgkGamePresentRepo gamePresentRepository) {
|
||||
this.mapper = mapper;
|
||||
this.gamePresentRepository = gamePresentRepository;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String handle(Map<String, ?> request) throws JsonProcessingException {
|
||||
Boolean isAllPresent = (Boolean) request.get("isAllPresent");
|
||||
|
||||
List<GamePresent> presentList = gamePresentRepository.findAll();
|
||||
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||
resultMap.put("length", presentList.size());
|
||||
resultMap.put("gamePresentList", presentList);
|
||||
|
||||
String json = mapper.write(resultMap);
|
||||
|
||||
logger.info("Response: " + json);
|
||||
return json;
|
||||
}
|
||||
}
|
|
@ -1,84 +0,0 @@
|
|||
package icu.samnyan.aqua.sega.ongeki.handler.impl;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import icu.samnyan.aqua.sega.general.dao.PropertyEntryRepository;
|
||||
import icu.samnyan.aqua.sega.general.model.PropertyEntry;
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.ongeki.model.GameRankingItem;
|
||||
import icu.samnyan.aqua.sega.util.jackson.BasicMapper;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Get game music hot ranking list.
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component("OngekiGetGameRankingHandler")
|
||||
public class GetGameRankingHandler implements BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GetGameRankingHandler.class);
|
||||
|
||||
private final BasicMapper mapper;
|
||||
|
||||
private final PropertyEntryRepository propertyEntryRepository;
|
||||
|
||||
@Autowired
|
||||
public GetGameRankingHandler(BasicMapper mapper, PropertyEntryRepository propertyEntryRepository) {
|
||||
this.mapper = mapper;
|
||||
this.propertyEntryRepository = propertyEntryRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(Map<String, ?> request) throws JsonProcessingException {
|
||||
// 1 is current, 2 is old
|
||||
// See ADT_Ranking.cs
|
||||
Integer type = (Integer) request.get("type");
|
||||
Optional<PropertyEntry> propertyEntryOptional;
|
||||
if(type == 1) {
|
||||
propertyEntryOptional = propertyEntryRepository.findByPropertyKey("ongeki_music_ranking_current");
|
||||
} else if(type == 2) {
|
||||
propertyEntryOptional = propertyEntryRepository.findByPropertyKey("ongeki_music_ranking_old");
|
||||
} else {
|
||||
propertyEntryOptional = Optional.empty();
|
||||
}
|
||||
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||
resultMap.put("type", type);
|
||||
|
||||
if (propertyEntryOptional.isPresent()) {
|
||||
String value = propertyEntryOptional.get().getPropertyValue();
|
||||
|
||||
if(StringUtils.isNotBlank(value) && value.contains(",")) {
|
||||
String[] ids = value.split(",");
|
||||
List<GameRankingItem> list = new LinkedList<>();
|
||||
|
||||
for (String id : ids) {
|
||||
try {
|
||||
list.add(new GameRankingItem(Integer.parseInt(id), 0, ""));
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
// in ADT_Ranking.cs, the game read this array and expected it has 10 value here.
|
||||
while (list.size() < 10) {
|
||||
list.add(new GameRankingItem(0, 0, ""));
|
||||
}
|
||||
}
|
||||
|
||||
resultMap.put("gameRankingList", list);
|
||||
|
||||
} else {
|
||||
resultMap.put("gameRankingList", new List[]{});
|
||||
}
|
||||
} else {
|
||||
resultMap.put("gameRankingList", new List[]{});
|
||||
}
|
||||
|
||||
String json = mapper.write(resultMap);
|
||||
logger.info("Response: " + json);
|
||||
return json;
|
||||
}
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
package icu.samnyan.aqua.sega.ongeki.handler.impl;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import icu.samnyan.aqua.sega.ongeki.OgkGameRewardRepo;
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.ongeki.model.GameReward;
|
||||
import icu.samnyan.aqua.sega.util.jackson.BasicMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component("OngekiGetGameRewardHandler")
|
||||
public class GetGameRewardHandler implements BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GetGameRewardHandler.class);
|
||||
|
||||
private final BasicMapper mapper;
|
||||
|
||||
private final OgkGameRewardRepo gameRewardRepository;
|
||||
|
||||
@Autowired
|
||||
public GetGameRewardHandler(BasicMapper mapper, OgkGameRewardRepo gameRewardRepository) {
|
||||
this.mapper = mapper;
|
||||
this.gameRewardRepository = gameRewardRepository;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String handle(Map<String, ?> request) throws JsonProcessingException {
|
||||
Boolean isAllGP = (Boolean) request.get("isAllReward");
|
||||
|
||||
List<GameReward> rewardList = gameRewardRepository.findAll();
|
||||
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||
resultMap.put("length", rewardList.size());
|
||||
resultMap.put("gameRewardList", rewardList);
|
||||
|
||||
String json = mapper.write(resultMap);
|
||||
|
||||
logger.info("Response: " + json);
|
||||
return json;
|
||||
}
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
package icu.samnyan.aqua.sega.ongeki.handler.impl;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import icu.samnyan.aqua.sega.general.dao.PropertyEntryRepository;
|
||||
import icu.samnyan.aqua.sega.general.model.PropertyEntry;
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.ongeki.model.GetGameSettingResp;
|
||||
import icu.samnyan.aqua.sega.ongeki.model.GameSetting;
|
||||
import icu.samnyan.aqua.sega.util.jackson.BasicMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component("OngekiGetGameSettingHandler")
|
||||
public class GetGameSettingHandler implements BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GetGameSettingHandler.class);
|
||||
|
||||
private final BasicMapper mapper;
|
||||
|
||||
private final PropertyEntryRepository propertyEntryRepository;
|
||||
|
||||
private final String GAME_VERSION;
|
||||
|
||||
@Autowired
|
||||
public GetGameSettingHandler(BasicMapper mapper, PropertyEntryRepository propertyEntryRepository, @Value("${game.ongeki.version:1.05.00}") String GAME_VERSION) {
|
||||
this.mapper = mapper;
|
||||
this.propertyEntryRepository = propertyEntryRepository;
|
||||
this.GAME_VERSION = GAME_VERSION;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String handle(Map<String, ?> request) throws JsonProcessingException {
|
||||
|
||||
PropertyEntry start = propertyEntryRepository.findByPropertyKey("reboot_start_time")
|
||||
.orElseGet(() -> new PropertyEntry("reboot_start_time", "2020-01-01 23:59:00.0"));
|
||||
PropertyEntry end = propertyEntryRepository.findByPropertyKey("reboot_end_time")
|
||||
.orElseGet(() -> new PropertyEntry("reboot_end_time", "2020-01-01 23:59:00.0"));
|
||||
|
||||
GameSetting gameSetting = new GameSetting(
|
||||
GAME_VERSION,
|
||||
GAME_VERSION,
|
||||
false,
|
||||
10,
|
||||
start.getPropertyValue(),
|
||||
end.getPropertyValue(),
|
||||
false,
|
||||
50,
|
||||
300,
|
||||
300,
|
||||
50,
|
||||
300,
|
||||
300);
|
||||
|
||||
GetGameSettingResp resp = new GetGameSettingResp(
|
||||
gameSetting,
|
||||
false,
|
||||
false
|
||||
);
|
||||
|
||||
String json = mapper.write(resp);
|
||||
|
||||
logger.info("Response: " + json);
|
||||
return json;
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
package icu.samnyan.aqua.sega.ongeki.handler.impl;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.util.jackson.BasicMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component("OngekiGetGameTechMusicHandler")
|
||||
public class GetGameTechMusicHandler implements BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GetGameTechMusicHandler.class);
|
||||
|
||||
private final BasicMapper mapper;
|
||||
|
||||
@Autowired
|
||||
public GetGameTechMusicHandler(BasicMapper mapper) {
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(Map<String, ?> request) throws JsonProcessingException {
|
||||
List<Object> techMusicList = new ArrayList<>();
|
||||
|
||||
// This endpoint seems related to "techchallengeevent" in game data, TBD
|
||||
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||
resultMap.put("length", 0);
|
||||
resultMap.put("gameTechMusicList", techMusicList);
|
||||
|
||||
String json = mapper.write(resultMap);
|
||||
|
||||
logger.info("Response: " + json);
|
||||
return json;
|
||||
}
|
||||
}
|
|
@ -7,12 +7,6 @@ class CodeResp(
|
|||
var apiName: String? = null,
|
||||
)
|
||||
|
||||
class GetGameSettingResp(
|
||||
var gameSetting: GameSetting? = null,
|
||||
var isDumpUpload: Bool = false,
|
||||
var isAou: Bool = false,
|
||||
)
|
||||
|
||||
class GetUserPreviewResp(
|
||||
var userId: Long = 0,
|
||||
var isLogin: Bool = false,
|
||||
|
@ -60,22 +54,6 @@ class GameRankingItem(
|
|||
var userName: String = "",
|
||||
)
|
||||
|
||||
class GameSetting(
|
||||
var dataVersion: String = "",
|
||||
var onlineDataVersion: String = "",
|
||||
var isMaintenance: Bool = false,
|
||||
var requestInterval: Int = 0,
|
||||
var rebootStartTime: String = "",
|
||||
var rebootEndTime: String = "",
|
||||
var isBackgroundDistribute: Bool = false,
|
||||
var maxCountCharacter: Int = 0,
|
||||
var maxCountCard: Int = 0,
|
||||
var maxCountItem: Int = 0,
|
||||
var maxCountMusic: Int = 0,
|
||||
var maxCountMusicItem: Int = 0,
|
||||
var maxCountRivalMusic: Int = 0,
|
||||
)
|
||||
|
||||
class UserEventRankingItem(
|
||||
var eventId: Int = 0,
|
||||
var type: Int = 0,
|
||||
|
|
Loading…
Reference in New Issue