forked from Cookies_Github_mirror/AquaDX
[O] Collapse basic handlers
This commit is contained in:
@@ -1,47 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.maimai2.handler;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
|
||||
import icu.samnyan.aqua.sega.maimai2.model.Mai2GameSellingCardRepo;
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.Mai2GameSellingCard;
|
||||
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("Maimai2CMGetSellingCardHandler")
|
||||
public class CMGetSellingCardHandler implements BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(CMGetSellingCardHandler.class);
|
||||
private final Mai2GameSellingCardRepo gameSellingCardRepository;
|
||||
private final BasicMapper mapper;
|
||||
|
||||
@Autowired
|
||||
public CMGetSellingCardHandler(Mai2GameSellingCardRepo gameSellingCardRepository, BasicMapper mapper) {
|
||||
this.gameSellingCardRepository = gameSellingCardRepository;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
||||
|
||||
List<Mai2GameSellingCard> sellingCardList = gameSellingCardRepository.findAll();
|
||||
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||
resultMap.put("length", sellingCardList.size());
|
||||
resultMap.put("sellingCardList", sellingCardList);
|
||||
|
||||
String json = mapper.write(resultMap);
|
||||
logger.info("Response: " + json);
|
||||
return json;
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.maimai2.handler;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.Mai2UserCharacterRepo;
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.userdata.Mai2UserCharacter;
|
||||
import icu.samnyan.aqua.sega.util.jackson.BasicMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component("Maimai2CMGetUserCharacterHandler")
|
||||
public class CMGetUserCharacterHandler implements BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(CMGetUserCharacterHandler.class);
|
||||
|
||||
private final BasicMapper mapper;
|
||||
|
||||
private final Mai2UserCharacterRepo userCharacterRepository;
|
||||
|
||||
public CMGetUserCharacterHandler(BasicMapper mapper, Mai2UserCharacterRepo userCharacterRepository) {
|
||||
this.mapper = mapper;
|
||||
this.userCharacterRepository = userCharacterRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
||||
long userId = ((Number) request.get("userId")).longValue();
|
||||
|
||||
List<Mai2UserCharacter> userCharacterList = userCharacterRepository.findByUser_Card_ExtId(userId);
|
||||
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||
resultMap.put("returnCode", 1);
|
||||
resultMap.put("length", userCharacterList.size());
|
||||
resultMap.put("userCharacterList", userCharacterList);
|
||||
|
||||
String json = mapper.write(resultMap);
|
||||
logger.info("Response: " + json);
|
||||
return json;
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.maimai2.handler;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.userdata.Mai2UserDetail;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.Mai2UserDataRepo;
|
||||
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("Maimai2CMGetUserPreviewHandler")
|
||||
public class CMGetUserPreviewHandler implements BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(CMGetUserPreviewHandler.class);
|
||||
|
||||
private final BasicMapper mapper;
|
||||
|
||||
private final Mai2UserDataRepo userDataRepository;
|
||||
|
||||
@Autowired
|
||||
public CMGetUserPreviewHandler(BasicMapper mapper, Mai2UserDataRepo userDataRepository) {
|
||||
this.mapper = mapper;
|
||||
this.userDataRepository = userDataRepository;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
||||
Long userId = ((Number) request.get("userId")).longValue();
|
||||
String segaIdAuthKey = String.valueOf(request.get("segaIdAuthKey"));
|
||||
|
||||
Optional<Mai2UserDetail> userDataOptional = userDataRepository.findByCardExtId(userId);
|
||||
|
||||
if (userDataOptional.isPresent()) {
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||
Mai2UserDetail user = userDataOptional.get();
|
||||
|
||||
resultMap.put("userName", user.getUserName());
|
||||
resultMap.put("rating", user.getPlayerRating());
|
||||
resultMap.put("lastDataVersion", "1.20.00"); //Hardcode due to outdated release
|
||||
resultMap.put("isLogin", false);
|
||||
resultMap.put("isExistSellingCard", false);
|
||||
|
||||
String json = mapper.write(resultMap);
|
||||
logger.info("Response: " + json);
|
||||
return json;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.maimai2.handler;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.Mai2GameChargeRepo;
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.Mai2GameCharge;
|
||||
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("Maimai2GetGameChargeHandler")
|
||||
public class GetGameChargeHandler implements BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GetGameChargeHandler.class);
|
||||
private final Mai2GameChargeRepo gameChargeRepository;
|
||||
private final BasicMapper mapper;
|
||||
|
||||
@Autowired
|
||||
public GetGameChargeHandler(Mai2GameChargeRepo gameChargeRepository, BasicMapper mapper) {
|
||||
this.gameChargeRepository = gameChargeRepository;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
||||
|
||||
List<Mai2GameCharge> gameChargeList = gameChargeRepository.findAll();
|
||||
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||
resultMap.put("length", gameChargeList.size());
|
||||
resultMap.put("gameChargeList", gameChargeList);
|
||||
|
||||
String json = mapper.write(resultMap);
|
||||
logger.info("Response: " + json);
|
||||
return json;
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.maimai2.handler;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
|
||||
import icu.samnyan.aqua.sega.maimai2.model.Mai2GameEventRepo;
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.Mai2GameEvent;
|
||||
import icu.samnyan.aqua.sega.util.jackson.BasicMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component("Maimai2GetGameEventHandler")
|
||||
public class GetGameEventHandler implements BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GetGameEventHandler.class);
|
||||
|
||||
private final Mai2GameEventRepo gameEventRepository;
|
||||
|
||||
private final BasicMapper mapper;
|
||||
|
||||
public GetGameEventHandler(Mai2GameEventRepo gameEventRepository, BasicMapper mapper) {
|
||||
this.gameEventRepository = gameEventRepository;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
||||
int type = ((Number) request.get("type")).intValue();
|
||||
|
||||
// Not sure why maimai2 only do type=1 request
|
||||
List<Mai2GameEvent> gameEventList = gameEventRepository.findByTypeAndEnable(0, true);
|
||||
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||
resultMap.put("type", type);
|
||||
resultMap.put("gameEventList", gameEventList);
|
||||
|
||||
String json = mapper.write(resultMap);
|
||||
logger.info("Response: length " + json.length());
|
||||
return json;
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.maimai2.handler;
|
||||
|
||||
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.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component("Maimai2GetGameNgMusicHandler")
|
||||
public class GetGameNgMusicIdHandler implements BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GetGameNgMusicIdHandler.class);
|
||||
|
||||
private final BasicMapper mapper;
|
||||
|
||||
public GetGameNgMusicIdHandler(BasicMapper mapper) {
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
||||
|
||||
List<Object> musicIdList = new ArrayList<>();
|
||||
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||
resultMap.put("length", 0);
|
||||
resultMap.put("musicIdList", musicIdList);
|
||||
|
||||
String json = mapper.write(resultMap);
|
||||
logger.info("Response: " + json);
|
||||
return json;
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.maimai2.handler;
|
||||
|
||||
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.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component("Maimai2GetGameRankingHandler")
|
||||
public class GetGameRankingHandler implements BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GetGameRankingHandler.class);
|
||||
|
||||
private final BasicMapper mapper;
|
||||
|
||||
public GetGameRankingHandler(BasicMapper mapper) {
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
||||
String type = Integer.toString((int) request.get("type"));
|
||||
|
||||
List<Object> gameRankingList = new ArrayList<>();
|
||||
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||
resultMap.put("type", type);
|
||||
resultMap.put("gameRankingList", gameRankingList);
|
||||
|
||||
String json = mapper.write(resultMap);
|
||||
logger.info("Response: " + json);
|
||||
return json;
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.maimai2.handler;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.response.GetGameSettingResp;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.response.data.GameSetting;
|
||||
import icu.samnyan.aqua.sega.general.dao.PropertyEntryRepository;
|
||||
import icu.samnyan.aqua.sega.general.model.PropertyEntry;
|
||||
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.Map;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component("Maimai2GetGameSettingHandler")
|
||||
public class GetGameSettingHandler implements BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GetGameSettingHandler.class);
|
||||
|
||||
private final BasicMapper mapper;
|
||||
|
||||
private final PropertyEntryRepository propertyEntryRepository;
|
||||
|
||||
@Autowired
|
||||
public GetGameSettingHandler(BasicMapper mapper, PropertyEntryRepository propertyEntryRepository) {
|
||||
this.mapper = mapper;
|
||||
this.propertyEntryRepository = propertyEntryRepository;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
||||
|
||||
PropertyEntry start = propertyEntryRepository.findByPropertyKey("reboot_start_time")
|
||||
.orElseGet(() -> new PropertyEntry("reboot_start_time", "2020-01-01 23:59:00.0"));
|
||||
PropertyEntry end = propertyEntryRepository.findByPropertyKey("reboot_end_time")
|
||||
.orElseGet(() -> new PropertyEntry("reboot_end_time", "2020-01-01 23:59:00.0"));
|
||||
|
||||
GameSetting gameSetting = new GameSetting(
|
||||
false,
|
||||
10,
|
||||
start.getPropertyValue(),
|
||||
end.getPropertyValue(),
|
||||
10000,
|
||||
0,
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
0);
|
||||
|
||||
GetGameSettingResp resp = new GetGameSettingResp(
|
||||
true,
|
||||
gameSetting
|
||||
);
|
||||
|
||||
String json = mapper.write(resp);
|
||||
|
||||
logger.info("Response: " + json);
|
||||
return json;
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.maimai2.handler;
|
||||
|
||||
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.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component("Maimai2GetGameTournamentInfoHandler")
|
||||
public class GetGameTournamentInfoHandler implements BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GetGameTournamentInfoHandler.class);
|
||||
|
||||
//private final GameEventRepository gameEventRepository;
|
||||
|
||||
private final BasicMapper mapper;
|
||||
|
||||
public GetGameTournamentInfoHandler(BasicMapper mapper) {
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
||||
|
||||
List<Object> gameTournamentInfoList = new ArrayList<>();
|
||||
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||
resultMap.put("length", 0);
|
||||
resultMap.put("gameTournamentInfoList", gameTournamentInfoList);
|
||||
|
||||
String json = mapper.write(resultMap);
|
||||
logger.info("Response: " + json);
|
||||
return json;
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.maimai2.handler;
|
||||
|
||||
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.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component("Maimai2GetTransferFriendHandler")
|
||||
public class GetTransferFriendHandler implements BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GetTransferFriendHandler.class);
|
||||
|
||||
private final BasicMapper mapper;
|
||||
|
||||
public GetTransferFriendHandler(BasicMapper mapper) {
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
||||
long userId = ((Number) request.get("userId")).longValue();
|
||||
|
||||
List<Object> transferFriendList = new ArrayList<>();
|
||||
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||
resultMap.put("userId", userId);
|
||||
resultMap.put("transferFriendList", transferFriendList);
|
||||
|
||||
String json = mapper.write(resultMap);
|
||||
logger.info("Response: " + json);
|
||||
return json;
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.maimai2.handler;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
|
||||
import icu.samnyan.aqua.sega.maimai2.model.Mai2UserActRepo;
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.response.data.UserActivity;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.userdata.Mai2UserAct;
|
||||
import icu.samnyan.aqua.sega.util.jackson.BasicMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component("Maimai2GetUserActivityHandler")
|
||||
public class GetUserActivityHandler implements BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GetUserActivityHandler.class);
|
||||
|
||||
private final BasicMapper mapper;
|
||||
|
||||
private final Mai2UserActRepo userActRepository;
|
||||
|
||||
public GetUserActivityHandler(BasicMapper mapper, Mai2UserActRepo userActRepository) {
|
||||
this.mapper = mapper;
|
||||
this.userActRepository = userActRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
||||
long userId = ((Number) request.get("userId")).longValue();
|
||||
|
||||
// kind 1 = playList, kind 2 = musicList
|
||||
// maimaiDX require these two
|
||||
List<Mai2UserAct> userPlayList = userActRepository.findByUser_Card_ExtIdAndKind(userId, 1);
|
||||
List<Mai2UserAct> userMusicList = userActRepository.findByUser_Card_ExtIdAndKind(userId, 2);
|
||||
|
||||
UserActivity userActivity = new UserActivity();
|
||||
userActivity.setMusicList(userMusicList);
|
||||
userActivity.setPlayList(userPlayList);
|
||||
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||
resultMap.put("userActivity", userActivity);
|
||||
|
||||
String json = mapper.write(resultMap);
|
||||
logger.info("Response: " + json);
|
||||
return json;
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.maimai2.handler;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
|
||||
import icu.samnyan.aqua.sega.maimai2.model.Mai2UserCardRepo;
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.userdata.Mai2UserCard;
|
||||
import icu.samnyan.aqua.sega.util.jackson.BasicMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
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("Maimai2GetUserCardHandler")
|
||||
public class GetUserCardHandler implements BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GetUserDataHandler.class);
|
||||
|
||||
private final BasicMapper mapper;
|
||||
|
||||
private final Mai2UserCardRepo userCardRepository;
|
||||
|
||||
public GetUserCardHandler(Mai2UserCardRepo userCardRepository, BasicMapper mapper) {
|
||||
this.mapper = mapper;
|
||||
this.userCardRepository = userCardRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
||||
long userId = ((Number) request.get("userId")).longValue();
|
||||
int nextIndex = ((Number) request.get("nextIndex")).intValue();
|
||||
int maxCount = ((Number) request.get("maxCount")).intValue();
|
||||
|
||||
int pageNum = nextIndex / maxCount;
|
||||
|
||||
Page<Mai2UserCard> dbPage = userCardRepository.findByUser_Card_ExtId(userId, PageRequest.of(pageNum, maxCount));
|
||||
|
||||
int currentIndex = maxCount * pageNum + dbPage.getNumberOfElements();
|
||||
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||
resultMap.put("userId", userId);
|
||||
resultMap.put("nextIndex", dbPage.getNumberOfElements() < maxCount ? 0 : currentIndex);
|
||||
resultMap.put("userCardList", dbPage.getContent());
|
||||
|
||||
String json = mapper.write(resultMap);
|
||||
logger.info("Response: " + json);
|
||||
return json;
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.maimai2.handler;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.util.jackson.BasicMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component("Maimai2GetUserCardPrintErrorHandler")
|
||||
public class GetUserCardPrintErrorHandler implements BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GetUserCardPrintErrorHandler.class);
|
||||
private final BasicMapper mapper;
|
||||
|
||||
@Autowired
|
||||
public GetUserCardPrintErrorHandler(BasicMapper mapper) {
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
||||
Long userId = ((Number) request.get("userId")).longValue();
|
||||
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||
resultMap.put("length", 0);
|
||||
resultMap.put("userPrintDetailList", List.of());
|
||||
|
||||
String json = mapper.write(resultMap);
|
||||
logger.info("Response: " + json);
|
||||
return json;
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.maimai2.handler;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.Mai2UserCharacterRepo;
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.userdata.Mai2UserCharacter;
|
||||
import icu.samnyan.aqua.sega.util.jackson.BasicMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component("Maimai2GetUserCharacterHandler")
|
||||
public class GetUserCharacterHandler implements BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GetUserCharacterHandler.class);
|
||||
|
||||
private final BasicMapper mapper;
|
||||
|
||||
private final Mai2UserCharacterRepo userCharacterRepository;
|
||||
|
||||
public GetUserCharacterHandler(BasicMapper mapper, Mai2UserCharacterRepo userCharacterRepository) {
|
||||
this.mapper = mapper;
|
||||
this.userCharacterRepository = userCharacterRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
||||
long userId = ((Number) request.get("userId")).longValue();
|
||||
|
||||
List<Mai2UserCharacter> userCharacterList = userCharacterRepository.findByUser_Card_ExtId(userId);
|
||||
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||
resultMap.put("userId", userId);
|
||||
resultMap.put("userCharacterList", userCharacterList);
|
||||
|
||||
String json = mapper.write(resultMap);
|
||||
logger.info("Response: length " + json.length());
|
||||
return json;
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.maimai2.handler;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.Mai2UserChargeRepo;
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.userdata.Mai2UserCharge;
|
||||
import icu.samnyan.aqua.sega.util.jackson.BasicMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component("Maimai2GetUserChargeHandler")
|
||||
public class GetUserChargeHandler implements BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GetUserCharacterHandler.class);
|
||||
|
||||
private final BasicMapper mapper;
|
||||
|
||||
private final Mai2UserChargeRepo UserChargeRepository;
|
||||
|
||||
public GetUserChargeHandler(BasicMapper mapper, Mai2UserChargeRepo UserChargeRepository) {
|
||||
this.mapper = mapper;
|
||||
this.UserChargeRepository = UserChargeRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
||||
long userId = ((Number) request.get("userId")).longValue();
|
||||
|
||||
List<Mai2UserCharge> userChargeList = UserChargeRepository.findByUser_Card_ExtId(userId);
|
||||
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||
resultMap.put("userId", userId);
|
||||
resultMap.put("length", userChargeList.size());
|
||||
resultMap.put("userChargeList", userChargeList);
|
||||
|
||||
String json = mapper.write(resultMap);
|
||||
logger.info("Response: " + json);
|
||||
return json;
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.maimai2.handler;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.Mai2UserCourseRepo;
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.userdata.Mai2UserCourse;
|
||||
import icu.samnyan.aqua.sega.util.jackson.BasicMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
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("Maimai2GetUserCourseHandler")
|
||||
public class GetUserCourseHandler implements BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GetUserMusicHandler.class);
|
||||
|
||||
private final BasicMapper mapper;
|
||||
|
||||
private final Mai2UserCourseRepo userCourseRepository;
|
||||
|
||||
public GetUserCourseHandler(BasicMapper mapper, Mai2UserCourseRepo userCourseRepository) {
|
||||
this.mapper = mapper;
|
||||
this.userCourseRepository = userCourseRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
||||
long userId = ((Number) request.get("userId")).longValue();
|
||||
int nextIndexVal = ((Number) request.get("nextIndex")).intValue();
|
||||
|
||||
//TODO: find what game actually wants. Stub value 10 used for now.
|
||||
int maxCount = 10;
|
||||
|
||||
int pageNum = nextIndexVal / maxCount;
|
||||
|
||||
Page<Mai2UserCourse> dbPage = userCourseRepository.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("nextIndex", dbPage.getNumberOfElements() < maxCount ? 0 : currentIndex);
|
||||
|
||||
resultMap.put("userCourseList", dbPage.getContent());
|
||||
|
||||
String json = mapper.write(resultMap);
|
||||
logger.info("Response: " + json);
|
||||
return json;
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.maimai2.handler
|
||||
|
||||
import ext.invoke
|
||||
import ext.minus
|
||||
import ext.toJson
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler
|
||||
import icu.samnyan.aqua.sega.maimai2.model.Mai2Repos
|
||||
import org.slf4j.Logger
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.stereotype.Component
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component("Maimai2GetUserDataHandler")
|
||||
class GetUserDataHandler(val repos: Mai2Repos) : BaseHandler {
|
||||
override fun handle(request: Map<String, Any>): String {
|
||||
val userId = (request["userId"] as Number).toLong()
|
||||
|
||||
val userData = repos.userData.findByCardExtId(userId)() ?: (404 - "User Data Not Found")
|
||||
val resultMap = mapOf(
|
||||
"userId" to userId,
|
||||
"userData" to userData,
|
||||
"banState" to userData.banState
|
||||
)
|
||||
|
||||
val json = resultMap.toJson()
|
||||
logger.info("Response: $json")
|
||||
return json
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val logger = LoggerFactory.getLogger(GetUserDataHandler::class.java)
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.maimai2.handler
|
||||
|
||||
import ext.invoke
|
||||
import ext.minus
|
||||
import ext.toJson
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler
|
||||
import icu.samnyan.aqua.sega.maimai2.model.Mai2Repos
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.stereotype.Component
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component("Maimai2GetUserExtendHandler")
|
||||
class GetUserExtendHandler(val repos: Mai2Repos) : BaseHandler {
|
||||
override fun handle(request: Map<String, Any>): Any {
|
||||
val userId = (request["userId"] as Number).toLong()
|
||||
|
||||
val userExtend = repos.userExtend.findSingleByUser_Card_ExtId(userId)() ?: (404 - "User Extend Not Found")
|
||||
val resultMap = mapOf(
|
||||
"userId" to userId,
|
||||
"userExtend" to userExtend
|
||||
)
|
||||
|
||||
val json = resultMap.toJson()
|
||||
logger.info("Response: $json")
|
||||
return json
|
||||
}
|
||||
|
||||
companion object {
|
||||
val logger = LoggerFactory.getLogger(GetUserExtendHandler::class.java)
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.maimai2.handler;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.Mai2UserFavoriteRepo;
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.userdata.Mai2UserFavorite;
|
||||
import icu.samnyan.aqua.sega.util.jackson.BasicMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component("Maimai2GetUserFavoriteHandler")
|
||||
public class GetUserFavoriteHandler implements BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GetUserFavoriteHandler.class);
|
||||
|
||||
private final BasicMapper mapper;
|
||||
|
||||
private final Mai2UserFavoriteRepo userFavoriteRepository;
|
||||
|
||||
public GetUserFavoriteHandler(BasicMapper mapper, Mai2UserFavoriteRepo userFavoriteRepository) {
|
||||
this.mapper = mapper;
|
||||
this.userFavoriteRepository = userFavoriteRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
||||
long userId = ((Number) request.get("userId")).longValue();
|
||||
int itemKind = ((Number) request.get("itemKind")).intValue();
|
||||
|
||||
List<Mai2UserFavorite> userFavoriteList = userFavoriteRepository.findByUserIdAndItemKind(userId, itemKind);
|
||||
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||
resultMap.put("userId", userId);
|
||||
resultMap.put("userFavoriteData", userFavoriteList);
|
||||
|
||||
String json = mapper.write(resultMap);
|
||||
logger.info("Response: " + json);
|
||||
return json;
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.maimai2.handler;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.response.data.UserFavoriteItem;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.userdata.Mai2UserGeneralData;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.Mai2UserGeneralDataRepo;
|
||||
import icu.samnyan.aqua.sega.general.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(GetUserFavoriteItemHandler.class);
|
||||
|
||||
private final StringMapper mapper;
|
||||
private final Mai2UserGeneralDataRepo userGeneralDataRepository;
|
||||
|
||||
@Autowired
|
||||
public GetUserFavoriteItemHandler(StringMapper mapper, Mai2UserGeneralDataRepo 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<Mai2UserGeneralData> 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 = ((Mai2UserGeneralData) 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,34 @@
|
||||
package icu.samnyan.aqua.sega.maimai2.handler
|
||||
|
||||
import ext.invoke
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler
|
||||
import icu.samnyan.aqua.sega.maimai2.model.Mai2Repos
|
||||
import org.springframework.stereotype.Component
|
||||
import java.util.*
|
||||
|
||||
@Component("Maimai2GetUserFavoriteItemHandler")
|
||||
class GetUserFavoriteItemHandler(val repos: Mai2Repos) : BaseHandler {
|
||||
override fun handle(request: Map<String, Any>): Any {
|
||||
val userId = (request["userId"] as Number).toLong()
|
||||
val kind = (request["kind"] as Number).toInt()
|
||||
|
||||
val items = when (kind) {
|
||||
1 -> repos.userGeneralData.findByUser_Card_ExtIdAndPropertyKey(userId, "favorite_music")
|
||||
2 -> repos.userGeneralData.findByUser_Card_ExtIdAndPropertyKey(userId, "favorite_rival")
|
||||
else -> Optional.empty()
|
||||
}()?.let { fav ->
|
||||
val v = fav.propertyValue
|
||||
if (v.isNotBlank()) v.split(",").dropLastWhile { it.isEmpty() }.mapIndexed { i, record ->
|
||||
mapOf("id" to record.toInt(), "orderId" to i) }
|
||||
else null
|
||||
} ?: emptyList()
|
||||
|
||||
return mapOf(
|
||||
"userId" to userId,
|
||||
"kind" to kind,
|
||||
"length" to items.size,
|
||||
"nextIndex" to 0,
|
||||
"userFavoriteItemList" to items
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.maimai2.handler;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.Mai2UserFriendSeasonRankingRepo;
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.userdata.Mai2UserFriendSeasonRanking;
|
||||
import icu.samnyan.aqua.sega.util.jackson.BasicMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
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("Maimai2GetUserFriendSeasonRankingHandler")
|
||||
public class GetUserFriendSeasonRankingHandler implements BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GetUserFriendSeasonRankingHandler.class);
|
||||
|
||||
private final BasicMapper mapper;
|
||||
|
||||
private final Mai2UserFriendSeasonRankingRepo userFriendSeasonRankingRepository;
|
||||
|
||||
public GetUserFriendSeasonRankingHandler(BasicMapper mapper, Mai2UserFriendSeasonRankingRepo userFriendSeasonRankingRepository) {
|
||||
this.mapper = mapper;
|
||||
this.userFriendSeasonRankingRepository = userFriendSeasonRankingRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
||||
long userId = ((Number) request.get("userId")).longValue();
|
||||
int nextIndexVal = ((Number) request.get("nextIndex")).intValue();
|
||||
int maxCount = ((Number) request.get("maxCount")).intValue();
|
||||
|
||||
int pageNum = nextIndexVal / maxCount;
|
||||
|
||||
Page<Mai2UserFriendSeasonRanking> dbPage = userFriendSeasonRankingRepository.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("nextIndex", dbPage.getNumberOfElements() < maxCount ? 0 : currentIndex);
|
||||
|
||||
resultMap.put("userFriendSeasonRankingList", dbPage.getContent());
|
||||
|
||||
String json = mapper.write(resultMap);
|
||||
logger.info("Response: " + json);
|
||||
return json;
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.maimai2.handler;
|
||||
|
||||
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.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component("Maimai2GetUserGhostHandler")
|
||||
public class GetUserGhostHandler implements BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GetUserDataHandler.class);
|
||||
|
||||
private final BasicMapper mapper;
|
||||
|
||||
public GetUserGhostHandler(BasicMapper mapper) {
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
||||
long userId = ((Number) request.get("userId")).longValue();
|
||||
|
||||
List<Object> userGhostList = new ArrayList<>();
|
||||
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||
resultMap.put("userId", userId);
|
||||
resultMap.put("userGhostList", userGhostList);
|
||||
|
||||
String json = mapper.write(resultMap);
|
||||
logger.info("Response: " + json);
|
||||
return json;
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.maimai2.handler
|
||||
|
||||
import ext.toJson
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler
|
||||
import icu.samnyan.aqua.sega.maimai2.model.Mai2Repos
|
||||
import org.slf4j.Logger
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.stereotype.Component
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component("Maimai2GetUserLoginBonusHandler")
|
||||
class GetUserLoginBonusHandler(val repos: Mai2Repos) : BaseHandler {
|
||||
override fun handle(request: Map<String, Any>): String {
|
||||
val userId = (request["userId"] as Number).toLong()
|
||||
|
||||
val resultMap = mapOf(
|
||||
"userId" to userId,
|
||||
"nextIndex" to 0,
|
||||
"userLoginBonusList" to repos.userLoginBonus.findByUser_Card_ExtId(userId)
|
||||
)
|
||||
|
||||
val json = resultMap.toJson()
|
||||
logger.info("Response: $json")
|
||||
return json
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val logger = LoggerFactory.getLogger(GetUserLoginBonusHandler::class.java)
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.maimai2.handler
|
||||
|
||||
import ext.toJson
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler
|
||||
import icu.samnyan.aqua.sega.maimai2.model.Mai2Repos
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.stereotype.Component
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component("Maimai2GetUserMapHandler")
|
||||
class GetUserMapHandler(val repos: Mai2Repos) : BaseHandler {
|
||||
override fun handle(request: Map<String, Any>): String {
|
||||
val userId = (request["userId"] as Number).toLong()
|
||||
|
||||
val resultMap = mapOf(
|
||||
"userId" to userId,
|
||||
"nextIndex" to 0,
|
||||
"userMapList" to repos.userMap.findByUser_Card_ExtId(userId)
|
||||
)
|
||||
|
||||
val json = resultMap.toJson()
|
||||
logger.info("Response: $json")
|
||||
return json
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val logger = LoggerFactory.getLogger(GetUserMapHandler::class.java)
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.maimai2.handler
|
||||
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler
|
||||
import icu.samnyan.aqua.sega.maimai2.model.Mai2Repos
|
||||
import icu.samnyan.aqua.sega.util.jackson.BasicMapper
|
||||
import org.slf4j.Logger
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.stereotype.Component
|
||||
|
||||
@Component("Maimai2GetUserMusicHandler")
|
||||
class GetUserMusicHandler(
|
||||
val mapper: BasicMapper,
|
||||
val repos: Mai2Repos
|
||||
) : BaseHandler {
|
||||
override fun handle(request: Map<String, Any>): Any {
|
||||
val userId = (request["userId"] as Number).toLong()
|
||||
|
||||
val db = repos.userMusicDetail.findByUser_Card_ExtId(userId)
|
||||
|
||||
logger.info("Response: ${db.size} music records")
|
||||
return mapOf(
|
||||
"userId" to userId,
|
||||
"nextIndex" to 0,
|
||||
"userMusicList" to listOf(mapOf("userMusicDetailList" to db))
|
||||
)
|
||||
}
|
||||
|
||||
companion object {
|
||||
val logger = LoggerFactory.getLogger(GetUserMusicHandler::class.java)
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.maimai2.handler;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.Mai2UserOptionRepo;
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.userdata.Mai2UserOption;
|
||||
import icu.samnyan.aqua.sega.util.jackson.BasicMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component("Maimai2GetUserOptionHandler")
|
||||
public class GetUserOptionHandler implements BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GetUserOptionHandler.class);
|
||||
|
||||
private final BasicMapper mapper;
|
||||
|
||||
private final Mai2UserOptionRepo userOptionRepository;
|
||||
|
||||
public GetUserOptionHandler(BasicMapper mapper, Mai2UserOptionRepo userOptionRepository) {
|
||||
this.mapper = mapper;
|
||||
this.userOptionRepository = userOptionRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
||||
long userId = ((Number) request.get("userId")).longValue();
|
||||
|
||||
Mai2UserOption userOption = userOptionRepository.findSingleByUser_Card_ExtId(userId).orElseThrow();
|
||||
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||
resultMap.put("userId", userId);
|
||||
resultMap.put("userOption", userOption);
|
||||
|
||||
String json = mapper.write(resultMap);
|
||||
logger.info("Response: " + json);
|
||||
return json;
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.maimai2.handler;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.Mai2UserDataRepo;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.Mai2UserOptionRepo;
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.response.GetUserPreviewResp;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.userdata.Mai2UserDetail;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.userdata.Mai2UserOption;
|
||||
import icu.samnyan.aqua.sega.util.jackson.BasicMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component("Maimai2GetUserPreviewHandler")
|
||||
public class GetUserPreviewHandler implements BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GetUserPreviewHandler.class);
|
||||
|
||||
private final BasicMapper mapper;
|
||||
|
||||
private final Mai2UserDataRepo userDataRepository;
|
||||
private final Mai2UserOptionRepo userOptionRepository;
|
||||
|
||||
public GetUserPreviewHandler(BasicMapper mapper, Mai2UserDataRepo userDataRepository, Mai2UserOptionRepo userOptionRepository) {
|
||||
this.mapper = mapper;
|
||||
this.userDataRepository = userDataRepository;
|
||||
this.userOptionRepository = userOptionRepository;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
||||
long userId = ((Number) request.get("userId")).longValue();
|
||||
|
||||
Optional<Mai2UserDetail> userDataOptional = userDataRepository.findByCardExtId(userId);
|
||||
|
||||
GetUserPreviewResp resp = new GetUserPreviewResp();
|
||||
resp.setUserId(userId);
|
||||
String json;
|
||||
if (userDataOptional.isPresent() && userDataOptional.get().getUserName() != null) {
|
||||
Mai2UserDetail user = userDataOptional.get();
|
||||
Optional<Mai2UserOption> userOptionOptional = userOptionRepository.findSingleByUser_Card_ExtId(userId);
|
||||
resp.setUserName(user.getUserName());
|
||||
resp.setLogin(false);
|
||||
resp.setLastGameId(user.getLastGameId());
|
||||
resp.setLastDataVersion(user.getLastDataVersion());
|
||||
resp.setLastRomVersion(user.getLastRomVersion());
|
||||
resp.setLastLoginDate(user.getLastPlayDate());
|
||||
resp.setLastPlayDate(user.getLastPlayDate());
|
||||
resp.setPlayerRating(user.getPlayerRating());
|
||||
resp.setNameplateId(user.getPlateId());
|
||||
resp.setIconId(user.getIconId());
|
||||
resp.setTrophyId(0);
|
||||
resp.setPartnerId(user.getPartnerId());
|
||||
resp.setFrameId(user.getFrameId());
|
||||
resp.setTotalAwake(user.getTotalAwake());
|
||||
resp.setIsNetMember(user.isNetMember());
|
||||
resp.setDailyBonusDate(user.getDailyBonusDate());
|
||||
if (userOptionOptional.isPresent()) {
|
||||
Mai2UserOption option = userOptionOptional.get();
|
||||
resp.setHeadPhoneVolume(option.getHeadPhoneVolume());
|
||||
resp.setDispRate(option.getDispRate());
|
||||
}
|
||||
resp.setInherit(false);
|
||||
resp.setBanState(user.getBanState());
|
||||
|
||||
json = mapper.write(resp);
|
||||
} else {
|
||||
json = "{}";
|
||||
}
|
||||
|
||||
logger.info("Response: " + json);
|
||||
return json;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package icu.samnyan.aqua.sega.maimai2.handler
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException
|
||||
import ext.invoke
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler
|
||||
import icu.samnyan.aqua.sega.maimai2.model.Mai2Repos
|
||||
@@ -8,10 +7,7 @@ import icu.samnyan.aqua.sega.maimai2.model.response.data.UserRating
|
||||
import icu.samnyan.aqua.sega.maimai2.model.userdata.Mai2UserRate
|
||||
import icu.samnyan.aqua.sega.maimai2.model.userdata.Mai2UserUdemae
|
||||
import icu.samnyan.aqua.sega.util.jackson.BasicMapper
|
||||
import org.slf4j.Logger
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.stereotype.Component
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
@@ -21,8 +17,7 @@ class GetUserRatingHandler(
|
||||
val mapper: BasicMapper,
|
||||
val repos: Mai2Repos
|
||||
) : BaseHandler {
|
||||
@Throws(JsonProcessingException::class)
|
||||
override fun handle(request: Map<String, Any>): String {
|
||||
override fun handle(request: Map<String, Any>): Any {
|
||||
val userId = (request["userId"] as Number?)!!.toLong()
|
||||
val empty: List<Mai2UserRate> = ArrayList()
|
||||
|
||||
@@ -48,22 +43,14 @@ class GetUserRatingHandler(
|
||||
|
||||
ur.udemae = repos.userUdemae.findSingleByUser_Card_ExtId(userId)() ?: Mai2UserUdemae()
|
||||
|
||||
val resultMap = mapOf(
|
||||
return mapOf(
|
||||
"userId" to userId,
|
||||
"userRating" to ur
|
||||
)
|
||||
|
||||
val json = mapper.write(resultMap)
|
||||
logger.info("Response: $json")
|
||||
return json
|
||||
}
|
||||
|
||||
fun loadRateData(value: String) = value.split(",").filter { it.isNotBlank() }.map {
|
||||
val (musicId, level, beforeRating, afterRating) = it.split(":")
|
||||
Mai2UserRate(musicId.toInt(), level.toInt(), beforeRating.toInt(), afterRating.toInt())
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val logger: Logger = LoggerFactory.getLogger(GetUserRatingHandler::class.java)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.maimai2.handler;
|
||||
|
||||
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.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component("Maimai2GetUserRecommendRateMusicHandler")
|
||||
public class GetUserRecommendRateMusicHandler implements BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GetUserDataHandler.class);
|
||||
|
||||
private final BasicMapper mapper;
|
||||
|
||||
public GetUserRecommendRateMusicHandler(BasicMapper mapper) {
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
||||
long userId = ((Number) request.get("userId")).longValue();
|
||||
|
||||
List<Object> userRecommendRateMusicIdList = new ArrayList<>();
|
||||
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||
resultMap.put("userId", userId);
|
||||
resultMap.put("userRecommendRateMusicIdList", userRecommendRateMusicIdList);
|
||||
|
||||
String json = mapper.write(resultMap);
|
||||
logger.info("Response: " + json);
|
||||
return json;
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.maimai2.handler;
|
||||
|
||||
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.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component("Maimai2GetUserRecommendSelectMusicHandler")
|
||||
public class GetUserRecommendSelectMusicHandler implements BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GetUserDataHandler.class);
|
||||
|
||||
private final BasicMapper mapper;
|
||||
|
||||
public GetUserRecommendSelectMusicHandler(BasicMapper mapper) {
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
||||
long userId = ((Number) request.get("userId")).longValue();
|
||||
|
||||
List<Object> userRecommendSelectionMusicIdList = new ArrayList<>();
|
||||
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||
resultMap.put("userId", userId);
|
||||
resultMap.put("userRecommendSelectionMusicIdList", userRecommendSelectionMusicIdList);
|
||||
|
||||
String json = mapper.write(resultMap);
|
||||
logger.info("Response: " + json);
|
||||
return json;
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.maimai2.handler;
|
||||
|
||||
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.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component("Maimai2GetUserRegionHandler")
|
||||
public class GetUserRegionHandler implements BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GetUserDataHandler.class);
|
||||
|
||||
private final BasicMapper mapper;
|
||||
|
||||
public GetUserRegionHandler(BasicMapper mapper) {
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
||||
long userId = ((Number) request.get("userId")).longValue();
|
||||
|
||||
List<Object> userRegionList = new ArrayList<>();
|
||||
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||
resultMap.put("userId", userId);
|
||||
resultMap.put("length", 0);
|
||||
resultMap.put("userRegionList", userRegionList);
|
||||
|
||||
String json = mapper.write(resultMap);
|
||||
logger.info("Response: " + json);
|
||||
return json;
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package icu.samnyan.aqua.sega.maimai2.handler;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
||||
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.model.Mai2UserDataRepo;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.response.data.UserRivalData;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.userdata.Mai2UserDetail;
|
||||
import icu.samnyan.aqua.sega.util.jackson.StringMapper;
|
||||
|
||||
@Component("Maimai2GetUserRivalDataHandler")
|
||||
public class GetUserRivalDataHandler implements BaseHandler {
|
||||
private static final Logger logger = LoggerFactory
|
||||
.getLogger(GetUserRivalDataHandler.class);
|
||||
|
||||
private final StringMapper mapper;
|
||||
private final Mai2UserDataRepo userDataRepository;
|
||||
|
||||
@Autowired
|
||||
public GetUserRivalDataHandler(StringMapper mapper, Mai2UserDataRepo 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<Mai2UserDetail> detailOptional = userDataRepository.findByCardExtId(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,24 @@
|
||||
package icu.samnyan.aqua.sega.maimai2.handler
|
||||
|
||||
import ext.invoke
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler
|
||||
import icu.samnyan.aqua.sega.maimai2.model.Mai2Repos
|
||||
import org.slf4j.Logger
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.stereotype.Component
|
||||
|
||||
@Component("Maimai2GetUserRivalDataHandler")
|
||||
class GetUserRivalDataHandler(val repos: Mai2Repos) : BaseHandler {
|
||||
override fun handle(request: Map<String, Any>): Any {
|
||||
val userId = (request["userId"] as Number).toLong()
|
||||
val rivalId = (request["rivalId"] as Number).toLong()
|
||||
|
||||
return mapOf(
|
||||
"userId" to userId,
|
||||
"userRivalData" to mapOf(
|
||||
"rivalId" to rivalId,
|
||||
"rivalName" to (repos.userData.findByCardExtId(rivalId)()?.userName ?: "")
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -39,8 +39,8 @@ public class GetUserRivalMusicHandler implements BaseHandler {
|
||||
long rivalId = ((Number) request.get("rivalId")).intValue();
|
||||
|
||||
List<Mai2UserMusicDetail> details = userMusicDetailRepository.findByUser_Card_ExtId(rivalId);
|
||||
List<UserRivalMusic> userRivalMusicList = new LinkedList<UserRivalMusic>();
|
||||
Map<Integer, UserRivalMusic> userRivalMusicMap = new HashMap<Integer, UserRivalMusic>();
|
||||
List<UserRivalMusic> userRivalMusicList = new LinkedList<>();
|
||||
Map<Integer, UserRivalMusic> userRivalMusicMap = new HashMap<>();
|
||||
for (Mai2UserMusicDetail detail : details) {
|
||||
int musicId = detail.getMusicId();
|
||||
UserRivalMusic info = userRivalMusicMap.getOrDefault(musicId, null);
|
||||
@@ -61,8 +61,6 @@ public class GetUserRivalMusicHandler implements BaseHandler {
|
||||
resultMap.put("nextIndex", 0);
|
||||
resultMap.put("userRivalMusicList", userRivalMusicList);
|
||||
|
||||
String json = this.mapper.write(resultMap);
|
||||
logger.info("Response: " + json);
|
||||
return json;
|
||||
return mapper.write(resultMap);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import icu.samnyan.aqua.sega.maimai2.model.userdata.Mai2UserCard;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.userdata.Mai2UserDetail;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.userdata.Mai2UserPrintDetail;
|
||||
import icu.samnyan.aqua.sega.util.jackson.BasicMapper;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -24,6 +25,7 @@ import java.util.Optional;
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component("Maimai2UpsertUserPrintHandler")
|
||||
@AllArgsConstructor
|
||||
public class UpsertUserPrintHandler implements BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(UpsertUserPrintHandler.class);
|
||||
@@ -33,14 +35,6 @@ public class UpsertUserPrintHandler implements BaseHandler {
|
||||
private final Mai2UserPrintDetailRepo userPrintDetailRepository;
|
||||
private final Mai2UserDataRepo userDataRepository;
|
||||
|
||||
@Autowired
|
||||
public UpsertUserPrintHandler(BasicMapper mapper, Mai2UserPrintDetailRepo userPrintDetailRepository, Mai2UserCardRepo userCardRepository, Mai2UserDataRepo userDataRepository) {
|
||||
this.mapper = mapper;
|
||||
this.userPrintDetailRepository = userPrintDetailRepository;
|
||||
this.userCardRepository = userCardRepository;
|
||||
this.userDataRepository = userDataRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
||||
long userId = ((Number) request.get("userId")).longValue();
|
||||
@@ -83,8 +77,6 @@ public class UpsertUserPrintHandler implements BaseHandler {
|
||||
resultMap.put("startDate", "2019-01-01 00:00:00.000000");
|
||||
resultMap.put("endDate", "2029-01-01 00:00:00.000000");
|
||||
|
||||
String json = mapper.write(resultMap);
|
||||
logger.info("Response: " + json);
|
||||
return json;
|
||||
return mapper.write(resultMap);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package icu.samnyan.aqua.sega.maimai2.handler;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface UserReqHandler extends BaseHandler {
|
||||
@Override
|
||||
default Object handle(Map<String, Object> request) throws JsonProcessingException {
|
||||
var userId = ((Number) request.get("userId")).longValue();
|
||||
return handleThis(request, userId);
|
||||
}
|
||||
|
||||
Object handleThis(Map<String, Object> request, Long userId) throws JsonProcessingException;
|
||||
}
|
||||
Reference in New Issue
Block a user