mirror of https://github.com/Soyandroid/aqua
commit
7d0d756447
|
@ -124,12 +124,13 @@ public class ApiOngekiPlayerDataController {
|
|||
public ReducedPageResponse<UserCard> getCard(@RequestParam Integer aimeId,
|
||||
@RequestParam(required = false, defaultValue = "0") int page,
|
||||
@RequestParam(required = false, defaultValue = "10") int size) {
|
||||
Page<UserCard> cards = userCardRepository.findByUser_Card_ExtId(aimeId, PageRequest.of(page,size, Sort.Direction.DESC, "id"));
|
||||
Page<UserCard> cards = userCardRepository.findByUser_Card_ExtId(aimeId, PageRequest.of(page, size, Sort.Direction.DESC, "id"));
|
||||
return new ReducedPageResponse<>(cards.getContent(), cards.getPageable().getPageNumber(), cards.getTotalPages(), cards.getTotalElements());
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @return result UserCard or error message
|
||||
*/
|
||||
|
@ -138,17 +139,17 @@ public class ApiOngekiPlayerDataController {
|
|||
UserData profile = userDataRepository.findByCard_ExtId((Integer) request.get("aimeId")).orElseThrow();
|
||||
Integer cardId = (Integer) request.get("cardId");
|
||||
Optional<UserCard> userCardOptional = userCardRepository.findByUserAndCardId(profile, cardId);
|
||||
if(userCardOptional.isPresent()) {
|
||||
if (userCardOptional.isPresent()) {
|
||||
UserCard card = userCardOptional.get();
|
||||
if(card.getDigitalStock() < 5) {
|
||||
if (card.getDigitalStock() < 5) {
|
||||
card.setDigitalStock(card.getDigitalStock() + 1);
|
||||
card.setMaxLevel(card.getMaxLevel() + 5);
|
||||
return ResponseEntity.ok(userCardRepository.save(card));
|
||||
} else {
|
||||
// If digital stock is larger than 5, check if this card is N card.
|
||||
Optional<GameCard> gameCard = gameCardRepository.findById((long) card.getCardId());
|
||||
if(gameCard.isPresent()) {
|
||||
if(gameCard.get().getRarity().equals("N")) {
|
||||
if (gameCard.isPresent()) {
|
||||
if (gameCard.get().getRarity().equals("N")) {
|
||||
card.setDigitalStock(card.getDigitalStock() + 1);
|
||||
card.setMaxLevel(card.getMaxLevel() + 5);
|
||||
return ResponseEntity.ok(userCardRepository.save(card));
|
||||
|
@ -165,21 +166,21 @@ public class ApiOngekiPlayerDataController {
|
|||
return ResponseEntity.ok(
|
||||
userCardRepository.save(
|
||||
new UserCard(
|
||||
profile,
|
||||
cardId,
|
||||
card.getSkillId(),
|
||||
LocalDateTime.now().format(df))
|
||||
profile,
|
||||
cardId,
|
||||
card.getSkillId(),
|
||||
LocalDateTime.now().format(df))
|
||||
));
|
||||
}
|
||||
|
||||
@PostMapping("card/{cardId}/kaika")
|
||||
public ResponseEntity<Object> kaikaCard(@RequestParam Integer aimeId, @PathVariable Integer cardId) {
|
||||
Optional<UserCard> userCardOptional = userCardRepository.findByUser_Card_ExtIdAndCardId(aimeId, cardId);
|
||||
if(userCardOptional.isEmpty()) {
|
||||
if (userCardOptional.isEmpty()) {
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new MessageResponse("Card not found."));
|
||||
} else {
|
||||
UserCard card = userCardOptional.get();
|
||||
if(!card.getKaikaDate().equals("0000-00-00 00:00:00.0")) {
|
||||
if (!card.getKaikaDate().equals("0000-00-00 00:00:00.0")) {
|
||||
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY).body(new MessageResponse("No, you have done this before."));
|
||||
} else {
|
||||
card.setKaikaDate(LocalDateTime.now().format(df));
|
||||
|
@ -193,22 +194,28 @@ public class ApiOngekiPlayerDataController {
|
|||
@PostMapping("card/{cardId}/choKaika")
|
||||
public ResponseEntity<Object> choKaikaCard(@RequestParam Integer aimeId, @PathVariable Integer cardId) {
|
||||
Optional<UserCard> userCardOptional = userCardRepository.findByUser_Card_ExtIdAndCardId(aimeId, cardId);
|
||||
if(userCardOptional.isEmpty()) {
|
||||
if (userCardOptional.isEmpty()) {
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new MessageResponse("Card not found."));
|
||||
} else {
|
||||
UserCard card = userCardOptional.get();
|
||||
Optional<GameCard> gameCard = gameCardRepository.findById((long) card.getCardId());
|
||||
if(gameCard.isPresent()) {
|
||||
if(gameCard.get().getRarity().equals("N")) {
|
||||
if (gameCard.isPresent()) {
|
||||
if (gameCard.get().getRarity().equals("N")) {
|
||||
card.setMaxLevel(100);
|
||||
card.setLevel(100);
|
||||
card.setDigitalStock(11);
|
||||
} else {
|
||||
card.setMaxLevel(70);
|
||||
card.setLevel(70);
|
||||
card.setDigitalStock(5);
|
||||
}
|
||||
} else {
|
||||
card.setMaxLevel(100);
|
||||
card.setLevel(100);
|
||||
card.setMaxLevel(70);
|
||||
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.setPrintCount(card.getPrintCount() + 1);
|
||||
|
@ -220,7 +227,7 @@ public class ApiOngekiPlayerDataController {
|
|||
public ReducedPageResponse<UserCharacter> getCharacter(@RequestParam Integer aimeId,
|
||||
@RequestParam(required = false, defaultValue = "0") int page,
|
||||
@RequestParam(required = false, defaultValue = "10") int size) {
|
||||
Page<UserCharacter> characters = userCharacterRepository.findByUser_Card_ExtId(aimeId, PageRequest.of(page,size));
|
||||
Page<UserCharacter> characters = userCharacterRepository.findByUser_Card_ExtId(aimeId, PageRequest.of(page, size));
|
||||
return new ReducedPageResponse<>(characters.getContent(), characters.getPageable().getPageNumber(), characters.getTotalPages(), characters.getTotalElements());
|
||||
}
|
||||
|
||||
|
@ -243,7 +250,7 @@ public class ApiOngekiPlayerDataController {
|
|||
Optional<UserActivity> userActivityOptional = userActivityRepository.findByUserAndKindAndActivityId(profile, kind, activityId);
|
||||
|
||||
UserActivity userActivity;
|
||||
if(userActivityOptional.isPresent()) {
|
||||
if (userActivityOptional.isPresent()) {
|
||||
userActivity = userActivityOptional.get();
|
||||
} else {
|
||||
userActivity = new UserActivity(profile);
|
||||
|
@ -262,7 +269,7 @@ public class ApiOngekiPlayerDataController {
|
|||
public ReducedPageResponse<UserItem> getItem(@RequestParam Integer aimeId,
|
||||
@RequestParam(required = false, defaultValue = "0") int page,
|
||||
@RequestParam(required = false, defaultValue = "10") int size) {
|
||||
Page<UserItem> items = userItemRepository.findByUser_Card_ExtId(aimeId, PageRequest.of(page,size));
|
||||
Page<UserItem> items = userItemRepository.findByUser_Card_ExtId(aimeId, PageRequest.of(page, size));
|
||||
return new ReducedPageResponse<>(items.getContent(), items.getPageable().getPageNumber(), items.getTotalPages(), items.getTotalElements());
|
||||
}
|
||||
|
||||
|
@ -272,14 +279,14 @@ public class ApiOngekiPlayerDataController {
|
|||
Integer itemKind = (Integer) request.get("itemKind");
|
||||
Integer itemId = (Integer) request.get("itemId");
|
||||
int stock = 1;
|
||||
if(request.containsKey("stock")) {
|
||||
if (request.containsKey("stock")) {
|
||||
stock = (Integer) request.get("stock");
|
||||
}
|
||||
|
||||
Optional<UserItem> userItemOptional = userItemRepository.findByUserAndItemKindAndItemId(profile, itemKind, itemId);
|
||||
|
||||
UserItem userItem;
|
||||
if(userItemOptional.isPresent()) {
|
||||
if (userItemOptional.isPresent()) {
|
||||
userItem = userItemOptional.get();
|
||||
} else {
|
||||
userItem = new UserItem(profile);
|
||||
|
@ -295,7 +302,7 @@ public class ApiOngekiPlayerDataController {
|
|||
public ReducedPageResponse<UserPlaylog> getRecent(@RequestParam Integer aimeId,
|
||||
@RequestParam(required = false, defaultValue = "0") int page,
|
||||
@RequestParam(required = false, defaultValue = "10") int size) {
|
||||
Page<UserPlaylog> playlogs = userPlaylogRepository.findByUser_Card_ExtId(aimeId,PageRequest.of(page,size, Sort.Direction.DESC, "id"));
|
||||
Page<UserPlaylog> playlogs = userPlaylogRepository.findByUser_Card_ExtId(aimeId, PageRequest.of(page, size, Sort.Direction.DESC, "id"));
|
||||
return new ReducedPageResponse<>(playlogs.getContent(), playlogs.getPageable().getPageNumber(), playlogs.getTotalPages(), playlogs.getTotalElements());
|
||||
|
||||
}
|
||||
|
@ -317,7 +324,7 @@ public class ApiOngekiPlayerDataController {
|
|||
|
||||
@GetMapping("general")
|
||||
public ResponseEntity<Object> getGeneralData(@RequestParam Integer aimeId, @RequestParam String key) {
|
||||
Optional<UserGeneralData> userGeneralDataOptional = userGeneralDataRepository.findByUser_Card_ExtIdAndPropertyKey(aimeId,key);
|
||||
Optional<UserGeneralData> userGeneralDataOptional = userGeneralDataRepository.findByUser_Card_ExtIdAndPropertyKey(aimeId, key);
|
||||
return userGeneralDataOptional.<ResponseEntity<Object>>map(ResponseEntity::ok)
|
||||
.orElseGet(() -> ResponseEntity.status(HttpStatus.NOT_FOUND).body(new MessageResponse("User or value not found.")));
|
||||
}
|
||||
|
@ -344,7 +351,7 @@ public class ApiOngekiPlayerDataController {
|
|||
data.setUserPlaylogList(userPlaylogRepository.findByUser_Card_ExtId(aimeId));
|
||||
data.setUserStoryList(userStoryRepository.findByUser_Card_ExtId(aimeId));
|
||||
data.setUserTrainingRoomList(userTrainingRoomRepository.findByUser_Card_ExtId(aimeId));
|
||||
} catch (NoSuchElementException e){
|
||||
} catch (NoSuchElementException e) {
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND)
|
||||
.body(new MessageResponse("User not found"));
|
||||
} catch (Exception e) {
|
||||
|
@ -359,7 +366,7 @@ public class ApiOngekiPlayerDataController {
|
|||
|
||||
@PostMapping("import")
|
||||
public ResponseEntity<Object> importAllUserData(@RequestBody OngekiDataImport data) {
|
||||
if(!data.getGameId().equals("SDDT")) {
|
||||
if (!data.getGameId().equals("SDDT")) {
|
||||
return ResponseEntity.unprocessableEntity().body(new MessageResponse("Wrong Game Profile, Expected 'SDDT', Get " + data.getGameId()));
|
||||
}
|
||||
|
||||
|
@ -368,11 +375,47 @@ public class ApiOngekiPlayerDataController {
|
|||
Optional<Card> cardOptional = cardService.getCardByAccessCode(exUser.getAccessCode());
|
||||
Card card;
|
||||
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 {
|
||||
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 org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
@ -20,4 +21,6 @@ public interface UserActivityRepository extends JpaRepository<UserActivity, Long
|
|||
|
||||
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.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
@ -24,4 +25,6 @@ public interface UserCardRepository extends JpaRepository<UserCard, Long> {
|
|||
|
||||
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 org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
@ -18,4 +19,6 @@ public interface UserChapterRepository extends JpaRepository<UserChapter, Long>
|
|||
|
||||
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.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
@ -22,4 +23,6 @@ public interface UserCharacterRepository extends JpaRepository<UserCharacter, Lo
|
|||
|
||||
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 org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
|
@ -17,4 +18,6 @@ public interface UserDataRepository extends JpaRepository<UserData, Long> {
|
|||
|
||||
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 org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
@ -17,5 +18,7 @@ public interface UserDeckRepository extends JpaRepository<UserDeck, Long> {
|
|||
List<UserDeck> findByUser_Card_ExtId(int userId);
|
||||
|
||||
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 org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
@ -18,4 +19,6 @@ public interface UserEventPointRepository extends JpaRepository<UserEventPoint,
|
|||
|
||||
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 org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
@ -20,4 +21,6 @@ public interface UserGeneralDataRepository extends JpaRepository<UserGeneralData
|
|||
|
||||
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.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
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);
|
||||
|
||||
@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.UserLoginBonus;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
@ -16,4 +17,6 @@ public interface UserLoginBonusRepository extends JpaRepository<UserLoginBonus,
|
|||
|
||||
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 org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
@ -18,4 +19,6 @@ public interface UserMissionPointRepository extends JpaRepository<UserMissionPoi
|
|||
|
||||
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.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
@ -24,4 +25,6 @@ public interface UserMusicDetailRepository extends JpaRepository<UserMusicDetail
|
|||
|
||||
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.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
@ -22,4 +23,6 @@ public interface UserMusicItemRepository extends JpaRepository<UserMusicItem, Lo
|
|||
|
||||
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 org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
|
@ -17,4 +18,6 @@ public interface UserOptionRepository extends JpaRepository<UserOption, Long> {
|
|||
|
||||
Optional<UserOption> findByUser_Card_ExtId(int userId);
|
||||
|
||||
@Transactional
|
||||
void deleteByUser(UserData user);
|
||||
}
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
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;
|
||||
|
||||
|
@ -20,4 +22,6 @@ public interface UserPlaylogRepository extends JpaRepository<UserPlaylog, Long>
|
|||
|
||||
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 org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
@ -18,4 +19,6 @@ public interface UserStoryRepository extends JpaRepository<UserStory, Long> {
|
|||
|
||||
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 org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
@ -18,4 +19,6 @@ public interface UserTrainingRoomRepository extends JpaRepository<UserTrainingRo
|
|||
|
||||
List<UserTrainingRoom> findByUser_Card_ExtId(int userId);
|
||||
|
||||
@Transactional
|
||||
void deleteByUser(UserData user);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package icu.samnyan.aqua.sega.ongeki.handler.impl;
|
||||
|
||||
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.model.userdata.UserStory;
|
||||
import icu.samnyan.aqua.sega.util.jackson.BasicMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -22,9 +24,12 @@ public class GetUserStoryHandler implements BaseHandler {
|
|||
|
||||
private final BasicMapper mapper;
|
||||
|
||||
private final UserStoryRepository userStoryRepository;
|
||||
|
||||
@Autowired
|
||||
public GetUserStoryHandler(BasicMapper mapper) {
|
||||
public GetUserStoryHandler(BasicMapper mapper, UserStoryRepository userStoryRepository) {
|
||||
this.mapper = mapper;
|
||||
this.userStoryRepository = userStoryRepository;
|
||||
}
|
||||
|
||||
|
||||
|
@ -32,10 +37,12 @@ public class GetUserStoryHandler implements BaseHandler {
|
|||
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
||||
Integer userId = (Integer) request.get("userId");
|
||||
|
||||
List<UserStory> userStoryList = userStoryRepository.findByUser_Card_ExtId(userId);
|
||||
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||
resultMap.put("userId", userId);
|
||||
resultMap.put("length", 0);
|
||||
resultMap.put("userStoryList", new List[]{});
|
||||
resultMap.put("length", userStoryList.size());
|
||||
resultMap.put("userStoryList", userStoryList);
|
||||
|
||||
String json = mapper.write(resultMap);
|
||||
|
||||
|
|
|
@ -34,6 +34,14 @@ public class UserStory implements Serializable {
|
|||
|
||||
private int lastChapterId;
|
||||
|
||||
private int jewelCount;
|
||||
|
||||
private int lastPlayMusicId;
|
||||
|
||||
private int lastPlayMusicCategory;
|
||||
|
||||
private int lastPlayMusicLevel;
|
||||
|
||||
public UserStory(UserData 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;
|
Loading…
Reference in New Issue