mirror of
https://github.com/MewoLab/AquaDX.git
synced 2026-02-13 00:47:27 +08:00
[O] Reduce loc
This commit is contained in:
@@ -29,13 +29,17 @@ typealias API = RequestMapping
|
|||||||
typealias Str = String
|
typealias Str = String
|
||||||
typealias Bool = Boolean
|
typealias Bool = Boolean
|
||||||
|
|
||||||
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
|
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY)
|
||||||
@Retention(AnnotationRetention.RUNTIME)
|
@Retention(AnnotationRetention.RUNTIME)
|
||||||
annotation class Doc(
|
annotation class Doc(
|
||||||
val desc: String,
|
val desc: String,
|
||||||
val ret: String = ""
|
val ret: String = ""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@Target(AnnotationTarget.VALUE_PARAMETER)
|
||||||
|
@Retention(AnnotationRetention.RUNTIME)
|
||||||
|
annotation class SettingField(val name: Str, val desc: Str)
|
||||||
|
|
||||||
// Make it easier to throw a ResponseStatusException
|
// Make it easier to throw a ResponseStatusException
|
||||||
operator fun HttpStatus.invoke(message: String? = null): Nothing = throw ApiException(value(), message ?: this.reasonPhrase)
|
operator fun HttpStatus.invoke(message: String? = null): Nothing = throw ApiException(value(), message ?: this.reasonPhrase)
|
||||||
operator fun Int.minus(message: String): Nothing {
|
operator fun Int.minus(message: String): Nothing {
|
||||||
|
|||||||
@@ -0,0 +1,104 @@
|
|||||||
|
package icu.samnyan.aqua.sega.maimai2
|
||||||
|
|
||||||
|
import ext.API
|
||||||
|
import icu.samnyan.aqua.sega.maimai2.handler.BaseHandler
|
||||||
|
import icu.samnyan.aqua.sega.maimai2.handler.impl.*
|
||||||
|
import lombok.AllArgsConstructor
|
||||||
|
import org.slf4j.LoggerFactory
|
||||||
|
import org.springframework.web.bind.annotation.*
|
||||||
|
import kotlin.reflect.full.declaredMemberProperties
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author samnyan (privateamusement@protonmail.com)
|
||||||
|
*/
|
||||||
|
@Suppress("unused")
|
||||||
|
@AllArgsConstructor
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(path = ["/g/mai2/Maimai2Servlet/", "/g/mai2/"])
|
||||||
|
class Maimai2ServletController(
|
||||||
|
val getGameSetting: GetGameSettingHandler,
|
||||||
|
val getGameEvent: GetGameEventHandler,
|
||||||
|
val getGameRanking: GetGameRankingHandler,
|
||||||
|
val getGameTournamentInfo: GetGameTournamentInfoHandler,
|
||||||
|
val getGameCharge: GetGameChargeHandler,
|
||||||
|
val getTransferFriend: GetTransferFriendHandler,
|
||||||
|
val getUserActivity: GetUserActivityHandler,
|
||||||
|
val userLogin: UserLoginHandler,
|
||||||
|
val userLogout: UserLogoutHandler,
|
||||||
|
val getUserData: GetUserDataHandler,
|
||||||
|
val upsertUserAll: UpsertUserAllHandler,
|
||||||
|
val getUserPreview: GetUserPreviewHandler,
|
||||||
|
val getUserCharacter: GetUserCharacterHandler,
|
||||||
|
val getUserOption: GetUserOptionHandler,
|
||||||
|
val getUserItem: GetUserItemHandler,
|
||||||
|
val getUserExtend: GetUserExtendHandler,
|
||||||
|
val getUserGhost: GetUserGhostHandler,
|
||||||
|
val getUserLoginBonus: GetUserLoginBonusHandler,
|
||||||
|
val getUserMap: GetUserMapHandler,
|
||||||
|
val getUserFavorite: GetUserFavoriteHandler,
|
||||||
|
val getUserCard: GetUserCardHandler,
|
||||||
|
val getUserMusic: GetUserMusicHandler,
|
||||||
|
val getUserRating: GetUserRatingHandler,
|
||||||
|
val getUserRegion: GetUserRegionHandler,
|
||||||
|
val getUserCharge: GetUserChargeHandler,
|
||||||
|
val getUserCourse: GetUserCourseHandler,
|
||||||
|
val uploadUserPhoto: UploadUserPhotoHandler,
|
||||||
|
val uploadUserPlaylog: UploadUserPlaylogHandler,
|
||||||
|
val getGameNgMusicId: GetGameNgMusicIdHandler,
|
||||||
|
val getUserFriendSeasonRanking: GetUserFriendSeasonRankingHandler,
|
||||||
|
val getUserPortrait: GetUserPortraitHandler,
|
||||||
|
val uploadUserPortrait: UploadUserPortraitHandler,
|
||||||
|
val cmGetUserPreview: CMGetUserPreviewHandler,
|
||||||
|
val cmGetSellingCard: CMGetSellingCardHandler,
|
||||||
|
val getUserCardPrintError: GetUserCardPrintErrorHandler,
|
||||||
|
val cmGetUserCharacter: CMGetUserCharacterHandler,
|
||||||
|
val upsertUserPrint: UpsertUserPrintHandler,
|
||||||
|
val getUserRecommendRateMusic: GetUserRecommendRateMusicHandler,
|
||||||
|
val getUserRecommendSelectMusic: GetUserRecommendSelectMusicHandler,
|
||||||
|
val getUserFavoriteItem: GetUserFavoriteItemHandler,
|
||||||
|
val getUserRivalData: GetUserRivalDataHandler,
|
||||||
|
val getUserRivalMusic: GetUserRivalMusicHandler,
|
||||||
|
) {
|
||||||
|
val logger = LoggerFactory.getLogger(Maimai2ServletController::class.java)
|
||||||
|
|
||||||
|
val createToken = BaseHandler { """{"Bearer":"AQUATOKEN"}""" }
|
||||||
|
val cmUpsertUserPrintLog = BaseHandler { """{"returnCode":1,"orderId":"0","serialId":"FAKECARDIMAG12345678"}""" }
|
||||||
|
|
||||||
|
val endpointList = listOf("GetGameEventApi", "GetGameRankingApi", "GetGameSettingApi", "GetGameTournamentInfoApi",
|
||||||
|
"GetTransferFriendApi", "GetUserActivityApi", "GetUserCardApi", "GetUserCharacterApi", "GetUserDataApi",
|
||||||
|
"GetUserExtendApi", "GetUserFavoriteApi", "GetUserGhostApi", "GetUserItemApi", "GetUserLoginBonusApi",
|
||||||
|
"GetUserMapApi", "GetUserMusicApi", "GetUserOptionApi", "GetUserPortraitApi", "GetUserPreviewApi",
|
||||||
|
"GetUserRatingApi", "GetUserRegionApi", "UploadUserPhotoApi", "UploadUserPlaylogApi", "UploadUserPortraitApi",
|
||||||
|
"UserLoginApi", "UserLogoutApi", "UpsertUserAllApi", "GetGameChargeApi", "GetUserChargeApi",
|
||||||
|
"GetUserCourseApi", "GetGameNgMusicIdApi", "GetUserFriendSeasonRankingApi", "CreateTokenApi",
|
||||||
|
"GetUserRecommendRateMusicApi", "GetUserRecommendSelectMusicApi", "CMGetSellingCardApi",
|
||||||
|
"CMGetUserCardApi", "CMGetUserCardPrintErrorApi", "CMGetUserCharacterApi", "CMGetUserDataApi", "CMGetUserItemApi",
|
||||||
|
"CMGetUserPreviewApi", "CMUpsertUserPrintApi",
|
||||||
|
"CMUpsertUserPrintlogApi", "GetUserFavoriteItemApi", "GetUserRivalDataApi", "GetUserRivalMusicApi")
|
||||||
|
|
||||||
|
val noopEndpoint = setOf("GetUserScoreRankingApi", "UpsertClientBookkeepingApi", "UpsertClientSettingApi",
|
||||||
|
"UpsertClientTestmodeApi", "UpsertClientUploadApi", "Ping", "RemoveTokenApi", "CMLoginApi", "CMLogoutApi",
|
||||||
|
"CMUpsertBuyCardApi")
|
||||||
|
|
||||||
|
val members = this::class.declaredMemberProperties
|
||||||
|
val handlers: Map<String, BaseHandler> = endpointList.associateWith { api ->
|
||||||
|
val name = api.replace("Api", "").lowercase()
|
||||||
|
(members.find { it.name.lowercase() == name } ?: members.find { it.name.lowercase() == name.replace("cm", "") })
|
||||||
|
?.let { it.call(this) as BaseHandler }
|
||||||
|
?: throw IllegalArgumentException("Mai2: No handler found for $api")
|
||||||
|
}
|
||||||
|
|
||||||
|
@API("/{api}")
|
||||||
|
fun handle(@PathVariable api: String, @RequestBody request: Map<String, Any>): Any {
|
||||||
|
logger.info("Mai2 $api : $request")
|
||||||
|
|
||||||
|
if (api in noopEndpoint) {
|
||||||
|
return """{"returnCode":1,"apiName":"com.sega.maimai2servlet.api.$api"}"""
|
||||||
|
}
|
||||||
|
|
||||||
|
return handlers[api]?.handle(request) ?: {
|
||||||
|
logger.warn("Mai2 $api not found")
|
||||||
|
"""{"returnCode":1,"apiName":"com.sega.maimai2servlet.api.$api"}"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,368 +0,0 @@
|
|||||||
package icu.samnyan.aqua.sega.maimai2.controller;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
|
|
||||||
import icu.samnyan.aqua.sega.maimai2.handler.impl.*;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author samnyan (privateamusement@protonmail.com)
|
|
||||||
*/
|
|
||||||
@AllArgsConstructor
|
|
||||||
@RestController
|
|
||||||
@RequestMapping({ "/g/mai2/Maimai2Servlet", "/g/mai2" })
|
|
||||||
public class Maimai2ServletController {
|
|
||||||
|
|
||||||
private final GetGameSettingHandler getGameSettingHandler;
|
|
||||||
private final GetGameEventHandler getGameEventHandler;
|
|
||||||
private final GetGameRankingHandler getGameRankingHandler;
|
|
||||||
private final GetGameTournamentInfoHandler getGameTournamentInfoHandler;
|
|
||||||
private final GetGameChargeHandler getGameChargeHandler;
|
|
||||||
private final GetTransferFriendHandler getTransferFriendHandler;
|
|
||||||
private final GetUserActivityHandler getUserActivityHandler;
|
|
||||||
private final UserLoginHandler userLoginHandler;
|
|
||||||
private final UserLogoutHandler userLogoutHandler;
|
|
||||||
private final GetUserDataHandler getUserDataHandler;
|
|
||||||
private final UpsertUserAllHandler upsertUserAllHandler;
|
|
||||||
private final GetUserPreviewHandler getUserPreviewHandler;
|
|
||||||
private final GetUserCharacterHandler getUserCharacterHandler;
|
|
||||||
private final GetUserOptionHandler getUserOptionHandler;
|
|
||||||
private final GetUserItemHandler getUserItemHandler;
|
|
||||||
private final GetUserExtendHandler getUserExtendHandler;
|
|
||||||
private final GetUserGhostHandler getUserGhostHandler;
|
|
||||||
private final GetUserLoginBonusHandler getUserLoginBonusHandler;
|
|
||||||
private final GetUserMapHandler getUserMapHandler;
|
|
||||||
private final GetUserFavoriteHandler getUserFavoriteHandler;
|
|
||||||
private final GetUserCardHandler getUserCardHandler;
|
|
||||||
private final GetUserMusicHandler getUserMusicHandler;
|
|
||||||
private final GetUserRatingHandler getUserRatingHandler;
|
|
||||||
private final GetUserRegionHandler getUserRegionHandler;
|
|
||||||
private final GetUserChargeHandler getUserChargeHandler;
|
|
||||||
private final GetUserCourseHandler getUserCourseHandler;
|
|
||||||
private final UploadUserPhotoHandler uploadUserPhotoHandler;
|
|
||||||
private final UploadUserPlaylogHandler uploadUserPlaylogHandler;
|
|
||||||
private final GetGameNgMusicIdHandler getGameNgMusicIdHandler;
|
|
||||||
private final GetUserFriendSeasonRankingHandler getUserFriendSeasonRankingHandler;
|
|
||||||
private final GetUserPortraitHandler getUserPortraitHandler;
|
|
||||||
private final UploadUserPortraitHandler uploadUserPortraitHandler;
|
|
||||||
private final CMGetUserPreviewHandler cmGetUserPreviewHandler;
|
|
||||||
private final CMGetSellingCardHandler cmGetSellingCardHandler;
|
|
||||||
private final GetUserCardPrintErrorHandler getUserCardPrintErrorHandler;
|
|
||||||
private final CMGetUserCharacterHandler cmGetUserCharacterHandler;
|
|
||||||
private final UpsertUserPrintHandler upsertUserPrintHandler;
|
|
||||||
private final GetUserRecommendRateMusicHandler getUserRecommendRateMusicHandler;
|
|
||||||
private final GetUserRecommendSelectMusicHandler getUserRecommendSelectMusicHandler;
|
|
||||||
private final GetUserFavoriteItemHandler getUserFavoriteItemHandler;
|
|
||||||
private final GetUserRivalDataHandler getUserRivalDataHandler;
|
|
||||||
private final GetUserRivalMusicHandler getUserRivalMusicHandler;
|
|
||||||
|
|
||||||
// Mandatory for boot
|
|
||||||
@PostMapping("GetGameEventApi")
|
|
||||||
public String getGameEvent(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getGameEventHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetGameRankingApi")
|
|
||||||
public String getGameRanking(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getGameRankingHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetGameSettingApi")
|
|
||||||
public String getGameSetting(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getGameSettingHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetGameTournamentInfoApi")
|
|
||||||
public String getGameTournamentInfoHandler(@ModelAttribute Map<String, Object> request)
|
|
||||||
throws JsonProcessingException {
|
|
||||||
return getGameTournamentInfoHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Gameplay
|
|
||||||
@PostMapping("GetTransferFriendApi")
|
|
||||||
public String getTransferFriendHandler(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getTransferFriendHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetUserActivityApi")
|
|
||||||
public String getUserActivityHandler(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getUserActivityHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetUserCardApi")
|
|
||||||
public String getUserCardHandler(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getUserCardHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetUserCharacterApi")
|
|
||||||
public String getUserCharacterHandler(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getUserCharacterHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetUserDataApi")
|
|
||||||
public String getUserDataHandler(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getUserDataHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetUserExtendApi")
|
|
||||||
public String getUserExtendHandler(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getUserExtendHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetUserFavoriteApi")
|
|
||||||
public String getUserFavoriteHandler(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getUserFavoriteHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
// No support, return empty
|
|
||||||
@PostMapping("GetUserGhostApi")
|
|
||||||
public String getUserGhostHandler(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getUserGhostHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetUserItemApi")
|
|
||||||
public String getUserItemHandler(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getUserItemHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetUserLoginBonusApi")
|
|
||||||
public String getUserLoginBonusHandler(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getUserLoginBonusHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetUserMapApi")
|
|
||||||
public String getUserMapHandler(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getUserMapHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetUserMusicApi")
|
|
||||||
public String getUserMusicHandler(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getUserMusicHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetUserOptionApi")
|
|
||||||
public String getUserOptionHandler(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getUserOptionHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetUserPortraitApi")
|
|
||||||
public String getUserPortraitHandler(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getUserPortraitHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetUserPreviewApi")
|
|
||||||
public String getUserPreviewHandler(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getUserPreviewHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetUserRatingApi")
|
|
||||||
public String getUserRatingHandler(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getUserRatingHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
// I don't know what it is. return empty
|
|
||||||
@PostMapping("GetUserRegionApi")
|
|
||||||
public String getUserRegionHandler(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getUserRegionHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Seems only used for tournament, No Support
|
|
||||||
@PostMapping("GetUserScoreRankingApi")
|
|
||||||
public String getUserScoreRankingHandler(@ModelAttribute Map<String, Object> request)
|
|
||||||
throws JsonProcessingException {
|
|
||||||
return "{}";
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("UploadUserPhotoApi")
|
|
||||||
public Object uploadUserPhotoHandler(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return uploadUserPhotoHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("UploadUserPlaylogApi")
|
|
||||||
public Object uploadUserPlaylogHandler(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return uploadUserPlaylogHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@CrossOrigin // enable cors because aqua-viewer also use it.
|
|
||||||
@PostMapping("UploadUserPortraitApi")
|
|
||||||
public Object uploadUserPortraitHandler(@ModelAttribute Map<String, Object> request)
|
|
||||||
throws JsonProcessingException {
|
|
||||||
return uploadUserPortraitHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("UserLoginApi")
|
|
||||||
public Object userLoginHandler(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return userLoginHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("UserLogoutApi")
|
|
||||||
public String userLogoutHandler(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return userLogoutHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("UpsertClientBookkeepingApi")
|
|
||||||
public String upsertClientBookkeeping(@ModelAttribute Map<String, Object> request) {
|
|
||||||
return "{\"returnCode\":1,\"apiName\":\"com.sega.maimai2servlet.api.UpsertClientBookkeepingApi\"}";
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("UpsertClientSettingApi")
|
|
||||||
public String upsertClientSetting(@ModelAttribute Map<String, Object> request) {
|
|
||||||
return "{\"returnCode\":1,\"apiName\":\"com.sega.maimai2servlet.api.UpsertClientSettingApi\"}";
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("UpsertClientTestmodeApi")
|
|
||||||
public String upsertClientTestmode(@ModelAttribute Map<String, Object> request) {
|
|
||||||
return "{\"returnCode\":1,\"apiName\":\"com.sega.maimai2servlet.api.UpsertClientTestmodeApi\"}";
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("UpsertClientUploadApi")
|
|
||||||
public String upsertClientUpload(@ModelAttribute Map<String, Object> request) {
|
|
||||||
return "{\"returnCode\":1,\"apiName\":\"com.sega.maimai2servlet.api.UpsertClientUploadApi\"}";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Score saving
|
|
||||||
@PostMapping("UpsertUserAllApi")
|
|
||||||
public String upsertUserAllHandler(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return upsertUserAllHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Splash plus APIs
|
|
||||||
@PostMapping("GetGameChargeApi")
|
|
||||||
public String getGameChargeHandler(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getGameChargeHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetUserChargeApi")
|
|
||||||
public String getUserChargeHandler(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getUserChargeHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("UpsertUserChargelogApi")
|
|
||||||
public String upsertUserChargelog(@ModelAttribute Map<String, Object> request) {
|
|
||||||
return "{\"returnCode\":1,\"apiName\":\"com.sega.maimai2servlet.api.UpsertUserChargelogApi\"}";
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetUserCourseApi")
|
|
||||||
public String getUserCourseHandler(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getUserCourseHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Universe APIs
|
|
||||||
@PostMapping("GetGameNgMusicIdApi")
|
|
||||||
public String getGameNgMusicIdHandler(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getGameNgMusicIdHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetUserFriendSeasonRankingApi")
|
|
||||||
public String getUserFriendSeasonRankingHandler(@ModelAttribute Map<String, Object> request)
|
|
||||||
throws JsonProcessingException {
|
|
||||||
return getUserFriendSeasonRankingHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("Ping")
|
|
||||||
String ping(@ModelAttribute Map<String, Object> request) {
|
|
||||||
return "{\"returnCode\":\"1\"}";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Festival APIs
|
|
||||||
@PostMapping("CreateTokenApi")
|
|
||||||
String createTokenHandler(@ModelAttribute Map<String, Object> request) {
|
|
||||||
return "{\"Bearer\":\"AQUATOKEN\"}";
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("RemoveTokenApi")
|
|
||||||
String removeTokenHandler(@ModelAttribute Map<String, Object> request) {
|
|
||||||
return "{\"returnCode\":\"1\"}";
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetUserRecommendRateMusicApi")
|
|
||||||
public String getUserRecommendRateMusicHandler(@ModelAttribute Map<String, Object> request)
|
|
||||||
throws JsonProcessingException {
|
|
||||||
return getUserRecommendRateMusicHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetUserRecommendSelectMusicApi")
|
|
||||||
public String getUserRecommendSelectMusicHandler(@ModelAttribute Map<String, Object> request)
|
|
||||||
throws JsonProcessingException {
|
|
||||||
return getUserRecommendSelectMusicHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
// CardMaker APIs
|
|
||||||
@PostMapping("CMGetSellingCardApi")
|
|
||||||
String cmGetSellingCard(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return cmGetSellingCardHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("CMGetUserCardApi")
|
|
||||||
String cmGetUserCard(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getUserCardHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("CMGetUserCardPrintErrorApi")
|
|
||||||
String cmGetUserCardPrintError(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getUserCardPrintErrorHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("CMGetUserCharacterApi")
|
|
||||||
String cmGetUserCharacter(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return cmGetUserCharacterHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("CMGetUserDataApi")
|
|
||||||
String cmGetUserData(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getUserDataHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("CMGetUserItemApi")
|
|
||||||
String cmGetUserItem(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return getUserItemHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("CMGetUserPreviewApi")
|
|
||||||
String cmGetUserPreview(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return cmGetUserPreviewHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("CMLoginApi")
|
|
||||||
String cmLoginApi(@ModelAttribute Map<String, Object> request) {
|
|
||||||
return "{\"returnCode\":\"1\"}";
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("CMLogoutApi")
|
|
||||||
String cmLogoutApi(@ModelAttribute Map<String, Object> request) {
|
|
||||||
return "{\"returnCode\":\"1\"}";
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("CMUpsertBuyCardApi")
|
|
||||||
String cmUpsertBuyCard(@ModelAttribute Map<String, Object> request) {
|
|
||||||
return "{\"returnCode\":\"1\"}";
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("CMUpsertUserPrintApi")
|
|
||||||
String cmUpsertUserPrint(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return upsertUserPrintHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("CMUpsertUserPrintlogApi")
|
|
||||||
String cmUpsertUserPrintlog(@ModelAttribute Map<String, Object> request) {
|
|
||||||
return "{\"returnCode\":\"1\", \"orderId\":\"0\", \"serialId\":\"FAKECARDIMAG12345678\"}";
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetUserFavoriteItemApi")
|
|
||||||
String getUserFavoriteItem(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return this.getUserFavoriteItemHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetUserRivalDataApi")
|
|
||||||
String getUserRivalData(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return this.getUserRivalDataHandler.handle(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("GetUserRivalMusicApi")
|
|
||||||
String getUserRivalMusic(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
|
||||||
return this.getUserRivalMusicHandler.handle(request);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
package icu.samnyan.aqua.sega.maimai2.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.maimai2")
|
|
||||||
public class Maimai2ServletControllerAdvice {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(Maimai2ServletControllerAdvice.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,12 +1,16 @@
|
|||||||
package icu.samnyan.aqua.sega.maimai2.handler;
|
package icu.samnyan.aqua.sega.maimai2.handler;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author samnyan (privateamusement@protonmail.com)
|
* @author samnyan (privateamusement@protonmail.com)
|
||||||
*/
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping({"/g/mai2/Maimai2Servlet/", "/g/mai2/"})
|
||||||
public interface BaseHandler {
|
public interface BaseHandler {
|
||||||
|
|
||||||
Object handle(Map<String, Object> request) throws JsonProcessingException;
|
Object handle(Map<String, Object> request) throws JsonProcessingException;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import java.util.LinkedHashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import icu.samnyan.aqua.sega.maimai2.handler.BaseHandler;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -17,7 +18,7 @@ import icu.samnyan.aqua.sega.maimai2.model.userdata.UserDetail;
|
|||||||
import icu.samnyan.aqua.sega.util.jackson.StringMapper;
|
import icu.samnyan.aqua.sega.util.jackson.StringMapper;
|
||||||
|
|
||||||
@Component("Maimai2GetUserRivalDataHandler")
|
@Component("Maimai2GetUserRivalDataHandler")
|
||||||
public class GetUserRivalDataHandler {
|
public class GetUserRivalDataHandler implements BaseHandler {
|
||||||
private static final Logger logger = LoggerFactory
|
private static final Logger logger = LoggerFactory
|
||||||
.getLogger(icu.samnyan.aqua.sega.maimai2.handler.impl.GetUserRivalDataHandler.class);
|
.getLogger(icu.samnyan.aqua.sega.maimai2.handler.impl.GetUserRivalDataHandler.class);
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import java.util.LinkedList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import icu.samnyan.aqua.sega.maimai2.handler.BaseHandler;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -20,7 +21,7 @@ import icu.samnyan.aqua.sega.maimai2.model.userdata.UserMusicDetail;
|
|||||||
import icu.samnyan.aqua.sega.util.jackson.StringMapper;
|
import icu.samnyan.aqua.sega.util.jackson.StringMapper;
|
||||||
|
|
||||||
@Component("Maimai2GetUserRivalMusicHandler")
|
@Component("Maimai2GetUserRivalMusicHandler")
|
||||||
public class GetUserRivalMusicHandler {
|
public class GetUserRivalMusicHandler implements BaseHandler {
|
||||||
private static final Logger logger = LoggerFactory
|
private static final Logger logger = LoggerFactory
|
||||||
.getLogger(icu.samnyan.aqua.sega.maimai2.handler.impl.GetUserRivalMusicHandler.class);
|
.getLogger(icu.samnyan.aqua.sega.maimai2.handler.impl.GetUserRivalMusicHandler.class);
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package icu.samnyan.aqua.sega.maimai2.handler.impl;
|
|||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import icu.samnyan.aqua.sega.general.model.Card;
|
import icu.samnyan.aqua.sega.general.model.Card;
|
||||||
import icu.samnyan.aqua.sega.general.service.CardService;
|
import icu.samnyan.aqua.sega.general.service.CardService;
|
||||||
import icu.samnyan.aqua.sega.maimai.handler.BaseHandler;
|
import icu.samnyan.aqua.sega.maimai2.handler.BaseHandler;
|
||||||
import icu.samnyan.aqua.sega.maimai2.model.*;
|
import icu.samnyan.aqua.sega.maimai2.model.*;
|
||||||
import icu.samnyan.aqua.sega.maimai2.model.request.UpsertUserAll;
|
import icu.samnyan.aqua.sega.maimai2.model.request.UpsertUserAll;
|
||||||
import icu.samnyan.aqua.sega.maimai2.model.request.data.UserAll;
|
import icu.samnyan.aqua.sega.maimai2.model.request.data.UserAll;
|
||||||
|
|||||||
Reference in New Issue
Block a user