pbl.js 96 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720
  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. if (ret[0].length) {
  110. var _ret = ret
  111. var paJ = _ret[0][0].password
  112. let uid = _ret[0][0].userid
  113. let duid = [uid]
  114. bcrypt.compare(c[1], paJ, function(err, result) {
  115. // console.log(result)
  116. if (result) {
  117. //参数拼接,登录
  118. duid.unshift(_mysqlLabor[0], _mysqlLabor[1], "selectUser");
  119. //执行存储过程
  120. mysql.usselect(duid, function(ret) {
  121. res.end(JSON.stringify({ status: "1", ...ret }));
  122. });
  123. } else {
  124. res.end(JSON.stringify([{ status: "0" }]));
  125. }
  126. })
  127. } else {
  128. res.end(JSON.stringify([{ status: "0" }]));
  129. }
  130. });
  131. // console.log(isEqual)
  132. }
  133. });
  134. // 图片转base64
  135. router.route('/imgToBase64').all((req, res, next) => {
  136. var json = queryString(req.url);
  137. //mode的处理
  138. https.get(json['img'], function(res2) {
  139. var chunks = [];
  140. var size = 0;
  141. res2.on('data', function(chunk) {
  142. chunks.push(chunk);
  143. size += chunk.length;   //累加缓冲数据的长度
  144. });
  145. res2.on('end', function(err) {
  146. var data = Buffer.concat(chunks, size);
  147. var base64Img = data.toString('base64');
  148. res.end(JSON.stringify([{ img: `data:image/png;base64,${base64Img}` }]));
  149. });
  150. });
  151. });
  152. /*登录接口*/
  153. router.route('/loginRace').all((req, res, next) => {
  154. //mode的处理
  155. if (req.body[0]) {
  156. // 0 用户名 1 用户密码
  157. c = Object.values(req.body[0]); //获取用户密码
  158. p = [c[0]]
  159. // p[1] = bcrypt.hashSync(p[1], bcrypt.genSaltSync(10));
  160. var _password = [c[0]];
  161. _password.unshift(_mysqlLabor[0], _mysqlLabor[1], "selectPasswordRace");
  162. mysql.usselect(_password, function(ret) {
  163. var _ret = ret
  164. var paJ = _ret[0][0].password
  165. bcrypt.compare(c[1], paJ, function(err, result) {
  166. // console.log(result)
  167. if (result) {
  168. //参数拼接,登录
  169. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "selectLoginRace");
  170. //执行存储过程
  171. mysql.usselect(p, function(ret) {
  172. res.end(JSON.stringify({ status: "1", ...ret }));
  173. });
  174. } else {
  175. res.end(JSON.stringify([{ status: "0" }]));
  176. }
  177. })
  178. });
  179. // console.log(isEqual)
  180. }
  181. });
  182. /* 修改密码接口 */
  183. router.route('/updatePassword').post(function(req, res, next) {
  184. //mode的处理
  185. if (req.body[0]) {
  186. let p = [req.body[0].userid];
  187. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "getPassword"); //執行存儲過程
  188. mysql.usselect(p, function(ret) {
  189. var paJ = ret[0][0].password
  190. var op = bcrypt.hashSync(req.body[0].opassword, bcrypt.genSaltSync(10));
  191. bcrypt.compare(req.body[0].opassword, paJ, function(err, result) {
  192. // console.log(result)
  193. if (result) {
  194. let p2 = [req.body[0].userid, bcrypt.hashSync(req.body[0].password, bcrypt.genSaltSync(10))];
  195. p2.unshift(_mysqlLabor[0], _mysqlLabor[1], "updatePassword"); //執行存儲過程
  196. mysql.usselect(p2, function(ret) {
  197. res.end(JSON.stringify([{ success: 1 }]));
  198. });
  199. } else {
  200. res.end(JSON.stringify([{ success: 0 }]));
  201. }
  202. })
  203. });
  204. }
  205. });
  206. /* 找寻重复手机号 */
  207. router.route('/findPhone').all((req, res, next) => {
  208. var json = queryString(req.url);
  209. getmysql(req, res, "findPhone", json['un']);
  210. });
  211. /* 找寻是否有此账号 */
  212. router.route('/findUsername').all((req, res, next) => {
  213. var json = queryString(req.url);
  214. getmysql(req, res, "findUsername", json['un']);
  215. });
  216. /* 找寻重复邮箱 */
  217. router.route('/findMail').all((req, res, next) => {
  218. var json = queryString(req.url);
  219. usergetmysql(req, res, "findMail", json['un']);
  220. });
  221. /* 找寻重复学号 */
  222. router.route('/findSid').all((req, res, next) => {
  223. var json = queryString(req.url);
  224. getmysql(req, res, "findSid", json['un']);
  225. });
  226. /* 新增班级 */
  227. router.route('/insertClass').all((req, res, next) => {
  228. var json = queryString(req.url);
  229. getmysql(req, res, "insertClass", json['name'], json['oid'], json['uid']);
  230. });
  231. /* 查询班级 */
  232. router.route('/selectClass').all((req, res, next) => {
  233. var json = queryString(req.url);
  234. getmysql(req, res, "selectClass", json['cu'], json['oid'], json['cn'], json['page'], 10);
  235. });
  236. /* 删除班级 */
  237. router.route('/deleteClass').all((req, res, next) => {
  238. var json = queryString(req.url);
  239. getmysql(req, res, "deleteClass", json['id']);
  240. });
  241. /* 查询学校 */
  242. router.route('/selectOrg').all((req, res, next) => {
  243. var json = queryString(req.url);
  244. getmysql(req, res, "selectOrg");
  245. });
  246. /* 查询组织 */
  247. router.route('/selectorg2').all((req, res, next) => {
  248. var json = queryString(req.url);
  249. getmysql(req, res, "selectorg2");
  250. });
  251. /* 修改学校名称 */
  252. router.route('/updateSN').all((req, res, next) => {
  253. var json = queryString(req.url);
  254. getmysql(req, res, "updateSchoolName", json["oid"], json["n"]);
  255. });
  256. /* 教师端修改学校名称 */
  257. router.route('/updateSchoolByOrg').all((req, res, next) => {
  258. var json = queryString(req.url);
  259. getmysql(req, res, "updateSchoolByOrg", json["n"], json["d"], json["id"]);
  260. });
  261. /* 教师端查询未联结学校 */
  262. router.route('/selectNoCSchool').all((req, res, next) => {
  263. var json = queryString(req.url);
  264. getmysql(req, res, "selectNoCSchool");
  265. });
  266. /* 教师端新增或修改联结学校 */
  267. router.route('/addNoSchool').all((req, res, next) => {
  268. var json = queryString(req.url);
  269. getmysql(req, res, "addNoSchool", json["id"], json["coid"]);
  270. });
  271. /* 新增学生 */
  272. router.route('/insertStudent').all((req, res, next) => {
  273. var json = queryString(req.url);
  274. json['userpassword'] = bcrypt.hashSync(json['userpassword'], bcrypt.genSaltSync(10))
  275. getmysql(req, res, "insertStudent", json['ph'], json['username'], json['userpassword'], json['type'], json['oid'], json['tid'], json['cid']);
  276. });
  277. // /* 新增学生 */
  278. // router.route('/iStudent').all((req, res, next) => {
  279. // var json = queryString(req.url);
  280. // json['userpassword'] = bcrypt.hashSync(json['userpassword'], bcrypt.genSaltSync(10))
  281. // getmysql(req, res, "insertStudent", json['ph'], json['username'], json['userpassword'], json['type'], json['oid'], json['tid'], json['cid']);
  282. // });
  283. /* 查询学生 */
  284. router.route('/selectStudent').all((req, res, next) => {
  285. var json = queryString(req.url);
  286. getmysql(req, res, "selectStudent", json['oid'], json['cu'], json['cn'], json['page'], 10);
  287. });
  288. /* ppt根据学校查询学生 */
  289. router.route('/selectStudentByScoolPPt').all((req, res, next) => {
  290. var json = queryString(req.url);
  291. getmysql(req, res, "selectStudentByScoolPPt", json['oid'], json['cid']);
  292. });
  293. /* 查询学生 */
  294. router.route('/selectStudentAdd').all((req, res, next) => {
  295. var json = queryString(req.url);
  296. getmysql(req, res, "selectStudentAdd", json['oid'], json['cu'], json['cn']);
  297. });
  298. /* 查询老师 */
  299. router.route('/selectTeacherAdd').all((req, res, next) => {
  300. var json = queryString(req.url);
  301. getmysql(req, res, "selectTeacherAdd", json['oid'], json['cu'], json['cn']);
  302. });
  303. /* 查询老师 */
  304. router.route('/selectTeacherAddOrg').all((req, res, next) => {
  305. var json = queryString(req.url);
  306. getmysql(req, res, "selectTeacherAddOrg", json['oid'], json['cu'], json['cn']);
  307. });
  308. /* 查询学生 */
  309. router.route('/selectStudentAddOrg').all((req, res, next) => {
  310. var json = queryString(req.url);
  311. getmysql(req, res, "selectStudentAddOrg", json['oid'], json['cu'], json['cn']);
  312. });
  313. /* 查询全部用户 */
  314. router.route('/selectUserAddOrg').all((req, res, next) => {
  315. var json = queryString(req.url);
  316. getmysql(req, res, "selectUserAddOrg", json['oid'], json['cu'], json['cn']);
  317. });
  318. /* 查询全部用户 */
  319. router.route('/selectUserAdd').all((req, res, next) => {
  320. var json = queryString(req.url);
  321. getmysql(req, res, "selectUserAdd", json['oid'], json['cu'], json['cn']);
  322. });
  323. /* 查询全部用户 */
  324. router.route('/selectUserByOidS').all((req, res, next) => {
  325. var json = queryString(req.url);
  326. getmysql(req, res, "selectUserByOidS", json['oid'], json['cu'], json['cn']);
  327. });
  328. /* 查询班级是否有重复 */
  329. router.route('/selectC').all((req, res, next) => {
  330. var json = queryString(req.url);
  331. getmysql(req, res, "selectC", json['className']);
  332. });
  333. /* 查询学校是否有重复 */
  334. router.route('/selectS').all((req, res, next) => {
  335. var json = queryString(req.url);
  336. getmysql(req, res, "selectS", json['schoolName']);
  337. });
  338. /* 修改个人信息 */
  339. router.route('/updateUser').all((req, res, next) => {
  340. postmysql(req, res, "updateUser");
  341. });
  342. //查询老师的信息
  343. router.route('/getUser').all((req, res, next) => {
  344. var json = queryString(req.url);
  345. getmysql(req, res, "selectUserDeail", json['uid']);
  346. });
  347. //查询老师的信息
  348. router.route('/getRaceUser').all((req, res, next) => {
  349. var json = queryString(req.url);
  350. getmysql(req, res, "getRaceUser", json['uid']);
  351. });
  352. router.route('/selectUser').all((req, res, next) => {
  353. var json = queryString(req.url);
  354. getmysql(req, res, "selectUser", json['userid']);
  355. });
  356. //查询教师端消息
  357. router.route('/getNewsTeacher').all((req, res, next) => {
  358. var json = queryString(req.url);
  359. getmysql(req, res, "selectNew", json['uid'], json['page'], 10);
  360. });
  361. //查询教师端消息
  362. router.route('/selectNotice').all((req, res, next) => {
  363. var json = queryString(req.url);
  364. getmysql(req, res, "selectNotice", json['uid'], json['oid'], json['org'], json['page'], 10);
  365. });
  366. //查询教师端消息
  367. router.route('/selectNotice2').all((req, res, next) => {
  368. var json = queryString(req.url);
  369. getmysql(req, res, "selectNotice2", json['uid'], json['oid'], json['org']);
  370. });
  371. //查询教师端消息
  372. router.route('/addNotice').all((req, res, next) => {
  373. postmysql(req, res, "addNotice");
  374. });
  375. //查询教师端消息
  376. router.route('/deleteNotice').all((req, res, next) => {
  377. postmysql(req, res, "deleteNotice");
  378. });
  379. //查询通知详情
  380. router.route('/selectNewDetail').all((req, res, next) => {
  381. var json = queryString(req.url);
  382. getmysql(req, res, "selectNewDetail", json['nid']);
  383. });
  384. //查出分组分类
  385. router.route('/getGroup').all((req, res, next) => {
  386. getmysql(req, res, "selectGroupTeacher");
  387. });
  388. //查询这个老师底下的学生提交的作业
  389. router.route('/getWorks').all((req, res, next) => {
  390. var json = queryString(req.url);
  391. getmysql(req, res, "selectWorks", json['cn'], json['cid'], json['page'], 10);
  392. });
  393. //查询项目
  394. router.route('/getProject').all((req, res, next) => {
  395. var json = queryString(req.url);
  396. getmysql(req, res, "selectProject", json['type'], json['uid'], json['oid'], json['cn'], json['page'], 10);
  397. });
  398. //查询项目
  399. router.route('/getMyProject').all((req, res, next) => {
  400. var json = queryString(req.url);
  401. getmysql(req, res, "selectMyProject", json['uid'], json['page'], 10);
  402. });
  403. //查询项目成员
  404. router.route('/selectProjectStudent').all((req, res, next) => {
  405. var json = queryString(req.url);
  406. getmysql(req, res, "select_student", json['cn'], json['oid'], json['uid']);
  407. });
  408. //查询Banner列表
  409. router.route('/selectBannerList').all((req, res, next) => {
  410. var json = queryString(req.url);
  411. getmysql(req, res, "selectBannerList", json['page'], 10);
  412. });
  413. //查询Banner列表
  414. router.route('/selectAllBanner').all((req, res, next) => {
  415. var json = queryString(req.url);
  416. getmysql(req, res, "selectAllBanner", json["t"]);
  417. });
  418. //新增Banner
  419. router.route('/insertBannerList').all((req, res, next) => {
  420. postmysql(req, res, "insertBannerList");
  421. });
  422. //删除提交的作业
  423. router.route('/deleteCourseWork').all((req, res, next) => {
  424. postmysql(req, res, "deleteCourseWork");
  425. });
  426. //删除提交的作业
  427. router.route('/deleteCourseWorkS').all((req, res, next) => {
  428. postmysql(req, res, "deleteCourseWorkS");
  429. });
  430. //删除Banner
  431. router.route('/deleteBannerList').all((req, res, next) => {
  432. var json = queryString(req.url);
  433. getmysql(req, res, "deleteBannerList", json['id']);
  434. });
  435. //新增课程
  436. router.route('/addWork').all((req, res, next) => {
  437. postmysql(req, res, "insert_teacher_work");
  438. });
  439. //点赞评论
  440. router.route('/insertComment').all((req, res, next) => {
  441. postmysql(req, res, "insertComment");
  442. });
  443. //点赞评论
  444. router.route('/getComment').all((req, res, next) => {
  445. postmysql(req, res, "getComment");
  446. });
  447. //取消点赞
  448. router.route('/deleteComment').all((req, res, next) => {
  449. var json = queryString(req.url);
  450. getmysql(req, res, "deleteComment", json['wid'], json['lid']);
  451. });
  452. //上传批注图片
  453. router.route('/updateCourseWorks').all((req, res, next) => {
  454. postmysql(req, res, "updateCourseWorks");
  455. });
  456. //上传文件
  457. router.route('/addCourseWorks').all((req, res, next) => {
  458. postmysql(req, res, "addCourseWorks");
  459. });
  460. //上传文件
  461. router.route('/addCourseWorksS').all((req, res, next) => {
  462. postmysql(req, res, "addCourseWorksS");
  463. });
  464. //可上传多个文件
  465. router.route('/addCourseWorksR').all((req, res, next) => {
  466. postmysql(req, res, "addCourseWorksR");
  467. });
  468. //上传文件
  469. router.route('/addCourseWorksTeacher').all((req, res, next) => {
  470. postmysql(req, res, "addCourseWorksTeacher");
  471. });
  472. //上传文件
  473. router.route('/addCourseWorks2').all((req, res, next) => {
  474. var json = queryString(req.url);
  475. postmysql(req, res, "addCourseWorks", json['uid'], json['cid'], json['stage'], json['task'], json['tool'], json['content'], json['type']);
  476. });
  477. //上传文件
  478. router.route('/addCourseWorks3').all((req, res, next) => {
  479. var json = queryString(req.url);
  480. getmysql(req, res, "addCourseWorks2", json['uid'], json['cid'], json['stage'], json['task'], json['tool'], json['content'], json['type'], json['atool']);
  481. });
  482. //上传文件
  483. router.route('/addCourseWorks4').all((req, res, next) => {
  484. postmysql3(req, res, "addCourseWorks3");
  485. });
  486. //上传文件
  487. router.route('/addCourseWorks4s').all((req, res, next) => {
  488. postmysql3(req, res, "addCourseWorks4s");
  489. });
  490. //上传文件
  491. router.route('/addCourseWorks5').all((req, res, next) => {
  492. postmysql(req, res, "addCourseWorks3");
  493. });
  494. //上传批量文件
  495. router.route('/addCourseWorksPl').all((req, res, next) => {
  496. if (req.body[0]) {
  497. var p = Object.values(req.body[0]);
  498. let ateacher = p[0]
  499. let cid = p[1]
  500. let stage = p[2]
  501. let task = p[3]
  502. let tool = p[4]
  503. let files = JSON.parse(p[5])
  504. for (let i = 0; i < files.length; i++) {
  505. var k = [files[i].username, cid, stage, task, tool, files[i].url, files[i].fileType, ateacher, '50']
  506. k.unshift(_mysqlLabor[0], _mysqlLabor[1], 'addCourseWorksPl');
  507. //執行存儲過程
  508. mysql.usselect(k, function(ret) {
  509. if (i == files.length - 1) {
  510. res.end(JSON.stringify(ret));
  511. }
  512. });
  513. }
  514. }
  515. });
  516. //修改课程权限(学生是否能查看所有作业)
  517. router.route('/updateCourseSLook').all((req, res, next) => {
  518. var json = queryString(req.url);
  519. getmysql(req, res, "updateCourseSLook", json['sopen'], json['cid']);
  520. });
  521. //修改阶段锁定状态
  522. router.route('/updateCourseLookOpen').all((req, res, next) => {
  523. postmysql(req, res, "updateCourseLookOpen");
  524. });
  525. //查看阶段锁定的状态
  526. router.route('/getCourseState').all((req, res, next) => {
  527. var json = queryString(req.url);
  528. getmysql(req, res, "getCourseState", json['cid']);
  529. });
  530. //添加锁定状态
  531. router.route('/addCourseState').all((req, res, next) => {
  532. postmysql(req, res, "addCourseState");
  533. });
  534. //修改锁定状态
  535. router.route('/updateCourseSate').all((req, res, next) => {
  536. postmysql(req, res, "updateCourseSate");
  537. });
  538. //查询课程权限(学生是否能查看所有作业)
  539. router.route('/selectCourseSLook').all((req, res, next) => {
  540. var json = queryString(req.url);
  541. getmysql(req, res, "selectCourseSLook", json['cid']);
  542. });
  543. //查询作业详情
  544. router.route('/selectWorksDetail2').all((req, res, next) => {
  545. var json = queryString(req.url);
  546. getmysql(req, res, "selectWorksDetail2", json['uid'], json['cid'], json['stage'], json['task']);
  547. });
  548. //查询课程全部作业详情
  549. router.route('/selectWorksDetail3').all((req, res, next) => {
  550. var json = queryString(req.url);
  551. getmysql(req, res, "selectWorksDetail3", json['uid'], json['cid']);
  552. });
  553. //学习中心教师查询作业
  554. router.route('/selectSWorks').all((req, res, next) => {
  555. var json = queryString(req.url);
  556. getmysql(req, res, "selectSWorks", json['cid'], json['s'], json['t']);
  557. });
  558. //学习中心教师查询作业全部展示
  559. router.route('/selectSWorks2').all((req, res, next) => {
  560. var json = queryString(req.url);
  561. getmysql(req, res, "selectSWorks2", json['cid']);
  562. });
  563. //学习中心学生查询作业
  564. router.route('/selectStudentWorks').all((req, res, next) => {
  565. var json = queryString(req.url);
  566. getmysql(req, res, "selectStudentWorks", json['uid'], json['cid'], json['s'], json['t']);
  567. });
  568. //实时课堂作业评价
  569. router.route('/updateStudentWork').all((req, res, next) => {
  570. postmysql(req, res, "updateStudentWork");
  571. });
  572. //学习中心查询学生
  573. router.route('/selectWorksStudent').all((req, res, next) => {
  574. var json = queryString(req.url);
  575. getmysql(req, res, "selectWorksStudent", json['oid'], json['cid']);
  576. });
  577. /* 查询学生 */
  578. router.route('/selectStudent2').all((req, res, next) => {
  579. var json = queryString(req.url);
  580. getmysql(req, res, "selectStudent2", json['oid'], json['cu'], json['cn'], json['cid'], json['page'], 10);
  581. });
  582. /* 查询教师 */
  583. router.route('/selectTeacher').all((req, res, next) => {
  584. var json = queryString(req.url);
  585. getmysql(req, res, "selectTeacher", json['org'], json['cu'], json['cn'], json['page'], 10);
  586. });
  587. /* 添加教师页面查询教师 */
  588. router.route('/selectTcTeacher').all((req, res, next) => {
  589. var json = queryString(req.url);
  590. getmysql(req, res, "selectTcTeacher", json['org'], json['oid'], json['cu'], json['cn'], json['page'], 10);
  591. });
  592. /* 查询所有评价体系 */
  593. router.route('/selectAllEvaluation').all((req, res, next) => {
  594. var json = queryString(req.url);
  595. getmysql(req, res, "selectAllEvaluation", json['oid']);
  596. });
  597. /* 根据市级用户查询评审员 */
  598. router.route('/selectReviewer').all((req, res, next) => {
  599. var json = queryString(req.url);
  600. getmysql(req, res, "selectReviewer", json['uid'], json['cn'], json['page'], 10);
  601. });
  602. /* 市级区县管理接口 */
  603. router.route('/selectCReviewer').all((req, res, next) => {
  604. var json = queryString(req.url);
  605. getmysql(req, res, "selectCReviewer", json['uid'], json['cn'], json['page'], 10);
  606. });
  607. /* 修改评审员 */
  608. router.route('/updateReviewer').all((req, res, next) => {
  609. var json = queryString(req.url);
  610. getmysql(req, res, "updateReviewer", json['n'], json['p'], json['t'], json['s'], json['uid']);
  611. });
  612. /* 删除评审员 */
  613. router.route('/deleteReviewer').all((req, res, next) => {
  614. var json = queryString(req.url);
  615. getmysql(req, res, "deleteReviewer", json['uid']);
  616. });
  617. /* 查询区县案例 */
  618. router.route('/selecAnliBox').all((req, res, next) => {
  619. var json = queryString(req.url);
  620. getmysql(req, res, "selecAnliBox");
  621. });
  622. /* 查询市级案例 */
  623. router.route('/selecAnliBox1').all((req, res, next) => {
  624. var json = queryString(req.url);
  625. getmysql(req, res, "selecAnliBox1");
  626. });
  627. /* 查询省级案例 */
  628. router.route('/selecAnliBox2').all((req, res, next) => {
  629. var json = queryString(req.url);
  630. getmysql(req, res, "selecAnliBox2");
  631. });
  632. /* 查询通知公告 */
  633. router.route('/selectRaceNotice').all((req, res, next) => {
  634. var json = queryString(req.url);
  635. getmysql(req, res, "selectRaceNotice", json['page'], 10);
  636. });
  637. /* 查询通知公告详情 */
  638. router.route('/getRaceNoticeDetail').all((req, res, next) => {
  639. var json = queryString(req.url);
  640. getmysql(req, res, "getRaceNoticeDetail", json['nid']);
  641. });
  642. router.route('/addWorkNew').all((req, res, next) => {
  643. // postmysql(req, res, "insert_teacher_work_new");
  644. if (req.body[0]) {
  645. // p = Object.values(req.body[0]);
  646. 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];
  647. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "insert_teacher_work_new");
  648. //執行存儲過程
  649. mysql.usselect(p, function(ret) {
  650. let course = req.body[0].courseType;
  651. let courseId = ret[0][0].courseId;
  652. let userid = req.body[0].uid;
  653. delCourseType(course, courseId, userid);
  654. res.end(JSON.stringify({ ordernumber: ret[0][0].ordernumber, courseId: ret[0][0].courseId, success: 1 }));
  655. // res.end(JSON.stringify(ret));
  656. });
  657. }
  658. });
  659. router.route('/addWorkNew2').all((req, res, next) => {
  660. if (req.body[0]) {
  661. 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];
  662. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "insert_teacher_work_new2"); //執行存儲過程
  663. mysql.usselect(p, function(ret) {
  664. let course = req.body[0].courseType;
  665. let courseId = ret[0][0].courseId;
  666. let userid = req.body[0].uid;
  667. delCourseType(course, courseId, userid);
  668. res.end(JSON.stringify({ ordernumber: ret[0][0].ordernumber, courseId: ret[0][0].courseId, success: 1 }));
  669. });
  670. }
  671. });
  672. router.route('/addCourseWorkNew2').all((req, res, next) => { //学生
  673. if (req.body[0]) {
  674. 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];
  675. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "addCourseWorkNew2"); //執行存儲過程
  676. mysql.usselect(p, function(ret) {
  677. let course = req.body[0].courseType;
  678. let courseId = ret[0][0].courseId;
  679. let userid = req.body[0].uid;
  680. delCourseType(course, courseId, userid);
  681. res.end(JSON.stringify({ ordernumber: ret[0][0].ordernumber, courseId: ret[0][0].courseId, success: 1 }));
  682. });
  683. }
  684. });
  685. router.route('/addCourseWorkNew22').all((req, res, next) => { //学生
  686. if (req.body[0]) {
  687. 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];
  688. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "addCourseWorkNew2"); //執行存儲過程
  689. mysql.usselect(p, function(ret) {
  690. let course = req.body[0].courseType;
  691. let courseId = ret[0][0].courseId;
  692. let userid = req.body[0].uid;
  693. delCourseTypeS(course, courseId, userid);
  694. res.end(JSON.stringify({ ordernumber: ret[0][0].ordernumber, courseId: ret[0][0].courseId, success: 1 }));
  695. });
  696. }
  697. });
  698. //新增赛事项目
  699. router.route('/addRace').all((req, res, next) => {
  700. if (req.body[0]) {
  701. 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];
  702. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "addRace"); //執行存儲過程
  703. mysql.usselect(p, function(ret) {
  704. let course = req.body[0].courseType;
  705. let courseId = ret[0][0].id;
  706. let userid = req.body[0].uid;
  707. delCourseType1(course, courseId, userid);
  708. res.end(JSON.stringify({ courseId: courseId, success: 1 }));
  709. });
  710. }
  711. });
  712. //新增赛事账号信息
  713. router.route('/addRaceUser').all((req, res, next) => {
  714. if (req.body[0]) {
  715. 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];
  716. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "addRaceUser"); //執行存儲過程
  717. mysql.usselect(p, function(ret) {
  718. let num = ret[0][0].num;
  719. let userid = ret[0][0].userid;
  720. if (num < 10) {
  721. num = "SZ" + "00" + num + "@gdae.com";
  722. } else if (num < 100) {
  723. num = "SZ" + "0" + num + "@gdae.com";
  724. } else if (num > 100) {
  725. num = "SZ" + num + "@gdae.com";
  726. }
  727. y = [userid, num, bcrypt.hashSync("123456", bcrypt.genSaltSync(10))];
  728. //参数拼接,注册
  729. y.unshift(_mysqlLabor[0], _mysqlLabor[1], "upRaceUserNamePassword");
  730. mysql.usselect(y, function(ret) {
  731. res.end(JSON.stringify(ret));
  732. });
  733. res.end(JSON.stringify({ num: num, success: 1 }));
  734. });
  735. }
  736. });
  737. //修改赛事项目
  738. router.route('/updateRace').all((req, res, next) => {
  739. if (req.body[0]) {
  740. 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];
  741. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "updateRace"); //執行存儲過程
  742. mysql.usselect(p, function(ret) {
  743. let course = req.body[0].courseType;
  744. let courseId = req.body[0].id;
  745. let userid = req.body[0].uid;
  746. delCourseType1(course, courseId, userid);
  747. res.end(JSON.stringify({ success: 1 }));
  748. });
  749. }
  750. });
  751. router.route('/addWorkNew3').all((req, res, next) => {
  752. if (req.body[0]) {
  753. 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];
  754. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "insert_teacher_work_new3"); //執行存儲過程
  755. mysql.usselect(p, function(ret) {
  756. let course = req.body[0].courseType;
  757. let courseId = ret[0][0].courseId;
  758. let userid = req.body[0].uid;
  759. delCourseType(course, courseId, userid);
  760. res.end(JSON.stringify({ ordernumber: ret[0][0].ordernumber, courseId: ret[0][0].courseId, success: 1 }));
  761. });
  762. }
  763. });
  764. function delCourseType(course, courseId, userid) {
  765. let _courseId = courseId;
  766. var _userdata = [
  767. _courseId
  768. ];
  769. _userdata.unshift(_mysqlLabor[0], _mysqlLabor[1], "delete_courseType");
  770. mysql.usselect(_userdata, function(ret) {
  771. // console.log(ret);
  772. });
  773. setTimeout(() => {
  774. addCourseType(userid, course, _courseId)
  775. }, 1000);
  776. }
  777. function delCourseType1(course, courseId, userid) {
  778. let _courseId = courseId;
  779. var _userdata = [
  780. _courseId
  781. ];
  782. _userdata.unshift(_mysqlLabor[0], _mysqlLabor[1], "delete_courseType1");
  783. mysql.usselect(_userdata, function(ret) {
  784. // console.log(ret);
  785. });
  786. setTimeout(() => {
  787. addCourseType1(userid, course, _courseId)
  788. }, 1000);
  789. }
  790. function delCourseTypeS(course, courseId, userid) {
  791. let _courseId = courseId;
  792. var _userdata = [
  793. _courseId
  794. ];
  795. _userdata.unshift(_mysqlLabor[0], _mysqlLabor[1], "delete_courseTypeS");
  796. mysql.usselect(_userdata, function(ret) {
  797. // console.log(ret);
  798. addCourseTypeS(userid, course, _courseId)
  799. });
  800. // setTimeout(() => {
  801. // }, 1000);
  802. }
  803. function addCourseType(userid, course, _courseId) {
  804. var _uid = userid;
  805. var _courses = _courseId
  806. var _tid = JSON.parse(course)
  807. for (let i = 0; i < _tid.length; i++) {
  808. if (_tid[i] == '') {
  809. continue;
  810. }
  811. var _userdata = [
  812. _courses,
  813. _tid[i],
  814. _uid,
  815. ];
  816. _userdata.unshift(_mysqlLabor[0], _mysqlLabor[1], "add_courseType");
  817. mysql.usselect(_userdata, function(ret) {
  818. // console.log(ret);
  819. });
  820. }
  821. }
  822. function addCourseType1(userid, course, _courseId) {
  823. var _uid = userid;
  824. var _courses = _courseId
  825. var _tid = JSON.parse(course)
  826. for (let i = 0; i < _tid.length; i++) {
  827. if (_tid[i] == '') {
  828. continue;
  829. }
  830. var _userdata = [
  831. _courses,
  832. _tid[i],
  833. _uid,
  834. ];
  835. _userdata.unshift(_mysqlLabor[0], _mysqlLabor[1], "add_courseType1");
  836. mysql.usselect(_userdata, function(ret) {
  837. // console.log(ret);
  838. });
  839. }
  840. }
  841. function addCourseTypeS(userid, course, _courseId) {
  842. var _uid = userid;
  843. var _courses = _courseId
  844. var _tid = JSON.parse(course)
  845. for (let i = 0; i < _tid.length; i++) {
  846. if (_tid[i] == '') {
  847. continue;
  848. }
  849. var _userdata = [
  850. _courses,
  851. _tid[i],
  852. _uid,
  853. ];
  854. _userdata.unshift(_mysqlLabor[0], _mysqlLabor[1], "add_courseTypeS");
  855. mysql.usselect(_userdata, function(ret) {
  856. // console.log(ret);
  857. });
  858. }
  859. }
  860. //修改课程
  861. // router.route('/updateWork').all((req, res, next) => {
  862. // postmysql(req, res, "update_teacher_work");
  863. // });
  864. router.route('/updateWorkNew').all((req, res, next) => {
  865. if (req.body[0]) {
  866. // p = Object.values(req.body[0]);
  867. 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];
  868. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "update_teacher_work_new");
  869. //執行存儲過程
  870. mysql.usselect(p, function(ret) {
  871. let course = req.body[0].courseType;
  872. let courseId = req.body[0].cid;
  873. let userid = req.body[0].uid;
  874. delCourseType(course, courseId, userid);
  875. res.end(JSON.stringify({ success: 1 }));
  876. // res.end(JSON.stringify(ret));
  877. });
  878. }
  879. });
  880. //查询课程
  881. // router.route('/selectCourse').all((req, res, next) => {
  882. // var json = queryString(req.url);
  883. // getmysql(req, res, "select_course", json['type'], json['uid'], json['oid'], json['page'], 10);
  884. // });
  885. router.route('/updateWorkNew2').all((req, res, next) => {
  886. // if (req.body[0]) {
  887. // 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];
  888. // p.unshift(_mysqlLabor[0], _mysqlLabor[1], "update_teacher_work_new2"); //執行存儲過程
  889. // mysql.usselect(p, function(ret) {
  890. // let course = req.body[0].courseType;
  891. // let courseId = req.body[0].cid;
  892. // let userid = req.body[0].uid;
  893. // delCourseType(course, courseId, userid);
  894. // res.end(JSON.stringify({ success: 1 }));
  895. // });
  896. // }
  897. if (req.body[0]) {
  898. 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];
  899. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "update_teacher_work_new2"); //執行存儲過程
  900. mysql.usselect(p, function(ret) {
  901. let course = req.body[0].courseType;
  902. let courseId = req.body[0].cid;
  903. let userid = req.body[0].uid;
  904. delCourseType(course, courseId, userid);
  905. res.end(JSON.stringify({ success: 1 }));
  906. });
  907. }
  908. });
  909. router.route('/updateStudentWorkNew2').all((req, res, next) => { //学生
  910. if (req.body[0]) {
  911. 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];
  912. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "updateStudentWorkNew2"); //執行存儲過程
  913. mysql.usselect(p, function(ret) {
  914. let course = req.body[0].courseType;
  915. let courseId = req.body[0].cid;
  916. let userid = req.body[0].uid;
  917. delCourseType(course, courseId, userid);
  918. res.end(JSON.stringify({ success: 1 }));
  919. });
  920. }
  921. });
  922. router.route('/updateStudentWorkNew22').all((req, res, next) => { //学生
  923. if (req.body[0]) {
  924. 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];
  925. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "updateStudentWorkNew2"); //執行存儲過程
  926. mysql.usselect(p, function(ret) {
  927. let course = req.body[0].courseType;
  928. let courseId = req.body[0].cid;
  929. let userid = req.body[0].uid;
  930. delCourseTypeS(course, courseId, userid);
  931. res.end(JSON.stringify({ success: 1 }));
  932. });
  933. }
  934. });
  935. router.route('/updateWorkNew3').all((req, res, next) => {
  936. if (req.body[0]) {
  937. 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];
  938. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "update_teacher_work_new3"); //執行存儲過程
  939. mysql.usselect(p, function(ret) {
  940. let course = req.body[0].courseType;
  941. let courseId = req.body[0].cid;
  942. let userid = req.body[0].uid;
  943. delCourseType(course, courseId, userid);
  944. res.end(JSON.stringify({ success: 1 }));
  945. });
  946. }
  947. });
  948. function guid() {
  949. var _num,
  950. i,
  951. _guid = "";
  952. for (i = 0; i < 32; i++) {
  953. _guid += Math.floor(Math.random() * 16).toString(16); //随机0 - 16 的数字 转变为16进制的字符串
  954. _num = Math.floor((i - 7) / 4); //计算 (i-7)除4
  955. if (_num > -1 && _num < 4 && i == 7 + 4 * _num) {
  956. //会使guid中间加 "-" 形式为xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
  957. _guid += "-";
  958. }
  959. }
  960. return _guid;
  961. }
  962. router.route('/updateWorkNew4').all((req, res, next) => {
  963. if (req.body[0]) {
  964. let p = [req.body[0].cid];
  965. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "select_course_detail"); //執行存儲過程
  966. mysql.usselect(p, function(ret) {
  967. let _unitIndex = parseInt(req.body[0].unitIndex);
  968. let _chapters = JSON.parse(req.body[0].chapters);
  969. let _unitJson = JSON.parse(ret[0][0].chapters)
  970. if ((_unitJson.length - 1) < _unitIndex) {
  971. let _i = _unitIndex - (_unitJson.length - 1)
  972. for (let i = 0; i < _i; i++) {
  973. _unitJson.push({
  974. dyName: "", //单元标题
  975. chapterInfo: [{
  976. isread: false,
  977. chapterid: guid(),
  978. title: "",
  979. courseName: "",
  980. taskJson: [{
  981. task: "",
  982. taskDetail: "",
  983. chapterData: [],
  984. toolText: "",
  985. toolChoose: [{
  986. tool: [],
  987. toolDetail: "",
  988. toolType: 0,
  989. askCount: 1,
  990. askTitle: "",
  991. askJson: [{ askstitle: "", askItem: 1, checkList: [] }],
  992. }, ],
  993. isShowTools: false,
  994. askCount: 1,
  995. isFold: 0,
  996. askTitle: "",
  997. askJson: [{ askstitle: "", askItem: 1, checkList: [] }],
  998. checkJson: [{ checkCount: [], checkPerent: [] }],
  999. homeworkList: [],
  1000. }, ],
  1001. itemCount: 1,
  1002. fileList1: [],
  1003. video: [],
  1004. testData: [],
  1005. pData: [],
  1006. templateArray: [],
  1007. }, ],
  1008. })
  1009. }
  1010. _unitJson[_unitIndex] = _chapters[_unitIndex]
  1011. } else {
  1012. _unitJson[_unitIndex] = _chapters[_unitIndex]
  1013. }
  1014. // console.log(_unitJson);
  1015. let p2 = [req.body[0].cid, JSON.stringify(_unitJson).replaceAll(/%/g, "%25")];
  1016. p2.unshift(_mysqlLabor[0], _mysqlLabor[1], "update_teacher_work_new4"); //執行存儲過程
  1017. mysql.usselect(p2, function(ret) {
  1018. res.end(JSON.stringify({ success: 1 }));
  1019. });
  1020. // res.end(JSON.stringify({ success: 1 }));
  1021. });
  1022. }
  1023. });
  1024. router.route('/updateStudentWorkNew4').all((req, res, next) => { //学生
  1025. if (req.body[0]) {
  1026. let p = [req.body[0].cid];
  1027. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "select_student_course_detail2"); //執行存儲過程
  1028. mysql.usselect(p, function(ret) {
  1029. let _unitIndex = parseInt(req.body[0].unitIndex);
  1030. let _chapters = JSON.parse(req.body[0].chapters);
  1031. let _unitJson = JSON.parse(ret[0][0].chapters)
  1032. if ((_unitJson.length - 1) < _unitIndex) {
  1033. let _i = _unitIndex - (_unitJson.length - 1)
  1034. for (let i = 0; i < _i; i++) {
  1035. _unitJson.push({
  1036. dyName: "", //单元标题
  1037. chapterInfo: [{
  1038. isread: false,
  1039. chapterid: guid(),
  1040. title: "",
  1041. courseName: "",
  1042. taskJson: [{
  1043. task: "",
  1044. taskDetail: "",
  1045. chapterData: [],
  1046. toolText: "",
  1047. toolChoose: [{
  1048. tool: [],
  1049. toolDetail: "",
  1050. toolType: 0,
  1051. askCount: 1,
  1052. askTitle: "",
  1053. askJson: [{ askstitle: "", askItem: 1, checkList: [] }],
  1054. }, ],
  1055. isShowTools: false,
  1056. askCount: 1,
  1057. isFold: 0,
  1058. askTitle: "",
  1059. askJson: [{ askstitle: "", askItem: 1, checkList: [] }],
  1060. checkJson: [{ checkCount: [], checkPerent: [] }],
  1061. homeworkList: [],
  1062. }, ],
  1063. itemCount: 1,
  1064. fileList1: [],
  1065. video: [],
  1066. testData: [],
  1067. pData: [],
  1068. templateArray: [],
  1069. }, ],
  1070. })
  1071. }
  1072. _unitJson[_unitIndex] = _chapters[_unitIndex]
  1073. } else {
  1074. _unitJson[_unitIndex] = _chapters[_unitIndex]
  1075. }
  1076. // console.log(_unitJson);
  1077. let p2 = [req.body[0].cid, JSON.stringify(_unitJson).replaceAll(/%/g, "%25")];
  1078. p2.unshift(_mysqlLabor[0], _mysqlLabor[1], "updateStudentWorkNew4"); //執行存儲過程
  1079. mysql.usselect(p2, function(ret) {
  1080. res.end(JSON.stringify({ success: 1 }));
  1081. });
  1082. // res.end(JSON.stringify({ success: 1 }));
  1083. });
  1084. }
  1085. });
  1086. //协同删除阶段
  1087. router.route('/deleteWork').all((req, res, next) => {
  1088. if (req.body[0]) {
  1089. let p = [req.body[0].cid];
  1090. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "select_course_detail"); //執行存儲過程
  1091. mysql.usselect(p, function(ret) {
  1092. let _chapid = req.body[0].chapid;
  1093. // console.log(_chapid);
  1094. let _chapters = JSON.parse(req.body[0].chapters);
  1095. let _unitJson = JSON.parse(ret[0][0].chapters)
  1096. let _unitJson2 = []
  1097. for (var i = 0; i < _unitJson.length; i++) {
  1098. if (_unitJson[i].chapterInfo[0].chapterid != _chapid) {
  1099. // console.log(1);
  1100. // _unitJson.splice(i, -1)
  1101. _unitJson2.push(_unitJson[i])
  1102. // break;
  1103. }
  1104. }
  1105. // console.log(_unitJson2);
  1106. let p2 = [req.body[0].cid, JSON.stringify(_unitJson2).replaceAll(/%/g, "%25")];
  1107. p2.unshift(_mysqlLabor[0], _mysqlLabor[1], "update_teacher_work_new4"); //執行存儲過程
  1108. mysql.usselect(p2, function(ret) {
  1109. res.end(JSON.stringify({ success: 1 }));
  1110. });
  1111. // res.end(JSON.stringify({ success: 1 }));
  1112. });
  1113. }
  1114. });
  1115. //协同删除阶段
  1116. router.route('/deleteStudentWork').all((req, res, next) => { //学生
  1117. if (req.body[0]) {
  1118. let p = [req.body[0].cid];
  1119. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "select_student_course_detail2"); //執行存儲過程
  1120. mysql.usselect(p, function(ret) {
  1121. let _chapid = req.body[0].chapid;
  1122. // console.log(_chapid);
  1123. let _chapters = JSON.parse(req.body[0].chapters);
  1124. let _unitJson = JSON.parse(ret[0][0].chapters)
  1125. let _unitJson2 = []
  1126. for (var i = 0; i < _unitJson.length; i++) {
  1127. if (_unitJson[i].chapterInfo[0].chapterid != _chapid) {
  1128. // console.log(1);
  1129. // _unitJson.splice(i, -1)
  1130. _unitJson2.push(_unitJson[i])
  1131. // break;
  1132. }
  1133. }
  1134. // console.log(_unitJson2);
  1135. let p2 = [req.body[0].cid, JSON.stringify(_unitJson2).replaceAll(/%/g, "%25")];
  1136. p2.unshift(_mysqlLabor[0], _mysqlLabor[1], "updateStudentWorkNew4"); //執行存儲過程
  1137. mysql.usselect(p2, function(ret) {
  1138. res.end(JSON.stringify({ success: 1 }));
  1139. });
  1140. // res.end(JSON.stringify({ success: 1 }));
  1141. });
  1142. }
  1143. });
  1144. //协同恢复删除的阶段
  1145. router.route('/restoreWork').all((req, res, next) => {
  1146. if (req.body[0]) {
  1147. let p = [req.body[0].cid];
  1148. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "select_course_detail"); //執行存儲過程
  1149. mysql.usselect(p, function(ret) {
  1150. let _chapid = req.body[0].chapid;
  1151. // console.log(_chapid);
  1152. let _chapters = JSON.parse(req.body[0].chapters);
  1153. let _unitJson = JSON.parse(ret[0][0].chapters)
  1154. let _unitJson2 = []
  1155. let chpaindex;
  1156. for (var i = 0; i < _chapters.length; i++) {
  1157. if (_chapters[i].chapterInfo[0].chapterid == _chapid) {
  1158. chpaindex = i
  1159. }
  1160. }
  1161. for (var i = 0; i < _unitJson.length; i++) {
  1162. if (_unitJson[i].chapterInfo[0].chapterid != _chapid) {
  1163. // console.log(1);
  1164. // _unitJson.splice(i, -1)
  1165. _unitJson2.push(_unitJson[i])
  1166. // break;
  1167. }
  1168. }
  1169. _unitJson2.splice(chpaindex, 0, _chapters[chpaindex])
  1170. // console.log(_unitJson2);
  1171. let p2 = [req.body[0].cid, JSON.stringify(_unitJson2).replaceAll(/%/g, "%25")];
  1172. p2.unshift(_mysqlLabor[0], _mysqlLabor[1], "update_teacher_work_new4"); //執行存儲過程
  1173. mysql.usselect(p2, function(ret) {
  1174. res.end(JSON.stringify({ success: 1 }));
  1175. });
  1176. // res.end(JSON.stringify({ success: 1 }));
  1177. });
  1178. }
  1179. });
  1180. //协同恢复删除的阶段
  1181. router.route('/restoreStudentWork').all((req, res, next) => { //学生
  1182. if (req.body[0]) {
  1183. let p = [req.body[0].cid];
  1184. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "select_student_course_detail2"); //執行存儲過程
  1185. mysql.usselect(p, function(ret) {
  1186. let _chapid = req.body[0].chapid;
  1187. // console.log(_chapid);
  1188. let _chapters = JSON.parse(req.body[0].chapters);
  1189. let _unitJson = JSON.parse(ret[0][0].chapters)
  1190. let _unitJson2 = []
  1191. let chpaindex;
  1192. for (var i = 0; i < _chapters.length; i++) {
  1193. if (_chapters[i].chapterInfo[0].chapterid == _chapid) {
  1194. chpaindex = i
  1195. }
  1196. }
  1197. for (var i = 0; i < _unitJson.length; i++) {
  1198. if (_unitJson[i].chapterInfo[0].chapterid != _chapid) {
  1199. // console.log(1);
  1200. // _unitJson.splice(i, -1)
  1201. _unitJson2.push(_unitJson[i])
  1202. // break;
  1203. }
  1204. }
  1205. _unitJson2.splice(chpaindex, 0, _chapters[chpaindex])
  1206. // console.log(_unitJson2);
  1207. let p2 = [req.body[0].cid, JSON.stringify(_unitJson2).replaceAll(/%/g, "%25")];
  1208. p2.unshift(_mysqlLabor[0], _mysqlLabor[1], "updateStudentWorkNew4"); //執行存儲過程
  1209. mysql.usselect(p2, function(ret) {
  1210. res.end(JSON.stringify({ success: 1 }));
  1211. });
  1212. // res.end(JSON.stringify({ success: 1 }));
  1213. });
  1214. }
  1215. });
  1216. router.route('/selectCourseNew').all((req, res, next) => {
  1217. var json = queryString(req.url);
  1218. 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);
  1219. });
  1220. router.route('/selectCourseNew2').all((req, res, next) => {
  1221. var json = queryString(req.url);
  1222. 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);
  1223. });
  1224. router.route('/selectStudentCourseNew2').all((req, res, next) => {
  1225. var json = queryString(req.url);
  1226. getmysql(req, res, "selectStudentCourseNew2", json['type'], json['uid'], json['oid'], json['org'], json['typea'], json['typeb'], json['typec'], json['typed'], json['typeE'], json['cu'], json['cn'], json['page'], 10);
  1227. });
  1228. router.route('/selectStudentCourseNew22').all((req, res, next) => {
  1229. var json = queryString(req.url);
  1230. getmysql(req, res, "selectStudentCourseNew22", json['type'], json['uid'], json['oid'], json['org'], json['typea'], json['typeb'], json['typec'], json['typed'], json['typef'], json['typeE'], json['cu'], json['cn'], json['page'], 10);
  1231. });
  1232. //查询协同编辑课程
  1233. router.route('/selectCourseTeam').all((req, res, next) => {
  1234. var json = queryString(req.url);
  1235. getmysql(req, res, "selectCourseTeam", json['uid'], json['oid']);
  1236. });
  1237. //查询学校
  1238. router.route('/selectSchoolName').all((req, res, next) => {
  1239. var json = queryString(req.url);
  1240. getmysql(req, res, "selectOidName", json['page'], 10);
  1241. });
  1242. //查询组织
  1243. router.route('/selectOrgName').all((req, res, next) => {
  1244. var json = queryString(req.url);
  1245. getmysql(req, res, "selectOrgName", json['page'], 10);
  1246. });
  1247. //查询学校
  1248. router.route('/selectSchoolName2').all((req, res, next) => {
  1249. var json = queryString(req.url);
  1250. getmysql(req, res, "selectOidName2", json['oid']);
  1251. });
  1252. //查询学校
  1253. router.route('/selectSchoolNameOrg').all((req, res, next) => {
  1254. var json = queryString(req.url);
  1255. getmysql(req, res, "selectSchoolNameOrg", json['org'], json['page'], 10);
  1256. });
  1257. //查询协同学校和被协同学校
  1258. router.route('/selectOrgType').all((req, res, next) => {
  1259. var json = queryString(req.url);
  1260. getmysql(req, res, "selectOrgType", json['t'], json['org'], json['page'], 10);
  1261. });
  1262. //新增批注
  1263. router.route('/addPz').all((req, res, next) => {
  1264. postmysql(req, res, "addPz");
  1265. });
  1266. //新增批注
  1267. router.route('/addPz2').all((req, res, next) => {
  1268. postmysql(req, res, "addPz2");
  1269. });
  1270. //删除批注
  1271. router.route('/deletePz').all((req, res, next) => {
  1272. postmysql(req, res, "deletePz");
  1273. });
  1274. //查询批注列表
  1275. router.route('/selectPzList').all((req, res, next) => {
  1276. var json = queryString(req.url);
  1277. getmysql(req, res, "selectPzList", json['cid'], json['s'], json['t']);
  1278. });
  1279. //评分
  1280. router.route('/scoreWork').all((req, res, next) => {
  1281. postmysql(req, res, "scoreWork");
  1282. });
  1283. //删除学生
  1284. router.route('/deleteStudent').all((req, res, next) => {
  1285. postmysql(req, res, "delete_student");
  1286. });
  1287. //查询学校底下的班级
  1288. router.route('/selectClassBySchool').all((req, res, next) => {
  1289. var json = queryString(req.url);
  1290. getmysql(req, res, "selectClassBySchool", json['oid']);
  1291. });
  1292. //查询组织底下的学校
  1293. router.route('/selectSchoolByOrg').all((req, res, next) => {
  1294. var json = queryString(req.url);
  1295. getmysql(req, res, "selectSchoolByOrg", json['org']);
  1296. });
  1297. //学生注册接口
  1298. router.route('/register_student').post(function(req, res, next) {
  1299. //mode的处理
  1300. if (req.body[0]) {
  1301. // 0 用户名 1 用户密码 2用户身份 3 第三方id(可有可无)
  1302. p = Object.values(req.body[0]); //获取用户密码
  1303. //没有第三方id的处理
  1304. // if (p.length < 4) {
  1305. // p.push("")
  1306. // }
  1307. p[1] = bcrypt.hashSync(p[1], bcrypt.genSaltSync(10));
  1308. //密码加密
  1309. // bcrypt.hash(p[1], 10, function (err, hash) {
  1310. // if (err) {
  1311. // return next(err);
  1312. // }
  1313. // p[1] = hash;
  1314. // });
  1315. //参数拼接,注册
  1316. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "register_student");
  1317. //返回注册用户数据
  1318. // mysql.usselect(p, function (ret) {
  1319. // res.end(ret);
  1320. // });
  1321. mysql.usselect(p, function(ret) {
  1322. res.end(JSON.stringify(ret));
  1323. });
  1324. }
  1325. });
  1326. //查询课程详情
  1327. router.route('/selectCourseDetail').all((req, res, next) => {
  1328. var json = queryString(req.url);
  1329. getmysql(req, res, "selectCourseDetail", json['courseId']);
  1330. });
  1331. //查询学校底下的所有赛事
  1332. router.route('/selectRaceByOid').all((req, res, next) => {
  1333. var json = queryString(req.url);
  1334. getmysql(req, res, "selectRaceByOid", json['sid']);
  1335. });
  1336. //修改作业学生名称
  1337. router.route('/updateCourseWorksName').all((req, res, next) => {
  1338. var json = queryString(req.url);
  1339. getmysql(req, res, "updateCourseWorksName", json['n'], json['cid']);
  1340. });
  1341. //查询课程详情
  1342. router.route('/selectStudentCourseDetail').all((req, res, next) => { //学生
  1343. var json = queryString(req.url);
  1344. getmysql(req, res, "selectStudentCourseDetail", json['courseId']);
  1345. });
  1346. //查询课程详情
  1347. router.route('/selectStudentCourseDetail2').all((req, res, next) => { //学生
  1348. var json = queryString(req.url);
  1349. getmysql(req, res, "selectStudentCourseDetail2", json['courseId']);
  1350. });
  1351. //跳转阶段时,如果有课程就查询1返回,如果没有就插入
  1352. router.route('/addUserR').all((req, res, next) => {
  1353. var json = queryString(req.url);
  1354. getmysql(req, res, "insertUserR", json['uid'], json['cid']);
  1355. });
  1356. //新增学生端作业
  1357. router.route('/addWorks').all((req, res, next) => {
  1358. postmysql(req, res, "add_works");
  1359. });
  1360. //查询已提交作业
  1361. router.route('/selectWork').all((req, res, next) => {
  1362. var json = queryString(req.url);
  1363. getmysql(req, res, "selectWork", json['cid'], json['stage'], json['task'], json['uid']);
  1364. });
  1365. //查询作业详情
  1366. router.route('/selectWorksDetail').all((req, res, next) => {
  1367. var json = queryString(req.url);
  1368. getmysql(req, res, "selectWorksDetail", json['uid'], json['cid']);
  1369. });
  1370. //新增作业评分
  1371. router.route('/updateWorks').all((req, res, next) => {
  1372. var json = queryString(req.url);
  1373. getmysql(req, res, "updateWorks", json['rate'], json['tuid'], json['id']);
  1374. });
  1375. //新增素材信息
  1376. router.route('/addMtl').all((req, res, next) => {
  1377. var json = queryString(req.url);
  1378. getmysql(req, res, "add_mtl", json['cInfo'], json['t'], json['cBy']);
  1379. });
  1380. //根据类型查询素材信息
  1381. router.route('/selectMtl').all((req, res, next) => {
  1382. var json = queryString(req.url);
  1383. getmysql(req, res, "selectMtl", json['t'], json['page'], 10);
  1384. });
  1385. //根据类型查询素材信息
  1386. router.route('/selectMtl2').all((req, res, next) => {
  1387. var json = queryString(req.url);
  1388. getmysql(req, res, "selectMtl2", json['t'], json['uid'], json['page'], 10);
  1389. });
  1390. //学习中心
  1391. //新增学习资源信息
  1392. router.route('/addStuMtl').all((req, res, next) => {
  1393. var json = queryString(req.url);
  1394. getmysql(req, res, "addStuMtl", json['cInfo'], json['t'], json['cBy']);
  1395. });
  1396. //根据类型查询学习资料信息
  1397. router.route('/selectStuMtl').all((req, res, next) => {
  1398. var json = queryString(req.url);
  1399. getmysql(req, res, "selectStuMtl", json['t'], json['page'], 10);
  1400. });
  1401. //删除素材
  1402. router.route('/deleteStuM').all((req, res, next) => {
  1403. var json = queryString(req.url);
  1404. getmysql(req, res, "deleteStuM", json['id']);
  1405. });
  1406. //查询学生信息
  1407. router.route('/selectSDetail').all((req, res, next) => {
  1408. var json = queryString(req.url);
  1409. getmysql(req, res, "selectStudentDetail", json['uid']);
  1410. });
  1411. //查询个人课程
  1412. router.route('/selectMyCourse').all((req, res, next) => {
  1413. var json = queryString(req.url);
  1414. getmysql(req, res, "selectMyCourse", json['uid']);
  1415. });
  1416. //查询个人课程groupby课程id
  1417. router.route('/selectMyCourseBycid').all((req, res, next) => {
  1418. var json = queryString(req.url);
  1419. getmysql(req, res, "selectMyCourseBycid", json['uid']);
  1420. });
  1421. //查询所有课程
  1422. router.route('/selectAllCourse').all((req, res, next) => {
  1423. var json = queryString(req.url);
  1424. getmysql(req, res, "selectAllCourse", json['oid'], json['page'], 10);
  1425. });
  1426. //根据班级查询所有课程
  1427. router.route('/selectAllCourseByCid').all((req, res, next) => {
  1428. var json = queryString(req.url);
  1429. getmysql(req, res, "selectAllCourseByCid", json['oid'], json['cid'], json['page'], 10);
  1430. });
  1431. //根据分类查询所有课程
  1432. router.route('/selectTypeCourse').all((req, res, next) => {
  1433. var json = queryString(req.url);
  1434. 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);
  1435. });
  1436. //根据分类查询所有课程
  1437. router.route('/selectTypeCourse2').all((req, res, next) => {
  1438. var json = queryString(req.url);
  1439. 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);
  1440. });
  1441. //根据分类查询所有课程
  1442. router.route('/selectTypeCourse2GM').all((req, res, next) => {
  1443. var json = queryString(req.url);
  1444. getmysql(req, res, "selectTypeCourse2GM", 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);
  1445. });
  1446. //根据分类查询所有课程
  1447. router.route('/selectCourseExamine').all((req, res, next) => {
  1448. var json = queryString(req.url);
  1449. getmysql(req, res, "selectCourseExamine", json['oid'], json['org'], json['cn'], json['page'], 10);
  1450. });
  1451. //根据分类查询所有课程
  1452. router.route('/selectTypeCourse3').all((req, res, next) => {
  1453. var json = queryString(req.url);
  1454. getmysql(req, res, "selectTypeCourse3", 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);
  1455. });
  1456. //审核课程
  1457. router.route('/examineCourse').all((req, res, next) => {
  1458. postmysql(req, res, "examineCourse");
  1459. });
  1460. //删除素材
  1461. router.route('/deleteM').all((req, res, next) => {
  1462. var json = queryString(req.url);
  1463. getmysql(req, res, "deleteM", json['id']);
  1464. });
  1465. //点击阶段时添加观看人数
  1466. router.route('/updateVc').all((req, res, next) => {
  1467. var json = queryString(req.url);
  1468. getmysql(req, res, "updateVc", json['cid']);
  1469. });
  1470. //删除课程
  1471. router.route('/deleteCourse').all((req, res, next) => {
  1472. var json = queryString(req.url);
  1473. getmysql(req, res, "deleteCourse", json['cid']);
  1474. });
  1475. //删除课程
  1476. router.route('/deleteStudentCourse').all((req, res, next) => {
  1477. var json = queryString(req.url);
  1478. getmysql(req, res, "deleteStudentCourse", json['cid']);
  1479. });
  1480. //复制课程
  1481. router.route('/copyCourse').all((req, res, next) => {
  1482. postmysql(req, res, "copyCourse");
  1483. });
  1484. //查看课程
  1485. router.route('/select_course_detail').all((req, res, next) => {
  1486. var json = queryString(req.url);
  1487. getmysql(req, res, "select_course_detail", json['cid']);
  1488. });
  1489. //查看课程
  1490. router.route('/select_student_course_detail').all((req, res, next) => { //学生
  1491. var json = queryString(req.url);
  1492. getmysql(req, res, "select_student_course_detail", json['cid']);
  1493. });
  1494. //查看课程
  1495. router.route('/select_student_course_detail2').all((req, res, next) => { //学生
  1496. var json = queryString(req.url);
  1497. getmysql(req, res, "select_student_course_detail2", json['cid']);
  1498. });
  1499. //模糊查找课程
  1500. // router.route('/searchCourse').all((req, res, next) => {
  1501. // var json = queryString(req.url);
  1502. // getmysql(req, res, "searchCourse", json['cu'], json['cn'], json['page'], 10);
  1503. // });
  1504. //创建调查问卷
  1505. router.route('/addAsk').all((req, res, next) => {
  1506. postmysql(req, res, "insert_ask");
  1507. });
  1508. //学生提交问卷
  1509. router.route('/addAskList').all((req, res, next) => {
  1510. postmysql(req, res, "insert_askList");
  1511. });
  1512. //根据课程id阶段id获取已提交的问卷
  1513. router.route('/getAskListByCidStage').all((req, res, next) => {
  1514. var json = queryString(req.url);
  1515. getmysql(req, res, "getAskListByCidStage", json['cid'], json['stage'], json['task']);
  1516. });
  1517. //获取调查问卷
  1518. router.route('/getAsk').all((req, res, next) => {
  1519. var json = queryString(req.url);
  1520. getmysql(req, res, "select_ask", json['uid'], json['page'], 10);
  1521. });
  1522. //删除问卷
  1523. router.route('/deleteAsk').all((req, res, next) => {
  1524. postmysql(req, res, "deleteAsk");
  1525. });
  1526. //问卷调查数据统计
  1527. router.route('/getAskListByAskid').all((req, res, next) => {
  1528. var json = queryString(req.url);
  1529. getmysql(req, res, "select_askListByAskid", json['aid']);
  1530. });
  1531. //删除学生提交问卷
  1532. router.route('/deleteAskList').all((req, res, next) => {
  1533. postmysql(req, res, "update_askList_delete");
  1534. });
  1535. //根据id获取调查问卷
  1536. router.route('/getAskList').all((req, res, next) => {
  1537. var json = queryString(req.url);
  1538. getmysql(req, res, "select_askList", json['uid'], json['page'], 10);
  1539. });
  1540. //查看便签列表
  1541. router.route('/selectNote').all((req, res, next) => {
  1542. var json = queryString(req.url);
  1543. getmysql(req, res, "selectNote", json['uid']);
  1544. });
  1545. //新增便签列表
  1546. router.route('/insertNote').all((req, res, next) => {
  1547. var json = queryString(req.url);
  1548. getmysql(req, res, "insertNote", json['uid'], json['c']);
  1549. });
  1550. //根据便签id修改便签内容
  1551. router.route('/updateNote').all((req, res, next) => {
  1552. var json = queryString(req.url);
  1553. getmysql(req, res, "updateNote", json['nid'], json['c']);
  1554. });
  1555. //删除便签
  1556. router.route('/deleteNote').all((req, res, next) => {
  1557. var json = queryString(req.url);
  1558. getmysql(req, res, "deleteNote", json['nid']);
  1559. });
  1560. //查询便签
  1561. router.route('/selectNoteContent').all((req, res, next) => {
  1562. var json = queryString(req.url);
  1563. getmysql(req, res, "selectNoteContent", json['cn']);
  1564. });
  1565. //修改用户信息
  1566. router.route('/updateUserByEdu').all((req, res, next) => {
  1567. postmysql(req, res, "updateUserByEdu");
  1568. });
  1569. //修改用户信息
  1570. router.route('/updateUserByEdu1').all((req, res, next) => {
  1571. postmysql(req, res, "updateUserByEdu1");
  1572. });
  1573. //修改用户信息
  1574. router.route('/updateUserByEduOid').all((req, res, next) => {
  1575. postmysql(req, res, "updateUserByEduOid");
  1576. });
  1577. //修改学生信息
  1578. router.route('/updateStudentInfo').all((req, res, next) => {
  1579. postmysql(req, res, "updateStudentInfo");
  1580. });
  1581. //教师端data修改pbl用户信息
  1582. router.route('/updatePblMessage').all((req, res, next) => {
  1583. postmysql2(req, res, "updatePblMessage");
  1584. });
  1585. router.route('/updatePblMessage2').all((req, res, next) => {
  1586. postmysql(req, res, "updatePblMessage");
  1587. });
  1588. router.route('/updateRaceUser').all((req, res, next) => {
  1589. postmysql(req, res, "updateRaceUser");
  1590. });
  1591. //查询用户信息
  1592. router.route('/selectUser').all((req, res, next) => {
  1593. var json = queryString(req.url);
  1594. getmysql(req, res, "selectUser", json['userid']);
  1595. });
  1596. //查询分类及子分类
  1597. router.route('/selectType').all((req, res, next) => {
  1598. var json = queryString(req.url);
  1599. getmysql(req, res, "selectType", );
  1600. });
  1601. //查询分类及子分类
  1602. router.route('/selectStudentType').all((req, res, next) => {
  1603. var json = queryString(req.url);
  1604. getmysql(req, res, "selectStudentType", );
  1605. });
  1606. //查询赛事分类及子分类
  1607. router.route('/selectMatType').all((req, res, next) => {
  1608. var json = queryString(req.url);
  1609. getmysql(req, res, "selectMatType", );
  1610. });
  1611. //根据学校查询分类
  1612. router.route('/selectPtype').all((req, res, next) => {
  1613. var json = queryString(req.url);
  1614. getmysql(req, res, "selectPtype", json["page"], 10);
  1615. });
  1616. //根据学校查询分类1
  1617. router.route('/selectPtype1').all((req, res, next) => {
  1618. var json = queryString(req.url);
  1619. getmysql(req, res, "selectPtype1", json["oid"], json["page"], 10);
  1620. });
  1621. //添加分类
  1622. router.route('/addPtype').all((req, res, next) => {
  1623. var json = queryString(req.url);
  1624. getmysql(req, res, "addPtype", json["n"], json["uid"], json["oid"]);
  1625. });
  1626. //修改分类
  1627. router.route('/updatePtype').all((req, res, next) => {
  1628. var json = queryString(req.url);
  1629. getmysql(req, res, "updatePtype", json["n"], json["tid"]);
  1630. });
  1631. //删除分类
  1632. router.route('/deletePtype').all((req, res, next) => {
  1633. var json = queryString(req.url);
  1634. getmysql(req, res, "deletePtype", json["tid"]);
  1635. });
  1636. //查询子分类列表
  1637. router.route('/selectStype').all((req, res, next) => {
  1638. var json = queryString(req.url);
  1639. getmysql(req, res, "selectStype", json["pid"], json["oid"], json["page"], 10);
  1640. });
  1641. //添加子分类
  1642. router.route('/addStype').all((req, res, next) => {
  1643. var json = queryString(req.url);
  1644. getmysql(req, res, "addStype", json["pid"], json["n"], json["uid"], json["oid"]);
  1645. });
  1646. //根据学校id查询子分类
  1647. router.route('/selectTypeByOid').all((req, res, next) => {
  1648. var json = queryString(req.url);
  1649. getmysql(req, res, "selectTypeByOid", json["oid"]);
  1650. });
  1651. //根据学校id查询子分类
  1652. router.route('/selectTypeByOid').all((req, res, next) => {
  1653. var json = queryString(req.url);
  1654. getmysql(req, res, "selectTypeByOid", json["oid"]);
  1655. });
  1656. //根据组织id查询子分类
  1657. router.route('/selectStudentTypeByOid').all((req, res, next) => {
  1658. var json = queryString(req.url);
  1659. getmysql(req, res, "selectStudentTypeByOid", json["oid"]);
  1660. });
  1661. //更加父id查询分类
  1662. router.route('/selectTypeByPid').all((req, res, next) => {
  1663. var json = queryString(req.url);
  1664. getmysql(req, res, "selectTypeByPid", json['pid']);
  1665. });
  1666. //点击工具计数
  1667. router.route('/insertToolsCount').all((req, res, next) => {
  1668. var json = queryString(req.url);
  1669. getmysql(req, res, "insertToolsCount", json['cid'], json['chid'], json['uid'], json['tid'], json['count']);
  1670. });
  1671. //修改工具次数
  1672. router.route('/updateToolsCount').all((req, res, next) => {
  1673. var json = queryString(req.url);
  1674. getmysql(req, res, "updateToolsCount", json['cid'], json['chid'], json['uid'], json['tid'], json['count']);
  1675. });
  1676. //查询工具次数
  1677. router.route('/selectToolsCount').all((req, res, next) => {
  1678. var json = queryString(req.url);
  1679. getmysql(req, res, "selectToolsCount", json['cid'], json['chid'], json['uid']);
  1680. });
  1681. //导出学生
  1682. router.route('/selectUserBySchool').all((req, res, next) => {
  1683. var json = queryString(req.url);
  1684. getmysql(req, res, "selectUserBySchool", json['oid']);
  1685. });
  1686. //上传学生作业
  1687. router.route('/insertSWork').all((req, res, next) => {
  1688. var json = queryString(req.url);
  1689. getmysql(req, res, "insertSWork", json['uid'], json['cid'], json['p'], json['t'], json['upload']);
  1690. });
  1691. //查询学生作业
  1692. router.route('/selectSWork').all((req, res, next) => {
  1693. var json = queryString(req.url);
  1694. getmysql(req, res, "selectSWork", json['uid'], json['cid'], json['p'], json['type']);
  1695. });
  1696. //查询赛事案例设计
  1697. router.route('/selectCase').all((req, res, next) => {
  1698. var json = queryString(req.url);
  1699. getmysql(req, res, "selectCase", json['org']);
  1700. });
  1701. //查询赛事案例设计
  1702. router.route('/selectCase2').all((req, res, next) => {
  1703. var json = queryString(req.url);
  1704. getmysql(req, res, "selectCase2", json['org']);
  1705. });
  1706. //查询赛事项目列表
  1707. router.route('/selectRaceList').all((req, res, next) => {
  1708. var json = queryString(req.url);
  1709. getmysql(req, res, "selectRaceList", json['uid']);
  1710. });
  1711. //修改赛事状态
  1712. router.route('/updateRaceState').all((req, res, next) => {
  1713. var json = queryString(req.url);
  1714. getmysql(req, res, "updateRaceState", json['id'], json['s']);
  1715. });
  1716. //查询赛事项目详情
  1717. router.route('/selectRaceDetail').all((req, res, next) => {
  1718. var json = queryString(req.url);
  1719. getmysql(req, res, "selectRaceDetail", json['id']);
  1720. });
  1721. //race 查询学校
  1722. router.route('/getSchool').all((req, res, next) => {
  1723. var json = queryString(req.url);
  1724. getmysql(req, res, "getSchool", json['n']);
  1725. });
  1726. //lsc
  1727. //admin 查询学校
  1728. router.route('/getSchoolAdmin').all((req, res, next) => {
  1729. var json = queryString(req.url);
  1730. getmysql(req, res, "select_school", json['page'], 10);
  1731. });
  1732. //admin 添加学校
  1733. router.route('/addSchoolAdmin').all((req, res, next) => {
  1734. postmysql(req, res, "add_school");
  1735. });
  1736. //组织添加学校
  1737. router.route('/addSchoolOrg').all((req, res, next) => {
  1738. postmysql(req, res, "addSchoolOrg");
  1739. });
  1740. //教师端组织添加学校
  1741. router.route('/insertSchoolByOrg').all((req, res, next) => {
  1742. postmysql(req, res, "insertSchoolByOrg");
  1743. });
  1744. //admin 删除学校
  1745. router.route('/deleteSchoolAdmin').all((req, res, next) => {
  1746. postmysql(req, res, "delete_school");
  1747. });
  1748. //admin 查询班级
  1749. router.route('/getClassAdmin').all((req, res, next) => {
  1750. var json = queryString(req.url);
  1751. getmysql(req, res, "select_classAdmin", json['cn'], json['page'], 10);
  1752. });
  1753. //admin 添加班级
  1754. router.route('/addClassAdmin').all((req, res, next) => {
  1755. postmysql(req, res, "add_classAdmin");
  1756. });
  1757. //admin 查询班级是否重复
  1758. router.route('/getClassRepeat').all((req, res, next) => {
  1759. var json = queryString(req.url);
  1760. getmysql(req, res, "select_classRepeatAdmin", json['n'], json['oid']);
  1761. });
  1762. //admin 发布通知
  1763. router.route('/addNews').all((req, res, next) => {
  1764. postmysql(req, res, "add_news");
  1765. });
  1766. //admin 删除通知
  1767. router.route('/deleteNews').all((req, res, next) => {
  1768. postmysql(req, res, "delete_news");
  1769. });
  1770. //admin 添加banner
  1771. router.route('/addBanner').all((req, res, next) => {
  1772. postmysql(req, res, "add_banner");
  1773. });
  1774. //admin 添加banner
  1775. router.route('/deleteBanner').all((req, res, next) => {
  1776. postmysql(req, res, "delete_banner");
  1777. });
  1778. //admin 查询banner
  1779. router.route('/getBanner').all((req, res, next) => {
  1780. var json = queryString(req.url);
  1781. getmysql(req, res, "select_banner");
  1782. });
  1783. //根据学校查询banner
  1784. router.route('/selectBannerByOid').all((req, res, next) => {
  1785. var json = queryString(req.url);
  1786. getmysql(req, res, "selectBannerByOid", json["oid"]);
  1787. });
  1788. //admin 查询课程getSearchCourse
  1789. router.route('/getSearchCourse').all((req, res, next) => {
  1790. var json = queryString(req.url);
  1791. getmysql(req, res, "selectAll_courseSearch", json['t']);
  1792. });
  1793. //根据学校查询课程
  1794. router.route('/getSearchCourseByoid').all((req, res, next) => {
  1795. var json = queryString(req.url);
  1796. getmysql(req, res, "selectAll_courseByOid", json['t'], json['oid']);
  1797. });
  1798. //admin 查询所有课程专区
  1799. router.route('/getZone').all((req, res, next) => {
  1800. getmysql(req, res, "select_zone");
  1801. });
  1802. //admin 添加课程专区
  1803. router.route('/addZone').all((req, res, next) => {
  1804. postmysql(req, res, "insert_classZone");
  1805. });
  1806. //查询所有课程专区下的课程
  1807. router.route('/getZoneClass').all((req, res, next) => {
  1808. var json = queryString(req.url);
  1809. getmysql(req, res, "select_zoneClass", json['bid'], json['oid'], json['page'], 10);
  1810. });
  1811. //查询所有课程专区下的课程
  1812. router.route('/getZoneClassStudent').all((req, res, next) => {
  1813. var json = queryString(req.url);
  1814. getmysql(req, res, "select_zoneClass", json['bid'], json['oid'], json['page'], 20);
  1815. });
  1816. //admin 后台查看专区下课程的数量
  1817. router.route('/getZoneClassNum').all((req, res, next) => {
  1818. var json = queryString(req.url);
  1819. getmysql(req, res, "select_zoneClassNum", json['bid']);
  1820. });
  1821. //admin 后台添加课程专区时查看课程是否在此专区重复
  1822. router.route('/getZoneClassRepeat').all((req, res, next) => {
  1823. var json = queryString(req.url);
  1824. getmysql(req, res, "select_zoneClassRepeat", json['pid'], json['cid']);
  1825. });
  1826. //把课程添加进专区
  1827. router.route('/addZoneCourse').all((req, res, next) => {
  1828. postmysql(req, res, "insert_app");
  1829. });
  1830. //admin 删除课程专区底下的课程
  1831. router.route('/deleteZoneCourse').all((req, res, next) => {
  1832. postmysql(req, res, "delete_app");
  1833. });
  1834. //admin 删除班级
  1835. router.route('/deleteZone').all((req, res, next) => {
  1836. postmysql(req, res, "delete_zone");
  1837. });
  1838. //admin 后台专区上移下移
  1839. router.route('/zoneRank').all((req, res, next) => {
  1840. postmysql(req, res, "update_classRank");
  1841. });
  1842. //admin 添加模板文档
  1843. router.route('/addTemplateAdmin').all((req, res, next) => {
  1844. postmysql(req, res, "add_template");
  1845. });
  1846. //admin 添加模板文档
  1847. router.route('/deleteTemplateAdmin').all((req, res, next) => {
  1848. postmysql(req, res, "delete_template");
  1849. });
  1850. //admin 查询模板文档
  1851. router.route('/getTemplateAdmin').all((req, res, next) => {
  1852. var json = queryString(req.url);
  1853. getmysql(req, res, "select_template", json['page'], 10);
  1854. });
  1855. //查询上传作业
  1856. router.route('/getCourseWorks').all((req, res, next) => {
  1857. var json = queryString(req.url); //cid 课程id,page 页数
  1858. getmysql(req, res, "select_courseWorks", json['cid'], json['stage'], json['task'], json['page'], 10);
  1859. });
  1860. //查询上传作业
  1861. router.route('/getCourseWorks2').all((req, res, next) => {
  1862. var json = queryString(req.url); //cid 课程id,page 页数
  1863. getmysql(req, res, "select_courseWorks2", json['cid'], json['uname'], json['stage'], json['task'], json['page'], 10);
  1864. });
  1865. //查询上传作业
  1866. router.route('/getCourseWorks3').all((req, res, next) => {
  1867. var json = queryString(req.url); //cid 课程id,page 页数
  1868. getmysql(req, res, "select_courseWorks3", json['cid'], json['uname'], json['stage'], json['task'], json['page'], 10);
  1869. });
  1870. //查询报告数据
  1871. router.route('/getCourseWorksReport').all((req, res, next) => {
  1872. var json = queryString(req.url); //cid 课程id,page 页数
  1873. getmysql(req, res, "getCourseWorksReport", json['cid']);
  1874. });
  1875. //admin 添加项目模板文档
  1876. router.route('/addCourseTemplateAdmin').all((req, res, next) => {
  1877. postmysql(req, res, "add_courseTemplate");
  1878. });
  1879. //admin 添加项目模板文档
  1880. router.route('/deleteCourseTemplateAdmin').all((req, res, next) => {
  1881. postmysql(req, res, "delete_courseTemplate");
  1882. });
  1883. //admin 查询项目模板文档
  1884. router.route('/getCourseTemplateAdmin').all((req, res, next) => {
  1885. var json = queryString(req.url);
  1886. getmysql(req, res, "select_courseTemplate", json['page'], 10);
  1887. });
  1888. //teacher 查询项目模板
  1889. router.route('/getCourseTemplateT').all((req, res, next) => {
  1890. var json = queryString(req.url);
  1891. getmysql(req, res, "select_courseTemplateT");
  1892. });
  1893. //admin 查询课程
  1894. router.route('/getCourseAdmin').all((req, res, next) => {
  1895. var json = queryString(req.url);
  1896. getmysql(req, res, "select_courseAdmin", json['cn'], json['page'], 10);
  1897. });
  1898. //admin 查询模板文档
  1899. router.route('/deleteCourseAdmin').all((req, res, next) => {
  1900. postmysql(req, res, "delete_courseAdmin");
  1901. });
  1902. //加入分组
  1903. router.route('/joinGroup').all((req, res, next) => {
  1904. postmysql(req, res, "joinGroup");
  1905. });
  1906. //退出分组
  1907. router.route('/exitGroup').all((req, res, next) => {
  1908. postmysql(req, res, "exitGroup");
  1909. });
  1910. //查看分组
  1911. router.route('/selectGroup').all((req, res, next) => {
  1912. postmysql(req, res, "selectGroup");
  1913. });
  1914. //查询ppt在哪页
  1915. router.route('/selectPptPage').all((req, res, next) => {
  1916. var json = queryString(req.url);
  1917. getmysql(req, res, "selectPptPage", json['id']);
  1918. });
  1919. //修改ppt页码
  1920. router.route('/updatePptPage').all((req, res, next) => {
  1921. postmysql(req, res, "updatePptPage");
  1922. });
  1923. //修改ppt操作
  1924. router.route('/updatePPTHandle').all((req, res, next) => {
  1925. postmysql(req, res, "updatePPTHandle");
  1926. });
  1927. //查询实时课堂
  1928. router.route('/getRealTimeClass').all((req, res, next) => {
  1929. var json = queryString(req.url);
  1930. getmysql(req, res, "getRealTimeClass", json["cn"], json["uid"], json["page"], 10);
  1931. });
  1932. //查询实时课堂学生
  1933. router.route('/getRealTimeClassStu').all((req, res, next) => {
  1934. var json = queryString(req.url);
  1935. getmysql(req, res, "getRealTimeClassStu", json["oid"], json["cid"], json["page"], 10);
  1936. });
  1937. //查询实时课堂学生
  1938. router.route('/getRealTimeClassById').all((req, res, next) => {
  1939. var json = queryString(req.url);
  1940. getmysql(req, res, "getRealTimeClassById", json["id"]);
  1941. });
  1942. //根据区级管理者查询案例
  1943. router.route('/selectAnliList').all((req, res, next) => {
  1944. var json = queryString(req.url);
  1945. getmysql(req, res, "selectAnliList", json["typea"], json["typeb"], json["typec"], json["typed"], json["typeE"], json["cn"], json["cid"], json["page"], 10);
  1946. });
  1947. //根据市级管理者查询案例
  1948. router.route('/selectAnliList1').all((req, res, next) => {
  1949. var json = queryString(req.url);
  1950. getmysql(req, res, "selectAnliList1", json["typea"], json["typeb"], json["typec"], json["typed"], json["typeE"], json["cn"], json["cid"], json["page"], 10);
  1951. });
  1952. //根据省级级管理者查询案例
  1953. router.route('/selectAnliList2').all((req, res, next) => {
  1954. var json = queryString(req.url);
  1955. getmysql(req, res, "selectAnliList2", json["typea"], json["typeb"], json["typec"], json["typed"], json["typeE"], json["cn"], json["cid"], json["page"], 10);
  1956. });
  1957. //删除案例
  1958. router.route('/deleteAnli').all((req, res, next) => {
  1959. var json = queryString(req.url);
  1960. getmysql(req, res, "deleteAnli", json["id"]);
  1961. });
  1962. //根据区县管理者查询评分
  1963. router.route('/selectPoint').all((req, res, next) => {
  1964. var json = queryString(req.url);
  1965. getmysql(req, res, "selectPoint", json["typea"], json["typeb"], json["typec"], json["typed"], json["typeE"], json["cn"], json["cid"], json["page"], 10);
  1966. });
  1967. //根据市级管理者查询评分
  1968. router.route('/selectPoint1').all((req, res, next) => {
  1969. var json = queryString(req.url);
  1970. getmysql(req, res, "selectPoint1", json["typea"], json["typeb"], json["typec"], json["typed"], json["typeE"], json["cn"], json["cid"], json["page"], 10);
  1971. });
  1972. //查询分配案例
  1973. router.route('/selectCaseUser').all((req, res, next) => {
  1974. var json = queryString(req.url);
  1975. getmysql(req, res, "select_case", json["uid"]);
  1976. });
  1977. //根据用户id,课程id,阶段,任务,工具去查询协同
  1978. router.route('/selectWord').all((req, res, next) => {
  1979. var json = queryString(req.url);
  1980. getmysql(req, res, "selectWord", json["uid"], json["cid"], json["s"], json["task"], json["t"]);
  1981. });
  1982. //根据用户id,课程id,阶段,任务,工具去查询协同
  1983. router.route('/selectWord2').all((req, res, next) => {
  1984. var json = queryString(req.url);
  1985. getmysql(req, res, "selectWord2", json["uid"], json["cid"], json["s"], json["task"], json["t"], json["type"]);
  1986. });
  1987. //根据用户id,课程id,阶段,任务,工具去查询协同
  1988. router.route('/selectWords').all((req, res, next) => {
  1989. var json = queryString(req.url);
  1990. getmysql(req, res, "selectWords", json["uid"], json["cid"], json["s"], json["task"], json["t"], json["type"]);
  1991. });
  1992. //新增协同内容
  1993. router.route('/insertWord').all((req, res, next) => {
  1994. var json = queryString(req.url);
  1995. getmysql(req, res, "insertWord", json["uid"], json["cid"], json["s"], json["task"], json["t"], json["text"]);
  1996. });
  1997. //分配案例
  1998. router.route('/insertCase').all((req, res, next) => {
  1999. if (req.body[0]) {
  2000. p = [req.body[0].uid, req.body[0].box];
  2001. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "insertCase"); //執行存儲過程
  2002. mysql.usselect(p, function(ret) {
  2003. res.end(JSON.stringify({ success: 1 }));
  2004. });
  2005. }
  2006. });
  2007. //新增评分
  2008. router.route('/addScore').all((req, res, next) => {
  2009. var json = queryString(req.url);
  2010. getmysql(req, res, "addScore", json["rid"], json["suser"], json["s"]);
  2011. });
  2012. //查询评分
  2013. router.route('/selectScore').all((req, res, next) => {
  2014. var json = queryString(req.url);
  2015. getmysql(req, res, "selectScore", json["rid"]);
  2016. });
  2017. //赛事推荐
  2018. router.route('/updateRaceRec').all((req, res, next) => {
  2019. var json = queryString(req.url);
  2020. getmysql(req, res, "updateRaceRec", json["id"], json["rec"]);
  2021. });
  2022. //teacher 查询模板
  2023. router.route('/getTemplateT').all((req, res, next) => {
  2024. var json = queryString(req.url);
  2025. getmysql(req, res, "select_templateT");
  2026. });
  2027. //思维网格 创建房间
  2028. router.route('/insertRoom').all((req, res, next) => {
  2029. postmysql(req, res, "insertRoom");
  2030. });
  2031. //删除作业阶段任务工具
  2032. router.route('/deleteStudentToolSTT').all((req, res, next) => {
  2033. postmysql(req, res, "deleteStudentToolSTT");
  2034. });
  2035. //删除作业阶段任务
  2036. router.route('/deleteStudentToolST').all((req, res, next) => {
  2037. postmysql(req, res, "deleteStudentToolST");
  2038. });
  2039. //删除作业阶段
  2040. router.route('/deleteStudentToolS').all((req, res, next) => {
  2041. postmysql(req, res, "deleteStudentToolST");
  2042. });
  2043. //协同编辑 创建房间
  2044. router.route('/insertRoomByFile').all((req, res, next) => {
  2045. //var json = queryString(req.url);
  2046. postmysql2(req, res, "insertRoomByFile");
  2047. //getmysql(req, res, "insertRoomByFile", json["uid"], json["n"], json["d"]);
  2048. });
  2049. //思维网格 查询是否是重复房间号
  2050. router.route('/checkRoomNum').all((req, res, next) => {
  2051. var json = queryString(req.url);
  2052. getmysql(req, res, "checkRoomNum", json['num']);
  2053. });
  2054. //思维网格 查询房间列表
  2055. router.route('/selectRoomList').all((req, res, next) => {
  2056. var json = queryString(req.url);
  2057. getmysql(req, res, "selectRoomList", json['uid'], json['oid'], json['cid'], json['cu'], json['cn']);
  2058. });
  2059. //查询pdf列表
  2060. router.route('/selectRTC').all((req, res, next) => {
  2061. var json = queryString(req.url);
  2062. getmysql(req, res, "selectRTC", json['uid'], json['cu'], json['cn']);
  2063. });
  2064. //协同文档 查询房间列表
  2065. router.route('/selectFileList').all((req, res, next) => {
  2066. var json = queryString(req.url);
  2067. getmysql(req, res, "selectFileList", json['uid'], json['oid'], json['cid'], json['cu'], json['cn']);
  2068. });
  2069. //协同编辑 查询是否是重复房间号
  2070. router.route('/checkRoomNumByFile').all((req, res, next) => {
  2071. var json = queryString(req.url);
  2072. getmysql(req, res, "checkRoomNumByFile", json['num']);
  2073. });
  2074. //思维网格 根据房间号或者用户id查询房间信息
  2075. router.route('/selectRoom').all((req, res, next) => {
  2076. var json = queryString(req.url);
  2077. getmysql(req, res, "selectRoom", json['uid']);
  2078. });
  2079. //思维网格 根据房间号或者用户id查询房间信息
  2080. router.route('/getRoom').all((req, res, next) => {
  2081. var json = queryString(req.url);
  2082. getmysql(req, res, "select_room", json['fid']);
  2083. });
  2084. //协同编辑 根据房间号或者用户id查询房间信息
  2085. router.route('/selectRoomByFile').all((req, res, next) => {
  2086. var json = queryString(req.url);
  2087. getmysql(req, res, "selectRoomByFile", json['uid']);
  2088. });
  2089. //思维网格 修改房间数据
  2090. router.route('/updateRoomData').all((req, res, next) => {
  2091. postmysql(req, res, "updateRoomData");
  2092. });
  2093. router.route('/updateFileData').all((req, res, next) => {
  2094. var json = queryString(req.url);
  2095. var json2 = json['mode'].split(',');
  2096. getmysql(req, res, "updateFileData", json2[0], json2[1]);
  2097. });
  2098. router.route('/select_file').all((req, res, next) => {
  2099. var json = queryString(req.url);
  2100. getmysql(req, res, "select_file", json['fid']);
  2101. });
  2102. //思维网格 解散房间
  2103. router.route('/dismiss').all((req, res, next) => {
  2104. postmysql(req, res, "update_room");
  2105. });
  2106. //提交提问
  2107. router.route('/addProblem').all((req, res, next) => {
  2108. postmysql(req, res, "add_problem");
  2109. //cid 课程id,chid 章节id,t 提问内容,uid 用户id
  2110. });
  2111. //查询提交的提问
  2112. router.route('/getProblem').all((req, res, next) => {
  2113. var json = queryString(req.url); //cid 课程id,page 页数
  2114. getmysql(req, res, "select_problem", json['cid'], json['page'], 10);
  2115. });
  2116. //获取用户基本信息
  2117. router.route('/getUserInfo').all((req, res, next) => {
  2118. var json = queryString(req.url);
  2119. getmysql(req, res, "getUserInfo", json['uid'], json['cid']);
  2120. });
  2121. //获取项目基本信息
  2122. router.route('/getCourseInfo').all((req, res, next) => {
  2123. var json = queryString(req.url);
  2124. getmysql(req, res, "getCourseInfo", json['cid']);
  2125. });
  2126. //作业生成报告
  2127. router.route('/getWorkData').all((req, res, next) => {
  2128. var json = queryString(req.url); //cid 课程id,page 页数
  2129. getmysql(req, res, "select_work_data", json['cid']);
  2130. });
  2131. //查询评价体系
  2132. router.route('/getEvaluation').all((req, res, next) => {
  2133. var json = queryString(req.url); //cid 课程id,page 页数
  2134. getmysql(req, res, "select_evaluation", json['oid'], json['n'], json['page'], 10);
  2135. });
  2136. //添加评价体系
  2137. router.route('/addEvaluation').all((req, res, next) => {
  2138. postmysql(req, res, "add_evaluation");
  2139. //uid 用户id t标题 c内容
  2140. });
  2141. //修改评价体系
  2142. router.route('/updateEvaluation').all((req, res, next) => {
  2143. postmysql(req, res, "update_evaluation");
  2144. //c内容 t标题 id评价id
  2145. });
  2146. //删除评价体系
  2147. router.route('/deleteEvaluation').all((req, res, next) => {
  2148. postmysql(req, res, "delete_evaluation");
  2149. // id评价id
  2150. });
  2151. //批量添加学生
  2152. router.route('/batchRegistrationMore').post(function(req, res, next) {
  2153. let users = req.body[0];
  2154. let arr = JSON.parse(req.body[0].arr);
  2155. for (let i = 0; i < arr.length; i++) {
  2156. let _username = arr[i].name;
  2157. let _mail = arr[i].mail;
  2158. let _password = users.password || "123456";
  2159. let _alias = arr[i].name;
  2160. let _oid = users.oid;
  2161. let _ph = arr[i].phone ? arr[i].phone : '';
  2162. let _class = arr[i].class;
  2163. let _sId = arr[i].sId;
  2164. //加密密碼
  2165. _password = bcrypt.hashSync(_password, bcrypt.genSaltSync(10));
  2166. //生成激活碼
  2167. let _hashstr = new Date().getTime() + "";
  2168. let _digest = crypto.createHash('sha256').update(_hashstr, 'utf8').digest('hex');
  2169. //用戶數據
  2170. let _userdata = [
  2171. _mail,
  2172. _password,
  2173. _alias,
  2174. "",
  2175. 1, //0老师 1学生
  2176. _username,
  2177. "",
  2178. generateAPIKey(_username),
  2179. _digest,
  2180. "",
  2181. _username,
  2182. _sId,
  2183. 2, //1老师 2学生
  2184. _oid,
  2185. _ph,
  2186. _class,
  2187. '',
  2188. "0",
  2189. ];
  2190. //參數拼接,註冊
  2191. _userdata.unshift(_mysqluser[0], _mysqluser[1], "pbl_add_batchregister");
  2192. //用戶註冊處理
  2193. mysql.usselect(_userdata, function(ret) {
  2194. // let _pbluserdata = [
  2195. // ret[1][0].uid,
  2196. // _username,
  2197. // _sId,
  2198. // 2,
  2199. // _oid,
  2200. // _ph,
  2201. // _class,
  2202. // '',
  2203. // "0",
  2204. // ];
  2205. // _pbluserdata.unshift(_mysqlLabor[0], _mysqlLabor[1], "updateUserByEdu");
  2206. // mysql.usselect(_pbluserdata, function(ret) {
  2207. res.end(JSON.stringify({ success: 1 }));
  2208. // });
  2209. });
  2210. }
  2211. });
  2212. //批量添加教师
  2213. router.route('/batchRegistrationMore1').post(function(req, res, next) {
  2214. let users = req.body[0];
  2215. let arr = JSON.parse(req.body[0].arr);
  2216. for (let i = 0; i < arr.length; i++) {
  2217. let _username = arr[i].name;
  2218. let _mail = arr[i].mail;
  2219. let _password = users.password || "123456";
  2220. let _alias = arr[i].name;
  2221. let _org = users.org;
  2222. let _oid = arr[i].school;
  2223. let _ph = arr[i].phone ? arr[i].phone : '';
  2224. let _class = arr[i].class;
  2225. let _sId = arr[i].sId;
  2226. //加密密碼
  2227. _password = bcrypt.hashSync(_password, bcrypt.genSaltSync(10));
  2228. //生成激活碼
  2229. let _hashstr = new Date().getTime() + "";
  2230. let _digest = crypto.createHash('sha256').update(_hashstr, 'utf8').digest('hex');
  2231. //用戶數據
  2232. let _userdata = [
  2233. _mail,
  2234. _password,
  2235. _alias,
  2236. "",
  2237. 0, //0老师 1学生
  2238. _username,
  2239. "",
  2240. generateAPIKey(_username),
  2241. _digest,
  2242. "",
  2243. _username,
  2244. _sId,
  2245. 1, //1老师 2学生
  2246. _org,
  2247. _oid,
  2248. '',
  2249. '',
  2250. '',
  2251. "0",
  2252. ];
  2253. //參數拼接,註冊
  2254. _userdata.unshift(_mysqluser[0], _mysqluser[1], "pbl_add_batchregister_oid");
  2255. //用戶註冊處理
  2256. mysql.usselect(_userdata, function(ret) {
  2257. res.end(JSON.stringify({ success: 1 }));
  2258. });
  2259. }
  2260. });
  2261. //新增学生
  2262. router.route('/batchRegistration').post(function(req, res, next) {
  2263. var users = req.body[0];
  2264. //循环注册
  2265. var _username = users.alias;
  2266. var _mail = users.username;
  2267. var _password = users.password || "123456";
  2268. var _alias = users.alias;
  2269. var _oid = users.oid;
  2270. var _ph = users.ph;
  2271. var _class = users.cid;
  2272. var _sId = users.sid;
  2273. //加密密碼
  2274. _password = bcrypt.hashSync(_password, bcrypt.genSaltSync(10));
  2275. //生成激活碼
  2276. let _hashstr = new Date().getTime() + "";
  2277. let _digest = crypto.createHash('sha256').update(_hashstr, 'utf8').digest('hex');
  2278. //用戶數據
  2279. var _userdata = [
  2280. _mail,
  2281. _password,
  2282. _alias,
  2283. "",
  2284. 1,
  2285. _username,
  2286. "",
  2287. generateAPIKey(_username),
  2288. _digest,
  2289. "",
  2290. _username,
  2291. _sId,
  2292. 2,
  2293. _oid,
  2294. _ph,
  2295. _class,
  2296. '',
  2297. "0",
  2298. ];
  2299. //參數拼接,註冊
  2300. _userdata.unshift(_mysqluser[0], _mysqluser[1], "pbl_add_batchregister");
  2301. //用戶註冊處理
  2302. mysql.usselect(_userdata, function(ret) {
  2303. res.end(JSON.stringify({ uid: ret[1][0].uid, ph: _ph, oid: _oid, cid: _class, success: 1 }));
  2304. });
  2305. });
  2306. //新增教师
  2307. router.route('/batchRegistration1').post(function(req, res, next) {
  2308. var users = req.body[0];
  2309. //循环注册
  2310. var _username = users.alias;
  2311. var _mail = users.username;
  2312. var _password = users.password || "123456";
  2313. var _alias = users.alias;
  2314. var _org = users.org;
  2315. var _oid = users.oid;
  2316. var _ph = users.ph;
  2317. var _class = users.cid;
  2318. var _sId = users.sid;
  2319. //加密密碼
  2320. _password = bcrypt.hashSync(_password, bcrypt.genSaltSync(10));
  2321. //生成激活碼
  2322. let _hashstr = new Date().getTime() + "";
  2323. let _digest = crypto.createHash('sha256').update(_hashstr, 'utf8').digest('hex');
  2324. //用戶數據
  2325. var _userdata = [
  2326. _mail,
  2327. _password,
  2328. _alias,
  2329. "",
  2330. 0,
  2331. _username,
  2332. "",
  2333. generateAPIKey(_username),
  2334. _digest,
  2335. "",
  2336. _username,
  2337. _sId,
  2338. 1,
  2339. _org,
  2340. _oid,
  2341. _ph,
  2342. _class,
  2343. '',
  2344. "0",
  2345. ];
  2346. //參數拼接,註冊
  2347. _userdata.unshift(_mysqluser[0], _mysqluser[1], "pbl_add_batchregister1");
  2348. //用戶註冊處理
  2349. mysql.usselect(_userdata, function(ret) {
  2350. res.end(JSON.stringify({ uid: ret[1][0].uid, ph: _ph, oid: _oid, cid: _class, success: 1 }));
  2351. });
  2352. });
  2353. router.route('/batchRegistrationOrg').post(function(req, res, next) {
  2354. var users = req.body[0];
  2355. //循环注册
  2356. var _username = users.alias;
  2357. var _mail = users.username;
  2358. var _password = users.password || "123456";
  2359. var _alias = users.alias;
  2360. var _oid = users.oid;
  2361. var _ph = users.ph;
  2362. var _class = users.cid;
  2363. var _sId = users.sid;
  2364. var _org = users.org;
  2365. //加密密碼
  2366. _password = bcrypt.hashSync(_password, bcrypt.genSaltSync(10));
  2367. //生成激活碼
  2368. let _hashstr = new Date().getTime() + "";
  2369. let _digest = crypto.createHash('sha256').update(_hashstr, 'utf8').digest('hex');
  2370. //用戶數據
  2371. var _userdata = [
  2372. _mail,
  2373. _password,
  2374. _alias,
  2375. "",
  2376. 1,
  2377. _username,
  2378. "",
  2379. generateAPIKey(_username),
  2380. _digest,
  2381. "",
  2382. _username,
  2383. _sId,
  2384. 2,
  2385. _oid,
  2386. _ph,
  2387. _class,
  2388. '',
  2389. "0",
  2390. _org
  2391. ];
  2392. //參數拼接,註冊
  2393. _userdata.unshift(_mysqluser[0], _mysqluser[1], "pbl_add_batchregister_org");
  2394. //用戶註冊處理
  2395. mysql.usselect(_userdata, function(ret) {
  2396. res.end(JSON.stringify({ uid: ret[1][0].uid, ph: _ph, oid: _oid, cid: _class, success: 1 }));
  2397. });
  2398. });
  2399. router.route('/batchRegistrationMoreOrg').post(function(req, res, next) {
  2400. let users = req.body[0];
  2401. let arr = JSON.parse(req.body[0].arr);
  2402. for (let i = 0; i < arr.length; i++) {
  2403. let _username = arr[i].name;
  2404. let _mail = arr[i].mail;
  2405. let _password = users.password || "123456";
  2406. let _alias = arr[i].name;
  2407. let _oid = users.oid;
  2408. let _ph = arr[i].phone ? arr[i].phone : '';
  2409. let _class = arr[i].class;
  2410. let _sId = arr[i].sId;
  2411. let _org = users.org;
  2412. //加密密碼
  2413. _password = bcrypt.hashSync(_password, bcrypt.genSaltSync(10));
  2414. //生成激活碼
  2415. let _hashstr = new Date().getTime() + "";
  2416. let _digest = crypto.createHash('sha256').update(_hashstr, 'utf8').digest('hex');
  2417. //用戶數據
  2418. let _userdata = [
  2419. _mail,
  2420. _password,
  2421. _alias,
  2422. "",
  2423. 1, //0老师 1学生
  2424. _username,
  2425. "",
  2426. generateAPIKey(_username),
  2427. _digest,
  2428. "",
  2429. _username,
  2430. _sId,
  2431. 2, //1老师 2学生
  2432. _oid,
  2433. _ph,
  2434. _class,
  2435. '',
  2436. "0",
  2437. _org
  2438. ];
  2439. //參數拼接,註冊
  2440. _userdata.unshift(_mysqluser[0], _mysqluser[1], "pbl_add_batchregister_org2");
  2441. //用戶註冊處理
  2442. mysql.usselect(_userdata, function(ret) {
  2443. res.end(JSON.stringify({ success: 1 }));
  2444. });
  2445. }
  2446. });
  2447. function generateAPIKey(username) {
  2448. let timeStamp = new Date().getTime();
  2449. let hashStr = timeStamp + username;
  2450. let digest = crypto.createHash('sha256').update(hashStr, 'utf8').digest('hex');
  2451. return digest;
  2452. }
  2453. queryString = function(url) {
  2454. var a = url.split("?");
  2455. var json = querystring.parse(a[1])
  2456. return json;
  2457. }
  2458. //post存儲過程處理
  2459. postmysql = function(req, res, functionname) {
  2460. //mode的處理
  2461. if (req.body[0]) {
  2462. p = Object.values(req.body[0]);
  2463. p.unshift(_mysqlLabor[0], _mysqlLabor[1], functionname);
  2464. //執行存儲過程
  2465. mysql.usselect(p, function(ret) { res.end(JSON.stringify(ret)); });
  2466. }
  2467. }
  2468. //post存儲過程處理
  2469. postmysql2 = function(req, res, functionname) {
  2470. //mode的處理
  2471. if (req.body) {
  2472. p = Object.values(req.body)[0].split(",");
  2473. p.unshift(_mysqlLabor[0], _mysqlLabor[1], functionname);
  2474. //執行存儲過程
  2475. mysql.usselect(p, function(ret) { res.end(JSON.stringify(ret)); });
  2476. }
  2477. }
  2478. //post存儲過程處理
  2479. postmysql3 = function(req, res, functionname) {
  2480. //mode的處理
  2481. if (req.body) {
  2482. p = Object.values(req.body);
  2483. p.unshift(_mysqlLabor[0], _mysqlLabor[1], functionname);
  2484. //執行存儲過程
  2485. mysql.usselect(p, function(ret) { res.end(JSON.stringify(ret)); });
  2486. }
  2487. }
  2488. //get獲取數據庫信息
  2489. getmysql = function(req, res, functionname, ...p) {
  2490. p = p || [];
  2491. p.unshift(_mysqlLabor[0], _mysqlLabor[1], functionname);
  2492. //執行存儲過程
  2493. mysql.usselect(p, function(ret) { res.end(JSON.stringify(ret)); }); //
  2494. }
  2495. //post存储过程处理
  2496. userpostmysql = function(req, res, functionname) {
  2497. //mode的处理
  2498. if (req.body.mode) {
  2499. p = req.body.mode.split(",");
  2500. p.unshift(_mysqluser[0], _mysqluser[1], functionname);
  2501. //执行存储过程
  2502. mysql.usselect(p, function(ret) { res.end(JSON.stringify(ret)); });
  2503. }
  2504. }
  2505. //get获取数据库信息
  2506. usergetmysql = function(req, res, functionname, ...p) {
  2507. p = p || [];
  2508. p.unshift(_mysqluser[0], _mysqluser[1], functionname);
  2509. //执行存储过程
  2510. mysql.usselect(p, function(ret) { res.end(JSON.stringify(ret)); }); //
  2511. }
  2512. module.exports = router;