mirror of https://github.com/hykilpikonna/AquaDX
[O] Ongeki: User unpaged apis
parent
a2b27090db
commit
654cda736d
|
@ -25,6 +25,7 @@ typealias SpecialHandler = RequestContext.() -> Any?
|
||||||
fun BaseHandler.toSpecial() = { ctx: RequestContext -> handle(ctx.data) }
|
fun BaseHandler.toSpecial() = { ctx: RequestContext -> handle(ctx.data) }
|
||||||
|
|
||||||
typealias PagedHandler = RequestContext.() -> List<Any>
|
typealias PagedHandler = RequestContext.() -> List<Any>
|
||||||
|
typealias PagedExtraHandler = RequestContext.() -> Pair<List<Any>, JDict>
|
||||||
typealias AddFn = RequestContext.() -> PagedProcessor
|
typealias AddFn = RequestContext.() -> PagedProcessor
|
||||||
typealias PagePost = (MutJDict) -> Unit
|
typealias PagePost = (MutJDict) -> Unit
|
||||||
data class PagedProcessor(val add: JDict?, val fn: PagedHandler, var post: PagePost? = null)
|
data class PagedProcessor(val add: JDict?, val fn: PagedHandler, var post: PagePost? = null)
|
||||||
|
@ -75,4 +76,21 @@ abstract class MeowApi(val serialize: (String, Any) -> String) {
|
||||||
val minTime = millis() - (1000 * 60)
|
val minTime = millis() - (1000 * 60)
|
||||||
pageCache.entries.removeIf { it.value.l < minTime }
|
pageCache.entries.removeIf { it.value.l < minTime }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Used because maimai and ongeki does not actually require paging implementation
|
||||||
|
fun String.unpaged(key: String? = null, fn: PagedHandler) {
|
||||||
|
val k = key ?: (this.replace("Get", "").firstCharLower() + "List")
|
||||||
|
this {
|
||||||
|
val l = fn(this)
|
||||||
|
mapOf("userId" to uid, "nextIndex" to 0, "length" to l.size, k to l)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun String.unpagedExtra(key: String? = null, fn: PagedExtraHandler) {
|
||||||
|
val k = key ?: (this.replace("Get", "").firstCharLower() + "List")
|
||||||
|
this {
|
||||||
|
val (l, e) = fn(this)
|
||||||
|
mapOf("userId" to uid, "nextIndex" to 0, "length" to l.size, k to l) + e
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,21 +3,12 @@
|
||||||
package icu.samnyan.aqua.sega.maimai2
|
package icu.samnyan.aqua.sega.maimai2
|
||||||
|
|
||||||
import ext.*
|
import ext.*
|
||||||
import icu.samnyan.aqua.sega.general.PagedHandler
|
|
||||||
import icu.samnyan.aqua.sega.maimai2.model.UserRivalMusic
|
import icu.samnyan.aqua.sega.maimai2.model.UserRivalMusic
|
||||||
import icu.samnyan.aqua.sega.maimai2.model.UserRivalMusicDetail
|
import icu.samnyan.aqua.sega.maimai2.model.UserRivalMusicDetail
|
||||||
import icu.samnyan.aqua.sega.maimai2.model.userdata.Mai2UserKaleidx
|
import icu.samnyan.aqua.sega.maimai2.model.userdata.Mai2UserKaleidx
|
||||||
import java.time.LocalDate
|
import java.time.LocalDate
|
||||||
|
|
||||||
fun Maimai2ServletController.initApis() {
|
fun Maimai2ServletController.initApis() {
|
||||||
// Used because maimai does not actually require paging implementation
|
|
||||||
fun String.unpaged(key: String? = null, fn: PagedHandler) {
|
|
||||||
val k = key ?: (this.replace("Get", "").firstCharLower() + "List")
|
|
||||||
this {
|
|
||||||
fn(this).let { mapOf("userId" to uid, "nextIndex" to 0, "length" to it.size, k to it) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
"GetUserExtend" { mapOf(
|
"GetUserExtend" { mapOf(
|
||||||
"userId" to uid,
|
"userId" to uid,
|
||||||
"userExtend" to (db.userExtend.findSingleByUser_Card_ExtId(uid)() ?: (404 - "User not found"))
|
"userExtend" to (db.userExtend.findSingleByUser_Card_ExtId(uid)() ?: (404 - "User not found"))
|
||||||
|
|
|
@ -9,6 +9,8 @@ import icu.samnyan.aqua.sega.ongeki.model.GameEventItem
|
||||||
fun OngekiController.ongekiInit() {
|
fun OngekiController.ongekiInit() {
|
||||||
fun <T> List<T>.staticLst(key: String) = mapOf("length" to size, key to this)
|
fun <T> List<T>.staticLst(key: String) = mapOf("length" to size, key to this)
|
||||||
|
|
||||||
|
initUser()
|
||||||
|
|
||||||
// Has type, but type is always 1
|
// Has type, but type is always 1
|
||||||
"GetGameEvent".static {
|
"GetGameEvent".static {
|
||||||
gdb.event.findAll().map { GameEventItem(it.id, 1, "2005-01-01 00:00:00.0", "2099-01-01 05:00:00.0") }
|
gdb.event.findAll().map { GameEventItem(it.id, 1, "2005-01-01 00:00:00.0", "2099-01-01 05:00:00.0") }
|
||||||
|
@ -58,4 +60,12 @@ fun OngekiController.ongekiInit() {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"GetClientBookkeeping" {
|
||||||
|
empty.staticLst("clientBookkeepingList") + mapOf("placeId" to data["placeId"])
|
||||||
|
}
|
||||||
|
|
||||||
|
"GetClientTestmode" {
|
||||||
|
empty.staticLst("clientTestmodeList") + mapOf("placeId" to data["placeId"])
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
package icu.samnyan.aqua.sega.ongeki
|
||||||
|
|
||||||
|
import ext.empty
|
||||||
|
import ext.int
|
||||||
|
import ext.invoke
|
||||||
|
import ext.parsing
|
||||||
|
import java.time.LocalDateTime
|
||||||
|
import java.time.format.DateTimeFormatter
|
||||||
|
|
||||||
|
|
||||||
|
fun OngekiController.initUser() {
|
||||||
|
"GetUserData" { mapOf("userId" to uid, "userData" to db.data.findByCard_ExtId(uid)()) }
|
||||||
|
"GetUserOption" { mapOf("userId" to uid, "userOption" to db.option.findSingleByUser_Card_ExtId(uid)()) }
|
||||||
|
"GetUserEventMap" { mapOf("userId" to uid, "userEventMap" to db.eventMap.findSingleByUser_Card_ExtId(uid)()) }
|
||||||
|
|
||||||
|
"GetUserTechEvent".unpaged { db.techEvent.findByUser_Card_ExtId(uid) }
|
||||||
|
"GetUserBoss".unpaged { db.boss.findByUser_Card_ExtId(uid) }
|
||||||
|
"GetUserCard".unpaged { db.card.findByUser_Card_ExtId(uid) }
|
||||||
|
"GetUserChapter".unpaged { db.chapter.findByUser_Card_ExtId(uid) }
|
||||||
|
"GetUserMemoryChapter".unpaged { db.memoryChapter.findByUser_Card_ExtId(uid) }
|
||||||
|
"GetUserCharacter".unpaged { db.character.findByUser_Card_ExtId(uid) }
|
||||||
|
"GetUserDeckByKey".unpaged { db.deck.findByUser_Card_ExtId(uid) }
|
||||||
|
"GetUserEventMusic".unpaged { db.eventMusic.findByUser_Card_ExtId(uid) }
|
||||||
|
"GetUserEventPoint".unpaged { db.eventPoint.findByUser_Card_ExtId(uid) }
|
||||||
|
"GetUserLoginBonus".unpaged { db.loginBonus.findByUser_Card_ExtId(uid) }
|
||||||
|
"GetUserMissionPoint".unpaged { db.missionPoint.findByUser_Card_ExtId(uid) }
|
||||||
|
"GetUserMusicItem".unpaged { db.musicItem.findByUser_Card_ExtId(uid) }
|
||||||
|
|
||||||
|
val dtPattern = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.0")
|
||||||
|
|
||||||
|
"GetUserTechEventRanking".unpaged {
|
||||||
|
val time = LocalDateTime.now().format(dtPattern)
|
||||||
|
|
||||||
|
db.techEvent.findByUser_Card_ExtId(uid).map { mapOf(
|
||||||
|
"eventId" to it.eventId,
|
||||||
|
"date" to time,
|
||||||
|
"rank" to 1,
|
||||||
|
"totalTechScore" to it.totalTechScore,
|
||||||
|
"totalPlatinumScore" to it.totalPlatinumScore
|
||||||
|
) }
|
||||||
|
}
|
||||||
|
|
||||||
|
"GetUserEventRanking".unpaged {
|
||||||
|
val time = LocalDateTime.now().format(dtPattern)
|
||||||
|
|
||||||
|
db.eventPoint.findByUser_Card_ExtId(uid).map { mapOf(
|
||||||
|
"eventId" to it.eventId,
|
||||||
|
"type" to 1, // Latest ranking
|
||||||
|
"date" to time,
|
||||||
|
"rank" to db.eventPoint.calculateRankByUserAndEventId(uid, it.eventId),
|
||||||
|
"point" to it.point
|
||||||
|
) }
|
||||||
|
}
|
||||||
|
|
||||||
|
"GetUserActivity".unpagedExtra {
|
||||||
|
val kind = parsing { data["kind"]!!.int }
|
||||||
|
db.activity.findByUser_Card_ExtIdAndKindOrderBySortNumberDesc(uid, kind)
|
||||||
|
.take(if (kind == 1) 15 else 10) to mapOf("kind" to kind)
|
||||||
|
}
|
||||||
|
|
||||||
|
"GetUserBpBase".unpaged { empty }
|
||||||
|
}
|
|
@ -18,25 +18,8 @@ import java.util.Map;
|
||||||
@RequestMapping("/g/ongeki")
|
@RequestMapping("/g/ongeki")
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class OngekiController {
|
public class OngekiController {
|
||||||
private final GetUserActivityHandler getUserActivityHandler;
|
|
||||||
private final GetUserBossHandler getUserBossHandler;
|
|
||||||
private final GetUserBpBaseHandler getUserBpBaseHandler;
|
|
||||||
private final GetUserCardHandler getUserCardHandler;
|
|
||||||
private final GetUserChapterHandler getUserChapterHandler;
|
|
||||||
private final GetUserMemoryChapterHandler getUserMemoryChapterHandler;
|
|
||||||
private final GetUserCharacterHandler getUserCharacterHandler;
|
|
||||||
private final GetUserDataHandler getUserDataHandler;
|
|
||||||
private final GetUserDeckByKeyHandler getUserDeckByKeyHandler;
|
|
||||||
private final GetUserEventMapHandler getUserEventMapHandler;
|
|
||||||
private final GetUserEventPointHandler getUserEventPointHandler;
|
|
||||||
private final GetUserEventRankingHandler getUserEventRankingHandler;
|
|
||||||
private final GetUserEventMusicHandler getUserEventMusicHandler;
|
|
||||||
private final GetUserItemHandler getUserItemHandler;
|
private final GetUserItemHandler getUserItemHandler;
|
||||||
private final GetUserLoginBonusHandler getUserLoginBonusHandler;
|
|
||||||
private final GetUserMissionPointHandler getUserMissionPointHandler;
|
|
||||||
private final GetUserMusicHandler getUserMusicHandler;
|
private final GetUserMusicHandler getUserMusicHandler;
|
||||||
private final GetUserMusicItemHandler getUserMusicItemHandler;
|
|
||||||
private final GetUserOptionHandler getUserOptionHandler;
|
|
||||||
private final GetUserPreviewHandler getUserPreviewHandler;
|
private final GetUserPreviewHandler getUserPreviewHandler;
|
||||||
private final GetUserRatinglogListHandler getUserRatinglogListHandler;
|
private final GetUserRatinglogListHandler getUserRatinglogListHandler;
|
||||||
private final GetUserRecentRatingHandler getUserRecentRatingHandler;
|
private final GetUserRecentRatingHandler getUserRecentRatingHandler;
|
||||||
|
@ -48,125 +31,26 @@ public class OngekiController {
|
||||||
private final GetUserSkinHandler getUserSkinHandler;
|
private final GetUserSkinHandler getUserSkinHandler;
|
||||||
private final GetUserStoryHandler getUserStoryHandler;
|
private final GetUserStoryHandler getUserStoryHandler;
|
||||||
private final GetUserTechCountHandler getUserTechCountHandler;
|
private final GetUserTechCountHandler getUserTechCountHandler;
|
||||||
private final GetUserTechEventHandler getUserTechEventHandler;
|
|
||||||
private final GetUserTechEventRankingHandler getUserTechEventRankingHandler;
|
|
||||||
private final GetUserTradeItemHandler getUserTradeItemHandler;
|
private final GetUserTradeItemHandler getUserTradeItemHandler;
|
||||||
private final GetUserTrainingRoomByKeyHandler getUserTrainingRoomByKeyHandler;
|
private final GetUserTrainingRoomByKeyHandler getUserTrainingRoomByKeyHandler;
|
||||||
private final GetUserKopHandler getUserKopHandler;
|
private final GetUserKopHandler getUserKopHandler;
|
||||||
private final UpsertUserAllHandler upsertUserAllHandler;
|
private final UpsertUserAllHandler upsertUserAllHandler;
|
||||||
private final GetClientBookkeepingHandler getClientBookkeepingHandler;
|
|
||||||
private final GetClientTestmodeHandler getClientTestmodeHandler;
|
|
||||||
|
|
||||||
@PostMapping("GetUserTechEventApi")
|
|
||||||
public String getUserTechEvent(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getUserTechEventHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetUserTechEventRankingApi")
|
|
||||||
public String getUserTechEventRanking(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getUserTechEventRankingHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetUserActivityApi")
|
|
||||||
public String getUserActivity(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getUserActivityHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetUserBossApi")
|
|
||||||
public String getUserBoss(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getUserBossHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetUserBpBaseApi")
|
|
||||||
public String getUserBpBase(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getUserBpBaseHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetUserCardApi")
|
|
||||||
public String getUserCard(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getUserCardHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetUserChapterApi")
|
|
||||||
public String getUserChapter(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getUserChapterHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetUserMemoryChapterApi")
|
|
||||||
public String getUserMemoryChapter(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getUserMemoryChapterHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetUserCharacterApi")
|
|
||||||
public String getUserCharacter(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getUserCharacterHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetUserDataApi")
|
|
||||||
public String getUserData(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getUserDataHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetUserDeckByKeyApi")
|
|
||||||
public String getUserDeckByKey(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getUserDeckByKeyHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetUserEventMapApi")
|
|
||||||
public String getUserEventMap(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getUserEventMapHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetUserEventPointApi")
|
|
||||||
public String getUserEventPoint(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getUserEventPointHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetUserEventMusicApi")
|
|
||||||
public String getUserEventMusic(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getUserEventMusicHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetUserTradeItemApi")
|
@PostMapping("GetUserTradeItemApi")
|
||||||
public String getUserTradeItem(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
public String getUserTradeItem(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
||||||
return getUserTradeItemHandler.handle(request);
|
return getUserTradeItemHandler.handle(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("GetUserEventRankingApi")
|
|
||||||
public String getUserEventRanking(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getUserEventRankingHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetUserItemApi")
|
@PostMapping("GetUserItemApi")
|
||||||
public String getUserItem(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
public String getUserItem(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
||||||
return getUserItemHandler.handle(request);
|
return getUserItemHandler.handle(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("GetUserLoginBonusApi")
|
|
||||||
public String getUserLoginBonus(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getUserLoginBonusHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetUserMissionPointApi")
|
|
||||||
public String getUserMissionPoint(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getUserMissionPointHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetUserMusicApi")
|
@PostMapping("GetUserMusicApi")
|
||||||
public String getUserMusic(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
public String getUserMusic(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
||||||
return getUserMusicHandler.handle(request);
|
return getUserMusicHandler.handle(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("GetUserMusicItemApi")
|
|
||||||
public String getUserMusicItem(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getUserMusicItemHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetUserOptionApi")
|
|
||||||
public String getUserOption(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getUserOptionHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetUserPreviewApi")
|
@PostMapping("GetUserPreviewApi")
|
||||||
public String getUserPreview(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
public String getUserPreview(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
||||||
return getUserPreviewHandler.handle(request);
|
return getUserPreviewHandler.handle(request);
|
||||||
|
@ -232,16 +116,6 @@ public class OngekiController {
|
||||||
return getUserKopHandler.handle(request);
|
return getUserKopHandler.handle(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("GetClientBookkeepingApi")
|
|
||||||
public String getClientBookkeeping(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getClientBookkeepingHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetClientTestmodeApi")
|
|
||||||
public String getClientTestmode(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getClientTestmodeHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("UpsertUserAllApi")
|
@PostMapping("UpsertUserAllApi")
|
||||||
public String upsertUserAll(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
public String upsertUserAll(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
||||||
return upsertUserAllHandler.handle(request);
|
return upsertUserAllHandler.handle(request);
|
||||||
|
|
|
@ -1,46 +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.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author samnyan (privateamusement@protonmail.com)
|
|
||||||
*/
|
|
||||||
@Component("OngekiGetClientBookkeepingHandler")
|
|
||||||
public class GetClientBookkeepingHandler implements BaseHandler {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(GetClientBookkeepingHandler.class);
|
|
||||||
|
|
||||||
private final BasicMapper mapper;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public GetClientBookkeepingHandler(BasicMapper mapper, OgkUserKopRepo userKopRepository) {
|
|
||||||
this.mapper = mapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String handle(Map<String, ?> request) throws JsonProcessingException {
|
|
||||||
long placeId = ((Number) request.get("placeId")).longValue();
|
|
||||||
|
|
||||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
|
||||||
resultMap.put("placeId", placeId);
|
|
||||||
resultMap.put("length", 0);
|
|
||||||
resultMap.put("clientBookkeepingList", List.of());
|
|
||||||
|
|
||||||
String json = mapper.write(resultMap);
|
|
||||||
|
|
||||||
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.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.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author samnyan (privateamusement@protonmail.com)
|
|
||||||
*/
|
|
||||||
@Component("OngekiGetClientTestmodeHandler")
|
|
||||||
public class GetClientTestmodeHandler implements BaseHandler {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(GetClientTestmodeHandler.class);
|
|
||||||
|
|
||||||
private final BasicMapper mapper;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public GetClientTestmodeHandler(BasicMapper mapper, OgkUserKopRepo userKopRepository) {
|
|
||||||
this.mapper = mapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String handle(Map<String, ?> request) throws JsonProcessingException {
|
|
||||||
long placeId = ((Number) request.get("placeId")).longValue();
|
|
||||||
|
|
||||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
|
||||||
resultMap.put("placeId", placeId);
|
|
||||||
resultMap.put("length", 0);
|
|
||||||
resultMap.put("clientTestmodeList", List.of());
|
|
||||||
|
|
||||||
String json = mapper.write(resultMap);
|
|
||||||
|
|
||||||
logger.info("Response: " + json);
|
|
||||||
return json;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,64 +0,0 @@
|
||||||
package icu.samnyan.aqua.sega.ongeki.handler.impl;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
import icu.samnyan.aqua.sega.ongeki.OgkUserActivityRepo;
|
|
||||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
|
||||||
import icu.samnyan.aqua.sega.ongeki.model.UserActivity;
|
|
||||||
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("OngekiGetUserActivityHandler")
|
|
||||||
public class GetUserActivityHandler implements BaseHandler {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(GetUserActivityHandler.class);
|
|
||||||
|
|
||||||
private final BasicMapper mapper;
|
|
||||||
|
|
||||||
private final OgkUserActivityRepo userActivityRepository;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public GetUserActivityHandler(BasicMapper mapper, OgkUserActivityRepo userActivityRepository) {
|
|
||||||
this.mapper = mapper;
|
|
||||||
this.userActivityRepository = userActivityRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String handle(Map<String, ?> request) throws JsonProcessingException {
|
|
||||||
long userId = ((Number) request.get("userId")).longValue();
|
|
||||||
Integer kind = (Integer) request.get("kind");
|
|
||||||
|
|
||||||
List<UserActivity> activityList = userActivityRepository.findByUser_Card_ExtIdAndKindOrderBySortNumberDesc(userId,kind);
|
|
||||||
|
|
||||||
// Game crash workaround. Ported from minime @ Felix, commit 7efa1d7fd8d6b31cfba5f1755bf7bf3b9bc7aeb0
|
|
||||||
if (kind == 1) {
|
|
||||||
// PlayActivity: 15
|
|
||||||
activityList = new ArrayList<>(activityList.subList(0, activityList.size() < 15 ? activityList.size() : 15));
|
|
||||||
} else if (kind == 2) {
|
|
||||||
// Music: 10
|
|
||||||
activityList = new ArrayList<>(activityList.subList(0, activityList.size() < 10 ? activityList.size() : 10));
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
|
||||||
resultMap.put("userId", userId);
|
|
||||||
resultMap.put("length", activityList.size());
|
|
||||||
resultMap.put("kind", kind);
|
|
||||||
resultMap.put("userActivityList", activityList);
|
|
||||||
|
|
||||||
String json = mapper.write(resultMap);
|
|
||||||
|
|
||||||
logger.info("Response: " + json);
|
|
||||||
return json;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,52 +0,0 @@
|
||||||
package icu.samnyan.aqua.sega.ongeki.handler.impl;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
import icu.samnyan.aqua.sega.ongeki.OgkUserBossRepo;
|
|
||||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
|
||||||
import icu.samnyan.aqua.sega.ongeki.model.UserBoss;
|
|
||||||
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("OngekiGetUserBossHandler")
|
|
||||||
public class GetUserBossHandler implements BaseHandler {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(GetUserBossHandler.class);
|
|
||||||
|
|
||||||
private final BasicMapper mapper;
|
|
||||||
|
|
||||||
private final OgkUserBossRepo userBossRepository;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public GetUserBossHandler(BasicMapper mapper, OgkUserBossRepo userBossRepository) {
|
|
||||||
this.mapper = mapper;
|
|
||||||
this.userBossRepository = userBossRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String handle(Map<String, ?> request) throws JsonProcessingException {
|
|
||||||
long userId = ((Number) request.get("userId")).longValue();
|
|
||||||
|
|
||||||
List<UserBoss> userBossList = userBossRepository.findByUser_Card_ExtId(userId);
|
|
||||||
|
|
||||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
|
||||||
resultMap.put("userId", userId);
|
|
||||||
resultMap.put("length", userBossList.size());
|
|
||||||
resultMap.put("userBossList", userBossList);
|
|
||||||
|
|
||||||
String json = mapper.write(resultMap);
|
|
||||||
|
|
||||||
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.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The game doesn't use this request. It will calculate from the music detail request.
|
|
||||||
* @author samnyan (privateamusement@protonmail.com)
|
|
||||||
*/
|
|
||||||
@Component("OngekiGetUserBpBaseHandler")
|
|
||||||
public class GetUserBpBaseHandler implements BaseHandler {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(GetUserBpBaseHandler.class);
|
|
||||||
|
|
||||||
private final BasicMapper mapper;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public GetUserBpBaseHandler(BasicMapper mapper) {
|
|
||||||
this.mapper = mapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String handle(Map<String, ?> request) throws JsonProcessingException {
|
|
||||||
long userId = ((Number) request.get("userId")).longValue();
|
|
||||||
|
|
||||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
|
||||||
resultMap.put("userId", userId);
|
|
||||||
resultMap.put("length", 0);
|
|
||||||
resultMap.put("userBpBaseList", new List[]{});
|
|
||||||
|
|
||||||
String json = mapper.write(resultMap);
|
|
||||||
|
|
||||||
logger.info("Response: " + json);
|
|
||||||
return json;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,60 +0,0 @@
|
||||||
package icu.samnyan.aqua.sega.ongeki.handler.impl;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
import icu.samnyan.aqua.sega.ongeki.OgkUserCardRepo;
|
|
||||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
|
||||||
import icu.samnyan.aqua.sega.ongeki.model.UserCard;
|
|
||||||
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.data.domain.Page;
|
|
||||||
import org.springframework.data.domain.PageRequest;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author samnyan (privateamusement@protonmail.com)
|
|
||||||
*/
|
|
||||||
@Component("OngekiGetUserCardHandler")
|
|
||||||
public class GetUserCardHandler implements BaseHandler {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(GetUserCardHandler.class);
|
|
||||||
|
|
||||||
private final BasicMapper mapper;
|
|
||||||
|
|
||||||
private final OgkUserCardRepo userCardRepository;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public GetUserCardHandler(BasicMapper mapper, OgkUserCardRepo userCardRepository) {
|
|
||||||
this.mapper = mapper;
|
|
||||||
this.userCardRepository = userCardRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String handle(Map<String, ?> request) throws JsonProcessingException {
|
|
||||||
long userId = ((Number) request.get("userId")).longValue();
|
|
||||||
Integer maxCount = (Integer) request.get("maxCount");
|
|
||||||
Integer nextIndex = (Integer) request.get("nextIndex");
|
|
||||||
|
|
||||||
int pageNum = nextIndex / maxCount;
|
|
||||||
|
|
||||||
Page<UserCard> dbPage = userCardRepository.findByUser_Card_ExtId(userId, PageRequest.of(pageNum, maxCount));
|
|
||||||
|
|
||||||
long currentIndex = maxCount * pageNum + dbPage.getNumberOfElements();
|
|
||||||
|
|
||||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
|
||||||
resultMap.put("userId", userId);
|
|
||||||
resultMap.put("length", dbPage.getNumberOfElements());
|
|
||||||
resultMap.put("nextIndex", dbPage.getNumberOfElements() < maxCount ? -1 : currentIndex);
|
|
||||||
resultMap.put("userCardList", dbPage.getContent());
|
|
||||||
|
|
||||||
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.OgkUserChapterRepo;
|
|
||||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
|
||||||
import icu.samnyan.aqua.sega.ongeki.model.UserChapter;
|
|
||||||
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("OngekiGetUserChapterHandler")
|
|
||||||
public class GetUserChapterHandler implements BaseHandler {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(GetUserChapterHandler.class);
|
|
||||||
|
|
||||||
private final BasicMapper mapper;
|
|
||||||
|
|
||||||
private final OgkUserChapterRepo userChapterRepository;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public GetUserChapterHandler(BasicMapper mapper, OgkUserChapterRepo userChapterRepository) {
|
|
||||||
this.mapper = mapper;
|
|
||||||
this.userChapterRepository = userChapterRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String handle(Map<String, ?> request) throws JsonProcessingException {
|
|
||||||
long userId = ((Number) request.get("userId")).longValue();
|
|
||||||
|
|
||||||
List<UserChapter> chapterList = userChapterRepository.findByUser_Card_ExtId(userId);
|
|
||||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
|
||||||
resultMap.put("userId", userId);
|
|
||||||
resultMap.put("length", chapterList.size());
|
|
||||||
resultMap.put("userChapterList", chapterList);
|
|
||||||
|
|
||||||
String json = mapper.write(resultMap);
|
|
||||||
|
|
||||||
logger.info("Response: " + json);
|
|
||||||
return json;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,60 +0,0 @@
|
||||||
package icu.samnyan.aqua.sega.ongeki.handler.impl;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
import icu.samnyan.aqua.sega.ongeki.OgkUserCharacterRepo;
|
|
||||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
|
||||||
import icu.samnyan.aqua.sega.ongeki.model.UserCharacter;
|
|
||||||
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.data.domain.Page;
|
|
||||||
import org.springframework.data.domain.PageRequest;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author samnyan (privateamusement@protonmail.com)
|
|
||||||
*/
|
|
||||||
@Component("OngekiGetUserCharacterHandler")
|
|
||||||
public class GetUserCharacterHandler implements BaseHandler {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(GetUserCharacterHandler.class);
|
|
||||||
|
|
||||||
private final BasicMapper mapper;
|
|
||||||
|
|
||||||
private final OgkUserCharacterRepo userCharacterRepository;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public GetUserCharacterHandler(BasicMapper mapper, OgkUserCharacterRepo userCharacterRepository) {
|
|
||||||
this.mapper = mapper;
|
|
||||||
this.userCharacterRepository = userCharacterRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String handle(Map<String, ?> request) throws JsonProcessingException {
|
|
||||||
long userId = ((Number) request.get("userId")).longValue();
|
|
||||||
Integer maxCount = (Integer) request.get("maxCount");
|
|
||||||
Integer nextIndex = (Integer) request.get("nextIndex");
|
|
||||||
|
|
||||||
int pageNum = nextIndex / maxCount;
|
|
||||||
|
|
||||||
Page<UserCharacter> dbPage = userCharacterRepository.findByUser_Card_ExtId(userId, PageRequest.of(pageNum, maxCount));
|
|
||||||
|
|
||||||
long currentIndex = maxCount * pageNum + dbPage.getNumberOfElements();
|
|
||||||
|
|
||||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
|
||||||
resultMap.put("userId", userId);
|
|
||||||
resultMap.put("length", dbPage.getNumberOfElements());
|
|
||||||
resultMap.put("nextIndex", dbPage.getNumberOfElements() < maxCount ? -1 : currentIndex);
|
|
||||||
resultMap.put("userCharacterList", dbPage.getContent());
|
|
||||||
|
|
||||||
String json = mapper.write(resultMap);
|
|
||||||
|
|
||||||
logger.info("Response: " + json);
|
|
||||||
return json;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,55 +0,0 @@
|
||||||
package icu.samnyan.aqua.sega.ongeki.handler.impl;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
import icu.samnyan.aqua.sega.ongeki.OgkUserDataRepo;
|
|
||||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
|
||||||
import icu.samnyan.aqua.sega.ongeki.model.UserData;
|
|
||||||
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;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author samnyan (privateamusement@protonmail.com)
|
|
||||||
*/
|
|
||||||
@Component("OngekiGetUserDataHandler")
|
|
||||||
public class GetUserDataHandler implements BaseHandler {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(GetUserDataHandler.class);
|
|
||||||
|
|
||||||
private final BasicMapper mapper;
|
|
||||||
|
|
||||||
private final OgkUserDataRepo userDataRepository;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public GetUserDataHandler(BasicMapper mapper, OgkUserDataRepo userDataRepository) {
|
|
||||||
this.mapper = mapper;
|
|
||||||
this.userDataRepository = userDataRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String handle(Map<String, ?> request) throws JsonProcessingException {
|
|
||||||
long userId = ((Number) request.get("userId")).longValue();
|
|
||||||
|
|
||||||
Optional<UserData> userDataOptional = userDataRepository.findByCard_ExtId(userId);
|
|
||||||
|
|
||||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
|
||||||
resultMap.put("userId", userId);
|
|
||||||
if(userDataOptional.isPresent()) {
|
|
||||||
resultMap.put("userData", userDataOptional.get());
|
|
||||||
} else {
|
|
||||||
resultMap.put("userData",null);
|
|
||||||
}
|
|
||||||
|
|
||||||
String json = mapper.write(resultMap);
|
|
||||||
|
|
||||||
logger.info("Response: " + json);
|
|
||||||
return json;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,52 +0,0 @@
|
||||||
package icu.samnyan.aqua.sega.ongeki.handler.impl;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
import icu.samnyan.aqua.sega.ongeki.OgkUserDeckRepo;
|
|
||||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
|
||||||
import icu.samnyan.aqua.sega.ongeki.model.UserDeck;
|
|
||||||
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("OngekiGetUserDeckByKeyHandler")
|
|
||||||
public class GetUserDeckByKeyHandler implements BaseHandler {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(GetUserDeckByKeyHandler.class);
|
|
||||||
|
|
||||||
private final BasicMapper mapper;
|
|
||||||
|
|
||||||
private final OgkUserDeckRepo userDeckRepository;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public GetUserDeckByKeyHandler(BasicMapper mapper, OgkUserDeckRepo userDeckRepository) {
|
|
||||||
this.mapper = mapper;
|
|
||||||
this.userDeckRepository = userDeckRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String handle(Map<String, ?> request) throws JsonProcessingException {
|
|
||||||
long userId = ((Number) request.get("userId")).longValue();
|
|
||||||
|
|
||||||
List<UserDeck> deckList = userDeckRepository.findByUser_Card_ExtId(userId);
|
|
||||||
|
|
||||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
|
||||||
resultMap.put("userId", userId);
|
|
||||||
resultMap.put("length", deckList.size());
|
|
||||||
resultMap.put("userDeckList", deckList);
|
|
||||||
|
|
||||||
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.general.BaseHandler;
|
|
||||||
import icu.samnyan.aqua.sega.ongeki.OgkUserEventMapRepo;
|
|
||||||
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("OngekiGetUserEventMapHandler")
|
|
||||||
public class GetUserEventMapHandler implements BaseHandler {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(GetUserEventMapHandler.class);
|
|
||||||
|
|
||||||
private final BasicMapper mapper;
|
|
||||||
|
|
||||||
private final OgkUserEventMapRepo userEventMapRepository;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public GetUserEventMapHandler(BasicMapper mapper, OgkUserEventMapRepo userEventMapRepository) {
|
|
||||||
this.mapper = mapper;
|
|
||||||
this.userEventMapRepository = userEventMapRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String handle(Map<String, ?> request) throws JsonProcessingException {
|
|
||||||
long userId = ((Number) request.get("userId")).longValue();
|
|
||||||
var eventMapOptional = userEventMapRepository.findByUser_Card_ExtId(userId);
|
|
||||||
|
|
||||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
|
||||||
resultMap.put("userId", userId);
|
|
||||||
if(eventMapOptional.isPresent()) {
|
|
||||||
resultMap.put("userEventMap", eventMapOptional.get());
|
|
||||||
} else {
|
|
||||||
resultMap.put("userEventMap", null);
|
|
||||||
}
|
|
||||||
|
|
||||||
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.OgkUserEventMusicRepo;
|
|
||||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
|
||||||
import icu.samnyan.aqua.sega.ongeki.model.UserEventMusic;
|
|
||||||
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("OngekiGetUserEventMusicHandler")
|
|
||||||
public class GetUserEventMusicHandler implements BaseHandler {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(GetUserEventMusicHandler.class);
|
|
||||||
|
|
||||||
private final BasicMapper mapper;
|
|
||||||
|
|
||||||
private final OgkUserEventMusicRepo userEventMusicRepository;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public GetUserEventMusicHandler(BasicMapper mapper, OgkUserEventMusicRepo userEventMusicRepository) {
|
|
||||||
this.mapper = mapper;
|
|
||||||
this.userEventMusicRepository = userEventMusicRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String handle(Map<String, ?> request) throws JsonProcessingException {
|
|
||||||
long userId = ((Number) request.get("userId")).longValue();
|
|
||||||
List<UserEventMusic> eventMusicList = userEventMusicRepository.findByUser_Card_ExtId(userId);
|
|
||||||
|
|
||||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
|
||||||
resultMap.put("userId", userId);
|
|
||||||
resultMap.put("length", eventMusicList.size());
|
|
||||||
resultMap.put("userEventMusicList", eventMusicList);
|
|
||||||
|
|
||||||
String json = mapper.write(resultMap);
|
|
||||||
|
|
||||||
logger.info("Response: " + json);
|
|
||||||
return json;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,52 +0,0 @@
|
||||||
package icu.samnyan.aqua.sega.ongeki.handler.impl;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
import icu.samnyan.aqua.sega.ongeki.OgkUserEventPointRepo;
|
|
||||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
|
||||||
import icu.samnyan.aqua.sega.ongeki.model.UserEventPoint;
|
|
||||||
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("OngekiGetUserEventPointHandler")
|
|
||||||
public class GetUserEventPointHandler implements BaseHandler {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(GetUserEventPointHandler.class);
|
|
||||||
|
|
||||||
private final BasicMapper mapper;
|
|
||||||
|
|
||||||
private final OgkUserEventPointRepo userEventPointRepository;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public GetUserEventPointHandler(BasicMapper mapper, OgkUserEventPointRepo userEventPointRepository) {
|
|
||||||
this.mapper = mapper;
|
|
||||||
this.userEventPointRepository = userEventPointRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String handle(Map<String, ?> request) throws JsonProcessingException {
|
|
||||||
long userId = ((Number) request.get("userId")).longValue();
|
|
||||||
|
|
||||||
List<UserEventPoint> eventPointList = userEventPointRepository.findByUser_Card_ExtId(userId);
|
|
||||||
|
|
||||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
|
||||||
resultMap.put("userId", userId);
|
|
||||||
resultMap.put("length", eventPointList.size());
|
|
||||||
resultMap.put("userEventPointList", eventPointList);
|
|
||||||
|
|
||||||
String json = mapper.write(resultMap);
|
|
||||||
|
|
||||||
logger.info("Response: " + json);
|
|
||||||
return json;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,65 +0,0 @@
|
||||||
package icu.samnyan.aqua.sega.ongeki.handler.impl;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
import icu.samnyan.aqua.sega.ongeki.OgkUserEventPointRepo;
|
|
||||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
|
||||||
import icu.samnyan.aqua.sega.ongeki.model.UserEventRankingItem;
|
|
||||||
import icu.samnyan.aqua.sega.ongeki.model.UserEventPoint;
|
|
||||||
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.time.LocalDateTime;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author samnyan (privateamusement@protonmail.com)
|
|
||||||
*/
|
|
||||||
@Component("OngekiGetUserEventRankingHandler")
|
|
||||||
public class GetUserEventRankingHandler implements BaseHandler {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(GetUserEventRankingHandler.class);
|
|
||||||
|
|
||||||
private final BasicMapper mapper;
|
|
||||||
|
|
||||||
private final OgkUserEventPointRepo userEventPointRepository;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public GetUserEventRankingHandler(BasicMapper mapper, OgkUserEventPointRepo userEventPointRepository) {
|
|
||||||
this.mapper = mapper;
|
|
||||||
this.userEventPointRepository = userEventPointRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String handle(Map<String, ?> request) throws JsonProcessingException {
|
|
||||||
long userId = ((Number) request.get("userId")).longValue();
|
|
||||||
String time = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.0"));
|
|
||||||
|
|
||||||
List<UserEventPoint> eventPointList = userEventPointRepository.findByUser_Card_ExtId(userId);
|
|
||||||
List<UserEventRankingItem> rankingItemList = new LinkedList<>();
|
|
||||||
eventPointList.forEach(x -> rankingItemList.add(new UserEventRankingItem(
|
|
||||||
x.getEventId(),
|
|
||||||
1, // Type 1 is latest ranking
|
|
||||||
time,
|
|
||||||
userEventPointRepository.calculateRankByUserAndEventId(x.getUser().getId(), x.getEventId()),
|
|
||||||
x.getPoint()
|
|
||||||
)));
|
|
||||||
|
|
||||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
|
||||||
resultMap.put("userId", userId);
|
|
||||||
resultMap.put("length", rankingItemList.size());
|
|
||||||
resultMap.put("userEventRankingList", rankingItemList);
|
|
||||||
|
|
||||||
String json = mapper.write(resultMap);
|
|
||||||
|
|
||||||
logger.info("Response: " + json);
|
|
||||||
return json;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,52 +0,0 @@
|
||||||
package icu.samnyan.aqua.sega.ongeki.handler.impl;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
import icu.samnyan.aqua.sega.ongeki.OgkUserLoginBonusRepo;
|
|
||||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
|
||||||
import icu.samnyan.aqua.sega.ongeki.model.UserLoginBonus;
|
|
||||||
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("OngekiGetUserLoginBonusHandler")
|
|
||||||
public class GetUserLoginBonusHandler implements BaseHandler {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(GetUserLoginBonusHandler.class);
|
|
||||||
|
|
||||||
private final BasicMapper mapper;
|
|
||||||
|
|
||||||
private final OgkUserLoginBonusRepo userLoginBonusRepository;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public GetUserLoginBonusHandler(BasicMapper mapper, OgkUserLoginBonusRepo userLoginBonusRepository) {
|
|
||||||
this.mapper = mapper;
|
|
||||||
this.userLoginBonusRepository = userLoginBonusRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String handle(Map<String, ?> request) throws JsonProcessingException {
|
|
||||||
long userId = ((Number) request.get("userId")).longValue();
|
|
||||||
|
|
||||||
List<UserLoginBonus> loginBonusList = userLoginBonusRepository.findByUser_Card_ExtId(userId);
|
|
||||||
|
|
||||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
|
||||||
resultMap.put("userId", userId);
|
|
||||||
resultMap.put("length", loginBonusList.size());
|
|
||||||
resultMap.put("userLoginBonusList", loginBonusList);
|
|
||||||
|
|
||||||
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.OgkUserMemoryChapterRepo;
|
|
||||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
|
||||||
import icu.samnyan.aqua.sega.ongeki.model.UserMemoryChapter;
|
|
||||||
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("OngekiGetUserMemoryChapterHandler")
|
|
||||||
public class GetUserMemoryChapterHandler implements BaseHandler {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(GetUserMemoryChapterHandler.class);
|
|
||||||
|
|
||||||
private final BasicMapper mapper;
|
|
||||||
|
|
||||||
private final OgkUserMemoryChapterRepo userMemoryChapterRepository;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public GetUserMemoryChapterHandler(BasicMapper mapper, OgkUserMemoryChapterRepo userMemoryChapterRepository) {
|
|
||||||
this.mapper = mapper;
|
|
||||||
this.userMemoryChapterRepository = userMemoryChapterRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String handle(Map<String, ?> request) throws JsonProcessingException {
|
|
||||||
long userId = ((Number) request.get("userId")).longValue();
|
|
||||||
|
|
||||||
List<UserMemoryChapter> MemoryChapterList = userMemoryChapterRepository.findByUser_Card_ExtId(userId);
|
|
||||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
|
||||||
resultMap.put("userId", userId);
|
|
||||||
resultMap.put("length", MemoryChapterList.size());
|
|
||||||
resultMap.put("userMemoryChapterList", MemoryChapterList);
|
|
||||||
|
|
||||||
String json = mapper.write(resultMap);
|
|
||||||
|
|
||||||
logger.info("Response: " + json);
|
|
||||||
return json;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,52 +0,0 @@
|
||||||
package icu.samnyan.aqua.sega.ongeki.handler.impl;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
import icu.samnyan.aqua.sega.ongeki.OgkUserMissionPointRepo;
|
|
||||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
|
||||||
import icu.samnyan.aqua.sega.ongeki.model.UserMissionPoint;
|
|
||||||
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("OngekiGetUserMissionPointHandler")
|
|
||||||
public class GetUserMissionPointHandler implements BaseHandler {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(GetUserMissionPointHandler.class);
|
|
||||||
|
|
||||||
private final BasicMapper mapper;
|
|
||||||
|
|
||||||
private final OgkUserMissionPointRepo userMissionPointRepository;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public GetUserMissionPointHandler(BasicMapper mapper, OgkUserMissionPointRepo userMissionPointRepository) {
|
|
||||||
this.mapper = mapper;
|
|
||||||
this.userMissionPointRepository = userMissionPointRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String handle(Map<String, ?> request) throws JsonProcessingException {
|
|
||||||
long userId = ((Number) request.get("userId")).longValue();
|
|
||||||
|
|
||||||
List<UserMissionPoint> missionPointList = userMissionPointRepository.findByUser_Card_ExtId(userId);
|
|
||||||
|
|
||||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
|
||||||
resultMap.put("userId", userId);
|
|
||||||
resultMap.put("length", missionPointList.size());
|
|
||||||
resultMap.put("userMissionPointList", missionPointList);
|
|
||||||
|
|
||||||
String json = mapper.write(resultMap);
|
|
||||||
|
|
||||||
logger.info("Response: " + json);
|
|
||||||
return json;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,60 +0,0 @@
|
||||||
package icu.samnyan.aqua.sega.ongeki.handler.impl;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
import icu.samnyan.aqua.sega.ongeki.OgkUserMusicItemRepo;
|
|
||||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
|
||||||
import icu.samnyan.aqua.sega.ongeki.model.UserMusicItem;
|
|
||||||
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.data.domain.Page;
|
|
||||||
import org.springframework.data.domain.PageRequest;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author samnyan (privateamusement@protonmail.com)
|
|
||||||
*/
|
|
||||||
@Component("OngekiGetUserMusicItemHandler")
|
|
||||||
public class GetUserMusicItemHandler implements BaseHandler {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(GetUserMusicItemHandler.class);
|
|
||||||
|
|
||||||
private final BasicMapper mapper;
|
|
||||||
|
|
||||||
private final OgkUserMusicItemRepo userMusicItemRepository;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public GetUserMusicItemHandler(BasicMapper mapper, OgkUserMusicItemRepo userMusicItemRepository) {
|
|
||||||
this.mapper = mapper;
|
|
||||||
this.userMusicItemRepository = userMusicItemRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String handle(Map<String, ?> request) throws JsonProcessingException {
|
|
||||||
long userId = ((Number) request.get("userId")).longValue();
|
|
||||||
Integer maxCount = (Integer) request.get("maxCount");
|
|
||||||
Integer nextIndex = (Integer) request.get("nextIndex");
|
|
||||||
|
|
||||||
int pageNum = nextIndex / maxCount;
|
|
||||||
|
|
||||||
Page<UserMusicItem> dbPage = userMusicItemRepository.findByUser_Card_ExtId(userId, PageRequest.of(pageNum, maxCount));
|
|
||||||
|
|
||||||
long currentIndex = maxCount * pageNum + dbPage.getNumberOfElements();
|
|
||||||
|
|
||||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
|
||||||
resultMap.put("userId", userId);
|
|
||||||
resultMap.put("length", dbPage.getNumberOfElements());
|
|
||||||
resultMap.put("nextIndex", dbPage.getNumberOfElements() < maxCount ? -1 : currentIndex);
|
|
||||||
resultMap.put("userMusicItemList", dbPage.getContent());
|
|
||||||
|
|
||||||
String json = mapper.write(resultMap);
|
|
||||||
|
|
||||||
logger.info("Response: " + json);
|
|
||||||
return json;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,56 +0,0 @@
|
||||||
package icu.samnyan.aqua.sega.ongeki.handler.impl;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
import icu.samnyan.aqua.sega.ongeki.OgkUserOptionRepo;
|
|
||||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
|
||||||
import icu.samnyan.aqua.sega.ongeki.model.UserOption;
|
|
||||||
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;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author samnyan (privateamusement@protonmail.com)
|
|
||||||
*/
|
|
||||||
@Component("OngekiGetUserOptionHandler")
|
|
||||||
public class GetUserOptionHandler implements BaseHandler {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(GetUserOptionHandler.class);
|
|
||||||
|
|
||||||
private final BasicMapper mapper;
|
|
||||||
|
|
||||||
private final OgkUserOptionRepo userOptionRepository;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public GetUserOptionHandler(BasicMapper mapper, OgkUserOptionRepo userOptionRepository) {
|
|
||||||
this.mapper = mapper;
|
|
||||||
this.userOptionRepository = userOptionRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String handle(Map<String, ?> request) throws JsonProcessingException {
|
|
||||||
long userId = ((Number) request.get("userId")).longValue();
|
|
||||||
|
|
||||||
Optional<UserOption> userOptionOptional = userOptionRepository.findSingleByUser_Card_ExtId(userId);
|
|
||||||
|
|
||||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
|
||||||
resultMap.put("userId", userId);
|
|
||||||
if(userOptionOptional.isPresent()) {
|
|
||||||
resultMap.put("userOption", userOptionOptional.get());
|
|
||||||
} else {
|
|
||||||
resultMap.put("userOption", null);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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.OgkUserTechEventRepo;
|
|
||||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
|
||||||
import icu.samnyan.aqua.sega.ongeki.model.UserTechEvent;
|
|
||||||
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("OngekiGetUserTechEventHandler")
|
|
||||||
public class GetUserTechEventHandler implements BaseHandler {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(GetUserTechEventHandler.class);
|
|
||||||
|
|
||||||
private final BasicMapper mapper;
|
|
||||||
|
|
||||||
private final OgkUserTechEventRepo userTechEventRepository;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public GetUserTechEventHandler(BasicMapper mapper, OgkUserTechEventRepo userTechEventRepository) {
|
|
||||||
this.mapper = mapper;
|
|
||||||
this.userTechEventRepository = userTechEventRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String handle(Map<String, ?> request) throws JsonProcessingException {
|
|
||||||
long userId = ((Number) request.get("userId")).longValue();
|
|
||||||
List<UserTechEvent> techEventList = userTechEventRepository.findByUser_Card_ExtId(userId);
|
|
||||||
|
|
||||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
|
||||||
resultMap.put("userId", userId);
|
|
||||||
resultMap.put("length", techEventList.size());
|
|
||||||
resultMap.put("userTechEventList", techEventList);
|
|
||||||
|
|
||||||
String json = mapper.write(resultMap);
|
|
||||||
|
|
||||||
logger.info("Response: " + json);
|
|
||||||
return json;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,66 +0,0 @@
|
||||||
package icu.samnyan.aqua.sega.ongeki.handler.impl;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
|
|
||||||
import icu.samnyan.aqua.sega.ongeki.OgkUserTechEventRepo;
|
|
||||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
|
||||||
import icu.samnyan.aqua.sega.ongeki.model.UserTechEventRankingItem;
|
|
||||||
import icu.samnyan.aqua.sega.ongeki.model.UserTechEvent;
|
|
||||||
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.time.LocalDateTime;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author samnyan (privateamusement@protonmail.com)
|
|
||||||
*/
|
|
||||||
@Component("OngekiGetUserTechEventRankingHandler")
|
|
||||||
public class GetUserTechEventRankingHandler implements BaseHandler {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(GetUserTechEventRankingHandler.class);
|
|
||||||
|
|
||||||
private final BasicMapper mapper;
|
|
||||||
|
|
||||||
private final OgkUserTechEventRepo userTechEventRepository;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public GetUserTechEventRankingHandler(BasicMapper mapper, OgkUserTechEventRepo userTechEventRepository) {
|
|
||||||
this.mapper = mapper;
|
|
||||||
this.userTechEventRepository = userTechEventRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String handle(Map<String, ?> request) throws JsonProcessingException {
|
|
||||||
long userId = ((Number) request.get("userId")).longValue();
|
|
||||||
|
|
||||||
String time = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.0"));
|
|
||||||
|
|
||||||
List<UserTechEvent> techEventList = userTechEventRepository.findByUser_Card_ExtId(userId);
|
|
||||||
List<UserTechEventRankingItem> techEventRankingList = new ArrayList<>();
|
|
||||||
techEventList.forEach(x -> techEventRankingList.add(new UserTechEventRankingItem(
|
|
||||||
x.getEventId(),
|
|
||||||
time,
|
|
||||||
1,
|
|
||||||
x.getTotalTechScore(),
|
|
||||||
x.getTotalPlatinumScore()
|
|
||||||
)));
|
|
||||||
|
|
||||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
|
||||||
resultMap.put("userId", userId);
|
|
||||||
resultMap.put("length", techEventRankingList.size());
|
|
||||||
resultMap.put("userTechEventRankingList", techEventRankingList);
|
|
||||||
|
|
||||||
String json = mapper.write(resultMap);
|
|
||||||
|
|
||||||
logger.info("Response: " + json);
|
|
||||||
return json;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -64,14 +64,6 @@ class GameRankingItem(
|
||||||
var userName: String = "",
|
var userName: String = "",
|
||||||
)
|
)
|
||||||
|
|
||||||
class UserEventRankingItem(
|
|
||||||
var eventId: Int = 0,
|
|
||||||
var type: Int = 0,
|
|
||||||
var date: String = "",
|
|
||||||
var rank: Int = 0,
|
|
||||||
var point: Long = 0,
|
|
||||||
)
|
|
||||||
|
|
||||||
class UserMusicListItem(
|
class UserMusicListItem(
|
||||||
var length: Int = 0,
|
var length: Int = 0,
|
||||||
var userMusicDetailList: List<UserMusicDetail>? = null,
|
var userMusicDetailList: List<UserMusicDetail>? = null,
|
||||||
|
@ -86,11 +78,3 @@ class UserRivalMusic(
|
||||||
var userRivalMusicDetailList: List<UserMusicDetail>? = null,
|
var userRivalMusicDetailList: List<UserMusicDetail>? = null,
|
||||||
var length: Int = 0,
|
var length: Int = 0,
|
||||||
)
|
)
|
||||||
|
|
||||||
class UserTechEventRankingItem(
|
|
||||||
var eventId: Int = 0,
|
|
||||||
var date: String = "",
|
|
||||||
var rank: Int = 0,
|
|
||||||
var totalTechScore: Int = 0,
|
|
||||||
var totalPlatinumScore: Int = 0,
|
|
||||||
)
|
|
||||||
|
|
Loading…
Reference in New Issue