mirror of https://github.com/hykilpikonna/AquaDX
[api] More endpoint for chunithm
parent
66f6613cb7
commit
c27a45a4d4
|
@ -2,16 +2,19 @@ package icu.samnyan.aqua.api.controller.sega.game.chuni.amazon;
|
|||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import icu.samnyan.aqua.api.model.MessageResponse;
|
||||
import icu.samnyan.aqua.api.model.ReducedPageResponse;
|
||||
import icu.samnyan.aqua.api.model.resp.sega.chuni.amazon.ProfileResp;
|
||||
import icu.samnyan.aqua.api.model.resp.sega.chuni.amazon.RatingItem;
|
||||
import icu.samnyan.aqua.api.model.resp.sega.chuni.amazon.RecentResp;
|
||||
import icu.samnyan.aqua.api.model.resp.sega.chuni.amazon.ScoreResp;
|
||||
import icu.samnyan.aqua.api.util.ApiMapper;
|
||||
import icu.samnyan.aqua.sega.chunithm.model.gamedata.Level;
|
||||
import icu.samnyan.aqua.sega.chunithm.model.gamedata.Music;
|
||||
import icu.samnyan.aqua.sega.chunithm.model.userdata.*;
|
||||
import icu.samnyan.aqua.sega.chunithm.service.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
@ -49,6 +52,12 @@ public class ApiAmazonController {
|
|||
this.gameMusicService = gameMusicService;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("music")
|
||||
public List<Music> getMusicList() {
|
||||
return gameMusicService.getAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Basic info
|
||||
*
|
||||
|
@ -95,9 +104,12 @@ public class ApiAmazonController {
|
|||
}
|
||||
|
||||
@GetMapping("recent")
|
||||
public List<RecentResp> getRecentPlay(@RequestParam String aimeId) {
|
||||
return mapper.convert(userPlaylogService.getRecentPlays(aimeId), new TypeReference<>() {
|
||||
});
|
||||
public ReducedPageResponse<RecentResp> getRecentPlay(@RequestParam String aimeId,
|
||||
@RequestParam(required = false, defaultValue = "0") int page,
|
||||
@RequestParam(required = false, defaultValue = "10") int size) {
|
||||
Page<UserPlaylog> playLogs = userPlaylogService.getRecentPlays(aimeId, PageRequest.of(page, size, Sort.by(Sort.Direction.DESC, "userPlayDate")));
|
||||
return new ReducedPageResponse<>(mapper.convert(playLogs.getContent(), new TypeReference<>() {
|
||||
}), playLogs.getPageable().getPageNumber(), playLogs.getTotalPages(), playLogs.getTotalElements());
|
||||
}
|
||||
|
||||
@GetMapping("rating")
|
||||
|
@ -154,18 +166,16 @@ public class ApiAmazonController {
|
|||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@GetMapping("score/list")
|
||||
public List<ScoreResp> getScoreList(@RequestParam String aimeId) {
|
||||
return mapper.convert(userMusicDetailService.getByUser(aimeId), new TypeReference<>() {
|
||||
});
|
||||
@GetMapping("song/{id}")
|
||||
public List<UserMusicDetail> getSongDetail(@RequestParam String aimeId, @PathVariable int id) {
|
||||
return userMusicDetailService.getByUserAndMusicId(aimeId, id);
|
||||
}
|
||||
|
||||
@GetMapping("music")
|
||||
public List<Music> getMusicList() {
|
||||
return gameMusicService.getAll();
|
||||
@GetMapping("song/{id}/{level}")
|
||||
public List<UserPlaylog> getLevelPlaylog(@RequestParam String aimeId, @PathVariable int id, @PathVariable int level) {
|
||||
return userPlaylogService.getByUserAndMusicIdAndLevel(aimeId, id, level);
|
||||
}
|
||||
|
||||
|
||||
private int calculateRating(int levelBase, int score) {
|
||||
if (score >= 1007500) return levelBase + 200;
|
||||
if (score >= 1005000) return levelBase + 150 + (score - 1005000) * 10 / 500;
|
||||
|
|
|
@ -20,5 +20,7 @@ public interface UserMusicDetailRepository extends JpaRepository<UserMusicDetail
|
|||
|
||||
List<UserMusicDetail> findByUser_Card_ExtId(int extId);
|
||||
|
||||
List<UserMusicDetail> findByUser_Card_ExtIdAndMusicId(int extId, int musicId);
|
||||
|
||||
Page<UserMusicDetail> findByUser_Card_ExtId(int extId, Pageable page);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package icu.samnyan.aqua.sega.chunithm.dao.userdata;
|
||||
|
||||
import icu.samnyan.aqua.sega.chunithm.model.userdata.UserPlaylog;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayLog;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
@ -14,5 +16,7 @@ import java.util.List;
|
|||
public interface UserPlaylogRepository extends JpaRepository<UserPlaylog, Long> {
|
||||
List<UserPlaylog> findByUser_Card_ExtIdAndLevelNot(int extId, int levelNot, Pageable page);
|
||||
|
||||
List<UserPlaylog> findByUser_Card_ExtId(int extId, Pageable page);
|
||||
Page<UserPlaylog> findByUser_Card_ExtId(int extId, Pageable page);
|
||||
|
||||
List<UserPlaylog> findByUser_Card_ExtIdAndMusicIdAndLevel(int extId, int musicId, int level);
|
||||
}
|
||||
|
|
|
@ -45,4 +45,8 @@ public class UserMusicDetailService {
|
|||
Pageable page = PageRequest.of(pageNum, maxCount);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ 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;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
|
@ -36,8 +38,11 @@ public class UserPlaylogService {
|
|||
return userPlaylogRepository.findByUser_Card_ExtIdAndLevelNot(Integer.parseInt(userId), 4, page);
|
||||
}
|
||||
|
||||
public List<UserPlaylog> getRecentPlays(String userId) {
|
||||
Pageable page = PageRequest.of(0, 50, Sort.by(Sort.Direction.DESC, "userPlayDate"));
|
||||
public Page<UserPlaylog> getRecentPlays(String userId, Pageable page) {
|
||||
return userPlaylogRepository.findByUser_Card_ExtId(Integer.parseInt(userId), page);
|
||||
}
|
||||
|
||||
public List<UserPlaylog> getByUserAndMusicIdAndLevel(String userId, int id, int level) {
|
||||
return userPlaylogRepository.findByUser_Card_ExtIdAndMusicIdAndLevel(Integer.parseInt(userId), id, level);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,6 +57,11 @@ public class GameBalanceParameter implements Internalizable {
|
|||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4, // unkn
|
||||
|
|
Loading…
Reference in New Issue