yuanyiming 1 年間 前
コミット
13018e36f1
1 ファイル変更194 行追加202 行削除
  1. 194 202
      pbl.js

+ 194 - 202
pbl.js

@@ -13,7 +13,6 @@ var mysql = require("./mysql");
 // const _mysqlLabor = ["127.0.0.1", "sc_app"]; //袁一鸣
 // const _mysqlLabor = ["10.3.13.84", "sc_app"]; //袁一鸣
 
-
 const _mysqlLabor = ["172.16.12.5", "sc_app"]; // 提交的使用用这两个edu數據庫信息
 // const _mysqluser = ["172.16.12.5", "cocorobouser"]; //edu數據庫信息
 
@@ -24,433 +23,426 @@ let jwt = require("jsonwebtoken");
 let multer = require("multer");
 
 const wx = {
-    appid: "wx1260af162664fd04", // 填写用户自己的appid
-    secret: "9d399b3aa0a9e8bce68d20e7734b73e0", // 填写用户自己的密钥
+	appid: "wx1260af162664fd04", // 填写用户自己的appid
+	secret: "9d399b3aa0a9e8bce68d20e7734b73e0", // 填写用户自己的密钥
 
-    // appid: "wxcf19f82bc4ca3229", // lqh
-    // secret: "148b350f8bbd2daed7c2f75a8b4411aa", // 填写用户自己的密钥
+	// appid: "wxcf19f82bc4ca3229", // lqh
+	// secret: "148b350f8bbd2daed7c2f75a8b4411aa", // 填写用户自己的密钥
 };
 //統壹處理區域
 router.use(async function (req, res, next) {
-    await asynnext(req, res, next);
-    //// make sure we go to the next routes and don't stop here
-    //res.end("");
+	await asynnext(req, res, next);
+	//// make sure we go to the next routes and don't stop here
+	//res.end("");
 });
 
 /**
  * @des 參數解釋同上
  */
 function asynnext(req, res, next) {
-    //異步處理
-    return new Promise(async (resolve, reject) => {
-        next();
-        //resolve(true);aa
-    });
+	//異步處理
+	return new Promise(async (resolve, reject) => {
+		next();
+		//resolve(true);aa
+	});
 }
 /*測試*/
 router.route("/a").all((req, res, next) => {
-    res.send({
-        msg: "成功",
-    });
-    return console.log(req.query);
-    QMysql(req, res, "insert_user");
-    var json = queryString(req.url);
-    getmysql(req, res, "a", json["ph"], json["pa"]);
+	res.send({
+		msg: "成功",
+	});
+	return console.log(req.query);
+	QMysql(req, res, "insert_user");
+	var json = queryString(req.url);
+	getmysql(req, res, "a", json["ph"], json["pa"]);
 });
 router.route("/b").all((req, res, next) => {
-    var json = queryString(req.url);
-    getmysql(req, res, "b", json["ph"], json["pa"]);
+	var json = queryString(req.url);
+	getmysql(req, res, "b", json["ph"], json["pa"]);
 });
 
 // yym获取微信openID
 router.get("/weChatCode", async (req, res) => {
-    console.log(req.query);
-    let response = await axios.get("https://api.weixin.qq.com/sns/jscode2session", {
-        params: {
-            appid: wx.appid,
-            secret: wx.secret,
-            js_code: req.query.codes,
-            grant_type: "authorization_code",
-        },
-    });
-    // console.log(response.data);
-    res.send(response.data.openid);
-    // QMysql(req, res, "update_NewStatusById");
+	console.log(req.query);
+	let response = await axios.get(
+		"https://api.weixin.qq.com/sns/jscode2session",
+		{
+			params: {
+				appid: wx.appid,
+				secret: wx.secret,
+				js_code: req.query.codes,
+				grant_type: "authorization_code",
+			},
+		}
+	);
+	// console.log(response.data);
+	res.send(response.data.openid);
+	// QMysql(req, res, "update_NewStatusById");
 });
 
 //yym注册接口
 router.post("/login", (req, res) => {
-    // return console.log(req.body);
-    // let { openid } = req.body;
-    postmysql3(req, res, "insert_user");
-    // let token = jwt.sign({
-    //     openid,
-    // },
-    //     "secret", {
-    //     expiresIn: "10s",
-    // }
-    // );
-
-    // res.send({
-    //     code: 200,
-    //     msg: "登录成功",
-    //     token,
-    // });
+	// return console.log(req.body);
+	// let { openid } = req.body;
+	postmysql3(req, res, "insert_user");
+	// let token = jwt.sign({
+	//     openid,
+	// },
+	//     "secret", {
+	//     expiresIn: "10s",
+	// }
+	// );
+
+	// res.send({
+	//     code: 200,
+	//     msg: "登录成功",
+	//     token,
+	// });
 });
 
 //yym查询用户(查询是否注册过)
 router.post("/selectUser", (req, res) => {
-    // console.log(req.body);
-    // let { openid } = req.body;
-    postmysql3(req, res, "Select_user");
-    // console.log(res.end);
+	// console.log(req.body);
+	// let { openid } = req.body;
+	postmysql3(req, res, "Select_user");
+	// console.log(res.end);
 });
 
 // yym更新头像昵称
 router.post("/updateUser", (req, res) => {
-    // console.log(req.body);
-    postmysql3(req, res, "update_User");
-
+	// console.log(req.body);
+	postmysql3(req, res, "update_User");
 });
 
-
 //yym上传活动
 router.post("/insertActive", (req, res) => {
-    // console.log(req.body);
-    postmysql3(req, res, "insert_activity");
+	// console.log(req.body);
+	postmysql3(req, res, "insert_activity");
 
-    // res.send({
-    //     code: 200,
-    //     msg: "上传成功",
-    // });
+	// res.send({
+	//     code: 200,
+	//     msg: "上传成功",
+	// });
 });
 
 //yym 获取活动
 router.post("/selectActivity", (req, res) => {
-    // console.log(req.body); 
-    postmysql3(req, res, "select_activity");
+	// console.log(req.body);
+	postmysql3(req, res, "select_activity");
 });
 
 //yym 获取用户收藏信息
 router.post("/selectColl", (req, res) => {
-    // console.log(req.body); 
-    postmysql3(req, res, "select_coll");
+	// console.log(req.body);
+	postmysql3(req, res, "select_coll");
 });
 
 //yym 更新用户收藏信息
 router.post("/updateColl", (req, res) => {
-    // console.log('更新用户收藏信息',req.body); 
-    postmysql3(req, res, "update_coll");
+	// console.log('更新用户收藏信息',req.body);
+	postmysql3(req, res, "update_coll");
 });
 
 //获取用户订阅信息 xlh
 router.post("/selectSub", (req, res) => {
-    postmysql3(req, res, "select_sub");
+	postmysql3(req, res, "select_sub");
 });
 
 //更新用户订阅信息 xlh
 router.post("/updateSub", (req, res) => {
-    postmysql3(req, res, "update_sub");
+	postmysql3(req, res, "update_sub");
 });
 //yym 获取用户收藏数据(数组查询)  废弃
 router.post("/selectCollList", (req, res) => {
-    // console.log('获取',req.body); 
-    postmysql3(req, res, "select_collList");
+	// console.log('获取',req.body);
+	postmysql3(req, res, "select_collList");
 });
 
 //yym 获取用户订阅数据(数组查询)  废弃
 router.post("/selectSubList", (req, res) => {
-    // console.log('获取',req.body); 
-    postmysql3(req, res, "select_subList");
+	// console.log('获取',req.body);
+	postmysql3(req, res, "select_subList");
 });
 
 //yym 获取用户信息
 router.post("/selectUserInfo", (req, res) => {
-    // console.log('获取',req.body); 
-    postmysql3(req, res, "select_UserInfo");
+	// console.log('获取',req.body);
+	postmysql3(req, res, "select_UserInfo");
 });
 
 //yym 更新用户信息
 router.post("/updateUserInfo", (req, res) => {
-    console.log('获取用户信息',req.body);  
-    postmysql3(req, res, "update_userInfo");
+	console.log("获取用户信息", req.body);
+	postmysql3(req, res, "update_userInfo");
 });
 
 //yym 用户报名收藏等操作  0收藏 1订阅 2报名
 router.post("/insertOperator", (req, res) => {
-    // console.log('获取',req.body); 
-    postmysql3(req, res, "insert_operator");
+	// console.log('获取',req.body);
+	postmysql3(req, res, "insert_operator");
 });
