forked from Cookies_Github_mirror/AquaDX
[+] Maimai2 Festival Plus
This commit is contained in:
@@ -43,7 +43,7 @@ public class GetGameEventHandler implements BaseHandler {
|
||||
resultMap.put("gameEventList", gameEventList);
|
||||
|
||||
String json = mapper.write(resultMap);
|
||||
logger.info("Response: " + json);
|
||||
logger.info("Response: length " + json.length());
|
||||
return json;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class GetUserCharacterHandler implements BaseHandler {
|
||||
resultMap.put("userCharacterList", userCharacterList);
|
||||
|
||||
String json = mapper.write(resultMap);
|
||||
logger.info("Response: " + json);
|
||||
logger.info("Response: length " + json.length());
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user