m = new HashMap<>();
+ m.put("code","-1");
+ m.put("msg","请输入后台密码");
+ m.put("url","./settings");
+ return Utils.ObjectToJson(m);
+ }
+ return null;
+ }
}
diff --git a/src/main/java/com/utils/DBUtil.java b/src/main/java/com/utils/DBUtil.java
index c23a183..872a3b7 100644
--- a/src/main/java/com/utils/DBUtil.java
+++ b/src/main/java/com/utils/DBUtil.java
@@ -16,11 +16,11 @@ import java.util.Map;
public class DBUtil {
// 四大金刚
- String dname = "scbox";
+ String dname = Utils.getPeoperties("dbname")+"";
String driver = "com.mysql.jdbc.Driver";// 驱动名称
- String url = "jdbc:mysql://127.0.0.1:3306/"+dname+"?useUnicode=false&characterEncoding=UTF-8&useOldAliasMetadataBehavior=true&autoReconnect=true&useSSL=false";// 连接
- String username = "root";// 用户名
- String password = "root";// 密码
+ String url = "jdbc:mysql://127.0.0.1:"+Utils.getPeoperties("dbport")+"/"+dname+"?useUnicode=false&characterEncoding=UTF-8&useOldAliasMetadataBehavior=true&autoReconnect=true&useSSL=false";// 连接
+ String username = Utils.getPeoperties("dbusername")+"";// 用户名
+ String password = Utils.getPeoperties("dbpassword")+"";// 密码
// 三剑客
Connection con = null;// 连接对象
@@ -257,4 +257,5 @@ public class DBUtil {
return m;
}
+
}
diff --git a/src/main/java/com/utils/Utils.java b/src/main/java/com/utils/Utils.java
index 255457f..8aad430 100644
--- a/src/main/java/com/utils/Utils.java
+++ b/src/main/java/com/utils/Utils.java
@@ -10,9 +10,11 @@ import org.apache.commons.codec.binary.Base64;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
-import java.io.ByteArrayOutputStream;
+import java.io.*;
+import java.net.URL;
import java.util.HashMap;
import java.util.Map;
+import java.util.Properties;
import java.util.Random;
public class Utils {
@@ -139,4 +141,49 @@ public class Utils {
return resMatrix;
}
+ public static Properties readPeoperties(){
+ InputStream inputStream = Utils.class.getClassLoader().getResourceAsStream("t.properties");
+
+ Properties p = new Properties();
+ try{
+ p.load(inputStream);
+ }catch(Exception e1) {
+ e1.printStackTrace();
+ }
+ return p;
+ }
+
+ public static Object getPeoperties(Object k){
+ InputStream inputStream = Utils.class.getClassLoader().getResourceAsStream("t.properties");
+
+ Properties p = new Properties();
+ try{
+ p.load(inputStream);
+ }catch(Exception e1) {
+ e1.printStackTrace();
+ }
+ return p.get(k);
+ }
+
+ public static void setPeoperties(String k,Object v){
+ Properties p = new Properties();
+ p.put(k,v);
+
+ URL f = Utils.class.getClassLoader().getResource("t.properties");
+
+ try{
+ System.out.println(f.toURI());
+ FileOutputStream fos = new FileOutputStream(new File(f.toURI()));
+ p.store(new BufferedOutputStream(fos),"save");
+ fos.close();
+ }catch(Exception e1) {
+ e1.printStackTrace();
+ }
+ }
+ public static void main(String[] args) {
+ Object p = Utils.getPeoperties("1");
+ System.out.println(p.toString());
+ Utils.setPeoperties("1","3");
+ }
+
}
diff --git a/src/main/resources/t.properties b/src/main/resources/t.properties
new file mode 100644
index 0000000..79f3703
--- /dev/null
+++ b/src/main/resources/t.properties
@@ -0,0 +1 @@
+1=2
\ No newline at end of file
diff --git a/src/main/webapp/index.html b/src/main/webapp/index.html
index fb6fcf0..a82f90d 100644
--- a/src/main/webapp/index.html
+++ b/src/main/webapp/index.html
@@ -38,7 +38,7 @@
return;
}
- let response = await fetch('./pay/createOrder?n=' + n + '&t=test');
+ let response = await fetch('./createOrder?n=' + n + '&t=test');
let res = JSON.parse(await response.text());
if (res.code == 1) {
@@ -64,7 +64,7 @@
*轮询检查支付状态
*/
async function subscribe(id) {
- let response = await fetch("./pay/queryPay?id=" + id);
+ let response = await fetch("./queryPay?id=" + id);
if (response.status == 502) {
// 连接超时,重新连接
@@ -93,7 +93,7 @@
* 手动查询支付状态
*/
async function selectPay(id) {
- let response = await fetch('./pay/queryPay?id=' + id);
+ let response = await fetch('./queryPay?id=' + id);
let res = JSON.parse(await response.text());
if (response.status == 200 && res.msg == "已支付") {
diff --git a/src/main/webapp/install.html b/src/main/webapp/install.html
new file mode 100644
index 0000000..f259f9f
--- /dev/null
+++ b/src/main/webapp/install.html
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+ 初始化
+
+
+
+
+
+
+
首次使用
+
设置后台密码:
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/webapp/settings.html b/src/main/webapp/settings.html
new file mode 100644
index 0000000..7455016
--- /dev/null
+++ b/src/main/webapp/settings.html
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+ 配置
+
+
+
+
+
+ 参数配置
+
输入后台密码获取配置:
+ --- 单个单个的参数后面跟一个修改按钮,每个按钮对应一个事件,事件用pkv传给后台,像是当面付回调地址、写上解释怎么填, API接口写一个调用示例解释一下 --- 运行建表程序
+
+
+
+
+
+
+
+
\ No newline at end of file