2026-08-01 21:44:52 +03:00

31 lines
1.1 KiB
Kotlin

package com.dowstats.controllers
import com.dowstats.data.rgd.RgdData
import com.dowstats.service.w40k.RgdParserService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.http.MediaType
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController
import org.springframework.web.multipart.MultipartFile
import java.io.DataInputStream
@RestController
@RequestMapping("api/v1/rgd")
class RgdController @Autowired constructor(
val rgdParserService: RgdParserService,
) {
@PostMapping(
value = ["/parse"],
consumes = [MediaType.APPLICATION_OCTET_STREAM_VALUE],
produces = [MediaType.APPLICATION_JSON_VALUE]
)
fun parseRgdBytes(@RequestBody body: ByteArray): List<RgdData> {
return rgdParserService.parseRgdFileStream(DataInputStream(body.inputStream()))
}
}