mirror of https://github.com/hykilpikonna/AquaDX
[F] Fix chusan export
parent
49d4e88022
commit
686b50eeda
|
@ -479,7 +479,7 @@ public class ApiChuniV2PlayerDataController {
|
|||
userItemList.forEach(x -> x.setUser(userData));
|
||||
userItemService.saveAll(userItemList);
|
||||
|
||||
List<UserMapArea> userMapList = data.getUserMapList();
|
||||
List<UserMap> userMapList = data.getUserMapList();
|
||||
userMapList.forEach(x -> x.setUser(userData));
|
||||
userMapAreaService.saveAll(userMapList);
|
||||
|
||||
|
|
|
@ -13,12 +13,11 @@ data class Chu3DataExport(
|
|||
var userCourseList: List<UserCourse>,
|
||||
var userDuelList: List<UserDuel>,
|
||||
var userItemList: List<UserItem>,
|
||||
var userMapList: List<UserMapArea>,
|
||||
var userMapList: List<UserMap>,
|
||||
var userMusicDetailList: List<UserMusicDetail>,
|
||||
var userPlaylogList: List<UserPlaylog>,
|
||||
var userLoginBonusList: List<UserLoginBonus>,
|
||||
): IExportClass<Chu3UserData> {
|
||||
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())
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ public class ChuniDataImport {
|
|||
private List<UserDuel> userDuelList;
|
||||
private UserGameOption userGameOption;
|
||||
private List<UserItem> userItemList;
|
||||
private List<UserMapArea> userMapList;
|
||||
private List<UserMap> userMapList;
|
||||
private List<UserMusicDetail> userMusicDetailList;
|
||||
private List<UserPlaylog> userPlaylogList;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ import kotlin.reflect.KClass
|
|||
data class ImportClass<T : Any>(
|
||||
val type: KClass<T>,
|
||||
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> {
|
||||
|
|
|
@ -19,9 +19,7 @@ class Chu3Import(
|
|||
) : ImportController<Chu3DataExport, Chu3UserData>(
|
||||
"SDHD", Chu3DataExport::class,
|
||||
exportFields = Chu3DataExport::class.vars().associateBy {
|
||||
var name = it.name
|
||||
if (name == "userMapList") name = "userMapAreaList"
|
||||
name.replace("List", "").lowercase()
|
||||
it.name.replace("List", "").lowercase()
|
||||
},
|
||||
exportRepos = Chu3DataExport::class.vars()
|
||||
.filter { f -> f.name !in setOf("gameId", "userData") }
|
||||
|
@ -34,8 +32,8 @@ class Chu3Import(
|
|||
"chuni_item_character" to ImportClass(UserCharacter::class),
|
||||
"chuni_item_duel" to ImportClass(UserDuel::class),
|
||||
"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_map_area" to ImportClass(UserMapArea::class),
|
||||
// "chuni_item_login_bonus" to ImportClass(UserLoginBonus::class, mapOf("isWatched" to "watched")),
|
||||
"chuni_item_map_area" to ImportClass(UserMap::class),
|
||||
"chuni_profile_activity" to ImportClass(UserActivity::class, mapOf("activityId" to "id")),
|
||||
"chuni_profile_charge" to ImportClass(UserCharge::class),
|
||||
"chuni_profile_data" to ImportClass(Chu3UserData::class, mapOf("user" to null, "version" to null, "isNetMember" to null)),
|
||||
|
|
|
@ -2,7 +2,7 @@ package icu.samnyan.aqua.sega.chusan.handler;
|
|||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
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.util.jackson.StringMapper;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -37,7 +37,7 @@ public class GetUserMapAreaHandler implements BaseHandler {
|
|||
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
||||
String userId = (String) request.get("userId");
|
||||
|
||||
List<UserMapArea> userMapAreaList = userMapAreaService.getByUserId(userId);
|
||||
List<UserMap> userMapAreaList = userMapAreaService.getByUserId(userId);
|
||||
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||
resultMap.put("userId", userId);
|
||||
|
|
|
@ -102,14 +102,14 @@ public class UpsertUserAllHandler implements BaseHandler {
|
|||
|
||||
// userMapList
|
||||
if (upsertUserAll.getUserMapAreaList() != null) {
|
||||
List<UserMapArea> userMapList = upsertUserAll.getUserMapAreaList();
|
||||
Map<Integer, UserMapArea> newUserMapMap = new HashMap<>();
|
||||
List<UserMap> userMapList = upsertUserAll.getUserMapAreaList();
|
||||
Map<Integer, UserMap> newUserMapMap = new HashMap<>();
|
||||
|
||||
userMapList.forEach(newUserMap -> {
|
||||
int mapId = newUserMap.getMapAreaId();
|
||||
UserMapArea userMap;
|
||||
Optional<UserMapArea> userMapOptional = userMapService.getByUserAndMapAreaId(newUserData, mapId);
|
||||
userMap = userMapOptional.orElseGet(() -> new UserMapArea(newUserData));
|
||||
UserMap userMap;
|
||||
Optional<UserMap> userMapOptional = userMapService.getByUserAndMapAreaId(newUserData, mapId);
|
||||
userMap = userMapOptional.orElseGet(() -> new UserMap(newUserData));
|
||||
|
||||
newUserMap.setId(userMap.getId());
|
||||
newUserMap.setUser(userMap.getUser());
|
||||
|
|
|
@ -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(
|
||||
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
|
||||
|
@ -88,8 +90,8 @@ interface Chu3UserItemRepo : Chu3UserLinked<UserItem> {
|
|||
fun findAllByUser_Card_ExtIdAndItemKind(extId: Long, itemKind: Int): List<UserItem>
|
||||
}
|
||||
|
||||
interface Chu3UserMapAreaRepo : Chu3UserLinked<UserMapArea> {
|
||||
fun findTopByUserAndMapAreaIdOrderByIdDesc(user: Chu3UserData, mapAreaId: Int): Optional<UserMapArea>
|
||||
interface Chu3UserMapRepo : Chu3UserLinked<UserMap> {
|
||||
fun findTopByUserAndMapAreaIdOrderByIdDesc(user: Chu3UserData, mapAreaId: Int): Optional<UserMap>
|
||||
}
|
||||
|
||||
interface Chu3UserMusicDetailRepo : Chu3UserLinked<UserMusicDetail> {
|
||||
|
@ -98,7 +100,7 @@ interface Chu3UserMusicDetailRepo : Chu3UserLinked<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_ExtIdAndMusicIdAndLevel(extId: Long, musicId: Int, level: Int): List<UserPlaylog>
|
||||
|
@ -170,7 +172,7 @@ class Chu3Repos(
|
|||
val userGameOption: Chu3UserGameOptionRepo,
|
||||
val userGeneralData: Chu3UserGeneralDataRepo,
|
||||
val userItem: Chu3UserItemRepo,
|
||||
val userMapArea: Chu3UserMapAreaRepo,
|
||||
val userMap: Chu3UserMapRepo,
|
||||
val userMusicDetail: Chu3UserMusicDetailRepo,
|
||||
val userPlaylog: Chu3UserPlaylogRepo,
|
||||
val gameAvatarAcc: Chu3GameAvatarAccRepo,
|
||||
|
|
|
@ -69,7 +69,7 @@ public class UpsertUserAll implements Serializable {
|
|||
private List<Map<String, Object>> userLoginBonusList;
|
||||
|
||||
@Nullable
|
||||
private List<UserMapArea> userMapAreaList;
|
||||
private List<UserMap> userMapAreaList;
|
||||
|
||||
@Nullable
|
||||
private List<Map<String, Object>> userOverPowerList;
|
||||
|
|
|
@ -27,7 +27,7 @@ import java.io.Serializable;
|
|||
"remainGridCount",
|
||||
"isLocked"
|
||||
})
|
||||
public class UserMapArea implements Serializable {
|
||||
public class UserMap implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
@ -58,7 +58,7 @@ public class UserMapArea implements Serializable {
|
|||
@JsonProperty("isLocked")
|
||||
private boolean isLocked;
|
||||
|
||||
public UserMapArea(Chu3UserData userData) {
|
||||
public UserMap(Chu3UserData userData) {
|
||||
user = userData;
|
||||
}
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
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.UserMapArea;
|
||||
import icu.samnyan.aqua.sega.chusan.model.userdata.UserMap;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
@ -15,30 +15,30 @@ import java.util.Optional;
|
|||
@Service("ChusanUserMapAreaService")
|
||||
public class UserMapAreaService {
|
||||
|
||||
private final Chu3UserMapAreaRepo userMapRepository;
|
||||
private final Chu3UserMapRepo userMapRepository;
|
||||
|
||||
@Autowired
|
||||
public UserMapAreaService(Chu3UserMapAreaRepo userMapRepository) {
|
||||
public UserMapAreaService(Chu3UserMapRepo userMapRepository) {
|
||||
this.userMapRepository = userMapRepository;
|
||||
}
|
||||
|
||||
public UserMapArea save(UserMapArea userMap) {
|
||||
public UserMap save(UserMap userMap) {
|
||||
return userMapRepository.save(userMap);
|
||||
}
|
||||
|
||||
public List<UserMapArea> saveAll(Iterable<UserMapArea> userMap) {
|
||||
public List<UserMap> saveAll(Iterable<UserMap> userMap) {
|
||||
return userMapRepository.saveAll(userMap);
|
||||
}
|
||||
|
||||
public List<UserMapArea> getByUser(Chu3UserData user) {
|
||||
public List<UserMap> getByUser(Chu3UserData 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));
|
||||
}
|
||||
|
||||
public Optional<UserMapArea> getByUserAndMapAreaId(Chu3UserData user, int mapId) {
|
||||
public Optional<UserMap> getByUserAndMapAreaId(Chu3UserData user, int mapId) {
|
||||
return userMapRepository.findTopByUserAndMapAreaIdOrderByIdDesc(user, mapId);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue