mirror of
https://github.com/MewoLab/AquaDX.git
synced 2025-10-25 12:02:40 +00:00
[O] Capsule
This commit is contained in:
parent
b7cb3cb6ea
commit
e90123389c
@ -1,9 +1,12 @@
|
||||
package icu.samnyan.aqua.sega.diva
|
||||
|
||||
import ext.invoke
|
||||
import icu.samnyan.aqua.sega.diva.model.common.Difficulty
|
||||
import icu.samnyan.aqua.sega.diva.model.common.Edition
|
||||
import icu.samnyan.aqua.sega.diva.model.gamedata.*
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.*
|
||||
import icu.samnyan.aqua.sega.diva.util.ProfileNotFoundException
|
||||
import icu.samnyan.aqua.sega.diva.util.SessionNotFoundException
|
||||
import org.springframework.data.jpa.repository.JpaRepository
|
||||
import org.springframework.data.jpa.repository.Query
|
||||
import org.springframework.data.repository.query.Param
|
||||
@ -34,8 +37,11 @@ class DivaRepos(
|
||||
val profile: PlayerProfileRepository,
|
||||
val pvCustomize: PlayerPvCustomizeRepository,
|
||||
val pvRecord: PlayerPvRecordRepository,
|
||||
val screenShot: PlayerScreenShotRepository
|
||||
)
|
||||
val screenShot: PlayerScreenShotRepository,
|
||||
) {
|
||||
fun profile(id: Long) = profile.findByPdId(id)() ?: throw ProfileNotFoundException()
|
||||
fun session(id: Long) = profile(id).let { it to (gameSession.findByPdId(it)() ?: throw SessionNotFoundException()) }
|
||||
}
|
||||
|
||||
@Repository
|
||||
interface ContestRepository : JpaRepository<Contest, Int> {
|
||||
|
||||
@ -56,7 +56,7 @@ class CardProcedureHandler(val db: DivaRepos) {
|
||||
profile.vocaloidPoints
|
||||
)
|
||||
|
||||
db.gameSession.save<GameSession?>(session)
|
||||
db.gameSession.save(session)
|
||||
return CardProcedureResponse(
|
||||
request.cmd,
|
||||
request.req_id,
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.card
|
||||
|
||||
import ext.invoke
|
||||
import icu.samnyan.aqua.sega.diva.DivaRepos
|
||||
import icu.samnyan.aqua.sega.diva.util.ProfileNotFoundException
|
||||
import icu.samnyan.aqua.sega.diva.util.SessionNotFoundException
|
||||
import icu.samnyan.aqua.sega.diva.model.common.Result
|
||||
import icu.samnyan.aqua.sega.diva.model.request.card.ChangeNameRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.response.card.ChangeNameResponse
|
||||
@ -15,8 +12,7 @@ import org.springframework.stereotype.Component
|
||||
@Component
|
||||
class ChangeNameHandler(val db: DivaRepos) {
|
||||
fun handle(request: ChangeNameRequest): Any {
|
||||
val profile = db.profile.findByPdId(request.pd_id)() ?: throw ProfileNotFoundException()
|
||||
val session = db.gameSession.findByPdId(profile)() ?: throw SessionNotFoundException()
|
||||
val (profile, session) = db.session(request.pd_id)
|
||||
|
||||
profile.playerName = request.player_name
|
||||
db.profile.save(profile)
|
||||
|
||||
@ -1,12 +1,11 @@
|
||||
package icu.samnyan.aqua.sega.diva.handler.card
|
||||
|
||||
import icu.samnyan.aqua.sega.diva.DivaRepos
|
||||
import icu.samnyan.aqua.sega.diva.util.ProfileNotFoundException
|
||||
import icu.samnyan.aqua.sega.diva.util.SessionNotFoundException
|
||||
import icu.samnyan.aqua.sega.diva.model.common.PassStat
|
||||
import icu.samnyan.aqua.sega.diva.model.common.Result
|
||||
import icu.samnyan.aqua.sega.diva.model.request.card.ChangePasswdRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.response.card.ChangePasswdResponse
|
||||
import icu.samnyan.aqua.sega.diva.util.SessionNotFoundException
|
||||
import org.springframework.stereotype.Component
|
||||
import java.util.function.Supplier
|
||||
|
||||
@ -16,10 +15,7 @@ import java.util.function.Supplier
|
||||
@Component
|
||||
class ChangePasswdHandler(val db: DivaRepos) {
|
||||
fun handle(request: ChangePasswdRequest): Any {
|
||||
val profile = db.profile.findByPdId(request.pd_id)
|
||||
.orElseThrow(Supplier { ProfileNotFoundException() })
|
||||
val session = db.gameSession.findByPdId(profile)
|
||||
.orElseThrow(Supplier { SessionNotFoundException() })
|
||||
val (profile, session) = db.session(request.pd_id)
|
||||
|
||||
profile.passwordStatus = PassStat.SET
|
||||
profile.password = request.new_passwd
|
||||
|
||||
@ -4,7 +4,6 @@ import icu.samnyan.aqua.sega.diva.DivaRepos
|
||||
import icu.samnyan.aqua.sega.diva.model.common.Result
|
||||
import icu.samnyan.aqua.sega.diva.model.request.ingame.BuyCstmzItmRequest
|
||||
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.util.ProfileNotFoundException
|
||||
import icu.samnyan.aqua.sega.diva.util.SessionNotFoundException
|
||||
import org.springframework.stereotype.Component
|
||||
@ -16,11 +15,7 @@ import java.util.function.Supplier
|
||||
@Component
|
||||
class BuyCstmzItmHandler(val db: DivaRepos) {
|
||||
fun handle(request: BuyCstmzItmRequest): Any {
|
||||
val profile = db.profile.findByPdId(request.pd_id).orElseThrow(
|
||||
Supplier { ProfileNotFoundException() })
|
||||
|
||||
val session = db.gameSession.findByPdId(profile)
|
||||
.orElseThrow(Supplier { SessionNotFoundException() })
|
||||
val (profile, session) = db.session(request.pd_id)
|
||||
|
||||
val customizeOptional = db.g.customize.findById(request.cstmz_itm_id)
|
||||
|
||||
@ -42,7 +37,7 @@ class BuyCstmzItmHandler(val db: DivaRepos) {
|
||||
}
|
||||
db.s.customize.buy(profile, request.cstmz_itm_id)
|
||||
session.vp -= customizeOptional.get().price
|
||||
db.gameSession.save<GameSession?>(session)
|
||||
db.gameSession.save(session)
|
||||
|
||||
return BuyCstmzItmResponse(
|
||||
request.cmd,
|
||||
|
||||
@ -4,11 +4,7 @@ import icu.samnyan.aqua.sega.diva.DivaRepos
|
||||
import icu.samnyan.aqua.sega.diva.model.common.Result
|
||||
import icu.samnyan.aqua.sega.diva.model.request.ingame.BuyModuleRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.response.ingame.BuyModuleResponse
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.GameSession
|
||||
import icu.samnyan.aqua.sega.diva.util.ProfileNotFoundException
|
||||
import icu.samnyan.aqua.sega.diva.util.SessionNotFoundException
|
||||
import org.springframework.stereotype.Component
|
||||
import java.util.function.Supplier
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
@ -16,12 +12,7 @@ import java.util.function.Supplier
|
||||
@Component
|
||||
class BuyModuleHandler(val db: DivaRepos) {
|
||||
fun handle(request: BuyModuleRequest): Any {
|
||||
val profile = db.profile.findByPdId(request.pd_id).orElseThrow<ProfileNotFoundException?>(
|
||||
Supplier { ProfileNotFoundException() })
|
||||
|
||||
val session = db.gameSession.findByPdId(profile)
|
||||
.orElseThrow<SessionNotFoundException?>(Supplier { SessionNotFoundException() })
|
||||
|
||||
val (profile, session) = db.session(request.pd_id)
|
||||
val moduleOptional = db.g.module.findById(request.mdl_id)
|
||||
|
||||
if (moduleOptional.isEmpty) {
|
||||
@ -42,7 +33,7 @@ class BuyModuleHandler(val db: DivaRepos) {
|
||||
}
|
||||
db.s.module.buy(profile, request.mdl_id)
|
||||
session.vp -= moduleOptional.get().price
|
||||
db.gameSession.save<GameSession?>(session)
|
||||
db.gameSession.save(session)
|
||||
|
||||
return BuyModuleResponse(
|
||||
request.cmd,
|
||||
|
||||
@ -6,7 +6,6 @@ import icu.samnyan.aqua.sega.diva.model.common.Result
|
||||
import icu.samnyan.aqua.sega.diva.model.request.ingame.ShopExitRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.response.ingame.ShopExitResponse
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerPvCustomize
|
||||
import icu.samnyan.aqua.sega.diva.util.ProfileNotFoundException
|
||||
import org.springframework.stereotype.Component
|
||||
import java.util.function.Supplier
|
||||
|
||||
@ -16,8 +15,7 @@ import java.util.function.Supplier
|
||||
@Component
|
||||
class ShopExitHandler(val db: DivaRepos) {
|
||||
fun handle(request: ShopExitRequest): Any {
|
||||
val profile = db.profile.findByPdId(request.pd_id).orElseThrow<ProfileNotFoundException?>(
|
||||
Supplier { ProfileNotFoundException() })
|
||||
val profile = db.profile(request.pd_id)
|
||||
val customize = db.pvCustomize.findByPdIdAndPvId(profile, request.ply_pv_id)
|
||||
.orElseGet(Supplier { PlayerPvCustomize(profile, request.ply_pv_id) })
|
||||
|
||||
|
||||
@ -33,10 +33,7 @@ class StageResultHandler(val db: DivaRepos, val calc: DivaCalculator) {
|
||||
fun handle(request: StageResultRequest): Any {
|
||||
val response: StageResultResponse?
|
||||
if (request.getPd_id() != -1L) {
|
||||
val profile = db.profile.findByPdId(request.getPd_id()).orElseThrow<ProfileNotFoundException?>(
|
||||
Supplier { ProfileNotFoundException() })
|
||||
val session = db.gameSession.findByPdId(profile)
|
||||
.orElseThrow<SessionNotFoundException?>(Supplier { SessionNotFoundException() })
|
||||
val (profile, session) = db.session(request.pd_id)
|
||||
|
||||
currentProfile = profile
|
||||
// Get the last played index
|
||||
@ -192,9 +189,9 @@ class StageResultHandler(val db: DivaRepos, val calc: DivaCalculator) {
|
||||
}
|
||||
}
|
||||
|
||||
db.pvRecord.save<PlayerPvRecord?>(record)
|
||||
db.playLog.save<PlayLog?>(log)
|
||||
db.gameSession.save<GameSession?>(session)
|
||||
db.pvRecord.save(record)
|
||||
db.playLog.save(log)
|
||||
db.gameSession.save(session)
|
||||
|
||||
|
||||
return StageResultResponse(
|
||||
@ -374,7 +371,7 @@ class StageResultHandler(val db: DivaRepos, val calc: DivaCalculator) {
|
||||
result["string1"] = "***"
|
||||
result["string2"] = "***"
|
||||
} else {
|
||||
db.inventory.save<PlayerInventory?>(
|
||||
db.inventory.save(
|
||||
PlayerInventory(
|
||||
null,
|
||||
currentProfile,
|
||||
@ -398,7 +395,7 @@ class StageResultHandler(val db: DivaRepos, val calc: DivaCalculator) {
|
||||
result.put("string1", "***")
|
||||
result.put("string2", "***")
|
||||
} else {
|
||||
db.inventory.save<PlayerInventory?>(
|
||||
db.inventory.save(
|
||||
PlayerInventory(
|
||||
null,
|
||||
currentProfile,
|
||||
|
||||
@ -3,11 +3,7 @@ package icu.samnyan.aqua.sega.diva.handler.ingame
|
||||
import icu.samnyan.aqua.sega.diva.DivaRepos
|
||||
import icu.samnyan.aqua.sega.diva.model.request.ingame.StageStartRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.response.BaseResponse
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.GameSession
|
||||
import icu.samnyan.aqua.sega.diva.util.ProfileNotFoundException
|
||||
import icu.samnyan.aqua.sega.diva.util.SessionNotFoundException
|
||||
import org.springframework.stereotype.Component
|
||||
import java.util.function.Supplier
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
@ -16,10 +12,7 @@ import java.util.function.Supplier
|
||||
class StageStartHandler(val db: DivaRepos) {
|
||||
fun handle(request: StageStartRequest): Any {
|
||||
if (request.getPd_id() != -1L) {
|
||||
val profile = db.profile.findByPdId(request.getPd_id()).orElseThrow<ProfileNotFoundException?>(
|
||||
Supplier { ProfileNotFoundException() })
|
||||
val session = db.gameSession.findByPdId(profile)
|
||||
.orElseThrow<SessionNotFoundException?>(Supplier { SessionNotFoundException() })
|
||||
val (_, session) = db.session(request.pd_id)
|
||||
|
||||
val stageArr = request.getStg_ply_pv_id()
|
||||
var stageIndex = 0
|
||||
@ -36,7 +29,7 @@ class StageStartHandler(val db: DivaRepos) {
|
||||
stageIndex = 3
|
||||
}
|
||||
session.stageIndex = stageIndex
|
||||
db.gameSession.save<GameSession?>(session)
|
||||
db.gameSession.save(session)
|
||||
}
|
||||
|
||||
return BaseResponse(
|
||||
|
||||
@ -6,7 +6,6 @@ import icu.samnyan.aqua.sega.diva.DivaRepos
|
||||
import icu.samnyan.aqua.sega.diva.model.request.ingame.StoreSsRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.response.BaseResponse
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerScreenShot
|
||||
import icu.samnyan.aqua.sega.diva.util.ProfileNotFoundException
|
||||
import org.springframework.stereotype.Component
|
||||
import org.springframework.web.multipart.MultipartFile
|
||||
import java.io.IOException
|
||||
@ -14,7 +13,6 @@ import java.nio.file.Files
|
||||
import java.nio.file.Paths
|
||||
import java.time.LocalDateTime
|
||||
import java.time.ZoneOffset
|
||||
import java.util.function.Supplier
|
||||
|
||||
/**
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
@ -23,14 +21,11 @@ import java.util.function.Supplier
|
||||
class StoreSsHandler(val db: DivaRepos) {
|
||||
val logger = logger()
|
||||
fun handle(request: StoreSsRequest, file: MultipartFile): Any {
|
||||
val profile = db.profile.findByPdId(request.pd_id).orElseThrow<ProfileNotFoundException?>(
|
||||
Supplier { ProfileNotFoundException() })
|
||||
val profile = db.profile(request.pd_id)
|
||||
|
||||
var response: BaseResponse?
|
||||
try {
|
||||
val filename =
|
||||
request.pd_id.toString() + "-" + LocalDateTime.now().toEpochSecond(ZoneOffset.UTC) + ".jpg"
|
||||
Files.write(Paths.get("data/" + filename), file.bytes)
|
||||
val filename = "${request.pd_id}-${LocalDateTime.now().toEpochSecond(ZoneOffset.UTC)}.jpg"
|
||||
Files.write(Paths.get("data/$filename"), file.bytes)
|
||||
|
||||
val ss = PlayerScreenShot(
|
||||
profile,
|
||||
@ -39,7 +34,7 @@ class StoreSsHandler(val db: DivaRepos) {
|
||||
request.ss_mdl_id.csv,
|
||||
request.ss_c_itm_id.csv
|
||||
)
|
||||
db.screenShot.save<PlayerScreenShot?>(ss)
|
||||
db.screenShot.save(ss)
|
||||
|
||||
return BaseResponse(
|
||||
request.cmd,
|
||||
|
||||
@ -26,11 +26,7 @@ import kotlin.math.max
|
||||
@Component
|
||||
class EndHandler(val db: DivaRepos) {
|
||||
fun handle(request: StageResultRequest): Any {
|
||||
val profile = db.profile.findByPdId(request.getPd_id()).orElseThrow<ProfileNotFoundException?>(
|
||||
Supplier { ProfileNotFoundException() })
|
||||
val session = db.gameSession.findByPdId(profile)
|
||||
.orElseThrow<SessionNotFoundException?>(Supplier { SessionNotFoundException() })
|
||||
|
||||
val (profile, session) = db.session(request.pd_id)
|
||||
|
||||
profile.headphoneVolume = request.getHp_vol()
|
||||
profile.isButtonSeOn = request.isBtn_se_vol
|
||||
@ -65,7 +61,7 @@ class EndHandler(val db: DivaRepos) {
|
||||
) currentResultRank else contestRecord.resultRank
|
||||
contestRecord.lastUpdateTime = LocalDateTime.now()
|
||||
|
||||
db.contest.save<PlayerContest?>(contestRecord)
|
||||
db.contest.save(contestRecord)
|
||||
profile.isContestNowPlayingEnable = false
|
||||
profile.contestNowPlayingId = -1
|
||||
profile.contestNowPlayingResultRank = ContestBorder.NONE
|
||||
|
||||
@ -3,7 +3,6 @@ package icu.samnyan.aqua.sega.diva.handler.user
|
||||
import icu.samnyan.aqua.sega.diva.DivaRepos
|
||||
import icu.samnyan.aqua.sega.diva.model.request.user.PdUnlockRequest
|
||||
import icu.samnyan.aqua.sega.diva.model.response.BaseResponse
|
||||
import icu.samnyan.aqua.sega.diva.util.ProfileNotFoundException
|
||||
import icu.samnyan.aqua.sega.diva.util.SessionNotFoundException
|
||||
import org.springframework.stereotype.Component
|
||||
import java.util.function.Supplier
|
||||
@ -11,10 +10,7 @@ import java.util.function.Supplier
|
||||
@Component
|
||||
class PdUnlockHandler(val db: DivaRepos) {
|
||||
fun handle(request: PdUnlockRequest): Any {
|
||||
val profile = db.profile.findByPdId(request.pd_id).orElseThrow<ProfileNotFoundException?>(
|
||||
Supplier { ProfileNotFoundException() })
|
||||
val session = db.gameSession.findByPdId(profile)
|
||||
.orElseThrow<SessionNotFoundException?>(Supplier { SessionNotFoundException() })
|
||||
val (profile, session) = db.session(request.pd_id)
|
||||
|
||||
db.gameSession.delete(session)
|
||||
|
||||
|
||||
@ -14,8 +14,7 @@ import java.util.function.Supplier
|
||||
@Component
|
||||
class SpendCreditHandler(val db: DivaRepos) {
|
||||
fun handle(request: SpendCreditRequest): Any {
|
||||
val profile = db.profile.findByPdId(request.pd_id).orElseThrow<ProfileNotFoundException?>(
|
||||
Supplier { ProfileNotFoundException() })
|
||||
val profile = db.profile(request.pd_id)
|
||||
|
||||
return SpendCreditResponse(
|
||||
request.cmd,
|
||||
|
||||
@ -9,14 +9,11 @@ import icu.samnyan.aqua.sega.diva.model.userdata.GameSession
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerContest
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerProfile
|
||||
import icu.samnyan.aqua.sega.diva.model.userdata.PlayerPvRecord
|
||||
import icu.samnyan.aqua.sega.diva.util.ProfileNotFoundException
|
||||
import icu.samnyan.aqua.sega.diva.util.PvRecordDataException
|
||||
import icu.samnyan.aqua.sega.diva.util.SessionNotFoundException
|
||||
import org.springframework.stereotype.Component
|
||||
import java.time.LocalDateTime
|
||||
import java.util.*
|
||||
import java.util.function.Consumer
|
||||
import java.util.function.Supplier
|
||||
import java.util.stream.Collectors
|
||||
|
||||
/**
|
||||
@ -25,10 +22,7 @@ import java.util.stream.Collectors
|
||||
@Component
|
||||
class StartHandler(val db: DivaRepos) {
|
||||
fun handle(request: StartRequest): Any {
|
||||
val profile = db.profile.findByPdId(request.getPd_id()).orElseThrow<ProfileNotFoundException>(
|
||||
Supplier { ProfileNotFoundException() })
|
||||
val session = db.gameSession.findByPdId(profile)
|
||||
.orElseThrow(Supplier { SessionNotFoundException() })
|
||||
val (profile, session) = db.session(request.pd_id)
|
||||
|
||||
session.startMode = StartMode.START
|
||||
db.gameSession.save<GameSession>(session)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user