[api] Add chunithm profile export and import

[general] Rename some method name and add more docs
This commit is contained in:
samnyan
2020-03-28 17:38:23 +09:00
parent 067c806674
commit 9a4ca3a612
32 changed files with 484 additions and 119 deletions

View File

@@ -37,4 +37,8 @@ public class UserActivityService {
public List<UserActivity> getAllByUserIdAndKind(String userId, String kind) {
return userActivityRepository.findAllByUser_Card_ExtIdAndKindOrderBySortNumberDesc(Integer.parseInt(userId), Integer.parseInt(kind));
}
public List<UserActivity> getByUserId(String userId) {
return userActivityRepository.findAllByUser_Card_ExtId(Integer.parseInt(userId));
}
}

View File

@@ -25,14 +25,6 @@ public class UserCharacterService {
this.userCharacterRepository = userCharacterRepository;
}
public Optional<UserCharacter> getByUserAndCharacterId(UserData user, String characterId) {
return getByUserAndCharacterId(user, Integer.parseInt(characterId));
}
public Optional<UserCharacter> getByUserAndCharacterId(UserData user, int characterId) {
return userCharacterRepository.findTopByUserAndCharacterIdOrderByIdDesc(user, characterId);
}
public UserCharacter save(UserCharacter userCharacter) {
return userCharacterRepository.save(userCharacter);
}
@@ -41,8 +33,20 @@ public class UserCharacterService {
return userCharacterRepository.saveAll(userCharacter);
}
public Page<UserCharacter> getByUser(String userId, int pageNumber, int maxCount) {
public List<UserCharacter> getByUserId(String userId) {
return userCharacterRepository.findByUser_Card_ExtId(Integer.parseInt(userId));
}
public Page<UserCharacter> getByUserId(String userId, int pageNumber, int maxCount) {
Pageable pageable = PageRequest.of(pageNumber, maxCount);
return userCharacterRepository.findByUser_Card_ExtId(Integer.parseInt(userId), pageable);
}
public Optional<UserCharacter> getByUserAndCharacterId(UserData user, String characterId) {
return getByUserAndCharacterId(user, Integer.parseInt(characterId));
}
public Optional<UserCharacter> getByUserAndCharacterId(UserData user, int characterId) {
return userCharacterRepository.findTopByUserAndCharacterIdOrderByIdDesc(user, characterId);
}
}

View File

@@ -24,6 +24,10 @@ public class UserChargeService {
return userChargeRepository.save(userCharge);
}
public List<UserCharge> saveAll(List<UserCharge> newUserChargeList) {
return userChargeRepository.saveAll(newUserChargeList);
}
public List<UserCharge> getByUserId(String userId) {
return userChargeRepository.findByUser_Card_ExtId(Integer.parseInt(userId));
}
@@ -32,7 +36,4 @@ public class UserChargeService {
return userChargeRepository.findByUserAndChargeId(user, Integer.parseInt(chargeId));
}
public List<UserCharge> saveAll(List<UserCharge> newUserChargeList) {
return userChargeRepository.saveAll(newUserChargeList);
}
}

View File

