[F] Fix chusan export

pull/29/head
Azalea 2024-04-01 21:04:49 -04:00
parent 49d4e88022
commit 686b50eeda
11 changed files with 34 additions and 35 deletions

View File

@ -479,7 +479,7 @@ public class ApiChuniV2PlayerDataController {
userItemList.forEach(x -> x.setUser(userData)); userItemList.forEach(x -> x.setUser(userData));
userItemService.saveAll(userItemList); userItemService.saveAll(userItemList);
List<UserMapArea> userMapList = data.getUserMapList(); List<UserMap> userMapList = data.getUserMapList();
userMapList.forEach(x -> x.setUser(userData)); userMapList.forEach(x -> x.setUser(userData));
userMapAreaService.saveAll(userMapList); userMapAreaService.saveAll(userMapList);

View File

@ -13,12 +13,11 @@ data class Chu3DataExport(
var userCourseList: List<UserCourse>, var userCourseList: List<UserCourse>,
var userDuelList: List<UserDuel>, var userDuelList: List<UserDuel>,
var userItemList: List<UserItem>, var userItemList: List<UserItem>,
var userMapList: List<UserMapArea>, var userMapList: List<UserMap>,
var userMusicDetailList: List<UserMusicDetail>, var userMusicDetailList: List<UserMusicDetail>,
var userPlaylogList: List<UserPlaylog>, var userPlaylogList: List<UserPlaylog>,
var userLoginBonusList: List<UserLoginBonus>,
): IExportClass<Chu3UserData> { ): IExportClass<Chu3UserData> {
constructor() : this("SDHD", constructor() : this("SDHD",
Chu3UserData(), UserGameOption(), ArrayList(), ArrayList(), ArrayList(), ArrayList(), ArrayList(), ArrayList(), ArrayList(), ArrayList(), ArrayList(), ArrayList()) Chu3UserData(), UserGameOption(), ArrayList(), ArrayList(), ArrayList(), ArrayList(), ArrayList(), ArrayList(), ArrayList(), ArrayList(), ArrayList())
} }

View File

@ -24,7 +24,7 @@ public class ChuniDataImport {
private List<UserDuel> userDuelList; private List<UserDuel> userDuelList;
private UserGameOption userGameOption; private UserGameOption userGameOption;
private List<UserItem> userItemList; private List<UserItem> userItemList;
private List<UserMapArea> userMapList; private List<UserMap> userMapList;
private List<UserMusicDetail> userMusicDetailList; private List<UserMusicDetail> userMusicDetailList;
private List<UserPlaylog> userPlaylogList; private List<UserPlaylog> userPlaylogList;
} }

View File

@ -20,7 +20,7 @@ import kotlin.reflect.KClass
data class ImportClass<T : Any>( data class ImportClass<T : Any>(
val type: KClass<T>, val type: KClass<T>,
val renames: Map<String, String?>? = null, val renames: Map<String, String?>? = null,
val name: String = type.simpleName!!.removePrefix("Mai2").lowercase() val name: String = type.simpleName!!.removePrefix("Mai2").removePrefix("Chu3").lowercase()
) )
interface IUserEntity<UserModel: IUserData> { interface IUserEntity<UserModel: IUserData> {

View File

@ -19,9 +19,7 @@ class Chu3Import(
) : ImportController<Chu3DataExport, Chu3UserData>( ) : ImportController<Chu3DataExport, Chu3UserData>(
"SDHD", Chu3DataExport::class, "SDHD", Chu3DataExport::class,
exportFields = Chu3DataExport::class.vars().associateBy { exportFields = Chu3DataExport::class.vars().associateBy {
var name = it.name it.name.replace("List", "").lowercase()
if (name == "userMapList") name = "userMapAreaList"
name.replace("List", "").lowercase()
}, },
exportRepos = Chu3DataExport::class.vars() exportRepos = Chu3DataExport::class.vars()
.filter { f -> f.name !in setOf("gameId", "userData") } .filter { f -> f.name !in setOf("gameId", "userData") }
@ -34,8 +32,8 @@ class Chu3Import(
"chuni_item_character" to ImportClass(UserCharacter::class), "chuni_item_character" to ImportClass(UserCharacter::class),
"chuni_item_duel" to ImportClass(UserDuel::class), "chuni_item_duel" to ImportClass(UserDuel::class),
"chuni_item_item" to ImportClass(UserItem::class, mapOf("isValid" to "valid")), "chuni_item_item" to ImportClass(UserItem::class, mapOf("isValid" to "valid")),
"chuni_item_login_bonus" to ImportClass(UserLoginBonus::class, mapOf("isWatched" to "watched")), // "chuni_item_login_bonus" to ImportClass(UserLoginBonus::class, mapOf("isWatched" to "watched")),
"chuni_item_map_area" to ImportClass(UserMapArea::class), "chuni_item_map_area" to ImportClass(UserMap::class),
"chuni_profile_activity" to ImportClass(UserActivity::class, mapOf("activityId" to "id")), "chuni_profile_activity" to ImportClass(UserActivity::class, mapOf("activityId" to "id")),
"chuni_profile_charge" to ImportClass(UserCharge::class), "chuni_profile_charge" to ImportClass(UserCharge::class),
"chuni_profile_data" to ImportClass(Chu3UserData::class, mapOf("user" to null, "version" to null, "isNetMember" to null)), "chuni_profile_data" to ImportClass(Chu3UserData::class, mapOf("user" to null, "version" to null, "isNetMember" to null)),

View File

@ -2,7 +2,7 @@ package icu.samnyan.aqua.sega.chusan.handler;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import icu.samnyan.aqua.sega.general.BaseHandler; import icu.samnyan.aqua.sega.general.BaseHandler;
import icu.samnyan.aqua.sega.chusan.model.userdata.UserMapArea; import icu.samnyan.aqua.sega.chusan.model.userdata.UserMap;
import icu.samnyan.aqua.sega.chusan.service.UserMapAreaService; import icu.samnyan.aqua.sega.chusan.service.UserMapAreaService;
import icu.samnyan.aqua.sega.util.jackson.StringMapper; import icu.samnyan.aqua.sega.util.jackson.StringMapper;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -37,7 +37,7 @@ public class GetUserMapAreaHandler implements BaseHandler {
public String handle(Map<String, Object> request) throws JsonProcessingException { public String handle(Map<String, Object> request) throws JsonProcessingException {
String userId = (String) request.get("userId"); String userId = (String) request.get("userId");
List<UserMapArea> userMapAreaList = userMapAreaService.getByUserId(userId); List<UserMap> userMapAreaList = userMapAreaService.getByUserId(userId);
Map<String, Object> resultMap = new LinkedHashMap<>(); Map<String, Object> resultMap = new LinkedHashMap<>();
resultMap.put("userId", userId); resultMap.put("userId", userId);

View File

@ -102,14 +102,14 @@ public class UpsertUserAllHandler implements BaseHandler {
// userMapList // userMapList
if (upsertUserAll.getUserMapAreaList() != null) { if (upsertUserAll.getUserMapAreaList() != null) {
List<UserMapArea> userMapList = upsertUserAll.getUserMapAreaList(); List<UserMap> userMapList = upsertUserAll.getUserMapAreaList();
Map<Integer, UserMapArea> newUserMapMap = new HashMap<>(); Map<Integer, UserMap> newUserMapMap = new HashMap<>();
userMapList.forEach(newUserMap -> { userMapList.forEach(newUserMap -> {
int mapId = newUserMap.getMapAreaId(); int mapId = newUserMap.getMapAreaId();
UserMapArea userMap; UserMap userMap;
Optional<UserMapArea> userMapOptional = userMapService.getByUserAndMapAreaId(newUserData, mapId); Optional<UserMap> userMapOptional = userMapService.getByUserAndMapAreaId(newUserData, mapId);
userMap = userMapOptional.orElseGet(() -> new UserMapArea(newUserData)); userMap = userMapOptional.orElseGet(() -> new UserMap(newUserData));
newUserMap.setId(userMap.getId()); newUserMap.setId(userMap.getId());
newUserMap.setUser(userMap.getUser()); newUserMap.setUser(userMap.getUser());

View File

@ -24,7 +24,9 @@ interface Chu3UserLinked<T> : IUserRepo<Chu3UserData, T> {
} }
interface Chu3UserLoginBonusRepo : Chu3UserLinked<UserLoginBonus> { // This repo cannot be generalized as UserLinked because the entity stores user as an int
// TODO: Find a way to generalize this
interface Chu3UserLoginBonusRepo : JpaRepository<UserLoginBonus, Long> {
@Query( @Query(
value = "select * from chusan_user_login_bonus where user = ?1 and version = ?2 and is_finished = ?3 order by last_update_date desc", value = "select * from chusan_user_login_bonus where user = ?1 and version = ?2 and is_finished = ?3 order by last_update_date desc",
nativeQuery = true nativeQuery = true
@ -88,8 +90,8 @@ interface Chu3UserItemRepo : Chu3UserLinked<UserItem> {
fun findAllByUser_Card_ExtIdAndItemKind(extId: Long, itemKind: Int): List<UserItem> fun findAllByUser_Card_ExtIdAndItemKind(extId: Long, itemKind: Int): List<UserItem>
} }
interface Chu3UserMapAreaRepo : Chu3UserLinked<UserMapArea> { interface Chu3UserMapRepo : Chu3UserLinked<UserMap> {
fun findTopByUserAndMapAreaIdOrderByIdDesc(user: Chu3UserData, mapAreaId: Int): Optional<UserMapArea> fun findTopByUserAndMapAreaIdOrderByIdDesc(user: Chu3UserData, mapAreaId: Int): Optional<UserMap>
} }
interface Chu3UserMusicDetailRepo : Chu3UserLinked<UserMusicDetail> { interface Chu3UserMusicDetailRepo : Chu3UserLinked<UserMusicDetail> {
@ -98,7 +100,7 @@ interface Chu3UserMusicDetailRepo : Chu3UserLinked<UserMusicDetail> {
fun findByUser_Card_ExtIdAndMusicId(extId: Long, musicId: Int): List<UserMusicDetail> fun findByUser_Card_ExtIdAndMusicId(extId: Long, musicId: Int): List<UserMusicDetail>
} }
interface Chu3UserPlaylogRepo : GenericPlaylogRepo<UserPlaylog> { interface Chu3UserPlaylogRepo : GenericPlaylogRepo<UserPlaylog>, Chu3UserLinked<UserPlaylog> {
fun findByUser_Card_ExtIdAndLevelNot(extId: Long, levelNot: Int, page: Pageable): List<UserPlaylog> fun findByUser_Card_ExtIdAndLevelNot(extId: Long, levelNot: Int, page: Pageable): List<UserPlaylog>
fun findByUser_Card_ExtIdAndMusicIdAndLevel(extId: Long, musicId: Int, level: Int): List<UserPlaylog> fun findByUser_Card_ExtIdAndMusicIdAndLevel(extId: Long, musicId: Int, level: Int): List<UserPlaylog>
@ -170,7 +172,7 @@ class Chu3Repos(
val userGameOption: Chu3UserGameOptionRepo, val userGameOption: Chu3UserGameOptionRepo,
val userGeneralData: Chu3UserGeneralDataRepo, val userGeneralData: Chu3UserGeneralDataRepo,
val userItem: Chu3UserItemRepo, val userItem: Chu3UserItemRepo,
val userMapArea: Chu3UserMapAreaRepo, val userMap: Chu3UserMapRepo,
val userMusicDetail: Chu3UserMusicDetailRepo, val userMusicDetail: Chu3UserMusicDetailRepo,
val userPlaylog: Chu3UserPlaylogRepo, val userPlaylog: Chu3UserPlaylogRepo,
val gameAvatarAcc: Chu3GameAvatarAccRepo, val gameAvatarAcc: Chu3GameAvatarAccRepo,

View File

@ -69,7 +69,7 @@ public class UpsertUserAll implements Serializable {
private List<Map<String, Object>> userLoginBonusList; private List<Map<String, Object>> userLoginBonusList;
@Nullable @Nullable
private List<UserMapArea> userMapAreaList; private List<UserMap> userMapAreaList;
@Nullable @Nullable
private List<Map<String, Object>> userOverPowerList; private List<Map<String, Object>> userOverPowerList;

View File

@ -27,7 +27,7 @@ import java.io.Serializable;
"remainGridCount", "remainGridCount",
"isLocked" "isLocked"
}) })
public class UserMapArea implements Serializable { public class UserMap implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -58,7 +58,7 @@ public class UserMapArea implements Serializable {
@JsonProperty("isLocked") @JsonProperty("isLocked")
private boolean isLocked; private boolean isLocked;
public UserMapArea(Chu3UserData userData) { public UserMap(Chu3UserData userData) {
user = userData; user = userData;
} }
} }

View File

@ -1,8 +1,8 @@
package icu.samnyan.aqua.sega.chusan.service; package icu.samnyan.aqua.sega.chusan.service;
import icu.samnyan.aqua.sega.chusan.model.Chu3UserMapAreaRepo; import icu.samnyan.aqua.sega.chusan.model.Chu3UserMapRepo;
import icu.samnyan.aqua.sega.chusan.model.userdata.Chu3UserData; import icu.samnyan.aqua.sega.chusan.model.userdata.Chu3UserData;
import icu.samnyan.aqua.sega.chusan.model.userdata.UserMapArea; import icu.samnyan.aqua.sega.chusan.model.userdata.UserMap;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -15,30 +15,30 @@ import java.util.Optional;
@Service("ChusanUserMapAreaService") @Service("ChusanUserMapAreaService")
public class UserMapAreaService { public class UserMapAreaService {
private final Chu3UserMapAreaRepo userMapRepository; private final Chu3UserMapRepo userMapRepository;
@Autowired @Autowired
public UserMapAreaService(Chu3UserMapAreaRepo userMapRepository) { public UserMapAreaService(Chu3UserMapRepo userMapRepository) {
this.userMapRepository = userMapRepository; this.userMapRepository = userMapRepository;
} }
public UserMapArea save(UserMapArea userMap) { public UserMap save(UserMap userMap) {
return userMapRepository.save(userMap); return userMapRepository.save(userMap);
} }
public List<UserMapArea> saveAll(Iterable<UserMapArea> userMap) { public List<UserMap> saveAll(Iterable<UserMap> userMap) {
return userMapRepository.saveAll(userMap); return userMapRepository.saveAll(userMap);
} }
public List<UserMapArea> getByUser(Chu3UserData user) { public List<UserMap> getByUser(Chu3UserData user) {
return userMapRepository.findByUser(user); return userMapRepository.findByUser(user);
} }
public List<UserMapArea> getByUserId(String userId) { public List<UserMap> getByUserId(String userId) {
return userMapRepository.findByUser_Card_ExtId(Long.parseLong(userId)); return userMapRepository.findByUser_Card_ExtId(Long.parseLong(userId));
} }
public Optional<UserMapArea> getByUserAndMapAreaId(Chu3UserData user, int mapId) { public Optional<UserMap> getByUserAndMapAreaId(Chu3UserData user, int mapId) {
return userMapRepository.findTopByUserAndMapAreaIdOrderByIdDesc(user, mapId); return userMapRepository.findTopByUserAndMapAreaIdOrderByIdDesc(user, mapId);
} }
} }