mirror of https://github.com/hykilpikonna/AquaDX
[+] Add field isBound to Card
parent
806953d107
commit
a128546954
|
@ -348,7 +348,7 @@ public class ApiOngekiPlayerDataController {
|
|||
|
||||
var rivalDataList = userDataRepository.findByCard_ExtIdIn(rivalUserIds)
|
||||
.stream()
|
||||
.map(x -> new UserRivalData(x.getCard().getExtId().longValue(), x.getUserName()))
|
||||
.map(x -> new UserRivalData(x.getCard().getExtId(), x.getUserName()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return rivalDataList;
|
||||
|
|
|
@ -61,7 +61,7 @@ public class FeliCaLookup2Handler implements BaseHandler {
|
|||
long aimeId = -1;
|
||||
Optional<Card> card = cardRepository.findByLuid(accessCode.toString());
|
||||
if (card.isPresent()) {
|
||||
aimeId = card.get().getExtId().longValue();
|
||||
aimeId = card.get().getExtId();
|
||||
}
|
||||
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
|
|
|
@ -48,7 +48,7 @@ public class Lookup2Handler implements BaseHandler {
|
|||
long aimeId = -1;
|
||||
Optional<Card> card = cardRepository.findByLuid((String) requestMap.get("luid"));
|
||||
if (card.isPresent()) {
|
||||
aimeId = card.get().getExtId().longValue();
|
||||
aimeId = card.get().getExtId();
|
||||
}
|
||||
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
|
|
|
@ -50,7 +50,7 @@ public class LookupHandler implements BaseHandler {
|
|||
long aimeId = -1;
|
||||
Optional<Card> card = cardRepository.findByLuid((String) requestMap.get("luid"));
|
||||
if (card.isPresent()) {
|
||||
aimeId = card.get().getExtId().longValue();
|
||||
aimeId = card.get().getExtId();
|
||||
}
|
||||
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
|
|
|
@ -51,7 +51,7 @@ public class RegisterHandler implements BaseHandler {
|
|||
Card card = cardService.registerByAccessCode((String) requestMap.get("luid"));
|
||||
|
||||
resultMap.put("status", 1);
|
||||
resultMap.put("aimeId", card.getExtId().longValue());
|
||||
resultMap.put("aimeId", card.getExtId());
|
||||
} else {
|
||||
logger.warn("Duplicated Aime Card Register detected, access code: {}", requestMap.get("luid"));
|
||||
resultMap.put("status", 0);
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
package icu.samnyan.aqua.sega.general.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import icu.samnyan.aqua.net.db.AquaNetUser;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Entity(name = "SegaCard")
|
||||
@Table(name = "sega_card")
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Card implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@JsonIgnore
|
||||
private long id;
|
||||
|
||||
// A external id
|
||||
@Column(name = "ext_id", unique = true)
|
||||
@JsonIgnore // Sensitive information
|
||||
private Long extId;
|
||||
|
||||
// Access Code
|
||||
@Column(unique = true)
|
||||
private String luid;
|
||||
|
||||
@Column(name = "register_time")
|
||||
private LocalDateTime registerTime;
|
||||
|
||||
@Column(name = "access_time")
|
||||
private LocalDateTime accessTime;
|
||||
|
||||
// Defines the AquaNet user that this card is bound to
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "net_user_id")
|
||||
@JsonIgnore
|
||||
private AquaNetUser aquaUser;
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package icu.samnyan.aqua.sega.general.model
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore
|
||||
import icu.samnyan.aqua.net.db.AquaNetUser
|
||||
import jakarta.persistence.*
|
||||
import java.io.Serial
|
||||
import java.io.Serializable
|
||||
import java.time.LocalDateTime
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Entity(name = "SegaCard")
|
||||
@Table(name = "sega_card")
|
||||
class Card(
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@JsonIgnore
|
||||
val id: Long = 0,
|
||||
|
||||
// A external id
|
||||
@Column(name = "ext_id", unique = true, nullable = false)
|
||||
@JsonIgnore // Sensitive information
|
||||
var extId: Long = 0,
|
||||
|
||||
// Access Code
|
||||
@Column(unique = true, nullable = false)
|
||||
var luid: String = "",
|
||||
|
||||
@Column(name = "register_time", nullable = false)
|
||||
var registerTime: LocalDateTime = LocalDateTime.now(),
|
||||
|
||||
@Column(name = "access_time", nullable = false)
|
||||
var accessTime: LocalDateTime = registerTime,
|
||||
|
||||
// Defines the AquaNet user that this card is bound to
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "net_user_id")
|
||||
@JsonIgnore
|
||||
var aquaUser: AquaNetUser? = null,
|
||||
): Serializable {
|
||||
companion object {
|
||||
@Serial
|
||||
private val serialVersionUID = 1L
|
||||
}
|
||||
|
||||
val isBound get() = aquaUser != null
|
||||
}
|
|
@ -40,7 +40,7 @@ class CardService(val cardRepo: CardRepository) {
|
|||
* @param accessCode String represent of an access code
|
||||
* @return a new registered Card
|
||||
*/
|
||||
fun registerByAccessCode(accessCode: String?): Card = cardRepo.save(Card().apply {
|
||||
fun registerByAccessCode(accessCode: String): Card = cardRepo.save(Card().apply {
|
||||
luid = accessCode
|
||||
extId = randExtID()
|
||||
registerTime = LocalDateTime.now()
|
||||
|
|
|
@ -38,7 +38,7 @@ public class GetUserRivalDataHandler implements BaseHandler {
|
|||
@Override
|
||||
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
||||
var userRivalId = ((Number) request.get("userId")).longValue();
|
||||
var userRivalList = ((Collection<HashMap<String,Object>>)request.get("userRivalList"))
|
||||
var userRivalList = ((Collection<HashMap<String,Object>>) request.get("userRivalList"))
|
||||
.stream()
|
||||
.map(x->((Number)x.get("rivalUserId")).longValue())
|
||||
.collect(Collectors.toList());
|
||||
|
@ -49,7 +49,7 @@ public class GetUserRivalDataHandler implements BaseHandler {
|
|||
var userInfos = userDataRepository
|
||||
.findByCard_ExtIdIn(userRivalList)
|
||||
.stream()
|
||||
.map(x -> new UserRivalData(x.getCard().getExtId().longValue(), x.getUserName()))
|
||||
.map(x -> new UserRivalData(x.getCard().getExtId(), x.getUserName()))
|
||||
.toArray();
|
||||
|
||||
resultMap.put("length", userInfos.length);
|
||||
|
|
Loading…
Reference in New Issue