mirror of https://github.com/hykilpikonna/AquaDX
[cardmaker] Add experimental maimai2 support
parent
7bfd51c1bd
commit
30b9ab73da
|
@ -47,6 +47,11 @@ public class Maimai2ServletController {
|
|||
private final UploadUserPlaylogHandler uploadUserPlaylogHandler;
|
||||
private final GetGameNgMusicIdHandler getGameNgMusicIdHandler;
|
||||
private final GetUserFriendSeasonRankingHandler getUserFriendSeasonRankingHandler;
|
||||
private final CMGetUserPreviewHandler cmGetUserPreviewHandler;
|
||||
private final CMGetSellingCardHandler cmGetSellingCardHandler;
|
||||
private final GetUserCardPrintErrorHandler getUserCardPrintErrorHandler;
|
||||
private final CMGetUserCharacterHandler cmGetUserCharacterHandler;
|
||||
private final UpsertUserPrintHandler upsertUserPrintHandler;
|
||||
|
||||
public Maimai2ServletController(GetGameSettingHandler getGameSettingHandler, GetGameEventHandler getGameEventHandler, GetGameRankingHandler getGameRankingHandler, GetGameTournamentInfoHandler getGameTournamentInfoHandler,
|
||||
GetTransferFriendHandler getTransferFriendHandler, GetUserActivityHandler getUserActivityHandler, UserLoginHandler userLoginHandler, UserLogoutHandler userLogoutHandler,
|
||||
|
@ -55,7 +60,9 @@ public class Maimai2ServletController {
|
|||
GetUserLoginBonusHandler getUserLoginBonusHandler, GetUserMapHandler getUserMapHandler, GetUserFavoriteHandler getUserFavoriteHandler,
|
||||
GetUserCardHandler getUserCardHandler, GetUserMusicHandler getUserMusicHandler, GetUserRatingHandler getUserRatingHandler, GetUserRegionHandler getUserRegionHandler,
|
||||
GetGameChargeHandler getGameChargeHandler, GetUserChargeHandler getUserChargeHandler, GetUserCourseHandler getUserCourseHandler, UploadUserPhotoHandler uploadUserPhotoHandler,
|
||||
UploadUserPlaylogHandler uploadUserPlaylogHandler, GetGameNgMusicIdHandler getGameNgMusicIdHandler, GetUserFriendSeasonRankingHandler getUserFriendSeasonRankingHandler) {
|
||||
UploadUserPlaylogHandler uploadUserPlaylogHandler, GetGameNgMusicIdHandler getGameNgMusicIdHandler, GetUserFriendSeasonRankingHandler getUserFriendSeasonRankingHandler,
|
||||
CMGetUserPreviewHandler cmGetUserPreviewHandler, CMGetSellingCardHandler cmGetSellingCardHandler, GetUserCardPrintErrorHandler getUserCardPrintErrorHandler, CMGetUserCharacterHandler cmGetUserCharacterHandler,
|
||||
UpsertUserPrintHandler upsertUserPrintHandler) {
|
||||
this.getGameSettingHandler = getGameSettingHandler;
|
||||
this.getGameEventHandler = getGameEventHandler;
|
||||
this.getGameRankingHandler = getGameRankingHandler;
|
||||
|
@ -86,6 +93,11 @@ public class Maimai2ServletController {
|
|||
this.uploadUserPlaylogHandler = uploadUserPlaylogHandler;
|
||||
this.getGameNgMusicIdHandler = getGameNgMusicIdHandler;
|
||||
this.getUserFriendSeasonRankingHandler = getUserFriendSeasonRankingHandler;
|
||||
this.cmGetUserPreviewHandler = cmGetUserPreviewHandler;
|
||||
this.cmGetSellingCardHandler = cmGetSellingCardHandler;
|
||||
this.getUserCardPrintErrorHandler = getUserCardPrintErrorHandler;
|
||||
this.cmGetUserCharacterHandler = cmGetUserCharacterHandler;
|
||||
this.upsertUserPrintHandler = upsertUserPrintHandler;
|
||||
}
|
||||
|
||||
// Mandatory for boot
|
||||
|
@ -120,7 +132,6 @@ public class Maimai2ServletController {
|
|||
return getUserActivityHandler.handle(request);
|
||||
}
|
||||
|
||||
// maybe releated DX Pass? return empty
|
||||
@PostMapping("GetUserCardApi")
|
||||
public String getUserCardHandler(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
||||
return getUserCardHandler.handle(request);
|
||||
|
@ -294,4 +305,65 @@ public class Maimai2ServletController {
|
|||
return "{\"returnCode\":\"1\"}";
|
||||
}
|
||||
|
||||
// CardMaker APIs
|
||||
@PostMapping("CMGetSellingCardApi")
|
||||
String cmGetSellingCard(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
||||
return cmGetSellingCardHandler.handle(request);
|
||||
}
|
||||
|
||||
@PostMapping("CMGetUserCardApi")
|
||||
String cmGetUserCard(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
||||
return getUserCardHandler.handle(request);
|
||||
}
|
||||
|
||||
@PostMapping("CMGetUserCardPrintErrorApi")
|
||||
String cmGetUserCardPrintError(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
||||
return getUserCardPrintErrorHandler.handle(request);
|
||||
}
|
||||
|
||||
@PostMapping("CMGetUserCharacterApi")
|
||||
String cmGetUserCharacter(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
||||
return cmGetUserCharacterHandler.handle(request);
|
||||
}
|
||||
|
||||
@PostMapping("CMGetUserDataApi")
|
||||
String cmGetUserData(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
||||
return getUserDataHandler.handle(request);
|
||||
}
|
||||
|
||||
@PostMapping("CMGetUserItemApi")
|
||||
String cmGetUserItem(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
||||
return getUserItemHandler.handle(request);
|
||||
}
|
||||
|
||||
@PostMapping("CMGetUserPreviewApi")
|
||||
String cmGetUserPreview(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
||||
return cmGetUserPreviewHandler.handle(request);
|
||||
}
|
||||
|
||||
@PostMapping("CMLoginApi")
|
||||
String cmLoginApi(@ModelAttribute Map<String, Object> request) {
|
||||
return "{\"returnCode\":\"1\"}";
|
||||
}
|
||||
|
||||
@PostMapping("CMLogoutApi")
|
||||
String cmLogoutApi(@ModelAttribute Map<String, Object> request) {
|
||||
return "{\"returnCode\":\"1\"}";
|
||||
}
|
||||
|
||||
@PostMapping("CMUpsertBuyCardApi")
|
||||
String cmUpsertBuyCard(@ModelAttribute Map<String, Object> request) {
|
||||
return "{\"returnCode\":\"1\"}";
|
||||
}
|
||||
|
||||
@PostMapping("CMUpsertUserPrintApi")
|
||||
String cmUpsertUserPrint(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
|
||||
return upsertUserPrintHandler.handle(request);
|
||||
}
|
||||
|
||||
@PostMapping("CMUpsertUserPrintlogApi")
|
||||
String cmUpsertUserPrintlog(@ModelAttribute Map<String, Object> request) {
|
||||
return "{\"returnCode\":\"1\", \"orderId\":\"0\", \"serialId\":\"FAKECARDIMAG12345678\"}";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package icu.samnyan.aqua.sega.maimai2.dao.gamedata;
|
||||
|
||||
import icu.samnyan.aqua.sega.maimai2.model.gamedata.GameSellingCard;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Repository("Maimai2GameSellingCardRepository")
|
||||
public interface GameSellingCardRepository extends JpaRepository<GameSellingCard, Long> {
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package icu.samnyan.aqua.sega.maimai2.dao.userdata;
|
||||
|
||||
import icu.samnyan.aqua.sega.maimai2.model.userdata.UserDetail;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.userdata.UserCard;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Repository("Maimai2UserCardRepository")
|
||||
public interface UserCardRepository extends JpaRepository<UserCard, Long> {
|
||||
|
||||
Optional<UserCard> findByUserAndCardId(UserDetail user, int cardId);
|
||||
|
||||
Page<UserCard> findByUser_Card_ExtId(long userId, Pageable page);
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package icu.samnyan.aqua.sega.maimai2.dao.userdata;
|
||||
|
||||
import icu.samnyan.aqua.sega.maimai2.model.userdata.UserPrintDetail;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Repository("Maimai2UserPrintDetailRepository")
|
||||
public interface UserPrintDetailRepository extends JpaRepository<UserPrintDetail, Long> {
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package icu.samnyan.aqua.sega.maimai2.handler.impl;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
|
||||
import icu.samnyan.aqua.sega.maimai2.dao.gamedata.GameSellingCardRepository;
|
||||
import icu.samnyan.aqua.sega.maimai2.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.gamedata.GameSellingCard;
|
||||
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 GameSellingCardRepository gameSellingCardRepository;
|
||||
private final BasicMapper mapper;
|
||||
|
||||
@Autowired
|
||||
public CMGetSellingCardHandler(GameSellingCardRepository gameSellingCardRepository, BasicMapper mapper) {
|
||||
this.gameSellingCardRepository = gameSellingCardRepository;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
||||
|
||||
List<GameSellingCard> 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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package icu.samnyan.aqua.sega.maimai2.handler.impl;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import icu.samnyan.aqua.sega.maimai2.dao.userdata.UserCharacterRepository;
|
||||
import icu.samnyan.aqua.sega.maimai2.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.userdata.UserCharacter;
|
||||
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 UserCharacterRepository userCharacterRepository;
|
||||
|
||||
public CMGetUserCharacterHandler(BasicMapper mapper, UserCharacterRepository 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<UserCharacter> 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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package icu.samnyan.aqua.sega.maimai2.handler.impl;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import icu.samnyan.aqua.sega.maimai2.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.userdata.UserDetail;
|
||||
import icu.samnyan.aqua.sega.maimai2.dao.userdata.UserDataRepository;
|
||||
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 UserDataRepository userDataRepository;
|
||||
|
||||
@Autowired
|
||||
public CMGetUserPreviewHandler(BasicMapper mapper, UserDataRepository 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<UserDetail> userDataOptional = userDataRepository.findByCard_ExtId(userId);
|
||||
|
||||
if (userDataOptional.isPresent()) {
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||
UserDetail 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,15 +1,18 @@
|
|||
package icu.samnyan.aqua.sega.maimai2.handler.impl;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
|
||||
import icu.samnyan.aqua.sega.maimai2.dao.userdata.UserCardRepository;
|
||||
import icu.samnyan.aqua.sega.maimai2.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.userdata.UserCard;
|
||||
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.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
@ -22,20 +25,29 @@ public class GetUserCardHandler implements BaseHandler {
|
|||
|
||||
private final BasicMapper mapper;
|
||||
|
||||
public GetUserCardHandler(BasicMapper mapper) {
|
||||
private final UserCardRepository userCardRepository;
|
||||
|
||||
public GetUserCardHandler(UserCardRepository 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();
|
||||
|
||||
List<Object> userCardList = new ArrayList<>();
|
||||
int pageNum = nextIndex / maxCount;
|
||||
|
||||
Page<UserCard> 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", 0);
|
||||
resultMap.put("userCardList", userCardList);
|
||||
resultMap.put("nextIndex", dbPage.getNumberOfElements() < maxCount ? 0 : currentIndex);
|
||||
resultMap.put("userCardList", dbPage.getContent());
|
||||
|
||||
String json = mapper.write(resultMap);
|
||||
logger.info("Response: " + json);
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
package icu.samnyan.aqua.sega.maimai2.handler.impl;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
|
||||
import icu.samnyan.aqua.sega.maimai2.handler.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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
package icu.samnyan.aqua.sega.maimai2.handler.impl;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
|
||||
import icu.samnyan.aqua.sega.maimai2.dao.userdata.UserCardRepository;
|
||||
import icu.samnyan.aqua.sega.maimai2.dao.userdata.UserDataRepository;
|
||||
import icu.samnyan.aqua.sega.maimai2.dao.userdata.UserPrintDetailRepository;
|
||||
import icu.samnyan.aqua.sega.maimai2.handler.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.request.UpsertUserPrint;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.userdata.UserCard;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.userdata.UserDetail;
|
||||
import icu.samnyan.aqua.sega.maimai2.model.userdata.UserPrintDetail;
|
||||
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("Maimai2UpsertUserPrintHandler")
|
||||
public class UpsertUserPrintHandler implements BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(UpsertUserPrintHandler.class);
|
||||
private final BasicMapper mapper;
|
||||
|
||||
private final UserCardRepository userCardRepository;
|
||||
private final UserPrintDetailRepository userPrintDetailRepository;
|
||||
private final UserDataRepository userDataRepository;
|
||||
|
||||
@Autowired
|
||||
public UpsertUserPrintHandler(BasicMapper mapper, UserPrintDetailRepository userPrintDetailRepository, UserCardRepository userCardRepository, UserDataRepository 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();
|
||||
|
||||
UserDetail userData;
|
||||
|
||||
Optional<UserDetail> userOptional = userDataRepository.findByCard_ExtId(userId);
|
||||
if (userOptional.isPresent()) {
|
||||
userData = userOptional.get();
|
||||
} else {
|
||||
logger.error("User not found. userId: {}", userId);
|
||||
return null;
|
||||
}
|
||||
|
||||
UpsertUserPrint upsertUserPrint = mapper.convert(request, UpsertUserPrint.class);
|
||||
|
||||
UserPrintDetail userPrintDetail = upsertUserPrint.getUserPrintDetail();
|
||||
UserCard newUserCard = userPrintDetail.getUserCard();
|
||||
|
||||
newUserCard.setUser(userData);
|
||||
userPrintDetail.setUser(userData);
|
||||
|
||||
newUserCard.setStartDate("2019-01-01 00:00:00.000000");
|
||||
newUserCard.setEndDate("2029-01-01 00:00:00.000000");
|
||||
userPrintDetail.setSerialId("FAKECARDIMAG12345678");
|
||||
|
||||
Optional<UserCard> userCardOptional = userCardRepository.findByUserAndCardId(newUserCard.getUser(), newUserCard.getCardId());
|
||||
if (userCardOptional.isPresent()) {
|
||||
UserCard userCard = userCardOptional.get();
|
||||
newUserCard.setId(userCard.getId());
|
||||
}
|
||||
|
||||
userCardRepository.save(newUserCard);
|
||||
userPrintDetailRepository.save(userPrintDetail);
|
||||
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||
resultMap.put("returnCode", 1);
|
||||
resultMap.put("orderId", 0);
|
||||
resultMap.put("serialId", "FAKECARDIMAG12345678");
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package icu.samnyan.aqua.sega.maimai2.model.gamedata;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Entity(name = "Maimai2GameSellingCard")
|
||||
@Table(name = "maimai2_game_selling_card")
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class GameSellingCard implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@JsonIgnore
|
||||
private int id;
|
||||
private int cardId;
|
||||
private LocalDateTime startDate;
|
||||
private LocalDateTime endDate;
|
||||
private LocalDateTime noticeStartDate;
|
||||
private LocalDateTime noticeEndDate;
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package icu.samnyan.aqua.sega.maimai2.model.request;
|
||||
|
||||
import icu.samnyan.aqua.sega.maimai2.model.userdata.UserPrintDetail;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class UpsertUserPrint implements Serializable {
|
||||
private long userId;
|
||||
private long orderId;
|
||||
private Map<String, Object> userPrintReserve;
|
||||
private UserPrintDetail userPrintDetail;
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package icu.samnyan.aqua.sega.maimai2.model.userdata;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Entity(name = "Maimai2UserCard")
|
||||
@Table(name = "maimai2_user_card")
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class UserCard implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@JsonIgnore
|
||||
private long id;
|
||||
|
||||
@JsonIgnore
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "user_id")
|
||||
private UserDetail user;
|
||||
|
||||
public int cardId;
|
||||
public int cardTypeId;
|
||||
public int charaId;
|
||||
public int mapId;
|
||||
public String startDate;
|
||||
public String endDate;
|
||||
|
||||
public UserCard(UserDetail user) {
|
||||
this.user = user;
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@ import lombok.NoArgsConstructor;
|
|||
import javax.persistence.*;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
@ -31,7 +32,22 @@ public class UserCharacter implements Serializable {
|
|||
private UserDetail user;
|
||||
|
||||
private int characterId;
|
||||
@JsonInclude
|
||||
@Transient
|
||||
private int point = 0;
|
||||
@JsonInclude
|
||||
@Transient
|
||||
private int count = 0;
|
||||
private int level;
|
||||
@JsonInclude
|
||||
@Transient
|
||||
private int nextAwake = 0;
|
||||
@JsonInclude
|
||||
@Transient
|
||||
private int nextAwakePercent = 0;
|
||||
@JsonInclude
|
||||
@Transient
|
||||
private boolean favorite = false;
|
||||
private int awakening;
|
||||
private int useCount;
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.util.List;
|
|||
import javax.persistence.*;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
|
||||
|
@ -39,8 +40,17 @@ public class UserDetail implements Serializable {
|
|||
private Card card;
|
||||
|
||||
private String userName;
|
||||
@JsonInclude
|
||||
@Transient
|
||||
private String friendCode = "";
|
||||
private int isNetMember;
|
||||
@JsonInclude
|
||||
@Transient
|
||||
private int nameplateId = 0;
|
||||
private int iconId;
|
||||
@JsonInclude
|
||||
@Transient
|
||||
private int trophyId = 0;
|
||||
private int plateId;
|
||||
private int titleId;
|
||||
private int partnerId;
|
||||
|
@ -102,6 +112,24 @@ public class UserDetail implements Serializable {
|
|||
private long totalExpertDeluxscore;
|
||||
private long totalMasterDeluxscore;
|
||||
private long totalReMasterDeluxscore;
|
||||
@JsonInclude
|
||||
@Transient
|
||||
private long totalHiscore = 0;
|
||||
@JsonInclude
|
||||
@Transient
|
||||
private long totalBasicHighscore = 0;
|
||||
@JsonInclude
|
||||
@Transient
|
||||
private long totalAdvancedHighscore = 0;
|
||||
@JsonInclude
|
||||
@Transient
|
||||
private long totalExpertHighscore = 0;
|
||||
@JsonInclude
|
||||
@Transient
|
||||
private long totalMasterHighscore = 0;
|
||||
@JsonInclude
|
||||
@Transient
|
||||
private long totalReMasterHighscore = 0;
|
||||
private int totalSync;
|
||||
private int totalBasicSync;
|
||||
private int totalAdvancedSync;
|
||||
|
@ -118,4 +146,10 @@ public class UserDetail implements Serializable {
|
|||
private long playerNewRating;
|
||||
private int banState;
|
||||
private long dateTime;
|
||||
@JsonInclude
|
||||
@Transient
|
||||
private int cmLastEmoneyBrand = 2;
|
||||
@JsonInclude
|
||||
@Transient
|
||||
private int cmLastEmoneyCredit = 69;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
package icu.samnyan.aqua.sega.maimai2.model.userdata;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Entity(name = "Maimai2UserPrintDetail")
|
||||
@Table(name = "maimai2_user_print_detail")
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class UserPrintDetail implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@JsonIgnore
|
||||
private long id;
|
||||
|
||||
@JsonIgnore
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "user_id")
|
||||
private UserDetail user;
|
||||
private long orderId;
|
||||
private int printNumber;
|
||||
private String printDate;
|
||||
private String serialId;
|
||||
private int placeId;
|
||||
private String clientId;
|
||||
private String printerSerialId;
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "user_card_id")
|
||||
private UserCard userCard;
|
||||
private int cardRomVersion;
|
||||
private boolean isHolograph;
|
||||
private boolean printOption1;
|
||||
private boolean printOption2;
|
||||
private boolean printOption3;
|
||||
private boolean printOption4;
|
||||
private boolean printOption5;
|
||||
private boolean printOption6;
|
||||
private boolean printOption7;
|
||||
private boolean printOption8;
|
||||
private boolean printOption9;
|
||||
private boolean printOption10;
|
||||
private String created;
|
||||
|
||||
public UserPrintDetail(UserDetail user) {
|
||||
this.user = user;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
-- maimai2 card maker support
|
||||
|
||||
CREATE TABLE maimai2_game_selling_card (
|
||||
id BIGINT auto_increment PRIMARY KEY,
|
||||
card_id INTEGER,
|
||||
start_date DATETIME,
|
||||
end_date DATETIME,
|
||||
notice_start_date DATETIME,
|
||||
notice_end_date DATETIME
|
||||
);
|
||||
|
||||
CREATE TABLE maimai2_user_card (
|
||||
id BIGINT auto_increment PRIMARY KEY,
|
||||
card_id INTEGER,
|
||||
card_type_id INTEGER,
|
||||
chara_id INTEGER,
|
||||
map_id INTEGER,
|
||||
start_date VARCHAR(255),
|
||||
end_date VARCHAR(255),
|
||||
user_id BIGINT,
|
||||
constraint FKEraxz5HoWgfKLz8w63
|
||||
foreign key (user_id) references maimai2_user_detail (id)
|
||||
);
|
||||
|
||||
CREATE TABLE maimai2_user_print_detail (
|
||||
id BIGINT auto_increment PRIMARY KEY,
|
||||
order_id BIGINT,
|
||||
print_number INTEGER,
|
||||
print_date VARCHAR(255),
|
||||
serial_id VARCHAR(255),
|
||||
place_id INTEGER,
|
||||
client_id VARCHAR(255),
|
||||
printer_serial_id VARCHAR(255),
|
||||
user_card_id BIGINT,
|
||||
card_rom_version INTEGER,
|
||||
is_holograph BOOLEAN,
|
||||
print_option1 BOOLEAN,
|
||||
print_option2 BOOLEAN,
|
||||
print_option3 BOOLEAN,
|
||||
print_option4 BOOLEAN,
|
||||
print_option5 BOOLEAN,
|
||||
print_option6 BOOLEAN,
|
||||
print_option7 BOOLEAN,
|
||||
print_option8 BOOLEAN,
|
||||
print_option9 BOOLEAN,
|
||||
print_option10 BOOLEAN,
|
||||
created VARCHAR(255),
|
||||
user_id BIGINT,
|
||||
constraint FKDjNkXby95DMyQ9RKem
|
||||
foreign key (user_card_id) references maimai2_user_card (id),
|
||||
constraint FKEnhDgski3cuxz8Z5jd
|
||||
foreign key (user_id) references maimai2_user_detail (id)
|
||||
);
|
|
@ -0,0 +1,53 @@
|
|||
-- maimai2 card maker support
|
||||
|
||||
CREATE TABLE maimai2_game_selling_card (
|
||||
id BIGINT auto_increment PRIMARY KEY,
|
||||
card_id INTEGER,
|
||||
start_date DATETIME,
|
||||
end_date DATETIME,
|
||||
notice_start_date DATETIME,
|
||||
notice_end_date DATETIME
|
||||
);
|
||||
|
||||
CREATE TABLE maimai2_user_card (
|
||||
id BIGINT auto_increment PRIMARY KEY,
|
||||
card_id INTEGER,
|
||||
card_type_id INTEGER,
|
||||
chara_id INTEGER,
|
||||
map_id INTEGER,
|
||||
start_date VARCHAR(255),
|
||||
end_date VARCHAR(255),
|
||||
user_id BIGINT,
|
||||
constraint FKEraxz5HoWgfKLz8w63
|
||||
foreign key (user_id) references maimai2_user_detail (id)
|
||||
);
|
||||
|
||||
CREATE TABLE maimai2_user_print_detail (
|
||||
id BIGINT auto_increment PRIMARY KEY,
|
||||
order_id BIGINT,
|
||||
print_number INTEGER,
|
||||
print_date VARCHAR(255),
|
||||
serial_id VARCHAR(255),
|
||||
place_id INTEGER,
|
||||
client_id VARCHAR(255),
|
||||
printer_serial_id VARCHAR(255),
|
||||
user_card_id BIGINT,
|
||||
card_rom_version INTEGER,
|
||||
is_holograph BOOLEAN,
|
||||
print_option1 BOOLEAN,
|
||||
print_option2 BOOLEAN,
|
||||
print_option3 BOOLEAN,
|
||||
print_option4 BOOLEAN,
|
||||
print_option5 BOOLEAN,
|
||||
print_option6 BOOLEAN,
|
||||
print_option7 BOOLEAN,
|
||||
print_option8 BOOLEAN,
|
||||
print_option9 BOOLEAN,
|
||||
print_option10 BOOLEAN,
|
||||
created VARCHAR(255),
|
||||
user_id BIGINT,
|
||||
constraint FKDjNkXby95DMyQ9RKem
|
||||
foreign key (user_card_id) references maimai2_user_card (id),
|
||||
constraint FKEnhDgski3cuxz8Z5jd
|
||||
foreign key (user_id) references maimai2_user_detail (id)
|
||||
);
|
|
@ -0,0 +1,56 @@
|
|||
-- maimai2 card maker support
|
||||
|
||||
CREATE TABLE maimai2_game_selling_card (
|
||||
id INTEGER,
|
||||
card_id INTEGER,
|
||||
start_date DATETIME,
|
||||
end_date DATETIME,
|
||||
notice_start_date DATETIME,
|
||||
notice_end_date DATETIME,
|
||||
PRIMARY KEY (
|
||||
id
|
||||
)
|
||||
);
|
||||
|
||||
CREATE TABLE maimai2_user_card (
|
||||
id INTEGER,
|
||||
card_id INTEGER,
|
||||
card_type_id INTEGER,
|
||||
chara_id INTEGER,
|
||||
map_id INTEGER,
|
||||
start_date VARCHAR,
|
||||
end_date VARCHAR,
|
||||
user_id BIGINT REFERENCES maimai2_user_detail (id),
|
||||
PRIMARY KEY (
|
||||
id
|
||||
)
|
||||
);
|
||||
|
||||
CREATE TABLE maimai2_user_print_detail (
|
||||
id INTEGER,
|
||||
order_id BIGINT,
|
||||
print_number INTEGER,
|
||||
print_date VARCHAR,
|
||||
serial_id VARCHAR,
|
||||
place_id INTEGER,
|
||||
client_id VARCHAR,
|
||||
printer_serial_id VARCHAR,
|
||||
user_card_id INTEGER REFERENCES maimai2_user_card (id),
|
||||
card_rom_version INTEGER,
|
||||
is_holograph BOOLEAN,
|
||||
print_option1 BOOLEAN,
|
||||
print_option2 BOOLEAN,
|
||||
print_option3 BOOLEAN,
|
||||
print_option4 BOOLEAN,
|
||||
print_option5 BOOLEAN,
|
||||
print_option6 BOOLEAN,
|
||||
print_option7 BOOLEAN,
|
||||
print_option8 BOOLEAN,
|
||||
print_option9 BOOLEAN,
|
||||
print_option10 BOOLEAN,
|
||||
created VARCHAR,
|
||||
user_id BIGINT REFERENCES maimai2_user_detail (id),
|
||||
PRIMARY KEY (
|
||||
id
|
||||
)
|
||||
);
|
Loading…
Reference in New Issue