mirror of https://github.com/hykilpikonna/AquaDX
[chusan] Add login bonus feature
parent
3f05b84c0f
commit
b858d9a2cd
|
@ -43,6 +43,8 @@ game.chusan.version=2.00.00
|
||||||
game.chusan.rom-version=2.00.01
|
game.chusan.rom-version=2.00.01
|
||||||
## This enables team function if you set team name here. Leave this blank to disable it.
|
## This enables team function if you set team name here. Leave this blank to disable it.
|
||||||
game.chusan.team-name=
|
game.chusan.team-name=
|
||||||
|
## This enables user use login bonus function if set to true.
|
||||||
|
game.chusan.loginbonus-enable=true
|
||||||
|
|
||||||
## Ongeki
|
## Ongeki
|
||||||
## The version of your client. Match this with DataConfig.xml file in latest option. (only if bright memory and up)
|
## The version of your client. Match this with DataConfig.xml file in latest option. (only if bright memory and up)
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
package icu.samnyan.aqua.sega.chusan.dao.gamedata;
|
||||||
|
|
||||||
|
import icu.samnyan.aqua.sega.chusan.model.gamedata.GameLoginBonusPreset;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface GameLoginBonusPresetsRepository extends JpaRepository<GameLoginBonusPreset, Integer> {
|
||||||
|
@Query(value = "select * from chusan_game_login_bonus_preset where version = ?1 and is_enabled = ?2", nativeQuery = true)
|
||||||
|
List<GameLoginBonusPreset> findLoginBonusPresets(int version, int isEnabled);
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package icu.samnyan.aqua.sega.chusan.dao.gamedata;
|
||||||
|
|
||||||
|
import icu.samnyan.aqua.sega.chusan.model.gamedata.GameLoginBonus;
|
||||||
|
import icu.samnyan.aqua.sega.chusan.model.gamedata.GameLoginBonusPreset;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public interface GameLoginBonusRepository extends JpaRepository<GameLoginBonus, Integer> {
|
||||||
|
@Query(value = "select * from chusan_game_login_bonus where version = ?1 and preset_id = ?2 order by need_login_day_count desc", nativeQuery = true)
|
||||||
|
List<GameLoginBonus> findGameLoginBonus(int version, int presetId);
|
||||||
|
|
||||||
|
@Query(value = "select * from chusan_game_login_bonus where version = ?1 and preset_id = ?2 and need_login_day_count = ?3 limit 1", nativeQuery = true)
|
||||||
|
Optional<GameLoginBonus> findByRequiredDays(int version, int presetId, int requiredDays);
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package icu.samnyan.aqua.sega.chusan.dao.userdata;
|
||||||
|
|
||||||
|
import icu.samnyan.aqua.sega.chusan.model.userdata.UserLoginBonus;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public interface ChusanUserLoginBonusRepository extends JpaRepository<UserLoginBonus, Integer>{
|
||||||
|
@Query(value = "select * from chusan_user_login_bonus where user = ?1 and version = ?2 and is_finished = ?3 order by last_update_date desc", nativeQuery = true)
|
||||||
|
List<UserLoginBonus> findAllLoginBonus(int user_id, int version, int is_finished);
|
||||||
|
|
||||||
|
@Query(value = "select * from chusan_user_login_bonus where user = ?1 and version = ?2 and preset_id = ?3 limit 1", nativeQuery = true)
|
||||||
|
Optional<UserLoginBonus> findLoginBonus(int user_id, int version, int preset_id);
|
||||||
|
}
|
|
@ -2,14 +2,26 @@ package icu.samnyan.aqua.sega.chusan.handler.impl;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import icu.samnyan.aqua.sega.chusan.handler.BaseHandler;
|
import icu.samnyan.aqua.sega.chusan.handler.BaseHandler;
|
||||||
|
import icu.samnyan.aqua.sega.chusan.model.gamedata.GameLoginBonus;
|
||||||
|
import icu.samnyan.aqua.sega.chusan.model.gamedata.GameLoginBonusPreset;
|
||||||
import icu.samnyan.aqua.sega.chusan.model.response.CodeResp;
|
import icu.samnyan.aqua.sega.chusan.model.response.CodeResp;
|
||||||
import icu.samnyan.aqua.sega.chusan.model.userdata.UserData;
|
import icu.samnyan.aqua.sega.chusan.model.userdata.UserData;
|
||||||
|
import icu.samnyan.aqua.sega.chusan.model.userdata.UserItem;
|
||||||
|
import icu.samnyan.aqua.sega.chusan.model.userdata.UserLoginBonus;
|
||||||
|
import icu.samnyan.aqua.sega.chusan.service.GameLoginBonusPresetService;
|
||||||
|
import icu.samnyan.aqua.sega.chusan.service.GameLoginBonusService;
|
||||||
import icu.samnyan.aqua.sega.chusan.service.UserDataService;
|
import icu.samnyan.aqua.sega.chusan.service.UserDataService;
|
||||||
|
import icu.samnyan.aqua.sega.chusan.service.UserItemService;
|
||||||
|
import icu.samnyan.aqua.sega.chusan.service.UserLoginBonusService;
|
||||||
import icu.samnyan.aqua.sega.util.jackson.StringMapper;
|
import icu.samnyan.aqua.sega.util.jackson.StringMapper;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.ZoneOffset;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@ -23,18 +35,112 @@ public class GameLoginHandler implements BaseHandler {
|
||||||
|
|
||||||
private final StringMapper mapper;
|
private final StringMapper mapper;
|
||||||
|
|
||||||
|
private boolean enableLoginBonus = false;
|
||||||
|
|
||||||
private final UserDataService userDataService;
|
private final UserDataService userDataService;
|
||||||
|
|
||||||
public GameLoginHandler(StringMapper mapper, UserDataService userDataService) {
|
private final UserItemService userItemService;
|
||||||
|
|
||||||
|
private final GameLoginBonusPresetService gameLoginBonusPresetService;
|
||||||
|
|
||||||
|
private final GameLoginBonusService gameLoginBonusService;
|
||||||
|
|
||||||
|
private final UserLoginBonusService userLoginBonusService;
|
||||||
|
|
||||||
|
public GameLoginHandler(StringMapper mapper,
|
||||||
|
@Value("${game.chusan.loginbonus-enable:}") boolean enableLoginBonus,
|
||||||
|
UserDataService userDataService,
|
||||||
|
UserItemService userItemService,
|
||||||
|
GameLoginBonusPresetService gameLoginBonusPresetService,
|
||||||
|
GameLoginBonusService gameLoginBonusService,
|
||||||
|
UserLoginBonusService userLoginBonusService
|
||||||
|
) {
|
||||||
this.mapper = mapper;
|
this.mapper = mapper;
|
||||||
|
this.enableLoginBonus = enableLoginBonus;
|
||||||
this.userDataService = userDataService;
|
this.userDataService = userDataService;
|
||||||
|
this.userItemService = userItemService;
|
||||||
|
this.gameLoginBonusPresetService = gameLoginBonusPresetService;
|
||||||
|
this.gameLoginBonusService = gameLoginBonusService;
|
||||||
|
this.userLoginBonusService = userLoginBonusService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
public String handle(Map<String, Object> request) throws JsonProcessingException {
|
||||||
String userId = (String) request.get("userId");
|
String userId = (String) request.get("userId");
|
||||||
Optional<UserData> userDataOptional = userDataService.getUserByExtId(userId);
|
Optional<UserData> userDataOptional = userDataService.getUserByExtId(userId);
|
||||||
userDataOptional.ifPresent(userDataService::updateLoginTime);
|
boolean userPresent = userDataOptional.isPresent();
|
||||||
|
if (userPresent){
|
||||||
|
userDataService.updateLoginTime(userDataOptional.get());
|
||||||
|
if(this.enableLoginBonus){
|
||||||
|
List<GameLoginBonusPreset> gameLoginBonusList = this.gameLoginBonusPresetService.getGameLoginBonusPresets(1);
|
||||||
|
|
||||||
|
for (GameLoginBonusPreset preset: gameLoginBonusList) {
|
||||||
|
// check if a user already has some progress and if not, add the login bonus entry
|
||||||
|
Optional<UserLoginBonus> userLoginBonus = userLoginBonusService.getUserLoginBonus(Integer.parseInt(userId), preset.getId());
|
||||||
|
if (userLoginBonus.isEmpty()){
|
||||||
|
UserLoginBonus u = new UserLoginBonus(1, Integer.parseInt(userId), preset.getId());
|
||||||
|
userLoginBonusService.saveUserLoginBonus(u);
|
||||||
|
userLoginBonus = userLoginBonusService.getUserLoginBonus(Integer.parseInt(userId), preset.getId());
|
||||||
|
}
|
||||||
|
UserLoginBonus userLoginBonusResult = userLoginBonus.get();
|
||||||
|
if (userLoginBonusResult.isFinished()){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// last login is 24 hours+ ago
|
||||||
|
if (userLoginBonusResult.getLastUpdateDate().toEpochSecond(ZoneOffset.ofHours(0)) < (LocalDateTime.now().minusHours(24).toEpochSecond(ZoneOffset.ofHours(0)))){
|
||||||
|
int bonusCount = userLoginBonusResult.getBonusCount() + 1;
|
||||||
|
LocalDateTime lastUpdateDate = LocalDateTime.now();
|
||||||
|
List<GameLoginBonus> allLoginBonus = gameLoginBonusService.getAllGameLoginBonus(preset.getId());
|
||||||
|
if (allLoginBonus.size() == 0){
|
||||||
|
logger.info("No bonus entry found for" + preset.getId());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
int maxNeededDays = allLoginBonus.get(0).getNeedLoginDayCount();
|
||||||
|
|
||||||
|
// if all items are redeemed, then don't show the login bonuses.
|
||||||
|
boolean isFinished = false;
|
||||||
|
if (bonusCount > maxNeededDays){
|
||||||
|
if (preset.getId() < 3000){
|
||||||
|
bonusCount = 1;
|
||||||
|
}else{
|
||||||
|
isFinished = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Optional<GameLoginBonus> gameLoginBonus = this.gameLoginBonusService.getGameLoginBonusByDay(preset.getId(), bonusCount);
|
||||||
|
if(gameLoginBonus.isPresent()){
|
||||||
|
GameLoginBonus gameLoginBonusResult = gameLoginBonus.get();
|
||||||
|
UserData userData = this.userDataService.getUserByExtId(userId).orElseThrow();
|
||||||
|
UserItem userItem = new UserItem(userData);
|
||||||
|
userItem.setItemId(gameLoginBonusResult.getPresentId());
|
||||||
|
userItem.setItemKind(6);
|
||||||
|
userItem.setStock(gameLoginBonusResult.getItemNum());
|
||||||
|
userItem.setValid(true);
|
||||||
|
this.userItemService.save(userItem);
|
||||||
|
}
|
||||||
|
Optional<UserLoginBonus> userLoginBonusOptional = this.userLoginBonusService.getUserLoginBonus(Integer.parseInt(userId), preset.getId());
|
||||||
|
UserLoginBonus userLoginBonusSave;
|
||||||
|
if(userLoginBonusOptional.isPresent()){
|
||||||
|
userLoginBonusSave = userLoginBonusOptional.get();
|
||||||
|
userLoginBonusSave.setBonusCount(bonusCount);
|
||||||
|
userLoginBonusSave.setLastUpdateDate(lastUpdateDate);
|
||||||
|
userLoginBonusSave.setWatched(false);
|
||||||
|
userLoginBonusSave.setFinished(isFinished);
|
||||||
|
}else{
|
||||||
|
userLoginBonusSave = new UserLoginBonus();
|
||||||
|
userLoginBonusSave.setUser(Integer.parseInt(userId));
|
||||||
|
userLoginBonusSave.setPresetId(preset.getId());
|
||||||
|
userLoginBonusSave.setVersion(1);
|
||||||
|
userLoginBonusSave.setBonusCount(bonusCount);
|
||||||
|
userLoginBonusSave.setLastUpdateDate(lastUpdateDate);
|
||||||
|
userLoginBonusSave.setWatched(false);
|
||||||
|
userLoginBonusSave.setFinished(isFinished);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.userLoginBonusService.saveUserLoginBonus(userLoginBonusSave);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
String json = mapper.write(new CodeResp(1));
|
String json = mapper.write(new CodeResp(1));
|
||||||
logger.info("Response: " + json);
|
logger.info("Response: " + json);
|
||||||
|
|
|
@ -2,15 +2,23 @@ package icu.samnyan.aqua.sega.chusan.handler.impl;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import icu.samnyan.aqua.sega.chusan.handler.BaseHandler;
|
import icu.samnyan.aqua.sega.chusan.handler.BaseHandler;
|
||||||
|
import icu.samnyan.aqua.sega.chusan.model.userdata.UserLoginBonus;
|
||||||
|
import icu.samnyan.aqua.sega.chusan.model.userdata.UserData;
|
||||||
|
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 icu.samnyan.aqua.sega.util.jackson.StringMapper;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
@Component("ChusanGetUserLoginBonusHandler")
|
@Component("ChusanGetUserLoginBonusHandler")
|
||||||
public class GetUserLoginBonusHandler implements BaseHandler {
|
public class GetUserLoginBonusHandler implements BaseHandler {
|
||||||
|
@ -19,9 +27,21 @@ public class GetUserLoginBonusHandler implements BaseHandler {
|
||||||
|
|
||||||
private final StringMapper mapper;
|
private final StringMapper mapper;
|
||||||
|
|
||||||
|
private boolean enableLoginBonus = false;
|
||||||
|
|
||||||
|
private final UserDataService userDataService;
|
||||||
|
|
||||||
|
private final UserLoginBonusService userLoginBonusService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public GetUserLoginBonusHandler(StringMapper mapper) {
|
public GetUserLoginBonusHandler(StringMapper mapper,
|
||||||
|
@Value("${game.chusan.loginbonus-enable:}") boolean enableLoginBonus,
|
||||||
|
UserDataService userDataService,
|
||||||
|
UserLoginBonusService userLoginBonusService) {
|
||||||
this.mapper = mapper;
|
this.mapper = mapper;
|
||||||
|
this.enableLoginBonus = enableLoginBonus;
|
||||||
|
this.userLoginBonusService = userLoginBonusService;
|
||||||
|
this.userDataService = userDataService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -30,8 +50,23 @@ public class GetUserLoginBonusHandler implements BaseHandler {
|
||||||
|
|
||||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||||
resultMap.put("userId", userId);
|
resultMap.put("userId", userId);
|
||||||
resultMap.put("length", 0);
|
if(!this.enableLoginBonus){
|
||||||
resultMap.put("userLoginBonusList", List.of());
|
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);
|
String json = mapper.write(resultMap);
|
||||||
logger.info("Response: " + json);
|
logger.info("Response: " + json);
|
||||||
|
|
|
@ -16,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,9 +45,24 @@ public class UpsertUserAllHandler implements BaseHandler {
|
||||||
private final UserCourseService userCourseService;
|
private final UserCourseService userCourseService;
|
||||||
private final UserDuelService userDuelService;
|
private final UserDuelService userDuelService;
|
||||||
private final UserGeneralDataService userGeneralDataService;
|
private final UserGeneralDataService userGeneralDataService;
|
||||||
|
private final UserLoginBonusService userLoginBonusService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public UpsertUserAllHandler(StringMapper mapper, CardService cardService, UserDataService userDataService, UserCharacterService userCharacterService, UserGameOptionService userGameOptionService, UserMapAreaService userMapService, UserItemService userItemService, UserMusicDetailService userMusicDetailService, UserActivityService userActivityService, UserPlaylogService userPlaylogService, UserChargeService userChargeService, UserCourseService userCourseService, UserDuelService userDuelService, UserGeneralDataService userGeneralDataService) {
|
public UpsertUserAllHandler(StringMapper mapper,
|
||||||
|
CardService cardService,
|
||||||
|
UserDataService userDataService,
|
||||||
|
UserCharacterService userCharacterService,
|
||||||
|
UserGameOptionService userGameOptionService,
|
||||||
|
UserMapAreaService userMapService,
|
||||||
|
UserItemService userItemService,
|
||||||
|
UserMusicDetailService userMusicDetailService,
|
||||||
|
UserActivityService userActivityService,
|
||||||
|
UserPlaylogService userPlaylogService,
|
||||||
|
UserChargeService userChargeService,
|
||||||
|
UserCourseService userCourseService,
|
||||||
|
UserDuelService userDuelService,
|
||||||
|
UserGeneralDataService userGeneralDataService,
|
||||||
|
UserLoginBonusService userLoginBonusService) {
|
||||||
this.mapper = mapper;
|
this.mapper = mapper;
|
||||||
this.cardService = cardService;
|
this.cardService = cardService;
|
||||||
this.userDataService = userDataService;
|
this.userDataService = userDataService;
|
||||||
|
@ -61,6 +77,7 @@ public class UpsertUserAllHandler implements BaseHandler {
|
||||||
this.userCourseService = userCourseService;
|
this.userCourseService = userCourseService;
|
||||||
this.userDuelService = userDuelService;
|
this.userDuelService = userDuelService;
|
||||||
this.userGeneralDataService = userGeneralDataService;
|
this.userGeneralDataService = userGeneralDataService;
|
||||||
|
this.userLoginBonusService = userLoginBonusService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -304,6 +321,21 @@ public class UpsertUserAllHandler implements BaseHandler {
|
||||||
userDuelService.saveAll(newUserDuelMap.values());
|
userDuelService.saveAll(newUserDuelMap.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (upsertUserAll.getUserLoginBonusList() != null){
|
||||||
|
List<Map<String, Object>> userLoginBonusList = upsertUserAll.getUserLoginBonusList();
|
||||||
|
Map<Integer, UserLoginBonus> newUserLoginBonusMap = new HashMap<>();
|
||||||
|
|
||||||
|
userLoginBonusList.forEach(newUserLoginBonus -> {
|
||||||
|
int loginBonusPresetId = Integer.parseInt((String) newUserLoginBonus.get("presetId"));
|
||||||
|
Optional<UserLoginBonus> userLoginBonusOptional = userLoginBonusService.getUserLoginBonus(Integer.parseInt(userId), loginBonusPresetId);
|
||||||
|
UserLoginBonus userLoginBonus = userLoginBonusOptional.orElseGet(UserLoginBonus::new);
|
||||||
|
userLoginBonus.setLastUpdateDate(LocalDateTime.now());
|
||||||
|
userLoginBonus.setWatched(true);
|
||||||
|
newUserLoginBonusMap.put(loginBonusPresetId, userLoginBonus);
|
||||||
|
});
|
||||||
|
userLoginBonusService.saveAll(newUserLoginBonusMap.values());
|
||||||
|
}
|
||||||
|
|
||||||
String json = mapper.write(new CodeResp(1));
|
String json = mapper.write(new CodeResp(1));
|
||||||
logger.info("Response: " + json);
|
logger.info("Response: " + json);
|
||||||
return json;
|
return json;
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
package icu.samnyan.aqua.sega.chusan.model.gamedata;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@Entity(name = "ChusanGameLoginBonus")
|
||||||
|
@Table(name = "chusan_game_login_bonus")
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class GameLoginBonus implements Serializable {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
@JsonIgnore
|
||||||
|
private int id;
|
||||||
|
private int version;
|
||||||
|
private int presetId;
|
||||||
|
private int loginBonusId;
|
||||||
|
private String loginBonusName;
|
||||||
|
private int presentId;
|
||||||
|
private String presentName;
|
||||||
|
private int itemNum;
|
||||||
|
private int needLoginDayCount;
|
||||||
|
private int loginBonusCategoryType;
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package icu.samnyan.aqua.sega.chusan.model.gamedata;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@Entity(name = "ChusanGameLoginBonusPreset")
|
||||||
|
@Table(name = "chusan_game_login_bonus_preset")
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class GameLoginBonusPreset implements Serializable {
|
||||||
|
// No one cares about chuni lol
|
||||||
|
// Maimai and Ongeki all got their login bonus but nothing for chunithm
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
@JsonIgnore
|
||||||
|
private int id;
|
||||||
|
private int version;
|
||||||
|
private String presetName;
|
||||||
|
private boolean isEnabled;
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
package icu.samnyan.aqua.sega.chusan.model.userdata;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.sun.istack.NotNull;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Required;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Entity(name = "ChusanUserLoginBonus")
|
||||||
|
@Table(name = "chusan_user_login_bonus")
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class UserLoginBonus implements Serializable {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
@JsonIgnore
|
||||||
|
private int id;
|
||||||
|
private int version;
|
||||||
|
private int user;
|
||||||
|
private int presetId;
|
||||||
|
private int bonusCount;
|
||||||
|
private LocalDateTime lastUpdateDate;
|
||||||
|
private boolean isWatched;
|
||||||
|
private boolean isFinished;
|
||||||
|
|
||||||
|
public UserLoginBonus(int version, int user, int presetId) {
|
||||||
|
this.version = version;
|
||||||
|
this.user = user;
|
||||||
|
this.presetId = presetId;
|
||||||
|
this.bonusCount = 0;
|
||||||
|
this.lastUpdateDate = LocalDateTime.parse("2018-01-01T00:00:00");
|
||||||
|
this.isWatched = false;
|
||||||
|
this.isFinished = false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package icu.samnyan.aqua.sega.chusan.service;
|
||||||
|
|
||||||
|
import icu.samnyan.aqua.sega.chusan.dao.gamedata.GameLoginBonusPresetsRepository;
|
||||||
|
import icu.samnyan.aqua.sega.chusan.dao.gamedata.GameLoginBonusRepository;
|
||||||
|
import icu.samnyan.aqua.sega.chusan.model.gamedata.GameLoginBonusPreset;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service("ChusanGameLoginBonusPresetService")
|
||||||
|
public class GameLoginBonusPresetService {
|
||||||
|
private final GameLoginBonusPresetsRepository gameLoginBonusPresetsRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public GameLoginBonusPresetService(GameLoginBonusPresetsRepository gameLoginBonusPresetsRepository){
|
||||||
|
this.gameLoginBonusPresetsRepository = gameLoginBonusPresetsRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<GameLoginBonusPreset> getGameLoginBonusPresets(int version){
|
||||||
|
return this.gameLoginBonusPresetsRepository.findLoginBonusPresets(version, 1);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package icu.samnyan.aqua.sega.chusan.service;
|
||||||
|
|
||||||
|
|
||||||
|
import icu.samnyan.aqua.sega.chusan.dao.gamedata.GameLoginBonusRepository;
|
||||||
|
import icu.samnyan.aqua.sega.chusan.model.gamedata.GameLoginBonus;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Service("ChusanGameLoginBonusService")
|
||||||
|
public class GameLoginBonusService {
|
||||||
|
private final GameLoginBonusRepository gameLoginBonusRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public GameLoginBonusService(GameLoginBonusRepository gameLoginBonusRepository){
|
||||||
|
this.gameLoginBonusRepository = gameLoginBonusRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<GameLoginBonus> getAllGameLoginBonus(int presetId){
|
||||||
|
return this.gameLoginBonusRepository.findGameLoginBonus(1, presetId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<GameLoginBonus> getGameLoginBonusByDay(int presetId, int day){
|
||||||
|
return this.gameLoginBonusRepository.findByRequiredDays(1, presetId, day);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
package icu.samnyan.aqua.sega.chusan.service;
|
||||||
|
|
||||||
|
import icu.samnyan.aqua.sega.chusan.dao.userdata.ChusanUserLoginBonusRepository;
|
||||||
|
import icu.samnyan.aqua.sega.chusan.model.userdata.UserLoginBonus;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Service("ChusanUserLoginBonusService")
|
||||||
|
public class UserLoginBonusService {
|
||||||
|
private final ChusanUserLoginBonusRepository chusanUserLoginBonusRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public UserLoginBonusService(ChusanUserLoginBonusRepository chusanUserLoginBonusRepository){
|
||||||
|
this.chusanUserLoginBonusRepository = chusanUserLoginBonusRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<UserLoginBonus> getUserLoginBonus(int userId, int preset_id){
|
||||||
|
return this.chusanUserLoginBonusRepository.findLoginBonus(userId, 1, preset_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<UserLoginBonus> getAllUserLoginBonus(int userId){
|
||||||
|
return this.chusanUserLoginBonusRepository.findAllLoginBonus(userId, 1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveUserLoginBonus(UserLoginBonus userLoginBonus){
|
||||||
|
this.chusanUserLoginBonusRepository.save(userLoginBonus);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveAll(Iterable<UserLoginBonus> userLoginBonuses) {
|
||||||
|
this.chusanUserLoginBonusRepository.saveAll(userLoginBonuses);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
create table chusan_game_login_bonus
|
||||||
|
(
|
||||||
|
id bigint not null
|
||||||
|
primary key,
|
||||||
|
version int not null,
|
||||||
|
preset_id int not null,
|
||||||
|
login_bonus_id int not null,
|
||||||
|
login_bonus_name varchar(255) not null,
|
||||||
|
present_id int not null,
|
||||||
|
present_name varchar(255) not null,
|
||||||
|
item_num int not null,
|
||||||
|
need_login_day_count int not null,
|
||||||
|
login_bonus_category_type int not null
|
||||||
|
) ENGINE = InnoDB
|
||||||
|
DEFAULT CHARSET = utf8mb4
|
||||||
|
collate = utf8mb4_unicode_ci;
|
||||||
|
|
||||||
|
create table chusan_game_login_bonus_preset
|
||||||
|
(
|
||||||
|
id bigint not null
|
||||||
|
primary key,
|
||||||
|
version int not null,
|
||||||
|
preset_name varchar(255) not null,
|
||||||
|
is_enabled int default 1 not null
|
||||||
|
) ENGINE = InnoDB
|
||||||
|
DEFAULT CHARSET = utf8mb4
|
||||||
|
collate = utf8mb4_unicode_ci;
|
||||||
|
|
||||||
|
create table chusan_user_login_bonus
|
||||||
|
(
|
||||||
|
id bigint auto_increment primary key,
|
||||||
|
user bigint not null,
|
||||||
|
version int not null,
|
||||||
|
preset_id int not null,
|
||||||
|
bonus_count int default 0 not null,
|
||||||
|
last_update_date datetime default '2018-01-01 00:00:00' not null,
|
||||||
|
is_watched int default 0 not null,
|
||||||
|
is_finished int default 0 not null
|
||||||
|
) ENGINE = InnoDB
|
||||||
|
DEFAULT CHARSET = utf8mb4
|
||||||
|
collate = utf8mb4_unicode_ci;
|
|
@ -0,0 +1,41 @@
|
||||||
|
create table chusan_game_login_bonus
|
||||||
|
(
|
||||||
|
id bigint not null
|
||||||
|
primary key,
|
||||||
|
version int not null,
|
||||||
|
preset_id int not null,
|
||||||
|
login_bonus_id int not null,
|
||||||
|
login_bonus_name varchar(255) not null,
|
||||||
|
present_id int not null,
|
||||||
|
present_name varchar(255) not null,
|
||||||
|
item_num int not null,
|
||||||
|
need_login_day_count int not null,
|
||||||
|
login_bonus_category_type int not null
|
||||||
|
) ENGINE = InnoDB
|
||||||
|
DEFAULT CHARSET = utf8mb4
|
||||||
|
COLLATE = utf8mb4_unicode_ci;
|
||||||
|
|
||||||
|
create table chusan_game_login_bonus_preset
|
||||||
|
(
|
||||||
|
id bigint not null
|
||||||
|
primary key,
|
||||||
|
version int not null,
|
||||||
|
preset_name varchar(255) not null,
|
||||||
|
is_enabled int default 1 not null
|
||||||
|
) ENGINE = InnoDB
|
||||||
|
DEFAULT CHARSET = utf8mb4
|
||||||
|
COLLATE = utf8mb4_unicode_ci;
|
||||||
|
|
||||||
|
create table chusan_user_login_bonus
|
||||||
|
(
|
||||||
|
id bigint auto_increment primary key,
|
||||||
|
user bigint not null,
|
||||||
|
version int not null,
|
||||||
|
preset_id int not null,
|
||||||
|
bonus_count int default 0 not null,
|
||||||
|
last_update_date datetime default '2018-01-01 00:00:00' not null,
|
||||||
|
is_watched int default 0 not null,
|
||||||
|
is_finished int default 0 not null
|
||||||
|
) ENGINE = InnoDB
|
||||||
|
DEFAULT CHARSET = utf8mb4
|
||||||
|
COLLATE = utf8mb4_unicode_ci;
|
|
@ -0,0 +1,42 @@
|
||||||
|
CREATE TABLE chusan_game_login_bonus_preset
|
||||||
|
(
|
||||||
|
id INTEGER NOT NULL,
|
||||||
|
version INTEGER NOT NULL,
|
||||||
|
preset_name VARCHAR(255) NOT NULL,
|
||||||
|
is_enabled INTEGER DEFAULT 1,
|
||||||
|
PRIMARY KEY (
|
||||||
|
id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE chusan_game_login_bonus
|
||||||
|
(
|
||||||
|
id INTEGER NOT NULL,
|
||||||
|
version INTEGER NOT NULL,
|
||||||
|
preset_id INTEGER NOT NULL,
|
||||||
|
login_bonus_id INTEGER NOT NULL,
|
||||||
|
login_bonus_name VARCHAR(255) NOT NULL,
|
||||||
|
present_id INTEGER NOT NULL,
|
||||||
|
present_name VARCHAR(255) NOT NULL,
|
||||||
|
item_num INTEGER NOT NULL,
|
||||||
|
need_login_day_count INTEGER NOT NULL,
|
||||||
|
login_bonus_category_type INTEGER NOT NULL,
|
||||||
|
PRIMARY KEY (
|
||||||
|
id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE chusan_user_login_bonus
|
||||||
|
(
|
||||||
|
id INTEGER NOT NULL,
|
||||||
|
user INTEGER NOT NULL,
|
||||||
|
version INTEGER NOT NULL,
|
||||||
|
preset_id INTEGER NOT NULL,
|
||||||
|
bonus_count INTEGER NOT NULL DEFAULT 0,
|
||||||
|
last_update_date DATETIME NOT NULL default '2018-01-01 00:00:00.0',
|
||||||
|
is_watched INTEGER DEFAULT 0,
|
||||||
|
is_finished INTEGER DEFAULT 0,
|
||||||
|
PRIMARY KEY (
|
||||||
|
id
|
||||||
|
)
|
||||||
|
);
|
Loading…
Reference in New Issue