- 
 
 //yym 查询用户全部报名收藏  0收藏 1订阅 2报名
 router.post("/selectOperator", (req, res) => {
-    // console.log('获取',req.body); 
-    postmysql3(req, res, "select_operator");
+	// console.log('获取',req.body);
+	postmysql3(req, res, "select_operator");
 });
 
-//yym 查询用户 单个 报名收藏 
+//yym 查询用户 单个 报名收藏
 router.post("/selectOneOperator", (req, res) => {
-    // console.log('获取',req.body); 
-    postmysql3(req, res, "select_oneOperator");
+	// console.log('获取',req.body);
+	postmysql3(req, res, "select_oneOperator");
 });
 
 //yym 删除用户收藏或订阅
 router.post("/deleteOperator", (req, res) => {
-    // console.log('获取',req.body); 
-    postmysql3(req, res, "delete_Operator");
+	// console.log('获取',req.body);
+	postmysql3(req, res, "delete_Operator");
 });
 
 //yym 我的发布页面获取要修改的活动数据
 router.post("/selectAmendAct", (req, res) => {
-    // console.log('获取',req.body); 
-    postmysql3(req, res, "select_amendAct");
+	// console.log('获取',req.body);
+	postmysql3(req, res, "select_amendAct");
 });
 
 //yym 获取活动详情页面是否收藏订阅报名
 router.post("/selectSignup", (req, res) => {
-    // console.log('获取',req.body); 
-    postmysql3(req, res, "select_signup");
+	// console.log('获取',req.body);
+	postmysql3(req, res, "select_signup");
 });
 
 //yym 报名活动
 router.post("/insertSignup", (req, res) => {
-    // console.log('获取',req.body); 
-    postmysql3(req, res, "insert_Signup");
+	// console.log('获取',req.body);
+	postmysql3(req, res, "insert_Signup");
 });
 
 //yym 做最后判断防止同一时间进入报名页面都报名成功
 router.post("/selectIntercept", (req, res) => {
-    // console.log('获取',req.body); 
-    postmysql3(req, res, "select_intercept");
+	// console.log('获取',req.body);
+	postmysql3(req, res, "select_intercept");
 });
 
 //yym 获取活动报名人
 router.post("/selectApplyUser", (req, res) => {
-    // console.log('获取',req.body); 
-    postmysql3(req, res, "select_applyUser");
+	// console.log('获取',req.body);
+	postmysql3(req, res, "select_applyUser");
 });
 
 //yym 添加活动通知
 router.post("/insertMessage", (req, res) => {
-    // console.log('获取',req.body); 
-    postmysql3(req, res, "insert_message");
+	// console.log('获取',req.body);
+	postmysql3(req, res, "insert_message");
 });
 
