[O] DIVA kt > better kt

This commit is contained in:
Azalea 2025-10-25 06:58:51 +08:00
parent 664365b09b
commit acf76bd270
27 changed files with 98 additions and 383 deletions

View File

@ -6,8 +6,6 @@ import icu.samnyan.aqua.sega.diva.model.gamedata.Contest
import icu.samnyan.aqua.sega.diva.model.request.BaseRequest
import icu.samnyan.aqua.sega.diva.model.response.databank.ContestInfoResponse
import icu.samnyan.aqua.sega.diva.util.URIEncoder.encode
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Component
import java.time.LocalDateTime
import java.util.function.Consumer
@ -36,8 +34,4 @@ class ContestInfoHandler(private val contestRepository: ContestRepository) : Bas
ci_str
)
}
companion object {
private val logger: Logger = LoggerFactory.getLogger(CmPlyInfoHandler::class.java)
}
}

View File

@ -19,21 +19,12 @@ class CstmzItmCtlgHandler(private val customizeRepository: DivaCustomizeReposito
fun handle(request: BaseRequest): Any {
val customizeList = customizeRepository.findAll()
val response = CstmzItmCtlgResponse(
return CstmzItmCtlgResponse(
request.cmd,
request.req_id,
"ok",
DivaDateTimeUtil.getString(LocalDateTime.now()),
encode(customizeList.map { it.toInternal() }.joinToString(",") { encode(it) })
)
val resp = this.build(mapper.toMap(response))
logger.info("Response: {}", resp)
return resp
}
companion object {
private val logger: Logger = LoggerFactory.getLogger(CstmzItmCtlgHandler::class.java)
}
}

View File

@ -4,8 +4,6 @@ import icu.samnyan.aqua.sega.diva.handler.BaseHandler
import icu.samnyan.aqua.sega.diva.model.request.BaseRequest
import icu.samnyan.aqua.sega.diva.model.response.databank.CstmzItmNgMdlListResponse
import icu.samnyan.aqua.sega.diva.util.DivaDateTimeUtil
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Component
import java.time.LocalDateTime
@ -14,22 +12,11 @@ import java.time.LocalDateTime
*/
@Component
class CstmzItmNgMdlListHandler : BaseHandler() {
fun handle(request: BaseRequest): Any {
val response = CstmzItmNgMdlListResponse(
request.cmd,
request.req_id,
"ok",
DivaDateTimeUtil.getString(LocalDateTime.now()),
"***"
)
val resp = this.build(mapper.toMap(response))
logger.info("Response: {}", resp)
return resp
}
companion object {
private val logger: Logger = LoggerFactory.getLogger(CstmzItmCtlgHandler::class.java)
}
fun handle(request: BaseRequest) = CstmzItmNgMdlListResponse(
request.cmd,
request.req_id,
"ok",
DivaDateTimeUtil.getString(LocalDateTime.now()),
"***"
)
}

View File

@ -18,7 +18,7 @@ class FestaInfoHandler(private val festaRepository: FestaRepository) : BaseHandl
val festaList = festaRepository.findTop2ByEnableOrderByCreateDateDesc(true)
val collection = FestaCollection(festaList)
val response = FestaInfoResponse(
return FestaInfoResponse(
request.cmd,
request.req_id,
"ok",
@ -34,14 +34,5 @@ class FestaInfoHandler(private val festaRepository: FestaRepository) : BaseHandl
collection.ends,
collection.lastUpdateTime
)
val resp = this.build(mapper.toMap(response))
logger.info("Response: {}", resp)
return resp
}
companion object {
private val logger: Logger = LoggerFactory.getLogger(FestaInfoHandler::class.java)
}
}

View File