@@ -25,10 +25,6 @@ public class UserCourseService {
this.userCourseRepository = userCourseRepository;
}
public Optional<UserCourse> getByUserAndCourseId(UserData user, String courseId) {
return userCourseRepository.findTopByUserAndCourseIdOrderByIdDesc(user, Integer.parseInt(courseId));
}
public UserCourse save(UserCourse userCourse) {
return userCourseRepository.save(userCourse);
}
@@ -37,16 +33,16 @@ public class UserCourseService {
return userCourseRepository.saveAll(userMusicDetail);
}
public List<UserCourse> getByUser(String userId) {
public List<UserCourse> getByUserId(String userId) {
return userCourseRepository.findByUser_Card_ExtId(Integer.parseInt(userId));
}
public Page<UserCourse> getByUser(String userId, int pageNum, int maxCount) {
public Page<UserCourse> getByUserId(String userId, int pageNum, int maxCount) {
Pageable page = PageRequest.of(pageNum, maxCount);
return userCourseRepository.findByUser_Card_ExtId(Integer.parseInt(userId), page);
}
public List<UserCourse> getAllByUser(String userId) {
return userCourseRepository.findByUser_Card_ExtId(Integer.parseInt(userId));
public Optional<UserCourse> getByUserAndCourseId(UserData user, String courseId) {
return userCourseRepository.findTopByUserAndCourseIdOrderByIdDesc(user, Integer.parseInt(courseId));
}
}

View File

@@ -21,15 +21,15 @@ public class UserDataExService {
this.userDataExRepository = userDataExRepository;
}
public Optional<UserDataEx> getByUser(UserData user) {
return userDataExRepository.findByUser(user);
}
public UserDataEx save(UserDataEx userDataEx) {
return userDataExRepository.save(userDataEx);
}
public Optional<UserDataEx> getUserByExtId(String userId) {
public Optional<UserDataEx> getByUser(UserData user) {
return userDataExRepository.findByUser(user);
}
public Optional<UserDataEx> getByExtId(String userId) {
return userDataExRepository.findByUser_Card_ExtId(Integer.parseInt(userId));
}
}

View File

@@ -2,6 +2,7 @@ package icu.samnyan.aqua.sega.chunithm.service;
import icu.samnyan.aqua.sega.chunithm.dao.userdata.UserDataRepository;
import icu.samnyan.aqua.sega.chunithm.model.userdata.UserData;
import icu.samnyan.aqua.sega.general.model.Card;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -21,21 +22,6 @@ public class UserDataService {
this.userDataRepository = userDataRepository;
}
public Optional<UserData> getUserByExtId(String aimeId) {
return userDataRepository.findByCard_ExtId(Integer.parseInt(aimeId));
}
public String updateLoginTime(UserData userData) {
userData.setLastLoginDate(LocalDateTime.now());
try {
userDataRepository.save(userData);
return "1";
} catch (Exception e) {
return "0";
}
}
public UserData saveUserData(UserData userData) {
return userDataRepository.save(userData);
}
@@ -43,4 +29,17 @@ public class UserDataService {
public UserData saveAndFlushUserData(UserData userData) {
return userDataRepository.saveAndFlush(userData);
}
public Optional<UserData> getUserByExtId(String aimeId) {
return userDataRepository.findByCard_ExtId(Integer.parseInt(aimeId));
}
public Optional<UserData> getUserByCard(Card card) {
return userDataRepository.findByCard(card);
}
public void updateLoginTime(UserData userData) {
userData.setLastLoginDate(LocalDateTime.now());
userDataRepository.save(userData);
}
}

View File

@@ -34,8 +34,7 @@ public class UserDuelService {
return userDuelRepository.saveAll(userDuel);
}
public List<UserDuel> getByUser(String userId) {
public List<UserDuel> getByUserId(String userId) {
return userDuelRepository.findByUser_Card_ExtId(Integer.parseInt(userId));
}
}

View File

@@ -21,14 +21,14 @@ public class UserGameOptionExService {
this.userGameOptionExRepository = userGameOptionExRepository;
}
public Optional<UserGameOptionEx> getByUser(UserData userData) {
return userGameOptionExRepository.findByUser(userData);
}
public UserGameOptionEx save(UserGameOptionEx userGameOptionEx) {
return userGameOptionExRepository.save(userGameOptionEx);
}
public Optional<UserGameOptionEx> getByUser(UserData userData) {
return userGameOptionExRepository.findByUser(userData);
}
public Optional<UserGameOptionEx> getByUserId(String userId) {
return userGameOptionExRepository.findByUser_Card_ExtId(Integer.parseInt(userId));
}

View File

@@ -21,15 +21,15 @@ public class UserGameOptionService {
this.userGameOptionRepository = userGameOptionRepository;
}
public Optional<UserGameOption> getByUserId(String userId) {
return userGameOptionRepository.findByUser_Card_ExtId(Integer.parseInt(userId));
public UserGameOption save(UserGameOption userGameOption) {
return userGameOptionRepository.save(userGameOption);
}
public Optional<UserGameOption> getByUser(UserData user) {
return userGameOptionRepository.findByUser(user);
}
public UserGameOption save(UserGameOption userGameOption) {
return userGameOptionRepository.save(userGameOption);
public Optional<UserGameOption> getByUserId(String userId) {
return userGameOptionRepository.findByUser_Card_ExtId(Integer.parseInt(userId));
}
}

View File

@@ -24,11 +24,6 @@ public class UserItemService {
this.userItemRepository = userItemRepository;
}
public Optional<UserItem> getByUserAndItemId(UserData user, String itemId, String itemKind) {
return userItemRepository.findTopByUserAndItemIdAndItemKindOrderByIdDesc(user, Integer.parseInt(itemId), Integer.parseInt(itemKind));
}
public UserItem save(UserItem userItem) {
return userItemRepository.save(userItem);
}
@@ -37,6 +32,14 @@ public class UserItemService {
return userItemRepository.saveAll(userItem);
}
public List<UserItem> getByUserId(String userId) {
return userItemRepository.findAllByUser_Card_ExtId(Integer.parseInt(userId));
}
public Optional<UserItem> getByUserAndItemId(UserData user, String itemId, String itemKind) {
return userItemRepository.findTopByUserAndItemIdAndItemKindOrderByIdDesc(user, Integer.parseInt(itemId), Integer.parseInt(itemKind));
}
public Page<UserItem> getByUserAndItemKind(String userId, int kind, int pageNumber, int maxCount) {
Pageable page = PageRequest.of(pageNumber, maxCount);
return userItemRepository.findAllByUser_Card_ExtIdAndItemKind(Integer.parseInt(userId), kind, page);

View File

@@ -22,18 +22,6 @@ public class UserMapService {
this.userMapRepository = userMapRepository;
}
public List<UserMap> getByUser(UserData user) {
return userMapRepository.findAllByUser(user);
}
public List<UserMap> getByUser(String userId) {
return userMapRepository.findAllByUser_Card_ExtId(Integer.parseInt(userId));
}
public Optional<UserMap> getByUserAndMapId(UserData user, String mapId) {
return userMapRepository.findTopByUserAndMapIdOrderByIdDesc(user, Integer.parseInt(mapId));
}
public UserMap save(UserMap userMap) {
return userMapRepository.save(userMap);
}
@@ -41,4 +29,16 @@ public class UserMapService {
public List<UserMap> saveAll(Iterable<UserMap> userMap) {
return userMapRepository.saveAll(userMap);
}
public List<UserMap> getByUser(UserData user) {
return userMapRepository.findAllByUser(user);
}
public List<UserMap> getByUserId(String userId) {
return userMapRepository.findAllByUser_Card_ExtId(Integer.parseInt(userId));
}
public Optional<UserMap> getByUserAndMapId(UserData user, String mapId) {
return userMapRepository.findTopByUserAndMapIdOrderByIdDesc(user, Integer.parseInt(mapId));
}
}

View File

@@ -25,10 +25,6 @@ public class UserMusicDetailService {
this.userMusicDetailRepository = userMusicDetailRepository;
}
public Optional<UserMusicDetail> getByUserAndMusicIdAndLevel(UserData user, String musicId, String level) {
return userMusicDetailRepository.findTopByUserAndMusicIdAndLevelOrderByIdDesc(user, Integer.parseInt(musicId), Integer.parseInt(level));
}
public UserMusicDetail save(UserMusicDetail userMusicDetail) {
return userMusicDetailRepository.save(userMusicDetail);
}
@@ -46,7 +42,15 @@ public class UserMusicDetailService {
return userMusicDetailRepository.findByUser_Card_ExtId(Integer.parseInt(userId), page);
}
public List<UserMusicDetail> getByUserAndMusicId(String userId, int id) {
return userMusicDetailRepository.findByUser_Card_ExtIdAndMusicId(Integer.parseInt(userId), id);
public List<UserMusicDetail> getByUserId(String userId) {
return userMusicDetailRepository.findByUser_Card_ExtId(Integer.parseInt(userId));
}
public List<UserMusicDetail> getByUserIdAndMusicId(String userId, int musicId) {
return userMusicDetailRepository.findByUser_Card_ExtIdAndMusicId(Integer.parseInt(userId), musicId);
}
public Optional<UserMusicDetail> getByUserAndMusicIdAndLevel(UserData user, String musicId, String level) {
return userMusicDetailRepository.findTopByUserAndMusicIdAndLevelOrderByIdDesc(user, Integer.parseInt(musicId), Integer.parseInt(level));
}
}

View File

@@ -2,7 +2,6 @@ package icu.samnyan.aqua.sega.chunithm.service;
import icu.samnyan.aqua.sega.chunithm.dao.userdata.UserPlaylogRepository;
import icu.samnyan.aqua.sega.chunithm.model.userdata.UserPlaylog;
import icu.samnyan.aqua.sega.diva.model.userdata.PlayLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
@@ -33,16 +32,20 @@ public class UserPlaylogService {
return userPlaylogRepository.saveAll(userPlaylogList);
}
public Page<UserPlaylog> getRecentPlays(String userId, Pageable page) {
return userPlaylogRepository.findByUser_Card_ExtId(Integer.parseInt(userId), page);
}
public List<UserPlaylog> getRecent30Plays(String userId) {
Pageable page = PageRequest.of(0, 30, Sort.by(Sort.Direction.DESC, "userPlayDate"));
return userPlaylogRepository.findByUser_Card_ExtIdAndLevelNot(Integer.parseInt(userId), 4, page);
}
public Page<UserPlaylog> getRecentPlays(String userId, Pageable page) {
return userPlaylogRepository.findByUser_Card_ExtId(Integer.parseInt(userId), page);
public List<UserPlaylog> getByUserId(String userId) {
return userPlaylogRepository.findByUser_Card_ExtId(Integer.parseInt(userId));
}
public List<UserPlaylog> getByUserAndMusicIdAndLevel(String userId, int id, int level) {
public List<UserPlaylog> getByUserIdAndMusicIdAndLevel(String userId, int id, int level) {
return userPlaylogRepository.findByUser_Card_ExtIdAndMusicIdAndLevel(Integer.parseInt(userId), id, level);
}
}