Remove scheduler, add hwt sergeant :)
This commit is contained in:
@@ -4,10 +4,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication
|
||||
import org.springframework.boot.context.properties.ConfigurationPropertiesScan
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties
|
||||
import org.springframework.boot.runApplication
|
||||
import org.springframework.scheduling.annotation.EnableScheduling
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableScheduling
|
||||
@ConfigurationPropertiesScan("com.dowstats.configuration")
|
||||
@EnableConfigurationProperties
|
||||
class WikiApplication
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
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()))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.dowstats.controllers.instruments
|
||||
|
||||
import com.dowstats.data.dto.controllers.instruments.RgdNodeDto
|
||||
import com.dowstats.data.dto.controllers.instruments.toRgdNodeDto
|
||||
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.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/instruments/rgd")
|
||||
class RgdTreeController @Autowired constructor(
|
||||
val rgdParserService: RgdParserService,
|
||||
) {
|
||||
|
||||
@PostMapping(
|
||||
value = ["/tree"],
|
||||
consumes = [MediaType.MULTIPART_FORM_DATA_VALUE],
|
||||
produces = [MediaType.APPLICATION_JSON_VALUE],
|
||||
)
|
||||
fun parseRgdToTree(@RequestParam("file") file: MultipartFile): List<RgdNodeDto> {
|
||||
return file.inputStream.use { input ->
|
||||
rgdParserService.parseRgdFileStream(DataInputStream(input))
|
||||
}.map { it.toRgdNodeDto() }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.dowstats.data.dto.controllers.instruments
|
||||
|
||||
import com.dowstats.data.rgd.RgdData
|
||||
|
||||
data class RgdNodeDto(
|
||||
val name: String,
|
||||
val type: Int,
|
||||
val value: Any?,
|
||||
val children: List<RgdNodeDto>?,
|
||||
)
|
||||
|
||||
fun RgdData.toRgdNodeDto(): RgdNodeDto {
|
||||
val children = (value as? List<*>)?.filterIsInstance<RgdData>()?.map { it.toRgdNodeDto() }
|
||||
return RgdNodeDto(
|
||||
name = name,
|
||||
type = type,
|
||||
value = if (children == null) value else null,
|
||||
children = children,
|
||||
)
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.dowstats.service.schedulers
|
||||
|
||||
import com.dowstats.service.integrations.ModStorageIntegrationService
|
||||
import org.apache.commons.logging.LogFactory
|
||||
import org.springframework.scheduling.annotation.Scheduled
|
||||
import org.springframework.stereotype.Component
|
||||
|
||||
|
||||
@Component
|
||||
class Schedulers (
|
||||
val modStorageIntegrationService: ModStorageIntegrationService
|
||||
) {
|
||||
|
||||
@Scheduled(fixedDelay = 600000)
|
||||
fun synchronizeLastMods() {
|
||||
modStorageIntegrationService.requestAvailableMods()
|
||||
}
|
||||
}
|
||||
@@ -167,7 +167,7 @@ class UnitRgdExtractService @Autowired constructor(
|
||||
unit.deathExplosions.addAll(deathExplosionRgdExtractService.getDeathExplosions(unitData, armorTypes).toMutableSet())
|
||||
|
||||
|
||||
val sergeantsData = getSergeantsData(squadData)
|
||||
val sergeantsData = getSergeantsData(squadData, unitData)
|
||||
|
||||
val sergeantsEntities: List<Pair<Sergeant, Set<Weapon>>>? = sergeantsData.first?.mapNotNull { sergeantData ->
|
||||
val sergeantFile = sergeantData.filePath.split("\\").last().replace(".lua", ".rgd")
|
||||
@@ -367,14 +367,22 @@ class UnitRgdExtractService @Autowired constructor(
|
||||
|
||||
|
||||
|
||||
private fun getSergeantsData(squadData: List<RgdData>?): Pair<List<SergeantData>?, Int?> {
|
||||
private fun getSergeantsData(squadData: List<RgdData>?, unitData: List<RgdData>): Pair<List<SergeantData>?, Int?> {
|
||||
|
||||
val squadTable = squadData
|
||||
?.getRgdTableByName("squad_leader_ext")
|
||||
|
||||
val maxSergeants = squadTable?.getIntByName("max_leaders")
|
||||
|
||||
val sergeantsData = squadTable?.mapNotNull { sergeantData ->
|
||||
|
||||
// Не хочется городить таблицы, путсть тот, в кого превращается юнит тоже будет сержантом
|
||||
val entrenchedBlueprint = unitData
|
||||
.getRgdTableByName("entrench_ext")
|
||||
?.getStringByName("entrenched_blueprint_name")
|
||||
|
||||
val sergeantsData = if (!entrenchedBlueprint.isNullOrEmpty()) {
|
||||
listOf(SergeantData(entrenchedBlueprint, BuildCost(null, null, null, null, null, null)))
|
||||
} else squadTable?.mapNotNull { sergeantData ->
|
||||
if (sergeantData.name.contains("leader_")) {
|
||||
val sergeantRgdTable = sergeantData.value as List<RgdData>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user