mirror of https://github.com/hykilpikonna/AquaDX
[F] Fix wrong implementation in GetUserMapAreaApi
Thanks rinsama for the patchpull/50/head
parent
c11bb3be59
commit
3b80b8d7f1
|
@ -1,36 +0,0 @@
|
|||
package icu.samnyan.aqua.sega.chusan.handler;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.util.jackson.StringMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Component("ChusanGetGameMapAreaConditionHandler")
|
||||
public class GetGameMapAreaConditionHandler implements BaseHandler {
|
||||
private static final Logger logger = LoggerFactory.getLogger(GetGameMapAreaConditionHandler.class);
|
||||
|
||||
private final StringMapper mapper;
|
||||
|
||||
@Autowired
|
||||
public GetGameMapAreaConditionHandler(StringMapper mapper) {
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
||||
logger.info("MapAreaCondition Dummy Handler");
|
||||
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||
resultMap.put("mapAreaConditionList", new LinkedHashMap<>());
|
||||
|
||||
String json = mapper.write(resultMap);
|
||||
logger.info("Response: " + json);
|
||||
return json;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package icu.samnyan.aqua.sega.chusan.handler
|
||||
|
||||
import ext.logger
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler
|
||||
import icu.samnyan.aqua.sega.util.jackson.StringMapper
|
||||
import org.springframework.stereotype.Component
|
||||
|
||||
@Component("ChusanGetGameMapAreaConditionHandler")
|
||||
class GetGameMapAreaConditionHandler(val mapper: StringMapper) : BaseHandler {
|
||||
override fun handle(request: Map<String, Any>): String {
|
||||
val cond = listOf(
|
||||
mapOf("mapAreaId" to 2206201, "mapAreaConditionList" to listOf(
|
||||
mapOf("type" to 3, "conditionId" to 6832, "logicalOpe" to 1)
|
||||
)),
|
||||
mapOf("mapAreaId" to 2206203, "mapAreaConditionList" to listOf(
|
||||
mapOf("type" to 3, "conditionId" to 6833, "logicalOpe" to 1)
|
||||
)),
|
||||
mapOf("mapAreaId" to 2206204, "mapAreaConditionList" to listOf(
|
||||
mapOf("type" to 3, "conditionId" to 6834, "logicalOpe" to 1),
|
||||
mapOf("type" to 3, "conditionId" to 6835, "logicalOpe" to 1)
|
||||
)),
|
||||
mapOf("mapAreaId" to 2206205, "mapAreaConditionList" to listOf(
|
||||
mapOf("type" to 3, "conditionId" to 6837, "logicalOpe" to 1)
|
||||
)),
|
||||
mapOf("mapAreaId" to 2206206, "mapAreaConditionList" to listOf(
|
||||
mapOf("type" to 3, "conditionId" to 6838, "logicalOpe" to 1)
|
||||
)),
|
||||
mapOf("mapAreaId" to 2206207, "mapAreaConditionList" to listOf(
|
||||
mapOf("type" to 2, "conditionId" to 2206201, "logicalOpe" to 1),
|
||||
mapOf("type" to 2, "conditionId" to 2206202, "logicalOpe" to 1),
|
||||
mapOf("type" to 2, "conditionId" to 2206203, "logicalOpe" to 1),
|
||||
mapOf("type" to 2, "conditionId" to 2206204, "logicalOpe" to 1),
|
||||
mapOf("type" to 2, "conditionId" to 2206205, "logicalOpe" to 1),
|
||||
mapOf("type" to 2, "conditionId" to 2206206, "logicalOpe" to 1)
|
||||
)),
|
||||
mapOf("mapAreaId" to 3229301, "mapAreaConditionList" to listOf(
|
||||
mapOf("type" to 1, "conditionId" to 3020701, "logicalOpe" to 2)
|
||||
)),
|
||||
mapOf("mapAreaId" to 3229302, "mapAreaConditionList" to listOf(
|
||||
mapOf("type" to 1, "conditionId" to 3020701, "logicalOpe" to 1)
|
||||
))
|
||||
)
|
||||
|
||||
val resultMap: MutableMap<String, Any> = linkedMapOf(
|
||||
"gameMapAreaConditionList" to cond
|
||||
)
|
||||
|
||||
val json = mapper.write(resultMap)
|
||||
logger.info("Response: $json")
|
||||
return json
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val logger = logger()
|
||||
}
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
package icu.samnyan.aqua.sega.chusan.handler;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler;
|
||||
import icu.samnyan.aqua.sega.chusan.model.userdata.UserMap;
|
||||
import icu.samnyan.aqua.sega.chusan.service.UserMapAreaService;
|
||||
import icu.samnyan.aqua.sega.util.jackson.StringMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Handle GetUserMap request
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component("ChusanGetUserMapAreaHandler")
|
||||
public class GetUserMapAreaHandler implements BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GetUserMapAreaHandler.class);
|
||||
|
||||
private final StringMapper mapper;
|
||||
|
||||
private final UserMapAreaService userMapAreaService;
|
||||
|
||||
@Autowired
|
||||
public GetUserMapAreaHandler(StringMapper mapper, UserMapAreaService userMapService) {
|
||||
this.mapper = mapper;
|
||||
this.userMapAreaService = userMapService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
||||
String userId = (String) request.get("userId");
|
||||
|
||||
List<UserMap> userMapAreaList = userMapAreaService.getByUserId(userId);
|
||||
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||
resultMap.put("userId", userId);
|
||||
resultMap.put("length", userMapAreaList.size());
|
||||
resultMap.put("userMapAreaList", userMapAreaList);
|
||||
|
||||
String json = mapper.write(resultMap);
|
||||
logger.info("Response: " + json);
|
||||
return json;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package icu.samnyan.aqua.sega.chusan.handler
|
||||
|
||||
import ext.logger
|
||||
import icu.samnyan.aqua.sega.chusan.model.Chu3UserMapRepo
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler
|
||||
import icu.samnyan.aqua.sega.util.jackson.StringMapper
|
||||
import org.springframework.stereotype.Component
|
||||
|
||||
/**
|
||||
* Handle GetUserMap request
|
||||
* @author samnyan (privateamusement@protonmail.com)
|
||||
*/
|
||||
@Component("ChusanGetUserMapAreaHandler")
|
||||
class GetUserMapAreaHandler(
|
||||
private val mapper: StringMapper,
|
||||
private val userMapRepo: Chu3UserMapRepo
|
||||
) : BaseHandler {
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun handle(request: Map<String, Any>): String {
|
||||
val userId = request["userId"] as String?
|
||||
val maps = (request["mapAreaIdList"] as List<Map<String, String>>)
|
||||
.mapNotNull { it["mapAreaId"]?.toIntOrNull() }
|
||||
|
||||
val resultMap = mapOf(
|
||||
"userId" to userId,
|
||||
"userMapAreaList" to userMapRepo.findAllUserMaps(userId?.toLong() ?: return "{}", maps)
|
||||
)
|
||||
|
||||
val json = mapper.write(resultMap)
|
||||
logger.info("Response: $json")
|
||||
return json
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val logger = logger()
|
||||
}
|
||||
}
|
|
@ -92,6 +92,9 @@ interface Chu3UserItemRepo : Chu3UserLinked<UserItem> {
|
|||
|
||||
interface Chu3UserMapRepo : Chu3UserLinked<UserMap> {
|
||||
fun findTopByUserAndMapAreaIdOrderByIdDesc(user: Chu3UserData, mapAreaId: Int): Optional<UserMap>
|
||||
|
||||
@Query("SELECT uma FROM ChusanUserMapArea uma WHERE uma.user.card.extId = :extId AND uma.mapAreaId IN :mapAreaIds")
|
||||
fun findAllUserMaps(extId: Long, mapAreaIds: List<Int>): List<UserMap>
|
||||
}
|
||||
|
||||
interface Chu3UserMusicDetailRepo : Chu3UserLinked<UserMusicDetail> {
|
||||
|
|
Loading…
Reference in New Issue