mirror of https://github.com/Soyandroid/aqua
[api] Add screenshot function
parent
266d7a20f0
commit
95512aa843
|
@ -0,0 +1,39 @@
|
|||
package icu.samnyan.aqua.api.controller.general;
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.dao.userdata.PlayerScreenShotRepository;
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerScreenShot;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("api/static")
|
||||
public class StaticController {
|
||||
|
||||
private final PlayerScreenShotRepository playerScreenShotRepository;
|
||||
|
||||
public StaticController(PlayerScreenShotRepository playerScreenShotRepository) {
|
||||
this.playerScreenShotRepository = playerScreenShotRepository;
|
||||
}
|
||||
|
||||
@GetMapping(value = "screenshot/{filename}", produces = MediaType.IMAGE_JPEG_VALUE)
|
||||
public ResponseEntity<Resource> getScreenshotFile(@PathVariable String filename) {
|
||||
Optional<PlayerScreenShot> ss = playerScreenShotRepository.findByFileName(filename);
|
||||
if (ss.isPresent()) {
|
||||
return ResponseEntity.ok(new FileSystemResource(Paths.get("data/" + ss.get().getFileName())));
|
||||
} else {
|
||||
return ResponseEntity.notFound().build();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -32,8 +32,9 @@ public class ApiDivaPlayerDataController {
|
|||
private final PlayerPvCustomizeRepository playerPvCustomizeRepository;
|
||||
private final PlayerModuleRepository playerModuleRepository;
|
||||
private final PlayerCustomizeRepository playerCustomizeRepository;
|
||||
private final PlayerScreenShotRepository playerScreenShotRepository;
|
||||
|
||||
public ApiDivaPlayerDataController(PlayerProfileService playerProfileService, GameSessionRepository gameSessionRepository, PlayLogRepository playLogRepository, PlayerPvRecordRepository playerPvRecordRepository, PlayerPvCustomizeRepository playerPvCustomizeRepository, PlayerModuleRepository playerModuleRepository, PlayerCustomizeRepository playerCustomizeRepository) {
|
||||
public ApiDivaPlayerDataController(PlayerProfileService playerProfileService, GameSessionRepository gameSessionRepository, PlayLogRepository playLogRepository, PlayerPvRecordRepository playerPvRecordRepository, PlayerPvCustomizeRepository playerPvCustomizeRepository, PlayerModuleRepository playerModuleRepository, PlayerCustomizeRepository playerCustomizeRepository, PlayerScreenShotRepository playerScreenShotRepository) {
|
||||
this.playerProfileService = playerProfileService;
|
||||
this.gameSessionRepository = gameSessionRepository;
|
||||
this.playLogRepository = playLogRepository;
|
||||
|
@ -41,6 +42,7 @@ public class ApiDivaPlayerDataController {
|
|||
this.playerPvCustomizeRepository = playerPvCustomizeRepository;
|
||||
this.playerModuleRepository = playerModuleRepository;
|
||||
this.playerCustomizeRepository = playerCustomizeRepository;
|
||||
this.playerScreenShotRepository = playerScreenShotRepository;
|
||||
}
|
||||
|
||||
@PostMapping("forceUnlock")
|
||||
|
@ -274,5 +276,9 @@ public class ApiDivaPlayerDataController {
|
|||
return new ReducedPageResponse<>(customizes.getContent(), customizes.getPageable().getPageNumber(), customizes.getTotalPages(), customizes.getTotalElements());
|
||||
}
|
||||
|
||||
@GetMapping("screenshot")
|
||||
public List<PlayerScreenShot> getScreenshotList(@RequestParam int pdId) {
|
||||
return playerScreenShotRepository.findByPdId_PdId(pdId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,8 +3,14 @@ package icu.samnyan.aqua.sega.diva.dao.userdata;
|
|||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerScreenShot;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
public interface PlayerScreenShotRepository extends JpaRepository<PlayerScreenShot, Long> {
|
||||
List<PlayerScreenShot> findByPdId_PdId(int pdId);
|
||||
Optional<PlayerScreenShot> findByFileName(String fileName);
|
||||
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ public class PlayerPvCustomize implements Serializable {
|
|||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "pd_id")
|
||||
@JsonIgnore
|
||||
private PlayerProfile pdId;
|
||||
|
||||
@Column(name = "pv_id")
|
||||
|
|
Loading…
Reference in New Issue