From 95b9871f7ff09fa707fda50867e935db5779acac Mon Sep 17 00:00:00 2001 From: HoshimiRIN Date: Wed, 6 Mar 2024 17:13:13 +0800 Subject: [PATCH] [chusan]add support for luminous --- .../controller/ChusanServletController.java | 155 ++++++++++-------- .../UserCMissionProgressRepository.java | 15 ++ .../dao/userdata/UserCMissionRepository.java | 12 ++ .../impl/GetGameMapAreaConditionHandler.java | 36 ++++ .../handler/impl/GetUserCMissionHandler.java | 63 +++++++ .../GetUserNetBattleRankingInfoHandler.java | 38 +++++ .../handler/impl/UpsertUserAllHandler.java | 48 +++++- .../chusan/model/request/UpsertUserAll.java | 7 + .../data/UserCMissionProgressResp.java | 16 ++ .../model/response/data/UserCMissionResp.java | 19 +++ .../chusan/model/userdata/UserCMission.java | 30 ++++ .../model/userdata/UserCMissionProgress.java | 34 ++++ .../V262__add_chusan_luminous_support.sql | 28 ++++ .../V262__add_chusan_luminous_support.sql | 28 ++++ .../V262__add_chusan_luminous_support.sql | 20 +++ 15 files changed, 482 insertions(+), 67 deletions(-) create mode 100644 src/main/java/icu/samnyan/aqua/sega/chusan/dao/userdata/UserCMissionProgressRepository.java create mode 100644 src/main/java/icu/samnyan/aqua/sega/chusan/dao/userdata/UserCMissionRepository.java create mode 100644 src/main/java/icu/samnyan/aqua/sega/chusan/handler/impl/GetGameMapAreaConditionHandler.java create mode 100644 src/main/java/icu/samnyan/aqua/sega/chusan/handler/impl/GetUserCMissionHandler.java create mode 100644 src/main/java/icu/samnyan/aqua/sega/chusan/handler/impl/GetUserNetBattleRankingInfoHandler.java create mode 100644 src/main/java/icu/samnyan/aqua/sega/chusan/model/response/data/UserCMissionProgressResp.java create mode 100644 src/main/java/icu/samnyan/aqua/sega/chusan/model/response/data/UserCMissionResp.java create mode 100644 src/main/java/icu/samnyan/aqua/sega/chusan/model/userdata/UserCMission.java create mode 100644 src/main/java/icu/samnyan/aqua/sega/chusan/model/userdata/UserCMissionProgress.java create mode 100644 src/main/resources/db/migration/mariadb/V262__add_chusan_luminous_support.sql create mode 100644 src/main/resources/db/migration/mysql/V262__add_chusan_luminous_support.sql create mode 100644 src/main/resources/db/migration/sqlite/V262__add_chusan_luminous_support.sql diff --git a/src/main/java/icu/samnyan/aqua/sega/chusan/controller/ChusanServletController.java b/src/main/java/icu/samnyan/aqua/sega/chusan/controller/ChusanServletController.java index dbce8059..a2912da8 100644 --- a/src/main/java/icu/samnyan/aqua/sega/chusan/controller/ChusanServletController.java +++ b/src/main/java/icu/samnyan/aqua/sega/chusan/controller/ChusanServletController.java @@ -49,6 +49,9 @@ public class ChusanServletController { private final GetGameGachaHandler getGameGachaHandler; private final GetGameGachaCardByIdHandler getGameGachaCardByIdHandler; private final GetUserCardPrintErrorHandler getUserCardPrintErrorHandler; + private final GetUserCMissionHandler getUserCMissionHandler; + private final GetGameMapAreaConditionHandler getGameMapAreaConditionHandler; + private final GetUserNetBattleRankingInfoHandler getUserNetBattleRankingInfoHandler; private final CMGetUserPreviewHandler cmGetUserPreviewHandler; private final CMGetUserDataHandler cmGetUserDataHandler; private final CMGetUserCharacterHandler cmGetUserCharacterHandler; @@ -59,6 +62,7 @@ public class ChusanServletController { private final CMUpsertUserGachaHandler cmUpsertUserGachaHandler; private final CMUpsertUserPrintSubtractHandler cmUpsertUserPrintSubtractHandler; private final CMUpsertUserPrintCancelHandler cmUpsertUserPrintCancelHandler; + private final GetUserCtoCPlayHandler getUserCtoCPlayHandler; private final BeginMatchingHandler beginMatchingHandler; private final EndMatchingHandler endMatchingHandler; private final GetMatchingStateHandler getMatchingStateHandler; @@ -66,29 +70,29 @@ public class ChusanServletController { @Autowired public ChusanServletController(GameLoginHandler gameLoginHandler, GameLogoutHandler gameLogoutHandler, - GetGameChargeHandler getGameChargeHandler, GetGameEventHandler getGameEventHandler, - GetGameIdlistHandler getGameIdlistHandler, GetGameRankingHandler getGameRankingHandler, - GetGameSettingHandler getGameSettingHandler, GetTeamCourseRuleHandler getTeamCourseRuleHandler, - GetTeamCourseSettingHandler getTeamCourseSettingHandler, GetUserActivityHandler getUserActivityHandler, - GetUserCharacterHandler getUserCharacterHandler, GetUserChargeHandler getUserChargeHandler, - GetUserCourseHandler getUserCourseHandler, GetUserDataHandler getUserDataHandler, - GetUserDuelHandler getUserDuelHandler, GetUserFavoriteItemHandler getUserFavoriteItemHandler, - GetUserItemHandler getUserItemHandler, GetUserLoginBonusHandler getUserLoginBonusHandler, - GetUserMapAreaHandler getUserMapAreaHandler, GetUserMusicHandler getUserMusicHandler, - GetUserOptionHandler getUserOptionHandler, GetUserPreviewHandler getUserPreviewHandler, - GetUserRecentRatingHandler getUserRecentRatingHandler, GetUserRegionHandler getUserRegionHandler, - GetUserRivalDataHandler getUserRivalDataHandler, GetUserRivalMusicHandler getUserRivalMusicHandler, - GetUserTeamHandler getUserTeamHandler, UpsertUserAllHandler upsertUserAllHandler, - UpsertUserChargelogHandler upsertUserChargelogHandler, GetUserSymbolChatSettingHandler getUserSymbolChatSettingHandler, - GetUserNetBattleDataHandler getUserNetBattleDataHandler, GetGameGachaHandler getGameGachaHandler, - GetGameGachaCardByIdHandler getGameGachaCardByIdHandler, GetUserCardPrintErrorHandler getUserCardPrintErrorHandler, - CMGetUserPreviewHandler cmGetUserPreviewHandler, CMGetUserDataHandler cmGetUserDataHandler, - CMGetUserCharacterHandler cmGetUserCharacterHandler, GetUserGachaHandler getUserGachaHandler, - GetUserPrintedCardHandler getUserPrintedCardHandler, CMGetUserItemHandler cmGetUserItemHandler, - RollGachaHandler rollGachaHandler, CMUpsertUserGachaHandler cmUpsertUserGachaHandler, - CMUpsertUserPrintSubtractHandler cmUpsertUserPrintSubtractHandler, CMUpsertUserPrintCancelHandler cmUpsertUserPrintCancelHandler, - BeginMatchingHandler beginMatchingHandler, EndMatchingHandler endMatchingHandler, - GetMatchingStateHandler getMatchingStateHandler, RemoveMatchingMemberHandler removeMatchingMemberHandler) { + GetGameChargeHandler getGameChargeHandler, GetGameEventHandler getGameEventHandler, + GetGameIdlistHandler getGameIdlistHandler, GetGameRankingHandler getGameRankingHandler, + GetGameSettingHandler getGameSettingHandler, GetTeamCourseRuleHandler getTeamCourseRuleHandler, + GetTeamCourseSettingHandler getTeamCourseSettingHandler, GetUserActivityHandler getUserActivityHandler, + GetUserCharacterHandler getUserCharacterHandler, GetUserChargeHandler getUserChargeHandler, + GetUserCourseHandler getUserCourseHandler, GetUserDataHandler getUserDataHandler, + GetUserDuelHandler getUserDuelHandler, GetUserFavoriteItemHandler getUserFavoriteItemHandler, + GetUserItemHandler getUserItemHandler, GetUserLoginBonusHandler getUserLoginBonusHandler, + GetUserMapAreaHandler getUserMapAreaHandler, GetUserMusicHandler getUserMusicHandler, + GetUserOptionHandler getUserOptionHandler, GetUserPreviewHandler getUserPreviewHandler, + GetUserRecentRatingHandler getUserRecentRatingHandler, GetUserRegionHandler getUserRegionHandler, + GetUserRivalDataHandler getUserRivalDataHandler, GetUserRivalMusicHandler getUserRivalMusicHandler, + GetUserTeamHandler getUserTeamHandler, UpsertUserAllHandler upsertUserAllHandler, + UpsertUserChargelogHandler upsertUserChargelogHandler, GetUserSymbolChatSettingHandler getUserSymbolChatSettingHandler, + GetUserNetBattleDataHandler getUserNetBattleDataHandler, GetGameGachaHandler getGameGachaHandler, + GetGameGachaCardByIdHandler getGameGachaCardByIdHandler, GetUserCardPrintErrorHandler getUserCardPrintErrorHandler, + GetUserCMissionHandler getUserCMissionHandler, GetGameMapAreaConditionHandler getGameMapAreaConditionHandler, GetUserNetBattleRankingInfoHandler getUserNetBattleRankingInfoHandler, CMGetUserPreviewHandler cmGetUserPreviewHandler, CMGetUserDataHandler cmGetUserDataHandler, + CMGetUserCharacterHandler cmGetUserCharacterHandler, GetUserGachaHandler getUserGachaHandler, + GetUserPrintedCardHandler getUserPrintedCardHandler, CMGetUserItemHandler cmGetUserItemHandler, + RollGachaHandler rollGachaHandler, CMUpsertUserGachaHandler cmUpsertUserGachaHandler, + CMUpsertUserPrintSubtractHandler cmUpsertUserPrintSubtractHandler, CMUpsertUserPrintCancelHandler cmUpsertUserPrintCancelHandler, + BeginMatchingHandler beginMatchingHandler, EndMatchingHandler endMatchingHandler, + GetMatchingStateHandler getMatchingStateHandler, RemoveMatchingMemberHandler removeMatchingMemberHandler) { this.gameLoginHandler = gameLoginHandler; this.gameLogoutHandler = gameLogoutHandler; this.getGameChargeHandler = getGameChargeHandler; @@ -123,6 +127,9 @@ public class ChusanServletController { this.getGameGachaHandler = getGameGachaHandler; this.getGameGachaCardByIdHandler = getGameGachaCardByIdHandler; this.getUserCardPrintErrorHandler = getUserCardPrintErrorHandler; + this.getUserCMissionHandler = getUserCMissionHandler; + this.getGameMapAreaConditionHandler = getGameMapAreaConditionHandler; + this.getUserNetBattleRankingInfoHandler = getUserNetBattleRankingInfoHandler; this.cmGetUserPreviewHandler = cmGetUserPreviewHandler; this.cmGetUserDataHandler = cmGetUserDataHandler; this.cmGetUserCharacterHandler = cmGetUserCharacterHandler; @@ -133,212 +140,228 @@ public class ChusanServletController { this.cmUpsertUserGachaHandler = cmUpsertUserGachaHandler; this.cmUpsertUserPrintSubtractHandler = cmUpsertUserPrintSubtractHandler; this.cmUpsertUserPrintCancelHandler = cmUpsertUserPrintCancelHandler; + this.getUserCtoCPlayHandler = getUserCtoCPlayHandler; this.beginMatchingHandler = beginMatchingHandler; this.endMatchingHandler = endMatchingHandler; this.getMatchingStateHandler = getMatchingStateHandler; this.removeMatchingMemberHandler = removeMatchingMemberHandler; } - @PostMapping("GameLoginApi") + @PostMapping({"GameLoginApi", "GameLoginApiC3Exp"}) String gameLogin(@ModelAttribute Map request) throws JsonProcessingException { return gameLoginHandler.handle(request); } - @PostMapping("GameLogoutApi") + @PostMapping({"GameLogoutApi", "GameLogoutApiC3Exp"}) String gameLogout(@ModelAttribute Map request) throws JsonProcessingException { return gameLogoutHandler.handle(request); } - @PostMapping("GetGameChargeApi") + @PostMapping({"GetGameChargeApi", "GetGameChargeApiC3Exp"}) String getGameCharge(@ModelAttribute Map request) throws JsonProcessingException { return getGameChargeHandler.handle(request); } - @PostMapping("GetGameEventApi") + @PostMapping({"GetGameEventApi", "GetGameEventApiC3Exp"}) String getGameEvent(@ModelAttribute Map request) throws JsonProcessingException { return getGameEventHandler.handle(request); } - @PostMapping("GetGameIdlistApi") + @PostMapping({"GetGameIdlistApi", "GetGameIdlistApiC3Exp"}) String getGameIdList(@ModelAttribute Map request) throws JsonProcessingException { return getGameIdlistHandler.handle(request); } - @PostMapping("GetGameRankingApi") + @PostMapping({"GetGameRankingApi", "GetGameRankingApiC3Exp"}) String getGameRanking(@ModelAttribute Map request) throws JsonProcessingException { return getGameRankingHandler.handle(request); } - @PostMapping("GetGameSettingApi") + @PostMapping({"GetGameSettingApi", "GetGameSettingApiC3Exp"}) String getGameSetting(@ModelAttribute Map request) throws JsonProcessingException { return getGameSettingHandler.handle(request); } - @PostMapping("GetTeamCourseRuleApi") + @PostMapping({"GetTeamCourseRuleApi", "GetTeamCourseRuleApiC3Exp"}) String getTeamCourseRule(@ModelAttribute Map request) throws JsonProcessingException { return getTeamCourseRuleHandler.handle(request); } - @PostMapping("GetTeamCourseSettingApi") + @PostMapping({"GetTeamCourseSettingApi", "GetTeamCourseSettingApiC3Exp"}) String getTeamCourseSetting(@ModelAttribute Map request) throws JsonProcessingException { return getTeamCourseSettingHandler.handle(request); } - @PostMapping("GetUserActivityApi") + @PostMapping({"GetUserActivityApi", "GetUserActivityApiC3Exp"}) String getUserActivity(@ModelAttribute Map request) throws JsonProcessingException { return getUserActivityHandler.handle(request); } - @PostMapping("GetUserCharacterApi") + @PostMapping({"GetUserCharacterApi", "GetUserCharacterApiC3Exp"}) String getUserCharacter(@ModelAttribute Map request) throws JsonProcessingException { return getUserCharacterHandler.handle(request); } - @PostMapping("GetUserChargeApi") + @PostMapping({"GetUserChargeApi", "GetUserChargeApiC3Exp"}) String getUserCharge(@ModelAttribute Map request) throws JsonProcessingException { return getUserChargeHandler.handle(request); } - @PostMapping("GetUserCourseApi") + @PostMapping({"GetUserCourseApi", "GetUserCourseApiC3Exp"}) String getUserCourse(@ModelAttribute Map request) throws JsonProcessingException { return getUserCourseHandler.handle(request); } - @PostMapping("GetUserDataApi") + @PostMapping({"GetUserDataApi", "GetUserDataApiC3Exp"}) String getUserData(@ModelAttribute Map request) throws JsonProcessingException { return getUserDataHandler.handle(request); } - @PostMapping("GetUserDuelApi") + @PostMapping({"GetUserDuelApi", "GetUserDuelApiC3Exp"}) String getUserDuel(@ModelAttribute Map request) throws JsonProcessingException { return getUserDuelHandler.handle(request); } - @PostMapping("GetUserFavoriteItemApi") + @PostMapping({"GetUserFavoriteItemApi", "GetUserFavoriteItemApiC3Exp"}) String getUserFavoriteItem(@ModelAttribute Map request) throws JsonProcessingException { return getUserFavoriteItemHandler.handle(request); } - @PostMapping("GetUserItemApi") + @PostMapping({"GetUserItemApi", "GetUserItemApiC3Exp"}) String getUserItem(@ModelAttribute Map request) throws JsonProcessingException { return getUserItemHandler.handle(request); } - @PostMapping("GetUserLoginBonusApi") + @PostMapping({"GetUserLoginBonusApi", "GetUserLoginBonusApiC3Exp"}) String getUserLoginBonus(@ModelAttribute Map request) throws JsonProcessingException { return getUserLoginBonusHandler.handle(request); } - @PostMapping("GetUserMapAreaApi") + @PostMapping({"GetUserMapAreaApi", "GetUserMapAreaApiC3Exp"}) String getUserMap(@ModelAttribute Map request) throws JsonProcessingException { return getUserMapAreaHandler.handle(request); } - @PostMapping("GetUserMusicApi") - String getUserMusic(@ModelAttribute Map request, @PathVariable String version) throws JsonProcessingException { - request.put("version", version); + @PostMapping({"GetUserMusicApi", "GetUserMusicApiC3Exp"}) + String getUserMusic(@ModelAttribute Map request, @PathVariable String ROM_VERSION) throws JsonProcessingException { + request.put("ROM_VERSION", ROM_VERSION); return getUserMusicHandler.handle(request); } - @PostMapping("GetUserOptionApi") + @PostMapping({"GetUserOptionApi", "GetUserOptionApiC3Exp"}) String getUserOption(@ModelAttribute Map request) throws JsonProcessingException { return getUserOptionHandler.handle(request); } // Call when login. Return null if no profile exist - @PostMapping("GetUserPreviewApi") + @PostMapping({"GetUserPreviewApi", "GetUserPreviewApiC3Exp"}) String getUserPreview(@ModelAttribute Map request) throws JsonProcessingException { return getUserPreviewHandler.handle(request); } - @PostMapping("GetUserRecentRatingApi") + @PostMapping({"GetUserRecentRatingApi", "GetUserRecentRatingApiC3Exp"}) String getUserRecentRating(@ModelAttribute Map request) throws JsonProcessingException { return getUserRecentRatingHandler.handle(request); } - @PostMapping("GetUserRegionApi") + @PostMapping({"GetUserRegionApi", "GetUserRegionApiC3Exp"}) String getUserRegion(@ModelAttribute Map request) throws JsonProcessingException { return getUserRegionHandler.handle(request); } - @PostMapping("GetUserRivalDataApi") + @PostMapping({"GetUserRivalDataApi", "GetUserRivalDataApiC3Exp"}) String getUserRivalData(@ModelAttribute Map request) throws JsonProcessingException { return getUserRivalDataHandler.handle(request); } - @PostMapping("GetUserRivalMusicApi") + @PostMapping({"GetUserRivalMusicApi", "GetUserRivalMusicApiC3EXP"}) String getUserRivalMusic(@ModelAttribute Map request) throws JsonProcessingException { return getUserRivalMusicHandler.handle(request); } - @PostMapping("GetUserTeamApi") + @PostMapping({"GetUserTeamApi", "GetUserTeamApiC3Exp"}) String getUserTeam(@ModelAttribute Map request) throws JsonProcessingException { return getUserTeamHandler.handle(request); } - @PostMapping("GetUserSymbolChatSettingApi") + @PostMapping({"GetUserSymbolChatSettingApi", "GetUserSymbolChatSettingApiC3Exp"}) String getUserSymbolChatSetting(@ModelAttribute Map request) throws JsonProcessingException { return getUserSymbolChatSettingHandler.handle(request); } - @PostMapping("GetUserNetBattleDataApi") + @PostMapping({"GetUserNetBattleDataApi", "GetUserNetBattleDataApiC3Exp"}) String getUserNetBattleData(@ModelAttribute Map request) throws JsonProcessingException { return getUserNetBattleDataHandler.handle(request); } - @PostMapping("UpsertClientBookkeepingApi") + @PostMapping({"UpsertClientBookkeepingApi", "UpsertClientBookkeepingApiC3Exp"}) String upsertClientBookkeeping(@ModelAttribute Map request) { return "{\"returnCode\":\"1\"}"; } - @PostMapping("UpsertClientDevelopApi") + @PostMapping({"UpsertClientDevelopApi", "UpsertClientDevelopApiC3Exp"}) String upsertClientDevelop(@ModelAttribute Map request) { return "{\"returnCode\":\"1\"}"; } - @PostMapping("UpsertClientErrorApi") + @PostMapping({"UpsertClientErrorApi", "UpsertClientErrorApiC3Exp"}) String upsertClientError(@ModelAttribute Map request) { return "{\"returnCode\":\"1\"}"; } - @PostMapping("UpsertClientSettingApi") + @PostMapping({"UpsertClientSettingApi", "UpsertClientSettingApiC3Exp"}) String upsertClientSetting(@ModelAttribute Map request) { return "{\"returnCode\":\"1\"}"; } - @PostMapping("UpsertClientTestmodeApi") + @PostMapping({"UpsertClientTestmodeApi", "UpsertClientTestmodeApiC3Exp"}) String upsertClientTestmode(@ModelAttribute Map request) { return "{\"returnCode\":\"1\"}"; } - @PostMapping("UpsertUserAllApi") + @PostMapping({"UpsertUserAllApi", "UpsertUserAllApiC3Exp"}) String upsertUserAll(@ModelAttribute Map request) throws JsonProcessingException { return upsertUserAllHandler.handle(request); } - @PostMapping("UpsertUserChargelogApi") + @PostMapping({"UpsertUserChargelogApi", "UpsertUserChargelogApiC3Exp"}) String upsertUserChargelog(@ModelAttribute Map request) throws JsonProcessingException { return upsertUserChargelogHandler.handle(request); } - @PostMapping("CreateTokenApi") + @PostMapping({"CreateTokenApi", "CreateTokenApiC3Exp"}) String createToken(@ModelAttribute Map request) { return "{\"returnCode\":\"1\"}"; } - @PostMapping("RemoveTokenApi") + @PostMapping({"RemoveTokenApi", "RemoveTokenApiC3Exp"}) String removeToken(@ModelAttribute Map request) { return "{\"returnCode\":\"1\"}"; } - @PostMapping("UpsertClientUploadApi") + @PostMapping({"UpsertClientUploadApi", "UpsertClientUploadApiC3Exp"}) String upsertClientUpload(@ModelAttribute Map request) { return "{\"returnCode\":\"1\"}"; } - // Matching endpoints + @PostMapping({"GetUserCMissionApi"}) + String getUserCMission(@ModelAttribute Map request) throws JsonProcessingException { + return getUserCMissionHandler.handle(request); + } - @PostMapping("MatchingServer/Ping") + @PostMapping({"GetGameMapAreaConditionApi"}) + String getUserGameMapAreaCondition(@ModelAttribute Map request) throws JsonProcessingException { + return getGameMapAreaConditionHandler.handle(request); + } + + @PostMapping({"GetUserNetBattleRankingInfoApi"}) + String getUserNetBattleRankingInfo(@ModelAttribute Map request) throws JsonProcessingException { + return getUserNetBattleRankingInfoHandler.handle(request); + } + + //Matching endpoints + + @PostMapping({"MatchingServer/Ping", "Ping"}) String ping(@ModelAttribute Map request) { return "{\"returnCode\":\"1\"}"; } diff --git a/src/main/java/icu/samnyan/aqua/sega/chusan/dao/userdata/UserCMissionProgressRepository.java b/src/main/java/icu/samnyan/aqua/sega/chusan/dao/userdata/UserCMissionProgressRepository.java new file mode 100644 index 00000000..edfcdcfe --- /dev/null +++ b/src/main/java/icu/samnyan/aqua/sega/chusan/dao/userdata/UserCMissionProgressRepository.java @@ -0,0 +1,15 @@ +package icu.samnyan.aqua.sega.chusan.dao.userdata; + +import icu.samnyan.aqua.sega.chusan.model.userdata.UserCMissionProgress; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.Optional; + +@Repository("ChusanUserCMissionProgressRepository") +public interface UserCMissionProgressRepository extends JpaRepository { + List findByUser_Card_ExtIdAndMissionId(Long extId, int missionId); + + Optional findByUser_Card_ExtIdAndMissionIdAndOrder(Long extId, int missionId, int order); +} \ No newline at end of file diff --git a/src/main/java/icu/samnyan/aqua/sega/chusan/dao/userdata/UserCMissionRepository.java b/src/main/java/icu/samnyan/aqua/sega/chusan/dao/userdata/UserCMissionRepository.java new file mode 100644 index 00000000..43cf446f --- /dev/null +++ b/src/main/java/icu/samnyan/aqua/sega/chusan/dao/userdata/UserCMissionRepository.java @@ -0,0 +1,12 @@ +package icu.samnyan.aqua.sega.chusan.dao.userdata; + +import icu.samnyan.aqua.sega.chusan.model.userdata.UserCMission; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.Optional; + +@Repository("ChusanUserCMissionRepository") +public interface UserCMissionRepository extends JpaRepository { + Optional findByUser_Card_ExtIdAndMissionId(Long extId, int missionId); +} diff --git a/src/main/java/icu/samnyan/aqua/sega/chusan/handler/impl/GetGameMapAreaConditionHandler.java b/src/main/java/icu/samnyan/aqua/sega/chusan/handler/impl/GetGameMapAreaConditionHandler.java new file mode 100644 index 00000000..fa882563 --- /dev/null +++ b/src/main/java/icu/samnyan/aqua/sega/chusan/handler/impl/GetGameMapAreaConditionHandler.java @@ -0,0 +1,36 @@ +package icu.samnyan.aqua.sega.chusan.handler.impl; + +import com.fasterxml.jackson.core.JsonProcessingException; +import icu.samnyan.aqua.sega.chusan.handler.BaseHandler; +import icu.samnyan.aqua.sega.util.jackson.StringMapper; +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; + +@Component("ChusanGetGameMapAreaConditionHandler") +public class GetGameMapAreaConditionHandler implements BaseHandler { + private static final Logger logger = LoggerFactory.getLogger(GetGameMapAreaConditionHandler.class); + + private final StringMapper mapper; + + @Autowired + public GetGameMapAreaConditionHandler(StringMapper mapper) { + this.mapper = mapper; + } + + @Override + public String handle(Map request) throws JsonProcessingException { + logger.info("MapAreaCondition Dummy Handler"); + + Map resultMap = new LinkedHashMap<>(); + resultMap.put("mapAreaConditionList", new LinkedHashMap<>()); + + String json = mapper.write(resultMap); + logger.info("Response: " + json); + return json; + } +} diff --git a/src/main/java/icu/samnyan/aqua/sega/chusan/handler/impl/GetUserCMissionHandler.java b/src/main/java/icu/samnyan/aqua/sega/chusan/handler/impl/GetUserCMissionHandler.java new file mode 100644 index 00000000..b4d991ec --- /dev/null +++ b/src/main/java/icu/samnyan/aqua/sega/chusan/handler/impl/GetUserCMissionHandler.java @@ -0,0 +1,63 @@ +package icu.samnyan.aqua.sega.chusan.handler.impl; + +import com.fasterxml.jackson.core.JsonProcessingException; +import icu.samnyan.aqua.sega.chusan.dao.userdata.UserCMissionProgressRepository; +import icu.samnyan.aqua.sega.chusan.dao.userdata.UserCMissionRepository; +import icu.samnyan.aqua.sega.chusan.handler.BaseHandler; +import icu.samnyan.aqua.sega.chusan.model.response.data.UserCMissionProgressResp; +import icu.samnyan.aqua.sega.chusan.model.response.data.UserCMissionResp; +import icu.samnyan.aqua.sega.chusan.model.userdata.UserCMission; +import icu.samnyan.aqua.sega.util.jackson.StringMapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.List; +import java.util.Map; +import java.util.Optional; + +@Component("ChusanGetUserCMissionHandler") +public class GetUserCMissionHandler implements BaseHandler { + private static final Logger logger = LoggerFactory.getLogger(GetUserCMissionHandler.class); + + private final StringMapper mapper; + + private final UserCMissionProgressRepository userCMissionProgressRepository; + private final UserCMissionRepository userCMissionRepository; + + @Autowired + public GetUserCMissionHandler(StringMapper mapper, UserCMissionProgressRepository userCMissionProgressRepository, UserCMissionRepository userCMissionRepository) { + this.mapper = mapper; + this.userCMissionProgressRepository = userCMissionProgressRepository; + this.userCMissionRepository = userCMissionRepository; + } + + @Override + public String handle(Map request) throws JsonProcessingException { + long userId = Long.parseLong((String) request.get("userId")); + int missionId = Integer.parseInt((String) request.get("missionId")); + + UserCMissionResp userCMissionResp = new UserCMissionResp(); + userCMissionResp.setUserId(userId); + userCMissionResp.setMissionId(missionId); + + Optional userCMissionOptional = userCMissionRepository.findByUser_Card_ExtIdAndMissionId(userId, missionId); + if (userCMissionOptional.isPresent()) { + userCMissionResp.setPoint(userCMissionOptional.get().getPoint()); + List userCMissionProgressRespList = userCMissionProgressRepository.findByUser_Card_ExtIdAndMissionId(userId, missionId).stream() + .map(userCMissionProgress -> { + UserCMissionProgressResp userCMissionProgressResp = new UserCMissionProgressResp(); + userCMissionProgressResp.setOrder(userCMissionProgress.getOrder()); + userCMissionProgressResp.setProgress(userCMissionProgress.getProgress()); + userCMissionProgressResp.setStage(userCMissionProgress.getStage()); + return userCMissionProgressResp; + }).toList(); + userCMissionResp.setUserCMissionProgressList(userCMissionProgressRespList); + } + + String json = mapper.write(userCMissionResp); + logger.info("Response: " + json); + return json; + } +} diff --git a/src/main/java/icu/samnyan/aqua/sega/chusan/handler/impl/GetUserNetBattleRankingInfoHandler.java b/src/main/java/icu/samnyan/aqua/sega/chusan/handler/impl/GetUserNetBattleRankingInfoHandler.java new file mode 100644 index 00000000..d2943d81 --- /dev/null +++ b/src/main/java/icu/samnyan/aqua/sega/chusan/handler/impl/GetUserNetBattleRankingInfoHandler.java @@ -0,0 +1,38 @@ +package icu.samnyan.aqua.sega.chusan.handler.impl; + +import com.fasterxml.jackson.core.JsonProcessingException; +import icu.samnyan.aqua.sega.chusan.handler.BaseHandler; +import icu.samnyan.aqua.sega.util.jackson.StringMapper; +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; + +@Component("ChusanGetUserNetBattleRankingInfoHandler") +public class GetUserNetBattleRankingInfoHandler implements BaseHandler { + private static final Logger logger = LoggerFactory.getLogger(GetUserNetBattleRankingInfoHandler.class); + + private final StringMapper mapper; + + @Autowired + public GetUserNetBattleRankingInfoHandler(StringMapper mapper) { + this.mapper = mapper; + } + + @Override + public String handle(Map request) throws JsonProcessingException { + logger.info("UserNetBattleRankingInfo Dummy Handler"); + + Map resultMap = new LinkedHashMap<>(); + resultMap.put("userId", request.get("userId")); + resultMap.put("length", 0); + resultMap.put("userNetBattleRankingInfoList", new LinkedHashMap<>()); + + String json = mapper.write(resultMap); + logger.info("Response: " + json); + return json; + } +} diff --git a/src/main/java/icu/samnyan/aqua/sega/chusan/handler/impl/UpsertUserAllHandler.java b/src/main/java/icu/samnyan/aqua/sega/chusan/handler/impl/UpsertUserAllHandler.java index 1aae9528..19f3262d 100644 --- a/src/main/java/icu/samnyan/aqua/sega/chusan/handler/impl/UpsertUserAllHandler.java +++ b/src/main/java/icu/samnyan/aqua/sega/chusan/handler/impl/UpsertUserAllHandler.java @@ -1,6 +1,8 @@ package icu.samnyan.aqua.sega.chusan.handler.impl; import com.fasterxml.jackson.core.JsonProcessingException; +import icu.samnyan.aqua.sega.chusan.dao.userdata.UserCMissionProgressRepository; +import icu.samnyan.aqua.sega.chusan.dao.userdata.UserCMissionRepository; import icu.samnyan.aqua.sega.chusan.handler.BaseHandler; import icu.samnyan.aqua.sega.chusan.model.request.UpsertUserAll; import icu.samnyan.aqua.sega.chusan.model.response.CodeResp; @@ -46,6 +48,8 @@ public class UpsertUserAllHandler implements BaseHandler { private final UserDuelService userDuelService; private final UserGeneralDataService userGeneralDataService; private final UserLoginBonusService userLoginBonusService; + private final UserCMissionRepository userCMissionRepository; + private final UserCMissionProgressRepository userCMissionProgressRepository; @Autowired public UpsertUserAllHandler(StringMapper mapper, @@ -62,7 +66,8 @@ public class UpsertUserAllHandler implements BaseHandler { UserCourseService userCourseService, UserDuelService userDuelService, UserGeneralDataService userGeneralDataService, - UserLoginBonusService userLoginBonusService) { + UserLoginBonusService userLoginBonusService, + UserCMissionRepository userCMissionRepository, UserCMissionProgressRepository userCMissionProgressRepository) { this.mapper = mapper; this.cardService = cardService; this.userDataService = userDataService; @@ -78,6 +83,8 @@ public class UpsertUserAllHandler implements BaseHandler { this.userDuelService = userDuelService; this.userGeneralDataService = userGeneralDataService; this.userLoginBonusService = userLoginBonusService; + this.userCMissionRepository = userCMissionRepository; + this.userCMissionProgressRepository = userCMissionProgressRepository; } @@ -336,6 +343,45 @@ public class UpsertUserAllHandler implements BaseHandler { userLoginBonusService.saveAll(newUserLoginBonusMap.values()); } + // userCMissionList + if (upsertUserAll.getUserCMissionList() != null){ + List> userCMissionList = upsertUserAll.getUserCMissionList(); + userCMissionList.forEach(userCMission -> { + int missionId = Integer.parseInt((String) userCMission.get("missionId")); + int point = Integer.parseInt((String) userCMission.get("point")); + List> userCMissionProgressList = (List>) userCMission.get("userCMissionProgressList"); + userCMissionRepository.findByUser_Card_ExtIdAndMissionId(Long.parseLong(userId), missionId).ifPresentOrElse(userCMission1 -> { + userCMission1.setPoint(point); + userCMissionRepository.save(userCMission1); + }, () -> { + UserCMission userCMission1 = new UserCMission(); + userCMission1.setMissionId(missionId); + userCMission1.setPoint(point); + userCMission1.setUser(userData); + userCMissionRepository.save(userCMission1); + }); + + userCMissionProgressList.forEach(userCMissionProgress -> { + int order = Integer.parseInt((String) userCMissionProgress.get("order")); + int progress = Integer.parseInt((String) userCMissionProgress.get("progress")); + int stage = Integer.parseInt((String) userCMissionProgress.get("stage")); + userCMissionProgressRepository.findByUser_Card_ExtIdAndMissionIdAndOrder(Long.parseLong(userId), missionId, order).ifPresentOrElse(userCMissionProgress1 -> { + userCMissionProgress1.setProgress(progress); + userCMissionProgress1.setStage(stage); + userCMissionProgressRepository.save(userCMissionProgress1); + }, () -> { + UserCMissionProgress userCMissionProgress1 = new UserCMissionProgress(); + userCMissionProgress1.setMissionId(missionId); + userCMissionProgress1.setOrder(order); + userCMissionProgress1.setProgress(progress); + userCMissionProgress1.setStage(stage); + userCMissionProgress1.setUser(userData); + userCMissionProgressRepository.save(userCMissionProgress1); + }); + }); + }); + } + String json = mapper.write(new CodeResp(1)); logger.info("Response: " + json); return json; diff --git a/src/main/java/icu/samnyan/aqua/sega/chusan/model/request/UpsertUserAll.java b/src/main/java/icu/samnyan/aqua/sega/chusan/model/request/UpsertUserAll.java index d8e21a94..7c0a27d2 100644 --- a/src/main/java/icu/samnyan/aqua/sega/chusan/model/request/UpsertUserAll.java +++ b/src/main/java/icu/samnyan/aqua/sega/chusan/model/request/UpsertUserAll.java @@ -83,6 +83,9 @@ public class UpsertUserAll implements Serializable { @Nullable private List> userNetBattleData; + @Nullable + private List> userCMissionList; + @Nullable @JsonProperty("isNewCharacterList") private String isNewCharacterList; @@ -107,4 +110,8 @@ public class UpsertUserAll implements Serializable { @JsonProperty("isNewMapAreaList") private String isNewMapAreaList; + @Nullable + @JsonProperty("isNewCMissionList") + private String isNewCMissionList; + } diff --git a/src/main/java/icu/samnyan/aqua/sega/chusan/model/response/data/UserCMissionProgressResp.java b/src/main/java/icu/samnyan/aqua/sega/chusan/model/response/data/UserCMissionProgressResp.java new file mode 100644 index 00000000..0c3f206f --- /dev/null +++ b/src/main/java/icu/samnyan/aqua/sega/chusan/model/response/data/UserCMissionProgressResp.java @@ -0,0 +1,16 @@ +package icu.samnyan.aqua.sega.chusan.model.response.data; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class UserCMissionProgressResp implements Serializable { + private int order; + private int stage; + private int progress; +} diff --git a/src/main/java/icu/samnyan/aqua/sega/chusan/model/response/data/UserCMissionResp.java b/src/main/java/icu/samnyan/aqua/sega/chusan/model/response/data/UserCMissionResp.java new file mode 100644 index 00000000..885bd100 --- /dev/null +++ b/src/main/java/icu/samnyan/aqua/sega/chusan/model/response/data/UserCMissionResp.java @@ -0,0 +1,19 @@ +package icu.samnyan.aqua.sega.chusan.model.response.data; + + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class UserCMissionResp implements Serializable { + private long userId; + private int missionId; + private int point; + private List userCMissionProgressList; +} diff --git a/src/main/java/icu/samnyan/aqua/sega/chusan/model/userdata/UserCMission.java b/src/main/java/icu/samnyan/aqua/sega/chusan/model/userdata/UserCMission.java new file mode 100644 index 00000000..bf0151dd --- /dev/null +++ b/src/main/java/icu/samnyan/aqua/sega/chusan/model/userdata/UserCMission.java @@ -0,0 +1,30 @@ +package icu.samnyan.aqua.sega.chusan.model.userdata; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import jakarta.persistence.*; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Entity(name = "ChusanUserCMission") +@Table(name = "chusan_user_cmission") +@Data +@AllArgsConstructor +@NoArgsConstructor +public class UserCMission { + @Id + @JsonIgnore + @GeneratedValue(strategy = GenerationType.IDENTITY) + private long id; + + @JsonIgnore + @ManyToOne + @JoinColumn(name = "user_id") + private UserData user; + + @Column(name = "mission_id") + private int missionId; + + @Column(name = "point") + private int point; +} diff --git a/src/main/java/icu/samnyan/aqua/sega/chusan/model/userdata/UserCMissionProgress.java b/src/main/java/icu/samnyan/aqua/sega/chusan/model/userdata/UserCMissionProgress.java new file mode 100644 index 00000000..3ff182eb --- /dev/null +++ b/src/main/java/icu/samnyan/aqua/sega/chusan/model/userdata/UserCMissionProgress.java @@ -0,0 +1,34 @@ +package icu.samnyan.aqua.sega.chusan.model.userdata; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import jakarta.persistence.*; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Entity(name = "ChusanUserCMissionProgress") +@Table(name = "chusan_user_cmission_progress", uniqueConstraints = {@UniqueConstraint(columnNames = {"user_id", "mission_id", "order"})}) +@Data +@AllArgsConstructor +@NoArgsConstructor +public class UserCMissionProgress { + @Id + @JsonIgnore + @GeneratedValue(strategy = GenerationType.IDENTITY) + private long id; + + @JsonIgnore + @ManyToOne + @JoinColumn(name = "user_id") + private UserData user; + + @Column(name = "mission_id") + private int missionId; + + @Column(name = "`order`") + private int order; + + private int stage; + + private int progress; +} diff --git a/src/main/resources/db/migration/mariadb/V262__add_chusan_luminous_support.sql b/src/main/resources/db/migration/mariadb/V262__add_chusan_luminous_support.sql new file mode 100644 index 00000000..0c6c3cfb --- /dev/null +++ b/src/main/resources/db/migration/mariadb/V262__add_chusan_luminous_support.sql @@ -0,0 +1,28 @@ +CREATE TABLE chusan_user_cmission +( + id BIGINT AUTO_INCREMENT NOT NULL, + user_id BIGINT NULL, + mission_id INT NULL, + point INT NULL, + CONSTRAINT pk_chusan_user_cmission PRIMARY KEY (id) +); + +ALTER TABLE chusan_user_cmission + ADD CONSTRAINT FK_CHUSAN_USER_CMISSION_ON_USER FOREIGN KEY (user_id) REFERENCES chusan_user_data (id); + +CREATE TABLE chusan_user_cmission_progress +( + id BIGINT AUTO_INCREMENT NOT NULL, + user_id BIGINT NULL, + mission_id INT NULL, + `order` INT NOT NULL, + stage INT NULL, + progress INT NULL, + CONSTRAINT pk_chusan_user_cmission_progress PRIMARY KEY (id) +); + +ALTER TABLE chusan_user_cmission_progress + ADD CONSTRAINT uc_6ab791e9e8fee2b3fab35d3d2 UNIQUE (user_id, mission_id, `order`); + +ALTER TABLE chusan_user_cmission_progress + ADD CONSTRAINT FK_CHUSAN_USER_CMISSION_PROGRESS_ON_USER FOREIGN KEY (user_id) REFERENCES chusan_user_data (id); \ No newline at end of file diff --git a/src/main/resources/db/migration/mysql/V262__add_chusan_luminous_support.sql b/src/main/resources/db/migration/mysql/V262__add_chusan_luminous_support.sql new file mode 100644 index 00000000..0c6c3cfb --- /dev/null +++ b/src/main/resources/db/migration/mysql/V262__add_chusan_luminous_support.sql @@ -0,0 +1,28 @@ +CREATE TABLE chusan_user_cmission +( + id BIGINT AUTO_INCREMENT NOT NULL, + user_id BIGINT NULL, + mission_id INT NULL, + point INT NULL, + CONSTRAINT pk_chusan_user_cmission PRIMARY KEY (id) +); + +ALTER TABLE chusan_user_cmission + ADD CONSTRAINT FK_CHUSAN_USER_CMISSION_ON_USER FOREIGN KEY (user_id) REFERENCES chusan_user_data (id); + +CREATE TABLE chusan_user_cmission_progress +( + id BIGINT AUTO_INCREMENT NOT NULL, + user_id BIGINT NULL, + mission_id INT NULL, + `order` INT NOT NULL, + stage INT NULL, + progress INT NULL, + CONSTRAINT pk_chusan_user_cmission_progress PRIMARY KEY (id) +); + +ALTER TABLE chusan_user_cmission_progress + ADD CONSTRAINT uc_6ab791e9e8fee2b3fab35d3d2 UNIQUE (user_id, mission_id, `order`); + +ALTER TABLE chusan_user_cmission_progress + ADD CONSTRAINT FK_CHUSAN_USER_CMISSION_PROGRESS_ON_USER FOREIGN KEY (user_id) REFERENCES chusan_user_data (id); \ No newline at end of file diff --git a/src/main/resources/db/migration/sqlite/V262__add_chusan_luminous_support.sql b/src/main/resources/db/migration/sqlite/V262__add_chusan_luminous_support.sql new file mode 100644 index 00000000..bd310b53 --- /dev/null +++ b/src/main/resources/db/migration/sqlite/V262__add_chusan_luminous_support.sql @@ -0,0 +1,20 @@ +CREATE TABLE chusan_user_cmission +( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + user_id INTEGER, + mission_id INTEGER, + point INTEGER, + FOREIGN KEY(user_id) REFERENCES chusan_user_data(id) +); + +CREATE TABLE chusan_user_cmission_progress +( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + user_id INTEGER, + mission_id INTEGER, + `order` INTEGER NOT NULL, + stage INTEGER, + progress INTEGER, + UNIQUE(user_id, mission_id, `order`), + FOREIGN KEY(user_id) REFERENCES chusan_user_data(id) +); \ No newline at end of file