[chuni] Read reboot time from database

pull/1/head
samnyan 2020-04-26 10:40:15 +09:00
parent 7fc1127026
commit 49d105de4e
3 changed files with 16 additions and 6 deletions

View File

@ -10,7 +10,7 @@
</parent> </parent>
<groupId>icu.samnya</groupId> <groupId>icu.samnya</groupId>
<artifactId>aqua</artifactId> <artifactId>aqua</artifactId>
<version>0.0.13-RELEASE</version> <version>0.0.14-RELEASE</version>
<name>Aqua Server</name> <name>Aqua Server</name>
<description>A multipurpose game server</description> <description>A multipurpose game server</description>

View File

@ -4,6 +4,8 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import icu.samnyan.aqua.sega.chunithm.handler.BaseHandler; import icu.samnyan.aqua.sega.chunithm.handler.BaseHandler;
import icu.samnyan.aqua.sega.chunithm.model.response.GetGameSettingResp; import icu.samnyan.aqua.sega.chunithm.model.response.GetGameSettingResp;
import icu.samnyan.aqua.sega.chunithm.model.response.data.GameSetting; import icu.samnyan.aqua.sega.chunithm.model.response.data.GameSetting;
import icu.samnyan.aqua.sega.general.dao.PropertyEntryRepository;
import icu.samnyan.aqua.sega.general.model.PropertyEntry;
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;
@ -22,21 +24,29 @@ public class GetGameSettingHandler implements BaseHandler {
private final StringMapper mapper; private final StringMapper mapper;
private final PropertyEntryRepository propertyEntryRepository;
@Autowired @Autowired
public GetGameSettingHandler(StringMapper mapper) { public GetGameSettingHandler(StringMapper mapper, PropertyEntryRepository propertyEntryRepository) {
this.mapper = mapper; this.mapper = mapper;
this.propertyEntryRepository = propertyEntryRepository;
} }
@Override @Override
public String handle(Map<String, Object> request) throws JsonProcessingException { public String handle(Map<String, Object> request) throws JsonProcessingException {
PropertyEntry start = propertyEntryRepository.findByPropertyKey("reboot_start_time")
.orElseGet(() -> new PropertyEntry("reboot_start_time", "2020-01-01 23:59:00.0"));
PropertyEntry end = propertyEntryRepository.findByPropertyKey("reboot_end_time")
.orElseGet(() -> new PropertyEntry("reboot_end_time", "2020-01-01 23:59:00.0"));
GameSetting gameSetting = new GameSetting( GameSetting gameSetting = new GameSetting(
1, 1,
false, false,
10, 10,
0, start.getPropertyValue(),
0, end.getPropertyValue(),
false, false,
300, 300,
300, 300,

View File

@ -16,8 +16,8 @@ public class GameSetting {
@JsonProperty("isMaintenance") @JsonProperty("isMaintenance")
private boolean isMaintenance; private boolean isMaintenance;
private int requestInterval; private int requestInterval;
private int rebootStartTime; private String rebootStartTime;
private int rebootEndTime; private String rebootEndTime;
@JsonProperty("isBackgroundDistribute") @JsonProperty("isBackgroundDistribute")
private boolean isBackgroundDistribute; private boolean isBackgroundDistribute;
private int maxCountCharacter; private int maxCountCharacter;