mirror of
https://github.com/MewoLab/AquaDX.git
synced 2026-02-11 10:57:28 +08:00
[M] Rename field
This commit is contained in:
@@ -129,48 +129,48 @@ public class ApiMaimai2PlayerDataController {
|
|||||||
|
|
||||||
@GetMapping("profile")
|
@GetMapping("profile")
|
||||||
public ProfileResp getProfile(@RequestParam long aimeId) {
|
public ProfileResp getProfile(@RequestParam long aimeId) {
|
||||||
return mapper.convert(userDataRepository.findByCard_ExtId(aimeId).orElseThrow(), new TypeReference<>() {
|
return mapper.convert(userDataRepository.findByCardExtId(aimeId).orElseThrow(), new TypeReference<>() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("profile/username")
|
@PostMapping("profile/username")
|
||||||
public UserDetail updateName(@RequestBody Map<String, Object> request) {
|
public UserDetail updateName(@RequestBody Map<String, Object> request) {
|
||||||
UserDetail profile = userDataRepository.findByCard_ExtId(((Number) request.get("aimeId")).longValue()).orElseThrow();
|
UserDetail profile = userDataRepository.findByCardExtId(((Number) request.get("aimeId")).longValue()).orElseThrow();
|
||||||
profile.setUserName((String) request.get("userName"));
|
profile.setUserName((String) request.get("userName"));
|
||||||
return userDataRepository.save(profile);
|
return userDataRepository.save(profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("profile/icon")
|
@PostMapping("profile/icon")
|
||||||
public UserDetail updateIcon(@RequestBody Map<String, Object> request) {
|
public UserDetail updateIcon(@RequestBody Map<String, Object> request) {
|
||||||
UserDetail profile = userDataRepository.findByCard_ExtId(((Number) request.get("aimeId")).longValue()).orElseThrow();
|
UserDetail profile = userDataRepository.findByCardExtId(((Number) request.get("aimeId")).longValue()).orElseThrow();
|
||||||
profile.setIconId((Integer) request.get("iconId"));
|
profile.setIconId((Integer) request.get("iconId"));
|
||||||
return userDataRepository.save(profile);
|
return userDataRepository.save(profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("profile/plate")
|
@PostMapping("profile/plate")
|
||||||
public UserDetail updatePlate(@RequestBody Map<String, Object> request) {
|
public UserDetail updatePlate(@RequestBody Map<String, Object> request) {
|
||||||
UserDetail profile = userDataRepository.findByCard_ExtId(((Number) request.get("aimeId")).longValue()).orElseThrow();
|
UserDetail profile = userDataRepository.findByCardExtId(((Number) request.get("aimeId")).longValue()).orElseThrow();
|
||||||
profile.setPlateId((Integer) request.get("plateId"));
|
profile.setPlateId((Integer) request.get("plateId"));
|
||||||
return userDataRepository.save(profile);
|
return userDataRepository.save(profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("profile/frame")
|
@PostMapping("profile/frame")
|
||||||
public UserDetail updateFrame(@RequestBody Map<String, Object> request) {
|
public UserDetail updateFrame(@RequestBody Map<String, Object> request) {
|
||||||
UserDetail profile = userDataRepository.findByCard_ExtId(((Number) request.get("aimeId")).longValue()).orElseThrow();
|
UserDetail profile = userDataRepository.findByCardExtId(((Number) request.get("aimeId")).longValue()).orElseThrow();
|
||||||
profile.setFrameId((Integer) request.get("frameId"));
|
profile.setFrameId((Integer) request.get("frameId"));
|
||||||
return userDataRepository.save(profile);
|
return userDataRepository.save(profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("profile/title")
|
@PostMapping("profile/title")
|
||||||
public UserDetail updateTrophy(@RequestBody Map<String, Object> request) {
|
public UserDetail updateTrophy(@RequestBody Map<String, Object> request) {
|
||||||
UserDetail profile = userDataRepository.findByCard_ExtId(((Number) request.get("aimeId")).longValue()).orElseThrow();
|
UserDetail profile = userDataRepository.findByCardExtId(((Number) request.get("aimeId")).longValue()).orElseThrow();
|
||||||
profile.setTitleId((Integer) request.get("titleId"));
|
profile.setTitleId((Integer) request.get("titleId"));
|
||||||
return userDataRepository.save(profile);
|
return userDataRepository.save(profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("profile/partner")
|
@PostMapping("profile/partner")
|
||||||
public UserDetail updatePartner(@RequestBody Map<String, Object> request) {
|
public UserDetail updatePartner(@RequestBody Map<String, Object> request) {
|
||||||
UserDetail profile = userDataRepository.findByCard_ExtId(((Number) request.get("aimeId")).longValue()).orElseThrow();
|
UserDetail profile = userDataRepository.findByCardExtId(((Number) request.get("aimeId")).longValue()).orElseThrow();
|
||||||
profile.setPartnerId((Integer) request.get("partnerId"));
|
profile.setPartnerId((Integer) request.get("partnerId"));
|
||||||
return userDataRepository.save(profile);
|
return userDataRepository.save(profile);
|
||||||
}
|
}
|
||||||
@@ -205,7 +205,7 @@ public class ApiMaimai2PlayerDataController {
|
|||||||
|
|
||||||
@PostMapping("item")
|
@PostMapping("item")
|
||||||
public ResponseEntity<Object> updateItem(@RequestBody Map<String, Object> request) {
|
public ResponseEntity<Object> updateItem(@RequestBody Map<String, Object> request) {
|
||||||
UserDetail profile = userDataRepository.findByCard_ExtId(((Number) request.get("aimeId")).longValue()).orElseThrow();
|
UserDetail profile = userDataRepository.findByCardExtId(((Number) request.get("aimeId")).longValue()).orElseThrow();
|
||||||
Integer itemKind = (Integer) request.get("itemKind");
|
Integer itemKind = (Integer) request.get("itemKind");
|
||||||
Integer itemId = (Integer) request.get("itemId");
|
Integer itemId = (Integer) request.get("itemId");
|
||||||
int stock = 1;
|
int stock = 1;
|
||||||
@@ -254,7 +254,7 @@ public class ApiMaimai2PlayerDataController {
|
|||||||
|
|
||||||
@PostMapping("options")
|
@PostMapping("options")
|
||||||
public ResponseEntity<Object> updateOptions(@RequestBody Map<String, Object> request) {
|
public ResponseEntity<Object> updateOptions(@RequestBody Map<String, Object> request) {
|
||||||
UserDetail profile = userDataRepository.findByCard_ExtId(((Number) request.get("aimeId")).longValue()).orElseThrow();
|
UserDetail profile = userDataRepository.findByCardExtId(((Number) request.get("aimeId")).longValue()).orElseThrow();
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
UserOption userOption = objectMapper.convertValue(request.get("options"), UserOption.class);
|
UserOption userOption = objectMapper.convertValue(request.get("options"), UserOption.class);
|
||||||
userOption.setUser(profile);
|
userOption.setUser(profile);
|
||||||
@@ -272,7 +272,7 @@ public class ApiMaimai2PlayerDataController {
|
|||||||
|
|
||||||
@PostMapping("general")
|
@PostMapping("general")
|
||||||
public ResponseEntity<Object> setGeneralData(@RequestBody Map<String, Object> request) {
|
public ResponseEntity<Object> setGeneralData(@RequestBody Map<String, Object> request) {
|
||||||
UserDetail profile = userDataRepository.findByCard_ExtId(((Number) request.get("aimeId")).longValue()).orElseThrow();
|
UserDetail profile = userDataRepository.findByCardExtId(((Number) request.get("aimeId")).longValue()).orElseThrow();
|
||||||
String key = (String) request.get("key");
|
String key = (String) request.get("key");
|
||||||
String value = (String) request.get("value");
|
String value = (String) request.get("value");
|
||||||
|
|
||||||
@@ -294,7 +294,7 @@ public class ApiMaimai2PlayerDataController {
|
|||||||
Maimai2DataExport data = new Maimai2DataExport();
|
Maimai2DataExport data = new Maimai2DataExport();
|
||||||
try {
|
try {
|
||||||
data.setGameId("SDEZ");
|
data.setGameId("SDEZ");
|
||||||
data.setUserData(userDataRepository.findByCard_ExtId(aimeId).orElseThrow());
|
data.setUserData(userDataRepository.findByCardExtId(aimeId).orElseThrow());
|
||||||
data.setUserExtend(userExtendRepository.findByUser_Card_ExtId(aimeId).orElseThrow());
|
data.setUserExtend(userExtendRepository.findByUser_Card_ExtId(aimeId).orElseThrow());
|
||||||
data.setUserOption(userOptionRepository.findByUser_Card_ExtId(aimeId).orElseThrow());
|
data.setUserOption(userOptionRepository.findByUser_Card_ExtId(aimeId).orElseThrow());
|
||||||
data.setUserUdemae(userUdemaeRepository.findByUser_Card_ExtId(aimeId).orElseThrow());
|
data.setUserUdemae(userUdemaeRepository.findByUser_Card_ExtId(aimeId).orElseThrow());
|
||||||
@@ -336,7 +336,7 @@ public class ApiMaimai2PlayerDataController {
|
|||||||
Card card;
|
Card card;
|
||||||
if (cardOptional.isPresent()) {
|
if (cardOptional.isPresent()) {
|
||||||
card = cardOptional.get();
|
card = cardOptional.get();
|
||||||
Optional<UserDetail> existUserData = userDataRepository.findByCard(cardOptional.get());
|
Optional<UserDetail> existUserData = Optional.ofNullable(userDataRepository.findByCard(cardOptional.get()));
|
||||||
if (existUserData.isPresent()) {
|
if (existUserData.isPresent()) {
|
||||||
// return ResponseEntity.status(HttpStatus.BAD_REQUEST)
|
// return ResponseEntity.status(HttpStatus.BAD_REQUEST)
|
||||||
// .body(new MessageResponse("This card already has a maimai2 profile."));
|
// .body(new MessageResponse("This card already has a maimai2 profile."));
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ class CardGameService(
|
|||||||
"maimai" -> maimai.findByCard_ExtId(crd.extId).getOrNull()?.let {
|
"maimai" -> maimai.findByCard_ExtId(crd.extId).getOrNull()?.let {
|
||||||
maimai.save(it.apply { card = crd.aquaUser!!.ghostCard })
|
maimai.save(it.apply { card = crd.aquaUser!!.ghostCard })
|
||||||
}
|
}
|
||||||
"maimai2" -> maimai2.findByCard_ExtId(crd.extId).getOrNull()?.let {
|
"maimai2" -> maimai2.findByCardExtId(crd.extId).getOrNull()?.let {
|
||||||
maimai2.save(it.apply { card = crd.aquaUser!!.ghostCard })
|
maimai2.save(it.apply { card = crd.aquaUser!!.ghostCard })
|
||||||
}
|
}
|
||||||
"chusan" -> chusan.findByCard_ExtId(crd.extId).getOrNull()?.let {
|
"chusan" -> chusan.findByCard_ExtId(crd.extId).getOrNull()?.let {
|
||||||
@@ -136,7 +136,7 @@ class CardGameService(
|
|||||||
"lastLogin" to it.lastPlayDate,
|
"lastLogin" to it.lastPlayDate,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
"maimai2" to maimai2.findByCard_ExtId(card.extId).getOrNull()?.let {
|
"maimai2" to maimai2.findByCardExtId(card.extId).getOrNull()?.let {
|
||||||
mapOf(
|
mapOf(
|
||||||
"name" to it.userName,
|
"name" to it.userName,
|
||||||
"rating" to it.playerRating,
|
"rating" to it.playerRating,
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
package icu.samnyan.aqua.sega.maimai2.dao.userdata;
|
|
||||||
|
|
||||||
import icu.samnyan.aqua.sega.general.model.Card;
|
|
||||||
import icu.samnyan.aqua.sega.maimai2.model.userdata.UserDetail;
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
|
||||||
import org.springframework.data.jpa.repository.Query;
|
|
||||||
import org.springframework.stereotype.Repository;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author samnyan (privateamusement@protonmail.com)
|
|
||||||
*/
|
|
||||||
@Repository("Maimai2UserDataRepository")
|
|
||||||
public interface UserDataRepository extends JpaRepository<UserDetail, Long> {
|
|
||||||
|
|
||||||
Optional<UserDetail> findByCard(Card card);
|
|
||||||
|
|
||||||
Optional<UserDetail> findByCard_ExtId(long userId);
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
void deleteByCard(Card card);
|
|
||||||
|
|
||||||
@Query("select count(*) from Maimai2UserData where playerRating > :rating")
|
|
||||||
Integer getRanking(int rating);
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package icu.samnyan.aqua.sega.maimai2.dao.userdata
|
||||||
|
|
||||||
|
import icu.samnyan.aqua.sega.general.model.Card
|
||||||
|
import icu.samnyan.aqua.sega.maimai2.model.userdata.UserDetail
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository
|
||||||
|
import org.springframework.data.jpa.repository.Query
|
||||||
|
import org.springframework.stereotype.Repository
|
||||||
|
import org.springframework.transaction.annotation.Transactional
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
|
||||||
|
@Repository("Maimai2UserDataRepository")
|
||||||
|
interface UserDataRepository : JpaRepository<UserDetail, Long?> {
|
||||||
|
fun findByCard(card: Card): UserDetail?
|
||||||
|
|
||||||
|
fun findByCardExtId(userId: Long): Optional<UserDetail>
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
fun deleteByCard(card: Card)
|
||||||
|
|
||||||
|
@Query("select count(*) from Maimai2UserData where playerRating > :rating")
|
||||||
|
fun getRanking(rating: Int): Long
|
||||||
|
}
|
||||||
@@ -38,7 +38,7 @@ public class CMGetUserPreviewHandler implements BaseHandler {
|
|||||||
Long userId = ((Number) request.get("userId")).longValue();
|
Long userId = ((Number) request.get("userId")).longValue();
|
||||||
String segaIdAuthKey = String.valueOf(request.get("segaIdAuthKey"));
|
String segaIdAuthKey = String.valueOf(request.get("segaIdAuthKey"));
|
||||||
|
|
||||||
Optional<UserDetail> userDataOptional = userDataRepository.findByCard_ExtId(userId);
|
Optional<UserDetail> userDataOptional = userDataRepository.findByCardExtId(userId);
|
||||||
|
|
||||||
if (userDataOptional.isPresent()) {
|
if (userDataOptional.isPresent()) {
|
||||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public class GetUserDataHandler implements BaseHandler {
|
|||||||
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
||||||
long userId = ((Number) request.get("userId")).longValue();
|
long userId = ((Number) request.get("userId")).longValue();
|
||||||
|
|
||||||
UserDetail userData = userDataRepository.findByCard_ExtId(userId).orElseThrow();
|
UserDetail userData = userDataRepository.findByCardExtId(userId).orElseThrow();
|
||||||
|
|
||||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||||
resultMap.put("userId", userId);
|
resultMap.put("userId", userId);
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public class GetUserPreviewHandler implements BaseHandler {
|
|||||||
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
||||||
long userId = ((Number) request.get("userId")).longValue();
|
long userId = ((Number) request.get("userId")).longValue();
|
||||||
|
|
||||||
Optional<UserDetail> userDataOptional = userDataRepository.findByCard_ExtId(userId);
|
Optional<UserDetail> userDataOptional = userDataRepository.findByCardExtId(userId);
|
||||||
|
|
||||||
GetUserPreviewResp resp = new GetUserPreviewResp();
|
GetUserPreviewResp resp = new GetUserPreviewResp();
|
||||||
resp.setUserId(userId);
|
resp.setUserId(userId);
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class GetUserRatingHandler implements BaseHandler {
|
|||||||
|
|
||||||
UserRating userRating = new UserRating();
|
UserRating userRating = new UserRating();
|
||||||
|
|
||||||
Optional<UserDetail> userDataOptional = userDataRepository.findByCard_ExtId(userId);
|
Optional<UserDetail> userDataOptional = userDataRepository.findByCardExtId(userId);
|
||||||
if (userDataOptional.isPresent() && userDataOptional.get().getUserName() != null) {
|
if (userDataOptional.isPresent() && userDataOptional.get().getUserName() != null) {
|
||||||
UserDetail user = userDataOptional.get();
|
UserDetail user = userDataOptional.get();
|
||||||
userRating.setRating(user.getPlayerRating());
|
userRating.setRating(user.getPlayerRating());
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class GetUserRivalDataHandler {
|
|||||||
long userId = ((Number) request.get("userId")).longValue();
|
long userId = ((Number) request.get("userId")).longValue();
|
||||||
long rivalId = ((Number) request.get("rivalId")).intValue();
|
long rivalId = ((Number) request.get("rivalId")).intValue();
|
||||||
|
|
||||||
Optional<UserDetail> detailOptional = userDataRepository.findByCard_ExtId(rivalId);
|
Optional<UserDetail> detailOptional = userDataRepository.findByCardExtId(rivalId);
|
||||||
UserRivalData rivalData;
|
UserRivalData rivalData;
|
||||||
if (detailOptional.isPresent()) {
|
if (detailOptional.isPresent()) {
|
||||||
rivalData = new UserRivalData(rivalId, detailOptional.get().getUserName());
|
rivalData = new UserRivalData(rivalId, detailOptional.get().getUserName());
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public class UploadUserPlaylogHandler implements BaseHandler {
|
|||||||
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
||||||
UploadUserPlaylog uploadUserPlaylog = mapper.convert(request, UploadUserPlaylog.class);
|
UploadUserPlaylog uploadUserPlaylog = mapper.convert(request, UploadUserPlaylog.class);
|
||||||
|
|
||||||
Optional<UserDetail> userOptional = userDataRepository.findByCard_ExtId(uploadUserPlaylog.getUserId());
|
Optional<UserDetail> userOptional = userDataRepository.findByCardExtId(uploadUserPlaylog.getUserId());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Due to how we handle userId, first user playlog can't be saved.
|
Due to how we handle userId, first user playlog can't be saved.
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -86,7 +85,7 @@ public class UpsertUserAllHandler implements BaseHandler {
|
|||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
newUserData = userAll.getUserData().get(0);
|
newUserData = userAll.getUserData().get(0);
|
||||||
Optional<UserDetail> userOptional = userDataRepository.findByCard_ExtId(userId);
|
Optional<UserDetail> userOptional = userDataRepository.findByCardExtId(userId);
|
||||||
|
|
||||||
if (userOptional.isPresent()) {
|
if (userOptional.isPresent()) {
|
||||||
userData = userOptional.get();
|
userData = userOptional.get();
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class UpsertUserPrintHandler implements BaseHandler {
|
|||||||
|
|
||||||
UserDetail userData;
|
UserDetail userData;
|
||||||
|
|
||||||
Optional<UserDetail> userOptional = userDataRepository.findByCard_ExtId(userId);
|
Optional<UserDetail> userOptional = userDataRepository.findByCardExtId(userId);
|
||||||
if (userOptional.isPresent()) {
|
if (userOptional.isPresent()) {
|
||||||
userData = userOptional.get();
|
userData = userOptional.get();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user