mirror of https://github.com/hykilpikonna/AquaDX
[+] Re:Fresh: Extract user skin
parent
a978f0ee0c
commit
cdb716d508
|
@ -0,0 +1,21 @@
|
|||
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.UserSkin;
|
||||
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("OngekiUserSkinRepository")
|
||||
public interface UserSkinRepository extends JpaRepository<UserSkin, Long> {
|
||||
|
||||
List<UserSkin> findByUser_Card_ExtId(long userId);
|
||||
|
||||
@Transactional
|
||||
void deleteByUser(UserData user);
|
||||
}
|
|
@ -2,8 +2,8 @@ package icu.samnyan.aqua.sega.ongeki.handler.impl;
|
|||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.ongeki.dao.userdata.UserDeckRepository;
|
||||
import icu.samnyan.aqua.sega.ongeki.model.userdata.UserDeck;
|
||||
import icu.samnyan.aqua.sega.ongeki.dao.userdata.UserSkinRepository;
|
||||
import icu.samnyan.aqua.sega.ongeki.model.userdata.UserSkin;
|
||||
import icu.samnyan.aqua.sega.util.jackson.BasicMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -13,7 +13,6 @@ import org.springframework.stereotype.Component;
|
|||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
|
@ -25,12 +24,12 @@ public class GetUserSkinHandler implements BaseHandler {
|
|||
|
||||
private final BasicMapper mapper;
|
||||
|
||||
private final UserDeckRepository userDeckRepository;
|
||||
private final UserSkinRepository userSkinRepository;
|
||||
|
||||
@Autowired
|
||||
public GetUserSkinHandler(BasicMapper mapper, UserDeckRepository userDeckRepository) {
|
||||
public GetUserSkinHandler(BasicMapper mapper, UserSkinRepository userSkinRepository) {
|
||||
this.mapper = mapper;
|
||||
this.userDeckRepository = userDeckRepository;
|
||||
this.userSkinRepository = userSkinRepository;
|
||||
}
|
||||
|
||||
|
||||
|
@ -40,20 +39,7 @@ public class GetUserSkinHandler implements BaseHandler {
|
|||
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||
resultMap.put("userId", userId);
|
||||
// Get the list of user decks
|
||||
List<UserDeck> deckList = userDeckRepository.findByUser_Card_ExtId(userId);
|
||||
|
||||
// Convert each UserDeck to UserSkin
|
||||
List<Map<String, Object>> userSkinList = deckList.stream().map(deck -> {
|
||||
Map<String, Object> skinMap = new LinkedHashMap<>();
|
||||
skinMap.put("deckId", deck.getDeckId());
|
||||
skinMap.put("isValid", false);
|
||||
skinMap.put("cardId1", deck.getCardId1());
|
||||
skinMap.put("cardId2", deck.getCardId2());
|
||||
skinMap.put("cardId3", deck.getCardId3());
|
||||
return skinMap;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
List<UserSkin> userSkinList = userSkinRepository.findByUser_Card_ExtId(userId);
|
||||
resultMap.put("length", userSkinList.size());
|
||||
resultMap.put("userSkinList", userSkinList);
|
||||
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
package icu.samnyan.aqua.sega.ongeki.model.userdata;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Entity(name = "OngekiUserSkin")
|
||||
@Table(name = "ongeki_user_skin")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class UserSkin implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@JsonIgnore
|
||||
private long id;
|
||||
|
||||
@JsonIgnore
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "user_id")
|
||||
private UserData user;
|
||||
|
||||
//TODO: should be updated on net when changing skin
|
||||
private boolean isValid;
|
||||
|
||||
private int deckId;
|
||||
|
||||
private int cardId1;
|
||||
|
||||
private int cardId2;
|
||||
|
||||
private int cardId3;
|
||||
|
||||
public UserSkin(UserData userData) {
|
||||
this.user = userData;
|
||||
}
|
||||
}
|
|
@ -32,3 +32,18 @@ CREATE TABLE ongeki_user_event_map
|
|||
|
||||
ALTER TABLE ongeki_user_event_map
|
||||
ADD CONSTRAINT FKU_ONGEKI_USER_EVENT_MAP FOREIGN KEY (user_id) REFERENCES ongeki_user_data (id);
|
||||
|
||||
-- ongeki_user_skin
|
||||
CREATE TABLE ongeki_user_skin
|
||||
(
|
||||
id BIGINT AUTO_INCREMENT PRIMARY KEY,
|
||||
user_id BIGINT NULL,
|
||||
is_valid BIT NOT NULL,
|
||||
deck_id INT NOT NULL,
|
||||
card_id1 INT NOT NULL,
|
||||
card_id2 INT NOT NULL,
|
||||
card_id3 INT NOT NULL
|
||||
);
|
||||
|
||||
ALTER TABLE ongeki_user_skin
|
||||
ADD CONSTRAINT FKU_ONGEKI_USER_SKIN FOREIGN KEY (user_id) REFERENCES ongeki_user_data (id);
|
Loading…
Reference in New Issue