[+] Re:Fresh: Add user event map and missing fields

pull/133/head
PenguinCaptain 2025-03-27 07:31:36 +08:00
parent d690b81681
commit a978f0ee0c
No known key found for this signature in database
8 changed files with 165 additions and 2 deletions

View File

@ -37,6 +37,7 @@ public class OngekiController {
private final GetUserCharacterHandler getUserCharacterHandler; private final GetUserCharacterHandler getUserCharacterHandler;
private final GetUserDataHandler getUserDataHandler; private final GetUserDataHandler getUserDataHandler;
private final GetUserDeckByKeyHandler getUserDeckByKeyHandler; private final GetUserDeckByKeyHandler getUserDeckByKeyHandler;
private final GetUserEventMapHandler getUserEventMapHandler;
private final GetUserEventPointHandler getUserEventPointHandler; private final GetUserEventPointHandler getUserEventPointHandler;
private final GetUserEventRankingHandler getUserEventRankingHandler; private final GetUserEventRankingHandler getUserEventRankingHandler;
private final GetUserEventMusicHandler getUserEventMusicHandler; private final GetUserEventMusicHandler getUserEventMusicHandler;
@ -54,6 +55,7 @@ public class OngekiController {
private final GetUserRivalMusicHandler getUserRivalMusicHandler; private final GetUserRivalMusicHandler getUserRivalMusicHandler;
private final GetUserRivalDataHandler getUserRivalDataHandler; private final GetUserRivalDataHandler getUserRivalDataHandler;
private final GetUserScenarioHandler getUserScenarioHandler; private final GetUserScenarioHandler getUserScenarioHandler;
private final GetUserSkinHandler getUserSkinHandler;
private final GetUserStoryHandler getUserStoryHandler; private final GetUserStoryHandler getUserStoryHandler;
private final GetUserTechCountHandler getUserTechCountHandler; private final GetUserTechCountHandler getUserTechCountHandler;
private final GetUserTechEventHandler getUserTechEventHandler; private final GetUserTechEventHandler getUserTechEventHandler;
@ -65,7 +67,6 @@ public class OngekiController {
private final GetClientBookkeepingHandler getClientBookkeepingHandler; private final GetClientBookkeepingHandler getClientBookkeepingHandler;
private final GetClientTestmodeHandler getClientTestmodeHandler; private final GetClientTestmodeHandler getClientTestmodeHandler;
private final GetGameMusicReleaseStateHandler getGameMusicReleaseStateHandler; private final GetGameMusicReleaseStateHandler getGameMusicReleaseStateHandler;
private final GetUserSkinHandler getUserSkinHandler;
@PostMapping("ExtendLockTimeApi") @PostMapping("ExtendLockTimeApi")
public String extendLockTime(@ModelAttribute Map<String, Object> request) { public String extendLockTime(@ModelAttribute Map<String, Object> request) {
@ -187,6 +188,11 @@ public class OngekiController {
return getUserDeckByKeyHandler.handle(request); return getUserDeckByKeyHandler.handle(request);
} }
@PostMapping("GetUserEventMapApi")
public String getUserEventMap(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
return getUserEventMapHandler.handle(request);
}
@PostMapping("GetUserEventPointApi") @PostMapping("GetUserEventPointApi")
public String getUserEventPoint(@ModelAttribute Map<String, Object> request) throws JsonProcessingException { public String getUserEventPoint(@ModelAttribute Map<String, Object> request) throws JsonProcessingException {
return getUserEventPointHandler.handle(request); return getUserEventPointHandler.handle(request);

View File

@ -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<UserEventMap, Long> {
Optional<UserEventMap> findByUser(UserData userData);
Optional<UserEventMap> findByUser_Card_ExtId(long userId);
@Transactional
void deleteByUser(UserData user);
}

View File

@ -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<String, ?> request) throws JsonProcessingException {
long userId = ((Number) request.get("userId")).longValue();
var eventMapOptional = userEventMapRepository.findByUser_Card_ExtId(userId);
Map<String, Object> 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;
}
}

View File

@ -60,10 +60,11 @@ public class UpsertUserAllHandler implements BaseHandler {
private final UserEventMusicRepository userEventMusicRepository; private final UserEventMusicRepository userEventMusicRepository;
private final UserTechEventRepository userTechEventRepository; private final UserTechEventRepository userTechEventRepository;
private final UserKopRepository userKopRepository; private final UserKopRepository userKopRepository;
private final UserEventMapRepository userEventMapRepository;
@Autowired @Autowired
public UpsertUserAllHandler(BasicMapper mapper, 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) { 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.mapper = mapper;
this.cardService = cardService; this.cardService = cardService;
this.userDataRepository = userDataRepository; this.userDataRepository = userDataRepository;
@ -91,6 +92,7 @@ public class UpsertUserAllHandler implements BaseHandler {
this.userEventMusicRepository = userEventMusicRepository; this.userEventMusicRepository = userEventMusicRepository;
this.userTechEventRepository = userTechEventRepository; this.userTechEventRepository = userTechEventRepository;
this.userKopRepository = userKopRepository; this.userKopRepository = userKopRepository;
this.userEventMapRepository = userEventMapRepository;
} }
@Override @Override
@ -574,6 +576,17 @@ public class UpsertUserAllHandler implements BaseHandler {
} }
userKopRepository.saveAll(newUserKopList); userKopRepository.saveAll(newUserKopList);
// UserEventMap
UserEventMap newUserEventMap = upsertUserAll.getUserEventMap();
if (newUserEventMap != null) {
Optional<UserEventMap> 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")); String json = mapper.write(new CodeResp(1, "upsertUserAll"));
logger.info("Response: " + json); logger.info("Response: " + json);
return json; return json;

View File

@ -102,6 +102,8 @@ public class UpsertUserAll implements Serializable {
private List<UserKop> userKopList; private List<UserKop> userKopList;
public UserEventMap userEventMap;
private Map<String, Object> clientSystemInfo; private Map<String, Object> clientSystemInfo;
@JsonProperty("isNewMusicDetailList") @JsonProperty("isNewMusicDetailList")

View File

@ -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;
}
}

View File

@ -50,6 +50,9 @@ public class UserMemoryChapter implements Serializable {
@JsonProperty("isBossWatched") @JsonProperty("isBossWatched")
private boolean isBossWatched; private boolean isBossWatched;
@JsonProperty("isEndingWatched")
private boolean isEndingWatched;
@JsonProperty("isClear") @JsonProperty("isClear")
private boolean isClear; private boolean isClear;

View File

@ -14,3 +14,21 @@ ALTER TABLE ongeki_user_data ADD COLUMN sum_platinum_score_star INT NOT NULL DEF
-- ongeki_user_music_detail -- ongeki_user_music_detail
ALTER TABLE ongeki_user_music_detail ADD COLUMN platinum_score_star INT NOT NULL DEFAULT 0; 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);