|
@@ -36,6 +36,39 @@ router.route('/a').all((req, res, next) => {
|
|
|
// postmysql(req, res, "b");
|
|
|
// });
|
|
|
|
|
|
+//qgt 查看数据库是否有此人
|
|
|
+router.use((req,res,next)=>{
|
|
|
+ const uid = req.body['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,"用户不存在",queryString(req.url))
|
|
|
+ }
|
|
|
+ })
|
|
|
+})
|
|
|
+
|
|
|
+//qgt 新增全站通知
|
|
|
+router.post('/CreateNewNotification',(req,res)=>{
|
|
|
+ //uid title brief
|
|
|
+ const ReqData = req.body;
|
|
|
+ //随机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)
|
|
|
+ }
|
|
|
+ })
|
|
|
+})
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
queryString = function(url) {
|
|
|
var a = url.split("?");
|
|
|
var json = querystring.parse(a[1])
|
|
@@ -94,7 +127,7 @@ userpostmysql = function(req, res, functionname) {
|
|
|
|
|
|
p = req.body.mode.split(",");
|
|
|
|
|
|
- p.unshift(_mysqluser[0], _mysqluser[1], functionname);
|
|
|
+ p.unshift(_mysqlLabor[0], _mysqlLabor[1], functionname);
|
|
|
|
|
|
//执行存储过程
|
|
|
|
|
@@ -112,7 +145,7 @@ usergetmysql = function(req, res, functionname, ...p) {
|
|
|
|
|
|
p = p || [];
|
|
|
|
|
|
- p.unshift(_mysqluser[0], _mysqluser[1], functionname);
|
|
|
+ p.unshift(_mysqlLabor[0], _mysqlLabor[1], functionname);
|
|
|
|
|
|
//执行存储过程
|
|
|
|
|
@@ -120,4 +153,21 @@ 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}`;
|
|
|
+}
|
|
|
+
|
|
|
module.exports = router;
|