mirror of https://github.com/hykilpikonna/AquaDX
[O] Rewrite GetUserLoginBonus
parent
ffcb94674e
commit
33aebc42b3
|
@ -7,4 +7,5 @@ import org.springframework.context.annotation.Configuration
|
||||||
@ConfigurationProperties(prefix = "game.chusan")
|
@ConfigurationProperties(prefix = "game.chusan")
|
||||||
class ChusanProps {
|
class ChusanProps {
|
||||||
var teamName: String? = null
|
var teamName: String? = null
|
||||||
|
var loginBonusEnable = false
|
||||||
}
|
}
|
|
@ -32,13 +32,10 @@ import kotlin.reflect.full.declaredMemberProperties
|
||||||
@API(value = ["/g/chu3/{version}/ChuniServlet", "/g/chu3/{version}"])
|
@API(value = ["/g/chu3/{version}/ChuniServlet", "/g/chu3/{version}"])
|
||||||
class ChusanServletController(
|
class ChusanServletController(
|
||||||
val gameLogin: GameLoginHandler,
|
val gameLogin: GameLoginHandler,
|
||||||
val getUserLoginBonus: GetUserLoginBonusHandler,
|
|
||||||
val getUserMusic: GetUserMusicHandler,
|
val getUserMusic: GetUserMusicHandler,
|
||||||
val getUserRecentRating: GetUserRecentRatingHandler,
|
val getUserRecentRating: GetUserRecentRatingHandler,
|
||||||
val upsertUserAll: UpsertUserAllHandler,
|
val upsertUserAll: UpsertUserAllHandler,
|
||||||
val cmGetUserPreview: CMGetUserPreviewHandler,
|
|
||||||
val cmGetUserCharacter: CMGetUserCharacterHandler,
|
val cmGetUserCharacter: CMGetUserCharacterHandler,
|
||||||
val cmGetUserItem: CMGetUserItemHandler,
|
|
||||||
val cmUpsertUserGacha: CMUpsertUserGachaHandler,
|
val cmUpsertUserGacha: CMUpsertUserGachaHandler,
|
||||||
val cmUpsertUserPrintSubtract: CMUpsertUserPrintSubtractHandler,
|
val cmUpsertUserPrintSubtract: CMUpsertUserPrintSubtractHandler,
|
||||||
val cmUpsertUserPrintCancel: CMUpsertUserPrintCancelHandler,
|
val cmUpsertUserPrintCancel: CMUpsertUserPrintCancelHandler,
|
||||||
|
@ -53,7 +50,7 @@ class ChusanServletController(
|
||||||
|
|
||||||
// Below are code related to handling the handlers
|
// Below are code related to handling the handlers
|
||||||
val externalHandlers = mutableListOf(
|
val externalHandlers = mutableListOf(
|
||||||
"GameLoginApi", "GetUserLoginBonusApi", "GetUserMusicApi", "GetUserRecentRatingApi", "UpsertUserAllApi",
|
"GameLoginApi", "GetUserMusicApi", "GetUserRecentRatingApi", "UpsertUserAllApi",
|
||||||
"CMGetUserCharacterApi", "CMUpsertUserGachaApi",
|
"CMGetUserCharacterApi", "CMUpsertUserGachaApi",
|
||||||
"CMUpsertUserPrintCancelApi", "CMUpsertUserPrintSubtractApi")
|
"CMUpsertUserPrintCancelApi", "CMUpsertUserPrintSubtractApi")
|
||||||
|
|
||||||
|
@ -265,6 +262,13 @@ fun ChusanServletController.init() {
|
||||||
) + userDict
|
) + userDict
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"GetUserLoginBonus" api@ {
|
||||||
|
if (!props.loginBonusEnable) return@api mapOf("userId" to uid, "length" to 0, "userLoginBonusList" to empty)
|
||||||
|
|
||||||
|
val lst = db.userLoginBonus.findAllLoginBonus(uid.int, 1, 0)
|
||||||
|
mapOf("userId" to uid, "length" to lst.size, "userLoginBonusList" to lst)
|
||||||
|
}
|
||||||
|
|
||||||
"GetUserMapArea" {
|
"GetUserMapArea" {
|
||||||
val maps = parsing { data["mapAreaIdList"] as List<Map<String, String>> }
|
val maps = parsing { data["mapAreaIdList"] as List<Map<String, String>> }
|
||||||
.mapNotNull { it["mapAreaId"]?.toIntOrNull() }
|
.mapNotNull { it["mapAreaId"]?.toIntOrNull() }
|
||||||
|
|
|
@ -1,69 +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.UserLoginBonus;
|
|
||||||
import icu.samnyan.aqua.sega.chusan.service.UserDataService;
|
|
||||||
import icu.samnyan.aqua.sega.chusan.service.UserLoginBonusService;
|
|
||||||
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.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
@Component("ChusanGetUserLoginBonusHandler")
|
|
||||||
public class GetUserLoginBonusHandler implements BaseHandler {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(GetUserLoginBonusHandler.class);
|
|
||||||
|
|
||||||
private final StringMapper mapper;
|
|
||||||
|
|
||||||
private boolean enableLoginBonus = false;
|
|
||||||
|
|
||||||
private final UserDataService userDataService;
|
|
||||||
|
|
||||||
private final UserLoginBonusService userLoginBonusService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public GetUserLoginBonusHandler(StringMapper mapper,
|
|
||||||
@Value("${game.chusan.loginbonus-enable:}") boolean enableLoginBonus,
|
|
||||||
UserDataService userDataService,
|
|
||||||
UserLoginBonusService userLoginBonusService) {
|
|
||||||
this.mapper = mapper;
|
|
||||||
this.enableLoginBonus = enableLoginBonus;
|
|
||||||
this.userLoginBonusService = userLoginBonusService;
|
|
||||||
this.userDataService = userDataService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String handle(Map<String, ?> request) throws JsonProcessingException {
|
|
||||||
String userId = (String) request.get("userId");
|
|
||||||
|
|
||||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
|
||||||
resultMap.put("userId", userId);
|
|
||||||
if(!this.enableLoginBonus){
|
|
||||||
resultMap.put("length", 0);
|
|
||||||
resultMap.put("userLoginBonusList", List.of());
|
|
||||||
}else{
|
|
||||||
List<UserLoginBonus> userLoginBonusList = userLoginBonusService.getAllUserLoginBonus(Integer.parseInt(userId));
|
|
||||||
List<Map<String, String>> retList = new ArrayList<>();
|
|
||||||
resultMap.put("length", userLoginBonusList.size());
|
|
||||||
for (UserLoginBonus u: userLoginBonusList) {
|
|
||||||
Map<String, String> appendInfo = new HashMap<>();
|
|
||||||
appendInfo.put("presetId", String.valueOf(u.getPresetId()));
|
|
||||||
appendInfo.put("bonusCount", String.valueOf(u.getBonusCount()));
|
|
||||||
appendInfo.put("lastUpdateDate", u.getLastUpdateDate().toString());
|
|
||||||
appendInfo.put("isWatched", String.valueOf(u.isWatched()));
|
|
||||||
retList.add(appendInfo);
|
|
||||||
}
|
|
||||||
resultMap.put("userLoginBonusList", retList);
|
|
||||||
}
|
|
||||||
|
|
||||||
String json = mapper.write(resultMap);
|
|
||||||
logger.info("Response: " + json);
|
|
||||||
return json;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue