pbl.js 72 KB

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