@ -3,8 +3,6 @@ package icu.samnyan.aqua.sega.diva.handler.databank
import icu.samnyan.aqua.sega.diva.handler.BaseHandler
import icu.samnyan.aqua.sega.diva.model.request.BaseRequest
import icu.samnyan.aqua.sega.diva.model.response.BaseResponse
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Component
/**
@ -12,20 +10,9 @@ import org.springframework.stereotype.Component
*/
@Component
class NgWordHandler : BaseHandler() {
fun handle(request: BaseRequest): Any {
val response = BaseResponse(
request.cmd,
request.req_id,
"ok"
)
val resp = this.build(mapper.toMap(response))
logger.info("Response: {}", resp)
return resp
}
companion object {
private val logger: Logger = LoggerFactory.getLogger(NgWordHandler::class.java)
}
fun handle(request: BaseRequest) = BaseResponse(
request.cmd,
request.req_id,
"ok"
)
}

View File

@ -3,8 +3,6 @@ package icu.samnyan.aqua.sega.diva.handler.databank
import icu.samnyan.aqua.sega.diva.handler.BaseHandler
import icu.samnyan.aqua.sega.diva.model.request.BaseRequest
import icu.samnyan.aqua.sega.diva.model.response.databank.NvRankingResponse
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Component
/**
@ -12,24 +10,13 @@ import org.springframework.stereotype.Component
*/
@Component
class NvRankingHandler : BaseHandler() {
fun handle(request: BaseRequest): Any {
val response = NvRankingResponse(
request.cmd,
request.req_id,
"ok",
null,
null,
null,
null
)
val resp = this.build(mapper.toMap(response))
logger.info("Response: {}", resp)
return resp
}
companion object {
private val logger: Logger = LoggerFactory.getLogger(NvRankingHandler::class.java)
}
fun handle(request: BaseRequest) = NvRankingResponse(
request.cmd,
request.req_id,
"ok",
null,
null,
null,
null
)
}

View File

@ -8,8 +8,6 @@ import icu.samnyan.aqua.sega.diva.model.common.collection.PsRankingCollection
import icu.samnyan.aqua.sega.diva.model.request.databank.PsRankingRequest
import icu.samnyan.aqua.sega.diva.model.response.databank.PsRankingResponse
import icu.samnyan.aqua.sega.diva.util.URIEncoder.encode
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Component
import java.time.LocalDateTime
import java.util.*
@ -80,7 +78,7 @@ class PsRankingHandler(private val playerPvRecordRepository: PlayerPvRecordRepos
)
}
val response = PsRankingResponse(
return PsRankingResponse(
request.cmd,
request.req_id,
"ok",
@ -98,14 +96,5 @@ class PsRankingHandler(private val playerPvRecordRepository: PlayerPvRecordRepos
name2.stream().map<String?> { obj: String? -> obj.toString() }.collect(Collectors.joining(",")),
name3.stream().map<String?> { obj: String? -> obj.toString() }.collect(Collectors.joining(","))
)
val resp = this.build(mapper.toMap(response))
logger.info("Response: {}", resp)
return resp
}
companion object {
private val logger: Logger = LoggerFactory.getLogger(PsRankingHandler::class.java)
}
}

View File

@ -14,22 +14,11 @@ import java.time.LocalDateTime
*/
@Component
class PstdHCtrlHandler : BaseHandler() {
fun handle(request: BaseRequest): Any {
val response = PstdHCtrlResponse(
request.cmd,
request.req_id,
"ok",
DivaDateTimeUtil.getString(LocalDateTime.now()),
"***,***"
)
val resp = this.build(mapper.toMap(response))
logger.info("Response: {}", resp)
return resp
}
companion object {
private val logger: Logger = LoggerFactory.getLogger(PstdHCtrlHandler::class.java)
}
fun handle(request: BaseRequest) = PstdHCtrlResponse(
request.cmd,
request.req_id,
"ok",
DivaDateTimeUtil.getString(LocalDateTime.now()),
"***,***"
)
}

View File

@ -4,8 +4,6 @@ import icu.samnyan.aqua.sega.diva.handler.BaseHandler
import icu.samnyan.aqua.sega.diva.model.request.BaseRequest
import icu.samnyan.aqua.sega.diva.model.response.databank.PstdItemNgLstResponse
import icu.samnyan.aqua.sega.diva.util.DivaDateTimeUtil
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Component
import java.time.LocalDateTime
@ -14,23 +12,12 @@ import java.time.LocalDateTime
*/
@Component
class PstdItemNgLstHandler : BaseHandler() {
fun handle(request: BaseRequest): Any {
val response = PstdItemNgLstResponse(
request.cmd,
request.req_id,
"ok",
DivaDateTimeUtil.getString(LocalDateTime.now()),
"***",
"***"
)
val resp = this.build(mapper.toMap(response))
logger.info("Response: {}", resp)
return resp
}
companion object {
private val logger: Logger = LoggerFactory.getLogger(PstdItemNgLstHandler::class.java)
}
fun handle(request: BaseRequest) = PstdItemNgLstResponse(
request.cmd,
request.req_id,
"ok",
DivaDateTimeUtil.getString(LocalDateTime.now()),
"***",
"***"
)
}

View File

@ -14,22 +14,11 @@ import java.time.LocalDateTime
*/
@Component
class PvDefChrLstHandler : BaseHandler() {
fun handle(request: BaseRequest): Any {
val response = PvDefChrLstResponse(
request.cmd,
request.req_id,
"ok",
DivaDateTimeUtil.getString(LocalDateTime.now()),
"***"
)
val resp = this.build(mapper.toMap(response))
logger.info("Response: {}", resp)
return resp
}
companion object {
private val logger: Logger = LoggerFactory.getLogger(PvDefChrLstHandler::class.java)
}
fun handle(request: BaseRequest) = PvDefChrLstResponse(
request.cmd,
request.req_id,
"ok",
DivaDateTimeUtil.getString(LocalDateTime.now()),
"***"
)
}

View File

@ -35,18 +35,13 @@ class PvListHandler(private val pvEntryRepository: PvEntryRepository) : BaseHand
sb.append(encode(difficultyString(extremeList))).append(",")
sb.append("%2A%2A%2A")
val response = PvListResponse(
return PvListResponse(
request.cmd,
request.req_id,
"ok",
LocalDateTime.now(),
sb.toString()
)
val resp = this.build(mapper.toMap(response))
logger.info("Response: {}", resp)
return resp
}
private fun entryString(entry: PvEntry): String {
@ -65,8 +60,4 @@ class PvListHandler(private val pvEntryRepository: PvEntryRepository) : BaseHand
if (sb.length > 0) sb.deleteCharAt(sb.length - 1)
return sb.toString()
}
companion object {
private val logger: Logger = LoggerFactory.getLogger(BannerDataHandler::class.java)
}
}

View File

@ -4,8 +4,6 @@ import icu.samnyan.aqua.sega.diva.handler.BaseHandler
import icu.samnyan.aqua.sega.diva.model.request.BaseRequest
import icu.samnyan.aqua.sega.diva.model.response.databank.PvNgMdlLstResponse
import icu.samnyan.aqua.sega.diva.util.DivaDateTimeUtil
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Component
import java.time.LocalDateTime
@ -14,22 +12,11 @@ import java.time.LocalDateTime
*/
@Component
class PvNgMdlLstHandler : BaseHandler() {
fun handle(request: BaseRequest): Any {
val response = PvNgMdlLstResponse(
request.cmd,
request.req_id,
"ok",
DivaDateTimeUtil.getString(LocalDateTime.now()),
"***"
)
val resp = this.build(mapper.toMap(response))
logger.info("Response: {}", resp)
return resp
}
companion object {
private val logger: Logger = LoggerFactory.getLogger(PvNgMdlLstHandler::class.java)
}
fun handle(request: BaseRequest) = PvNgMdlLstResponse(
request.cmd,
request.req_id,
"ok",
DivaDateTimeUtil.getString(LocalDateTime.now()),
"***"
)
}

View File

@ -4,8 +4,6 @@ import icu.samnyan.aqua.sega.diva.handler.BaseHandler
import icu.samnyan.aqua.sega.diva.model.request.BaseRequest
import icu.samnyan.aqua.sega.diva.model.response.databank.QstInfResponse
import icu.samnyan.aqua.sega.diva.util.DivaDateTimeUtil
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Component
import java.time.LocalDateTime
@ -14,23 +12,12 @@ import java.time.LocalDateTime
*/
@Component
class QstInfHandler : BaseHandler() {
fun handle(request: BaseRequest): Any {
val response = QstInfResponse(
request.cmd,
request.req_id,
"ok",
DivaDateTimeUtil.getString(LocalDateTime.now()),
null,
null
)
val resp = this.build(mapper.toMap(response))
logger.info("Response: {}", resp)
return resp
}
companion object {
private val logger: Logger = LoggerFactory.getLogger(QstInfHandler::class.java)
}
fun handle(request: BaseRequest) = QstInfResponse(
request.cmd,
request.req_id,
"ok",
DivaDateTimeUtil.getString(LocalDateTime.now()),
null,
null
)
}

View File

@ -4,8 +4,6 @@ import icu.samnyan.aqua.sega.diva.handler.BaseHandler
import icu.samnyan.aqua.sega.diva.model.request.BaseRequest
import icu.samnyan.aqua.sega.diva.model.response.databank.RmtWpLstResponse
import icu.samnyan.aqua.sega.diva.util.DivaDateTimeUtil
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Component
import java.time.LocalDateTime
@ -14,22 +12,11 @@ import java.time.LocalDateTime
*/
@Component
class RmtWpLstHandler : BaseHandler() {
fun handle(request: BaseRequest): Any {
val response = RmtWpLstResponse(
request.cmd,
request.req_id,
"ok",
DivaDateTimeUtil.getString(LocalDateTime.now()),
"***"
)
val resp = this.build(mapper.toMap(response))
logger.info("Response: {}", resp)
return resp
}
companion object {
private val logger: Logger = LoggerFactory.getLogger(QstInfHandler::class.java)
}
fun handle(request: BaseRequest) = RmtWpLstResponse(
request.cmd,
request.req_id,
"ok",
DivaDateTimeUtil.getString(LocalDateTime.now()),
"***"
)
}

View File

@ -18,21 +18,12 @@ class ShopCatalogHandler(private val moduleRepository: DivaModuleRepository) : B
fun handle(request: BaseRequest): Any {
val moduleList = moduleRepository.findAll()
val response = ShopCatalogResponse(
return ShopCatalogResponse(
request.cmd,
request.req_id,
"ok",
LocalDateTime.now(),
encode(moduleList.map { it.toInternal() }.joinToString(",") { encode(it) })
)
val resp = this.build(mapper.toMap(response))
logger.info("Response: {}", resp)
return resp
}
companion object {
private val logger: Logger = LoggerFactory.getLogger(ShopCatalogHandler::class.java)
}
}

View File

