mirror of
https://github.com/MewoLab/AquaDX.git
synced 2026-02-10 18:47:26 +08:00
Merge branch 'master' into 'master'
[ongeki] some feature See merge request NeumPhis/aqua!1
This commit is contained in:
@@ -130,6 +130,7 @@ public class ApiOngekiPlayerDataController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Force insert a card. This will use to create a new card or update a currently existed card star level.
|
* Force insert a card. This will use to create a new card or update a currently existed card star level.
|
||||||
|
*
|
||||||
* @param request Map of aimeId and cardId
|
* @param request Map of aimeId and cardId
|
||||||
* @return result UserCard or error message
|
* @return result UserCard or error message
|
||||||
*/
|
*/
|
||||||
@@ -202,13 +203,19 @@ public class ApiOngekiPlayerDataController {
|
|||||||
if (gameCard.get().getRarity().equals("N")) {
|
if (gameCard.get().getRarity().equals("N")) {
|
||||||
card.setMaxLevel(100);
|
card.setMaxLevel(100);
|
||||||
card.setLevel(100);
|
card.setLevel(100);
|
||||||
|
card.setDigitalStock(11);
|
||||||
} else {
|
} else {
|
||||||
card.setMaxLevel(70);
|
card.setMaxLevel(70);
|
||||||
card.setLevel(70);
|
card.setLevel(70);
|
||||||
|
card.setDigitalStock(5);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
card.setMaxLevel(100);
|
card.setMaxLevel(70);
|
||||||
card.setLevel(100);
|
card.setLevel(70);
|
||||||
|
card.setDigitalStock(5);
|
||||||
|
}
|
||||||
|
if (card.getKaikaDate().equals("0000-00-00 00:00:00.0")) {
|
||||||
|
card.setKaikaDate(LocalDateTime.now().format(df));
|
||||||
}
|
}
|
||||||
card.setChoKaikaDate(LocalDateTime.now().format(df));
|
card.setChoKaikaDate(LocalDateTime.now().format(df));
|
||||||
card.setPrintCount(card.getPrintCount() + 1);
|
card.setPrintCount(card.getPrintCount() + 1);
|
||||||
@@ -368,11 +375,47 @@ public class ApiOngekiPlayerDataController {
|
|||||||
Optional<Card> cardOptional = cardService.getCardByAccessCode(exUser.getAccessCode());
|
Optional<Card> cardOptional = cardService.getCardByAccessCode(exUser.getAccessCode());
|
||||||
Card card;
|
Card card;
|
||||||
if (cardOptional.isPresent()) {
|
if (cardOptional.isPresent()) {
|
||||||
if (userDataRepository.findByCard(cardOptional.get()).isPresent()) {
|
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
|
|
||||||
.body(new MessageResponse("This card already has a ongeki profile."));
|
|
||||||
} else {
|
|
||||||
card = cardOptional.get();
|
card = cardOptional.get();
|
||||||
|
Optional<UserData> existUserData = userDataRepository.findByCard(cardOptional.get());
|
||||||
|
if (existUserData.isPresent()) {
|
||||||
|
// return ResponseEntity.status(HttpStatus.BAD_REQUEST)
|
||||||
|
// .body(new MessageResponse("This card already has a ongeki profile."));
|
||||||
|
// delete all same card data
|
||||||
|
userActivityRepository.deleteByUser(existUserData.get());
|
||||||
|
userActivityRepository.flush();
|
||||||
|
userCardRepository.deleteByUser(existUserData.get());
|
||||||
|
userCardRepository.flush();
|
||||||
|
userChapterRepository.deleteByUser(existUserData.get());
|
||||||
|
userChapterRepository.flush();
|
||||||
|
userCharacterRepository.deleteByUser(existUserData.get());
|
||||||
|
userCharacterRepository.flush();
|
||||||
|
userDeckRepository.deleteByUser(existUserData.get());
|
||||||
|
userDeckRepository.flush();
|
||||||
|
userEventPointRepository.deleteByUser(existUserData.get());
|
||||||
|
userEventPointRepository.flush();
|
||||||
|
userGeneralDataRepository.deleteByUser(existUserData.get());
|
||||||
|
userGeneralDataRepository.flush();
|
||||||
|
userItemRepository.deleteByUser(existUserData.get());
|
||||||
|
userItemRepository.flush();
|
||||||
|
userLoginBonusRepository.deleteByUser(existUserData.get());
|
||||||
|
userLoginBonusRepository.flush();
|
||||||
|
userMissionPointRepository.deleteByUser(existUserData.get());
|
||||||
|
userMissionPointRepository.flush();
|
||||||
|
userMusicDetailRepository.deleteByUser(existUserData.get());
|
||||||
|
userMusicDetailRepository.flush();
|
||||||
|
userMusicItemRepository.deleteByUser(existUserData.get());
|
||||||
|
userMusicItemRepository.flush();
|
||||||
|
userOptionRepository.deleteByUser(existUserData.get());
|
||||||
|
userOptionRepository.flush();
|
||||||
|
userPlaylogRepository.deleteByUser(existUserData.get());
|
||||||
|
userPlaylogRepository.flush();
|
||||||
|
userStoryRepository.deleteByUser(existUserData.get());
|
||||||
|
userStoryRepository.flush();
|
||||||
|
userTrainingRoomRepository.deleteByUser(existUserData.get());
|
||||||
|
userTrainingRoomRepository.flush();
|
||||||
|
|
||||||
|
userDataRepository.deleteByCard(card);
|
||||||
|
userDataRepository.flush();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
card = cardService.registerByAccessCode(exUser.getAccessCode());
|
card = cardService.registerByAccessCode(exUser.getAccessCode());
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import icu.samnyan.aqua.sega.ongeki.model.userdata.UserActivity;
|
|||||||
import icu.samnyan.aqua.sega.ongeki.model.userdata.UserData;
|
import icu.samnyan.aqua.sega.ongeki.model.userdata.UserData;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -20,4 +21,6 @@ public interface UserActivityRepository extends JpaRepository<UserActivity, Long
|
|||||||
|
|
||||||
List<UserActivity> findByUser_Card_ExtIdAndKindOrderBySortNumberDesc(int userId, int kind);
|
List<UserActivity> findByUser_Card_ExtIdAndKindOrderBySortNumberDesc(int userId, int kind);
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
void deleteByUser(UserData user);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import org.springframework.data.domain.Page;
|
|||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -24,4 +25,6 @@ public interface UserCardRepository extends JpaRepository<UserCard, Long> {
|
|||||||
|
|
||||||
Page<UserCard> findByUser_Card_ExtId(int userId, Pageable page);
|
Page<UserCard> findByUser_Card_ExtId(int userId, Pageable page);
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
void deleteByUser(UserData user);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import icu.samnyan.aqua.sega.ongeki.model.userdata.UserChapter;
|
|||||||
import icu.samnyan.aqua.sega.ongeki.model.userdata.UserData;
|
import icu.samnyan.aqua.sega.ongeki.model.userdata.UserData;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -18,4 +19,6 @@ public interface UserChapterRepository extends JpaRepository<UserChapter, Long>
|
|||||||
|
|
||||||
Optional<UserChapter> findByUserAndChapterId(UserData userData, int chapterId);
|
Optional<UserChapter> findByUserAndChapterId(UserData userData, int chapterId);
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
void deleteByUser(UserData user);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import org.springframework.data.domain.Page;
|
|||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -22,4 +23,6 @@ public interface UserCharacterRepository extends JpaRepository<UserCharacter, Lo
|
|||||||
|
|
||||||
Optional<UserCharacter> findByUserAndCharacterId(UserData userData, int characterId);
|
Optional<UserCharacter> findByUserAndCharacterId(UserData userData, int characterId);
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
void deleteByUser(UserData user);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import icu.samnyan.aqua.sega.general.model.Card;
|
|||||||
import icu.samnyan.aqua.sega.ongeki.model.userdata.UserData;
|
import icu.samnyan.aqua.sega.ongeki.model.userdata.UserData;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@@ -17,4 +18,6 @@ public interface UserDataRepository extends JpaRepository<UserData, Long> {
|
|||||||
|
|
||||||
Optional<UserData> findByCard_ExtId(int aimeId);
|
Optional<UserData> findByCard_ExtId(int aimeId);
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
void deleteByCard(Card card);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import icu.samnyan.aqua.sega.ongeki.model.userdata.UserData;
|
|||||||
import icu.samnyan.aqua.sega.ongeki.model.userdata.UserDeck;
|
import icu.samnyan.aqua.sega.ongeki.model.userdata.UserDeck;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -18,4 +19,6 @@ public interface UserDeckRepository extends JpaRepository<UserDeck, Long> {
|
|||||||
|
|
||||||
Optional<UserDeck> findByUserAndDeckId(UserData userData, int deckId);
|
Optional<UserDeck> findByUserAndDeckId(UserData userData, int deckId);
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
void deleteByUser(UserData user);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import icu.samnyan.aqua.sega.ongeki.model.userdata.UserData;
|
|||||||
import icu.samnyan.aqua.sega.ongeki.model.userdata.UserEventPoint;
|
import icu.samnyan.aqua.sega.ongeki.model.userdata.UserEventPoint;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -18,4 +19,6 @@ public interface UserEventPointRepository extends JpaRepository<UserEventPoint,
|
|||||||
|
|
||||||
Optional<UserEventPoint> findByUserAndEventId(UserData userData, int eventId);
|
Optional<UserEventPoint> findByUserAndEventId(UserData userData, int eventId);
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
void deleteByUser(UserData user);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import icu.samnyan.aqua.sega.ongeki.model.userdata.UserData;
|
|||||||
import icu.samnyan.aqua.sega.ongeki.model.userdata.UserGeneralData;
|
import icu.samnyan.aqua.sega.ongeki.model.userdata.UserGeneralData;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -20,4 +21,6 @@ public interface UserGeneralDataRepository extends JpaRepository<UserGeneralData
|
|||||||
|
|
||||||
Optional<UserGeneralData> findByUser_Card_ExtIdAndPropertyKey(int userId, String key);
|
Optional<UserGeneralData> findByUser_Card_ExtIdAndPropertyKey(int userId, String key);
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
void deleteByUser(UserData user);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import org.springframework.data.domain.Page;
|
|||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -24,4 +25,6 @@ public interface UserItemRepository extends JpaRepository<UserItem, Long> {
|
|||||||
|
|
||||||
Page<UserItem> findByUser_Card_ExtIdAndItemKind(int userId, int kind, Pageable page);
|
Page<UserItem> findByUser_Card_ExtIdAndItemKind(int userId, int kind, Pageable page);
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
void deleteByUser(UserData user);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ 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.UserData;
|
||||||
import icu.samnyan.aqua.sega.ongeki.model.userdata.UserLoginBonus;
|
import icu.samnyan.aqua.sega.ongeki.model.userdata.UserLoginBonus;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -16,4 +17,6 @@ public interface UserLoginBonusRepository extends JpaRepository<UserLoginBonus,
|
|||||||
|
|
||||||
Optional<UserLoginBonus> findByUserAndBonusId(UserData userData, int bonusId);
|
Optional<UserLoginBonus> findByUserAndBonusId(UserData userData, int bonusId);
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
void deleteByUser(UserData user);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import icu.samnyan.aqua.sega.ongeki.model.userdata.UserData;
|
|||||||
import icu.samnyan.aqua.sega.ongeki.model.userdata.UserMissionPoint;
|
import icu.samnyan.aqua.sega.ongeki.model.userdata.UserMissionPoint;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -18,4 +19,6 @@ public interface UserMissionPointRepository extends JpaRepository<UserMissionPoi
|
|||||||
|
|
||||||
Optional<UserMissionPoint> findByUserAndEventId(UserData userData, int eventId);
|
Optional<UserMissionPoint> findByUserAndEventId(UserData userData, int eventId);
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
void deleteByUser(UserData user);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import org.springframework.data.domain.Page;
|
|||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -24,4 +25,6 @@ public interface UserMusicDetailRepository extends JpaRepository<UserMusicDetail
|
|||||||
|
|
||||||
Optional<UserMusicDetail> findByUserAndMusicIdAndLevel(UserData userData, int musicId, int level);
|
Optional<UserMusicDetail> findByUserAndMusicIdAndLevel(UserData userData, int musicId, int level);
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
void deleteByUser(UserData user);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import org.springframework.data.domain.Page;
|
|||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -22,4 +23,6 @@ public interface UserMusicItemRepository extends JpaRepository<UserMusicItem, Lo
|
|||||||
|
|
||||||
Optional<UserMusicItem> findByUserAndMusicId(UserData userData, int musicId);
|
Optional<UserMusicItem> findByUserAndMusicId(UserData userData, int musicId);
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
void deleteByUser(UserData user);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import icu.samnyan.aqua.sega.ongeki.model.userdata.UserData;
|
|||||||
import icu.samnyan.aqua.sega.ongeki.model.userdata.UserOption;
|
import icu.samnyan.aqua.sega.ongeki.model.userdata.UserOption;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@@ -17,4 +18,6 @@ public interface UserOptionRepository extends JpaRepository<UserOption, Long> {
|
|||||||
|
|
||||||
Optional<UserOption> findByUser_Card_ExtId(int userId);
|
Optional<UserOption> findByUser_Card_ExtId(int userId);
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
void deleteByUser(UserData user);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
package icu.samnyan.aqua.sega.ongeki.dao.userdata;
|
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 icu.samnyan.aqua.sega.ongeki.model.userdata.UserPlaylog;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -20,4 +22,6 @@ public interface UserPlaylogRepository extends JpaRepository<UserPlaylog, Long>
|
|||||||
|
|
||||||
List<UserPlaylog> findByUser_Card_ExtIdAndMusicIdAndLevel(Integer userId, int musicId, int level);
|
List<UserPlaylog> findByUser_Card_ExtIdAndMusicIdAndLevel(Integer userId, int musicId, int level);
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
void deleteByUser(UserData user);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import icu.samnyan.aqua.sega.ongeki.model.userdata.UserData;
|
|||||||
import icu.samnyan.aqua.sega.ongeki.model.userdata.UserStory;
|
import icu.samnyan.aqua.sega.ongeki.model.userdata.UserStory;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -18,4 +19,6 @@ public interface UserStoryRepository extends JpaRepository<UserStory, Long> {
|
|||||||
|
|
||||||
Optional<UserStory> findByUserAndStoryId(UserData userData, int storyId);
|
Optional<UserStory> findByUserAndStoryId(UserData userData, int storyId);
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
void deleteByUser(UserData user);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import icu.samnyan.aqua.sega.ongeki.model.userdata.UserData;
|
|||||||
import icu.samnyan.aqua.sega.ongeki.model.userdata.UserTrainingRoom;
|
import icu.samnyan.aqua.sega.ongeki.model.userdata.UserTrainingRoom;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -18,4 +19,6 @@ public interface UserTrainingRoomRepository extends JpaRepository<UserTrainingRo
|
|||||||
|
|
||||||
List<UserTrainingRoom> findByUser_Card_ExtId(int userId);
|
List<UserTrainingRoom> findByUser_Card_ExtId(int userId);
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
void deleteByUser(UserData user);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package icu.samnyan.aqua.sega.ongeki.handler.impl;
|
package icu.samnyan.aqua.sega.ongeki.handler.impl;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import icu.samnyan.aqua.sega.ongeki.dao.userdata.UserStoryRepository;
|
||||||
import icu.samnyan.aqua.sega.ongeki.handler.BaseHandler;
|
import icu.samnyan.aqua.sega.ongeki.handler.BaseHandler;
|
||||||
|
import icu.samnyan.aqua.sega.ongeki.model.userdata.UserStory;
|
||||||
import icu.samnyan.aqua.sega.util.jackson.BasicMapper;
|
import icu.samnyan.aqua.sega.util.jackson.BasicMapper;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -22,9 +24,12 @@ public class GetUserStoryHandler implements BaseHandler {
|
|||||||
|
|
||||||
private final BasicMapper mapper;
|
private final BasicMapper mapper;
|
||||||
|
|
||||||
|
private final UserStoryRepository userStoryRepository;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public GetUserStoryHandler(BasicMapper mapper) {
|
public GetUserStoryHandler(BasicMapper mapper, UserStoryRepository userStoryRepository) {
|
||||||
this.mapper = mapper;
|
this.mapper = mapper;
|
||||||
|
this.userStoryRepository = userStoryRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -32,10 +37,12 @@ public class GetUserStoryHandler implements BaseHandler {
|
|||||||
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
||||||
Integer userId = (Integer) request.get("userId");
|
Integer userId = (Integer) request.get("userId");
|
||||||
|
|
||||||
|
List<UserStory> userStoryList = userStoryRepository.findByUser_Card_ExtId(userId);
|
||||||
|
|
||||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||||
resultMap.put("userId", userId);
|
resultMap.put("userId", userId);
|
||||||
resultMap.put("length", 0);
|
resultMap.put("length", userStoryList.size());
|
||||||
resultMap.put("userStoryList", new List[]{});
|
resultMap.put("userStoryList", userStoryList);
|
||||||
|
|
||||||
String json = mapper.write(resultMap);
|
String json = mapper.write(resultMap);
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,14 @@ public class UserStory implements Serializable {
|
|||||||
|
|
||||||
private int lastChapterId;
|
private int lastChapterId;
|
||||||
|
|
||||||
|
private int jewelCount;
|
||||||
|
|
||||||
|
private int lastPlayMusicId;
|
||||||
|
|
||||||
|
private int lastPlayMusicCategory;
|
||||||
|
|
||||||
|
private int lastPlayMusicLevel;
|
||||||
|
|
||||||
public UserStory(UserData userData) {
|
public UserStory(UserData userData) {
|
||||||
this.user = userData;
|
this.user = userData;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
ALTER TABLE `ongeki_user_story`
|
||||||
|
ADD COLUMN `jewel_count` int(11) DEFAULT 0,
|
||||||
|
ADD COLUMN `last_play_music_id` int(11) DEFAULT 0,
|
||||||
|
ADD COLUMN `last_play_music_category` int(11) DEFAULT 0,
|
||||||
|
ADD COLUMN `last_play_music_level` int(11) DEFAULT 0;
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
PRAGMA foreign_keys = 0;
|
||||||
|
|
||||||
|
CREATE TABLE ongeki_user_story_new (
|
||||||
|
id INTEGER,
|
||||||
|
last_chapter_id INTEGER NOT NULL,
|
||||||
|
story_id INTEGER NOT NULL,
|
||||||
|
jewel_count INTEGER,
|
||||||
|
last_play_music_id INTEGER,
|
||||||
|
last_play_music_category INTEGER,
|
||||||
|
last_play_music_level INTEGER,
|
||||||
|
user_id BIGINT REFERENCES ongeki_user_data (id) ON DELETE CASCADE,
|
||||||
|
PRIMARY KEY (
|
||||||
|
id
|
||||||
|
),
|
||||||
|
CONSTRAINT ongeki_user_story_uq UNIQUE (
|
||||||
|
story_id,
|
||||||
|
user_id
|
||||||
|
) ON CONFLICT REPLACE
|
||||||
|
);
|
||||||
|
|
||||||
|
INSERT INTO ongeki_user_story_new (
|
||||||
|
id,
|
||||||
|
last_chapter_id,
|
||||||
|
story_id,
|
||||||
|
user_id,
|
||||||
|
jewel_count,
|
||||||
|
last_play_music_id,
|
||||||
|
last_play_music_category,
|
||||||
|
last_play_music_level
|
||||||
|
)
|
||||||
|
SELECT id,
|
||||||
|
last_chapter_id,
|
||||||
|
story_id,
|
||||||
|
user_id,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
FROM ongeki_user_story;
|
||||||
|
|
||||||
|
ALTER TABLE ongeki_user_story RENAME TO bak_ongeki_user_story;
|
||||||
|
ALTER TABLE ongeki_user_story_new RENAME TO ongeki_user_story;
|
||||||
|
|
||||||
|
PRAGMA foreign_keys = 1;
|
||||||
Reference in New Issue
Block a user