From 913244c2b5bd04a7af86aae68d83212492db6aa3 Mon Sep 17 00:00:00 2001
From: samnyan <205-neumphis@users.noreply.dev.s-ul.eu>
Date: Sat, 21 Mar 2020 23:07:54 +0900
Subject: [PATCH] [api] Add more ongeki feature
---
README.md | 5 +
pom.xml | 2 +-
.../ongeki/ApiOngekiPlayerDataController.java | 145 +++++++++++++++++-
.../dao/userdata/UserActivityRepository.java | 2 +
.../dao/userdata/UserCardRepository.java | 2 +
.../sega/ongeki/model/userdata/UserCard.java | 3 +-
6 files changed, 150 insertions(+), 9 deletions(-)
diff --git a/README.md b/README.md
index b72f36fe..ae3ae702 100644
--- a/README.md
+++ b/README.md
@@ -54,6 +54,11 @@ And DIVA screenshot will be save in data folder.
### Changelog:
+
+v0.0.11a:
+
+[api] Add more ongeki feature
+
v0.0.11: **[This will do database update]**
[ongeki] Add support to ongeki plus
diff --git a/pom.xml b/pom.xml
index 5045e7fb..7d266439 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
icu.samnya
aqua
- 0.0.11-RELEASE
+ 0.0.11a-RELEASE
Aqua Server
A multipurpose game server
diff --git a/src/main/java/icu/samnyan/aqua/api/controller/sega/game/ongeki/ApiOngekiPlayerDataController.java b/src/main/java/icu/samnyan/aqua/api/controller/sega/game/ongeki/ApiOngekiPlayerDataController.java
index 2f110194..53e14ba9 100644
--- a/src/main/java/icu/samnyan/aqua/api/controller/sega/game/ongeki/ApiOngekiPlayerDataController.java
+++ b/src/main/java/icu/samnyan/aqua/api/controller/sega/game/ongeki/ApiOngekiPlayerDataController.java
@@ -1,6 +1,7 @@
package icu.samnyan.aqua.api.controller.sega.game.ongeki;
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.ongeki.ProfileResp;
import icu.samnyan.aqua.api.util.ApiMapper;
@@ -11,10 +12,15 @@ import icu.samnyan.aqua.sega.ongeki.model.userdata.*;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
/**
* @author samnyan (privateamusement@protonmail.com)
@@ -25,6 +31,8 @@ public class ApiOngekiPlayerDataController {
private final ApiMapper mapper;
+ private static DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.0");
+
private final UserActivityRepository userActivityRepository;
private final UserCardRepository userCardRepository;
private final UserCharacterRepository userCharacterRepository;
@@ -91,22 +99,86 @@ public class ApiOngekiPlayerDataController {
public ReducedPageResponse getCard(@RequestParam Integer aimeId,
@RequestParam(required = false, defaultValue = "0") int page,
@RequestParam(required = false, defaultValue = "10") int size) {
- Page cards = userCardRepository.findByUser_Card_ExtId(aimeId, PageRequest.of(page,size));
+ Page 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());
}
- @PostMapping("insert")
- public UserCard insertCard(@RequestBody Map request) {
+ /**
+ * 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
+ */
+ @PostMapping("card")
+ public ResponseEntity