mod
This commit is contained in:
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -22,7 +22,7 @@ import com.utils.Utils;
|
|||||||
public class alipay_core {
|
public class alipay_core {
|
||||||
AlipayClient client = null;
|
AlipayClient client = null;
|
||||||
/**支付宝回调的接口地址*/
|
/**支付宝回调的接口地址*/
|
||||||
private static String aliNotifyUrl = "yourWebUrl/pay/alinotify";
|
private static String aliNotifyUrl = Utils.getPeoperties("aliNotifyUrl")+"";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -30,9 +30,9 @@ public class alipay_core {
|
|||||||
*/
|
*/
|
||||||
public void getConfig() {
|
public void getConfig() {
|
||||||
|
|
||||||
String appid="一串数字ID";
|
String appid = Utils.getPeoperties("appid")+"";
|
||||||
String private_key="私钥";
|
String private_key = Utils.getPeoperties("private_key")+"";
|
||||||
String public_key="公钥";
|
String public_key = Utils.getPeoperties("public_key")+"";
|
||||||
String sign_type="RSA2";
|
String sign_type="RSA2";
|
||||||
|
|
||||||
client =new DefaultAlipayClient("https://openapi.alipay.com/gateway.do",appid,private_key,"json","utf-8",public_key,sign_type);
|
client =new DefaultAlipayClient("https://openapi.alipay.com/gateway.do",appid,private_key,"json","utf-8",public_key,sign_type);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.demo;
|
package com.demo;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -18,7 +19,6 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
|
|
||||||
|
|
||||||
@CrossOrigin(origins = "*", maxAge = 3600)
|
@CrossOrigin(origins = "*", maxAge = 3600)
|
||||||
@RequestMapping(value="/pay",produces="text/html;charset=UTF-8")
|
|
||||||
@RestController
|
@RestController
|
||||||
public class payController {
|
public class payController {
|
||||||
|
|
||||||
@@ -128,10 +128,80 @@ public class payController {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/install", produces = "text/html;charset=UTF-8")
|
||||||
|
public String install(
|
||||||
|
@RequestParam(required = false, defaultValue = "") String p,
|
||||||
|
HttpServletRequest request,
|
||||||
|
HttpServletResponse response
|
||||||
|
) {
|
||||||
|
|
||||||
|
//检查数据是否已经初始化,若没有,先设置后台密码
|
||||||
|
|
||||||
|
String pwd = Utils.getPeoperties("pwd") + "";
|
||||||
|
if(pwd.replace("null","").trim().length()>0){
|
||||||
|
try {
|
||||||
|
response.sendRedirect("./settings.html");
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return "{\"code\":\"-1\"}";
|
||||||
|
}else if(p.replace("null","").trim().length()>0) {
|
||||||
|
Utils.setPeoperties("pwd",p);
|
||||||
|
return "{\"code\":\"1\"}";
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
response.sendRedirect("./install.html");
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return "{\"code\":\"-1\"}";
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/settings", produces = "text/html;charset=UTF-8")
|
||||||
|
public String setsettings(
|
||||||
|
@RequestParam(required = false, defaultValue = "") String p,//后台密码
|
||||||
|
@RequestParam(required = false, defaultValue = "") String k,//key
|
||||||
|
@RequestParam(required = false, defaultValue = "") String v,//value
|
||||||
|
HttpServletRequest request,
|
||||||
|
HttpServletResponse response
|
||||||
|
) {
|
||||||
|
|
||||||
|
String pwd = Utils.getPeoperties("pwd") + "";
|
||||||
|
if(pwd.replace("null","").trim().length()<1){
|
||||||
|
try {
|
||||||
|
response.sendRedirect("./install.html");
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return "{\"code\":\"-1\"}";
|
||||||
|
}else if("get".equals(k)&&pwd.equals(v)){
|
||||||
|
//获取配置
|
||||||
|
Map<String,String> m = new HashMap<>();
|
||||||
|
m.put("code","1");
|
||||||
|
m.put("pwd#后台密码",Utils.getPeoperties("pwd") + "");
|
||||||
|
m.put("dbname#数据库库名",Utils.getPeoperties("dbname")+"");
|
||||||
|
m.put("dbport#数据库端口",Utils.getPeoperties("dbport")+"");
|
||||||
|
m.put("dbusername#数据库用户名",Utils.getPeoperties("dbusername")+"");
|
||||||
|
m.put("dbpassword#数据库密码",Utils.getPeoperties("dbpassword")+"");
|
||||||
|
m.put("aliNotifyUrl#当面付回调地址",Utils.getPeoperties("aliNotifyUrl")+"");
|
||||||
|
m.put("appid#当面付APPID",Utils.getPeoperties("appid")+"");
|
||||||
|
m.put("private_key#当面付私钥",Utils.getPeoperties("private_key")+"");
|
||||||
|
m.put("public_key#当面付公钥",Utils.getPeoperties("public_key")+"");
|
||||||
|
return Utils.ObjectToJson(m);
|
||||||
|
|
||||||
|
}else if(pwd.equals(p)){
|
||||||
|
//k,v,写入properties
|
||||||
|
|
||||||
|
}else{
|
||||||
|
Map<String,String> m = new HashMap<>();
|
||||||
|
m.put("code","-1");
|
||||||
|
m.put("msg","请输入后台密码");
|
||||||
|
m.put("url","./settings");
|
||||||
|
return Utils.ObjectToJson(m);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,11 +16,11 @@ import java.util.Map;
|
|||||||
public class DBUtil {
|
public class DBUtil {
|
||||||
|
|
||||||
// 四大金刚
|
// 四大金刚
|
||||||
String dname = "scbox";
|
String dname = Utils.getPeoperties("dbname")+"";
|
||||||
String driver = "com.mysql.jdbc.Driver";// 驱动名称
|
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 url = "jdbc:mysql://127.0.0.1:"+Utils.getPeoperties("dbport")+"/"+dname+"?useUnicode=false&characterEncoding=UTF-8&useOldAliasMetadataBehavior=true&autoReconnect=true&useSSL=false";// 连接
|
||||||
String username = "root";// 用户名
|
String username = Utils.getPeoperties("dbusername")+"";// 用户名
|
||||||
String password = "root";// 密码
|
String password = Utils.getPeoperties("dbpassword")+"";// 密码
|
||||||
|
|
||||||
// 三剑客
|
// 三剑客
|
||||||
Connection con = null;// 连接对象
|
Connection con = null;// 连接对象
|
||||||
@@ -257,4 +257,5 @@ public class DBUtil {
|
|||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,9 +10,11 @@ import org.apache.commons.codec.binary.Base64;
|
|||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.*;
|
||||||
|
import java.net.URL;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class Utils {
|
public class Utils {
|
||||||
@@ -139,4 +141,49 @@ public class Utils {
|
|||||||
return resMatrix;
|
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");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
1
src/main/resources/t.properties
Normal file
1
src/main/resources/t.properties
Normal file
@@ -0,0 +1 @@
|
|||||||
|
1=2
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
return;
|
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());
|
let res = JSON.parse(await response.text());
|
||||||
|
|
||||||
if (res.code == 1) {
|
if (res.code == 1) {
|
||||||
@@ -64,7 +64,7 @@
|
|||||||
*轮询检查支付状态
|
*轮询检查支付状态
|
||||||
*/
|
*/
|
||||||
async function subscribe(id) {
|
async function subscribe(id) {
|
||||||
let response = await fetch("./pay/queryPay?id=" + id);
|
let response = await fetch("./queryPay?id=" + id);
|
||||||
|
|
||||||
if (response.status == 502) {
|
if (response.status == 502) {
|
||||||
// 连接超时,重新连接
|
// 连接超时,重新连接
|
||||||
@@ -93,7 +93,7 @@
|
|||||||
* 手动查询支付状态
|
* 手动查询支付状态
|
||||||
*/
|
*/
|
||||||
async function selectPay(id) {
|
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());
|
let res = JSON.parse(await response.text());
|
||||||
|
|
||||||
if (response.status == 200 && res.msg == "已支付") {
|
if (response.status == 200 && res.msg == "已支付") {
|
||||||
|
|||||||
39
src/main/webapp/install.html
Normal file
39
src/main/webapp/install.html
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang='en'>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset='UTF-8'>
|
||||||
|
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
|
||||||
|
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
|
||||||
|
<title>初始化</title>
|
||||||
|
<style>
|
||||||
|
* {
|
||||||
|
margin: 10px auto;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div id="">
|
||||||
|
<br><br><br>
|
||||||
|
<h3>首次使用</h3>
|
||||||
|
<br><br> 设置后台密码:
|
||||||
|
<input type="text" name="p" id="p"> <button onclick="setp()">提交</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src='https://libs.baidu.com/jquery/2.0.0/jquery.min.js'></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
async function setp() {
|
||||||
|
var p = $('#p').val();
|
||||||
|
let response = await fetch('./install?p=' + p);
|
||||||
|
let res = JSON.parse(await response.text());
|
||||||
|
if (res.code / 1 == 1) {
|
||||||
|
window.location.href = "./settings.html";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
36
src/main/webapp/settings.html
Normal file
36
src/main/webapp/settings.html
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang='en'>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset='UTF-8'>
|
||||||
|
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
|
||||||
|
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
|
||||||
|
<title>配置</title>
|
||||||
|
<style>
|
||||||
|
* {
|
||||||
|
margin: 10px auto;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<br><br><br>
|
||||||
|
<h3>参数配置</h3>
|
||||||
|
<br><br> 输入后台密码获取配置:
|
||||||
|
<input type="text" name="p" id="p"> <button onclick="setp()">提交</button> --- 单个单个的参数后面跟一个修改按钮,每个按钮对应一个事件,事件用pkv传给后台,像是当面付回调地址、写上解释怎么填, API接口写一个调用示例解释一下 --- 运行建表程序
|
||||||
|
|
||||||
|
|
||||||
|
<script src='https://libs.baidu.com/jquery/2.0.0/jquery.min.js'></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
async function setp() {
|
||||||
|
var p = $('#p').val();
|
||||||
|
let response = await fetch('./settings?k=get&v=' + p);
|
||||||
|
let res = JSON.parse(await response.text());
|
||||||
|
console.log(res);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user