pbl.js 71 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087
  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. // 图片转base64
  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. //查询老师的信息
  277. router.route('/getRaceUser').all((req, res, next) => {
  278. var json = queryString(req.url);
  279. getmysql(req, res, "getRaceUser", json['uid']);
  280. });
  281. router.route('/selectUser').all((req, res, next) => {
  282. var json = queryString(req.url);
  283. getmysql(req, res, "selectUser", json['userid']);
  284. });
  285. //查询教师端消息
  286. router.route('/getNewsTeacher').all((req, res, next) => {
  287. var json = queryString(req.url);
  288. getmysql(req, res, "selectNew", json['uid'], json['page'], 10);
  289. });
  290. //查询通知详情
  291. router.route('/selectNewDetail').all((req, res, next) => {
  292. var json = queryString(req.url);
  293. getmysql(req, res, "selectNewDetail", json['nid']);
  294. });
  295. //查出分组分类
  296. router.route('/getGroup').all((req, res, next) => {
  297. getmysql(req, res, "selectGroupTeacher");
  298. });
  299. //查询这个老师底下的学生提交的作业
  300. router.route('/getWorks').all((req, res, next) => {
  301. var json = queryString(req.url);
  302. getmysql(req, res, "selectWorks", json['cn'], json['cid'], json['page'], 10);
  303. });
  304. //查询项目
  305. router.route('/getProject').all((req, res, next) => {
  306. var json = queryString(req.url);
  307. getmysql(req, res, "selectProject", json['type'], json['uid'], json['oid'], json['cn'], json['page'], 10);
  308. });
  309. //查询项目
  310. router.route('/getMyProject').all((req, res, next) => {
  311. var json = queryString(req.url);
  312. getmysql(req, res, "selectMyProject", json['uid'], json['page'], 10);
  313. });
  314. //查询项目成员
  315. router.route('/selectProjectStudent').all((req, res, next) => {
  316. var json = queryString(req.url);
  317. getmysql(req, res, "select_student", json['cn'], json['oid'], json['uid']);
  318. });
  319. //查询Banner列表
  320. router.route('/selectBannerList').all((req, res, next) => {
  321. var json = queryString(req.url);
  322. getmysql(req, res, "selectBannerList", json['page'], 10);
  323. });
  324. //查询Banner列表
  325. router.route('/selectAllBanner').all((req, res, next) => {
  326. var json = queryString(req.url);
  327. getmysql(req, res, "selectAllBanner", json["t"]);
  328. });
  329. //新增Banner
  330. router.route('/insertBannerList').all((req, res, next) => {
  331. postmysql(req, res, "insertBannerList");
  332. });
  333. //删除提交的作业
  334. router.route('/deleteCourseWork').all((req, res, next) => {
  335. postmysql(req, res, "deleteCourseWork");
  336. });
  337. //删除Banner
  338. router.route('/deleteBannerList').all((req, res, next) => {
  339. var json = queryString(req.url);
  340. getmysql(req, res, "deleteBannerList", json['id']);
  341. });
  342. //新增课程
  343. router.route('/addWork').all((req, res, next) => {
  344. postmysql(req, res, "insert_teacher_work");
  345. });
  346. //点赞评论
  347. router.route('/insertComment').all((req, res, next) => {
  348. postmysql(req, res, "insertComment");
  349. });
  350. //取消点赞
  351. router.route('/deleteComment').all((req, res, next) => {
  352. var json = queryString(req.url);
  353. getmysql(req, res, "deleteComment", json['wid'], json['lid']);
  354. });
  355. //上传批注图片
  356. router.route('/updateCourseWorks').all((req, res, next) => {
  357. postmysql(req, res, "updateCourseWorks");
  358. });
  359. //上传文件
  360. router.route('/addCourseWorks').all((req, res, next) => {
  361. postmysql(req, res, "addCourseWorks");
  362. });
  363. //上传文件
  364. router.route('/addCourseWorksTeacher').all((req, res, next) => {
  365. postmysql(req, res, "addCourseWorksTeacher");
  366. });
  367. //上传文件
  368. router.route('/addCourseWorks2').all((req, res, next) => {
  369. var json = queryString(req.url);
  370. getmysql(req, res, "addCourseWorks", json['uid'], json['cid'], json['stage'], json['task'], json['tool'], json['content'], json['type']);
  371. });
  372. //上传文件
  373. router.route('/addCourseWorks3').all((req, res, next) => {
  374. var json = queryString(req.url);
  375. getmysql(req, res, "addCourseWorks2", json['uid'], json['cid'], json['stage'], json['task'], json['tool'], json['content'], json['type'], json['atool']);
  376. });
  377. //修改课程权限(学生是否能查看所有作业)
  378. router.route('/updateCourseSLook').all((req, res, next) => {
  379. var json = queryString(req.url);
  380. getmysql(req, res, "updateCourseSLook", json['sopen'], json['cid']);
  381. });
  382. //修改阶段锁定状态
  383. router.route('/updateCourseLookOpen').all((req, res, next) => {
  384. postmysql(req, res, "updateCourseLookOpen");
  385. });
  386. //查看阶段锁定的状态
  387. router.route('/getCourseState').all((req, res, next) => {
  388. var json = queryString(req.url);
  389. getmysql(req, res, "getCourseState", json['cid']);
  390. });
  391. //添加锁定状态
  392. router.route('/addCourseState').all((req, res, next) => {
  393. postmysql(req, res, "addCourseState");
  394. });
  395. //修改锁定状态
  396. router.route('/updateCourseSate').all((req, res, next) => {
  397. postmysql(req, res, "updateCourseSate");
  398. });
  399. //查询课程权限(学生是否能查看所有作业)
  400. router.route('/selectCourseSLook').all((req, res, next) => {
  401. var json = queryString(req.url);
  402. getmysql(req, res, "selectCourseSLook", json['cid']);
  403. });
  404. //查询作业详情
  405. router.route('/selectWorksDetail2').all((req, res, next) => {
  406. var json = queryString(req.url);
  407. getmysql(req, res, "selectWorksDetail2", json['uid'], json['cid'], json['stage'], json['task']);
  408. });
  409. //查询课程全部作业详情
  410. router.route('/selectWorksDetail3').all((req, res, next) => {
  411. var json = queryString(req.url);
  412. getmysql(req, res, "selectWorksDetail3", json['uid'], json['cid']);
  413. });
  414. //学习中心教师查询作业
  415. router.route('/selectSWorks').all((req, res, next) => {
  416. var json = queryString(req.url);
  417. getmysql(req, res, "selectSWorks", json['cid'], json['s'], json['t']);
  418. });
  419. //学习中心教师查询作业全部展示
  420. router.route('/selectSWorks2').all((req, res, next) => {
  421. var json = queryString(req.url);
  422. getmysql(req, res, "selectSWorks2", json['cid']);
  423. });
  424. //学习中心学生查询作业
  425. router.route('/selectStudentWorks').all((req, res, next) => {
  426. var json = queryString(req.url);
  427. getmysql(req, res, "selectStudentWorks", json['uid'], json['cid'], json['s'], json['t']);
  428. });
  429. //实时课堂作业评价
  430. router.route('/updateStudentWork').all((req, res, next) => {
  431. postmysql(req, res, "updateStudentWork");
  432. });
  433. //学习中心查询学生
  434. router.route('/selectWorksStudent').all((req, res, next) => {
  435. var json = queryString(req.url);
  436. getmysql(req, res, "selectWorksStudent", json['oid'], json['cid']);
  437. });
  438. /* 查询学生 */
  439. router.route('/selectStudent2').all((req, res, next) => {
  440. var json = queryString(req.url);
  441. getmysql(req, res, "selectStudent2", json['oid'], json['cu'], json['cn'], json['cid'], json['page'], 8);
  442. });
  443. /* 查询教师 */
  444. router.route('/selectTeacher').all((req, res, next) => {
  445. var json = queryString(req.url);
  446. getmysql(req, res, "selectTeacher", json['org'], json['cu'], json['cn'], json['page'], 8);
  447. });
  448. /* 查询所有评价体系 */
  449. router.route('/selectAllEvaluation').all((req, res, next) => {
  450. var json = queryString(req.url);
  451. getmysql(req, res, "selectAllEvaluation", json['oid']);
  452. });
  453. /* 根据市级用户查询评审员 */
  454. router.route('/selectReviewer').all((req, res, next) => {
  455. var json = queryString(req.url);
  456. getmysql(req, res, "selectReviewer", json['uid'], json['cn'], json['page'], 10);
  457. });
  458. router.route('/addWorkNew').all((req, res, next) => {
  459. // postmysql(req, res, "insert_teacher_work_new");
  460. if (req.body[0]) {
  461. // p = Object.values(req.body[0]);
  462. 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];
  463. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "insert_teacher_work_new");
  464. //執行存儲過程
  465. mysql.usselect(p, function(ret) {
  466. let course = req.body[0].courseType;
  467. let courseId = ret[0][0].courseId;
  468. let userid = req.body[0].uid;
  469. delCourseType(course, courseId, userid);
  470. res.end(JSON.stringify({ ordernumber: ret[0][0].ordernumber, courseId: ret[0][0].courseId, success: 1 }));
  471. // res.end(JSON.stringify(ret));
  472. });
  473. }
  474. });
  475. router.route('/addWorkNew2').all((req, res, next) => {
  476. if (req.body[0]) {
  477. 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];
  478. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "insert_teacher_work_new2"); //執行存儲過程
  479. mysql.usselect(p, function(ret) {
  480. let course = req.body[0].courseType;
  481. let courseId = ret[0][0].courseId;
  482. let userid = req.body[0].uid;
  483. delCourseType(course, courseId, userid);
  484. res.end(JSON.stringify({ ordernumber: ret[0][0].ordernumber, courseId: ret[0][0].courseId, success: 1 }));
  485. });
  486. }
  487. });
  488. //新增赛事项目
  489. router.route('/addRace').all((req, res, next) => {
  490. if (req.body[0]) {
  491. 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];
  492. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "addRace"); //執行存儲過程
  493. mysql.usselect(p, function(ret) {
  494. let course = req.body[0].courseType;
  495. let courseId = ret[0][0].id;
  496. let userid = req.body[0].uid;
  497. delCourseType1(course, courseId, userid);
  498. res.end(JSON.stringify({ courseId: courseId, success: 1 }));
  499. });
  500. }
  501. });
  502. //新增赛事账号信息
  503. router.route('/addRaceUser').all((req, res, next) => {
  504. if (req.body[0]) {
  505. p = [req.body[0].reg, req.body[0].res, req.body[0].sch, req.body[0].n, req.body[0].p, req.body[0].t, req.body[0].parent];
  506. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "addRaceUser"); //執行存儲過程
  507. mysql.usselect(p, function(ret) {
  508. let num = ret[0][0].num;
  509. let userid = ret[0][0].userid;
  510. if (num < 10) {
  511. num = "SZ" + "00" + num + "@gdae.com";
  512. } else if (num < 100) {
  513. num = "SZ" + "0" + num + "@gdae.com";
  514. } else if (num > 100) {
  515. num = "SZ" + num + "@gdae.com";
  516. }
  517. y = [userid, num, bcrypt.hashSync("123456", bcrypt.genSaltSync(10))];
  518. //参数拼接,注册
  519. y.unshift(_mysqlLabor[0], _mysqlLabor[1], "upRaceUserNamePassword");
  520. mysql.usselect(y, function(ret) {
  521. res.end(JSON.stringify(ret));
  522. });
  523. res.end(JSON.stringify({ num: num, success: 1 }));
  524. });
  525. }
  526. });
  527. //修改赛事项目
  528. router.route('/updateRace').all((req, res, next) => {
  529. if (req.body[0]) {
  530. 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];
  531. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "updateRace"); //執行存儲過程
  532. mysql.usselect(p, function(ret) {
  533. let course = req.body[0].courseType;
  534. let courseId = req.body[0].id;
  535. let userid = req.body[0].uid;
  536. delCourseType1(course, courseId, userid);
  537. res.end(JSON.stringify({ success: 1 }));
  538. });
  539. }
  540. });
  541. router.route('/addWorkNew3').all((req, res, next) => {
  542. if (req.body[0]) {
  543. 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];
  544. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "insert_teacher_work_new3"); //執行存儲過程
  545. mysql.usselect(p, function(ret) {
  546. let course = req.body[0].courseType;
  547. let courseId = ret[0][0].courseId;
  548. let userid = req.body[0].uid;
  549. delCourseType(course, courseId, userid);
  550. res.end(JSON.stringify({ ordernumber: ret[0][0].ordernumber, courseId: ret[0][0].courseId, success: 1 }));
  551. });
  552. }
  553. });
  554. function delCourseType(course, courseId, userid) {
  555. let _courseId = courseId;
  556. var _userdata = [
  557. _courseId
  558. ];
  559. _userdata.unshift(_mysqlLabor[0], _mysqlLabor[1], "delete_courseType");
  560. mysql.usselect(_userdata, function(ret) {
  561. // console.log(ret);
  562. });
  563. setTimeout(() => {
  564. addCourseType(userid, course, _courseId)
  565. }, 1000);
  566. }
  567. function delCourseType1(course, courseId, userid) {
  568. let _courseId = courseId;
  569. var _userdata = [
  570. _courseId
  571. ];
  572. _userdata.unshift(_mysqlLabor[0], _mysqlLabor[1], "delete_courseType1");
  573. mysql.usselect(_userdata, function(ret) {
  574. // console.log(ret);
  575. });
  576. setTimeout(() => {
  577. addCourseType1(userid, course, _courseId)
  578. }, 1000);
  579. }
  580. function addCourseType(userid, course, _courseId) {
  581. var _uid = userid;
  582. var _courses = _courseId
  583. var _tid = JSON.parse(course)
  584. for (let i = 0; i < _tid.length; i++) {
  585. if (_tid[i] == '') {
  586. continue;
  587. }
  588. var _userdata = [
  589. _courses,
  590. _tid[i],
  591. _uid,
  592. ];
  593. _userdata.unshift(_mysqlLabor[0], _mysqlLabor[1], "add_courseType");
  594. mysql.usselect(_userdata, function(ret) {
  595. // console.log(ret);
  596. });
  597. }
  598. }
  599. function addCourseType1(userid, course, _courseId) {
  600. var _uid = userid;
  601. var _courses = _courseId
  602. var _tid = JSON.parse(course)
  603. for (let i = 0; i < _tid.length; i++) {
  604. if (_tid[i] == '') {
  605. continue;
  606. }
  607. var _userdata = [
  608. _courses,
  609. _tid[i],
  610. _uid,
  611. ];
  612. _userdata.unshift(_mysqlLabor[0], _mysqlLabor[1], "add_courseType1");
  613. mysql.usselect(_userdata, function(ret) {
  614. // console.log(ret);
  615. });
  616. }
  617. }
  618. //修改课程
  619. // router.route('/updateWork').all((req, res, next) => {
  620. // postmysql(req, res, "update_teacher_work");
  621. // });
  622. router.route('/updateWorkNew').all((req, res, next) => {
  623. if (req.body[0]) {
  624. // p = Object.values(req.body[0]);
  625. 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];
  626. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "update_teacher_work_new");
  627. //執行存儲過程
  628. mysql.usselect(p, function(ret) {
  629. let course = req.body[0].courseType;
  630. let courseId = req.body[0].cid;
  631. let userid = req.body[0].uid;
  632. delCourseType(course, courseId, userid);
  633. res.end(JSON.stringify({ success: 1 }));
  634. // res.end(JSON.stringify(ret));
  635. });
  636. }
  637. });
  638. //查询课程
  639. // router.route('/selectCourse').all((req, res, next) => {
  640. // var json = queryString(req.url);
  641. // getmysql(req, res, "select_course", json['type'], json['uid'], json['oid'], json['page'], 10);
  642. // });
  643. router.route('/updateWorkNew2').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].evaId, req.body[0].astudent, req.body[0].see, req.body[0].chapters, req.body[0].template];
  646. // p.unshift(_mysqlLabor[0], _mysqlLabor[1], "update_teacher_work_new2"); //執行存儲過程
  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. if (req.body[0]) {
  656. 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];
  657. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "update_teacher_work_new2"); //執行存儲過程
  658. mysql.usselect(p, function(ret) {
  659. let course = req.body[0].courseType;
  660. let courseId = req.body[0].cid;
  661. let userid = req.body[0].uid;
  662. delCourseType(course, courseId, userid);
  663. res.end(JSON.stringify({ success: 1 }));
  664. });
  665. }
  666. });
  667. router.route('/updateWorkNew3').all((req, res, next) => {
  668. if (req.body[0]) {
  669. 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];
  670. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "update_teacher_work_new3"); //執行存儲過程
  671. mysql.usselect(p, function(ret) {
  672. let course = req.body[0].courseType;
  673. let courseId = req.body[0].cid;
  674. let userid = req.body[0].uid;
  675. delCourseType(course, courseId, userid);
  676. res.end(JSON.stringify({ success: 1 }));
  677. });
  678. }
  679. });
  680. function guid() {
  681. var _num,
  682. i,
  683. _guid = "";
  684. for (i = 0; i < 32; i++) {
  685. _guid += Math.floor(Math.random() * 16).toString(16); //随机0 - 16 的数字 转变为16进制的字符串
  686. _num = Math.floor((i - 7) / 4); //计算 (i-7)除4
  687. if (_num > -1 && _num < 4 && i == 7 + 4 * _num) {
  688. //会使guid中间加 "-" 形式为xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
  689. _guid += "-";
  690. }
  691. }
  692. return _guid;
  693. }
  694. router.route('/updateWorkNew4').all((req, res, next) => {
  695. if (req.body[0]) {
  696. let p = [req.body[0].cid];
  697. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "select_course_detail"); //執行存儲過程
  698. mysql.usselect(p, function(ret) {
  699. let _unitIndex = parseInt(req.body[0].unitIndex);
  700. let _chapters = JSON.parse(req.body[0].chapters);
  701. let _unitJson = JSON.parse(ret[0][0].chapters)
  702. if ((_unitJson.length - 1) < _unitIndex) {
  703. let _i = _unitIndex - (_unitJson.length - 1)
  704. for (let i = 0; i < _i; i++) {
  705. _unitJson.push({
  706. dyName: "", //单元标题
  707. chapterInfo: [{
  708. isread: false,
  709. chapterid: guid(),
  710. title: "",
  711. courseName: "",
  712. taskJson: [{
  713. task: "",
  714. taskDetail: "",
  715. chapterData: [],
  716. toolText: "",
  717. toolChoose: [{
  718. tool: [],
  719. toolDetail: "",
  720. toolType: 0,
  721. askCount: 1,
  722. askTitle: "",
  723. askJson: [{ askstitle: "", askItem: 1, checkList: [] }],
  724. }, ],
  725. isShowTools: false,
  726. askCount: 1,
  727. isFold: 0,
  728. askTitle: "",
  729. askJson: [{ askstitle: "", askItem: 1, checkList: [] }],
  730. checkJson: [{ checkCount: [], checkPerent: [] }],
  731. homeworkList: [],
  732. }, ],
  733. itemCount: 1,
  734. fileList1: [],
  735. video: [],
  736. testData: [],
  737. pData: [],
  738. templateArray: [],
  739. }, ],
  740. })
  741. }
  742. _unitJson[_unitIndex] = _chapters[_unitIndex]
  743. } else {
  744. _unitJson[_unitIndex] = _chapters[_unitIndex]
  745. }
  746. // console.log(_unitJson);
  747. let p2 = [req.body[0].cid, JSON.stringify(_unitJson).replaceAll(/%/g, "%25")];
  748. p2.unshift(_mysqlLabor[0], _mysqlLabor[1], "update_teacher_work_new4"); //執行存儲過程
  749. mysql.usselect(p2, function(ret) {
  750. res.end(JSON.stringify({ success: 1 }));
  751. });
  752. // res.end(JSON.stringify({ success: 1 }));
  753. });
  754. }
  755. });
  756. //协同删除阶段
  757. router.route('/deleteWork').all((req, res, next) => {
  758. if (req.body[0]) {
  759. let p = [req.body[0].cid];
  760. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "select_course_detail"); //執行存儲過程
  761. mysql.usselect(p, function(ret) {
  762. let _chapid = req.body[0].chapid;
  763. // console.log(_chapid);
  764. let _chapters = JSON.parse(req.body[0].chapters);
  765. let _unitJson = JSON.parse(ret[0][0].chapters)
  766. let _unitJson2 = []
  767. for (var i = 0; i < _unitJson.length; i++) {
  768. if (_unitJson[i].chapterInfo[0].chapterid != _chapid) {
  769. // console.log(1);
  770. // _unitJson.splice(i, -1)
  771. _unitJson2.push(_unitJson[i])
  772. // break;
  773. }
  774. }
  775. // console.log(_unitJson2);
  776. let p2 = [req.body[0].cid, JSON.stringify(_unitJson2).replaceAll(/%/g, "%25")];
  777. p2.unshift(_mysqlLabor[0], _mysqlLabor[1], "update_teacher_work_new4"); //執行存儲過程
  778. mysql.usselect(p2, function(ret) {
  779. res.end(JSON.stringify({ success: 1 }));
  780. });
  781. // res.end(JSON.stringify({ success: 1 }));
  782. });
  783. }
  784. });
  785. //协同恢复删除的阶段
  786. router.route('/restoreWork').all((req, res, next) => {
  787. if (req.body[0]) {
  788. let p = [req.body[0].cid];
  789. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "select_course_detail"); //執行存儲過程
  790. mysql.usselect(p, function(ret) {
  791. let _chapid = req.body[0].chapid;
  792. // console.log(_chapid);
  793. let _chapters = JSON.parse(req.body[0].chapters);
  794. let _unitJson = JSON.parse(ret[0][0].chapters)
  795. let _unitJson2 = []
  796. let chpaindex;
  797. for (var i = 0; i < _chapters.length; i++) {
  798. if (_chapters[i].chapterInfo[0].chapterid == _chapid) {
  799. chpaindex = i
  800. }
  801. }
  802. for (var i = 0; i < _unitJson.length; i++) {
  803. if (_unitJson[i].chapterInfo[0].chapterid != _chapid) {
  804. // console.log(1);
  805. // _unitJson.splice(i, -1)
  806. _unitJson2.push(_unitJson[i])
  807. // break;
  808. }
  809. }
  810. _unitJson2.splice(chpaindex, 0, _chapters[chpaindex])
  811. // console.log(_unitJson2);
  812. let p2 = [req.body[0].cid, JSON.stringify(_unitJson2).replaceAll(/%/g, "%25")];
  813. p2.unshift(_mysqlLabor[0], _mysqlLabor[1], "update_teacher_work_new4"); //執行存儲過程
  814. mysql.usselect(p2, function(ret) {
  815. res.end(JSON.stringify({ success: 1 }));
  816. });
  817. // res.end(JSON.stringify({ success: 1 }));
  818. });
  819. }
  820. });
  821. router.route('/selectCourseNew').all((req, res, next) => {
  822. var json = queryString(req.url);
  823. 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);
  824. });
  825. router.route('/selectCourseNew2').all((req, res, next) => {
  826. var json = queryString(req.url);
  827. 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);
  828. });
  829. //查询协同编辑课程
  830. router.route('/selectCourseTeam').all((req, res, next) => {
  831. var json = queryString(req.url);
  832. getmysql(req, res, "selectCourseTeam", json['uid'], json['oid']);
  833. });
  834. //查询学校
  835. router.route('/selectSchoolName').all((req, res, next) => {
  836. var json = queryString(req.url);
  837. getmysql(req, res, "selectOidName", json['page'], 10);
  838. });
  839. //查询学校
  840. router.route('/selectSchoolName2').all((req, res, next) => {
  841. var json = queryString(req.url);
  842. getmysql(req, res, "selectOidName2", json['oid']);
  843. });
  844. //查询学校
  845. router.route('/selectSchoolNameOrg').all((req, res, next) => {
  846. var json = queryString(req.url);
  847. getmysql(req, res, "selectSchoolNameOrg", json['org'], json['page'], 10);
  848. });
  849. //新增批注
  850. router.route('/addPz').all((req, res, next) => {
  851. postmysql(req, res, "addPz");
  852. });
  853. //新增批注
  854. router.route('/addPz2').all((req, res, next) => {
  855. postmysql(req, res, "addPz2");
  856. });
  857. //删除批注
  858. router.route('/deletePz').all((req, res, next) => {
  859. postmysql(req, res, "deletePz");
  860. });
  861. //查询批注列表
  862. router.route('/selectPzList').all((req, res, next) => {
  863. var json = queryString(req.url);
  864. getmysql(req, res, "selectPzList", json['cid'], json['s'], json['t']);
  865. });
  866. //评分
  867. router.route('/scoreWork').all((req, res, next) => {
  868. postmysql(req, res, "scoreWork");
  869. });
  870. //删除学生
  871. router.route('/deleteStudent').all((req, res, next) => {
  872. postmysql(req, res, "delete_student");
  873. });
  874. //查询学校底下的班级
  875. router.route('/selectClassBySchool').all((req, res, next) => {
  876. var json = queryString(req.url);
  877. getmysql(req, res, "selectClassBySchool", json['oid']);
  878. });
  879. //查询组织底下的学校
  880. router.route('/selectSchoolByOrg').all((req, res, next) => {
  881. var json = queryString(req.url);
  882. getmysql(req, res, "selectSchoolByOrg", json['org']);
  883. });
  884. //学生注册接口
  885. router.route('/register_student').post(function(req, res, next) {
  886. //mode的处理
  887. if (req.body[0]) {
  888. // 0 用户名 1 用户密码 2用户身份 3 第三方id(可有可无)
  889. p = Object.values(req.body[0]); //获取用户密码
  890. //没有第三方id的处理
  891. // if (p.length < 4) {
  892. // p.push("")
  893. // }
  894. p[1] = bcrypt.hashSync(p[1], bcrypt.genSaltSync(10));
  895. //密码加密
  896. // bcrypt.hash(p[1], 10, function (err, hash) {
  897. // if (err) {
  898. // return next(err);
  899. // }
  900. // p[1] = hash;
  901. // });
  902. //参数拼接,注册
  903. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "register_student");
  904. //返回注册用户数据
  905. // mysql.usselect(p, function (ret) {
  906. // res.end(ret);
  907. // });
  908. mysql.usselect(p, function(ret) {
  909. res.end(JSON.stringify(ret));
  910. });
  911. }
  912. });
  913. //查询课程详情
  914. router.route('/selectCourseDetail').all((req, res, next) => {
  915. var json = queryString(req.url);
  916. getmysql(req, res, "selectCourseDetail", json['courseId']);
  917. });
  918. //跳转阶段时,如果有课程就查询1返回,如果没有就插入
  919. router.route('/addUserR').all((req, res, next) => {
  920. var json = queryString(req.url);
  921. getmysql(req, res, "insertUserR", json['uid'], json['cid']);
  922. });
  923. //新增学生端作业
  924. router.route('/addWorks').all((req, res, next) => {
  925. postmysql(req, res, "add_works");
  926. });
  927. //查询已提交作业
  928. router.route('/selectWork').all((req, res, next) => {
  929. var json = queryString(req.url);
  930. getmysql(req, res, "selectWork", json['cid'], json['stage'], json['task'], json['uid']);
  931. });
  932. //查询作业详情
  933. router.route('/selectWorksDetail').all((req, res, next) => {
  934. var json = queryString(req.url);
  935. getmysql(req, res, "selectWorksDetail", json['uid'], json['cid']);
  936. });
  937. //新增作业评分
  938. router.route('/updateWorks').all((req, res, next) => {
  939. var json = queryString(req.url);
  940. getmysql(req, res, "updateWorks", json['rate'], json['tuid'], json['id']);
  941. });
  942. //新增素材信息
  943. router.route('/addMtl').all((req, res, next) => {
  944. var json = queryString(req.url);
  945. getmysql(req, res, "add_mtl", json['cInfo'], json['t'], json['cBy']);
  946. });
  947. //根据类型查询素材信息
  948. router.route('/selectMtl').all((req, res, next) => {
  949. var json = queryString(req.url);
  950. getmysql(req, res, "selectMtl", json['t'], json['page'], 10);
  951. });
  952. //根据类型查询素材信息
  953. router.route('/selectMtl2').all((req, res, next) => {
  954. var json = queryString(req.url);
  955. getmysql(req, res, "selectMtl2", json['t'], json['uid'], json['page'], 10);
  956. });
  957. //学习中心
  958. //新增学习资源信息
  959. router.route('/addStuMtl').all((req, res, next) => {
  960. var json = queryString(req.url);
  961. getmysql(req, res, "addStuMtl", json['cInfo'], json['t'], json['cBy']);
  962. });
  963. //根据类型查询学习资料信息
  964. router.route('/selectStuMtl').all((req, res, next) => {
  965. var json = queryString(req.url);
  966. getmysql(req, res, "selectStuMtl", json['t'], json['page'], 10);
  967. });
  968. //删除素材
  969. router.route('/deleteStuM').all((req, res, next) => {
  970. var json = queryString(req.url);
  971. getmysql(req, res, "deleteStuM", json['id']);
  972. });
  973. //查询学生信息
  974. router.route('/selectSDetail').all((req, res, next) => {
  975. var json = queryString(req.url);
  976. getmysql(req, res, "selectStudentDetail", json['uid']);
  977. });
  978. //查询个人课程
  979. router.route('/selectMyCourse').all((req, res, next) => {
  980. var json = queryString(req.url);
  981. getmysql(req, res, "selectMyCourse", json['uid']);
  982. });
  983. //查询个人课程groupby课程id
  984. router.route('/selectMyCourseBycid').all((req, res, next) => {
  985. var json = queryString(req.url);
  986. getmysql(req, res, "selectMyCourseBycid", json['uid']);
  987. });
  988. //查询所有课程
  989. router.route('/selectAllCourse').all((req, res, next) => {
  990. var json = queryString(req.url);
  991. getmysql(req, res, "selectAllCourse", json['oid'], json['page'], 10);
  992. });
  993. //根据班级查询所有课程
  994. router.route('/selectAllCourseByCid').all((req, res, next) => {
  995. var json = queryString(req.url);
  996. getmysql(req, res, "selectAllCourseByCid", json['oid'], json['cid'], json['page'], 10);
  997. });
  998. //根据分类查询所有课程
  999. router.route('/selectTypeCourse').all((req, res, next) => {
  1000. var json = queryString(req.url);
  1001. 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);
  1002. });
  1003. //根据分类查询所有课程
  1004. router.route('/selectTypeCourse2').all((req, res, next) => {
  1005. var json = queryString(req.url);
  1006. 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);
  1007. });
  1008. //删除素材
  1009. router.route('/deleteM').all((req, res, next) => {
  1010. var json = queryString(req.url);
  1011. getmysql(req, res, "deleteM", json['id']);
  1012. });
  1013. //点击阶段时添加观看人数
  1014. router.route('/updateVc').all((req, res, next) => {
  1015. var json = queryString(req.url);
  1016. getmysql(req, res, "updateVc", json['cid']);
  1017. });
  1018. //删除课程
  1019. router.route('/deleteCourse').all((req, res, next) => {
  1020. var json = queryString(req.url);
  1021. getmysql(req, res, "deleteCourse", json['cid']);
  1022. });
  1023. //查看课程
  1024. router.route('/select_course_detail').all((req, res, next) => {
  1025. var json = queryString(req.url);
  1026. getmysql(req, res, "select_course_detail", json['cid']);
  1027. });
  1028. //模糊查找课程
  1029. // router.route('/searchCourse').all((req, res, next) => {
  1030. // var json = queryString(req.url);
  1031. // getmysql(req, res, "searchCourse", json['cu'], json['cn'], json['page'], 10);
  1032. // });
  1033. //创建调查问卷
  1034. router.route('/addAsk').all((req, res, next) => {
  1035. postmysql(req, res, "insert_ask");
  1036. });
  1037. //学生提交问卷
  1038. router.route('/addAskList').all((req, res, next) => {
  1039. postmysql(req, res, "insert_askList");
  1040. });
  1041. //根据课程id阶段id获取已提交的问卷
  1042. router.route('/getAskListByCidStage').all((req, res, next) => {
  1043. var json = queryString(req.url);
  1044. getmysql(req, res, "getAskListByCidStage", json['cid'], json['stage'], json['task']);
  1045. });
  1046. //获取调查问卷
  1047. router.route('/getAsk').all((req, res, next) => {
  1048. var json = queryString(req.url);
  1049. getmysql(req, res, "select_ask", json['uid'], json['page'], 10);
  1050. });
  1051. //删除问卷
  1052. router.route('/deleteAsk').all((req, res, next) => {
  1053. postmysql(req, res, "deleteAsk");
  1054. });
  1055. //问卷调查数据统计
  1056. router.route('/getAskListByAskid').all((req, res, next) => {
  1057. var json = queryString(req.url);
  1058. getmysql(req, res, "select_askListByAskid", json['aid']);
  1059. });
  1060. //删除学生提交问卷
  1061. router.route('/deleteAskList').all((req, res, next) => {
  1062. postmysql(req, res, "update_askList_delete");
  1063. });
  1064. //根据id获取调查问卷
  1065. router.route('/getAskList').all((req, res, next) => {
  1066. var json = queryString(req.url);
  1067. getmysql(req, res, "select_askList", json['uid'], json['page'], 10);
  1068. });
  1069. //查看便签列表
  1070. router.route('/selectNote').all((req, res, next) => {
  1071. var json = queryString(req.url);
  1072. getmysql(req, res, "selectNote", json['uid']);
  1073. });
  1074. //新增便签列表
  1075. router.route('/insertNote').all((req, res, next) => {
  1076. var json = queryString(req.url);
  1077. getmysql(req, res, "insertNote", json['uid'], json['c']);
  1078. });
  1079. //根据便签id修改便签内容
  1080. router.route('/updateNote').all((req, res, next) => {
  1081. var json = queryString(req.url);
  1082. getmysql(req, res, "updateNote", json['nid'], json['c']);
  1083. });
  1084. //删除便签
  1085. router.route('/deleteNote').all((req, res, next) => {
  1086. var json = queryString(req.url);
  1087. getmysql(req, res, "deleteNote", json['nid']);
  1088. });
  1089. //查询便签
  1090. router.route('/selectNoteContent').all((req, res, next) => {
  1091. var json = queryString(req.url);
  1092. getmysql(req, res, "selectNoteContent", json['cn']);
  1093. });
  1094. //修改用户信息
  1095. router.route('/updateUserByEdu').all((req, res, next) => {
  1096. postmysql(req, res, "updateUserByEdu");
  1097. });
  1098. //修改用户信息
  1099. router.route('/updateUserByEdu1').all((req, res, next) => {
  1100. postmysql(req, res, "updateUserByEdu1");
  1101. });
  1102. //修改用户信息
  1103. router.route('/updateUserByEduOid').all((req, res, next) => {
  1104. postmysql(req, res, "updateUserByEduOid");
  1105. });
  1106. //教师端data修改pbl用户信息
  1107. router.route('/updatePblMessage').all((req, res, next) => {
  1108. postmysql2(req, res, "updatePblMessage");
  1109. });
  1110. router.route('/updatePblMessage2').all((req, res, next) => {
  1111. postmysql(req, res, "updatePblMessage");
  1112. });
  1113. router.route('/updateRaceUser').all((req, res, next) => {
  1114. postmysql(req, res, "updateRaceUser");
  1115. });
  1116. //查询用户信息
  1117. router.route('/selectUser').all((req, res, next) => {
  1118. var json = queryString(req.url);
  1119. getmysql(req, res, "selectUser", json['userid']);
  1120. });
  1121. //查询分类及子分类
  1122. router.route('/selectType').all((req, res, next) => {
  1123. var json = queryString(req.url);
  1124. getmysql(req, res, "selectType", );
  1125. });
  1126. //查询赛事分类及子分类
  1127. router.route('/selectMatType').all((req, res, next) => {
  1128. var json = queryString(req.url);
  1129. getmysql(req, res, "selectMatType", );
  1130. });
  1131. //根据学校查询分类
  1132. router.route('/selectPtype').all((req, res, next) => {
  1133. var json = queryString(req.url);
  1134. getmysql(req, res, "selectPtype", json["page"], 10);
  1135. });
  1136. //添加分类
  1137. router.route('/addPtype').all((req, res, next) => {
  1138. var json = queryString(req.url);
  1139. getmysql(req, res, "addPtype", json["n"], json["uid"], json["oid"]);
  1140. });
  1141. //修改分类
  1142. router.route('/updatePtype').all((req, res, next) => {
  1143. var json = queryString(req.url);
  1144. getmysql(req, res, "updatePtype", json["n"], json["tid"]);
  1145. });
  1146. //删除分类
  1147. router.route('/deletePtype').all((req, res, next) => {
  1148. var json = queryString(req.url);
  1149. getmysql(req, res, "deletePtype", json["tid"]);
  1150. });
  1151. //查询子分类列表
  1152. router.route('/selectStype').all((req, res, next) => {
  1153. var json = queryString(req.url);
  1154. getmysql(req, res, "selectStype", json["pid"], json["oid"], json["page"], 10);
  1155. });
  1156. //添加子分类
  1157. router.route('/addStype').all((req, res, next) => {
  1158. var json = queryString(req.url);
  1159. getmysql(req, res, "addStype", json["pid"], json["n"], json["uid"], json["oid"]);
  1160. });
  1161. //根据学校id查询子分类
  1162. router.route('/selectTypeByOid').all((req, res, next) => {
  1163. var json = queryString(req.url);
  1164. getmysql(req, res, "selectTypeByOid", json["oid"]);
  1165. });
  1166. //根据组织id查询子分类
  1167. router.route('/selectTypeByOrg').all((req, res, next) => {
  1168. var json = queryString(req.url);
  1169. getmysql(req, res, "selectTypeByOrg", json["oid"]);
  1170. });
  1171. //更加父id查询分类
  1172. router.route('/selectTypeByPid').all((req, res, next) => {
  1173. var json = queryString(req.url);
  1174. getmysql(req, res, "selectTypeByPid", json['pid']);
  1175. });
  1176. //点击工具计数
  1177. router.route('/insertToolsCount').all((req, res, next) => {
  1178. var json = queryString(req.url);
  1179. getmysql(req, res, "insertToolsCount", json['cid'], json['chid'], json['uid'], json['tid'], json['count']);
  1180. });
  1181. //修改工具次数
  1182. router.route('/updateToolsCount').all((req, res, next) => {
  1183. var json = queryString(req.url);
  1184. getmysql(req, res, "updateToolsCount", json['cid'], json['chid'], json['uid'], json['tid'], json['count']);
  1185. });
  1186. //查询工具次数
  1187. router.route('/selectToolsCount').all((req, res, next) => {
  1188. var json = queryString(req.url);
  1189. getmysql(req, res, "selectToolsCount", json['cid'], json['chid'], json['uid']);
  1190. });
  1191. //导出学生
  1192. router.route('/selectUserBySchool').all((req, res, next) => {
  1193. var json = queryString(req.url);
  1194. getmysql(req, res, "selectUserBySchool", json['oid']);
  1195. });
  1196. //上传学生作业
  1197. router.route('/insertSWork').all((req, res, next) => {
  1198. var json = queryString(req.url);
  1199. getmysql(req, res, "insertSWork", json['uid'], json['cid'], json['p'], json['t'], json['upload']);
  1200. });
  1201. //查询学生作业
  1202. router.route('/selectSWork').all((req, res, next) => {
  1203. var json = queryString(req.url);
  1204. getmysql(req, res, "selectSWork", json['uid'], json['cid'], json['p'], json['type']);
  1205. });
  1206. //查询赛事案例设计
  1207. router.route('/selectCase').all((req, res, next) => {
  1208. var json = queryString(req.url);
  1209. getmysql(req, res, "selectCase", json['org']);
  1210. });
  1211. //查询赛事案例设计
  1212. router.route('/selectCase2').all((req, res, next) => {
  1213. var json = queryString(req.url);
  1214. getmysql(req, res, "selectCase2", json['org']);
  1215. });
  1216. //查询赛事项目列表
  1217. router.route('/selectRaceList').all((req, res, next) => {
  1218. var json = queryString(req.url);
  1219. getmysql(req, res, "selectRaceList", json['uid']);
  1220. });
  1221. //修改赛事状态
  1222. router.route('/updateRaceState').all((req, res, next) => {
  1223. var json = queryString(req.url);
  1224. getmysql(req, res, "updateRaceState", json['id']);
  1225. });
  1226. //查询赛事项目详情
  1227. router.route('/selectRaceDetail').all((req, res, next) => {
  1228. var json = queryString(req.url);
  1229. getmysql(req, res, "selectRaceDetail", json['id']);
  1230. });
  1231. //race 查询学校
  1232. router.route('/getSchool').all((req, res, next) => {
  1233. var json = queryString(req.url);
  1234. getmysql(req, res, "getSchool", json['n']);
  1235. });
  1236. //lsc
  1237. //admin 查询学校
  1238. router.route('/getSchoolAdmin').all((req, res, next) => {
  1239. var json = queryString(req.url);
  1240. getmysql(req, res, "select_school", json['page'], 10);
  1241. });
  1242. //admin 添加学校
  1243. router.route('/addSchoolAdmin').all((req, res, next) => {
  1244. postmysql(req, res, "add_school");
  1245. });
  1246. //组织添加学校
  1247. router.route('/addSchoolOrg').all((req, res, next) => {
  1248. postmysql(req, res, "addSchoolOrg");
  1249. });
  1250. //admin 删除学校
  1251. router.route('/deleteSchoolAdmin').all((req, res, next) => {
  1252. postmysql(req, res, "delete_school");
  1253. });
  1254. //admin 查询班级
  1255. router.route('/getClassAdmin').all((req, res, next) => {
  1256. var json = queryString(req.url);
  1257. getmysql(req, res, "select_classAdmin", json['cn'], json['page'], 10);
  1258. });
  1259. //admin 添加班级
  1260. router.route('/addClassAdmin').all((req, res, next) => {
  1261. postmysql(req, res, "add_classAdmin");
  1262. });
  1263. //admin 查询班级是否重复
  1264. router.route('/getClassRepeat').all((req, res, next) => {
  1265. var json = queryString(req.url);
  1266. getmysql(req, res, "select_classRepeatAdmin", json['n'], json['oid']);
  1267. });
  1268. //admin 发布通知
  1269. router.route('/addNews').all((req, res, next) => {
  1270. postmysql(req, res, "add_news");
  1271. });
  1272. //admin 删除通知
  1273. router.route('/deleteNews').all((req, res, next) => {
  1274. postmysql(req, res, "delete_news");
  1275. });
  1276. //admin 添加banner
  1277. router.route('/addBanner').all((req, res, next) => {
  1278. postmysql(req, res, "add_banner");
  1279. });
  1280. //admin 添加banner
  1281. router.route('/deleteBanner').all((req, res, next) => {
  1282. postmysql(req, res, "delete_banner");
  1283. });
  1284. //admin 查询banner
  1285. router.route('/getBanner').all((req, res, next) => {
  1286. var json = queryString(req.url);
  1287. getmysql(req, res, "select_banner");
  1288. });
  1289. //根据学校查询banner
  1290. router.route('/selectBannerByOid').all((req, res, next) => {
  1291. var json = queryString(req.url);
  1292. getmysql(req, res, "selectBannerByOid", json["oid"]);
  1293. });
  1294. //admin 查询课程getSearchCourse
  1295. router.route('/getSearchCourse').all((req, res, next) => {
  1296. var json = queryString(req.url);
  1297. getmysql(req, res, "selectAll_courseSearch", json['t']);
  1298. });
  1299. //根据学校查询课程
  1300. router.route('/getSearchCourseByoid').all((req, res, next) => {
  1301. var json = queryString(req.url);
  1302. getmysql(req, res, "selectAll_courseByOid", json['t'], json['oid']);
  1303. });
  1304. //admin 查询所有课程专区
  1305. router.route('/getZone').all((req, res, next) => {
  1306. getmysql(req, res, "select_zone");
  1307. });
  1308. //admin 添加课程专区
  1309. router.route('/addZone').all((req, res, next) => {
  1310. postmysql(req, res, "insert_classZone");
  1311. });
  1312. //查询所有课程专区下的课程
  1313. router.route('/getZoneClass').all((req, res, next) => {
  1314. var json = queryString(req.url);
  1315. getmysql(req, res, "select_zoneClass", json['bid'], json['oid'], json['page'], 10);
  1316. });
  1317. //查询所有课程专区下的课程
  1318. router.route('/getZoneClassStudent').all((req, res, next) => {
  1319. var json = queryString(req.url);
  1320. getmysql(req, res, "select_zoneClass", json['bid'], json['oid'], json['page'], 20);
  1321. });
  1322. //admin 后台查看专区下课程的数量
  1323. router.route('/getZoneClassNum').all((req, res, next) => {
  1324. var json = queryString(req.url);
  1325. getmysql(req, res, "select_zoneClassNum", json['bid']);
  1326. });
  1327. //admin 后台添加课程专区时查看课程是否在此专区重复
  1328. router.route('/getZoneClassRepeat').all((req, res, next) => {
  1329. var json = queryString(req.url);
  1330. getmysql(req, res, "select_zoneClassRepeat", json['pid'], json['cid']);
  1331. });
  1332. //把课程添加进专区
  1333. router.route('/addZoneCourse').all((req, res, next) => {
  1334. postmysql(req, res, "insert_app");
  1335. });
  1336. //admin 删除课程专区底下的课程
  1337. router.route('/deleteZoneCourse').all((req, res, next) => {
  1338. postmysql(req, res, "delete_app");
  1339. });
  1340. //admin 删除班级
  1341. router.route('/deleteZone').all((req, res, next) => {
  1342. postmysql(req, res, "delete_zone");
  1343. });
  1344. //admin 后台专区上移下移
  1345. router.route('/zoneRank').all((req, res, next) => {
  1346. postmysql(req, res, "update_classRank");
  1347. });
  1348. //admin 添加模板文档
  1349. router.route('/addTemplateAdmin').all((req, res, next) => {
  1350. postmysql(req, res, "add_template");
  1351. });
  1352. //admin 添加模板文档
  1353. router.route('/deleteTemplateAdmin').all((req, res, next) => {
  1354. postmysql(req, res, "delete_template");
  1355. });
  1356. //admin 查询模板文档
  1357. router.route('/getTemplateAdmin').all((req, res, next) => {
  1358. var json = queryString(req.url);
  1359. getmysql(req, res, "select_template", json['page'], 10);
  1360. });
  1361. //查询上传作业
  1362. router.route('/getCourseWorks').all((req, res, next) => {
  1363. var json = queryString(req.url); //cid 课程id,page 页数
  1364. getmysql(req, res, "select_courseWorks", json['cid'], json['stage'], json['task'], json['page'], 10);
  1365. });
  1366. //查询上传作业
  1367. router.route('/getCourseWorks2').all((req, res, next) => {
  1368. var json = queryString(req.url); //cid 课程id,page 页数
  1369. getmysql(req, res, "select_courseWorks2", json['cid'], json['uname'], json['stage'], json['task'], json['page'], 10);
  1370. });
  1371. //查询上传作业
  1372. router.route('/getCourseWorks3').all((req, res, next) => {
  1373. var json = queryString(req.url); //cid 课程id,page 页数
  1374. getmysql(req, res, "select_courseWorks3", json['cid'], json['uname'], json['stage'], json['task'], json['page'], 10);
  1375. });
  1376. //查询报告数据
  1377. router.route('/getCourseWorksReport').all((req, res, next) => {
  1378. var json = queryString(req.url); //cid 课程id,page 页数
  1379. getmysql(req, res, "getCourseWorksReport", json['cid']);
  1380. });
  1381. //admin 添加项目模板文档
  1382. router.route('/addCourseTemplateAdmin').all((req, res, next) => {
  1383. postmysql(req, res, "add_courseTemplate");
  1384. });
  1385. //admin 添加项目模板文档
  1386. router.route('/deleteCourseTemplateAdmin').all((req, res, next) => {
  1387. postmysql(req, res, "delete_courseTemplate");
  1388. });
  1389. //admin 查询项目模板文档
  1390. router.route('/getCourseTemplateAdmin').all((req, res, next) => {
  1391. var json = queryString(req.url);
  1392. getmysql(req, res, "select_courseTemplate", json['page'], 10);
  1393. });
  1394. //teacher 查询项目模板
  1395. router.route('/getCourseTemplateT').all((req, res, next) => {
  1396. var json = queryString(req.url);
  1397. getmysql(req, res, "select_courseTemplateT");
  1398. });
  1399. //admin 查询课程
  1400. router.route('/getCourseAdmin').all((req, res, next) => {
  1401. var json = queryString(req.url);
  1402. getmysql(req, res, "select_courseAdmin", json['cn'], json['page'], 10);
  1403. });
  1404. //admin 查询模板文档
  1405. router.route('/deleteCourseAdmin').all((req, res, next) => {
  1406. postmysql(req, res, "delete_courseAdmin");
  1407. });
  1408. //查询ppt在哪页
  1409. router.route('/selectPptPage').all((req, res, next) => {
  1410. var json = queryString(req.url);
  1411. getmysql(req, res, "selectPptPage", json['id']);
  1412. });
  1413. //修改ppt页码
  1414. router.route('/updatePptPage').all((req, res, next) => {
  1415. postmysql(req, res, "updatePptPage");
  1416. });
  1417. //修改ppt操作
  1418. router.route('/updatePPTHandle').all((req, res, next) => {
  1419. postmysql(req, res, "updatePPTHandle");
  1420. });
  1421. //查询实时课堂
  1422. router.route('/getRealTimeClass').all((req, res, next) => {
  1423. var json = queryString(req.url);
  1424. getmysql(req, res, "getRealTimeClass", json["cn"], json["uid"], json["page"], 10);
  1425. });
  1426. //查询实时课堂学生
  1427. router.route('/getRealTimeClassStu').all((req, res, next) => {
  1428. var json = queryString(req.url);
  1429. getmysql(req, res, "getRealTimeClassStu", json["oid"], json["cid"], json["page"], 10);
  1430. });
  1431. //查询实时课堂学生
  1432. router.route('/getRealTimeClassById').all((req, res, next) => {
  1433. var json = queryString(req.url);
  1434. getmysql(req, res, "getRealTimeClassById", json["id"]);
  1435. });
  1436. //根据市级管理者查询案例
  1437. router.route('/selectAnliList').all((req, res, next) => {
  1438. var json = queryString(req.url);
  1439. getmysql(req, res, "selectAnliList", json["cn"], json["page"], 10);
  1440. });
  1441. //teacher 查询模板
  1442. router.route('/getTemplateT').all((req, res, next) => {
  1443. var json = queryString(req.url);
  1444. getmysql(req, res, "select_templateT");
  1445. });
  1446. //思维网格 创建房间
  1447. router.route('/insertRoom').all((req, res, next) => {
  1448. postmysql(req, res, "insertRoom");
  1449. });
  1450. //协同编辑 创建房间
  1451. router.route('/insertRoomByFile').all((req, res, next) => {
  1452. //var json = queryString(req.url);
  1453. postmysql2(req, res, "insertRoomByFile");
  1454. //getmysql(req, res, "insertRoomByFile", json["uid"], json["n"], json["d"]);
  1455. });
  1456. //思维网格 查询是否是重复房间号
  1457. router.route('/checkRoomNum').all((req, res, next) => {
  1458. var json = queryString(req.url);
  1459. getmysql(req, res, "checkRoomNum", json['num']);
  1460. });
  1461. //思维网格 查询房间列表
  1462. router.route('/selectRoomList').all((req, res, next) => {
  1463. var json = queryString(req.url);
  1464. getmysql(req, res, "selectRoomList", json['uid'], json['oid'], json['cid'], json['cu'], json['cn']);
  1465. });
  1466. //查询pdf列表
  1467. router.route('/selectRTC').all((req, res, next) => {
  1468. var json = queryString(req.url);
  1469. getmysql(req, res, "selectRTC", json['uid'], json['cu'], json['cn']);
  1470. });
  1471. //协同文档 查询房间列表
  1472. router.route('/selectFileList').all((req, res, next) => {
  1473. var json = queryString(req.url);
  1474. getmysql(req, res, "selectFileList", json['uid'], json['oid'], json['cid'], json['cu'], json['cn']);
  1475. });
  1476. //协同编辑 查询是否是重复房间号
  1477. router.route('/checkRoomNumByFile').all((req, res, next) => {
  1478. var json = queryString(req.url);
  1479. getmysql(req, res, "checkRoomNumByFile", json['num']);
  1480. });
  1481. //思维网格 根据房间号或者用户id查询房间信息
  1482. router.route('/selectRoom').all((req, res, next) => {
  1483. var json = queryString(req.url);
  1484. getmysql(req, res, "selectRoom", json['uid']);
  1485. });
  1486. //思维网格 根据房间号或者用户id查询房间信息
  1487. router.route('/getRoom').all((req, res, next) => {
  1488. var json = queryString(req.url);
  1489. getmysql(req, res, "select_room", json['fid']);
  1490. });
  1491. //协同编辑 根据房间号或者用户id查询房间信息
  1492. router.route('/selectRoomByFile').all((req, res, next) => {
  1493. var json = queryString(req.url);
  1494. getmysql(req, res, "selectRoomByFile", json['uid']);
  1495. });
  1496. //思维网格 修改房间数据
  1497. router.route('/updateRoomData').all((req, res, next) => {
  1498. postmysql(req, res, "updateRoomData");
  1499. });
  1500. router.route('/updateFileData').all((req, res, next) => {
  1501. var json = queryString(req.url);
  1502. var json2 = json['mode'].split(',');
  1503. getmysql(req, res, "updateFileData", json2[0], json2[1]);
  1504. });
  1505. router.route('/select_file').all((req, res, next) => {
  1506. var json = queryString(req.url);
  1507. getmysql(req, res, "select_file", json['fid']);
  1508. });
  1509. //思维网格 解散房间
  1510. router.route('/dismiss').all((req, res, next) => {
  1511. postmysql(req, res, "update_room");
  1512. });
  1513. //提交提问
  1514. router.route('/addProblem').all((req, res, next) => {
  1515. postmysql(req, res, "add_problem");
  1516. //cid 课程id,chid 章节id,t 提问内容,uid 用户id
  1517. });
  1518. //查询提交的提问
  1519. router.route('/getProblem').all((req, res, next) => {
  1520. var json = queryString(req.url); //cid 课程id,page 页数
  1521. getmysql(req, res, "select_problem", json['cid'], json['page'], 10);
  1522. });
  1523. //获取用户基本信息
  1524. router.route('/getUserInfo').all((req, res, next) => {
  1525. var json = queryString(req.url);
  1526. getmysql(req, res, "getUserInfo", json['uid'], json['cid']);
  1527. });
  1528. //获取项目基本信息
  1529. router.route('/getCourseInfo').all((req, res, next) => {
  1530. var json = queryString(req.url);
  1531. getmysql(req, res, "getCourseInfo", json['cid']);
  1532. });
  1533. //作业生成报告
  1534. router.route('/getWorkData').all((req, res, next) => {
  1535. var json = queryString(req.url); //cid 课程id,page 页数
  1536. getmysql(req, res, "select_work_data", json['cid']);
  1537. });
  1538. //查询评价体系
  1539. router.route('/getEvaluation').all((req, res, next) => {
  1540. var json = queryString(req.url); //cid 课程id,page 页数
  1541. getmysql(req, res, "select_evaluation", json['oid'], json['n'], json['page'], 10);
  1542. });
  1543. //添加评价体系
  1544. router.route('/addEvaluation').all((req, res, next) => {
  1545. postmysql(req, res, "add_evaluation");
  1546. //uid 用户id t标题 c内容
  1547. });
  1548. //修改评价体系
  1549. router.route('/updateEvaluation').all((req, res, next) => {
  1550. postmysql(req, res, "update_evaluation");
  1551. //c内容 t标题 id评价id
  1552. });
  1553. //删除评价体系
  1554. router.route('/deleteEvaluation').all((req, res, next) => {
  1555. postmysql(req, res, "delete_evaluation");
  1556. // id评价id
  1557. });
  1558. //批量添加学生
  1559. router.route('/batchRegistrationMore').post(function(req, res, next) {
  1560. let users = req.body[0];
  1561. let arr = JSON.parse(req.body[0].arr);
  1562. for (let i = 0; i < arr.length; i++) {
  1563. let _username = arr[i].name;
  1564. let _mail = arr[i].mail;
  1565. let _password = users.password || "123456";
  1566. let _alias = arr[i].name;
  1567. let _oid = users.oid;
  1568. let _ph = arr[i].phone ? arr[i].phone : '';
  1569. let _class = arr[i].class;
  1570. let _sId = arr[i].sId;
  1571. //加密密碼
  1572. _password = bcrypt.hashSync(_password, bcrypt.genSaltSync(10));
  1573. //生成激活碼
  1574. let _hashstr = new Date().getTime() + "";
  1575. let _digest = crypto.createHash('sha256').update(_hashstr, 'utf8').digest('hex');
  1576. //用戶數據
  1577. let _userdata = [
  1578. _mail,
  1579. _password,
  1580. _alias,
  1581. "",
  1582. 1, //0老师 1学生
  1583. _username,
  1584. "",
  1585. generateAPIKey(_username),
  1586. _digest,
  1587. "",
  1588. _username,
  1589. _sId,
  1590. 2, //1老师 2学生
  1591. _oid,
  1592. _ph,
  1593. _class,
  1594. '',
  1595. "0",
  1596. ];
  1597. //參數拼接,註冊
  1598. _userdata.unshift(_mysqluser[0], _mysqluser[1], "pbl_add_batchregister");
  1599. //用戶註冊處理
  1600. mysql.usselect(_userdata, function(ret) {
  1601. // let _pbluserdata = [
  1602. // ret[1][0].uid,
  1603. // _username,
  1604. // _sId,
  1605. // 2,
  1606. // _oid,
  1607. // _ph,
  1608. // _class,
  1609. // '',
  1610. // "0",
  1611. // ];
  1612. // _pbluserdata.unshift(_mysqlLabor[0], _mysqlLabor[1], "updateUserByEdu");
  1613. // mysql.usselect(_pbluserdata, function(ret) {
  1614. res.end(JSON.stringify({ success: 1 }));
  1615. // });
  1616. });
  1617. }
  1618. });
  1619. //批量添加教师
  1620. router.route('/batchRegistrationMore1').post(function(req, res, next) {
  1621. let users = req.body[0];
  1622. let arr = JSON.parse(req.body[0].arr);
  1623. for (let i = 0; i < arr.length; i++) {
  1624. let _username = arr[i].name;
  1625. let _mail = arr[i].mail;
  1626. let _password = users.password || "123456";
  1627. let _alias = arr[i].name;
  1628. let _org = users.org;
  1629. let _oid = arr[i].school;
  1630. let _ph = arr[i].phone ? arr[i].phone : '';
  1631. let _class = arr[i].class;
  1632. let _sId = arr[i].sId;
  1633. //加密密碼
  1634. _password = bcrypt.hashSync(_password, bcrypt.genSaltSync(10));
  1635. //生成激活碼
  1636. let _hashstr = new Date().getTime() + "";
  1637. let _digest = crypto.createHash('sha256').update(_hashstr, 'utf8').digest('hex');
  1638. //用戶數據
  1639. let _userdata = [
  1640. _mail,
  1641. _password,
  1642. _alias,
  1643. "",
  1644. 0, //0老师 1学生
  1645. _username,
  1646. "",
  1647. generateAPIKey(_username),
  1648. _digest,
  1649. "",
  1650. _username,
  1651. _sId,
  1652. 1, //1老师 2学生
  1653. _org,
  1654. _oid,
  1655. '',
  1656. '',
  1657. '',
  1658. "0",
  1659. ];
  1660. //參數拼接,註冊
  1661. _userdata.unshift(_mysqluser[0], _mysqluser[1], "pbl_add_batchregister_oid");
  1662. //用戶註冊處理
  1663. mysql.usselect(_userdata, function(ret) {
  1664. res.end(JSON.stringify({ success: 1 }));
  1665. });
  1666. }
  1667. });
  1668. //新增学生
  1669. router.route('/batchRegistration').post(function(req, res, next) {
  1670. var users = req.body[0];
  1671. //循环注册
  1672. var _username = users.alias;
  1673. var _mail = users.username;
  1674. var _password = users.password || "123456";
  1675. var _alias = users.alias;
  1676. var _oid = users.oid;
  1677. var _ph = users.ph;
  1678. var _class = users.cid;
  1679. var _sId = users.sid;
  1680. //加密密碼
  1681. _password = bcrypt.hashSync(_password, bcrypt.genSaltSync(10));
  1682. //生成激活碼
  1683. let _hashstr = new Date().getTime() + "";
  1684. let _digest = crypto.createHash('sha256').update(_hashstr, 'utf8').digest('hex');
  1685. //用戶數據
  1686. var _userdata = [
  1687. _mail,
  1688. _password,
  1689. _alias,
  1690. "",
  1691. 1,
  1692. _username,
  1693. "",
  1694. generateAPIKey(_username),
  1695. _digest,
  1696. "",
  1697. _username,
  1698. _sId,
  1699. 2,
  1700. _oid,
  1701. _ph,
  1702. _class,
  1703. '',
  1704. "0",
  1705. ];
  1706. //參數拼接,註冊
  1707. _userdata.unshift(_mysqluser[0], _mysqluser[1], "pbl_add_batchregister");
  1708. //用戶註冊處理
  1709. mysql.usselect(_userdata, function(ret) {
  1710. res.end(JSON.stringify({ uid: ret[1][0].uid, ph: _ph, oid: _oid, cid: _class, success: 1 }));
  1711. });
  1712. });
  1713. //新增教师
  1714. router.route('/batchRegistration1').post(function(req, res, next) {
  1715. var users = req.body[0];
  1716. //循环注册
  1717. var _username = users.alias;
  1718. var _mail = users.username;
  1719. var _password = users.password || "123456";
  1720. var _alias = users.alias;
  1721. var _org = users.org;
  1722. var _oid = users.oid;
  1723. var _ph = users.ph;
  1724. var _class = users.cid;
  1725. var _sId = users.sid;
  1726. //加密密碼
  1727. _password = bcrypt.hashSync(_password, bcrypt.genSaltSync(10));
  1728. //生成激活碼
  1729. let _hashstr = new Date().getTime() + "";
  1730. let _digest = crypto.createHash('sha256').update(_hashstr, 'utf8').digest('hex');
  1731. //用戶數據
  1732. var _userdata = [
  1733. _mail,
  1734. _password,
  1735. _alias,
  1736. "",
  1737. 0,
  1738. _username,
  1739. "",
  1740. generateAPIKey(_username),
  1741. _digest,
  1742. "",
  1743. _username,
  1744. _sId,
  1745. 1,
  1746. _org,
  1747. _oid,
  1748. _ph,
  1749. _class,
  1750. '',
  1751. "0",
  1752. ];
  1753. //參數拼接,註冊
  1754. _userdata.unshift(_mysqluser[0], _mysqluser[1], "pbl_add_batchregister1");
  1755. //用戶註冊處理
  1756. mysql.usselect(_userdata, function(ret) {
  1757. res.end(JSON.stringify({ uid: ret[1][0].uid, ph: _ph, oid: _oid, cid: _class, success: 1 }));
  1758. });
  1759. });
  1760. router.route('/batchRegistrationOrg').post(function(req, res, next) {
  1761. var users = req.body[0];
  1762. //循环注册
  1763. var _username = users.alias;
  1764. var _mail = users.username;
  1765. var _password = users.password || "123456";
  1766. var _alias = users.alias;
  1767. var _oid = users.oid;
  1768. var _ph = users.ph;
  1769. var _class = users.cid;
  1770. var _sId = users.sid;
  1771. var _org = users.org;
  1772. //加密密碼
  1773. _password = bcrypt.hashSync(_password, bcrypt.genSaltSync(10));
  1774. //生成激活碼
  1775. let _hashstr = new Date().getTime() + "";
  1776. let _digest = crypto.createHash('sha256').update(_hashstr, 'utf8').digest('hex');
  1777. //用戶數據
  1778. var _userdata = [
  1779. _mail,
  1780. _password,
  1781. _alias,
  1782. "",
  1783. 1,
  1784. _username,
  1785. "",
  1786. generateAPIKey(_username),
  1787. _digest,
  1788. "",
  1789. _username,
  1790. _sId,
  1791. 2,
  1792. _oid,
  1793. _ph,
  1794. _class,
  1795. '',
  1796. "0",
  1797. _org
  1798. ];
  1799. //參數拼接,註冊
  1800. _userdata.unshift(_mysqluser[0], _mysqluser[1], "pbl_add_batchregister_org");
  1801. //用戶註冊處理
  1802. mysql.usselect(_userdata, function(ret) {
  1803. res.end(JSON.stringify({ uid: ret[1][0].uid, ph: _ph, oid: _oid, cid: _class, success: 1 }));
  1804. });
  1805. });
  1806. router.route('/batchRegistrationMoreOrg').post(function(req, res, next) {
  1807. let users = req.body[0];
  1808. let arr = JSON.parse(req.body[0].arr);
  1809. for (let i = 0; i < arr.length; i++) {
  1810. let _username = arr[i].name;
  1811. let _mail = arr[i].mail;
  1812. let _password = users.password || "123456";
  1813. let _alias = arr[i].name;
  1814. let _oid = users.oid;
  1815. let _ph = arr[i].phone ? arr[i].phone : '';
  1816. let _class = arr[i].class;
  1817. let _sId = arr[i].sId;
  1818. let _org = users.org;
  1819. //加密密碼
  1820. _password = bcrypt.hashSync(_password, bcrypt.genSaltSync(10));
  1821. //生成激活碼
  1822. let _hashstr = new Date().getTime() + "";
  1823. let _digest = crypto.createHash('sha256').update(_hashstr, 'utf8').digest('hex');
  1824. //用戶數據
  1825. let _userdata = [
  1826. _mail,
  1827. _password,
  1828. _alias,
  1829. "",
  1830. 1, //0老师 1学生
  1831. _username,
  1832. "",
  1833. generateAPIKey(_username),
  1834. _digest,
  1835. "",
  1836. _username,
  1837. _sId,
  1838. 2, //1老师 2学生
  1839. _oid,
  1840. _ph,
  1841. _class,
  1842. '',
  1843. "0",
  1844. _org
  1845. ];
  1846. //參數拼接,註冊
  1847. _userdata.unshift(_mysqluser[0], _mysqluser[1], "pbl_add_batchregisterp_org2");
  1848. //用戶註冊處理
  1849. mysql.usselect(_userdata, function(ret) {
  1850. res.end(JSON.stringify({ success: 1 }));
  1851. });
  1852. }
  1853. });
  1854. function generateAPIKey(username) {
  1855. let timeStamp = new Date().getTime();
  1856. let hashStr = timeStamp + username;
  1857. let digest = crypto.createHash('sha256').update(hashStr, 'utf8').digest('hex');
  1858. return digest;
  1859. }
  1860. queryString = function(url) {
  1861. var a = url.split("?");
  1862. var json = querystring.parse(a[1])
  1863. return json;
  1864. }
  1865. //post存儲過程處理
  1866. postmysql = function(req, res, functionname) {
  1867. //mode的處理
  1868. if (req.body[0]) {
  1869. p = Object.values(req.body[0]);
  1870. p.unshift(_mysqlLabor[0], _mysqlLabor[1], functionname);
  1871. //執行存儲過程
  1872. mysql.usselect(p, function(ret) { res.end(JSON.stringify(ret)); });
  1873. }
  1874. }
  1875. //post存儲過程處理
  1876. postmysql2 = function(req, res, functionname) {
  1877. //mode的處理
  1878. if (req.body) {
  1879. p = Object.values(req.body)[0].split(",");
  1880. p.unshift(_mysqlLabor[0], _mysqlLabor[1], functionname);
  1881. //執行存儲過程
  1882. mysql.usselect(p, function(ret) { res.end(JSON.stringify(ret)); });
  1883. }
  1884. }
  1885. //get獲取數據庫信息
  1886. getmysql = function(req, res, functionname, ...p) {
  1887. p = p || [];
  1888. p.unshift(_mysqlLabor[0], _mysqlLabor[1], functionname);
  1889. //執行存儲過程
  1890. mysql.usselect(p, function(ret) { res.end(JSON.stringify(ret)); }); //
  1891. }
  1892. //post存储过程处理
  1893. userpostmysql = function(req, res, functionname) {
  1894. //mode的处理
  1895. if (req.body.mode) {
  1896. p = req.body.mode.split(",");
  1897. p.unshift(_mysqluser[0], _mysqluser[1], functionname);
  1898. //执行存储过程
  1899. mysql.usselect(p, function(ret) { res.end(JSON.stringify(ret)); });
  1900. }
  1901. }
  1902. //get获取数据库信息
  1903. usergetmysql = function(req, res, functionname, ...p) {
  1904. p = p || [];
  1905. p.unshift(_mysqluser[0], _mysqluser[1], functionname);
  1906. //执行存储过程
  1907. mysql.usselect(p, function(ret) { res.end(JSON.stringify(ret)); }); //
  1908. }
  1909. module.exports = router;