首页登陆替换成Google身份验证器

新增配置工具类
更新页面
This commit is contained in:
2020-09-29 08:52:16 +08:00
parent 11bbd3642e
commit 71d8a52dec
9 changed files with 325 additions and 40 deletions

View File

@@ -0,0 +1,79 @@
package com.yutou.tools.utils;
import com.alibaba.fastjson.JSONObject;
import java.io.*;
/**
* 配置和参数
*/
public class ConfigTools {
public static final String CONFIG="config.json";
public static final String DATA="data.json";
static {
try {
File file=new File(CONFIG);
if(!file.exists()){
file.createNewFile();
}
file=new File(DATA);
if(!file.exists()){
file.createNewFile();
}
file=null;
}catch (Exception e){
e.printStackTrace();
}
}
public static Object load(String type,String key){
File file=new File(type);
String src=readFile(file);
if(src!=null){
JSONObject json=JSONObject.parseObject(src);
if(json==null){
json=new JSONObject();
saveFile(file,json.toJSONString());
}
return json.getOrDefault(key, "");
}
return null;
}
public static boolean save(String type,String key,Object data){
File file=new File(type);
String src=readFile(file);
if(src!=null){
JSONObject json=JSONObject.parseObject(src);
json.put(key,data);
saveFile(file,json.toJSONString());
}
return false;
}
public static boolean saveFile(File file,String data){
try {
FileWriter writer=new FileWriter(file);
writer.write(data);
writer.flush();
writer.close();
return true;
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
public static String readFile(File file){
try {
BufferedReader reader=new BufferedReader(new FileReader(file));
String tmp;
StringBuilder str= new StringBuilder();
while ((tmp=reader.readLine())!=null){
str.append(tmp);
}
reader.close();
return str.toString();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}

View File

@@ -226,6 +226,9 @@ public class RedisTools {
case "cmd":
system("cmd", message);
break;
case "msg":
Tools.sendServer("来自服务姬的通知~",message);
break;
}
}
@@ -260,23 +263,7 @@ public class RedisTools {
}
}
private void processOut(InputStream inputStream) {
String tmp, str = "null";
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
while ((tmp = reader.readLine()) != null) {
str += tmp + "\n";
}
reader.close();
inputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("cmd > " + str);
RedisTools.set(1, "msg_" + System.currentTimeMillis(), str);
System.out.println("线程结束");
}
private void bot(String value) {
switch (value) {
@@ -288,7 +275,23 @@ public class RedisTools {
}
}
}
public static void processOut(InputStream inputStream) {
String tmp, str = "null";
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
while ((tmp = reader.readLine()) != null) {
str += tmp + "\n";
}
reader.close();
inputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("cmd > " + str);
RedisTools.set(1, "msg_" + System.currentTimeMillis(), str);
System.out.println("线程结束");
}
public static void main(String[] args) {
RedisTools.pullMsg("msg", "abc");
}