pbl.js 66 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919
  1. // ROUTES FOR OUR API
  2. // =============================================================================
  3. var express = require('express');
  4. var bcrypt = require('bcryptjs');
  5. var router = express.Router(); // get an instance of the express Router
  6. const querystring = require('querystring');
  7. var mysql = require('./mysql');
  8. // const _mysqlLabor = ["123.58.32.151", "pbl"]; //edu數據庫信息
  9. // const _mysqluser = ["123.58.32.151", "cocorobouser"]; //用户数据库信息
  10. const _mysqlLabor = ["172.16.12.5", "pbl"]; //edu數據庫信息
  11. const _mysqluser = ["172.16.12.5", "cocorobouser"]; //edu數據庫信息
  12. var crypto = require('crypto');
  13. var https = require('https');
  14. //統壹處理區域
  15. router.use(async function(req, res, next) {
  16. await asynnext(req, res, next);
  17. //// make sure we go to the next routes and don't stop here
  18. //res.end("");
  19. });
  20. /**
  21. * @des 參數解釋同上
  22. */
  23. function asynnext(req, res, next) {
  24. //異步處理
  25. return new Promise(async(resolve, reject) => {
  26. next();
  27. //resolve(true);aa
  28. });
  29. }
  30. /*測試*/
  31. router.route('/a').all((req, res, next) => {
  32. var json = queryString(req.url);
  33. getmysql(req, res, "a", json['ph'], json['pa']);
  34. });
  35. router.route('/b').all((req, res, next) => {
  36. var json = queryString(req.url);
  37. getmysql(req, res, "b", json['ph'], json['pa']);
  38. });
  39. /* 注册接口 */
  40. router.route('/register').post(function(req, res, next) {
  41. //mode的处理
  42. if (req.body[0]) {
  43. // 0 用户名 1 用户密码 2用户身份 3 第三方id(可有可无)
  44. p = Object.values(req.body[0]); //获取用户密码
  45. //没有第三方id的处理
  46. // if (p.length < 4) {
  47. // p.push("")
  48. // }
  49. p[1] = bcrypt.hashSync(p[1], bcrypt.genSaltSync(10));
  50. //密码加密
  51. // bcrypt.hash(p[1], 10, function (err, hash) {
  52. // if (err) {
  53. // return next(err);
  54. // }
  55. // p[1] = hash;
  56. // });
  57. //参数拼接,注册
  58. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "register");
  59. //返回注册用户数据
  60. // mysql.usselect(p, function (ret) {
  61. // res.end(ret);
  62. // });
  63. mysql.usselect(p, function(ret) {
  64. res.end(JSON.stringify(ret));
  65. });
  66. }
  67. });
  68. /*登录接口*/
  69. router.route('/login').all((req, res, next) => {
  70. //mode的处理
  71. if (req.body[0]) {
  72. // 0 用户名 1 用户密码
  73. c = Object.values(req.body[0]); //获取用户密码
  74. p = [c[0]]
  75. // p[1] = bcrypt.hashSync(p[1], bcrypt.genSaltSync(10));
  76. var _password = [c[0]];
  77. _password.unshift(_mysqlLabor[0], _mysqlLabor[1], "selectPassword");
  78. mysql.usselect(_password, function(ret) {
  79. var _ret = ret
  80. var paJ = _ret[0][0].userpassword
  81. bcrypt.compare(c[1], paJ, function(err, result) {
  82. // console.log(result)
  83. if (result) {
  84. //参数拼接,登录
  85. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "selectLogin");
  86. //执行存储过程
  87. mysql.usselect(p, function(ret) {
  88. res.end(JSON.stringify({ status: "1", ...ret }));
  89. });
  90. } else {
  91. res.end(JSON.stringify([{ status: "0" }]));
  92. }
  93. })
  94. });
  95. // console.log(isEqual)
  96. }
  97. });
  98. /*登录接口*/
  99. router.route('/imgToBase64').all((req, res, next) => {
  100. var json = queryString(req.url);
  101. //mode的处理
  102. https.get(json['img'], function (res2) {
  103. var chunks = [];
  104. var size = 0;
  105. res2.on('data', function (chunk) {
  106. chunks.push(chunk);
  107. size += chunk.length;  //累加缓冲数据的长度
  108. });
  109. res2.on('end', function (err) {
  110. var data = Buffer.concat(chunks, size);
  111. var base64Img = data.toString('base64');
  112. res.end(JSON.stringify([{ img: `data:image/png;base64,${base64Img}` }]));
  113. });
  114. });
  115. });
  116. /*登录接口*/
  117. router.route('/loginRace').all((req, res, next) => {
  118. //mode的处理
  119. if (req.body[0]) {
  120. // 0 用户名 1 用户密码
  121. c = Object.values(req.body[0]); //获取用户密码
  122. p = [c[0]]
  123. // p[1] = bcrypt.hashSync(p[1], bcrypt.genSaltSync(10));
  124. var _password = [c[0]];
  125. _password.unshift(_mysqlLabor[0], _mysqlLabor[1], "selectPasswordRace");
  126. mysql.usselect(_password, function(ret) {
  127. var _ret = ret
  128. var paJ = _ret[0][0].password
  129. bcrypt.compare(c[1], paJ, function(err, result) {
  130. // console.log(result)
  131. if (result) {
  132. //参数拼接,登录
  133. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "selectLoginRace");
  134. //执行存储过程
  135. mysql.usselect(p, function(ret) {
  136. res.end(JSON.stringify({ status: "1", ...ret }));
  137. });
  138. } else {
  139. res.end(JSON.stringify([{ status: "0" }]));
  140. }
  141. })
  142. });
  143. // console.log(isEqual)
  144. }
  145. });
  146. /* 修改密码接口 */
  147. router.route('/updatePassword').post(function(req, res, next) {
  148. //mode的处理
  149. if (req.body[0]) {
  150. let p = [req.body[0].userid];
  151. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "getPassword"); //執行存儲過程
  152. mysql.usselect(p, function(ret) {
  153. var paJ = ret[0][0].password
  154. var op = bcrypt.hashSync(req.body[0].opassword, bcrypt.genSaltSync(10));
  155. bcrypt.compare(req.body[0].opassword, paJ, function(err, result) {
  156. // console.log(result)
  157. if (result) {
  158. let p2 = [req.body[0].userid, bcrypt.hashSync(req.body[0].password, bcrypt.genSaltSync(10))];
  159. p2.unshift(_mysqlLabor[0], _mysqlLabor[1], "updatePassword"); //執行存儲過程
  160. mysql.usselect(p2, function(ret) {
  161. res.end(JSON.stringify([{ success: 1 }]));
  162. });
  163. } else {
  164. res.end(JSON.stringify([{ success: 0 }]));
  165. }
  166. })
  167. });
  168. }
  169. });
  170. /* 找寻重复手机号 */
  171. router.route('/findPhone').all((req, res, next) => {
  172. var json = queryString(req.url);
  173. getmysql(req, res, "findPhone", json['un']);
  174. });
  175. /* 找寻是否有此账号 */
  176. router.route('/findUsername').all((req, res, next) => {
  177. var json = queryString(req.url);
  178. getmysql(req, res, "findUsername", json['un']);
  179. });
  180. /* 找寻重复邮箱 */
  181. router.route('/findMail').all((req, res, next) => {
  182. var json = queryString(req.url);
  183. usergetmysql(req, res, "findMail", json['un']);
  184. });
  185. /* 找寻重复学号 */
  186. router.route('/findSid').all((req, res, next) => {
  187. var json = queryString(req.url);
  188. getmysql(req, res, "findSid", json['un']);
  189. });
  190. /* 新增班级 */
  191. router.route('/insertClass').all((req, res, next) => {
  192. var json = queryString(req.url);
  193. getmysql(req, res, "insertClass", json['name'], json['oid'], json['uid']);
  194. });
  195. /* 查询班级 */
  196. router.route('/selectClass').all((req, res, next) => {
  197. var json = queryString(req.url);
  198. getmysql(req, res, "selectClass", json['cu'], json['oid'], json['cn'], json['page'], 10);
  199. });
  200. /* 删除班级 */
  201. router.route('/deleteClass').all((req, res, next) => {
  202. var json = queryString(req.url);
  203. getmysql(req, res, "deleteClass", json['id']);
  204. });
  205. /* 查询学校 */
  206. router.route('/selectOrg').all((req, res, next) => {
  207. var json = queryString(req.url);
  208. getmysql(req, res, "selectOrg");
  209. });
  210. /* 查询组织 */
  211. router.route('/selectorg2').all((req, res, next) => {
  212. var json = queryString(req.url);
  213. getmysql(req, res, "selectorg2");
  214. });
  215. /* 修改学校名称 */
  216. router.route('/updateSN').all((req, res, next) => {
  217. var json = queryString(req.url);
  218. getmysql(req, res, "updateSchoolName", json["oid"], json["n"]);
  219. });
  220. /* 新增学生 */
  221. router.route('/insertStudent').all((req, res, next) => {
  222. var json = queryString(req.url);
  223. json['userpassword'] = bcrypt.hashSync(json['userpassword'], bcrypt.genSaltSync(10))
  224. getmysql(req, res, "insertStudent", json['ph'], json['username'], json['userpassword'], json['type'], json['oid'], json['tid'], json['cid']);
  225. });
  226. // /* 新增学生 */
  227. // router.route('/iStudent').all((req, res, next) => {
  228. // var json = queryString(req.url);
  229. // json['userpassword'] = bcrypt.hashSync(json['userpassword'], bcrypt.genSaltSync(10))
  230. // getmysql(req, res, "insertStudent", json['ph'], json['username'], json['userpassword'], json['type'], json['oid'], json['tid'], json['cid']);
  231. // });
  232. /* 查询学生 */
  233. router.route('/selectStudent').all((req, res, next) => {
  234. var json = queryString(req.url);
  235. getmysql(req, res, "selectStudent", json['oid'], json['cu'], json['cn'], json['page'], 8);
  236. });
  237. /* ppt根据学校查询学生 */
  238. router.route('/selectStudentByScoolPPt').all((req, res, next) => {
  239. var json = queryString(req.url);
  240. getmysql(req, res, "selectStudentByScoolPPt", json['oid'], json['cid']);
  241. });
  242. /* 查询项目 */
  243. router.route('/selectStudentAdd').all((req, res, next) => {
  244. var json = queryString(req.url);
  245. getmysql(req, res, "selectStudentAdd", json['oid'], json['cu'], json['cn']);
  246. });
  247. /* 查询老师 */
  248. router.route('/selectTeacherAdd').all((req, res, next) => {
  249. var json = queryString(req.url);
  250. getmysql(req, res, "selectTeacherAdd", json['oid'], json['cu'], json['cn']);
  251. });
  252. /* 查询老师 */
  253. router.route('/selectTeacherAddOrg').all((req, res, next) => {
  254. var json = queryString(req.url);
  255. getmysql(req, res, "selectTeacherAddOrg", json['oid'], json['cu'], json['cn']);
  256. });
  257. /* 查询班级是否有重复 */
  258. router.route('/selectC').all((req, res, next) => {
  259. var json = queryString(req.url);
  260. getmysql(req, res, "selectC", json['className']);
  261. });
  262. /* 查询学校是否有重复 */
  263. router.route('/selectS').all((req, res, next) => {
  264. var json = queryString(req.url);
  265. getmysql(req, res, "selectS", json['schoolName']);
  266. });
  267. /* 修改个人信息 */
  268. router.route('/updateUser').all((req, res, next) => {
  269. postmysql(req, res, "updateUser");
  270. });
  271. //查询老师的信息
  272. router.route('/getUser').all((req, res, next) => {
  273. var json = queryString(req.url);
  274. getmysql(req, res, "selectUserDeail", json['uid']);
  275. });
  276. router.route('/selectUser').all((req, res, next) => {
  277. var json = queryString(req.url);
  278. getmysql(req, res, "selectUser", json['userid']);
  279. });
  280. //查询教师端消息
  281. router.route('/getNewsTeacher').all((req, res, next) => {
  282. var json = queryString(req.url);
  283. getmysql(req, res, "selectNew", json['uid'], json['page'], 10);
  284. });
  285. //查询通知详情
  286. router.route('/selectNewDetail').all((req, res, next) => {
  287. var json = queryString(req.url);
  288. getmysql(req, res, "selectNewDetail", json['nid']);
  289. });
  290. //查出分组分类
  291. router.route('/getGroup').all((req, res, next) => {
  292. getmysql(req, res, "selectGroupTeacher");
  293. });
  294. //查询这个老师底下的学生提交的作业
  295. router.route('/getWorks').all((req, res, next) => {
  296. var json = queryString(req.url);
  297. getmysql(req, res, "selectWorks", json['cn'], json['cid'], json['page'], 10);
  298. });
  299. //查询项目
  300. router.route('/getProject').all((req, res, next) => {
  301. var json = queryString(req.url);
  302. getmysql(req, res, "selectProject", json['type'], json['uid'], json['oid'], json['cn'], json['page'], 10);
  303. });
  304. //查询项目
  305. router.route('/getMyProject').all((req, res, next) => {
  306. var json = queryString(req.url);
  307. getmysql(req, res, "selectMyProject", json['uid'], json['page'], 10);
  308. });
  309. //查询项目成员
  310. router.route('/selectProjectStudent').all((req, res, next) => {
  311. var json = queryString(req.url);
  312. getmysql(req, res, "select_student", json['cn'], json['oid'], json['uid']);
  313. });
  314. //查询Banner列表
  315. router.route('/selectBannerList').all((req, res, next) => {
  316. var json = queryString(req.url);
  317. getmysql(req, res, "selectBannerList", json['page'], 10);
  318. });
  319. //查询Banner列表
  320. router.route('/selectAllBanner').all((req, res, next) => {
  321. var json = queryString(req.url);
  322. getmysql(req, res, "selectAllBanner", json["t"]);
  323. });
  324. //新增Banner
  325. router.route('/insertBannerList').all((req, res, next) => {
  326. postmysql(req, res, "insertBannerList");
  327. });
  328. //删除提交的作业
  329. router.route('/deleteCourseWork').all((req, res, next) => {
  330. postmysql(req, res, "deleteCourseWork");
  331. });
  332. //删除Banner
  333. router.route('/deleteBannerList').all((req, res, next) => {
  334. var json = queryString(req.url);
  335. getmysql(req, res, "deleteBannerList", json['id']);
  336. });
  337. //新增课程
  338. router.route('/addWork').all((req, res, next) => {
  339. postmysql(req, res, "insert_teacher_work");
  340. });
  341. //点赞评论
  342. router.route('/insertComment').all((req, res, next) => {
  343. postmysql(req, res, "insertComment");
  344. });
  345. //取消点赞
  346. router.route('/deleteComment').all((req, res, next) => {
  347. var json = queryString(req.url);
  348. getmysql(req, res, "deleteComment", json['wid'], json['lid']);
  349. });
  350. //上传批注图片
  351. router.route('/updateCourseWorks').all((req, res, next) => {
  352. postmysql(req, res, "updateCourseWorks");
  353. });
  354. //上传文件
  355. router.route('/addCourseWorks').all((req, res, next) => {
  356. postmysql(req, res, "addCourseWorks");
  357. });
  358. //上传文件
  359. router.route('/addCourseWorks2').all((req, res, next) => {
  360. var json = queryString(req.url);
  361. getmysql(req, res, "addCourseWorks", json['uid'], json['cid'], json['stage'], json['task'], json['tool'], json['content'], json['type']);
  362. });
  363. //修改课程权限(学生是否能查看所有作业)
  364. router.route('/updateCourseSLook').all((req, res, next) => {
  365. var json = queryString(req.url);
  366. getmysql(req, res, "updateCourseSLook", json['sopen'], json['cid']);
  367. });
  368. //修改阶段锁定状态
  369. router.route('/updateCourseLookOpen').all((req, res, next) => {
  370. postmysql(req, res, "updateCourseLookOpen");
  371. });
  372. //查看阶段锁定的状态
  373. router.route('/getCourseState').all((req, res, next) => {
  374. var json = queryString(req.url);
  375. getmysql(req, res, "getCourseState", json['cid']);
  376. });
  377. //添加锁定状态
  378. router.route('/addCourseState').all((req, res, next) => {
  379. postmysql(req, res, "addCourseState");
  380. });
  381. //修改锁定状态
  382. router.route('/updateCourseSate').all((req, res, next) => {
  383. postmysql(req, res, "updateCourseSate");
  384. });
  385. //查询课程权限(学生是否能查看所有作业)
  386. router.route('/selectCourseSLook').all((req, res, next) => {
  387. var json = queryString(req.url);
  388. getmysql(req, res, "selectCourseSLook", json['cid']);
  389. });
  390. //查询作业详情
  391. router.route('/selectWorksDetail2').all((req, res, next) => {
  392. var json = queryString(req.url);
  393. getmysql(req, res, "selectWorksDetail2", json['uid'], json['cid'], json['stage'], json['task']);
  394. });
  395. //查询课程全部作业详情
  396. router.route('/selectWorksDetail3').all((req, res, next) => {
  397. var json = queryString(req.url);
  398. getmysql(req, res, "selectWorksDetail3", json['uid'], json['cid']);
  399. });
  400. //学习中心教师查询作业
  401. router.route('/selectSWorks').all((req, res, next) => {
  402. var json = queryString(req.url);
  403. getmysql(req, res, "selectSWorks", json['cid'], json['s'], json['t']);
  404. });
  405. //学习中心教师查询作业全部展示
  406. router.route('/selectSWorks2').all((req, res, next) => {
  407. var json = queryString(req.url);
  408. getmysql(req, res, "selectSWorks2", json['cid']);
  409. });
  410. //学习中心学生查询作业
  411. router.route('/selectStudentWorks').all((req, res, next) => {
  412. var json = queryString(req.url);
  413. getmysql(req, res, "selectStudentWorks", json['uid'], json['cid'], json['s'], json['t']);
  414. });
  415. //实时课堂作业评价
  416. router.route('/updateStudentWork').all((req, res, next) => {
  417. postmysql(req, res, "updateStudentWork");
  418. });
  419. //学习中心查询学生
  420. router.route('/selectWorksStudent').all((req, res, next) => {
  421. var json = queryString(req.url);
  422. getmysql(req, res, "selectWorksStudent", json['oid'], json['cid']);
  423. });
  424. /* 查询学生 */
  425. router.route('/selectStudent2').all((req, res, next) => {
  426. var json = queryString(req.url);
  427. getmysql(req, res, "selectStudent2", json['oid'], json['cu'], json['cn'], json['cid'], json['page'], 8);
  428. });
  429. /* 查询所有评价体系 */
  430. router.route('/selectAllEvaluation').all((req, res, next) => {
  431. var json = queryString(req.url);
  432. getmysql(req, res, "selectAllEvaluation", json['oid']);
  433. });
  434. router.route('/addWorkNew').all((req, res, next) => {
  435. // postmysql(req, res, "insert_teacher_work_new");
  436. if (req.body[0]) {
  437. // p = Object.values(req.body[0]);
  438. p = [req.body[0].uid, req.body[0].title, req.body[0].brief, req.body[0].cover, req.body[0].astudent, req.body[0].see, req.body[0].chapters, req.body[0].template];
  439. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "insert_teacher_work_new");
  440. //執行存儲過程
  441. mysql.usselect(p, function(ret) {
  442. let course = req.body[0].courseType;
  443. let courseId = ret[0][0].courseId;
  444. let userid = req.body[0].uid;
  445. delCourseType(course, courseId, userid);
  446. res.end(JSON.stringify({ ordernumber: ret[0][0].ordernumber, courseId: ret[0][0].courseId, success: 1 }));
  447. // res.end(JSON.stringify(ret));
  448. });
  449. }
  450. });
  451. router.route('/addWorkNew2').all((req, res, next) => {
  452. if (req.body[0]) {
  453. p = [req.body[0].uid, req.body[0].title, req.body[0].brief, req.body[0].cover, req.body[0].evaId, req.body[0].astudent, req.body[0].see, req.body[0].chapters, req.body[0].template, req.body[0].ateacher];
  454. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "insert_teacher_work_new2"); //執行存儲過程
  455. mysql.usselect(p, function(ret) {
  456. let course = req.body[0].courseType;
  457. let courseId = ret[0][0].courseId;
  458. let userid = req.body[0].uid;
  459. delCourseType(course, courseId, userid);
  460. res.end(JSON.stringify({ ordernumber: ret[0][0].ordernumber, courseId: ret[0][0].courseId, success: 1 }));
  461. });
  462. }
  463. });
  464. //新增赛事项目
  465. router.route('/addRace').all((req, res, next) => {
  466. if (req.body[0]) {
  467. p = [req.body[0].uid, req.body[0].info, req.body[0].over, req.body[0].pro, req.body[0].act, req.body[0].exc, req.body[0].res];
  468. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "addRace"); //執行存儲過程
  469. mysql.usselect(p, function(ret) {
  470. let course = req.body[0].courseType;
  471. let courseId = ret[0][0].id;
  472. let userid = req.body[0].uid;
  473. delCourseType1(course, courseId, userid);
  474. res.end(JSON.stringify({ success: 1 }));
  475. });
  476. }
  477. });
  478. //新增赛事账号信息
  479. router.route('/addRaceUser').all((req, res, next) => {
  480. if (req.body[0]) {
  481. p = [req.body[0].reg, req.body[0].res, req.body[0].sch, req.body[0].n, req.body[0].p];
  482. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "addRaceUser"); //執行存儲過程
  483. mysql.usselect(p, function(ret) {
  484. let num = ret[0][0].num;
  485. let userid = ret[0][0].userid;
  486. if (num < 10) {
  487. num = "SZ" + "00" + num + "@gdae.com";
  488. } else if (num < 100) {
  489. num = "SZ" + "0" + num + "@gdae.com";
  490. } else if (num > 100) {
  491. num = "SZ" + num + "@gdae.com";
  492. }
  493. y = [userid, num, bcrypt.hashSync("123456", bcrypt.genSaltSync(10))];
  494. //参数拼接,注册
  495. y.unshift(_mysqlLabor[0], _mysqlLabor[1], "upRaceUserNamePassword");
  496. mysql.usselect(y, function(ret) {
  497. res.end(JSON.stringify(ret));
  498. });
  499. res.end(JSON.stringify({ num: num, success: 1 }));
  500. });
  501. }
  502. });
  503. //修改赛事项目
  504. router.route('/updateRace').all((req, res, next) => {
  505. if (req.body[0]) {
  506. p = [req.body[0].id, req.body[0].info, req.body[0].over, req.body[0].pro, req.body[0].act, req.body[0].exc, req.body[0].res];
  507. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "updateRace"); //執行存儲過程
  508. mysql.usselect(p, function(ret) {
  509. let course = req.body[0].courseType;
  510. let courseId = req.body[0].id;
  511. let userid = req.body[0].uid;
  512. delCourseType1(course, courseId, userid);
  513. res.end(JSON.stringify({ success: 1 }));
  514. });
  515. }
  516. });
  517. router.route('/addWorkNew3').all((req, res, next) => {
  518. if (req.body[0]) {
  519. p = [req.body[0].uid, req.body[0].title, req.body[0].brief, req.body[0].cover, req.body[0].astudent, req.body[0].see, req.body[0].chapters, req.body[0].template, req.body[0].ateacher];
  520. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "insert_teacher_work_new3"); //執行存儲過程
  521. mysql.usselect(p, function(ret) {
  522. let course = req.body[0].courseType;
  523. let courseId = ret[0][0].courseId;
  524. let userid = req.body[0].uid;
  525. delCourseType(course, courseId, userid);
  526. res.end(JSON.stringify({ ordernumber: ret[0][0].ordernumber, courseId: ret[0][0].courseId, success: 1 }));
  527. });
  528. }
  529. });
  530. function delCourseType(course, courseId, userid) {
  531. let _courseId = courseId;
  532. var _userdata = [
  533. _courseId
  534. ];
  535. _userdata.unshift(_mysqlLabor[0], _mysqlLabor[1], "delete_courseType");
  536. mysql.usselect(_userdata, function(ret) {
  537. // console.log(ret);
  538. });
  539. setTimeout(() => {
  540. addCourseType(userid, course, _courseId)
  541. }, 1000);
  542. }
  543. function delCourseType1(course, courseId, userid) {
  544. let _courseId = courseId;
  545. var _userdata = [
  546. _courseId
  547. ];
  548. _userdata.unshift(_mysqlLabor[0], _mysqlLabor[1], "delete_courseType1");
  549. mysql.usselect(_userdata, function(ret) {
  550. // console.log(ret);
  551. });
  552. setTimeout(() => {
  553. addCourseType1(userid, course, _courseId)
  554. }, 1000);
  555. }
  556. function addCourseType(userid, course, _courseId) {
  557. var _uid = userid;
  558. var _courses = _courseId
  559. var _tid = JSON.parse(course)
  560. for (let i = 0; i < _tid.length; i++) {
  561. if (_tid[i] == '') {
  562. continue;
  563. }
  564. var _userdata = [
  565. _courses,
  566. _tid[i],
  567. _uid,
  568. ];
  569. _userdata.unshift(_mysqlLabor[0], _mysqlLabor[1], "add_courseType");
  570. mysql.usselect(_userdata, function(ret) {
  571. // console.log(ret);
  572. });
  573. }
  574. }
  575. function addCourseType1(userid, course, _courseId) {
  576. var _uid = userid;
  577. var _courses = _courseId
  578. var _tid = JSON.parse(course)
  579. for (let i = 0; i < _tid.length; i++) {
  580. if (_tid[i] == '') {
  581. continue;
  582. }
  583. var _userdata = [
  584. _courses,
  585. _tid[i],
  586. _uid,
  587. ];
  588. _userdata.unshift(_mysqlLabor[0], _mysqlLabor[1], "add_courseType1");
  589. mysql.usselect(_userdata, function(ret) {
  590. // console.log(ret);
  591. });
  592. }
  593. }
  594. //修改课程
  595. // router.route('/updateWork').all((req, res, next) => {
  596. // postmysql(req, res, "update_teacher_work");
  597. // });
  598. router.route('/updateWorkNew').all((req, res, next) => {
  599. if (req.body[0]) {
  600. // p = Object.values(req.body[0]);
  601. p = [req.body[0].cid, req.body[0].title, req.body[0].brief, req.body[0].cover, req.body[0].astudent, req.body[0].see, req.body[0].chapters, req.body[0].template];
  602. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "update_teacher_work_new");
  603. //執行存儲過程
  604. mysql.usselect(p, function(ret) {
  605. let course = req.body[0].courseType;
  606. let courseId = req.body[0].cid;
  607. let userid = req.body[0].uid;
  608. delCourseType(course, courseId, userid);
  609. res.end(JSON.stringify({ success: 1 }));
  610. // res.end(JSON.stringify(ret));
  611. });
  612. }
  613. });
  614. //查询课程
  615. // router.route('/selectCourse').all((req, res, next) => {
  616. // var json = queryString(req.url);
  617. // getmysql(req, res, "select_course", json['type'], json['uid'], json['oid'], json['page'], 10);
  618. // });
  619. router.route('/updateWorkNew2').all((req, res, next) => {
  620. // if (req.body[0]) {
  621. // p = [req.body[0].cid, req.body[0].title, req.body[0].brief, req.body[0].cover,req.body[0].evaId, req.body[0].astudent, req.body[0].see, req.body[0].chapters, req.body[0].template];
  622. // p.unshift(_mysqlLabor[0], _mysqlLabor[1], "update_teacher_work_new2"); //執行存儲過程
  623. // mysql.usselect(p, function(ret) {
  624. // let course = req.body[0].courseType;
  625. // let courseId = req.body[0].cid;
  626. // let userid = req.body[0].uid;
  627. // delCourseType(course, courseId, userid);
  628. // res.end(JSON.stringify({ success: 1 }));
  629. // });
  630. // }
  631. if (req.body[0]) {
  632. p = [req.body[0].cid, req.body[0].title, req.body[0].brief, req.body[0].cover, req.body[0].evaId, req.body[0].astudent, req.body[0].see, req.body[0].chapters, req.body[0].template, req.body[0].ateacher];
  633. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "update_teacher_work_new2"); //執行存儲過程
  634. mysql.usselect(p, function(ret) {
  635. let course = req.body[0].courseType;
  636. let courseId = req.body[0].cid;
  637. let userid = req.body[0].uid;
  638. delCourseType(course, courseId, userid);
  639. res.end(JSON.stringify({ success: 1 }));
  640. });
  641. }
  642. });
  643. router.route('/updateWorkNew3').all((req, res, next) => {
  644. if (req.body[0]) {
  645. p = [req.body[0].cid, req.body[0].title, req.body[0].brief, req.body[0].cover, req.body[0].astudent, req.body[0].see, req.body[0].chapters, req.body[0].template, req.body[0].ateacher];
  646. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "update_teacher_work_new3"); //執行存儲過程
  647. mysql.usselect(p, function(ret) {
  648. let course = req.body[0].courseType;
  649. let courseId = req.body[0].cid;
  650. let userid = req.body[0].uid;
  651. delCourseType(course, courseId, userid);
  652. res.end(JSON.stringify({ success: 1 }));
  653. });
  654. }
  655. });
  656. function guid() {
  657. var _num,
  658. i,
  659. _guid = "";
  660. for (i = 0; i < 32; i++) {
  661. _guid += Math.floor(Math.random() * 16).toString(16); //随机0 - 16 的数字 转变为16进制的字符串
  662. _num = Math.floor((i - 7) / 4); //计算 (i-7)除4
  663. if (_num > -1 && _num < 4 && i == 7 + 4 * _num) {
  664. //会使guid中间加 "-" 形式为xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
  665. _guid += "-";
  666. }
  667. }
  668. return _guid;
  669. }
  670. router.route('/updateWorkNew4').all((req, res, next) => {
  671. if (req.body[0]) {
  672. let p = [req.body[0].cid];
  673. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "select_course_detail"); //執行存儲過程
  674. mysql.usselect(p, function(ret) {
  675. let _unitIndex = parseInt(req.body[0].unitIndex);
  676. let _chapters = JSON.parse(req.body[0].chapters);
  677. let _unitJson = JSON.parse(ret[0][0].chapters)
  678. if ((_unitJson.length - 1) < _unitIndex) {
  679. let _i = _unitIndex - (_unitJson.length - 1)
  680. for (let i = 0; i < _i; i++) {
  681. _unitJson.push({
  682. dyName: "", //单元标题
  683. chapterInfo: [{
  684. isread: false,
  685. chapterid: guid(),
  686. title: "",
  687. courseName: "",
  688. taskJson: [{
  689. task: "",
  690. taskDetail: "",
  691. chapterData: [],
  692. toolText: "",
  693. toolChoose: [{
  694. tool: [],
  695. toolDetail: "",
  696. toolType: 0,
  697. askCount: 1,
  698. askTitle: "",
  699. askJson: [{ askstitle: "", askItem: 1, checkList: [] }],
  700. }, ],
  701. isShowTools: false,
  702. askCount: 1,
  703. isFold: 0,
  704. askTitle: "",
  705. askJson: [{ askstitle: "", askItem: 1, checkList: [] }],
  706. checkJson: [{ checkCount: [], checkPerent: [] }],
  707. homeworkList: [],
  708. }, ],
  709. itemCount: 1,
  710. fileList1: [],
  711. video: [],
  712. testData: [],
  713. pData: [],
  714. templateArray: [],
  715. }, ],
  716. })
  717. }
  718. _unitJson[_unitIndex] = _chapters[_unitIndex]
  719. } else {
  720. _unitJson[_unitIndex] = _chapters[_unitIndex]
  721. }
  722. // console.log(_unitJson);
  723. let p2 = [req.body[0].cid, JSON.stringify(_unitJson).replaceAll(/%/g, "%25")];
  724. p2.unshift(_mysqlLabor[0], _mysqlLabor[1], "update_teacher_work_new4"); //執行存儲過程
  725. mysql.usselect(p2, function(ret) {
  726. res.end(JSON.stringify({ success: 1 }));
  727. });
  728. // res.end(JSON.stringify({ success: 1 }));
  729. });
  730. }
  731. });
  732. //协同删除阶段
  733. router.route('/deleteWork').all((req, res, next) => {
  734. if (req.body[0]) {
  735. let p = [req.body[0].cid];
  736. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "select_course_detail"); //執行存儲過程
  737. mysql.usselect(p, function(ret) {
  738. let _chapid = req.body[0].chapid;
  739. // console.log(_chapid);
  740. let _chapters = JSON.parse(req.body[0].chapters);
  741. let _unitJson = JSON.parse(ret[0][0].chapters)
  742. let _unitJson2 = []
  743. for (var i = 0; i < _unitJson.length; i++) {
  744. if (_unitJson[i].chapterInfo[0].chapterid != _chapid) {
  745. // console.log(1);
  746. // _unitJson.splice(i, -1)
  747. _unitJson2.push(_unitJson[i])
  748. // break;
  749. }
  750. }
  751. // console.log(_unitJson2);
  752. let p2 = [req.body[0].cid, JSON.stringify(_unitJson2).replaceAll(/%/g, "%25")];
  753. p2.unshift(_mysqlLabor[0], _mysqlLabor[1], "update_teacher_work_new4"); //執行存儲過程
  754. mysql.usselect(p2, function(ret) {
  755. res.end(JSON.stringify({ success: 1 }));
  756. });
  757. // res.end(JSON.stringify({ success: 1 }));
  758. });
  759. }
  760. });
  761. //协同恢复删除的阶段
  762. router.route('/restoreWork').all((req, res, next) => {
  763. if (req.body[0]) {
  764. let p = [req.body[0].cid];
  765. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "select_course_detail"); //執行存儲過程
  766. mysql.usselect(p, function(ret) {
  767. let _chapid = req.body[0].chapid;
  768. // console.log(_chapid);
  769. let _chapters = JSON.parse(req.body[0].chapters);
  770. let _unitJson = JSON.parse(ret[0][0].chapters)
  771. let _unitJson2 = []
  772. let chpaindex;
  773. for (var i = 0; i < _chapters.length; i++) {
  774. if (_chapters[i].chapterInfo[0].chapterid == _chapid) {
  775. chpaindex = i
  776. }
  777. }
  778. for (var i = 0; i < _unitJson.length; i++) {
  779. if (_unitJson[i].chapterInfo[0].chapterid != _chapid) {
  780. // console.log(1);
  781. // _unitJson.splice(i, -1)
  782. _unitJson2.push(_unitJson[i])
  783. // break;
  784. }
  785. }
  786. _unitJson2.splice(chpaindex, 0, _chapters[chpaindex])
  787. // console.log(_unitJson2);
  788. let p2 = [req.body[0].cid, JSON.stringify(_unitJson2).replaceAll(/%/g, "%25")];
  789. p2.unshift(_mysqlLabor[0], _mysqlLabor[1], "update_teacher_work_new4"); //執行存儲過程
  790. mysql.usselect(p2, function(ret) {
  791. res.end(JSON.stringify({ success: 1 }));
  792. });
  793. // res.end(JSON.stringify({ success: 1 }));
  794. });
  795. }
  796. });
  797. router.route('/selectCourseNew').all((req, res, next) => {
  798. var json = queryString(req.url);
  799. getmysql(req, res, "select_course_new", json['type'], json['uid'], json['oid'], json['typea'], json['typeb'], json['typec'], json['typed'], json['typeE'], json['cu'], json['cn'], json['page'], 10);
  800. });
  801. router.route('/selectCourseNew2').all((req, res, next) => {
  802. var json = queryString(req.url);
  803. getmysql(req, res, "select_course_new2", json['type'], json['uid'], json['oid'], json['typea'], json['typeb'], json['typec'], json['typed'], json['typeE'], json['cu'], json['cn'], json['page'], 10);
  804. });
  805. //查询协同编辑课程
  806. router.route('/selectCourseTeam').all((req, res, next) => {
  807. var json = queryString(req.url);
  808. getmysql(req, res, "selectCourseTeam", json['uid'], json['oid']);
  809. });
  810. //查询学校
  811. router.route('/selectSchoolName').all((req, res, next) => {
  812. var json = queryString(req.url);
  813. getmysql(req, res, "selectOidName", json['page'], 10);
  814. });
  815. //查询学校
  816. router.route('/selectSchoolName2').all((req, res, next) => {
  817. var json = queryString(req.url);
  818. getmysql(req, res, "selectOidName2", json['oid']);
  819. });
  820. //查询学校
  821. router.route('/selectSchoolNameOrg').all((req, res, next) => {
  822. var json = queryString(req.url);
  823. getmysql(req, res, "selectSchoolNameOrg", json['org'], json['page'], 10);
  824. });
  825. //新增批注
  826. router.route('/addPz').all((req, res, next) => {
  827. postmysql(req, res, "addPz");
  828. });
  829. //新增批注
  830. router.route('/addPz2').all((req, res, next) => {
  831. postmysql(req, res, "addPz2");
  832. });
  833. //删除批注
  834. router.route('/deletePz').all((req, res, next) => {
  835. postmysql(req, res, "deletePz");
  836. });
  837. //查询批注列表
  838. router.route('/selectPzList').all((req, res, next) => {
  839. var json = queryString(req.url);
  840. getmysql(req, res, "selectPzList", json['cid'], json['s'], json['t']);
  841. });
  842. //评分
  843. router.route('/scoreWork').all((req, res, next) => {
  844. postmysql(req, res, "scoreWork");
  845. });
  846. //删除学生
  847. router.route('/deleteStudent').all((req, res, next) => {
  848. postmysql(req, res, "delete_student");
  849. });
  850. //查询学校底下的班级
  851. router.route('/selectClassBySchool').all((req, res, next) => {
  852. var json = queryString(req.url);
  853. getmysql(req, res, "selectClassBySchool", json['oid']);
  854. });
  855. //学生注册接口
  856. router.route('/register_student').post(function(req, res, next) {
  857. //mode的处理
  858. if (req.body[0]) {
  859. // 0 用户名 1 用户密码 2用户身份 3 第三方id(可有可无)
  860. p = Object.values(req.body[0]); //获取用户密码
  861. //没有第三方id的处理
  862. // if (p.length < 4) {
  863. // p.push("")
  864. // }
  865. p[1] = bcrypt.hashSync(p[1], bcrypt.genSaltSync(10));
  866. //密码加密
  867. // bcrypt.hash(p[1], 10, function (err, hash) {
  868. // if (err) {
  869. // return next(err);
  870. // }
  871. // p[1] = hash;
  872. // });
  873. //参数拼接,注册
  874. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "register_student");
  875. //返回注册用户数据
  876. // mysql.usselect(p, function (ret) {
  877. // res.end(ret);
  878. // });
  879. mysql.usselect(p, function(ret) {
  880. res.end(JSON.stringify(ret));
  881. });
  882. }
  883. });
  884. //查询课程详情
  885. router.route('/selectCourseDetail').all((req, res, next) => {
  886. var json = queryString(req.url);
  887. getmysql(req, res, "selectCourseDetail", json['courseId']);
  888. });
  889. //跳转阶段时,如果有课程就查询1返回,如果没有就插入
  890. router.route('/addUserR').all((req, res, next) => {
  891. var json = queryString(req.url);
  892. getmysql(req, res, "insertUserR", json['uid'], json['cid']);
  893. });
  894. //新增学生端作业
  895. router.route('/addWorks').all((req, res, next) => {
  896. postmysql(req, res, "add_works");
  897. });
  898. //查询已提交作业
  899. router.route('/selectWork').all((req, res, next) => {
  900. var json = queryString(req.url);
  901. getmysql(req, res, "selectWork", json['cid'], json['stage'], json['task'], json['uid']);
  902. });
  903. //查询作业详情
  904. router.route('/selectWorksDetail').all((req, res, next) => {
  905. var json = queryString(req.url);
  906. getmysql(req, res, "selectWorksDetail", json['uid'], json['cid']);
  907. });
  908. //新增作业评分
  909. router.route('/updateWorks').all((req, res, next) => {
  910. var json = queryString(req.url);
  911. getmysql(req, res, "updateWorks", json['rate'], json['tuid'], json['id']);
  912. });
  913. //新增素材信息
  914. router.route('/addMtl').all((req, res, next) => {
  915. var json = queryString(req.url);
  916. getmysql(req, res, "add_mtl", json['cInfo'], json['t'], json['cBy']);
  917. });
  918. //根据类型查询素材信息
  919. router.route('/selectMtl').all((req, res, next) => {
  920. var json = queryString(req.url);
  921. getmysql(req, res, "selectMtl", json['t'], json['page'], 10);
  922. });
  923. //根据类型查询素材信息
  924. router.route('/selectMtl2').all((req, res, next) => {
  925. var json = queryString(req.url);
  926. getmysql(req, res, "selectMtl2", json['t'], json['uid'], json['page'], 10);
  927. });
  928. //学习中心
  929. //新增学习资源信息
  930. router.route('/addStuMtl').all((req, res, next) => {
  931. var json = queryString(req.url);
  932. getmysql(req, res, "addStuMtl", json['cInfo'], json['t'], json['cBy']);
  933. });
  934. //根据类型查询学习资料信息
  935. router.route('/selectStuMtl').all((req, res, next) => {
  936. var json = queryString(req.url);
  937. getmysql(req, res, "selectStuMtl", json['t'], json['page'], 10);
  938. });
  939. //删除素材
  940. router.route('/deleteStuM').all((req, res, next) => {
  941. var json = queryString(req.url);
  942. getmysql(req, res, "deleteStuM", json['id']);
  943. });
  944. //查询学生信息
  945. router.route('/selectSDetail').all((req, res, next) => {
  946. var json = queryString(req.url);
  947. getmysql(req, res, "selectStudentDetail", json['uid']);
  948. });
  949. //查询个人课程
  950. router.route('/selectMyCourse').all((req, res, next) => {
  951. var json = queryString(req.url);
  952. getmysql(req, res, "selectMyCourse", json['uid']);
  953. });
  954. //查询个人课程groupby课程id
  955. router.route('/selectMyCourseBycid').all((req, res, next) => {
  956. var json = queryString(req.url);
  957. getmysql(req, res, "selectMyCourseBycid", json['uid']);
  958. });
  959. //查询所有课程
  960. router.route('/selectAllCourse').all((req, res, next) => {
  961. var json = queryString(req.url);
  962. getmysql(req, res, "selectAllCourse", json['oid'], json['page'], 10);
  963. });
  964. //根据班级查询所有课程
  965. router.route('/selectAllCourseByCid').all((req, res, next) => {
  966. var json = queryString(req.url);
  967. getmysql(req, res, "selectAllCourseByCid", json['oid'], json['cid'], json['page'], 10);
  968. });
  969. //根据分类查询所有课程
  970. router.route('/selectTypeCourse').all((req, res, next) => {
  971. var json = queryString(req.url);
  972. getmysql(req, res, "selectTypeCourse", json['uid'], json['oid'], json['typea'], json['typeb'], json['typec'], json['typed'], json['typeE'], json['cu'], json['cn'], json['classid'], json['page'], 10);
  973. });
  974. //根据分类查询所有课程
  975. router.route('/selectTypeCourse2').all((req, res, next) => {
  976. var json = queryString(req.url);
  977. getmysql(req, res, "selectTypeCourse2", json['uid'], json['oid'], json['typea'], json['typeb'], json['typec'], json['typed'], json['typeE'], json['cu'], json['cn'], json['classid'], json['org'], json['page'], 10);
  978. });
  979. //删除素材
  980. router.route('/deleteM').all((req, res, next) => {
  981. var json = queryString(req.url);
  982. getmysql(req, res, "deleteM", json['id']);
  983. });
  984. //点击阶段时添加观看人数
  985. router.route('/updateVc').all((req, res, next) => {
  986. var json = queryString(req.url);
  987. getmysql(req, res, "updateVc", json['cid']);
  988. });
  989. //删除课程
  990. router.route('/deleteCourse').all((req, res, next) => {
  991. var json = queryString(req.url);
  992. getmysql(req, res, "deleteCourse", json['cid']);
  993. });
  994. //查看课程
  995. router.route('/select_course_detail').all((req, res, next) => {
  996. var json = queryString(req.url);
  997. getmysql(req, res, "select_course_detail", json['cid']);
  998. });
  999. //模糊查找课程
  1000. // router.route('/searchCourse').all((req, res, next) => {
  1001. // var json = queryString(req.url);
  1002. // getmysql(req, res, "searchCourse", json['cu'], json['cn'], json['page'], 10);
  1003. // });
  1004. //创建调查问卷
  1005. router.route('/addAsk').all((req, res, next) => {
  1006. postmysql(req, res, "insert_ask");
  1007. });
  1008. //学生提交问卷
  1009. router.route('/addAskList').all((req, res, next) => {
  1010. postmysql(req, res, "insert_askList");
  1011. });
  1012. //根据课程id阶段id获取已提交的问卷
  1013. router.route('/getAskListByCidStage').all((req, res, next) => {
  1014. var json = queryString(req.url);
  1015. getmysql(req, res, "getAskListByCidStage", json['cid'], json['stage'], json['task']);
  1016. });
  1017. //获取调查问卷
  1018. router.route('/getAsk').all((req, res, next) => {
  1019. var json = queryString(req.url);
  1020. getmysql(req, res, "select_ask", json['uid'], json['page'], 10);
  1021. });
  1022. //删除问卷
  1023. router.route('/deleteAsk').all((req, res, next) => {
  1024. postmysql(req, res, "deleteAsk");
  1025. });
  1026. //问卷调查数据统计
  1027. router.route('/getAskListByAskid').all((req, res, next) => {
  1028. var json = queryString(req.url);
  1029. getmysql(req, res, "select_askListByAskid", json['aid']);
  1030. });
  1031. //删除学生提交问卷
  1032. router.route('/deleteAskList').all((req, res, next) => {
  1033. postmysql(req, res, "update_askList_delete");
  1034. });
  1035. //根据id获取调查问卷
  1036. router.route('/getAskList').all((req, res, next) => {
  1037. var json = queryString(req.url);
  1038. getmysql(req, res, "select_askList", json['uid'], json['page'], 10);
  1039. });
  1040. //查看便签列表
  1041. router.route('/selectNote').all((req, res, next) => {
  1042. var json = queryString(req.url);
  1043. getmysql(req, res, "selectNote", json['uid']);
  1044. });
  1045. //新增便签列表
  1046. router.route('/insertNote').all((req, res, next) => {
  1047. var json = queryString(req.url);
  1048. getmysql(req, res, "insertNote", json['uid'], json['c']);
  1049. });
  1050. //根据便签id修改便签内容
  1051. router.route('/updateNote').all((req, res, next) => {
  1052. var json = queryString(req.url);
  1053. getmysql(req, res, "updateNote", json['nid'], json['c']);
  1054. });
  1055. //删除便签
  1056. router.route('/deleteNote').all((req, res, next) => {
  1057. var json = queryString(req.url);
  1058. getmysql(req, res, "deleteNote", json['nid']);
  1059. });
  1060. //查询便签
  1061. router.route('/selectNoteContent').all((req, res, next) => {
  1062. var json = queryString(req.url);
  1063. getmysql(req, res, "selectNoteContent", json['cn']);
  1064. });
  1065. //修改用户信息
  1066. router.route('/updateUserByEdu').all((req, res, next) => {
  1067. postmysql(req, res, "updateUserByEdu");
  1068. });
  1069. //教师端data修改pbl用户信息
  1070. router.route('/updatePblMessage').all((req, res, next) => {
  1071. postmysql2(req, res, "updatePblMessage");
  1072. });
  1073. router.route('/updatePblMessage2').all((req, res, next) => {
  1074. postmysql(req, res, "updatePblMessage");
  1075. });
  1076. //查询用户信息
  1077. router.route('/selectUser').all((req, res, next) => {
  1078. var json = queryString(req.url);
  1079. getmysql(req, res, "selectUser", json['userid']);
  1080. });
  1081. //查询分类及子分类
  1082. router.route('/selectType').all((req, res, next) => {
  1083. var json = queryString(req.url);
  1084. getmysql(req, res, "selectType", );
  1085. });
  1086. //查询赛事分类及子分类
  1087. router.route('/selectMatType').all((req, res, next) => {
  1088. var json = queryString(req.url);
  1089. getmysql(req, res, "selectMatType", );
  1090. });
  1091. //根据学校查询分类
  1092. router.route('/selectPtype').all((req, res, next) => {
  1093. var json = queryString(req.url);
  1094. getmysql(req, res, "selectPtype", json["page"], 10);
  1095. });
  1096. //添加分类
  1097. router.route('/addPtype').all((req, res, next) => {
  1098. var json = queryString(req.url);
  1099. getmysql(req, res, "addPtype", json["n"], json["uid"], json["oid"]);
  1100. });
  1101. //修改分类
  1102. router.route('/updatePtype').all((req, res, next) => {
  1103. var json = queryString(req.url);
  1104. getmysql(req, res, "updatePtype", json["n"], json["tid"]);
  1105. });
  1106. //删除分类
  1107. router.route('/deletePtype').all((req, res, next) => {
  1108. var json = queryString(req.url);
  1109. getmysql(req, res, "deletePtype", json["tid"]);
  1110. });
  1111. //查询子分类列表
  1112. router.route('/selectStype').all((req, res, next) => {
  1113. var json = queryString(req.url);
  1114. getmysql(req, res, "selectStype", json["pid"], json["oid"], json["page"], 10);
  1115. });
  1116. //添加子分类
  1117. router.route('/addStype').all((req, res, next) => {
  1118. var json = queryString(req.url);
  1119. getmysql(req, res, "addStype", json["pid"], json["n"], json["uid"], json["oid"]);
  1120. });
  1121. //根据学校id查询子分类
  1122. router.route('/selectTypeByOid').all((req, res, next) => {
  1123. var json = queryString(req.url);
  1124. getmysql(req, res, "selectTypeByOid", json["oid"]);
  1125. });
  1126. //根据组织id查询子分类
  1127. router.route('/selectTypeByOrg').all((req, res, next) => {
  1128. var json = queryString(req.url);
  1129. getmysql(req, res, "selectTypeByOrg", json["oid"]);
  1130. });
  1131. //更加父id查询分类
  1132. router.route('/selectTypeByPid').all((req, res, next) => {
  1133. var json = queryString(req.url);
  1134. getmysql(req, res, "selectTypeByPid", json['pid']);
  1135. });
  1136. //点击工具计数
  1137. router.route('/insertToolsCount').all((req, res, next) => {
  1138. var json = queryString(req.url);
  1139. getmysql(req, res, "insertToolsCount", json['cid'], json['chid'], json['uid'], json['tid'], json['count']);
  1140. });
  1141. //修改工具次数
  1142. router.route('/updateToolsCount').all((req, res, next) => {
  1143. var json = queryString(req.url);
  1144. getmysql(req, res, "updateToolsCount", json['cid'], json['chid'], json['uid'], json['tid'], json['count']);
  1145. });
  1146. //查询工具次数
  1147. router.route('/selectToolsCount').all((req, res, next) => {
  1148. var json = queryString(req.url);
  1149. getmysql(req, res, "selectToolsCount", json['cid'], json['chid'], json['uid']);
  1150. });
  1151. //导出学生
  1152. router.route('/selectUserBySchool').all((req, res, next) => {
  1153. var json = queryString(req.url);
  1154. getmysql(req, res, "selectUserBySchool", json['oid']);
  1155. });
  1156. //上传学生作业
  1157. router.route('/insertSWork').all((req, res, next) => {
  1158. var json = queryString(req.url);
  1159. getmysql(req, res, "insertSWork", json['uid'], json['cid'], json['p'], json['t'], json['upload']);
  1160. });
  1161. //查询学生作业
  1162. router.route('/selectSWork').all((req, res, next) => {
  1163. var json = queryString(req.url);
  1164. getmysql(req, res, "selectSWork", json['uid'], json['cid'], json['p'], json['type']);
  1165. });
  1166. //查询赛事案例设计
  1167. router.route('/selectCase').all((req, res, next) => {
  1168. var json = queryString(req.url);
  1169. getmysql(req, res, "selectCase", json['org']);
  1170. });
  1171. //查询赛事项目列表
  1172. router.route('/selectRaceList').all((req, res, next) => {
  1173. var json = queryString(req.url);
  1174. getmysql(req, res, "selectRaceList", json['uid']);
  1175. });
  1176. //修改赛事状态
  1177. router.route('/updateRaceState').all((req, res, next) => {
  1178. var json = queryString(req.url);
  1179. getmysql(req, res, "updateRaceState", json['id']);
  1180. });
  1181. //查询赛事项目详情
  1182. router.route('/selectRaceDetail').all((req, res, next) => {
  1183. var json = queryString(req.url);
  1184. getmysql(req, res, "selectRaceDetail", json['id']);
  1185. });
  1186. //race 查询学校
  1187. router.route('/getSchool').all((req, res, next) => {
  1188. var json = queryString(req.url);
  1189. getmysql(req, res, "getSchool", json['n']);
  1190. });
  1191. //lsc
  1192. //admin 查询学校
  1193. router.route('/getSchoolAdmin').all((req, res, next) => {
  1194. var json = queryString(req.url);
  1195. getmysql(req, res, "select_school", json['page'], 10);
  1196. });
  1197. //admin 添加学校
  1198. router.route('/addSchoolAdmin').all((req, res, next) => {
  1199. postmysql(req, res, "add_school");
  1200. });
  1201. //组织添加学校
  1202. router.route('/addSchoolOrg').all((req, res, next) => {
  1203. postmysql(req, res, "addSchoolOrg");
  1204. });
  1205. //admin 删除学校
  1206. router.route('/deleteSchoolAdmin').all((req, res, next) => {
  1207. postmysql(req, res, "delete_school");
  1208. });
  1209. //admin 查询班级
  1210. router.route('/getClassAdmin').all((req, res, next) => {
  1211. var json = queryString(req.url);
  1212. getmysql(req, res, "select_classAdmin", json['cn'], json['page'], 10);
  1213. });
  1214. //admin 添加班级
  1215. router.route('/addClassAdmin').all((req, res, next) => {
  1216. postmysql(req, res, "add_classAdmin");
  1217. });
  1218. //admin 查询班级是否重复
  1219. router.route('/getClassRepeat').all((req, res, next) => {
  1220. var json = queryString(req.url);
  1221. getmysql(req, res, "select_classRepeatAdmin", json['n'], json['oid']);
  1222. });
  1223. //admin 发布通知
  1224. router.route('/addNews').all((req, res, next) => {
  1225. postmysql(req, res, "add_news");
  1226. });
  1227. //admin 删除通知
  1228. router.route('/deleteNews').all((req, res, next) => {
  1229. postmysql(req, res, "delete_news");
  1230. });
  1231. //admin 添加banner
  1232. router.route('/addBanner').all((req, res, next) => {
  1233. postmysql(req, res, "add_banner");
  1234. });
  1235. //admin 添加banner
  1236. router.route('/deleteBanner').all((req, res, next) => {
  1237. postmysql(req, res, "delete_banner");
  1238. });
  1239. //admin 查询banner
  1240. router.route('/getBanner').all((req, res, next) => {
  1241. var json = queryString(req.url);
  1242. getmysql(req, res, "select_banner");
  1243. });
  1244. //根据学校查询banner
  1245. router.route('/selectBannerByOid').all((req, res, next) => {
  1246. var json = queryString(req.url);
  1247. getmysql(req, res, "selectBannerByOid", json["oid"]);
  1248. });
  1249. //admin 查询课程getSearchCourse
  1250. router.route('/getSearchCourse').all((req, res, next) => {
  1251. var json = queryString(req.url);
  1252. getmysql(req, res, "selectAll_courseSearch", json['t']);
  1253. });
  1254. //根据学校查询课程
  1255. router.route('/getSearchCourseByoid').all((req, res, next) => {
  1256. var json = queryString(req.url);
  1257. getmysql(req, res, "selectAll_courseByOid", json['t'], json['oid']);
  1258. });
  1259. //admin 查询所有课程专区
  1260. router.route('/getZone').all((req, res, next) => {
  1261. getmysql(req, res, "select_zone");
  1262. });
  1263. //admin 添加课程专区
  1264. router.route('/addZone').all((req, res, next) => {
  1265. postmysql(req, res, "insert_classZone");
  1266. });
  1267. //查询所有课程专区下的课程
  1268. router.route('/getZoneClass').all((req, res, next) => {
  1269. var json = queryString(req.url);
  1270. getmysql(req, res, "select_zoneClass", json['bid'], json['oid'], json['page'], 10);
  1271. });
  1272. //查询所有课程专区下的课程
  1273. router.route('/getZoneClassStudent').all((req, res, next) => {
  1274. var json = queryString(req.url);
  1275. getmysql(req, res, "select_zoneClass", json['bid'], json['oid'], json['page'], 20);
  1276. });
  1277. //admin 后台查看专区下课程的数量
  1278. router.route('/getZoneClassNum').all((req, res, next) => {
  1279. var json = queryString(req.url);
  1280. getmysql(req, res, "select_zoneClassNum", json['bid']);
  1281. });
  1282. //admin 后台添加课程专区时查看课程是否在此专区重复
  1283. router.route('/getZoneClassRepeat').all((req, res, next) => {
  1284. var json = queryString(req.url);
  1285. getmysql(req, res, "select_zoneClassRepeat", json['pid'], json['cid']);
  1286. });
  1287. //把课程添加进专区
  1288. router.route('/addZoneCourse').all((req, res, next) => {
  1289. postmysql(req, res, "insert_app");
  1290. });
  1291. //admin 删除课程专区底下的课程
  1292. router.route('/deleteZoneCourse').all((req, res, next) => {
  1293. postmysql(req, res, "delete_app");
  1294. });
  1295. //admin 删除班级
  1296. router.route('/deleteZone').all((req, res, next) => {
  1297. postmysql(req, res, "delete_zone");
  1298. });
  1299. //admin 后台专区上移下移
  1300. router.route('/zoneRank').all((req, res, next) => {
  1301. postmysql(req, res, "update_classRank");
  1302. });
  1303. //admin 添加模板文档
  1304. router.route('/addTemplateAdmin').all((req, res, next) => {
  1305. postmysql(req, res, "add_template");
  1306. });
  1307. //admin 添加模板文档
  1308. router.route('/deleteTemplateAdmin').all((req, res, next) => {
  1309. postmysql(req, res, "delete_template");
  1310. });
  1311. //admin 查询模板文档
  1312. router.route('/getTemplateAdmin').all((req, res, next) => {
  1313. var json = queryString(req.url);
  1314. getmysql(req, res, "select_template", json['page'], 10);
  1315. });
  1316. //查询上传作业
  1317. router.route('/getCourseWorks').all((req, res, next) => {
  1318. var json = queryString(req.url); //cid 课程id,page 页数
  1319. getmysql(req, res, "select_courseWorks", json['cid'], json['stage'], json['task'], json['page'], 10);
  1320. });
  1321. //查询上传作业
  1322. router.route('/getCourseWorks2').all((req, res, next) => {
  1323. var json = queryString(req.url); //cid 课程id,page 页数
  1324. getmysql(req, res, "select_courseWorks2", json['cid'], json['uname'], json['stage'], json['task'], json['page'], 10);
  1325. });
  1326. //查询上传作业
  1327. router.route('/getCourseWorks3').all((req, res, next) => {
  1328. var json = queryString(req.url); //cid 课程id,page 页数
  1329. getmysql(req, res, "select_courseWorks3", json['cid'], json['uname'], json['stage'], json['task'], json['page'], 10);
  1330. });
  1331. //查询报告数据
  1332. router.route('/getCourseWorksReport').all((req, res, next) => {
  1333. var json = queryString(req.url); //cid 课程id,page 页数
  1334. getmysql(req, res, "getCourseWorksReport", json['cid']);
  1335. });
  1336. //admin 添加项目模板文档
  1337. router.route('/addCourseTemplateAdmin').all((req, res, next) => {
  1338. postmysql(req, res, "add_courseTemplate");
  1339. });
  1340. //admin 添加项目模板文档
  1341. router.route('/deleteCourseTemplateAdmin').all((req, res, next) => {
  1342. postmysql(req, res, "delete_courseTemplate");
  1343. });
  1344. //admin 查询项目模板文档
  1345. router.route('/getCourseTemplateAdmin').all((req, res, next) => {
  1346. var json = queryString(req.url);
  1347. getmysql(req, res, "select_courseTemplate", json['page'], 10);
  1348. });
  1349. //teacher 查询项目模板
  1350. router.route('/getCourseTemplateT').all((req, res, next) => {
  1351. var json = queryString(req.url);
  1352. getmysql(req, res, "select_courseTemplateT");
  1353. });
  1354. //admin 查询课程
  1355. router.route('/getCourseAdmin').all((req, res, next) => {
  1356. var json = queryString(req.url);
  1357. getmysql(req, res, "select_courseAdmin", json['cn'], json['page'], 10);
  1358. });
  1359. //admin 查询模板文档
  1360. router.route('/deleteCourseAdmin').all((req, res, next) => {
  1361. postmysql(req, res, "delete_courseAdmin");
  1362. });
  1363. //查询ppt在哪页
  1364. router.route('/selectPptPage').all((req, res, next) => {
  1365. var json = queryString(req.url);
  1366. getmysql(req, res, "selectPptPage", json['id']);
  1367. });
  1368. //修改ppt页码
  1369. router.route('/updatePptPage').all((req, res, next) => {
  1370. postmysql(req, res, "updatePptPage");
  1371. });
  1372. //修改ppt操作
  1373. router.route('/updatePPTHandle').all((req, res, next) => {
  1374. postmysql(req, res, "updatePPTHandle");
  1375. });
  1376. //查询实时课堂
  1377. router.route('/getRealTimeClass').all((req, res, next) => {
  1378. var json = queryString(req.url);
  1379. getmysql(req, res, "getRealTimeClass", json["cn"], json["uid"], json["page"], 10);
  1380. });
  1381. //查询实时课堂学生
  1382. router.route('/getRealTimeClassStu').all((req, res, next) => {
  1383. var json = queryString(req.url);
  1384. getmysql(req, res, "getRealTimeClassStu", json["oid"], json["cid"], json["page"], 10);
  1385. });
  1386. //查询实时课堂学生
  1387. router.route('/getRealTimeClassById').all((req, res, next) => {
  1388. var json = queryString(req.url);
  1389. getmysql(req, res, "getRealTimeClassById", json["id"]);
  1390. });
  1391. //teacher 查询模板
  1392. router.route('/getTemplateT').all((req, res, next) => {
  1393. var json = queryString(req.url);
  1394. getmysql(req, res, "select_templateT");
  1395. });
  1396. //思维网格 创建房间
  1397. router.route('/insertRoom').all((req, res, next) => {
  1398. postmysql(req, res, "insertRoom");
  1399. });
  1400. //协同编辑 创建房间
  1401. router.route('/insertRoomByFile').all((req, res, next) => {
  1402. //var json = queryString(req.url);
  1403. postmysql2(req, res, "insertRoomByFile");
  1404. //getmysql(req, res, "insertRoomByFile", json["uid"], json["n"], json["d"]);
  1405. });
  1406. //思维网格 查询是否是重复房间号
  1407. router.route('/checkRoomNum').all((req, res, next) => {
  1408. var json = queryString(req.url);
  1409. getmysql(req, res, "checkRoomNum", json['num']);
  1410. });
  1411. //思维网格 查询房间列表
  1412. router.route('/selectRoomList').all((req, res, next) => {
  1413. var json = queryString(req.url);
  1414. getmysql(req, res, "selectRoomList", json['uid'], json['oid'], json['cid'], json['cu'], json['cn']);
  1415. });
  1416. //查询pdf列表
  1417. router.route('/selectRTC').all((req, res, next) => {
  1418. var json = queryString(req.url);
  1419. getmysql(req, res, "selectRTC", json['uid'], json['cu'], json['cn']);
  1420. });
  1421. //协同文档 查询房间列表
  1422. router.route('/selectFileList').all((req, res, next) => {
  1423. var json = queryString(req.url);
  1424. getmysql(req, res, "selectFileList", json['uid'], json['oid'], json['cid'], json['cu'], json['cn']);
  1425. });
  1426. //协同编辑 查询是否是重复房间号
  1427. router.route('/checkRoomNumByFile').all((req, res, next) => {
  1428. var json = queryString(req.url);
  1429. getmysql(req, res, "checkRoomNumByFile", json['num']);
  1430. });
  1431. //思维网格 根据房间号或者用户id查询房间信息
  1432. router.route('/selectRoom').all((req, res, next) => {
  1433. var json = queryString(req.url);
  1434. getmysql(req, res, "selectRoom", json['uid']);
  1435. });
  1436. //思维网格 根据房间号或者用户id查询房间信息
  1437. router.route('/getRoom').all((req, res, next) => {
  1438. var json = queryString(req.url);
  1439. getmysql(req, res, "select_room", json['fid']);
  1440. });
  1441. //协同编辑 根据房间号或者用户id查询房间信息
  1442. router.route('/selectRoomByFile').all((req, res, next) => {
  1443. var json = queryString(req.url);
  1444. getmysql(req, res, "selectRoomByFile", json['uid']);
  1445. });
  1446. //思维网格 修改房间数据
  1447. router.route('/updateRoomData').all((req, res, next) => {
  1448. postmysql(req, res, "updateRoomData");
  1449. });
  1450. router.route('/updateFileData').all((req, res, next) => {
  1451. var json = queryString(req.url);
  1452. var json2 = json['mode'].split(',');
  1453. getmysql(req, res, "updateFileData", json2[0], json2[1]);
  1454. });
  1455. router.route('/select_file').all((req, res, next) => {
  1456. var json = queryString(req.url);
  1457. getmysql(req, res, "select_file", json['fid']);
  1458. });
  1459. //思维网格 解散房间
  1460. router.route('/dismiss').all((req, res, next) => {
  1461. postmysql(req, res, "update_room");
  1462. });
  1463. //提交提问
  1464. router.route('/addProblem').all((req, res, next) => {
  1465. postmysql(req, res, "add_problem");
  1466. //cid 课程id,chid 章节id,t 提问内容,uid 用户id
  1467. });
  1468. //查询提交的提问
  1469. router.route('/getProblem').all((req, res, next) => {
  1470. var json = queryString(req.url); //cid 课程id,page 页数
  1471. getmysql(req, res, "select_problem", json['cid'], json['page'], 10);
  1472. });
  1473. //获取用户基本信息
  1474. router.route('/getUserInfo').all((req, res, next) => {
  1475. var json = queryString(req.url);
  1476. getmysql(req, res, "getUserInfo", json['uid'], json['cid']);
  1477. });
  1478. //获取项目基本信息
  1479. router.route('/getCourseInfo').all((req, res, next) => {
  1480. var json = queryString(req.url);
  1481. getmysql(req, res, "getCourseInfo", json['cid']);
  1482. });
  1483. //作业生成报告
  1484. router.route('/getWorkData').all((req, res, next) => {
  1485. var json = queryString(req.url); //cid 课程id,page 页数
  1486. getmysql(req, res, "select_work_data", json['cid']);
  1487. });
  1488. //查询评价体系
  1489. router.route('/getEvaluation').all((req, res, next) => {
  1490. var json = queryString(req.url); //cid 课程id,page 页数
  1491. getmysql(req, res, "select_evaluation", json['oid'], json['n'], json['page'], 10);
  1492. });
  1493. //添加评价体系
  1494. router.route('/addEvaluation').all((req, res, next) => {
  1495. postmysql(req, res, "add_evaluation");
  1496. //uid 用户id t标题 c内容
  1497. });
  1498. //修改评价体系
  1499. router.route('/updateEvaluation').all((req, res, next) => {
  1500. postmysql(req, res, "update_evaluation");
  1501. //c内容 t标题 id评价id
  1502. });
  1503. //删除评价体系
  1504. router.route('/deleteEvaluation').all((req, res, next) => {
  1505. postmysql(req, res, "delete_evaluation");
  1506. // id评价id
  1507. });
  1508. router.route('/batchRegistrationMore').post(function(req, res, next) {
  1509. let users = req.body[0];
  1510. let arr = JSON.parse(req.body[0].arr);
  1511. //循环注册
  1512. // for (let j = 0; j < arr.length; j++) {
  1513. // if (arr[j].phone && arr[j].phone != "") {
  1514. // let _phonedata = [arr[j].phone];
  1515. // _phonedata.unshift(_mysqlLabor[0], _mysqlLabor[1], "findPhone");
  1516. // mysql.usselect(_phonedata, function(ret) {
  1517. // if (ret[0].length > 0) {
  1518. // res.end(JSON.stringify({ type: 1 }));
  1519. // return;
  1520. // }
  1521. // });
  1522. // }
  1523. // if (arr[j].mail && arr[j].mail != "") {
  1524. // let _maildata = [arr[j].mail];
  1525. // _maildata.unshift(_mysqluser[0], _mysqluser[1], "findMail");
  1526. // mysql.usselect(_maildata, function(ret) {
  1527. // if (ret[0].length > 0) {
  1528. // res.end(JSON.stringify({ type: 2 }));
  1529. // return;
  1530. // }
  1531. // });
  1532. // }
  1533. // if (arr[j].sId && arr[j].sId != "") {
  1534. // let _siddata = [arr[j].sId];
  1535. // _siddata.unshift(_mysqlLabor[0], _mysqlLabor[1], "findSid");
  1536. // mysql.usselect(_siddata, function(ret) {
  1537. // if (ret[0].length > 0) {
  1538. // res.end(JSON.stringify({ type: 3 }));
  1539. // return;
  1540. // }
  1541. // });
  1542. // }
  1543. // }
  1544. for (let i = 0; i < arr.length; i++) {
  1545. let _username = arr[i].name;
  1546. let _mail = arr[i].mail;
  1547. let _password = users.password || "123456";
  1548. let _alias = arr[i].name;
  1549. let _oid = users.oid;
  1550. let _ph = arr[i].phone ? arr[i].phone : '';
  1551. let _class = arr[i].class;
  1552. let _sId = arr[i].sId;
  1553. //加密密碼
  1554. _password = bcrypt.hashSync(_password, bcrypt.genSaltSync(10));
  1555. //生成激活碼
  1556. let _hashstr = new Date().getTime() + "";
  1557. let _digest = crypto.createHash('sha256').update(_hashstr, 'utf8').digest('hex');
  1558. //用戶數據
  1559. let _userdata = [
  1560. _mail,
  1561. _password,
  1562. _alias,
  1563. "",
  1564. 1, //0老师 1学生
  1565. _username,
  1566. "",
  1567. generateAPIKey(_username),
  1568. _digest,
  1569. "",
  1570. _username,
  1571. _sId,
  1572. 2, //1老师 2学生
  1573. _oid,
  1574. _ph,
  1575. _class,
  1576. '',
  1577. "0",
  1578. ];
  1579. //參數拼接,註冊
  1580. _userdata.unshift(_mysqluser[0], _mysqluser[1], "pbl_add_batchregister");
  1581. //用戶註冊處理
  1582. mysql.usselect(_userdata, function(ret) {
  1583. // let _pbluserdata = [
  1584. // ret[1][0].uid,
  1585. // _username,
  1586. // _sId,
  1587. // 2,
  1588. // _oid,
  1589. // _ph,
  1590. // _class,
  1591. // '',
  1592. // "0",
  1593. // ];
  1594. // _pbluserdata.unshift(_mysqlLabor[0], _mysqlLabor[1], "updateUserByEdu");
  1595. // mysql.usselect(_pbluserdata, function(ret) {
  1596. res.end(JSON.stringify({ success: 1 }));
  1597. // });
  1598. });
  1599. }
  1600. });
  1601. router.route('/batchRegistration').post(function(req, res, next) {
  1602. var users = req.body[0];
  1603. //循环注册
  1604. var _username = users.alias;
  1605. var _mail = users.username;
  1606. var _password = users.password || "123456";
  1607. var _alias = users.alias;
  1608. var _oid = users.oid;
  1609. var _ph = users.ph;
  1610. var _class = users.cid;
  1611. var _sId = users.sid;
  1612. //加密密碼
  1613. _password = bcrypt.hashSync(_password, bcrypt.genSaltSync(10));
  1614. //生成激活碼
  1615. let _hashstr = new Date().getTime() + "";
  1616. let _digest = crypto.createHash('sha256').update(_hashstr, 'utf8').digest('hex');
  1617. //用戶數據
  1618. var _userdata = [
  1619. _mail,
  1620. _password,
  1621. _alias,
  1622. "",
  1623. 1,
  1624. _username,
  1625. "",
  1626. generateAPIKey(_username),
  1627. _digest,
  1628. "",
  1629. _username,
  1630. _sId,
  1631. 2,
  1632. _oid,
  1633. _ph,
  1634. _class,
  1635. '',
  1636. "0",
  1637. ];
  1638. //參數拼接,註冊
  1639. _userdata.unshift(_mysqluser[0], _mysqluser[1], "pbl_add_batchregister");
  1640. //用戶註冊處理
  1641. mysql.usselect(_userdata, function(ret) {
  1642. res.end(JSON.stringify({ uid: ret[1][0].uid, ph: _ph, oid: _oid, cid: _class, success: 1 }));
  1643. });
  1644. });
  1645. router.route('/batchRegistrationOrg').post(function(req, res, next) {
  1646. var users = req.body[0];
  1647. //循环注册
  1648. var _username = users.alias;
  1649. var _mail = users.username;
  1650. var _password = users.password || "123456";
  1651. var _alias = users.alias;
  1652. var _oid = users.oid;
  1653. var _ph = users.ph;
  1654. var _class = users.cid;
  1655. var _sId = users.sid;
  1656. var _org = users.org;
  1657. //加密密碼
  1658. _password = bcrypt.hashSync(_password, bcrypt.genSaltSync(10));
  1659. //生成激活碼
  1660. let _hashstr = new Date().getTime() + "";
  1661. let _digest = crypto.createHash('sha256').update(_hashstr, 'utf8').digest('hex');
  1662. //用戶數據
  1663. var _userdata = [
  1664. _mail,
  1665. _password,
  1666. _alias,
  1667. "",
  1668. 1,
  1669. _username,
  1670. "",
  1671. generateAPIKey(_username),
  1672. _digest,
  1673. "",
  1674. _username,
  1675. _sId,
  1676. 2,
  1677. _oid,
  1678. _ph,
  1679. _class,
  1680. '',
  1681. "0",
  1682. _org
  1683. ];
  1684. //參數拼接,註冊
  1685. _userdata.unshift(_mysqluser[0], _mysqluser[1], "pbl_add_batchregister_org");
  1686. //用戶註冊處理
  1687. mysql.usselect(_userdata, function(ret) {
  1688. res.end(JSON.stringify({ uid: ret[1][0].uid, ph: _ph, oid: _oid, cid: _class, success: 1 }));
  1689. });
  1690. });
  1691. function generateAPIKey(username) {
  1692. let timeStamp = new Date().getTime();
  1693. let hashStr = timeStamp + username;
  1694. let digest = crypto.createHash('sha256').update(hashStr, 'utf8').digest('hex');
  1695. return digest;
  1696. }
  1697. queryString = function(url) {
  1698. var a = url.split("?");
  1699. var json = querystring.parse(a[1])
  1700. return json;
  1701. }
  1702. //post存儲過程處理
  1703. postmysql = function(req, res, functionname) {
  1704. //mode的處理
  1705. if (req.body[0]) {
  1706. p = Object.values(req.body[0]);
  1707. p.unshift(_mysqlLabor[0], _mysqlLabor[1], functionname);
  1708. //執行存儲過程
  1709. mysql.usselect(p, function(ret) { res.end(JSON.stringify(ret)); });
  1710. }
  1711. }
  1712. //post存儲過程處理
  1713. postmysql2 = function(req, res, functionname) {
  1714. //mode的處理
  1715. if (req.body) {
  1716. p = Object.values(req.body)[0].split(",");
  1717. p.unshift(_mysqlLabor[0], _mysqlLabor[1], functionname);
  1718. //執行存儲過程
  1719. mysql.usselect(p, function(ret) { res.end(JSON.stringify(ret)); });
  1720. }
  1721. }
  1722. //get獲取數據庫信息
  1723. getmysql = function(req, res, functionname, ...p) {
  1724. p = p || [];
  1725. p.unshift(_mysqlLabor[0], _mysqlLabor[1], functionname);
  1726. //執行存儲過程
  1727. mysql.usselect(p, function(ret) { res.end(JSON.stringify(ret)); }); //
  1728. }
  1729. //post存储过程处理
  1730. userpostmysql = function(req, res, functionname) {
  1731. //mode的处理
  1732. if (req.body.mode) {
  1733. p = req.body.mode.split(",");
  1734. p.unshift(_mysqluser[0], _mysqluser[1], functionname);
  1735. //执行存储过程
  1736. mysql.usselect(p, function(ret) { res.end(JSON.stringify(ret)); });
  1737. }
  1738. }
  1739. //get获取数据库信息
  1740. usergetmysql = function(req, res, functionname, ...p) {
  1741. p = p || [];
  1742. p.unshift(_mysqluser[0], _mysqluser[1], functionname);
  1743. //执行存储过程
  1744. mysql.usselect(p, function(ret) { res.end(JSON.stringify(ret)); }); //
  1745. }
  1746. module.exports = router;