mirror of
https://github.com/Geniusay/ChopperBot.git
synced 2026-05-23 04:39:41 +08:00
1,完成热门模块的数据中心
2,完成api接口
This commit is contained in:
@@ -213,7 +213,7 @@ public class FileCache <T extends ConfigFile>{
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public Object get(String key){
|
||||
private Object get(String key){
|
||||
return jsonFile.get(key);
|
||||
}
|
||||
|
||||
@@ -238,7 +238,7 @@ public class FileCache <T extends ConfigFile>{
|
||||
*/
|
||||
public void forceSync(){
|
||||
if(writeByte.get()==0){
|
||||
logger.info("未发生版本变化");
|
||||
logger.debug("未发生版本变化");
|
||||
return;
|
||||
}
|
||||
clearWriteBytes();
|
||||
|
||||
@@ -76,7 +76,7 @@ public class FileCacheManager {
|
||||
fileCaches.add(fileCache);
|
||||
fileCacheMap.put(fileCache.getFullFilePath(),fileCache);
|
||||
initSleepTime();
|
||||
FileModuleLogger.logger.info("FileCacheManager add a new FileCache:{}",fileCache.getFullFilePath());
|
||||
FileModuleLogger.logger.debug("FileCacheManager add a new FileCache:{}",fileCache.getFullFilePath());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -99,7 +99,7 @@ public class FileCacheManager {
|
||||
BlockingQueue fileChannel = cache.getFileChannel();
|
||||
if(fileChannel.isEmpty()){
|
||||
if(cache.needAutoSync()){
|
||||
logger.info("检测到需要强制刷新的文件 {}",cache.getFileName());
|
||||
FileModuleLogger.logger.debug("检测到需要强制刷新的文件 {}",cache.getFileName());
|
||||
autoSyncer.submit(new AutoSyncer(cache));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
package org.example.service;
|
||||
|
||||
import org.example.pojo.vo.ConfigVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Genius
|
||||
* @date 2023/04/26 00:59
|
||||
**/
|
||||
|
||||
public interface FileService {
|
||||
|
||||
//获取所有模块
|
||||
List<String> getAllModule();
|
||||
|
||||
//获取所有文件
|
||||
List<ConfigVO> getAllConfigs();
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package org.example.service.impl;
|
||||
|
||||
import org.example.cache.FileCache;
|
||||
import org.example.cache.FileCacheManagerInstance;
|
||||
import org.example.bean.FileType;
|
||||
import org.example.pojo.vo.ConfigVO;
|
||||
import org.example.service.FileService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Genius
|
||||
* @date 2023/04/26 01:01
|
||||
**/
|
||||
|
||||
@Service
|
||||
public class FileServiceImpl implements FileService {
|
||||
|
||||
@Override
|
||||
public List<String> getAllModule() {
|
||||
List<String> moduleList = new ArrayList<>();
|
||||
for (FileType value : FileType.values()) {
|
||||
if(!value.equals(FileType.COMMON)){
|
||||
moduleList.add(value.getName());
|
||||
}
|
||||
}
|
||||
return moduleList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ConfigVO> getAllConfigs() {
|
||||
List<ConfigVO> configVOList = new ArrayList<>();
|
||||
List<FileCache> runnableFileCaches = FileCacheManagerInstance.getInstance().getRunnableFileCaches();
|
||||
for (FileCache runnableFileCache : runnableFileCaches) {
|
||||
if (runnableFileCache.getFileType().equals(FileType.COMMON)) {
|
||||
continue;
|
||||
}
|
||||
configVOList.add(new ConfigVO(runnableFileCache.getFileName()
|
||||
,runnableFileCache.getFullFilePath()
|
||||
,runnableFileCache.getFileType().getName()));
|
||||
}
|
||||
return configVOList;
|
||||
}
|
||||
}
|
||||
@@ -71,7 +71,6 @@ public class JsonFileUtil {
|
||||
T t = null;
|
||||
Path dir = Paths.get(fullPath);
|
||||
try{
|
||||
System.out.println(dir);
|
||||
if (FileUtil.isFileExist(dir.toString())) {
|
||||
String res = Files.readString(dir, StandardCharsets.UTF_8);
|
||||
// logger.debug("读取json文件成功, 文件内容为: {}", res);
|
||||
|
||||
Reference in New Issue
Block a user