-
 //yym 信息列表查询信息
 router.post("/selectMessage", (req, res) => {
-    // console.log('获取',req.body); 
-    postmysql3(req, res, "select_message");
+	// console.log('获取',req.body);
+	postmysql3(req, res, "select_message");
 });
 
 //yym 查询所有未读信息
 router.post("/selectAllMessage", (req, res) => {
-    // console.log('获取',req.body); 
-    postmysql3(req, res, "select_allMessage");
+	// console.log('获取',req.body);
+	postmysql3(req, res, "select_allMessage");
 });
 
 //yym 信息页面分组查询未读信息
 router.post("/selectGroupMessage", (req, res) => {
-    // console.log('获取',req.body); 
-    postmysql3(req, res, "select_groupMessage");
+	// console.log('获取',req.body);
+	postmysql3(req, res, "select_groupMessage");
 });
 
 //yym 更新未读信息
 router.post("/updateIsRead", (req, res) => {
-    console.log('获取',req.body); 
-    postmysql3(req, res, "update_isRead");
+	console.log("获取", req.body);
+	postmysql3(req, res, "update_isRead");
 });
 
 //yym 我的页面,我的收藏活动列表
 router.post("/selectCollAcList", (req, res) => {
-    console.log('获取',req.body); 
-    postmysql3(req, res, "select_collAcList");
+	console.log("获取", req.body);
+	postmysql3(req, res, "select_collAcList");
 });
 
 //yym 我的页面,我的收藏课程列表
 router.post("/selectCollClassList", (req, res) => {
-    console.log('获取',req.body); 
-    postmysql3(req, res, "select_collClassList");
+	console.log("获取", req.body);
+	postmysql3(req, res, "select_collClassList");
 });
 
 //yym 获取资源库
 router.post("/selectResource", (req, res) => {
-    console.log('获取',req.body); 
-    postmysql3(req, res, "select_resource");
+	console.log("获取", req.body);
+	postmysql3(req, res, "select_resource");
 });
 
 //yym 获取精品慕课
 router.post("/selectJTeach", (req, res) => {
-    console.log('获取',req.body); 
-    postmysql3(req, res, "select_jTeach");
+	console.log("获取", req.body);
+	postmysql3(req, res, "select_jTeach");
 });
 //yym 获取课程
 router.post("/selectOperatorTech", (req, res) => {
-    console.log('获取',req.body); 
-    postmysql3(req, res, "select_operatorTech");
+	console.log("获取", req.body);
+	postmysql3(req, res, "select_operatorTech");
 });
 
 //yym 获取我的消息,未读红点所填数据
 router.post("/selectUnreadMsg", (req, res) => {
-    console.log('获取',req.body); 
-    postmysql3(req, res, "select_unreadMsg");
+	console.log("获取", req.body);
+	postmysql3(req, res, "select_unreadMsg");
 });
 
 //yym 单个点击信息变已读
 router.post("/updateOneIsRead", (req, res) => {
-    console.log('获取',req.body); 
-    postmysql3(req, res, "update_oneIsRead");
+	console.log("获取", req.body);
+	postmysql3(req, res, "update_oneIsRead");
 });
 
-
-
-
-
+//yym 我的活动-获取已报名数据
+router.post("/selectRegistered", (req, res) => {
+	console.log("获取", req.body);
+	postmysql3(req, res, "selectRegistered");
+});
 
 //lqh获取活动acid
 router.post("/selectActivityID", (req, res) => {
-    postmysql3(req, res, "select_activityID");
+	postmysql3(req, res, "select_activityID");
 });
 
 //查询当前用户发布的活动 xlh
 router.post("/selectMyPublish", (req, res) => {
-    postmysql3(req, res, "select_mypublish");
+	postmysql3(req, res, "select_mypublish");
 });
 
 //更改当前用户发布的活动 xlh
 router.post("/updateMyPublish", (req, res) => {
-    postmysql3(req, res, "update_mypublish");
+	postmysql3(req, res, "update_mypublish");
 });
 
 //删除当前用户发布的活动 xlh
 router.post("/deleteMyPublish", (req, res) => {
-    postmysql3(req, res, "delete_mypublish");
+	postmysql3(req, res, "delete_mypublish");
 });
 
 //查询当前的活动是否是当前的用户发布的 xlh
 router.post("/selectPublisher", (req, res) => {
-    postmysql3(req, res, "select_activity_publisher");
+	postmysql3(req, res, "select_activity_publisher");
 });
 
 //报名申请加入 zwb
 router.post("/insertActivityEnroll", (req, res) => {
-    // console.log(req.body);
-    postmysql3(req, res, "insert_activity_enroll");
-
-    // res.send({
-    //     msg: "上传成功",
-    // });
+	// console.log(req.body);
+	postmysql3(req, res, "insert_activity_enroll");
 
+	// res.send({
+	//     msg: "上传成功",
+	// });
 });
 
 // 查询我的活动 zwb
 router.post("/selectActivityEnroll", (req, res) => {
-    postmysql3(req, res, "select_activity_enroll");
+	postmysql3(req, res, "select_activity_enroll");
 });
 
 //查询用户是否报名 zwb
 router.post("/selectActivityEnrollid", (req, res) => {
-    postmysql3(req, res, "select_activity_enroll_ID");
+	postmysql3(req, res, "select_activity_enroll_ID");
 });
 
 //查询全部活动
 router.route("/selectAct").all((req, res, next) => {
-    // var json = queryString(req.url);
-    getmysql(req, res, "selectAct");
+	// var json = queryString(req.url);
+	getmysql(req, res, "selectAct");
 });
 