@ -11,8 +11,6 @@ import icu.samnyan.aqua.sega.diva.model.response.ingame.BuyCstmzItmResponse
import icu.samnyan.aqua.sega.diva.model.userdata.GameSession
import icu.samnyan.aqua.sega.diva.service.PlayerCustomizeService
import icu.samnyan.aqua.sega.diva.service.PlayerProfileService
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Component
import java.util.function.Supplier
@ -27,17 +25,16 @@ class BuyCstmzItmHandler(
private val gameSessionRepository: GameSessionRepository
) : BaseHandler() {
fun handle(request: BuyCstmzItmRequest): Any {
val profile = playerProfileService.findByPdId(request.pd_id).orElseThrow<ProfileNotFoundException?>(
val profile = playerProfileService.findByPdId(request.pd_id).orElseThrow(
Supplier { ProfileNotFoundException() })
val session = gameSessionRepository.findByPdId(profile)
.orElseThrow<SessionNotFoundException?>(Supplier { SessionNotFoundException() })
.orElseThrow(Supplier { SessionNotFoundException() })
val customizeOptional = divaCustomizeRepository.findById(request.cstmz_itm_id)
val response: BuyCstmzItmResponse?
if (customizeOptional.isEmpty) {
response = BuyCstmzItmResponse(
return BuyCstmzItmResponse(
request.cmd,
request.req_id,
"ok",
@ -45,7 +42,7 @@ class BuyCstmzItmHandler(
)
} else {
if (session.vp < customizeOptional.get().price) {
response = BuyCstmzItmResponse(
return BuyCstmzItmResponse(
request.cmd,
request.req_id,
"ok",
@ -56,7 +53,7 @@ class BuyCstmzItmHandler(
session.vp = session.vp - customizeOptional.get().price
gameSessionRepository.save<GameSession?>(session)
response = BuyCstmzItmResponse(
return BuyCstmzItmResponse(
request.cmd,
request.req_id,
"ok",
@ -67,14 +64,5 @@ class BuyCstmzItmHandler(
)
}
}
val resp = this.build(mapper.toMap(response))
logger.info("Response: {}", resp)
return resp
}
companion object {
private val logger: Logger = LoggerFactory.getLogger(BuyCstmzItmHandler::class.java)
}
}

View File

@ -37,7 +37,7 @@ class BuyModuleHandler(
val response: BuyModuleResponse?
if (moduleOptional.isEmpty) {
response = BuyModuleResponse(
return BuyModuleResponse(
request.cmd,
request.req_id,
"ok",
@ -45,7 +45,7 @@ class BuyModuleHandler(
)
} else {
if (session.vp < moduleOptional.get().price) {
response = BuyModuleResponse(
return BuyModuleResponse(
request.cmd,
request.req_id,
"ok",
@ -56,7 +56,7 @@ class BuyModuleHandler(
session.vp = session.vp - moduleOptional.get().price
gameSessionRepository.save<GameSession?>(session)
response = BuyModuleResponse(
return BuyModuleResponse(
request.cmd,
request.req_id,
"ok",
@ -67,14 +67,5 @@ class BuyModuleHandler(
)
}
}
val resp = this.build(mapper.toMap(response))
logger.info("Response: {}", resp)
return resp
}
companion object {
private val logger: Logger = LoggerFactory.getLogger(BuyModuleHandler::class.java)
}
}

View File

@ -100,7 +100,7 @@ class GetPvPdHandler(
pd.deleteCharAt(pd.length - 1)
val response = GetPvPdResponse(
return GetPvPdResponse(
request.cmd,
request.req_id,
"ok",
@ -108,11 +108,6 @@ class GetPvPdHandler(
false,
DivaDateTimeUtil.getString(LocalDateTime.now())
)
val resp = this.build(mapper.toMap(response))
logger.info("Response: {}", resp)
return resp
}
@ -149,8 +144,4 @@ class GetPvPdHandler(
record.rgoPurchased + "," +
record.rgoPlayed
}
companion object {
private val logger: Logger = LoggerFactory.getLogger(GetPvPdHandler::class.java)
}
}

View File

@ -44,20 +44,11 @@ class ShopExitHandler(
playerProfileService.save(profile)
pvCustomizeRepository.save<PlayerPvCustomize?>(customize)
val response = ShopExitResponse(
return ShopExitResponse(
request.cmd,
request.req_id,
"ok",
Result.SUCCESS
)
val resp = this.build(mapper.toMap(response))
logger.info("Response: {}", resp)
return resp
}
companion object {
private val logger: Logger = LoggerFactory.getLogger(ShopExitHandler::class.java)
}
}

View File

@ -1,5 +1,6 @@
package icu.samnyan.aqua.sega.diva.handler.ingame
import ext.logger
import icu.samnyan.aqua.sega.diva.dao.gamedata.ContestRepository
import icu.samnyan.aqua.sega.diva.dao.userdata.*
import icu.samnyan.aqua.sega.diva.exception.ProfileNotFoundException
@ -42,6 +43,7 @@ class StageResultHandler(
private val divaCalculator: DivaCalculator
) : BaseHandler() {
private var currentProfile: PlayerProfile? = null
val logger = logger()
fun handle(request: StageResultRequest): Any {
val response: StageResultResponse?
@ -210,7 +212,7 @@ class StageResultHandler(
gameSessionRepository.save<GameSession?>(session)
response = StageResultResponse(
return StageResultResponse(
request.cmd,
request.req_id,
"ok",
@ -260,17 +262,12 @@ class StageResultHandler(
"-1,-1,-1,-1,-1"
)
} else {
response = StageResultResponse(
return StageResultResponse(
request.cmd,
request.req_id,
"ok"
)
}
val resp = this.build(mapper.toMap(response))
logger.info("Response: {}", resp)
return resp
}
private fun getLog(request: StageResultRequest, profile: PlayerProfile?, i: Int): PlayLog {
@ -458,8 +455,4 @@ class StageResultHandler(
}
return null
}
companion object {
private val logger: Logger = LoggerFactory.getLogger(StageResultHandler::class.java)
}
}

View File

@ -46,19 +46,10 @@ class StageStartHandler(
gameSessionRepository.save<GameSession?>(session)
}
val response = BaseResponse(
return BaseResponse(
request.cmd,
request.req_id,
"ok"
)
val resp = this.build(mapper.toMap(response))
logger.info("Response: {}", resp)
return resp
}
companion object {
private val logger: Logger = LoggerFactory.getLogger(StageResultHandler::class.java)
}
}

View File

@ -1,5 +1,6 @@
package icu.samnyan.aqua.sega.diva.handler.ingame
import ext.logger
import icu.samnyan.aqua.sega.diva.dao.userdata.PlayerScreenShotRepository
import icu.samnyan.aqua.sega.diva.exception.ProfileNotFoundException
import icu.samnyan.aqua.sega.diva.handler.BaseHandler
@ -8,8 +9,6 @@ import icu.samnyan.aqua.sega.diva.model.response.BaseResponse
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerScreenShot
import icu.samnyan.aqua.sega.diva.service.PlayerProfileService
import icu.samnyan.aqua.sega.diva.util.DivaStringUtils
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Component
import org.springframework.web.multipart.MultipartFile
import java.io.IOException
@ -27,6 +26,7 @@ class StoreSsHandler(
private val playerProfileService: PlayerProfileService,
private val screenShotRepository: PlayerScreenShotRepository
) : BaseHandler() {
val logger = logger()
fun handle(request: StoreSsRequest, file: MultipartFile): Any {
val profile = playerProfileService.findByPdId(request.pd_id).orElseThrow<ProfileNotFoundException?>(
Supplier { ProfileNotFoundException() })
@ -46,7 +46,7 @@ class StoreSsHandler(
)
screenShotRepository.save<PlayerScreenShot?>(ss)
response = BaseResponse(
return BaseResponse(
request.cmd,
request.req_id,
"ok"
@ -54,20 +54,11 @@ class StoreSsHandler(
} catch (e: IOException) {
logger.error("Screenshot save failed", e)
response = BaseResponse(
return BaseResponse(
request.cmd,
request.req_id,
"0"
)
}
val resp = this.build(mapper.toMap(response))
logger.info("Response: {}", resp)
return resp
}
companion object {
private val logger: Logger = LoggerFactory.getLogger(StoreSsHandler::class.java)
}
}

View File

@ -89,16 +89,11 @@ class EndHandler(
gameSessionRepository.delete(session)
val response = BaseResponse(
return BaseResponse(
request.cmd,
request.req_id,
"ok"
)
val resp = this.build(mapper.toMap(response))
logger.info("Response: {}", resp)
return resp
}
private fun getContestRank(contest: Contest, value: Int): ContestBorder {
@ -107,8 +102,4 @@ class EndHandler(
if (value >= contest.bronzeBorders) return ContestBorder.BRONZE
return ContestBorder.NONE
}
companion object {
private val logger: Logger = LoggerFactory.getLogger(EndHandler::class.java)
}
}

View File

@ -28,19 +28,10 @@ class PdUnlockHandler(
gameSessionRepository.delete(session)
val response = BaseResponse(
return BaseResponse(
request.cmd,
request.req_id,
"ok"
)
val resp = this.build(mapper.toMap(response))
logger.info("Response: {}", resp)
return resp
}
companion object {
private val logger: Logger = LoggerFactory.getLogger(PdUnlockHandler::class.java)
}
}

View File

@ -1,5 +1,6 @@
package icu.samnyan.aqua.sega.diva.handler.user
import ext.logger
import icu.samnyan.aqua.sega.diva.dao.userdata.GameSessionRepository
import icu.samnyan.aqua.sega.diva.handler.BaseHandler
import icu.samnyan.aqua.sega.diva.model.common.PreStartResult
@ -8,8 +9,6 @@ import icu.samnyan.aqua.sega.diva.model.request.user.PreStartRequest
import icu.samnyan.aqua.sega.diva.model.response.user.PreStartResponse
import icu.samnyan.aqua.sega.diva.model.userdata.GameSession
import icu.samnyan.aqua.sega.diva.service.PlayerProfileService
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Component
import java.time.LocalDateTime
import java.util.concurrent.ThreadLocalRandom
@ -22,21 +21,17 @@ class PreStartHandler(
private val playerProfileService: PlayerProfileService,
private val gameSessionRepository: GameSessionRepository
) : BaseHandler() {
var logger = logger()
fun handle(request: PreStartRequest): Any {
val profileOptional = playerProfileService.findByPdId(request.aime_id)
val response: PreStartResponse?
if (profileOptional.isEmpty) {
response = PreStartResponse(
return PreStartResponse(
request.cmd,
request.req_id,
"ok",
PreStartResult.NEW_REGISTRATION
)
val resp = this.build(mapper.toMap(response))
logger.info("Response: {}", resp)
return resp
} else {
val profile = profileOptional.get()
@ -46,17 +41,12 @@ class PreStartHandler(
if (!session.lastUpdateTime
.isBefore(LocalDateTime.now().minusMinutes(5)) && session.startMode == StartMode.START
) {
response = PreStartResponse(
return PreStartResponse(
request.cmd,
request.req_id,
"ok",
PreStartResult.ALREADY_PLAYING
)
val resp = this.build(mapper.toMap(response))
logger.info("Response: {}", resp)
return resp
} else {
gameSessionRepository.delete(session)
}
@ -80,7 +70,7 @@ class PreStartHandler(
gameSessionRepository.save<GameSession?>(session)
response = PreStartResponse(
return PreStartResponse(
request.cmd,
request.req_id,
"ok",
@ -104,15 +94,6 @@ class PreStartHandler(
profile.vocaloidPoints,
profile.passwordStatus
)
val resp = this.build(mapper.toMap(response))
logger.info("Response: {}", resp)
return resp
}
}
companion object {
private val logger: Logger = LoggerFactory.getLogger(PreStartHandler::class.java)
}
}

View File

@ -19,7 +19,7 @@ class SpendCreditHandler(private val playerProfileService: PlayerProfileService)
val profile = playerProfileService.findByPdId(request.pd_id).orElseThrow<ProfileNotFoundException?>(
Supplier { ProfileNotFoundException() })
val response = SpendCreditResponse(
return SpendCreditResponse(
request.cmd,
request.req_id,
"ok",
@ -30,14 +30,5 @@ class SpendCreditHandler(private val playerProfileService: PlayerProfileService)
profile.plateEffectId,
profile.plateId
)
val resp = this.build(mapper.toMap(response))
logger.info("Response: {}", resp)
return resp
}
companion object {
private val logger: Logger = LoggerFactory.getLogger(SpendCreditHandler::class.java)
}
}

View File

@ -58,7 +58,7 @@ class StartHandler(
border = border or ((if (profile.isShowExcellentBorder) 1 else 0) shl 1)
border = border or ((if (profile.isShowRivalBorder) 1 else 0) shl 2)
val response = StartResponse(
return StartResponse(
request.cmd,
request.req_id,
"ok",
@ -121,11 +121,6 @@ class StartHandler(
null,
null
)
val resp = this.build(mapper.toMap(response))
logger.info("Response: {}", resp)
return resp
}
private fun countClearStatus(profile: PlayerProfile?): String? {
@ -198,8 +193,4 @@ class StartHandler(
result["cv_bf"] = cv_bf.stream().map<String?> { obj: Int? -> obj.toString() }.collect(Collectors.joining(","))
return result
}
companion object {
private val logger: Logger = LoggerFactory.getLogger(StartHandler::class.java)
}
}