|
@@ -32,75 +32,38 @@ router.route('/a').all((req, res, next) => {
|
|
|
var json = GetData(req);
|
|
|
getmysql(req, res, "a");
|
|
|
});
|
|
|
-// router.route('/b').all((req, res, next) => {
|
|
|
-// postmysql(req, res, "b");
|
|
|
-// });
|
|
|
|
|
|
//qgt 查看数据库是否有此人
|
|
|
-router.use((req,res,next)=>{
|
|
|
- const uid = GetData(req)['uid'];
|
|
|
- let p = [_mysqlLabor[0], _mysqlLabor[1], 'select_UserByUserId',uid];
|
|
|
- mysql.usselect(p,function(result){
|
|
|
- if(result[0].length==1){
|
|
|
- next();
|
|
|
- }else{
|
|
|
- res.Back(1,"用户不存在",GetData(req))
|
|
|
- }
|
|
|
- })
|
|
|
-})
|
|
|
+// router.use((req,res,next)=>{
|
|
|
+// const uid = GetData(req)['uid'];
|
|
|
+// let p = [_mysqlLabor[0], _mysqlLabor[1], 'select_UserByUserId',uid];
|
|
|
+// mysql.usselect(p,function(result){
|
|
|
+// if(result[0].length==1){
|
|
|
+// next();
|
|
|
+// }else{
|
|
|
+// res.Back(1,"用户不存在",GetData(req))
|
|
|
+// }
|
|
|
+// })
|
|
|
+// })
|
|
|
|
|
|
//qgt 新增全站通知
|
|
|
-router.post('/CreateNewNotification',(req,res)=>{
|
|
|
- //uid title brief
|
|
|
- const ReqData = GetData(req);
|
|
|
- //随机ID
|
|
|
- const nid = crypto.randomUUID({ disableEntropyCache: true })
|
|
|
- let p = [_mysqlLabor[0], _mysqlLabor[1], 'insert_New',nid,ReqData['title'],ReqData['brief'],ReqData['uid'],getNowDate()];
|
|
|
- mysql.usselect(p,function(result){
|
|
|
- if(result==1){
|
|
|
- res.Back(0,"添加成功",result)
|
|
|
- }else{
|
|
|
- res.Back(1,"添加失败",result)
|
|
|
- }
|
|
|
- })
|
|
|
+router.post("/CreateNewNotification",(req,res)=>{
|
|
|
+ QMysql(req,res,"insert_New")
|
|
|
})
|
|
|
|
|
|
//qgt 获取全站通知
|
|
|
router.get('/SelectNotification',(req,res)=>{
|
|
|
- //uid title nowPage lim
|
|
|
- const ReqData = GetData(req);
|
|
|
- let p = [_mysqlLabor[0], _mysqlLabor[1], 'select_NewByTitle',ReqData['title'],ReqData['nowPage'],ReqData['lim']];
|
|
|
- mysql.usselect(p,function(result){
|
|
|
- res.Back(0,"查询成功",result)
|
|
|
- })
|
|
|
+ QMysql(req,res,'select_NewByTitle')
|
|
|
})
|
|
|
|
|
|
//qgt 删除通知
|
|
|
router.post("/DeleteNotification",(req,res)=>{
|
|
|
- //uid nid
|
|
|
- const ReqData = GetData(req);
|
|
|
- const p = [_mysqlLabor[0], _mysqlLabor[1], 'update_NewStatusById',ReqData['nid']];
|
|
|
- mysql.usselect(p,(result)=>{
|
|
|
- if(result==1){
|
|
|
- res.Back(0,"成功删除一条通知",result);
|
|
|
- }else{
|
|
|
- res.Back(1,"删除通知失败",result);
|
|
|
- }
|
|
|
- })
|
|
|
+ QMysql(req,res,"update_NewStatusById");
|
|
|
})
|
|
|
|
|
|
//qgt 获取消息通知详细
|
|
|
router.get("/SelectNotificationDetail",(req,res)=>{
|
|
|
- //uid nid
|
|
|
- const ReqData = GetData(req);
|
|
|
- const p = [_mysqlLabor[0], _mysqlLabor[1], 'select_NewById',ReqData['nid']];
|
|
|
- mysql.usselect(p,(result)=>{
|
|
|
- if(result[0].length==1){
|
|
|
- res.Back(0,"成功获取消息详细",result[0][0]);
|
|
|
- }else{
|
|
|
- res.Back(1,"获取消息消息失败")
|
|
|
- }
|
|
|
- })
|
|
|
+ QMysql(req,res,"select_NewById");
|
|
|
})
|
|
|
|
|
|
|
|
@@ -112,22 +75,61 @@ GetData = function(req) {
|
|
|
var json = querystring.parse(a[1])
|
|
|
if(Object.keys(json).length!=0){
|
|
|
return json
|
|
|
- }else{
|
|
|
+ }else if(req.body){
|
|
|
return req.body
|
|
|
+ }else if(req.body.mode){
|
|
|
+ return req.body.mode;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-//post存儲過程處理
|
|
|
-postmysql = function(req, res, functionname) {
|
|
|
- //mode的處理
|
|
|
- if (req.body[0]) {
|
|
|
- p = Object.values(req.body[0]);
|
|
|
- p.unshift(_mysqlLabor[0], _mysqlLabor[1], functionname);
|
|
|
+//存储过程处理
|
|
|
+QMysql = function(req,res,functionName){
|
|
|
+ if (GetData(req)) {
|
|
|
+ p = Object.values(GetData(req));
|
|
|
+ p.unshift(_mysqlLabor[0], _mysqlLabor[1], functionName);
|
|
|
//執行存儲過程
|
|
|
mysql.usselect(p, function(ret) { res.end(JSON.stringify(ret)); });
|
|
|
+ }else{
|
|
|
+ res.end("未获取参数")
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+//post存儲過程處理
|
|
|
+// PostMysql = function(req, res, functionName) {
|
|
|
+// //mode的處理
|
|
|
+// if (GetData(req)) {
|
|
|
+// p = Object.values(GetData(req));
|
|
|
+// p.unshift(_mysqlLabor[0], _mysqlLabor[1], functionName);
|
|
|
+// //執行存儲過程
|
|
|
+// mysql.usselect(p, function(ret) { res.end(JSON.stringify(ret)); });
|
|
|
+// }else{
|
|
|
+// res.end("未获取参数")
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+// GetMysql = function(req,res,functionName){
|
|
|
+// if(GetData(req)){
|
|
|
+// p = Object.values(GetData(req));
|
|
|
+// p.unshift(_mysqlLabor[0], _mysqlLabor[1], functionName);
|
|
|
+// mysql.usselect(p, function(ret) { res.end(JSON.stringify(ret)); });
|
|
|
+
|
|
|
+// }else{
|
|
|
+// res.end("未获取参数")
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
+//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)); });
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
//post存儲過程處理
|
|
|
postmysql2 = function(req, res, functionname) {
|
|
|
//mode的處理
|
|
@@ -139,6 +141,14 @@ postmysql2 = function(req, res, functionname) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// router.route('/selectStudentCourseDetail').all((req, res, next) => { //学生
|
|
|
+// var json = queryString(req.url);
|
|
|
+// getmysql(req, res, "selectStudentCourseDetail", json['courseId']);
|
|
|
+// });
|
|
|
+// router.route('/addWorks').all((req, res, next) => {
|
|
|
+// postmysql(req, res, "add_works");
|
|
|
+// });
|
|
|
+
|
|
|
//post存儲過程處理
|
|
|
postmysql3 = function(req, res, functionname) {
|
|
|
//mode的處理
|
|
@@ -215,20 +225,20 @@ usergetmysql = function(req, res, functionname, ...p) {
|
|
|
|
|
|
|
|
|
//获取当前时间
|
|
|
-function getNowDate() {
|
|
|
- let date = new Date();
|
|
|
- let year = date.getFullYear(); //年
|
|
|
- let month = date.getMonth() + 1; //月
|
|
|
- let day = date.getDate(); //日
|
|
|
- let hour = date.getHours(); //时
|
|
|
- let minutes = date.getMinutes(); //分
|
|
|
- let seconds = date.getSeconds(); //秒
|
|
|
- if (month > 1 && month <= 9) month = "0" + month;
|
|
|
- if (day > 0 && day <= 9) day = "0" + day;
|
|
|
- if (hour > 0 && hour < 9) hour = "0" + hour;
|
|
|
- if (minutes > 0 && minutes <= 9) minutes = "0" + minutes;
|
|
|
- if (seconds > 0 && seconds < 9) seconds = "0" + seconds;
|
|
|
- return `${year}-${month}-${day} ${hour}:${minutes}:${seconds}`;
|
|
|
-}
|
|
|
+// function getNowDate() {
|
|
|
+// let date = new Date();
|
|
|
+// let year = date.getFullYear(); //年
|
|
|
+// let month = date.getMonth() + 1; //月
|
|
|
+// let day = date.getDate(); //日
|
|
|
+// let hour = date.getHours(); //时
|
|
|
+// let minutes = date.getMinutes(); //分
|
|
|
+// let seconds = date.getSeconds(); //秒
|
|
|
+// if (month > 1 && month <= 9) month = "0" + month;
|
|
|
+// if (day > 0 && day <= 9) day = "0" + day;
|
|
|
+// if (hour > 0 && hour < 9) hour = "0" + hour;
|
|
|
+// if (minutes > 0 && minutes <= 9) minutes = "0" + minutes;
|
|
|
+// if (seconds > 0 && seconds < 9) seconds = "0" + seconds;
|
|
|
+// return `${year}-${month}-${day} ${hour}:${minutes}:${seconds}`;
|
|
|
+// }
|
|
|
|
|
|
module.exports = router;
|