mirror of https://github.com/hykilpikonna/AquaDX
[+] Maimai2 Festival Plus
parent
07a6631b81
commit
b9116b1bce
|
@ -214,6 +214,25 @@ public class ApiMaimai2PlayerDataController {
|
||||||
.orElseGet(() -> ResponseEntity.status(HttpStatus.NOT_FOUND).body(new MessageResponse("User or value not found.")));
|
.orElseGet(() -> ResponseEntity.status(HttpStatus.NOT_FOUND).body(new MessageResponse("User or value not found.")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("general")
|
||||||
|
public ResponseEntity<Object> setGeneralData(@RequestBody Map<String, Object> request) {
|
||||||
|
UserDetail profile = userDataRepository.findByCard_ExtId(((Number) request.get("aimeId")).longValue()).orElseThrow();
|
||||||
|
String key = (String) request.get("key");
|
||||||
|
String value = (String) request.get("value");
|
||||||
|
|
||||||
|
Optional<UserGeneralData> userGeneralDataOptional = userGeneralDataRepository.findByUserAndPropertyKey(profile, key);
|
||||||
|
UserGeneralData userGeneralData;
|
||||||
|
if (userGeneralDataOptional.isPresent()) {
|
||||||
|
userGeneralData = userGeneralDataOptional.get();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
userGeneralData = new UserGeneralData(profile, key);
|
||||||
|
}
|
||||||
|
userGeneralData.setPropertyValue(value);
|
||||||
|
|
||||||
|
return ResponseEntity.ok(userGeneralDataRepository.save(userGeneralData));
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("export")
|
@GetMapping("export")
|
||||||
public ResponseEntity<Object> exportAllUserData(@RequestParam long aimeId) {
|
public ResponseEntity<Object> exportAllUserData(@RequestParam long aimeId) {
|
||||||
Maimai2DataExport data = new Maimai2DataExport();
|
Maimai2DataExport data = new Maimai2DataExport();
|
||||||
|
|
|
@ -11,7 +11,7 @@ import java.util.Map;
|
||||||
* @author samnyan (privateamusement@protonmail.com)
|
* @author samnyan (privateamusement@protonmail.com)
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping({"/Maimai2Servlet/Maimai2Servlet", "/Maimai2Servlet"})
|
@RequestMapping({ "/Maimai2Servlet/Maimai2Servlet", "/Maimai2Servlet" })
|
||||||
public class Maimai2ServletController {
|
public class Maimai2ServletController {
|
||||||
|
|
||||||
private final GetGameSettingHandler getGameSettingHandler;
|
private final GetGameSettingHandler getGameSettingHandler;
|
||||||
|
@ -53,17 +53,53 @@ public class Maimai2ServletController {
|
||||||
private final UpsertUserPrintHandler upsertUserPrintHandler;
|
private final UpsertUserPrintHandler upsertUserPrintHandler;
|
||||||
private final GetUserRecommendRateMusicHandler getUserRecommendRateMusicHandler;
|
private final GetUserRecommendRateMusicHandler getUserRecommendRateMusicHandler;
|
||||||
private final GetUserRecommendSelectMusicHandler getUserRecommendSelectMusicHandler;
|
private final GetUserRecommendSelectMusicHandler getUserRecommendSelectMusicHandler;
|
||||||
|
private final GetUserFavoriteItemHandler getUserFavoriteItemHandler;
|
||||||
|
private final GetUserRivalDataHandler getUserRivalDataHandler;
|
||||||
|
private final GetUserRivalMusicHandler getUserRivalMusicHandler;
|
||||||
|
|
||||||
public Maimai2ServletController(GetGameSettingHandler getGameSettingHandler, GetGameEventHandler getGameEventHandler, GetGameRankingHandler getGameRankingHandler, GetGameTournamentInfoHandler getGameTournamentInfoHandler,
|
public Maimai2ServletController(
|
||||||
GetTransferFriendHandler getTransferFriendHandler, GetUserActivityHandler getUserActivityHandler, UserLoginHandler userLoginHandler, UserLogoutHandler userLogoutHandler,
|
GetGameSettingHandler getGameSettingHandler,
|
||||||
GetUserDataHandler getUserDataHandler, UpsertUserAllHandler upsertUserAllHandler, GetUserPreviewHandler getUserPreviewHandler, GetUserCharacterHandler getUserCharacterHandler,
|
GetGameEventHandler getGameEventHandler,
|
||||||
GetUserOptionHandler getUserOptionHandler, GetUserItemHandler getUserItemHandler, GetUserExtendHandler getUserExtendHandler, GetUserGhostHandler getUserGhostHandler,
|
GetGameRankingHandler getGameRankingHandler,
|
||||||
GetUserLoginBonusHandler getUserLoginBonusHandler, GetUserMapHandler getUserMapHandler, GetUserFavoriteHandler getUserFavoriteHandler,
|
GetGameTournamentInfoHandler getGameTournamentInfoHandler,
|
||||||
GetUserCardHandler getUserCardHandler, GetUserMusicHandler getUserMusicHandler, GetUserRatingHandler getUserRatingHandler, GetUserRegionHandler getUserRegionHandler,
|
GetTransferFriendHandler getTransferFriendHandler,
|
||||||
GetGameChargeHandler getGameChargeHandler, GetUserChargeHandler getUserChargeHandler, GetUserCourseHandler getUserCourseHandler, UploadUserPhotoHandler uploadUserPhotoHandler,
|
GetUserActivityHandler getUserActivityHandler,
|
||||||
UploadUserPlaylogHandler uploadUserPlaylogHandler, UploadUserPortraitHandler uploadUserPortraitHandler, GetGameNgMusicIdHandler getGameNgMusicIdHandler,GetUserPortraitHandler getUserPortraitHandler, GetUserFriendSeasonRankingHandler getUserFriendSeasonRankingHandler,
|
UserLoginHandler userLoginHandler,
|
||||||
CMGetUserPreviewHandler cmGetUserPreviewHandler, CMGetSellingCardHandler cmGetSellingCardHandler, GetUserCardPrintErrorHandler getUserCardPrintErrorHandler, CMGetUserCharacterHandler cmGetUserCharacterHandler,
|
UserLogoutHandler userLogoutHandler,
|
||||||
UpsertUserPrintHandler upsertUserPrintHandler, GetUserRecommendRateMusicHandler getUserRecommendRateMusicHandler, GetUserRecommendSelectMusicHandler getUserRecommendSelectMusicHandler) {
|
GetUserDataHandler getUserDataHandler,
|
||||||
|
UpsertUserAllHandler upsertUserAllHandler,
|
||||||
|
GetUserPreviewHandler getUserPreviewHandler,
|
||||||
|
GetUserCharacterHandler getUserCharacterHandler,
|
||||||
|
GetUserOptionHandler getUserOptionHandler,
|
||||||
|
GetUserItemHandler getUserItemHandler,
|
||||||
|
GetUserExtendHandler getUserExtendHandler,
|
||||||
|
GetUserGhostHandler getUserGhostHandler,
|
||||||
|
GetUserLoginBonusHandler getUserLoginBonusHandler,
|
||||||
|
GetUserMapHandler getUserMapHandler,
|
||||||
|
GetUserFavoriteHandler getUserFavoriteHandler,
|
||||||
|
GetUserCardHandler getUserCardHandler,
|
||||||
|
GetUserMusicHandler getUserMusicHandler,
|
||||||
|
GetUserRatingHandler getUserRatingHandler,
|
||||||
|
GetUserRegionHandler getUserRegionHandler,
|
||||||
|
GetGameChargeHandler getGameChargeHandler,
|
||||||
|
GetUserChargeHandler getUserChargeHandler,
|
||||||
|
GetUserCourseHandler getUserCourseHandler,
|
||||||
|
UploadUserPhotoHandler uploadUserPhotoHandler,
|
||||||
|
UploadUserPlaylogHandler uploadUserPlaylogHandler,
|
||||||
|
UploadUserPortraitHandler uploadUserPortraitHandler,
|
||||||
|
GetGameNgMusicIdHandler getGameNgMusicIdHandler,
|
||||||
|
GetUserPortraitHandler getUserPortraitHandler,
|
||||||
|
GetUserFriendSeasonRankingHandler getUserFriendSeasonRankingHandler,
|
||||||
|
CMGetUserPreviewHandler cmGetUserPreviewHandler,
|
||||||
|
CMGetSellingCardHandler cmGetSellingCardHandler,
|
||||||
|
GetUserCardPrintErrorHandler getUserCardPrintErrorHandler,
|
||||||
|
CMGetUserCharacterHandler cmGetUserCharacterHandler,
|
||||||
|
UpsertUserPrintHandler upsertUserPrintHandler,
|
||||||
|
GetUserRecommendRateMusicHandler getUserRecommendRateMusicHandler,
|
||||||
|
GetUserRecommendSelectMusicHandler getUserRecommendSelectMusicHandler,
|
||||||
|
GetUserFavoriteItemHandler getUserFavoriteItemHandler,
|
||||||
|
GetUserRivalDataHandler getUserRivalDataHandler,
|
||||||
|
GetUserRivalMusicHandler getUserRivalMusicHandler) {
|
||||||
this.getGameSettingHandler = getGameSettingHandler;
|
this.getGameSettingHandler = getGameSettingHandler;
|
||||||
this.getGameEventHandler = getGameEventHandler;
|
this.getGameEventHandler = getGameEventHandler;
|
||||||
this.getGameRankingHandler = getGameRankingHandler;
|
this.getGameRankingHandler = getGameRankingHandler;
|
||||||
|
@ -103,6 +139,9 @@ public class Maimai2ServletController {
|
||||||
this.upsertUserPrintHandler = upsertUserPrintHandler;
|
this.upsertUserPrintHandler = upsertUserPrintHandler;
|
||||||
this.getUserRecommendRateMusicHandler = getUserRecommendRateMusicHandler;
|
this.getUserRecommendRateMusicHandler = getUserRecommendRateMusicHandler;
|
||||||
this.getUserRecommendSelectMusicHandler = getUserRecommendSelectMusicHandler;
|
this.getUserRecommendSelectMusicHandler = getUserRecommendSelectMusicHandler;
|
||||||
|
this.getUserFavoriteItemHandler = getUserFavoriteItemHandler;
|
||||||
|
this.getUserRivalDataHandler = getUserRivalDataHandler;
|
||||||
|
this.getUserRivalMusicHandler = getUserRivalMusicHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mandatory for boot
|
// Mandatory for boot
|
||||||
|
@ -122,7 +161,8 @@ public class Maimai2ServletController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("GetGameTournamentInfoApi")
|
@PostMapping("GetGameTournamentInfoApi")
|
||||||
public String getGameTournamentInfoHandler(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
public String getGameTournamentInfoHandler(@ModelAttribute Map<String, Object> request)
|
||||||
|
throws JsonProcessingException {
|
||||||
return getGameTournamentInfoHandler.handle(request);
|
return getGameTournamentInfoHandler.handle(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,7 +256,8 @@ public class Maimai2ServletController {
|
||||||
|
|
||||||
// Seems only used for tournament, No Support
|
// Seems only used for tournament, No Support
|
||||||
@PostMapping("GetUserScoreRankingApi")
|
@PostMapping("GetUserScoreRankingApi")
|
||||||
public String getUserScoreRankingHandler(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
public String getUserScoreRankingHandler(@ModelAttribute Map<String, Object> request)
|
||||||
|
throws JsonProcessingException {
|
||||||
return "{}";
|
return "{}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,9 +271,10 @@ public class Maimai2ServletController {
|
||||||
return uploadUserPlaylogHandler.handle(request);
|
return uploadUserPlaylogHandler.handle(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@CrossOrigin//enable cors because aqua-viewer also use it.
|
@CrossOrigin // enable cors because aqua-viewer also use it.
|
||||||
@PostMapping("UploadUserPortraitApi")
|
@PostMapping("UploadUserPortraitApi")
|
||||||
public String uploadUserPortraitHandler(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
public String uploadUserPortraitHandler(@ModelAttribute Map<String, Object> request)
|
||||||
|
throws JsonProcessingException {
|
||||||
return uploadUserPortraitHandler.handle(request);
|
return uploadUserPortraitHandler.handle(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -300,7 +342,8 @@ public class Maimai2ServletController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("GetUserFriendSeasonRankingApi")
|
@PostMapping("GetUserFriendSeasonRankingApi")
|
||||||
public String getUserFriendSeasonRankingHandler(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
public String getUserFriendSeasonRankingHandler(@ModelAttribute Map<String, Object> request)
|
||||||
|
throws JsonProcessingException {
|
||||||
return getUserFriendSeasonRankingHandler.handle(request);
|
return getUserFriendSeasonRankingHandler.handle(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -321,12 +364,14 @@ public class Maimai2ServletController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("GetUserRecommendRateMusicApi")
|
@PostMapping("GetUserRecommendRateMusicApi")
|
||||||
public String getUserRecommendRateMusicHandler(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
public String getUserRecommendRateMusicHandler(@ModelAttribute Map<String, Object> request)
|
||||||
|
throws JsonProcessingException {
|
||||||
return getUserRecommendRateMusicHandler.handle(request);
|
return getUserRecommendRateMusicHandler.handle(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("GetUserRecommendSelectMusicApi")
|
@PostMapping("GetUserRecommendSelectMusicApi")
|
||||||
public String getUserRecommendSelectMusicHandler(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
public String getUserRecommendSelectMusicHandler(@ModelAttribute Map<String, Object> request)
|
||||||
|
throws JsonProcessingException {
|
||||||
return getUserRecommendSelectMusicHandler.handle(request);
|
return getUserRecommendSelectMusicHandler.handle(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,4 +436,18 @@ public class Maimai2ServletController {
|
||||||
return "{\"returnCode\":\"1\", \"orderId\":\"0\", \"serialId\":\"FAKECARDIMAG12345678\"}";
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class GetGameEventHandler implements BaseHandler {
|
||||||
resultMap.put("gameEventList", gameEventList);
|
resultMap.put("gameEventList", gameEventList);
|
||||||
|
|
||||||
String json = mapper.write(resultMap);
|
String json = mapper.write(resultMap);
|
||||||
logger.info("Response: " + json);
|
logger.info("Response: length " + json.length());
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class GetUserCharacterHandler implements BaseHandler {
|
||||||
resultMap.put("userCharacterList", userCharacterList);
|
resultMap.put("userCharacterList", userCharacterList);
|
||||||
|
|
||||||
String json = mapper.write(resultMap);
|
String json = mapper.write(resultMap);
|
||||||
logger.info("Response: " + json);
|
logger.info("Response: length " + json.length());
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,74 @@
|
||||||
|
package icu.samnyan.aqua.sega.maimai2.handler.impl;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import icu.samnyan.aqua.sega.maimai2.model.response.data.UserFavoriteItem;
|
||||||
|
import icu.samnyan.aqua.sega.maimai2.model.userdata.UserGeneralData;
|
||||||
|
import icu.samnyan.aqua.sega.maimai2.dao.userdata.UserGeneralDataRepository;
|
||||||
|
import icu.samnyan.aqua.sega.maimai2.handler.BaseHandler;
|
||||||
|
import icu.samnyan.aqua.sega.util.jackson.StringMapper;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component("Maimai2GetUserFavoriteItemHandler")
|
||||||
|
public class GetUserFavoriteItemHandler implements BaseHandler {
|
||||||
|
private static final Logger logger = LoggerFactory
|
||||||
|
.getLogger(icu.samnyan.aqua.sega.maimai2.handler.impl.GetUserFavoriteItemHandler.class);
|
||||||
|
|
||||||
|
private final StringMapper mapper;
|
||||||
|
private final UserGeneralDataRepository userGeneralDataRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public GetUserFavoriteItemHandler(StringMapper mapper, UserGeneralDataRepository userGeneralDataRepository) {
|
||||||
|
this.mapper = mapper;
|
||||||
|
this.userGeneralDataRepository = userGeneralDataRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
||||||
|
long userId = ((Number) request.get("userId")).longValue();
|
||||||
|
int kind = ((Number) request.get("kind")).intValue();
|
||||||
|
|
||||||
|
Optional<UserGeneralData> favOptional;
|
||||||
|
List<UserFavoriteItem> items = new LinkedList<>();
|
||||||
|
switch (kind) {
|
||||||
|
case 1:
|
||||||
|
favOptional = this.userGeneralDataRepository.findByUser_Card_ExtIdAndPropertyKey(userId,
|
||||||
|
"favorite_music");
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
favOptional = this.userGeneralDataRepository.findByUser_Card_ExtIdAndPropertyKey(userId, "favorite_rival");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
favOptional = Optional.empty();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (favOptional.isPresent()) {
|
||||||
|
String val = ((UserGeneralData) favOptional.get()).getPropertyValue();
|
||||||
|
if (StringUtils.isNotBlank(val)) {
|
||||||
|
String[] records = val.split(",");
|
||||||
|
int order = 0;
|
||||||
|
for (String record : records) {
|
||||||
|
items.add(new UserFavoriteItem(Integer.parseInt(record), order));
|
||||||
|
order += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||||
|
resultMap.put("userId", userId);
|
||||||
|
resultMap.put("kind", Integer.valueOf(kind));
|
||||||
|
resultMap.put("length", Integer.valueOf(items.size()));
|
||||||
|
resultMap.put("nextIndex", Integer.valueOf(0));
|
||||||
|
resultMap.put("userFavoriteItemList", items);
|
||||||
|
String json = this.mapper.write(resultMap);
|
||||||
|
logger.info("Response: " + json);
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
package icu.samnyan.aqua.sega.maimai2.handler.impl;
|
||||||
|
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
|
||||||
|
import icu.samnyan.aqua.sega.maimai2.dao.userdata.UserDataRepository;
|
||||||
|
import icu.samnyan.aqua.sega.maimai2.model.response.data.UserRivalData;
|
||||||
|
import icu.samnyan.aqua.sega.maimai2.model.userdata.UserDetail;
|
||||||
|
import icu.samnyan.aqua.sega.util.jackson.StringMapper;
|
||||||
|
|
||||||
|
@Component("Maimai2GetUserRivalDataHandler")
|
||||||
|
public class GetUserRivalDataHandler {
|
||||||
|
private static final Logger logger = LoggerFactory
|
||||||
|
.getLogger(icu.samnyan.aqua.sega.maimai2.handler.impl.GetUserRivalDataHandler.class);
|
||||||
|
|
||||||
|
private final StringMapper mapper;
|
||||||
|
private final UserDataRepository userDataRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public GetUserRivalDataHandler(StringMapper mapper, UserDataRepository userDataRepository) {
|
||||||
|
this.mapper = mapper;
|
||||||
|
this.userDataRepository = userDataRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
||||||
|
long userId = ((Number) request.get("userId")).longValue();
|
||||||
|
long rivalId = ((Number) request.get("rivalId")).intValue();
|
||||||
|
|
||||||
|
Optional<UserDetail> detailOptional = userDataRepository.findByCard_ExtId(rivalId);
|
||||||
|
UserRivalData rivalData;
|
||||||
|
if (detailOptional.isPresent()) {
|
||||||
|
rivalData = new UserRivalData(rivalId, detailOptional.get().getUserName());
|
||||||
|
} else {
|
||||||
|
rivalData = new UserRivalData(rivalId, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||||
|
resultMap.put("userId", userId);
|
||||||
|
resultMap.put("userRivalData", rivalData);
|
||||||
|
|
||||||
|
String json = this.mapper.write(resultMap);
|
||||||
|
logger.info("Response: " + json);
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,67 @@
|
||||||
|
package icu.samnyan.aqua.sega.maimai2.handler.impl;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
|
||||||
|
import icu.samnyan.aqua.sega.maimai2.dao.userdata.UserMusicDetailRepository;
|
||||||
|
import icu.samnyan.aqua.sega.maimai2.model.response.data.UserRivalMusic;
|
||||||
|
import icu.samnyan.aqua.sega.maimai2.model.response.data.UserRivalMusicDetail;
|
||||||
|
import icu.samnyan.aqua.sega.maimai2.model.userdata.UserMusicDetail;
|
||||||
|
import icu.samnyan.aqua.sega.util.jackson.StringMapper;
|
||||||
|
|
||||||
|
@Component("Maimai2GetUserRivalMusicHandler")
|
||||||
|
public class GetUserRivalMusicHandler {
|
||||||
|
private static final Logger logger = LoggerFactory
|
||||||
|
.getLogger(icu.samnyan.aqua.sega.maimai2.handler.impl.GetUserRivalMusicHandler.class);
|
||||||
|
|
||||||
|
private final StringMapper mapper;
|
||||||
|
private final UserMusicDetailRepository userMusicDetailRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public GetUserRivalMusicHandler(StringMapper mapper, UserMusicDetailRepository userMusicDetailRepository) {
|
||||||
|
this.mapper = mapper;
|
||||||
|
this.userMusicDetailRepository = userMusicDetailRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
||||||
|
long userId = ((Number) request.get("userId")).longValue();
|
||||||
|
long rivalId = ((Number) request.get("rivalId")).intValue();
|
||||||
|
|
||||||
|
List<UserMusicDetail> details = userMusicDetailRepository.findByUser_Card_ExtId(rivalId);
|
||||||
|
List<UserRivalMusic> userRivalMusicList = new LinkedList<UserRivalMusic>();
|
||||||
|
Map<Integer, UserRivalMusic> userRivalMusicMap = new HashMap<Integer, UserRivalMusic>();
|
||||||
|
for (UserMusicDetail detail : details) {
|
||||||
|
int musicId = detail.getMusicId();
|
||||||
|
UserRivalMusic info = userRivalMusicMap.getOrDefault(musicId, null);
|
||||||
|
if (info == null) {
|
||||||
|
info = new UserRivalMusic(musicId, new LinkedList<>());
|
||||||
|
userRivalMusicList.add(info);
|
||||||
|
userRivalMusicMap.put(musicId, info);
|
||||||
|
}
|
||||||
|
|
||||||
|
info.getUserRivalMusicDetailList().add(
|
||||||
|
new UserRivalMusicDetail(detail.getLevel(), detail.getAchievement(), detail.getDeluxscoreMax())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||||
|
resultMap.put("userId", userId);
|
||||||
|
resultMap.put("rivalId", rivalId);
|
||||||
|
resultMap.put("nextIndex", 0);
|
||||||
|
resultMap.put("userRivalMusicList", userRivalMusicList);
|
||||||
|
|
||||||
|
String json = this.mapper.write(resultMap);
|
||||||
|
logger.info("Response: " + json);
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package icu.samnyan.aqua.sega.maimai2.model.response.data;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class UserFavoriteItem {
|
||||||
|
private int id;
|
||||||
|
private int orderId;
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package icu.samnyan.aqua.sega.maimai2.model.response.data;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class UserRivalData {
|
||||||
|
private long rivalId;
|
||||||
|
private String rivalName;
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package icu.samnyan.aqua.sega.maimai2.model.response.data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class UserRivalMusic {
|
||||||
|
private int musicId;
|
||||||
|
private List<UserRivalMusicDetail> userRivalMusicDetailList;
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package icu.samnyan.aqua.sega.maimai2.model.response.data;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class UserRivalMusicDetail {
|
||||||
|
private int level;
|
||||||
|
private int achievement;
|
||||||
|
private int deluxscoreMax;
|
||||||
|
}
|
|
@ -152,4 +152,5 @@ public class UserDetail implements Serializable {
|
||||||
@JsonInclude
|
@JsonInclude
|
||||||
@Transient
|
@Transient
|
||||||
private int cmLastEmoneyCredit = 69;
|
private int cmLastEmoneyCredit = 69;
|
||||||
|
private int mapStock;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,7 @@ public class UserExtend implements Serializable {
|
||||||
private int sortCategorySetting; //enum SortTabID
|
private int sortCategorySetting; //enum SortTabID
|
||||||
private int sortMusicSetting; //enum SortMusicID
|
private int sortMusicSetting; //enum SortMusicID
|
||||||
private int playStatusSetting; //enum PlaystatusTabID
|
private int playStatusSetting; //enum PlaystatusTabID
|
||||||
|
private int selectResultScoreViewType;
|
||||||
|
|
||||||
@Convert(converter = IntegerListConverter.class)
|
@Convert(converter = IntegerListConverter.class)
|
||||||
private List<Integer> selectedCardList;
|
private List<Integer> selectedCardList;
|
||||||
|
|
|
@ -74,6 +74,9 @@ public class UserOption implements Serializable {
|
||||||
private int headPhoneVolume;
|
private int headPhoneVolume;
|
||||||
private int sortTab;
|
private int sortTab;
|
||||||
private int sortMusic;
|
private int sortMusic;
|
||||||
|
private int outFrameType;
|
||||||
|
private int breakSlideVolume;
|
||||||
|
private int touchVolume;
|
||||||
|
|
||||||
public UserOption(UserDetail user) {
|
public UserOption(UserDetail user) {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
ALTER TABLE maimai2_user_option ADD COLUMN out_frame_type INTEGER;
|
||||||
|
ALTER TABLE maimai2_user_option ADD COLUMN break_slide_volume INTEGER;
|
||||||
|
ALTER TABLE maimai2_user_option ADD COLUMN touch_volume INTEGER;
|
||||||
|
|
||||||
|
ALTER TABLE maimai2_user_extend ADD COLUMN select_result_score_view_type INTEGER;
|
||||||
|
|
||||||
|
ALTER TABLE maimai2_user_detail ADD COLUMN map_stock INTEGER;
|
||||||
|
|
||||||
|
UPDATE maimai2_user_option SET out_frame_type=0;
|
||||||
|
UPDATE maimai2_user_option SET break_slide_volume=0;
|
||||||
|
UPDATE maimai2_user_option SET touch_volume=0;
|
||||||
|
UPDATE maimai2_user_extend SET select_result_score_view_type=0;
|
||||||
|
UPDATE maimai2_user_detail SET map_stock=0;
|
|
@ -0,0 +1,13 @@
|
||||||
|
ALTER TABLE maimai2_user_option ADD COLUMN out_frame_type INTEGER;
|
||||||
|
ALTER TABLE maimai2_user_option ADD COLUMN break_slide_volume INTEGER;
|
||||||
|
ALTER TABLE maimai2_user_option ADD COLUMN touch_volume INTEGER;
|
||||||
|
|
||||||
|
ALTER TABLE maimai2_user_extend ADD COLUMN select_result_score_view_type INTEGER;
|
||||||
|
|
||||||
|
ALTER TABLE maimai2_user_detail ADD COLUMN map_stock INTEGER;
|
||||||
|
|
||||||
|
UPDATE maimai2_user_option SET out_frame_type=0;
|
||||||
|
UPDATE maimai2_user_option SET break_slide_volume=0;
|
||||||
|
UPDATE maimai2_user_option SET touch_volume=0;
|
||||||
|
UPDATE maimai2_user_extend SET select_result_score_view_type=0;
|
||||||
|
UPDATE maimai2_user_detail SET map_stock=0;
|
|
@ -0,0 +1,13 @@
|
||||||
|
ALTER TABLE maimai2_user_option ADD COLUMN out_frame_type INTEGER;
|
||||||
|
ALTER TABLE maimai2_user_option ADD COLUMN break_slide_volume INTEGER;
|
||||||
|
ALTER TABLE maimai2_user_option ADD COLUMN touch_volume INTEGER;
|
||||||
|
|
||||||
|
ALTER TABLE maimai2_user_extend ADD COLUMN select_result_score_view_type INTEGER;
|
||||||
|
|
||||||
|
ALTER TABLE maimai2_user_detail ADD COLUMN map_stock INTEGER;
|
||||||
|
|
||||||
|
UPDATE maimai2_user_option SET out_frame_type=0;
|
||||||
|
UPDATE maimai2_user_option SET break_slide_volume=0;
|
||||||
|
UPDATE maimai2_user_option SET touch_volume=0;
|
||||||
|
UPDATE maimai2_user_extend SET select_result_score_view_type=0;
|
||||||
|
UPDATE maimai2_user_detail SET map_stock=0;
|
Loading…
Reference in New Issue