mirror of https://github.com/hykilpikonna/AquaDX
[+] Ongeki adaptor
parent
1c8860c596
commit
bb2c8ae8e5
|
@ -455,7 +455,7 @@ public class ApiOngekiPlayerDataController {
|
|||
Card card;
|
||||
if (cardOptional.isPresent()) {
|
||||
card = cardOptional.get();
|
||||
Optional<UserData> existUserData = userDataRepository.findByCard(cardOptional.get());
|
||||
Optional<UserData> existUserData = Optional.ofNullable(userDataRepository.findByCard(cardOptional.get()));
|
||||
if (existUserData.isPresent()) {
|
||||
// return ResponseEntity.status(HttpStatus.BAD_REQUEST)
|
||||
// .body(new MessageResponse("This card already has a ongeki profile."));
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package icu.samnyan.aqua.net.games
|
||||
|
||||
import ext.API
|
||||
import ext.RP
|
||||
|
||||
data class TrendOut(val date: String, val rating: Int, val plays: Int)
|
||||
|
||||
|
@ -41,7 +42,7 @@ data class GenericGameSummary(
|
|||
|
||||
interface GameApiController {
|
||||
@API("trend")
|
||||
fun trend(username: String): List<TrendOut>
|
||||
fun trend(@RP username: String): List<TrendOut>
|
||||
@API("user-summary")
|
||||
fun userSummary(username: String): GenericGameSummary
|
||||
fun userSummary(@RP username: String): GenericGameSummary
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package icu.samnyan.aqua.net.games
|
||||
|
||||
import ext.API
|
||||
import icu.samnyan.aqua.net.db.AquaUserServices
|
||||
import icu.samnyan.aqua.net.utils.TrendLog
|
||||
import icu.samnyan.aqua.net.utils.findTrend
|
||||
import icu.samnyan.aqua.net.utils.genericUserSummary
|
||||
import icu.samnyan.aqua.net.utils.ongekiScores
|
||||
import icu.samnyan.aqua.sega.ongeki.dao.userdata.UserDataRepository
|
||||
import icu.samnyan.aqua.sega.ongeki.dao.userdata.UserGeneralDataRepository
|
||||
import icu.samnyan.aqua.sega.ongeki.dao.userdata.UserPlaylogRepository
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
|
||||
@RestController
|
||||
@API("api/v2/game/ongeki")
|
||||
class Ongeki(
|
||||
val us: AquaUserServices,
|
||||
val userPlaylogRepository: UserPlaylogRepository,
|
||||
val userDataRepository: UserDataRepository,
|
||||
val userGeneralDataRepository: UserGeneralDataRepository
|
||||
): GameApiController {
|
||||
override fun trend(username: String) = us.byName(username) { u ->
|
||||
findTrend(userPlaylogRepository.findByUser_Card_ExtId(u.ghostCard.extId)
|
||||
.map { TrendLog(it.playDate, it.playerRating) })
|
||||
}
|
||||
|
||||
private val shownRanks = ongekiScores.filter { it.first >= 950000 }
|
||||
|
||||
override fun userSummary(username: String) = us.byName(username) { u ->
|
||||
// val extra = userGeneralDataRepository.findByUser_Card_ExtId(u.ghostCard.extId)
|
||||
// .associate { it.propertyKey to it.propertyValue }
|
||||
|
||||
// TODO: Rating composition
|
||||
|
||||
genericUserSummary(u, userDataRepository, userPlaylogRepository, shownRanks, mapOf())
|
||||
}
|
||||
}
|
|
@ -30,4 +30,19 @@ val chu3Scores = listOf(
|
|||
60.0 to "B",
|
||||
50.0 to "C",
|
||||
0.0 to "D",
|
||||
).map { (k, v) -> (k * 10000).toInt() to v }
|
||||
|
||||
val ongekiScores = listOf(
|
||||
100.75 to "SSS+",
|
||||
100.0 to "SSS",
|
||||
99.0 to "SS",
|
||||
97.0 to "S",
|
||||
94.0 to "AAA",
|
||||
90.0 to "AA",
|
||||
85.0 to "A",
|
||||
80.0 to "BBB",
|
||||
75.0 to "BB",
|
||||
70.0 to "B",
|
||||
50.0 to "C",
|
||||
0.0 to "D",
|
||||
).map { (k, v) -> (k * 10000).toInt() to v }
|
|
@ -1,5 +1,6 @@
|
|||
package icu.samnyan.aqua.sega.ongeki.dao.userdata;
|
||||
|
||||
import icu.samnyan.aqua.net.utils.GenericUserDataRepo;
|
||||
import icu.samnyan.aqua.sega.general.model.Card;
|
||||
import icu.samnyan.aqua.sega.ongeki.model.userdata.UserData;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
@ -14,10 +15,10 @@ import java.util.Optional;
|
|||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Repository("OngekiUserDataRepository")
|
||||
public interface UserDataRepository extends JpaRepository<UserData, Long> {
|
||||
public interface UserDataRepository extends JpaRepository<UserData, Long>, GenericUserDataRepo {
|
||||
List<UserData> findByCard_ExtIdIn(Collection<Long> userIds);
|
||||
|
||||
Optional<UserData> findByCard(Card card);
|
||||
UserData findByCard(Card card);
|
||||
|
||||
Optional<UserData> findByCard_ExtId(long aimeId);
|
||||
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
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.UserPlaylog;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Repository("OngekiUserPlaylogRepository")
|
||||
public interface UserPlaylogRepository extends JpaRepository<UserPlaylog, Long> {
|
||||
|
||||
List<UserPlaylog> findByUser_Card_ExtId(long userId);
|
||||
|
||||
Page<UserPlaylog> findByUser_Card_ExtId(long userId, Pageable page);
|
||||
|
||||
List<UserPlaylog> findByUser_Card_ExtIdAndMusicIdAndLevel(long userId, int musicId, int level);
|
||||
|
||||
@Transactional
|
||||
void deleteByUser(UserData user);
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package icu.samnyan.aqua.sega.ongeki.dao.userdata
|
||||
|
||||
import icu.samnyan.aqua.net.utils.GenericPlaylogRepo
|
||||
import icu.samnyan.aqua.sega.ongeki.model.userdata.UserData
|
||||
import icu.samnyan.aqua.sega.ongeki.model.userdata.UserPlaylog
|
||||
import org.springframework.data.domain.Page
|
||||
import org.springframework.data.domain.Pageable
|
||||
import org.springframework.data.jpa.repository.JpaRepository
|
||||
import org.springframework.stereotype.Repository
|
||||
import org.springframework.transaction.annotation.Transactional
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Repository("OngekiUserPlaylogRepository")
|
||||
interface UserPlaylogRepository : JpaRepository<UserPlaylog, Long>, GenericPlaylogRepo {
|
||||
fun findByUser_Card_ExtId(userId: Long): List<UserPlaylog>
|
||||
|
||||
fun findByUser_Card_ExtId(userId: Long, page: Pageable): Page<UserPlaylog>
|
||||
|
||||
fun findByUser_Card_ExtIdAndMusicIdAndLevel(userId: Long, musicId: Int, level: Int): List<UserPlaylog>
|
||||
|
||||
@Transactional
|
||||
fun deleteByUser(user: UserData)
|
||||
}
|
|
@ -3,6 +3,7 @@ package icu.samnyan.aqua.sega.ongeki.model.userdata;
|
|||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import icu.samnyan.aqua.net.utils.IGenericUserData;
|
||||
import icu.samnyan.aqua.sega.general.model.Card;
|
||||
import icu.samnyan.aqua.sega.util.jackson.AccessCodeSerializer;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
@ -20,7 +21,7 @@ import java.io.Serializable;
|
|||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class UserData implements Serializable {
|
||||
public class UserData implements Serializable, IGenericUserData {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
@ -157,4 +158,13 @@ public class UserData implements Serializable {
|
|||
|
||||
private int lastEmoneyBrand;
|
||||
|
||||
@Override
|
||||
public int getIconId() {
|
||||
return characterId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTotalScore() {
|
||||
return sumTechHighScore;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,11 +2,14 @@ package icu.samnyan.aqua.sega.ongeki.model.userdata;
|
|||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import icu.samnyan.aqua.net.utils.IGenericGamePlaylog;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
|
@ -17,7 +20,7 @@ import java.io.Serializable;
|
|||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class UserPlaylog implements Serializable {
|
||||
public class UserPlaylog implements Serializable, IGenericGamePlaylog {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
@ -157,4 +160,24 @@ public class UserPlaylog implements Serializable {
|
|||
|
||||
private int battlePoint;
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Object getDate() {
|
||||
return playDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAchievement() {
|
||||
return techScore;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTotalCombo() {
|
||||
return maxCombo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAfterRating() {
|
||||
return playerRating;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue