diff --git a/src/main/java/icu/samnyan/aqua/api/controller/sega/game/maimai2/ApiMaimai2PlayerDataController.java b/src/main/java/icu/samnyan/aqua/api/controller/sega/game/maimai2/ApiMaimai2PlayerDataController.java index dab6abab..1526ee11 100644 --- a/src/main/java/icu/samnyan/aqua/api/controller/sega/game/maimai2/ApiMaimai2PlayerDataController.java +++ b/src/main/java/icu/samnyan/aqua/api/controller/sega/game/maimai2/ApiMaimai2PlayerDataController.java @@ -1,6 +1,8 @@ package icu.samnyan.aqua.api.controller.sega.game.maimai2; import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; + import icu.samnyan.aqua.api.model.MessageResponse; import icu.samnyan.aqua.api.model.ReducedPageResponse; import icu.samnyan.aqua.api.model.resp.sega.maimai2.ProfileResp; @@ -21,9 +23,12 @@ import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; +import java.io.IOException; +import java.nio.file.*; import java.time.format.DateTimeFormatter; import java.util.*; import java.util.stream.Collectors; +import java.util.stream.Stream; /** * @author samnyan (privateamusement@protonmail.com) @@ -89,6 +94,28 @@ public class ApiMaimai2PlayerDataController { return divMaxLength; } + @GetMapping("userPhoto") + public List getUserPhoto(@RequestParam long aimeId) { + List matchedFiles = new ArrayList<>(); + try (Stream paths = Files.walk(Paths.get("data"))) { + matchedFiles = paths + .filter(Files::isRegularFile) + .filter(path -> path.getFileName().toString().endsWith(".jpg")) + .filter(path -> { + String fileName = path.getFileName().toString(); + String[] parts = fileName.split("-"); + return parts.length > 0 && parts[0].equals(String.valueOf(aimeId)); + }) + .map(Path::getFileName) + .map(Path::toString) + .sorted() + .collect(Collectors.toList()); + matchedFiles.forEach(System.out::println); + } catch (IOException e) { + } + return matchedFiles; + } + @GetMapping("profile") public ProfileResp getProfile(@RequestParam long aimeId) { return mapper.convert(userDataRepository.findByCard_ExtId(aimeId).orElseThrow(), new TypeReference<>() {