-
-
-
-
-
-
 queryString = function (url) {
-    var a = url.split("?");
-    var json = querystring.parse(a[1]);
-    return json;
+	var a = url.split("?");
+	var json = querystring.parse(a[1]);
+	return json;
 };
 
 //post存儲過程處理
 postmysql = function (req, res, functionname) {
-    //mode的處理
-    if (req.body[0]) {
-        p = Object.values(req.body[0]);
-        p.unshift(_mysqlLabor[0], _mysqlLabor[1], functionname);
-        //執行存儲過程
-        mysql.usselect(p, function (ret) {
-            res.end(JSON.stringify(ret));
-        });
-    }
+	//mode的處理
+	if (req.body[0]) {
+		p = Object.values(req.body[0]);
+		p.unshift(_mysqlLabor[0], _mysqlLabor[1], functionname);
+		//執行存儲過程
+		mysql.usselect(p, function (ret) {
+			res.end(JSON.stringify(ret));
+		});
+	}
 };
 
 //post存儲過程處理
 postmysql2 = function (req, res, functionname) {
-    //mode的處理
-    if (req.body) {
-        p = Object.values(req.body)[0].split(",");
-        p.unshift(_mysqlLabor[0], _mysqlLabor[1], functionname);
-        //執行存儲過程
-        mysql.usselect(p, function (ret) {
-            res.end(JSON.stringify(ret));
-        });
-    }
+	//mode的處理
+	if (req.body) {
+		p = Object.values(req.body)[0].split(",");
+		p.unshift(_mysqlLabor[0], _mysqlLabor[1], functionname);
+		//執行存儲過程
+		mysql.usselect(p, function (ret) {
+			res.end(JSON.stringify(ret));
+		});
+	}
 };
 
 //post存儲過程處理
 postmysql3 = function (req, res, functionname) {
-    //mode的處理
-    if (req.body) {
-        p = Object.values(req.body);
-        p.unshift(_mysqlLabor[0], _mysqlLabor[1], functionname);
-        //執行存儲過程
-        mysql.usselect(p, function (ret) {
-            res.end(JSON.stringify(ret));
-        });
-    }
+	//mode的處理
+	if (req.body) {
+		p = Object.values(req.body);
+		p.unshift(_mysqlLabor[0], _mysqlLabor[1], functionname);
+		//執行存儲過程
+		mysql.usselect(p, function (ret) {
+			res.end(JSON.stringify(ret));
+		});
+	}
 };
 
 //get獲取數據庫信息
 getmysql = function (req, res, functionname, ...p) {
-    p = p || [];
-    p.unshift(_mysqlLabor[0], _mysqlLabor[1], functionname);
-    //執行存儲過程
-    mysql.usselect(p, function (ret) {
-        res.end(JSON.stringify(ret));
-    }); //
+	p = p || [];
+	p.unshift(_mysqlLabor[0], _mysqlLabor[1], functionname);
+	//執行存儲過程
+	mysql.usselect(p, function (ret) {
+		res.end(JSON.stringify(ret));
+	}); //
 };
 
 //post存储过程处理
 
 userpostmysql = function (req, res, functionname) {
-    //mode的处理
+	//mode的处理
 
-    if (req.body.mode) {
-        p = req.body.mode.split(",");
+	if (req.body.mode) {
+		p = req.body.mode.split(",");
 
-        p.unshift(_mysqluser[0], _mysqluser[1], functionname);
+		p.unshift(_mysqluser[0], _mysqluser[1], functionname);
 
-        //执行存储过程
+		//执行存储过程
 
-        mysql.usselect(p, function (ret) {
-            res.end(JSON.stringify(ret));
-        });
-    }
+		mysql.usselect(p, function (ret) {
+			res.end(JSON.stringify(ret));
+		});
+	}
 };
 
 //get获取数据库信息
 
 usergetmysql = function (req, res, functionname, ...p) {
-    p = p || [];
+	p = p || [];
 
-    p.unshift(_mysqluser[0], _mysqluser[1], functionname);
+	p.unshift(_mysqluser[0], _mysqluser[1], functionname);
 
-    //执行存储过程
+	//执行存储过程
 
-    mysql.usselect(p, function (ret) {
-        res.end(JSON.stringify(ret));
-    }); //
+	mysql.usselect(p, function (ret) {
+		res.end(JSON.stringify(ret));
+	}); //
 };
 
-module.exports = router;
+module.exports = router;