mirror of https://github.com/hykilpikonna/AquaDX
[+] Team name
parent
19ac32d328
commit
6fa052bfcf
|
@ -33,7 +33,7 @@ class AquaGameOptions(
|
|||
var waccaAlwaysVip: Boolean = false,
|
||||
|
||||
@SettingField("general")
|
||||
var chuniTeamName: String = "",
|
||||
var chusanTeamName: String = "",
|
||||
)
|
||||
|
||||
interface AquaGameOptionsRepo : JpaRepository<AquaGameOptions, Long>
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package icu.samnyan.aqua.sega.chusan
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties
|
||||
import org.springframework.context.annotation.Configuration
|
||||
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "game.chusan")
|
||||
class ChusanProps {
|
||||
var teamName: String? = null
|
||||
}
|
|
@ -18,6 +18,7 @@ import icu.samnyan.aqua.spring.Metrics
|
|||
import jakarta.servlet.http.HttpServletRequest
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
import java.nio.charset.StandardCharsets
|
||||
import java.time.LocalDateTime
|
||||
import java.time.format.DateTimeFormatter
|
||||
import kotlin.collections.set
|
||||
|
@ -34,7 +35,6 @@ class ChusanServletController(
|
|||
val getUserLoginBonus: GetUserLoginBonusHandler,
|
||||
val getUserMusic: GetUserMusicHandler,
|
||||
val getUserRecentRating: GetUserRecentRatingHandler,
|
||||
val getUserTeam: GetUserTeamHandler,
|
||||
val upsertUserAll: UpsertUserAllHandler,
|
||||
val cmGetUserPreview: CMGetUserPreviewHandler,
|
||||
val cmGetUserData: CMGetUserDataHandler,
|
||||
|
@ -48,6 +48,7 @@ class ChusanServletController(
|
|||
val db: Chu3Repos,
|
||||
val us: AquaUserServices,
|
||||
val versionHelper: ChusanVersionHelper,
|
||||
val props: ChusanProps
|
||||
) {
|
||||
val logger = LoggerFactory.getLogger(ChusanServletController::class.java)
|
||||
|
||||
|
@ -287,6 +288,18 @@ fun ChusanServletController.init() {
|
|||
mapOf("userId" to uid, "userMapAreaList" to db.userMap.findAllByUserCardExtIdAndMapAreaIdIn(uid, maps))
|
||||
}
|
||||
|
||||
"GetUserTeam" {
|
||||
val playDate = parsing { data["playDate"] as String }
|
||||
val team = db.userData.findByCard_ExtId(uid)()?.card?.aquaUser?.gameOptions?.chusanTeamName
|
||||
?: props.teamName ?: "一緒に歌おう!"
|
||||
val teamStr = String(team.toByteArray(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8)
|
||||
|
||||
mapOf(
|
||||
"userId" to uid, "teamId" to 1, "teamRank" to 1, "teamName" to teamStr,
|
||||
"userTeamPoint" to mapOf("userId" to uid, "teamId" to 1, "orderId" to 1, "teamPoint" to 1, "aggrDate" to playDate)
|
||||
)
|
||||
}
|
||||
|
||||
// Game settings
|
||||
"GetGameSetting" {
|
||||
val version = data["version"].toString()
|
||||
|
|
|
@ -1,60 +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.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Component("ChusanGetUserTeamHandler")
|
||||
public class GetUserTeamHandler implements BaseHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GetUserTeamHandler.class);
|
||||
|
||||
private final StringMapper mapper;
|
||||
|
||||
private final String teamName;
|
||||
|
||||
|
||||
public GetUserTeamHandler(StringMapper mapper, @Value("${game.chusan.team-name:#{null}}") String teamName) {
|
||||
this.mapper = mapper;
|
||||
// Decode team name because Java assumes application.properties as ISO-8859-1
|
||||
this.teamName = new String(teamName.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(Map<String, ?> request) throws JsonProcessingException {
|
||||
String userId = (String) request.get("userId");
|
||||
String playDate = (String) request.get("playDate");
|
||||
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||
resultMap.put("userId", userId);
|
||||
|
||||
if (teamName != null && !teamName.isEmpty()) {
|
||||
resultMap.put("teamId", 1);
|
||||
resultMap.put("teamRank", 1);
|
||||
resultMap.put("teamName", teamName);
|
||||
|
||||
Map<String, Object> userTeamMap = new LinkedHashMap<>();
|
||||
userTeamMap.put("userId", userId);
|
||||
userTeamMap.put("teamId", 1);
|
||||
userTeamMap.put("orderId", 1);
|
||||
userTeamMap.put("teamPoint", 1);
|
||||
userTeamMap.put("aggrDate", playDate);
|
||||
|
||||
resultMap.put("userTeamPoint", userTeamMap);
|
||||
} else {
|
||||
resultMap.put("teamId", 0);
|
||||
}
|
||||
|
||||
String json = mapper.write(resultMap);
|
||||
logger.info("Response: " + json);
|
||||
return json;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue