|
@@ -28,165 +28,158 @@ function asynnext(req, res, next) {
|
|
|
|
|
|
//指定用户访问 CocoBlockly 的行为
|
|
//指定用户访问 CocoBlockly 的行为
|
|
router.route('/history').post((req, res, next) => {
|
|
router.route('/history').post((req, res, next) => {
|
|
- var _str = postmysql(req, res, "blockly_history");
|
|
|
|
- res.end(_str);
|
|
|
|
|
|
+ var _arr = [req.body.userid, req.body.username, 0, "history"];
|
|
|
|
+ postmysql(req, res, "blockly_history", _arr);
|
|
}).get((req, res, next) => {
|
|
}).get((req, res, next) => {
|
|
- var _str = getmysql(req, res, "blockly_history_get")
|
|
|
|
- res.end(_str);
|
|
|
|
|
|
+ getmysql(req, res, "blockly_history_get", req.params.username, "history")
|
|
});
|
|
});
|
|
|
|
|
|
//指定用户在 CocoBlockly 停留的总时间(离开的时候请求)
|
|
//指定用户在 CocoBlockly 停留的总时间(离开的时候请求)
|
|
router.route('/duration').post((req, res, next) => {
|
|
router.route('/duration').post((req, res, next) => {
|
|
- var _str = postmysql(req, res, "blockly_duration");
|
|
|
|
- res.end(_str);
|
|
|
|
|
|
+ var _arr = [req.body.userid, req.body.username, req.body.time, "duration"];
|
|
|
|
+ postmysql(req, res, "blockly_duration", _arr);
|
|
}).get((req, res, next) => {
|
|
}).get((req, res, next) => {
|
|
- var _str = getmysql(req, res, "blockly_duration_get")
|
|
|
|
- res.end(_str);
|
|
|
|
|
|
+ getmysql(req, res, "blockly_duration_get", req.params.username, "duration")
|
|
|
|
+
|
|
});
|
|
});
|
|
|
|
|
|
//指定用户打开实验室的行为
|
|
//指定用户打开实验室的行为
|
|
router.route('/labs').post((req, res, next) => {
|
|
router.route('/labs').post((req, res, next) => {
|
|
- var _str = postmysql(req, res, "blockly_labs");
|
|
|
|
- res.end(_str);
|
|
|
|
|
|
+ postmysql(req, res, "blockly_labs");
|
|
}).get((req, res, next) => {
|
|
}).get((req, res, next) => {
|
|
- var _str = getmysql(req, res, "blockly_labs_get")
|
|
|
|
- res.end(_str);
|
|
|
|
|
|
+ getmysql(req, res, "blockly_labs_get")
|
|
|
|
+
|
|
});
|
|
});
|
|
|
|
|
|
//指定用户打开某个样例的行为
|
|
//指定用户打开某个样例的行为
|
|
router.route('/examples').post((req, res, next) => {
|
|
router.route('/examples').post((req, res, next) => {
|
|
- var _str = postmysql(req, res, "blockly_examples");
|
|
|
|
- res.end(_str);
|
|
|
|
|
|
+ var _arr = [req.body.userid, req.body.username, "example", req.body.eventname, req.body.eventcontent];
|
|
|
|
+ postmysql(req, res, "blockly_examples", _arr);
|
|
}).get((req, res, next) => {
|
|
}).get((req, res, next) => {
|
|
- var _str = getmysql(req, res, "blockly_examples_get")
|
|
|
|
- res.end(_str);
|
|
|
|
|
|
+ getmysql(req, res, "blockly_examples_get", req.body.username, "example");
|
|
});
|
|
});
|
|
|
|
|
|
//指定用户切换上传模式的行为
|
|
//指定用户切换上传模式的行为
|
|
router.route('/mode_switch').post((req, res, next) => {
|
|
router.route('/mode_switch').post((req, res, next) => {
|
|
- var _str = postmysql(req, res, "blockly_mode_switch");
|
|
|
|
- res.end(_str);
|
|
|
|
|
|
+ var _arr = [req.body.userid, req.body.username, "modeswitch", req.body.eventname, req.body.eventcontent];
|
|
|
|
+ postmysql(req, res, "blockly_mode_switch", _arr);
|
|
}).get((req, res, next) => {
|
|
}).get((req, res, next) => {
|
|
- var _str = getmysql(req, res, "blockly_mode_switch_get")
|
|
|
|
- res.end(_str);
|
|
|
|
|
|
+ getmysql(req, res, "blockly_mode_switch_get", req.body.username, "modeswitch");
|
|
|
|
+
|
|
});
|
|
});
|
|
|
|
|
|
//指定用户点击串口监视窗按钮的行为
|
|
//指定用户点击串口监视窗按钮的行为
|
|
router.route('/serial_monitor').post((req, res, next) => {
|
|
router.route('/serial_monitor').post((req, res, next) => {
|
|
- var _str = postmysql(req, res, "blockly_serial_monitor");
|
|
|
|
- res.end(_str);
|
|
|
|
|
|
+ var _arr = [req.body.userid, req.body.username, "serialmonitor", req.body.eventname, req.body.eventcontent];
|
|
|
|
+ postmysql(req, res, "blockly_serial_monitor", _arr);
|
|
|
|
+
|
|
}).get((req, res, next) => {
|
|
}).get((req, res, next) => {
|
|
- var _str = getmysql(req, res, "blockly_serial_monitor_get")
|
|
|
|
- res.end(_str);
|
|
|
|
|
|
+ getmysql(req, res, "blockly_serial_monitor_get", req.body.username, "serialmonitor");
|
|
|
|
+
|
|
});
|
|
});
|
|
|
|
|
|
//指定用户点击复制源代码的行为
|
|
//指定用户点击复制源代码的行为
|
|
router.route('/copy').post((req, res, next) => {
|
|
router.route('/copy').post((req, res, next) => {
|
|
- var _str = postmysql(req, res, "blockly_copy");
|
|
|
|
- res.end(_str);
|
|
|
|
|
|
+ var _arr = [req.body.userid, req.body.username, "copy", req.body.eventname, req.body.eventcontent];
|
|
|
|
+ postmysql(req, res, "blockly_copy", _arr);
|
|
|
|
+
|
|
}).get((req, res, next) => {
|
|
}).get((req, res, next) => {
|
|
- var _str = getmysql(req, res, "blockly_copy_get")
|
|
|
|
- res.end(_str);
|
|
|
|
|
|
+ getmysql(req, res, "blockly_copy_get", req.body.username, "copy");
|
|
});
|
|
});
|
|
|
|
|
|
//指定用户点击运行的行为
|
|
//指定用户点击运行的行为
|
|
router.route('/upload_area/run').post((req, res, next) => {
|
|
router.route('/upload_area/run').post((req, res, next) => {
|
|
- var _str = postmysql(req, res, "blockly_upload_area_run");
|
|
|
|
- res.end(_str);
|
|
|
|
|
|
+ var _arr = [req.body.userid, req.body.username, "run", req.body.eventname, req.body.eventcontent];
|
|
|
|
+ postmysql(req, res, "blockly_upload_area_run", _arr);
|
|
}).get((req, res, next) => {
|
|
}).get((req, res, next) => {
|
|
- var _str = getmysql(req, res, "blockly_upload_area_run_get")
|
|
|
|
- res.end(_str);
|
|
|
|
|
|
+ getmysql(req, res, "blockly_upload_area_run_get", req.body.username, "run");
|
|
|
|
+
|
|
});
|
|
});
|
|
|
|
|
|
//指定用户点击上传的行为
|
|
//指定用户点击上传的行为
|
|
router.route('/upload_area/upload').post((req, res, next) => {
|
|
router.route('/upload_area/upload').post((req, res, next) => {
|
|
- var _str = postmysql(req, res, "blockly_upload_area_upload");
|
|
|
|
- res.end(_str);
|
|
|
|
|
|
+ var _arr = [req.body.userid, req.body.username, "upload", req.body.eventname, req.body.eventcontent];
|
|
|
|
+ postmysql(req, res, "blockly_upload_area_upload", _arr);
|
|
}).get((req, res, next) => {
|
|
}).get((req, res, next) => {
|
|
- var _str = getmysql(req, res, "blockly_upload_area_upload_get")
|
|
|
|
- res.end(_str);
|
|
|
|
|
|
+ getmysql(req, res, "blockly_upload_area_upload_get", req.body.username, "upload")
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
//指定用户在 Blockly 中弹出错误信息的行为(并报错错误信息)
|
|
//指定用户在 Blockly 中弹出错误信息的行为(并报错错误信息)
|
|
router.route('/upload_area/errormsg').post((req, res, next) => {
|
|
router.route('/upload_area/errormsg').post((req, res, next) => {
|
|
- var _str = postmysql(req, res, "blockly_upload_area_errormsg");
|
|
|
|
- res.end(_str);
|
|
|
|
|
|
+ var _arr = [req.body.userid, req.body.username, "errormsg", req.body.eventname, req.body.eventcontent];
|
|
|
|
+ postmysql(req, res, "blockly_upload_area_errormsg", _arr);
|
|
}).get((req, res, next) => {
|
|
}).get((req, res, next) => {
|
|
- var _str = getmysql(req, res, "blockly_upload_area_errormsg_get")
|
|
|
|
- res.end(_str);
|
|
|
|
|
|
+ getmysql(req, res, "blockly_upload_area_errormsg_get", req.body.username, "errormsg")
|
|
|
|
+
|
|
});
|
|
});
|
|
|
|
|
|
//指定用户将积木拖入编程区域的行为
|
|
//指定用户将积木拖入编程区域的行为
|
|
router.route('/blocks/to_workspace').post((req, res, next) => {
|
|
router.route('/blocks/to_workspace').post((req, res, next) => {
|
|
- var _str = postmysql(req, res, "blockly_blocks_to_workspace");
|
|
|
|
- res.end(_str);
|
|
|
|
|
|
+ postmysql(req, res, "blockly_blocks_to_workspace");
|
|
|
|
+
|
|
}).get((req, res, next) => {
|
|
}).get((req, res, next) => {
|
|
- var _str = getmysql(req, res, "blockly_blocks_to_workspace_get")
|
|
|
|
- res.end(_str);
|
|
|
|
|
|
+ getmysql(req, res, "blockly_blocks_to_workspace_get")
|
|
|
|
+
|
|
});
|
|
});
|
|
|
|
|
|
//指定用户将积木拖入编程区域的行为
|
|
//指定用户将积木拖入编程区域的行为
|
|
router.route('/blocks/out_workspace').post((req, res, next) => {
|
|
router.route('/blocks/out_workspace').post((req, res, next) => {
|
|
- var _str = postmysql(req, res, "blockly_blocks_out_workspace");
|
|
|
|
- res.end(_str);
|
|
|
|
|
|
+ postmysql(req, res, "blockly_blocks_out_workspace");
|
|
|
|
+
|
|
}).get((req, res, next) => {
|
|
}).get((req, res, next) => {
|
|
- var _str = getmysql(req, res, "blockly_blocks_out_workspace_get")
|
|
|
|
- res.end(_str);
|
|
|
|
|
|
+ getmysql(req, res, "blockly_blocks_out_workspace_get")
|
|
|
|
+
|
|
});
|
|
});
|
|
|
|
|
|
//指定用户导出文件的行为
|
|
//指定用户导出文件的行为
|
|
router.route('/files/local_export').post((req, res, next) => {
|
|
router.route('/files/local_export').post((req, res, next) => {
|
|
- var _str = postmysql(req, res, "blockly_files_local_export");
|
|
|
|
- res.end(_str);
|
|
|
|
|
|
+ var _arr = [req.body.userid, req.body.username, "local_export", req.body.eventname, req.body.eventcontent];
|
|
|
|
+ postmysql(req, res, "blockly_files_local_export", _arr);
|
|
}).get((req, res, next) => {
|
|
}).get((req, res, next) => {
|
|
- var _str = getmysql(req, res, "blockly_files_local_export_get")
|
|
|
|
- res.end(_str);
|
|
|
|
|
|
+ getmysql(req, res, "blockly_files_local_export_get", req.body.username, "local_export")
|
|
|
|
+
|
|
});
|
|
});
|
|
|
|
|
|
//指定用户导入文件的行为
|
|
//指定用户导入文件的行为
|
|
router.route('/files/local_import').post((req, res, next) => {
|
|
router.route('/files/local_import').post((req, res, next) => {
|
|
- var _str = postmysql(req, res, "blockly_files_local_import");
|
|
|
|
- res.end(_str);
|
|
|
|
|
|
+ var _arr = [req.body.userid, req.body.username, "local_import", req.body.eventname, req.body.eventcontent];
|
|
|
|
+ postmysql(req, res, "blockly_files_local_import", _arr);
|
|
}).get((req, res, next) => {
|
|
}).get((req, res, next) => {
|
|
- var _str = getmysql(req, res, "blockly_files_local_import_get")
|
|
|
|
- res.end(_str);
|
|
|
|
|
|
+ getmysql(req, res, "blockly_files_local_import_get", req.body.username, "local_export")
|
|
});
|
|
});
|
|
|
|
|
|
//指定用户创建指定云端文件的行为
|
|
//指定用户创建指定云端文件的行为
|
|
router.route('/files/cloud_create').post((req, res, next) => {
|
|
router.route('/files/cloud_create').post((req, res, next) => {
|
|
- var _str = postmysql(req, res, "blockly_files_cloud_create");
|
|
|
|
- res.end(_str);
|
|
|
|
|
|
+ var _arr = [req.body.userid, req.body.username, "cloud", req.body.eventname, req.body.eventcontent];
|
|
|
|
+ postmysql(req, res, "blockly_files_cloud_create", _arr);
|
|
}).get((req, res, next) => {
|
|
}).get((req, res, next) => {
|
|
- var _str = getmysql(req, res, "blockly_files_cloud_create_get")
|
|
|
|
- res.end(_str);
|
|
|
|
|
|
+ getmysql(req, res, "blockly_files_cloud_create_get", req.body.username, "cloudcreate");
|
|
});
|
|
});
|
|
|
|
|
|
//指定用户更新指定云端文件的行为
|
|
//指定用户更新指定云端文件的行为
|
|
router.route('/files/cloud_update').post((req, res, next) => {
|
|
router.route('/files/cloud_update').post((req, res, next) => {
|
|
- var _str = postmysql(req, res, "blockly_files_cloud_update");
|
|
|
|
- res.end(_str);
|
|
|
|
|
|
+ var _arr = [req.body.userid, req.body.username, "cloud", req.body.eventname, req.body.eventcontent];
|
|
|
|
+ postmysql(req, res, "blockly_files_cloud_update", _arr);
|
|
|
|
+
|
|
}).get((req, res, next) => {
|
|
}).get((req, res, next) => {
|
|
- var _str = getmysql(req, res, "blockly_files_cloud_update_get")
|
|
|
|
- res.end(_str);
|
|
|
|
|
|
+ getmysql(req, res, "blockly_files_cloud_update_get", req.body.username, "cloudupdate");
|
|
});
|
|
});
|
|
|
|
|
|
//指定用户打开指定云端文件的行为
|
|
//指定用户打开指定云端文件的行为
|
|
router.route('/files/cloud_open').post((req, res, next) => {
|
|
router.route('/files/cloud_open').post((req, res, next) => {
|
|
- var _str = postmysql(req, res, "blockly_files_cloud_open");
|
|
|
|
- res.end(_str);
|
|
|
|
|
|
+ var _arr = [req.body.userid, req.body.username, "cloud", req.body.eventname, req.body.eventcontent];
|
|
|
|
+ postmysql(req, res, "blockly_files_cloud_open", _arr);
|
|
}).get((req, res, next) => {
|
|
}).get((req, res, next) => {
|
|
- var _str = getmysql(req, res, "blockly_files_cloud_open_get")
|
|
|
|
- res.end(_str);
|
|
|
|
|
|
+ getmysql(req, res, "blockly_files_cloud_open_get", req.body.username, "cloudopen");
|
|
});
|
|
});
|
|
|
|
|
|
//指定用户删除指定云端文件的行为
|
|
//指定用户删除指定云端文件的行为
|
|
router.route('/files/cloud_delete').post((req, res, next) => {
|
|
router.route('/files/cloud_delete').post((req, res, next) => {
|
|
- var _str = postmysql(req, res, "blockly_files_cloud_delete");
|
|
|
|
- res.end(_str);
|
|
|
|
|
|
+ var _arr = [req.body.userid, req.body.username, "cloud", req.body.eventname, req.body.eventcontent];
|
|
|
|
+ postmysql(req, res, "blockly_files_cloud_delete", _arr);
|
|
}).get((req, res, next) => {
|
|
}).get((req, res, next) => {
|
|
- var _str = getmysql(req, res, "blockly_files_cloud_delete_get")
|
|
|
|
- res.end(_str);
|
|
|
|
|
|
+ getmysql(req, res, "blockly_files_cloud_delete_get", req.body.username, "clouddelete");
|
|
});
|
|
});
|
|
|
|
|
|
queryString = function (url) {
|
|
queryString = function (url) {
|
|
@@ -196,14 +189,11 @@ queryString = function (url) {
|
|
}
|
|
}
|
|
|
|
|
|
//post存儲過程處理
|
|
//post存儲過程處理
|
|
-postmysql = function (req, res, functionname) {
|
|
|
|
|
|
+postmysql = function (req, res, functionname, arr) {
|
|
//mode的處理
|
|
//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)); });
|
|
|
|
- }
|
|
|
|
|
|
+ arr.unshift(_mysqlLabor[0], _mysqlLabor[1], functionname);
|
|
|
|
+ //執行存儲過程
|
|
|
|
+ mysql.usselect(arr, function (ret) { res.end(JSON.stringify(ret)); });
|
|
}
|
|
}
|
|
|
|
|
|
//get獲取數據庫信息
|
|
//get獲取數據庫信息
|
|
@@ -213,7 +203,7 @@ getmysql = function (req, res, functionname, ...p) {
|
|
//執行存儲過程
|
|
//執行存儲過程
|
|
mysql.usselect(p, function (ret) {
|
|
mysql.usselect(p, function (ret) {
|
|
res.end(JSON.stringify(ret));
|
|
res.end(JSON.stringify(ret));
|
|
- }); //
|
|
|
|
|
|
+ });
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|