diff --git a/README.md b/README.md index 4064094b..8d779dfa 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Below is a list of games supported by this server. | SDEZ: MaiMai DX | 1.50 | PRiSM | [@肥宅虾哥](https://github.com/FeiZhaixiage) | | SDGA: MaiMai DX (Intl) | 1.50 | PRiSM | [@Clansty](https://github.com/clansty) | | SDED: Card Maker | 1.39 | | [@Becods](https://github.com/Becods) | -| SDDT: O.N.G.E.K.I. | 1.45 | bright MEMORY Act.3 | [@Gamer2097](https://github.com/Gamer2097) | +| SDDT: O.N.G.E.K.I. | 1.50 | Re:Fresh | [@PenguinCaptain](https://github.com/PenguinCaptain) | | SBZV: Project DIVA | 7.10 | Future Tone | | | SDFE: Wacca (*ALPHA) | 3.07 | Reverse | | diff --git a/src/main/java/icu/samnyan/aqua/sega/ongeki/controller/OngekiController.java b/src/main/java/icu/samnyan/aqua/sega/ongeki/controller/OngekiController.java index c3870447..64b8dbaf 100644 --- a/src/main/java/icu/samnyan/aqua/sega/ongeki/controller/OngekiController.java +++ b/src/main/java/icu/samnyan/aqua/sega/ongeki/controller/OngekiController.java @@ -4,7 +4,6 @@ package icu.samnyan.aqua.sega.ongeki.controller; import com.fasterxml.jackson.core.JsonProcessingException; import icu.samnyan.aqua.sega.ongeki.handler.impl.*; import lombok.AllArgsConstructor; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -28,6 +27,7 @@ public class OngekiController { private final GetUserCharacterHandler getUserCharacterHandler; private final GetUserDataHandler getUserDataHandler; private final GetUserDeckByKeyHandler getUserDeckByKeyHandler; + private final GetUserEventMapHandler getUserEventMapHandler; private final GetUserEventPointHandler getUserEventPointHandler; private final GetUserEventRankingHandler getUserEventRankingHandler; private final GetUserEventMusicHandler getUserEventMusicHandler; @@ -45,6 +45,7 @@ public class OngekiController { private final GetUserRivalMusicHandler getUserRivalMusicHandler; private final GetUserRivalDataHandler getUserRivalDataHandler; private final GetUserScenarioHandler getUserScenarioHandler; + private final GetUserSkinHandler getUserSkinHandler; private final GetUserStoryHandler getUserStoryHandler; private final GetUserTechCountHandler getUserTechCountHandler; private final GetUserTechEventHandler getUserTechEventHandler; @@ -111,6 +112,11 @@ public class OngekiController { return getUserDeckByKeyHandler.handle(request); } + @PostMapping("GetUserEventMapApi") + public String getUserEventMap(@ModelAttribute Map request) throws JsonProcessingException { + return getUserEventMapHandler.handle(request); + } + @PostMapping("GetUserEventPointApi") public String getUserEventPoint(@ModelAttribute Map request) throws JsonProcessingException { return getUserEventPointHandler.handle(request); @@ -201,6 +207,11 @@ public class OngekiController { return getUserScenarioHandler.handle(request); } + @PostMapping("GetUserSkinApi") + public String getUserSkin(@ModelAttribute Map request) throws JsonProcessingException { + return getUserSkinHandler.handle(request); + } + @PostMapping("GetUserStoryApi") public String getUserStory(@ModelAttribute Map request) throws JsonProcessingException { return getUserStoryHandler.handle(request); diff --git a/src/main/java/icu/samnyan/aqua/sega/ongeki/dao/userdata/UserEventMapRepository.java b/src/main/java/icu/samnyan/aqua/sega/ongeki/dao/userdata/UserEventMapRepository.java new file mode 100644 index 00000000..e3a1e979 --- /dev/null +++ b/src/main/java/icu/samnyan/aqua/sega/ongeki/dao/userdata/UserEventMapRepository.java @@ -0,0 +1,23 @@ +package icu.samnyan.aqua.sega.ongeki.dao.userdata; + +import icu.samnyan.aqua.sega.ongeki.model.userdata.UserData; +import icu.samnyan.aqua.sega.ongeki.model.userdata.UserEventMap; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Optional; + +/** + * @author samnyan (privateamusement@protonmail.com) + */ +@Repository("OngekiUserEventMapRepository") +public interface UserEventMapRepository extends JpaRepository { + + Optional findByUser(UserData userData); + + Optional findByUser_Card_ExtId(long userId); + + @Transactional + void deleteByUser(UserData user); +} diff --git a/src/main/java/icu/samnyan/aqua/sega/ongeki/dao/userdata/UserSkinRepository.java b/src/main/java/icu/samnyan/aqua/sega/ongeki/dao/userdata/UserSkinRepository.java new file mode 100644 index 00000000..fd1e1c73 --- /dev/null +++ b/src/main/java/icu/samnyan/aqua/sega/ongeki/dao/userdata/UserSkinRepository.java @@ -0,0 +1,21 @@ +package icu.samnyan.aqua.sega.ongeki.dao.userdata; + +import icu.samnyan.aqua.sega.ongeki.model.userdata.UserData; +import icu.samnyan.aqua.sega.ongeki.model.userdata.UserSkin; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +/** + * @author samnyan (privateamusement@protonmail.com) + */ +@Repository("OngekiUserSkinRepository") +public interface UserSkinRepository extends JpaRepository { + + List findByUser_Card_ExtId(long userId); + + @Transactional + void deleteByUser(UserData user); +} diff --git a/src/main/java/icu/samnyan/aqua/sega/ongeki/handler/impl/GetUserEventMapHandler.java b/src/main/java/icu/samnyan/aqua/sega/ongeki/handler/impl/GetUserEventMapHandler.java new file mode 100644 index 00000000..a447ecd8 --- /dev/null +++ b/src/main/java/icu/samnyan/aqua/sega/ongeki/handler/impl/GetUserEventMapHandler.java @@ -0,0 +1,51 @@ +package icu.samnyan.aqua.sega.ongeki.handler.impl; + +import com.fasterxml.jackson.core.JsonProcessingException; +import icu.samnyan.aqua.sega.general.BaseHandler; +import icu.samnyan.aqua.sega.ongeki.dao.userdata.UserEventMapRepository; +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; + +/** + * @author samnyan (privateamusement@protonmail.com) + */ +@Component("OngekiGetUserEventMapHandler") +public class GetUserEventMapHandler implements BaseHandler { + + private static final Logger logger = LoggerFactory.getLogger(GetUserEventMapHandler.class); + + private final BasicMapper mapper; + + private final UserEventMapRepository userEventMapRepository; + + @Autowired + public GetUserEventMapHandler(BasicMapper mapper, UserEventMapRepository userEventMapRepository) { + this.mapper = mapper; + this.userEventMapRepository = userEventMapRepository; + } + + @Override + public String handle(Map request) throws JsonProcessingException { + long userId = ((Number) request.get("userId")).longValue(); + var eventMapOptional = userEventMapRepository.findByUser_Card_ExtId(userId); + + Map resultMap = new LinkedHashMap<>(); + resultMap.put("userId", userId); + if(eventMapOptional.isPresent()) { + resultMap.put("userEventMap", eventMapOptional.get()); + } else { + resultMap.put("userEventMap", null); + } + + String json = mapper.write(resultMap); + + logger.info("Response: " + json); + return json; + } +} diff --git a/src/main/java/icu/samnyan/aqua/sega/ongeki/handler/impl/GetUserPreviewHandler.java b/src/main/java/icu/samnyan/aqua/sega/ongeki/handler/impl/GetUserPreviewHandler.java index 1794bb64..3af3b810 100644 --- a/src/main/java/icu/samnyan/aqua/sega/ongeki/handler/impl/GetUserPreviewHandler.java +++ b/src/main/java/icu/samnyan/aqua/sega/ongeki/handler/impl/GetUserPreviewHandler.java @@ -66,6 +66,7 @@ public class GetUserPreviewHandler implements BaseHandler { resp.setLevel(user.getLevel()); resp.setExp(user.getExp()); resp.setPlayerRating(user.getPlayerRating()); + resp.setNewPlayerRating(user.getNewPlayerRating()); resp.setLastGameId(user.getLastGameId()); diff --git a/src/main/java/icu/samnyan/aqua/sega/ongeki/handler/impl/GetUserSkinHandler.java b/src/main/java/icu/samnyan/aqua/sega/ongeki/handler/impl/GetUserSkinHandler.java new file mode 100644 index 00000000..7963c908 --- /dev/null +++ b/src/main/java/icu/samnyan/aqua/sega/ongeki/handler/impl/GetUserSkinHandler.java @@ -0,0 +1,51 @@ +package icu.samnyan.aqua.sega.ongeki.handler.impl; + +import com.fasterxml.jackson.core.JsonProcessingException; +import icu.samnyan.aqua.sega.general.BaseHandler; +import icu.samnyan.aqua.sega.ongeki.dao.userdata.UserSkinRepository; +import icu.samnyan.aqua.sega.ongeki.model.userdata.UserSkin; +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("OngekiGetUserSkinHandler") +public class GetUserSkinHandler implements BaseHandler { + + private static final Logger logger = LoggerFactory.getLogger(GetUserSkinHandler.class); + + private final BasicMapper mapper; + + private final UserSkinRepository userSkinRepository; + + @Autowired + public GetUserSkinHandler(BasicMapper mapper, UserSkinRepository userSkinRepository) { + this.mapper = mapper; + this.userSkinRepository = userSkinRepository; + } + + + @Override + public String handle(Map request) throws JsonProcessingException { + long userId = ((Number) request.get("userId")).longValue(); + + Map resultMap = new LinkedHashMap<>(); + resultMap.put("userId", userId); + List userSkinList = userSkinRepository.findByUser_Card_ExtId(userId); + resultMap.put("length", userSkinList.size()); + resultMap.put("userSkinList", userSkinList); + + String json = mapper.write(resultMap); + + logger.info("Response: " + json); + return json; + } +} diff --git a/src/main/java/icu/samnyan/aqua/sega/ongeki/handler/impl/UpsertUserAllHandler.java b/src/main/java/icu/samnyan/aqua/sega/ongeki/handler/impl/UpsertUserAllHandler.java new file mode 100644 index 00000000..513427d9 --- /dev/null +++ b/src/main/java/icu/samnyan/aqua/sega/ongeki/handler/impl/UpsertUserAllHandler.java @@ -0,0 +1,634 @@ +package icu.samnyan.aqua.sega.ongeki.handler.impl; + +import com.fasterxml.jackson.core.JsonProcessingException; +import icu.samnyan.aqua.sega.general.BaseHandler; +import icu.samnyan.aqua.sega.general.model.Card; +import icu.samnyan.aqua.sega.general.model.response.UserRecentRating; +import icu.samnyan.aqua.sega.general.service.CardService; +import icu.samnyan.aqua.sega.ongeki.dao.userdata.*; +import icu.samnyan.aqua.sega.ongeki.model.gamedata.OngekiFumenScore; +import icu.samnyan.aqua.sega.ongeki.model.request.UpsertUserAll; +import icu.samnyan.aqua.sega.ongeki.model.response.CodeResp; +import icu.samnyan.aqua.sega.ongeki.model.userdata.*; +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.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +/** + * The handler for saving all data of a ONGEKI profile + * + * @author samnyan (privateamusement@protonmail.com) + */ +@Component("OngekiUserAllHandler") +public class UpsertUserAllHandler implements BaseHandler { + + private static final Logger logger = LoggerFactory.getLogger(UpsertUserAllHandler.class); + + private final BasicMapper mapper; + + private final CardService cardService; + + private final UserDataRepository userDataRepository; + private final UserOptionRepository userOptionRepository; + private final UserPlaylogRepository userPlaylogRepository; + private final UserActivityRepository userActivityRepository; + private final UserMusicDetailRepository userMusicDetailRepository; + private final UserCharacterRepository userCharacterRepository; + private final UserCardRepository userCardRepository; + private final UserDeckRepository userDeckRepository; + private final UserStoryRepository userStoryRepository; + private final UserChapterRepository userChapterRepository; + private final UserMemoryChapterRepository userMemoryChapterRepository; + private final UserItemRepository userItemRepository; + private final UserMusicItemRepository userMusicItemRepository; + private final UserLoginBonusRepository userLoginBonusRepository; + private final UserEventPointRepository userEventPointRepository; + private final UserMissionPointRepository userMissionPointRepository; + private final UserTrainingRoomRepository userTrainingRoomRepository; + private final UserGeneralDataRepository userGeneralDataRepository; + private final UserBossRepository userBossRepository; + private final UserScenarioRepository userScenarioRepository; + private final UserTechCountRepository userTechCountRepository; + private final UserTradeItemRepository userTradeItemRepository; + private final UserEventMusicRepository userEventMusicRepository; + private final UserTechEventRepository userTechEventRepository; + private final UserKopRepository userKopRepository; + private final UserEventMapRepository userEventMapRepository; + + @Autowired + public UpsertUserAllHandler(BasicMapper mapper, + CardService cardService, UserDataRepository userDataRepository, UserOptionRepository userOptionRepository, UserPlaylogRepository userPlaylogRepository, UserActivityRepository userActivityRepository, UserMusicDetailRepository userMusicDetailRepository, UserCharacterRepository userCharacterRepository, UserCardRepository userCardRepository, UserDeckRepository userDeckRepository, UserStoryRepository userStoryRepository, UserChapterRepository userChapterRepository, UserItemRepository userItemRepository, UserMusicItemRepository userMusicItemRepository, UserLoginBonusRepository userLoginBonusRepository, UserEventPointRepository userEventPointRepository, UserMissionPointRepository userMissionPointRepository, UserTrainingRoomRepository userTrainingRoomRepository, UserGeneralDataRepository userGeneralDataRepository, UserBossRepository userBossRepository, UserScenarioRepository userScenarioRepository, UserTechCountRepository userTechCountRepository, UserTradeItemRepository userTradeItemRepository, UserEventMusicRepository userEventMusicRepository, UserTechEventRepository userTechEventRepository, UserKopRepository userKopRepository, UserMemoryChapterRepository userMemoryChapterRepository, UserEventMapRepository userEventMapRepository) { + this.mapper = mapper; + this.cardService = cardService; + this.userDataRepository = userDataRepository; + this.userOptionRepository = userOptionRepository; + this.userPlaylogRepository = userPlaylogRepository; + this.userActivityRepository = userActivityRepository; + this.userMusicDetailRepository = userMusicDetailRepository; + this.userCharacterRepository = userCharacterRepository; + this.userCardRepository = userCardRepository; + this.userDeckRepository = userDeckRepository; + this.userStoryRepository = userStoryRepository; + this.userChapterRepository = userChapterRepository; + this.userMemoryChapterRepository = userMemoryChapterRepository; + this.userItemRepository = userItemRepository; + this.userMusicItemRepository = userMusicItemRepository; + this.userLoginBonusRepository = userLoginBonusRepository; + this.userEventPointRepository = userEventPointRepository; + this.userMissionPointRepository = userMissionPointRepository; + this.userTrainingRoomRepository = userTrainingRoomRepository; + this.userGeneralDataRepository = userGeneralDataRepository; + this.userBossRepository = userBossRepository; + this.userScenarioRepository = userScenarioRepository; + this.userTechCountRepository = userTechCountRepository; + this.userTradeItemRepository = userTradeItemRepository; + this.userEventMusicRepository = userEventMusicRepository; + this.userTechEventRepository = userTechEventRepository; + this.userKopRepository = userKopRepository; + this.userEventMapRepository = userEventMapRepository; + } + + @Override + public String handle(Map request) throws JsonProcessingException { + long userId = ((Number) request.get("userId")).longValue(); + UpsertUserAll upsertUserAll = mapper.convert(request.get("upsertUserAll"), UpsertUserAll.class); + + // All the field should exist, no need to check now. + // UserData + UserData newUserData; + { + UserData userData; + + Optional userOptional = userDataRepository.findByCard_ExtId(userId); + + // UserData might be empty on later runs + if (userOptional.isEmpty() && upsertUserAll.getUserData().isEmpty()) { + return null; + } + + if (userOptional.isPresent()) { + userData = userOptional.get(); + } else { + userData = new UserData(); + Card card = cardService.getCardByExtId(userId).orElseThrow(); + userData.setCard(card); + } + + // If new data exists, use new data. Otherwise, use old data + newUserData = !upsertUserAll.getUserData().isEmpty() ? upsertUserAll.getUserData().getFirst() : userData; + + newUserData.setId(userData.getId()); + newUserData.setCard(userData.getCard()); + + // Set eventWatchedDate with lastPlayDate, because client doesn't update it + newUserData.setEventWatchedDate(userData.getLastPlayDate()); + newUserData.setCmEventWatchedDate(userData.getLastPlayDate()); + + userDataRepository.save(newUserData); + } + + + // UserOption + UserOption newUserOption = upsertUserAll.getUserOption().getFirst(); + + Optional userOptionOptional = userOptionRepository.findByUser(newUserData); + UserOption userOption = userOptionOptional.orElseGet(() -> new UserOption(newUserData)); + + newUserOption.setId(userOption.getId()); + newUserOption.setUser(userOption.getUser()); + + userOptionRepository.save(newUserOption); + + + // UserPlaylogList + List userPlaylogList = upsertUserAll.getUserPlaylogList(); + List newUserPlaylogList = new ArrayList<>(); + + for (UserPlaylog newUserPlaylog : userPlaylogList) { + newUserPlaylog.setUser(newUserData); + newUserPlaylogList.add(newUserPlaylog); + } + + userPlaylogRepository.saveAll(newUserPlaylogList); + + + // UserSessionlogList, UserJewelboostlogLost doesn't need to be saved for a private server + + + // UserActivityList + List userActivityList = upsertUserAll.getUserActivityList(); + List newUserActivityList = new ArrayList<>(); + + for (UserActivity newUserActivity : userActivityList) { + int kind = newUserActivity.getKind(); + int id = newUserActivity.getActivityId(); + + if (kind != 0 && id != 0) { + Optional activityOptional = userActivityRepository.findByUserAndKindAndActivityId(newUserData, kind, id); + UserActivity userActivity = activityOptional.orElseGet(() -> new UserActivity(newUserData)); + + newUserActivity.setId(userActivity.getId()); + newUserActivity.setUser(newUserData); + newUserActivityList.add(newUserActivity); + } + } + newUserActivityList.sort((a, b) -> Integer.compare(b.getSortNumber(), a.getSortNumber())); + userActivityRepository.saveAll(newUserActivityList); + + + // UserRecentRatingList + // This thing still need to save to solve the rating drop + this.saveRecentRatingData(upsertUserAll.getUserRecentRatingList(), newUserData, "recent_rating_list"); + + + /* + * The rating and battle point calculation is little bit complex. + * So I just create a UserGeneralData class to store this value + * into a csv format for convenience + */ + // UserBpBaseList (For calculating Battle point) + this.saveRecentRatingData(upsertUserAll.getUserBpBaseList(), newUserData, "battle_point_base"); + + + // This is the best rating of all charts. Best 30 + 10 after that. + // userRatingBaseBestList + this.saveRecentRatingData(upsertUserAll.getUserRatingBaseBestList(), newUserData, "rating_base_best"); + + + // userRatingBaseNextList + this.saveRecentRatingData(upsertUserAll.getUserRatingBaseNextList(), newUserData, "rating_base_next"); + + + // This is the best rating of new charts. Best 15 + 10 after that. + // New chart means same version + // userRatingBaseBestNewList + this.saveRecentRatingData(upsertUserAll.getUserRatingBaseBestNewList(), newUserData, "rating_base_new_best"); + + // userRatingBaseNextNewList + this.saveRecentRatingData(upsertUserAll.getUserRatingBaseNextNewList(), newUserData, "rating_base_new_next"); + + // This is the recent best + // userRatingBaseHotList + this.saveRecentRatingData(upsertUserAll.getUserRatingBaseHotList(), newUserData, "rating_base_hot_best"); + + // userRatingBaseHotNextList + this.saveRecentRatingData(upsertUserAll.getUserRatingBaseHotNextList(), newUserData, "rating_base_hot_next"); + + this.saveFumenScoreData(upsertUserAll.getUserNewRatingBaseBestList(), newUserData, "new_rating_base_best"); + + this.saveFumenScoreData(upsertUserAll.getUserNewRatingBaseNextBestList(), newUserData, "new_rating_base_next_best"); + + this.saveFumenScoreData(upsertUserAll.getUserNewRatingBaseBestNewList(), newUserData, "new_rating_base_new_best"); + + this.saveFumenScoreData(upsertUserAll.getUserNewRatingBaseNextBestNewList(), newUserData, "new_rating_base_new_next_best"); + + this.saveFumenScoreData(upsertUserAll.getUserNewRatingBasePScoreList(), newUserData, "new_rating_base_pscore"); + + this.saveFumenScoreData(upsertUserAll.getUserNewRatingBaseNextPScoreList(), newUserData, "new_rating_base_next_pscore"); + + // UserMusicDetailList + List userMusicDetailList = upsertUserAll.getUserMusicDetailList(); + List newUserMusicDetailList = new ArrayList<>(); + + for (UserMusicDetail newUserMusicDetail : userMusicDetailList) { + int musicId = newUserMusicDetail.getMusicId(); + int level = newUserMusicDetail.getLevel(); + + Optional musicDetailOptional = userMusicDetailRepository.findByUserAndMusicIdAndLevel(newUserData, musicId, level); + UserMusicDetail userMusicDetail = musicDetailOptional.orElseGet(() -> new UserMusicDetail(newUserData)); + + newUserMusicDetail.setId(userMusicDetail.getId()); + newUserMusicDetail.setUser(newUserData); + newUserMusicDetailList.add(newUserMusicDetail); + } + userMusicDetailRepository.saveAll(newUserMusicDetailList); + + + // UserCharacterList + List userCharacterList = upsertUserAll.getUserCharacterList(); + List newUserCharacterList = new ArrayList<>(); + + for (UserCharacter newUserCharacter : userCharacterList) { + int characterId = newUserCharacter.getCharacterId(); + + Optional characterOptional = userCharacterRepository.findByUserAndCharacterId(newUserData, characterId); + UserCharacter userCharacter = characterOptional.orElseGet(() -> new UserCharacter(newUserData)); + + newUserCharacter.setId(userCharacter.getId()); + newUserCharacter.setUser(newUserData); + newUserCharacterList.add(newUserCharacter); + } + userCharacterRepository.saveAll(newUserCharacterList); + + // UserCardList + List userCardList = upsertUserAll.getUserCardList(); + List newUserCardList = new ArrayList<>(); + + for (UserCard newUserCard : userCardList) { + int cardId = newUserCard.getCardId(); + + Optional cardOptional = userCardRepository.findByUserAndCardId(newUserData, cardId); + UserCard userCard = cardOptional.orElseGet(() -> new UserCard(newUserData)); + + newUserCard.setId(userCard.getId()); + newUserCard.setUser(newUserData); + newUserCardList.add(newUserCard); + } + userCardRepository.saveAll(newUserCardList); + + + // UserDeckList + List userDeckList = upsertUserAll.getUserDeckList(); + List newUserDeckList = new ArrayList<>(); + + for (UserDeck newUserDeck : userDeckList) { + int deckId = newUserDeck.getDeckId(); + + Optional deckOptional = userDeckRepository.findByUserAndDeckId(newUserData, deckId); + UserDeck userDeck = deckOptional.orElseGet(() -> new UserDeck(newUserData)); + + newUserDeck.setId(userDeck.getId()); + newUserDeck.setUser(newUserData); + newUserDeckList.add(newUserDeck); + } + userDeckRepository.saveAll(newUserDeckList); + + + // userTrainingRoomList + List userTrainingRoomList = upsertUserAll.getUserTrainingRoomList(); + List newUserTrainingRoomList = new ArrayList<>(); + + for (UserTrainingRoom newUserTrainingRoom : userTrainingRoomList) { + int roomId = newUserTrainingRoom.getRoomId(); + + Optional trainingRoomOptional = userTrainingRoomRepository.findByUserAndRoomId(newUserData, roomId); + UserTrainingRoom trainingRoom = trainingRoomOptional.orElseGet(() -> new UserTrainingRoom(newUserData)); + + newUserTrainingRoom.setId(trainingRoom.getId()); + newUserTrainingRoom.setUser(newUserData); + newUserTrainingRoomList.add(newUserTrainingRoom); + } + userTrainingRoomRepository.saveAll(newUserTrainingRoomList); + + + // UserStoryList + List userStoryList = upsertUserAll.getUserStoryList(); + List newUserStoryList = new ArrayList<>(); + + for (UserStory newUserStory : userStoryList) { + int storyId = newUserStory.getStoryId(); + + Optional storyOptional = userStoryRepository.findByUserAndStoryId(newUserData, storyId); + UserStory userStory = storyOptional.orElseGet(() -> new UserStory(newUserData)); + + newUserStory.setId(userStory.getId()); + newUserStory.setUser(newUserData); + newUserStoryList.add(newUserStory); + } + userStoryRepository.saveAll(newUserStoryList); + + + // UserChapterList + List userChapterList = upsertUserAll.getUserChapterList(); + List newUserChapterList = new ArrayList<>(); + + for (UserChapter newUserChapter : userChapterList) { + int chapterId = newUserChapter.getChapterId(); + + Optional chapterOptional = userChapterRepository.findByUserAndChapterId(newUserData, chapterId); + UserChapter userChapter = chapterOptional.orElseGet(() -> new UserChapter(newUserData)); + + newUserChapter.setId(userChapter.getId()); + newUserChapter.setUser(newUserData); + newUserChapterList.add(newUserChapter); + } + userChapterRepository.saveAll(newUserChapterList); + + + // UserMemoryChapterList + List userMemoryChapterList = upsertUserAll.getUserMemoryChapterList(); + + if (userMemoryChapterList != null) { + List newUserMemoryChapterList = new ArrayList<>(); + + for (UserMemoryChapter newUserMemoryChapter : userMemoryChapterList) { + int chapterId = newUserMemoryChapter.getChapterId(); + + Optional chapterOptional = userMemoryChapterRepository.findByUserAndChapterId(newUserData, chapterId); + UserMemoryChapter userChapter = chapterOptional.orElseGet(() -> new UserMemoryChapter(newUserData)); + + newUserMemoryChapter.setId(userChapter.getId()); + newUserMemoryChapter.setUser(newUserData); + newUserMemoryChapterList.add(newUserMemoryChapter); + } + userMemoryChapterRepository.saveAll(newUserMemoryChapterList); + } + + // UserItemList + List userItemList = upsertUserAll.getUserItemList(); + List newUserItemList = new ArrayList<>(); + + for (UserItem newUserItem : userItemList) { + int itemKind = newUserItem.getItemKind(); + int itemId = newUserItem.getItemId(); + + Optional itemOptional = userItemRepository.findByUserAndItemKindAndItemId(newUserData, itemKind, itemId); + UserItem userItem = itemOptional.orElseGet(() -> new UserItem(newUserData)); + + newUserItem.setId(userItem.getId()); + newUserItem.setUser(newUserData); + newUserItemList.add(newUserItem); + } + userItemRepository.saveAll(newUserItemList); + + // UserMusicItemList + List userMusicItemList = upsertUserAll.getUserMusicItemList(); + List newUserMusicItemList = new ArrayList<>(); + + for (UserMusicItem newUserMusicItem : userMusicItemList) { + int musicId = newUserMusicItem.getMusicId(); + + Optional musicItemOptional = userMusicItemRepository.findByUserAndMusicId(newUserData, musicId); + UserMusicItem userMusicItem = musicItemOptional.orElseGet(() -> new UserMusicItem(newUserData)); + + newUserMusicItem.setId(userMusicItem.getId()); + newUserMusicItem.setUser(newUserData); + newUserMusicItemList.add(newUserMusicItem); + } + userMusicItemRepository.saveAll(newUserMusicItemList); + + + // userLoginBonusList + List userLoginBonusList = upsertUserAll.getUserLoginBonusList(); + List newUserLoginBonusList = new ArrayList<>(); + + for (UserLoginBonus newUserLoginBonus : userLoginBonusList) { + int bonusId = newUserLoginBonus.getBonusId(); + + Optional loginBonusOptional = userLoginBonusRepository.findByUserAndBonusId(newUserData, bonusId); + UserLoginBonus userLoginBonus = loginBonusOptional.orElseGet(() -> new UserLoginBonus(newUserData)); + + newUserLoginBonus.setId(userLoginBonus.getId()); + newUserLoginBonus.setUser(newUserData); + newUserLoginBonusList.add(newUserLoginBonus); + } + userLoginBonusRepository.saveAll(newUserLoginBonusList); + + + // UserEventPointList + List userEventPointList = upsertUserAll.getUserEventPointList(); + List newUserEventPointList = new ArrayList<>(); + + for (UserEventPoint newUserEventPoint : userEventPointList) { + int eventId = newUserEventPoint.getEventId(); + + Optional eventPointOptional = userEventPointRepository.findByUserAndEventId(newUserData, eventId); + UserEventPoint userEventPoint = eventPointOptional.orElseGet(() -> new UserEventPoint(newUserData)); + + newUserEventPoint.setId(userEventPoint.getId()); + newUserEventPoint.setUser(newUserData); + newUserEventPointList.add(newUserEventPoint); + } + userEventPointRepository.saveAll(newUserEventPointList); + + + // UserMissionPointList + List userMissionPointList = upsertUserAll.getUserMissionPointList(); + List newUserMissionPointList = new ArrayList<>(); + + for (UserMissionPoint newUserMissionPoint : userMissionPointList) { + int eventId = newUserMissionPoint.getEventId(); + + Optional userMissionPointOptional = userMissionPointRepository.findByUserAndEventId(newUserData, eventId); + UserMissionPoint userMissionPoint = userMissionPointOptional.orElseGet(() -> new UserMissionPoint(newUserData)); + + newUserMissionPoint.setId(userMissionPoint.getId()); + newUserMissionPoint.setUser(newUserData); + newUserMissionPointList.add(newUserMissionPoint); + } + userMissionPointRepository.saveAll(newUserMissionPointList); + + // UserRatinglogList (For the highest rating of each version) + + // UserBossList + List userBossList = upsertUserAll.getUserBossList(); + if (userBossList != null) { + List newUserBossList = new ArrayList<>(); + for (UserBoss newUserBoss : userBossList) { + int musicId = newUserBoss.getMusicId(); + + Optional userBossOptional = userBossRepository.findByUserAndMusicId(newUserData, musicId); + UserBoss userBoss = userBossOptional.orElseGet(() -> new UserBoss(newUserData)); + + newUserBoss.setId(userBoss.getId()); + newUserBoss.setUser(userBoss.getUser()); + newUserBossList.add(newUserBoss); + } + userBossRepository.saveAll(newUserBossList); + } + + // UserTechCountList + List userTechCountList = upsertUserAll.getUserTechCountList(); + if (userTechCountList != null) { + List newUserTechCountList = new ArrayList<>(); + for (UserTechCount newUserTechCount : userTechCountList) { + int levelId = newUserTechCount.getLevelId(); + + Optional userTechCountOptional = userTechCountRepository.findByUserAndLevelId(newUserData, levelId); + UserTechCount userTechCount = userTechCountOptional.orElseGet(() -> new UserTechCount(newUserData)); + + newUserTechCount.setId(userTechCount.getId()); + newUserTechCount.setUser(userTechCount.getUser()); + newUserTechCountList.add(newUserTechCount); + } + userTechCountRepository.saveAll(newUserTechCountList); + } + + // UserScenarioList + List userScenarioList = upsertUserAll.getUserScenarioList(); + if (userScenarioList != null) { + List newUserScenarioList = new ArrayList<>(); + for (UserScenario newUserScenario : userScenarioList) { + int scenarioId = newUserScenario.getScenarioId(); + + Optional userScenarioOptional = userScenarioRepository.findByUserAndScenarioId(newUserData, scenarioId); + UserScenario userScenario = userScenarioOptional.orElseGet(() -> new UserScenario(newUserData)); + + newUserScenario.setId(userScenario.getId()); + newUserScenario.setUser(userScenario.getUser()); + newUserScenarioList.add(newUserScenario); + } + userScenarioRepository.saveAll(newUserScenarioList); + } + + // UserTradeItemList + List userTradeItemList = upsertUserAll.getUserTradeItemList(); + List newUserTradeItemList = new ArrayList<>(); + + for (UserTradeItem newUserTradeItem : userTradeItemList) { + int chapterId = newUserTradeItem.getChapterId(); + int tradeItemId = newUserTradeItem.getTradeItemId(); + + Optional tradeItemOptional = userTradeItemRepository.findByUserAndChapterIdAndTradeItemId(newUserData, chapterId, tradeItemId); + UserTradeItem userTradeItem = tradeItemOptional.orElseGet(() -> new UserTradeItem(newUserData)); + + newUserTradeItem.setId(userTradeItem.getId()); + newUserTradeItem.setUser(newUserData); + newUserTradeItemList.add(newUserTradeItem); + } + userTradeItemRepository.saveAll(newUserTradeItemList); + + // UserEventMusicList + List userEventMusicList = upsertUserAll.getUserEventMusicList(); + List newUserEventMusicList = new ArrayList<>(); + + for (UserEventMusic newUserEventMusic : userEventMusicList) { + int eventId = newUserEventMusic.getEventId(); + int type = newUserEventMusic.getType(); + int musicId = newUserEventMusic.getMusicId(); + + Optional eventMusicOptional = userEventMusicRepository.findByUserAndEventIdAndTypeAndMusicId(newUserData, eventId, type, musicId); + UserEventMusic userEventMusic = eventMusicOptional.orElseGet(() -> new UserEventMusic(newUserData)); + + newUserEventMusic.setId(userEventMusic.getId()); + newUserEventMusic.setUser(newUserData); + newUserEventMusicList.add(newUserEventMusic); + } + userEventMusicRepository.saveAll(newUserEventMusicList); + + // UserTechEventList + List userTechEventList = upsertUserAll.getUserTechEventList(); + List newUserTechEventList = new ArrayList<>(); + + for (UserTechEvent newUserTechEvent : userTechEventList) { + int eventId = newUserTechEvent.getEventId(); + + Optional techEventOptional = userTechEventRepository.findByUserAndEventId(newUserData, eventId); + UserTechEvent userTechEvent = techEventOptional.orElseGet(() -> new UserTechEvent(newUserData)); + + newUserTechEvent.setId(userTechEvent.getId()); + newUserTechEvent.setUser(newUserData); + newUserTechEventList.add(newUserTechEvent); + } + userTechEventRepository.saveAll(newUserTechEventList); + + // UserKopList + List userKopList = upsertUserAll.getUserKopList(); + List newUserKopList = new ArrayList<>(); + + for (UserKop newUserKop : userKopList) { + int kopId = newUserKop.getKopId(); + int areaId = newUserKop.getAreaId(); + + Optional kopOptional = userKopRepository.findByUserAndKopIdAndAreaId(newUserData, kopId, areaId); + UserKop userKop = kopOptional.orElseGet(() -> new UserKop(newUserData)); + + newUserKop.setId(userKop.getId()); + newUserKop.setUser(newUserData); + newUserKopList.add(newUserKop); + } + userKopRepository.saveAll(newUserKopList); + + // UserEventMap + UserEventMap newUserEventMap = upsertUserAll.getUserEventMap(); + if (newUserEventMap != null) { + Optional userEventOptional = userEventMapRepository.findByUser(newUserData); + UserEventMap userEventMap = userEventOptional.orElseGet(() -> new UserEventMap(newUserData)); + + newUserEventMap.setId(userEventMap.getId()); + newUserEventMap.setUser(newUserData); + userEventMapRepository.save(newUserEventMap); + } + + String json = mapper.write(new CodeResp(1, "upsertUserAll")); + logger.info("Response: " + json); + return json; + + } + + private void saveRecentRatingData(List itemList, UserData newUserData, String key) { + StringBuilder sb = new StringBuilder(); + // Convert to a string + for (UserRecentRating item : + itemList) { + sb.append(item.getMusicId()).append(":").append(item.getDifficultId()).append(":").append(item.getScore()); + sb.append(","); + } + if (!sb.isEmpty()) { + sb.deleteCharAt(sb.length() - 1); + } + saveGeneralData(newUserData, key, sb.toString()); + } + + private void saveFumenScoreData(List itemList, UserData newUserData, String key) { + StringBuilder sb = new StringBuilder(); + for (OngekiFumenScore item : itemList) { + sb.append(item.getMusicId()).append(":") + .append(item.getDifficultId()).append(":") + .append(item.getScore()).append(":") + .append(item.getPlatinumScoreStar()).append(":") + .append(item.getPlatinumScoreMax()); + sb.append(","); + } + + if (!sb.isEmpty()) { + sb.deleteCharAt(sb.length() - 1); + } + saveGeneralData(newUserData, key, sb.toString()); + } + + private void saveGeneralData(UserData newUserData, String key, String data) { + Optional uOptional = userGeneralDataRepository.findByUserAndPropertyKey(newUserData, key); + UserGeneralData userGeneralData = uOptional.orElseGet(() -> new UserGeneralData(newUserData, key)); + userGeneralData.setPropertyValue(data); + userGeneralDataRepository.save(userGeneralData); + } + +} diff --git a/src/main/java/icu/samnyan/aqua/sega/ongeki/model/gamedata/OngekiFumenScore.java b/src/main/java/icu/samnyan/aqua/sega/ongeki/model/gamedata/OngekiFumenScore.java new file mode 100644 index 00000000..ceedea12 --- /dev/null +++ b/src/main/java/icu/samnyan/aqua/sega/ongeki/model/gamedata/OngekiFumenScore.java @@ -0,0 +1,17 @@ +package icu.samnyan.aqua.sega.ongeki.model.gamedata; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class OngekiFumenScore { + private int musicId; + private int difficultId; + private String romVersionCode; + private int score; + public int platinumScoreMax; + public int platinumScoreStar; +} diff --git a/src/main/java/icu/samnyan/aqua/sega/ongeki/model/response/GetUserPreviewResp.java b/src/main/java/icu/samnyan/aqua/sega/ongeki/model/response/GetUserPreviewResp.java new file mode 100644 index 00000000..7fe63eb8 --- /dev/null +++ b/src/main/java/icu/samnyan/aqua/sega/ongeki/model/response/GetUserPreviewResp.java @@ -0,0 +1,42 @@ +package icu.samnyan.aqua.sega.ongeki.model.response; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author samnyan (privateamusement@protonmail.com) + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class GetUserPreviewResp { + + private long userId = 0; + @JsonProperty("isLogin") + private boolean isLogin = false; + private String lastLoginDate = null; + private String userName = ""; + private int reincarnationNum = 0; + private int level = 0; + private long exp = 0; + private long playerRating = 0; + private long newPlayerRating = 0; + private String lastGameId = ""; + private String lastRomVersion = ""; + private String lastDataVersion = ""; + private String lastPlayDate = null; + private int nameplateId = 0; + private int trophyId = 0; + private int cardId = 0; + private int dispPlayerLv = 0; + private int dispRating = 0; + private int dispBP = 0; + private int headphone = 0; + private int banStatus = 0; + @JsonProperty("isWarningConfirmed") + private boolean isWarningConfirmed = false; + private int lastEmoneyBrand = 0; + private int lastEmoneyCredit = 0; +} diff --git a/src/main/java/icu/samnyan/aqua/sega/ongeki/model/userdata/UserData.java b/src/main/java/icu/samnyan/aqua/sega/ongeki/model/userdata/UserData.java new file mode 100644 index 00000000..7dbff99f --- /dev/null +++ b/src/main/java/icu/samnyan/aqua/sega/ongeki/model/userdata/UserData.java @@ -0,0 +1,183 @@ +package icu.samnyan.aqua.sega.ongeki.model.userdata; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import icu.samnyan.aqua.net.games.IUserData; +import icu.samnyan.aqua.sega.general.model.Card; +import icu.samnyan.aqua.sega.util.jackson.AccessCodeSerializer; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import jakarta.persistence.*; +import java.io.Serializable; + +/** + * @author samnyan (privateamusement@protonmail.com) + */ +@Entity(name = "OngekiUserData") +@Table(name = "ongeki_user_data") +@Data +@NoArgsConstructor +@AllArgsConstructor +public class UserData implements Serializable, IUserData { + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @JsonIgnore + private long id; + + @JsonSerialize(using = AccessCodeSerializer.class) + @JsonProperty(value = "accessCode", access = JsonProperty.Access.READ_ONLY) + @OneToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "aime_card_id", unique = true) + private Card card; + + private String userName; + + private int level; + + private int reincarnationNum; + + private long exp; + + private long point; + + private long totalPoint; + + private int playCount; + + private int jewelCount; + + private int totalJewelCount; + + private int medalCount; + + private int shizukuCount; + + private int playerRating; + + private int highestRating; + + private int newPlayerRating; + + private int newHighestRating; + + private int battlePoint; + + private int bestBattlePoint; + + private int overDamageBattlePoint; + + @JsonProperty("isDialogWatchedSuggestMemory") + private boolean isDialogWatchedSuggestMemory; + + private int nameplateId; + + private int trophyId; + + private int cardId; + + private int characterId; + + private int characterVoiceNo; + + private int tabSetting; + + private int tabSortSetting; + + private int cardCategorySetting; + + private int cardSortSetting; + + private int rivalScoreCategorySetting; + + private int playedTutorialBit; + + private int firstTutorialCancelNum; + + private long sumTechHighScore; + + private long sumTechBasicHighScore; + + private long sumTechAdvancedHighScore; + + private long sumTechExpertHighScore; + + private long sumTechMasterHighScore; + + private long sumTechLunaticHighScore; + + private long sumBattleHighScore; + + private long sumBattleBasicHighScore; + + private long sumBattleAdvancedHighScore; + + private long sumBattleExpertHighScore; + + private long sumBattleMasterHighScore; + + private long sumBattleLunaticHighScore; + + private int sumPlatinumScoreStar; + + private int sumBasicPlatinumScoreStar; + + private int sumAdvancedPlatinumScoreStar; + + private int sumExpertPlatinumScoreStar; + + private int sumMasterPlatinumScoreStar; + + private int sumLunaticPlatinumScoreStar; + + private String eventWatchedDate; + + private String cmEventWatchedDate; + + private String firstGameId; + + private String firstRomVersion; + + private String firstDataVersion; + + private String firstPlayDate; + + private String lastGameId; + + private String lastRomVersion; + + private String lastDataVersion; + + private String compatibleCmVersion; + + private String lastPlayDate; + + private int lastPlaceId; + + private String lastPlaceName; + + private int lastRegionId; + + private String lastRegionName; + + private int lastAllNetId; + + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + private String lastClientId; + + private int lastUsedDeckId; + + private int lastPlayMusicLevel; + + private int lastEmoneyBrand; + + @Override + public long getTotalScore() { + return sumTechHighScore; + } +} \ No newline at end of file diff --git a/src/main/java/icu/samnyan/aqua/sega/ongeki/model/userdata/UserEventMap.java b/src/main/java/icu/samnyan/aqua/sega/ongeki/model/userdata/UserEventMap.java new file mode 100644 index 00000000..0a841a9d --- /dev/null +++ b/src/main/java/icu/samnyan/aqua/sega/ongeki/model/userdata/UserEventMap.java @@ -0,0 +1,47 @@ +package icu.samnyan.aqua.sega.ongeki.model.userdata; + +import com.fasterxml.jackson.annotation.JsonIgnore; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import jakarta.persistence.*; +import java.io.Serializable; + +/** + * @author samnyan (privateamusement@protonmail.com) + */ +@Entity(name = "OngekiUserEventMap") +@Table(name = "ongeki_user_event_map") +@Data +@NoArgsConstructor +@AllArgsConstructor +public class UserEventMap implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @JsonIgnore + private long id; + + @JsonIgnore + @ManyToOne + @JoinColumn(name = "user_id") + private UserData user; + + private int eventId; + + private int mapId; + + private String mapData; + + private int totalPoint; + + private int totalUsePoint; + + public UserEventMap(UserData userData) { + this.user = userData; + } +} diff --git a/src/main/java/icu/samnyan/aqua/sega/ongeki/model/userdata/UserMemoryChapter.java b/src/main/java/icu/samnyan/aqua/sega/ongeki/model/userdata/UserMemoryChapter.java new file mode 100644 index 00000000..2ed5a1d2 --- /dev/null +++ b/src/main/java/icu/samnyan/aqua/sega/ongeki/model/userdata/UserMemoryChapter.java @@ -0,0 +1,66 @@ +package icu.samnyan.aqua.sega.ongeki.model.userdata; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import jakarta.persistence.*; +import java.io.Serializable; + +/** + * @author samnyan (privateamusement@protonmail.com) + */ +@Entity(name = "OngekiUserMemoryChapter") +@Table(name = "ongeki_user_memory_chapter") +@Data +@NoArgsConstructor +@AllArgsConstructor +public class UserMemoryChapter implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @JsonIgnore + private long id; + + @JsonIgnore + @ManyToOne + @JoinColumn(name = "user_id") + private UserData user; + + private int chapterId; + + private int jewelCount; + + private int lastPlayMusicCategory; + + private int lastPlayMusicId; + + private int lastPlayMusicLevel; + + @JsonProperty("isDialogWatched") + private boolean isDialogWatched; + + @JsonProperty("isStoryWatched") + private boolean isStoryWatched; + + @JsonProperty("isBossWatched") + private boolean isBossWatched; + + @JsonProperty("isEndingWatched") + private boolean isEndingWatched; + + @JsonProperty("isClear") + private boolean isClear; + + private int gaugeId; + + private int gaugeNum; + + public UserMemoryChapter(UserData userData) { + this.user = userData; + } +} diff --git a/src/main/java/icu/samnyan/aqua/sega/ongeki/model/userdata/UserMusicDetail.java b/src/main/java/icu/samnyan/aqua/sega/ongeki/model/userdata/UserMusicDetail.java new file mode 100644 index 00000000..4496bee2 --- /dev/null +++ b/src/main/java/icu/samnyan/aqua/sega/ongeki/model/userdata/UserMusicDetail.java @@ -0,0 +1,78 @@ +package icu.samnyan.aqua.sega.ongeki.model.userdata; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import icu.samnyan.aqua.net.games.IGenericUserMusic; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import jakarta.persistence.*; +import java.io.Serializable; + +/** + * @author samnyan (privateamusement@protonmail.com) + */ +@Entity(name = "OngekiUserMusicDetail") +@Table(name = "ongeki_user_music_detail") +@Data +@NoArgsConstructor +@AllArgsConstructor +public class UserMusicDetail implements Serializable, IGenericUserMusic { + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @JsonIgnore + private long id; + + @JsonIgnore + @ManyToOne + @JoinColumn(name = "user_id") + private UserData user; + + private int musicId; + + private int level; + + private int playCount; + + private int techScoreMax; + + private int techScoreRank; + + private int battleScoreMax; + + private int battleScoreRank; + + private int platinumScoreMax; + + private int platinumScoreStar; + + private int maxComboCount; + + private int maxOverKill; + + private int maxTeamOverKill; + + @JsonProperty("isFullBell") + private boolean isFullBell; + + @JsonProperty("isFullCombo") + private boolean isFullCombo; + + @JsonProperty("isAllBreake") + private boolean isAllBreake; + + @JsonProperty("isLock") + private boolean isLock; + + private int clearStatus; + + private boolean isStoryWatched; + + public UserMusicDetail(UserData userData) { + this.user = userData; + } +} diff --git a/src/main/java/icu/samnyan/aqua/sega/ongeki/model/userdata/UserOption.java b/src/main/java/icu/samnyan/aqua/sega/ongeki/model/userdata/UserOption.java new file mode 100644 index 00000000..94739ba4 --- /dev/null +++ b/src/main/java/icu/samnyan/aqua/sega/ongeki/model/userdata/UserOption.java @@ -0,0 +1,112 @@ +package icu.samnyan.aqua.sega.ongeki.model.userdata; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import jakarta.persistence.*; +import java.io.Serializable; + +/** + * @author samnyan (privateamusement@protonmail.com) + */ +@Entity(name = "OngekiUserOption") +@Table(name = "ongeki_user_option") +@Data +@NoArgsConstructor +@AllArgsConstructor +public class UserOption implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @JsonIgnore + private long id; + + @JsonIgnore + @ManyToOne + @JoinColumn(name = "user_id") + private UserData user; + + private int optionSet; + + private int speed; + + private int mirror; + + private int judgeTiming; + + private int judgeAdjustment; + + private int abort; + + private int stealthField; + + private int tapSound; + + private int volGuide; + + private int volAll; + + private int volTap; + + private int volCrTap; + + private int volHold; + + private int volSide; + + private int volFlick; + + private int volBell; + + private int volEnemy; + + private int volSkill; + + private int volDamage; + + private int colorField; + + private int colorLaneBright; + + private int colorWallBright; + + private int colorLane; + + private int colorSide; + + private int effectDamage; + + private int effectPos; + + private int effectAttack; + + private int judgeDisp; + + private int judgePos; + + private int judgeBreak; + + private int judgeHit; + + private int platinumBreakDisp; + + private int judgeCriticalBreak; + + private int matching; + + private int dispPlayerLv; + + private int dispRating; + + private int dispBP; + + private int headphone; + + public UserOption(UserData userData) { + this.user = userData; + } +} diff --git a/src/main/java/icu/samnyan/aqua/sega/ongeki/model/userdata/UserSkin.java b/src/main/java/icu/samnyan/aqua/sega/ongeki/model/userdata/UserSkin.java new file mode 100644 index 00000000..d0c35d51 --- /dev/null +++ b/src/main/java/icu/samnyan/aqua/sega/ongeki/model/userdata/UserSkin.java @@ -0,0 +1,47 @@ +package icu.samnyan.aqua.sega.ongeki.model.userdata; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import jakarta.persistence.*; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author samnyan (privateamusement@protonmail.com) + */ +@Entity(name = "OngekiUserSkin") +@Table(name = "ongeki_user_skin") +@Data +@NoArgsConstructor +@AllArgsConstructor +public class UserSkin implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @JsonIgnore + private long id; + + @JsonIgnore + @ManyToOne + @JoinColumn(name = "user_id") + private UserData user; + + //TODO: should be updated on net when changing skin + private boolean isValid; + + private int deckId; + + private int cardId1; + + private int cardId2; + + private int cardId3; + + public UserSkin(UserData userData) { + this.user = userData; + } +} diff --git a/src/main/resources/db/40/V1000_42__ongeki_refresh.sql b/src/main/resources/db/40/V1000_42__ongeki_refresh.sql new file mode 100644 index 00000000..8ccdc606 --- /dev/null +++ b/src/main/resources/db/40/V1000_42__ongeki_refresh.sql @@ -0,0 +1,49 @@ +-- ongeki_user_option +ALTER TABLE ongeki_user_option ADD COLUMN effect_attack INT NOT NULL DEFAULT 0; + +-- ongeki_user_data +ALTER TABLE ongeki_user_data ADD COLUMN new_highest_rating INT NOT NULL DEFAULT 0; +ALTER TABLE ongeki_user_data ADD COLUMN new_player_rating INT NOT NULL DEFAULT 0; +ALTER TABLE ongeki_user_data ADD COLUMN shizuku_count INT NOT NULL DEFAULT 0; +ALTER TABLE ongeki_user_data ADD COLUMN sum_advanced_platinum_score_star INT NOT NULL DEFAULT 0; +ALTER TABLE ongeki_user_data ADD COLUMN sum_basic_platinum_score_star INT NOT NULL DEFAULT 0; +ALTER TABLE ongeki_user_data ADD COLUMN sum_expert_platinum_score_star INT NOT NULL DEFAULT 0; +ALTER TABLE ongeki_user_data ADD COLUMN sum_lunatic_platinum_score_star INT NOT NULL DEFAULT 0; +ALTER TABLE ongeki_user_data ADD COLUMN sum_master_platinum_score_star INT NOT NULL DEFAULT 0; +ALTER TABLE ongeki_user_data ADD COLUMN sum_platinum_score_star INT NOT NULL DEFAULT 0; + +-- ongeki_user_music_detail +ALTER TABLE ongeki_user_music_detail ADD COLUMN platinum_score_star INT NOT NULL DEFAULT 0; + +-- ongeki_user_memory_chapter +ALTER TABLE ongeki_user_memory_chapter ADD COLUMN is_ending_watched BIT NOT NULL; + +-- ongeki_user_event_map +CREATE TABLE ongeki_user_event_map +( + id BIGINT AUTO_INCREMENT PRIMARY KEY, + user_id BIGINT NULL, + event_id INT NOT NULL, + map_id INT NOT NULL, + map_data VARCHAR(255) NULL, + total_point INT NOT NULL, + total_use_point INT NOT NULL +); + +ALTER TABLE ongeki_user_event_map + ADD CONSTRAINT FKU_ONGEKI_USER_EVENT_MAP FOREIGN KEY (user_id) REFERENCES ongeki_user_data (id); + +-- ongeki_user_skin +CREATE TABLE ongeki_user_skin +( + id BIGINT AUTO_INCREMENT PRIMARY KEY, + user_id BIGINT NULL, + is_valid BIT NOT NULL, + deck_id INT NOT NULL, + card_id1 INT NOT NULL, + card_id2 INT NOT NULL, + card_id3 INT NOT NULL +); + +ALTER TABLE ongeki_user_skin + ADD CONSTRAINT FKU_ONGEKI_USER_SKIN FOREIGN KEY (user_id) REFERENCES ongeki_user_data (id); \ No newline at end of file