pbl.js 134 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683
  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('/updatePassword1').post(function(req, res, next) {
  208. //mode的处理
  209. if (req.body[0]) {
  210. let p = [req.body[0].userid];
  211. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "getPassword1"); //執行存儲過程
  212. mysql.usselect(p, function(ret) {
  213. var paJ = ret[0][0].password
  214. var op = bcrypt.hashSync(req.body[0].opassword, bcrypt.genSaltSync(10));
  215. bcrypt.compare(req.body[0].opassword, paJ, function(err, result) {
  216. // console.log(result)
  217. if (result) {
  218. let p2 = [req.body[0].userid, bcrypt.hashSync(req.body[0].password, bcrypt.genSaltSync(10))];
  219. p2.unshift(_mysqlLabor[0], _mysqlLabor[1], "updatePassword1"); //執行存儲過程
  220. mysql.usselect(p2, function(ret) {
  221. res.end(JSON.stringify([{ success: 1 }]));
  222. });
  223. } else {
  224. res.end(JSON.stringify([{ success: 0 }]));
  225. }
  226. })
  227. });
  228. }
  229. });
  230. /* 找寻重复手机号 */
  231. router.route('/findPhone').all((req, res, next) => {
  232. var json = queryString(req.url);
  233. getmysql(req, res, "findPhone", json['un']);
  234. });
  235. /* 找寻是否有此账号 */
  236. router.route('/findUsername').all((req, res, next) => {
  237. var json = queryString(req.url);
  238. getmysql(req, res, "findUsername", json['un']);
  239. });
  240. /* 找寻重复邮箱 */
  241. router.route('/findMail').all((req, res, next) => {
  242. var json = queryString(req.url);
  243. usergetmysql(req, res, "findMail", json['un']);
  244. });
  245. /* 找寻重复学号 */
  246. router.route('/findSid').all((req, res, next) => {
  247. var json = queryString(req.url);
  248. getmysql(req, res, "findSid", json['un']);
  249. });
  250. /* 新增班级 */
  251. router.route('/insertClass').all((req, res, next) => {
  252. var json = queryString(req.url);
  253. getmysql(req, res, "insertClass", json['name'], json['oid'], json['uid']);
  254. });
  255. /* 修改班级 */
  256. router.route('/updateClass').all((req, res, next) => {
  257. var json = queryString(req.url);
  258. getmysql(req, res, "updateClass", json['id'], json['n'], json['oid']);
  259. });
  260. /* 查询班级 */
  261. router.route('/selectClass').all((req, res, next) => {
  262. var json = queryString(req.url);
  263. getmysql(req, res, "selectClass", json['cu'], json['oid'], json['cn'], json['page'], 10);
  264. });
  265. /* 删除班级 */
  266. router.route('/deleteClass').all((req, res, next) => {
  267. var json = queryString(req.url);
  268. getmysql(req, res, "deleteClass", json['id']);
  269. });
  270. /* 查询学校 */
  271. router.route('/selectOrg').all((req, res, next) => {
  272. var json = queryString(req.url);
  273. getmysql(req, res, "selectOrg");
  274. });
  275. /* 查询组织 */
  276. router.route('/selectorg2').all((req, res, next) => {
  277. var json = queryString(req.url);
  278. getmysql(req, res, "selectorg2");
  279. });
  280. /* 修改学校名称 */
  281. router.route('/updateSN').all((req, res, next) => {
  282. var json = queryString(req.url);
  283. getmysql(req, res, "updateSchoolName", json["oid"], json["n"]);
  284. });
  285. /* 教师端修改学校名称 */
  286. router.route('/updateSchoolByOrg').all((req, res, next) => {
  287. var json = queryString(req.url);
  288. getmysql(req, res, "updateSchoolByOrg", json["n"], json["d"], json["id"]);
  289. });
  290. /* 教师端查询未联结学校 */
  291. router.route('/selectNoCSchool').all((req, res, next) => {
  292. var json = queryString(req.url);
  293. getmysql(req, res, "selectNoCSchool");
  294. });
  295. /* 教师端新增或修改联结学校 */
  296. router.route('/addNoSchool').all((req, res, next) => {
  297. var json = queryString(req.url);
  298. getmysql(req, res, "addNoSchool", json["id"], json["coid"]);
  299. });
  300. /* 新增学生 */
  301. router.route('/insertStudent').all((req, res, next) => {
  302. var json = queryString(req.url);
  303. json['userpassword'] = bcrypt.hashSync(json['userpassword'], bcrypt.genSaltSync(10))
  304. getmysql(req, res, "insertStudent", json['ph'], json['username'], json['userpassword'], json['type'], json['oid'], json['tid'], json['cid']);
  305. });
  306. // /* 新增学生 */
  307. // router.route('/iStudent').all((req, res, next) => {
  308. // var json = queryString(req.url);
  309. // json['userpassword'] = bcrypt.hashSync(json['userpassword'], bcrypt.genSaltSync(10))
  310. // getmysql(req, res, "insertStudent", json['ph'], json['username'], json['userpassword'], json['type'], json['oid'], json['tid'], json['cid']);
  311. // });
  312. /* 查询学生 */
  313. router.route('/selectStudent').all((req, res, next) => {
  314. var json = queryString(req.url);
  315. getmysql(req, res, "selectStudent", json['oid'], json['cu'], json['cn'], json['page'], 10);
  316. });
  317. /* ppt根据学校查询学生 */
  318. router.route('/selectStudentByScoolPPt').all((req, res, next) => {
  319. var json = queryString(req.url);
  320. getmysql(req, res, "selectStudentByScoolPPt", json['oid'], json['cid']);
  321. });
  322. /* 查询学校底下的所有学生 */
  323. router.route('/selectOrgStu').all((req, res, next) => {
  324. var json = queryString(req.url);
  325. getmysql(req, res, "selectOrgStu", json['oid']);
  326. });
  327. /* 查询学生 */
  328. router.route('/selectStudentAdd').all((req, res, next) => {
  329. var json = queryString(req.url);
  330. getmysql(req, res, "selectStudentAdd", json['oid'], json['cu'], json['cn']);
  331. });
  332. /* 查询老师 */
  333. router.route('/selectTeacherAdd').all((req, res, next) => {
  334. var json = queryString(req.url);
  335. getmysql(req, res, "selectTeacherAdd", json['oid'], json['cu'], json['cn']);
  336. });
  337. /* 查询老师 */
  338. router.route('/selectTeacherAddOrg').all((req, res, next) => {
  339. var json = queryString(req.url);
  340. getmysql(req, res, "selectTeacherAddOrg", json['oid'], json['cu'], json['cn']);
  341. });
  342. /* 查询学生 */
  343. router.route('/selectStudentAddOrg').all((req, res, next) => {
  344. var json = queryString(req.url);
  345. getmysql(req, res, "selectStudentAddOrg", json['oid'], json['cu'], json['cn']);
  346. });
  347. /* 查询全部用户 */
  348. router.route('/selectUserAddOrg').all((req, res, next) => {
  349. var json = queryString(req.url);
  350. getmysql(req, res, "selectUserAddOrg", json['oid'], json['cu'], json['cn']);
  351. });
  352. /* 查询全部用户 */
  353. router.route('/selectUserAdd').all((req, res, next) => {
  354. var json = queryString(req.url);
  355. getmysql(req, res, "selectUserAdd", json['oid'], json['cu'], json['cn']);
  356. });
  357. /* 查询全部用户 */
  358. router.route('/selectUserByOidS').all((req, res, next) => {
  359. var json = queryString(req.url);
  360. getmysql(req, res, "selectUserByOidS", json['oid'], json['org'], json['cu'], json['cn']);
  361. });
  362. /* 查询全部用户 */
  363. router.route('/selectUserByOidS2').all((req, res, next) => {
  364. var json = queryString(req.url);
  365. getmysql(req, res, "selectUserByOidS2", json['oid'], json['org'], json['cu'], json['cn'], json['page'], json['pageSize']);
  366. });
  367. /* 查询全部用户 */
  368. router.route('/selectUserByOidS2Studio').all((req, res, next) => {
  369. var json = queryString(req.url);
  370. getmysql(req, res, "selectUserByOidS2Studio", json['oid'], json['org'], json['cu'], json['cn'], json['page'], json['pageSize']);
  371. });
  372. /* 查询班级是否有重复 */
  373. router.route('/selectC').all((req, res, next) => {
  374. var json = queryString(req.url);
  375. getmysql(req, res, "selectC", json['className']);
  376. });
  377. /* 查询学校是否有重复 */
  378. router.route('/selectS').all((req, res, next) => {
  379. var json = queryString(req.url);
  380. getmysql(req, res, "selectS", json['schoolName']);
  381. });
  382. /* 修改个人信息 */
  383. router.route('/updateUser').all((req, res, next) => {
  384. postmysql(req, res, "updateUser");
  385. });
  386. //查询老师的信息
  387. router.route('/getUser').all((req, res, next) => {
  388. var json = queryString(req.url);
  389. getmysql(req, res, "selectUserDeail", json['uid']);
  390. });
  391. //查询老师的信息
  392. router.route('/getRaceUser').all((req, res, next) => {
  393. var json = queryString(req.url);
  394. getmysql(req, res, "getRaceUser", json['uid']);
  395. });
  396. router.route('/selectUser').all((req, res, next) => {
  397. var json = queryString(req.url);
  398. getmysql(req, res, "selectUser", json['userid']);
  399. });
  400. //查询教师端消息
  401. router.route('/getNewsTeacher').all((req, res, next) => {
  402. var json = queryString(req.url);
  403. getmysql(req, res, "selectNew", json['uid'], json['page'], 10);
  404. });
  405. //查询教师端消息
  406. router.route('/selectNotice').all((req, res, next) => {
  407. var json = queryString(req.url);
  408. getmysql(req, res, "selectNotice", json['uid'], json['oid'], json['org'], json['page'], 10);
  409. });
  410. //查询教师端消息
  411. router.route('/selectNotice2').all((req, res, next) => {
  412. var json = queryString(req.url);
  413. getmysql(req, res, "selectNotice2", json['uid'], json['oid'], json['org']);
  414. });
  415. //查询教师端消息
  416. router.route('/addNotice').all((req, res, next) => {
  417. postmysql(req, res, "addNotice");
  418. });
  419. //查询教师端消息
  420. router.route('/deleteNotice').all((req, res, next) => {
  421. postmysql(req, res, "deleteNotice");
  422. });
  423. //查询通知详情
  424. router.route('/selectNewDetail').all((req, res, next) => {
  425. var json = queryString(req.url);
  426. getmysql(req, res, "selectNewDetail", json['nid']);
  427. });
  428. //查出分组分类
  429. router.route('/getGroup').all((req, res, next) => {
  430. getmysql(req, res, "selectGroupTeacher");
  431. });
  432. //查询这个老师底下的学生提交的作业
  433. router.route('/getWorks').all((req, res, next) => { //已经不用
  434. var json = queryString(req.url);
  435. getmysql(req, res, "selectWorks", json['cn'], json['cid'], json['page'], 10);
  436. });
  437. //查询项目
  438. router.route('/getProject').all((req, res, next) => {
  439. var json = queryString(req.url);
  440. getmysql(req, res, "selectProject", json['type'], json['uid'], json['oid'], json['cn'], json['page'], 10);
  441. });
  442. //新评价查询项目
  443. router.route('/getProject1').all((req, res, next) => { //已经不用
  444. var json = queryString(req.url);
  445. getmysql(req, res, "selectProject1", json['uid'], json['cid'], json['eid'], json['cn'], json['page'], 10);
  446. });
  447. //查询项目
  448. router.route('/getMyProject').all((req, res, next) => {
  449. var json = queryString(req.url);
  450. getmysql(req, res, "selectMyProject", json['uid'], json['page'], 10);
  451. });
  452. //查询项目成员
  453. router.route('/selectProjectStudent').all((req, res, next) => {
  454. var json = queryString(req.url);
  455. getmysql(req, res, "select_student", json['cn'], json['oid'], json['uid']);
  456. });
  457. //查询Banner列表
  458. router.route('/selectBannerList').all((req, res, next) => {
  459. var json = queryString(req.url);
  460. getmysql(req, res, "selectBannerList", json['page'], 10);
  461. });
  462. //查询Banner列表
  463. router.route('/selectAllBanner').all((req, res, next) => {
  464. var json = queryString(req.url);
  465. getmysql(req, res, "selectAllBanner", json["t"]);
  466. });
  467. //新增Banner
  468. router.route('/insertBannerList').all((req, res, next) => {
  469. postmysql(req, res, "insertBannerList");
  470. });
  471. //删除提交的作业
  472. router.route('/deleteCourseWork').all((req, res, next) => {
  473. postmysql(req, res, "deleteCourseWork");
  474. });
  475. //删除提交的作业
  476. router.route('/deleteCourseWorkS').all((req, res, next) => {
  477. postmysql(req, res, "deleteCourseWorkS");
  478. });
  479. //删除Banner
  480. router.route('/deleteBannerList').all((req, res, next) => {
  481. var json = queryString(req.url);
  482. getmysql(req, res, "deleteBannerList", json['id']);
  483. });
  484. //新增课程
  485. router.route('/addWork').all((req, res, next) => {
  486. postmysql(req, res, "insert_teacher_work");
  487. });
  488. //点赞评论
  489. router.route('/insertComment').all((req, res, next) => {
  490. postmysql(req, res, "insertComment");
  491. });
  492. //点赞评论
  493. router.route('/getComment').all((req, res, next) => {
  494. postmysql(req, res, "getComment");
  495. });
  496. //取消点赞
  497. router.route('/deleteComment').all((req, res, next) => {
  498. var json = queryString(req.url);
  499. getmysql(req, res, "deleteComment", json['wid'], json['lid']);
  500. });
  501. //删除评论
  502. router.route('/deleteComment2').all((req, res, next) => {
  503. var json = queryString(req.url);
  504. getmysql(req, res, "deleteComment2", json['id']);
  505. });
  506. //上传批注图片
  507. router.route('/updateCourseWorks').all((req, res, next) => {
  508. postmysql(req, res, "updateCourseWorks");
  509. });
  510. //上传文件
  511. router.route('/addCourseWorks').all((req, res, next) => {
  512. postmysql(req, res, "addCourseWorks");
  513. });
  514. //上传文件
  515. router.route('/addCourseWorksS').all((req, res, next) => {
  516. postmysql(req, res, "addCourseWorksS");
  517. });
  518. //可上传多个文件
  519. router.route('/addCourseWorksR').all((req, res, next) => {
  520. postmysql(req, res, "addCourseWorksR");
  521. });
  522. //上传文件
  523. router.route('/addCourseWorksTeacher').all((req, res, next) => {
  524. postmysql(req, res, "addCourseWorksTeacher");
  525. });
  526. //上传文件
  527. router.route('/addCourseWorks2').all((req, res, next) => {
  528. var json = queryString(req.url);
  529. postmysql(req, res, "addCourseWorks", json['uid'], json['cid'], json['stage'], json['task'], json['tool'], json['content'], json['type']);
  530. });
  531. //上传文件
  532. router.route('/addCourseWorks3').all((req, res, next) => {
  533. var json = queryString(req.url);
  534. getmysql(req, res, "addCourseWorks2", json['uid'], json['cid'], json['stage'], json['task'], json['tool'], json['content'], json['type'], json['atool']);
  535. });
  536. //上传文件
  537. router.route('/addCourseWorks3-2').all((req, res, next) => {
  538. var json = queryString(req.url);
  539. postmysql(req, res, "addCourseWorks2");
  540. });
  541. //上传文件
  542. router.route('/addCourseWorks2Inter').all((req, res, next) => {
  543. var json = queryString(req.url);
  544. postmysql(req, res, "addCourseWorks2Inter");
  545. });
  546. //上传文件
  547. router.route('/addCourseWorks4').all((req, res, next) => {
  548. postmysql3(req, res, "addCourseWorks3");
  549. });
  550. //上传文件
  551. router.route('/addCourseWorks4E').all((req, res, next) => {
  552. postmysql3(req, res, "addCourseWorks3E");
  553. });
  554. //上传文件
  555. router.route('/addCourseWorks4s').all((req, res, next) => {
  556. postmysql3(req, res, "addCourseWorks4s");
  557. });
  558. //上传文件
  559. router.route('/addCourseWorks5').all((req, res, next) => {
  560. postmysql(req, res, "addCourseWorks3");
  561. });
  562. //上传批量文件
  563. router.route('/addCourseWorksPl').all((req, res, next) => {
  564. if (req.body[0]) {
  565. var p = Object.values(req.body[0]);
  566. let ateacher = p[0]
  567. let cid = p[1]
  568. let stage = p[2]
  569. let task = p[3]
  570. let tool = p[4]
  571. let files = JSON.parse(p[5])
  572. for (let i = 0; i < files.length; i++) {
  573. var k = [files[i].username, cid, stage, task, tool, files[i].url, files[i].fileType, ateacher, '50']
  574. k.unshift(_mysqlLabor[0], _mysqlLabor[1], 'addCourseWorksPl');
  575. //執行存儲過程
  576. mysql.usselect(k, function(ret) {
  577. if (i == files.length - 1) {
  578. res.end(JSON.stringify(ret));
  579. }
  580. });
  581. }
  582. }
  583. });
  584. //修改课程权限(学生是否能查看所有作业)
  585. router.route('/updateCourseSLook').all((req, res, next) => {
  586. var json = queryString(req.url);
  587. getmysql(req, res, "updateCourseSLook", json['sopen'], json['cid']);
  588. });
  589. //修改跟随模式阶段-任务
  590. router.route('/updateCourseFollowC').all((req, res, next) => {
  591. postmysql(req, res, "updateCourseFollowC");
  592. });
  593. //修改跟随模式
  594. router.route('/updateCourseFollow').all((req, res, next) => {
  595. postmysql(req, res, "updateCourseFollow");
  596. });
  597. //修改阶段锁定状态
  598. router.route('/updateCourseLookOpen').all((req, res, next) => {
  599. postmysql(req, res, "updateCourseLookOpen");
  600. });
  601. //查看阶段锁定的状态
  602. router.route('/getCourseState').all((req, res, next) => {
  603. var json = queryString(req.url);
  604. getmysql(req, res, "getCourseState", json['cid']);
  605. });
  606. //添加锁定状态
  607. router.route('/addCourseState').all((req, res, next) => {
  608. postmysql(req, res, "addCourseState");
  609. });
  610. //修改锁定状态
  611. router.route('/updateCourseSate').all((req, res, next) => {
  612. postmysql(req, res, "updateCourseSate");
  613. });
  614. //查询课程权限(学生是否能查看所有作业)
  615. router.route('/selectCourseSLook').all((req, res, next) => {
  616. var json = queryString(req.url);
  617. getmysql(req, res, "selectCourseSLook", json['cid']);
  618. });
  619. //查询作业详情
  620. router.route('/selectWorksDetail2').all((req, res, next) => {
  621. var json = queryString(req.url);
  622. getmysql(req, res, "selectWorksDetail2", json['uid'], json['cid'], json['stage'], json['task']);
  623. });
  624. //查询课程全部作业详情
  625. router.route('/selectWorksDetail3').all((req, res, next) => {
  626. var json = queryString(req.url);
  627. getmysql(req, res, "selectWorksDetail3", json['uid'], json['cid']);
  628. });
  629. //查询课程所有作业详情
  630. router.route('/selectAllWorksDetail').all((req, res, next) => {
  631. var json = queryString(req.url);
  632. getmysql(req, res, "selectAllWorksDetail", json['uid'], json['cid']);
  633. });
  634. //查询多个课程全部作业详情
  635. router.route('/selectWorksDetailMore').all((req, res, next) => {
  636. var json = queryString(req.url);
  637. getmysql(req, res, "selectWorksDetailMore", json['uid'], json['cid']);
  638. });
  639. //查询课程某个阶段某个任务下的评价
  640. router.route('/updateWorksEva').all((req, res, next) => {
  641. var json = queryString(req.url);
  642. getmysql(req, res, "updateWorksEva", json['cid'], json['s'], json['t'], json['uid'], json['rate']);
  643. });
  644. //学习中心教师查询作业
  645. router.route('/selectSWorks').all((req, res, next) => {
  646. var json = queryString(req.url);
  647. getmysql(req, res, "selectSWorks", json['cid'], json['s'], json['t']);
  648. });
  649. //学习中心教师查询作业全部展示
  650. router.route('/selectSWorks2').all((req, res, next) => {
  651. var json = queryString(req.url);
  652. getmysql(req, res, "selectSWorks2", json['cid']);
  653. });
  654. //学习中心学生查询作业
  655. router.route('/selectStudentWorks').all((req, res, next) => {
  656. var json = queryString(req.url);
  657. getmysql(req, res, "selectStudentWorks", json['uid'], json['cid'], json['s'], json['t']);
  658. });
  659. //实时课堂作业评价
  660. router.route('/updateStudentWork').all((req, res, next) => {
  661. postmysql(req, res, "updateStudentWork");
  662. });
  663. //学习中心查询学生
  664. router.route('/selectWorksStudent').all((req, res, next) => {
  665. var json = queryString(req.url);
  666. getmysql(req, res, "selectWorksStudent", json['oid'], json['cid']);
  667. });
  668. //批量上传查询学生
  669. router.route('/selectSnameByCid').all((req, res, next) => {
  670. var json = queryString(req.url);
  671. getmysql(req, res, "selectSnameByCid", json['cid']);
  672. });
  673. //批量上传查询学生分页
  674. router.route('/selectSnameByCidPage').all((req, res, next) => {
  675. var json = queryString(req.url);
  676. getmysql(req, res, "selectSnameByCidPage", json['cid'], json['cn'], json['page'], json['num']);
  677. });
  678. //分组查询学生
  679. router.route('/selectSnameByCidGroup').all((req, res, next) => {
  680. var json = queryString(req.url);
  681. getmysql(req, res, "selectSnameByCidGroup", json['cid'], json['oid'], json['cn']);
  682. });
  683. /* 查询学生 */
  684. router.route('/selectStudent2').all((req, res, next) => {
  685. var json = queryString(req.url);
  686. getmysql(req, res, "selectStudent2", json['oid'], json['cu'], json['cn'], json['cid'], json['page'], 10);
  687. });
  688. /* 查询教师 */
  689. router.route('/selectTeacher').all((req, res, next) => {
  690. var json = queryString(req.url);
  691. getmysql(req, res, "selectTeacher", json['org'], json['cu'], json['cn'], json['page'], 10);
  692. });
  693. /* 添加教师页面查询教师 */
  694. router.route('/selectTcTeacher').all((req, res, next) => {
  695. var json = queryString(req.url);
  696. getmysql(req, res, "selectTcTeacher", json['org'], json['oid'], json['cu'], json['cn'], json['page'], 10);
  697. });
  698. /* 查询所有评价体系 */
  699. router.route('/selectAllEvaluation').all((req, res, next) => {
  700. var json = queryString(req.url);
  701. getmysql(req, res, "selectAllEvaluation", json['oid']);
  702. });
  703. /* 根据市级用户查询评审员 */
  704. router.route('/selectReviewer').all((req, res, next) => {
  705. var json = queryString(req.url);
  706. getmysql(req, res, "selectReviewer", json['uid'], json['cn'], json['page'], 10);
  707. });
  708. /* 市级区县管理接口 */
  709. router.route('/selectCReviewer').all((req, res, next) => {
  710. var json = queryString(req.url);
  711. getmysql(req, res, "selectCReviewer", json['uid'], json['cn'], json['page'], 10);
  712. });
  713. /* 修改评审员 */
  714. router.route('/updateReviewer').all((req, res, next) => {
  715. var json = queryString(req.url);
  716. getmysql(req, res, "updateReviewer", json['n'], json['p'], json['t'], json['s'], json['uid']);
  717. });
  718. /* 删除评审员 */
  719. router.route('/deleteReviewer').all((req, res, next) => {
  720. var json = queryString(req.url);
  721. getmysql(req, res, "deleteReviewer", json['uid']);
  722. });
  723. /* 查询区县案例 */
  724. router.route('/selecAnliBox').all((req, res, next) => {
  725. var json = queryString(req.url);
  726. getmysql(req, res, "selecAnliBox");
  727. });
  728. /* 查询市级案例 */
  729. router.route('/selecAnliBox1').all((req, res, next) => {
  730. var json = queryString(req.url);
  731. getmysql(req, res, "selecAnliBox1");
  732. });
  733. /* 查询省级案例 */
  734. router.route('/selecAnliBox2').all((req, res, next) => {
  735. var json = queryString(req.url);
  736. getmysql(req, res, "selecAnliBox2");
  737. });
  738. /* 查询通知公告 */
  739. router.route('/selectRaceNotice').all((req, res, next) => {
  740. var json = queryString(req.url);
  741. getmysql(req, res, "selectRaceNotice", json['page'], 10);
  742. });
  743. /* 查询通知公告详情 */
  744. router.route('/getRaceNoticeDetail').all((req, res, next) => {
  745. var json = queryString(req.url);
  746. getmysql(req, res, "getRaceNoticeDetail", json['nid']);
  747. });
  748. /* 查看随机码是否重复 */
  749. router.route('/selectInviteCode').all((req, res, next) => {
  750. var json = queryString(req.url);
  751. getmysql(req, res, "selectInviteCode", json['code'], json['oid']);
  752. });
  753. /* 查看随机码是否重复 */
  754. router.route('/selectInviteCode2').all((req, res, next) => {
  755. var json = queryString(req.url);
  756. getmysql(req, res, "selectInviteCode2", json['code'], json['oid']);
  757. });
  758. /* 根据随机码获取学校 */
  759. router.route('/selectCourseByIc').all((req, res, next) => {
  760. var json = queryString(req.url);
  761. getmysql(req, res, "selectCourseByIc", json['code'], json['oid']);
  762. });
  763. /* 根据随机码获取学校 */
  764. router.route('/selectCourseByIc2').all((req, res, next) => {
  765. var json = queryString(req.url);
  766. getmysql(req, res, "selectCourseByIc2", json['code'], json['oid']);
  767. });
  768. router.route('/addWorkNew').all((req, res, next) => {
  769. // postmysql(req, res, "insert_teacher_work_new");
  770. if (req.body[0]) {
  771. // p = Object.values(req.body[0]);
  772. 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];
  773. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "insert_teacher_work_new");
  774. //執行存儲過程
  775. mysql.usselect(p, function(ret) {
  776. let course = req.body[0].courseType;
  777. let courseId = ret[0][0].courseId;
  778. let userid = req.body[0].uid;
  779. delCourseType(course, courseId, userid);
  780. res.end(JSON.stringify({ ordernumber: ret[0][0].ordernumber, courseId: ret[0][0].courseId, success: 1 }));
  781. // res.end(JSON.stringify(ret));
  782. });
  783. }
  784. });
  785. router.route('/addWorkNew2').all((req, res, next) => {
  786. if (req.body[0]) {
  787. 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];
  788. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "insert_teacher_work_new2"); //執行存儲過程
  789. mysql.usselect(p, function(ret) {
  790. let course = req.body[0].courseType;
  791. let courseId = ret[0][0].courseId;
  792. let userid = req.body[0].uid;
  793. delCourseType(course, courseId, userid);
  794. // delCourseInviteCode(courseId, JSON.parse(req.body[0].inviteCode));
  795. res.end(JSON.stringify({ ordernumber: ret[0][0].ordernumber, courseId: ret[0][0].courseId, success: 1 }));
  796. });
  797. }
  798. });
  799. router.route('/addWorkNew2E').all((req, res, next) => {
  800. if (req.body[0]) {
  801. 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];
  802. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "insert_teacher_work_new2E"); //執行存儲過程
  803. mysql.usselect(p, function(ret) {
  804. let course = req.body[0].courseType;
  805. let courseId = ret[0][0].courseId;
  806. let userid = req.body[0].uid;
  807. delCourseType(course, courseId, userid);
  808. // delCourseInviteCode(courseId, JSON.parse(req.body[0].inviteCode));
  809. res.end(JSON.stringify({ ordernumber: ret[0][0].ordernumber, courseId: ret[0][0].courseId, success: 1 }));
  810. });
  811. }
  812. });
  813. router.route('/addWorkNew2T').all((req, res, next) => {
  814. if (req.body[0]) {
  815. 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];
  816. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "insert_teacher_work_new2T"); //執行存儲過程
  817. mysql.usselect(p, function(ret) {
  818. let course = req.body[0].courseType;
  819. let courseId = ret[0][0].courseId;
  820. let userid = req.body[0].uid;
  821. delCourseType(course, courseId, userid);
  822. // delCourseInviteCode(courseId, JSON.parse(req.body[0].inviteCode));
  823. res.end(JSON.stringify({ ordernumber: ret[0][0].ordernumber, courseId: ret[0][0].courseId, success: 1 }));
  824. });
  825. }
  826. });
  827. router.route('/addWorkNew4').all((req, res, next) => {
  828. if (req.body[0]) {
  829. 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, req.body[0].inviteCode];
  830. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "insert_teacher_work_new4"); //執行存儲過程
  831. mysql.usselect(p, function(ret) {
  832. let course = req.body[0].courseType;
  833. let courseId = ret[0][0].courseId;
  834. let userid = req.body[0].uid;
  835. delCourseType(course, courseId, userid);
  836. res.end(JSON.stringify({ ordernumber: ret[0][0].ordernumber, courseId: ret[0][0].courseId, success: 1 }));
  837. });
  838. }
  839. });
  840. router.route('/addCourseWorkNew2').all((req, res, next) => { //学生
  841. if (req.body[0]) {
  842. 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];
  843. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "addCourseWorkNew2"); //執行存儲過程
  844. mysql.usselect(p, function(ret) {
  845. let course = req.body[0].courseType;
  846. let courseId = ret[0][0].courseId;
  847. let userid = req.body[0].uid;
  848. delCourseType(course, courseId, userid);
  849. res.end(JSON.stringify({ ordernumber: ret[0][0].ordernumber, courseId: ret[0][0].courseId, success: 1 }));
  850. });
  851. }
  852. });
  853. router.route('/addCourseWorkNew22').all((req, res, next) => { //学生
  854. if (req.body[0]) {
  855. 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];
  856. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "addCourseWorkNew2"); //執行存儲過程
  857. mysql.usselect(p, function(ret) {
  858. let course = req.body[0].courseType;
  859. let courseId = ret[0][0].courseId;
  860. let userid = req.body[0].uid;
  861. delCourseTypeS(course, courseId, userid);
  862. res.end(JSON.stringify({ ordernumber: ret[0][0].ordernumber, courseId: ret[0][0].courseId, success: 1 }));
  863. });
  864. }
  865. });
  866. //新增赛事项目
  867. router.route('/addRace').all((req, res, next) => {
  868. if (req.body[0]) {
  869. 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];
  870. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "addRace"); //執行存儲過程
  871. mysql.usselect(p, function(ret) {
  872. let course = req.body[0].courseType;
  873. let courseId = ret[0][0].id;
  874. let userid = req.body[0].uid;
  875. delCourseType1(course, courseId, userid);
  876. res.end(JSON.stringify({ courseId: courseId, success: 1 }));
  877. });
  878. }
  879. });
  880. //新增赛事账号信息
  881. router.route('/addRaceUser').all((req, res, next) => {
  882. if (req.body[0]) {
  883. 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];
  884. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "addRaceUser"); //執行存儲過程
  885. mysql.usselect(p, function(ret) {
  886. let num = ret[0][0].num;
  887. let userid = ret[0][0].userid;
  888. if (num < 10) {
  889. num = "SZ" + "00" + num + "@gdae.com";
  890. } else if (num < 100) {
  891. num = "SZ" + "0" + num + "@gdae.com";
  892. } else if (num > 100) {
  893. num = "SZ" + num + "@gdae.com";
  894. }
  895. y = [userid, num, bcrypt.hashSync("123456", bcrypt.genSaltSync(10))];
  896. //参数拼接,注册
  897. y.unshift(_mysqlLabor[0], _mysqlLabor[1], "upRaceUserNamePassword");
  898. mysql.usselect(y, function(ret) {
  899. res.end(JSON.stringify(ret));
  900. });
  901. res.end(JSON.stringify({ num: num, success: 1 }));
  902. });
  903. }
  904. });
  905. //修改赛事项目
  906. router.route('/updateRace').all((req, res, next) => {
  907. if (req.body[0]) {
  908. 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];
  909. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "updateRace"); //執行存儲過程
  910. mysql.usselect(p, function(ret) {
  911. let course = req.body[0].courseType;
  912. let courseId = req.body[0].id;
  913. let userid = req.body[0].uid;
  914. delCourseType1(course, courseId, userid);
  915. res.end(JSON.stringify({ success: 1 }));
  916. });
  917. }
  918. });
  919. router.route('/addWorkNew3').all((req, res, next) => {
  920. if (req.body[0]) {
  921. 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];
  922. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "insert_teacher_work_new3"); //執行存儲過程
  923. mysql.usselect(p, function(ret) {
  924. let course = req.body[0].courseType;
  925. let courseId = ret[0][0].courseId;
  926. let userid = req.body[0].uid;
  927. delCourseType(course, courseId, userid);
  928. res.end(JSON.stringify({ ordernumber: ret[0][0].ordernumber, courseId: ret[0][0].courseId, success: 1 }));
  929. });
  930. }
  931. });
  932. router.route('/addInviteCode').all((req, res, next) => {
  933. if (req.body[0]) {
  934. // delCourseInviteCode(req.body[0].courseId,JSON.parse(req.body[0].inviteCode))
  935. addCourseInviteCode(req.body[0].courseId, JSON.parse(req.body[0].inviteCode))
  936. }
  937. });
  938. function delCourseInviteCode(courseId, inviteCode) {
  939. let _courseId = courseId;
  940. var _userdata = [
  941. _courseId
  942. ];
  943. _userdata.unshift(_mysqlLabor[0], _mysqlLabor[1], "delete_courseInviteCode");
  944. mysql.usselect(_userdata, function(ret) {
  945. // console.log(ret);
  946. addCourseInviteCode(_courseId, inviteCode)
  947. });
  948. }
  949. function delCourseType(course, courseId, userid) {
  950. let _courseId = courseId;
  951. var _userdata = [
  952. _courseId
  953. ];
  954. _userdata.unshift(_mysqlLabor[0], _mysqlLabor[1], "delete_courseType");
  955. mysql.usselect(_userdata, function(ret) {
  956. // console.log(ret);
  957. addCourseType(userid, course, _courseId)
  958. });
  959. // setTimeout(() => {
  960. // }, 1000);
  961. }
  962. function delCourseType1(course, courseId, userid) {
  963. let _courseId = courseId;
  964. var _userdata = [
  965. _courseId
  966. ];
  967. _userdata.unshift(_mysqlLabor[0], _mysqlLabor[1], "delete_courseType1");
  968. mysql.usselect(_userdata, function(ret) {
  969. // console.log(ret);
  970. });
  971. setTimeout(() => {
  972. addCourseType1(userid, course, _courseId)
  973. }, 1000);
  974. }
  975. function delCourseTypeS(course, courseId, userid) {
  976. let _courseId = courseId;
  977. var _userdata = [
  978. _courseId
  979. ];
  980. _userdata.unshift(_mysqlLabor[0], _mysqlLabor[1], "delete_courseTypeS");
  981. mysql.usselect(_userdata, function(ret) {
  982. // console.log(ret);
  983. addCourseTypeS(userid, course, _courseId)
  984. });
  985. // setTimeout(() => {
  986. // }, 1000);
  987. }
  988. function addCourseInviteCode(courseId, inviteCode) {
  989. var _courses = courseId
  990. var _tid = inviteCode
  991. for (let i = 0; i < _tid.length; i++) {
  992. let _userdata = [
  993. _courses,
  994. _tid[i].cid,
  995. _tid[i].ic,
  996. ];
  997. _userdata.unshift(_mysqlLabor[0], _mysqlLabor[1], "add_courseInviteCode");
  998. setTimeout(() => {
  999. mysql.usselect(_userdata, function(ret) {
  1000. // console.log(ret);
  1001. });
  1002. }, i * 100)
  1003. }
  1004. }
  1005. function addCourseType(userid, course, _courseId) {
  1006. var _uid = userid;
  1007. var _courses = _courseId
  1008. var _tid = JSON.parse(course)
  1009. for (let i = 0; i < _tid.length; i++) {
  1010. if (_tid[i] == '') {
  1011. continue;
  1012. }
  1013. var _userdata = [
  1014. _courses,
  1015. _tid[i],
  1016. _uid,
  1017. ];
  1018. _userdata.unshift(_mysqlLabor[0], _mysqlLabor[1], "add_courseType");
  1019. mysql.usselect(_userdata, function(ret) {
  1020. // console.log(ret);
  1021. });
  1022. }
  1023. }
  1024. function addCourseType1(userid, course, _courseId) {
  1025. var _uid = userid;
  1026. var _courses = _courseId
  1027. var _tid = JSON.parse(course)
  1028. for (let i = 0; i < _tid.length; i++) {
  1029. if (_tid[i] == '') {
  1030. continue;
  1031. }
  1032. var _userdata = [
  1033. _courses,
  1034. _tid[i],
  1035. _uid,
  1036. ];
  1037. _userdata.unshift(_mysqlLabor[0], _mysqlLabor[1], "add_courseType1");
  1038. mysql.usselect(_userdata, function(ret) {
  1039. // console.log(ret);
  1040. });
  1041. }
  1042. }
  1043. function addCourseTypeS(userid, course, _courseId) {
  1044. var _uid = userid;
  1045. var _courses = _courseId
  1046. var _tid = JSON.parse(course)
  1047. for (let i = 0; i < _tid.length; i++) {
  1048. if (_tid[i] == '') {
  1049. continue;
  1050. }
  1051. var _userdata = [
  1052. _courses,
  1053. _tid[i],
  1054. _uid,
  1055. ];
  1056. _userdata.unshift(_mysqlLabor[0], _mysqlLabor[1], "add_courseTypeS");
  1057. mysql.usselect(_userdata, function(ret) {
  1058. // console.log(ret);
  1059. });
  1060. }
  1061. }
  1062. //修改课程
  1063. // router.route('/updateWork').all((req, res, next) => {
  1064. // postmysql(req, res, "update_teacher_work");
  1065. // });
  1066. router.route('/updateWorkNew').all((req, res, next) => {
  1067. if (req.body[0]) {
  1068. // p = Object.values(req.body[0]);
  1069. 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];
  1070. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "update_teacher_work_new");
  1071. //執行存儲過程
  1072. mysql.usselect(p, function(ret) {
  1073. let course = req.body[0].courseType;
  1074. let courseId = req.body[0].cid;
  1075. let userid = req.body[0].uid;
  1076. delCourseType(course, courseId, userid);
  1077. res.end(JSON.stringify({ success: 1 }));
  1078. // res.end(JSON.stringify(ret));
  1079. });
  1080. }
  1081. });
  1082. //查询课程
  1083. // router.route('/selectCourse').all((req, res, next) => {
  1084. // var json = queryString(req.url);
  1085. // getmysql(req, res, "select_course", json['type'], json['uid'], json['oid'], json['page'], 10);
  1086. // });
  1087. router.route('/updateWorkNew2').all((req, res, next) => {
  1088. if (req.body[0]) {
  1089. 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];
  1090. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "update_teacher_work_new2"); //執行存儲過程
  1091. mysql.usselect(p, function(ret) {
  1092. let course = req.body[0].courseType;
  1093. let courseId = req.body[0].cid;
  1094. let userid = req.body[0].uid;
  1095. delCourseType(course, courseId, userid);
  1096. // delCourseInviteCode(courseId, JSON.parse(req.body[0].inviteCode));
  1097. res.end(JSON.stringify({ success: 1 }));
  1098. });
  1099. }
  1100. });
  1101. router.route('/updateWorkNew5').all((req, res, next) => {
  1102. if (req.body[0]) {
  1103. 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, req.body[0].inviteCode];
  1104. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "update_teacher_work_new5"); //執行存儲過程
  1105. mysql.usselect(p, function(ret) {
  1106. let course = req.body[0].courseType;
  1107. let courseId = req.body[0].cid;
  1108. let userid = req.body[0].uid;
  1109. delCourseType(course, courseId, userid);
  1110. res.end(JSON.stringify({ success: 1 }));
  1111. });
  1112. }
  1113. });
  1114. router.route('/updateStudentWorkNew2').all((req, res, next) => { //学生
  1115. if (req.body[0]) {
  1116. 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];
  1117. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "updateStudentWorkNew2"); //執行存儲過程
  1118. mysql.usselect(p, function(ret) {
  1119. let course = req.body[0].courseType;
  1120. let courseId = req.body[0].cid;
  1121. let userid = req.body[0].uid;
  1122. delCourseType(course, courseId, userid);
  1123. res.end(JSON.stringify({ success: 1 }));
  1124. });
  1125. }
  1126. });
  1127. router.route('/updateStudentWorkNew22').all((req, res, next) => { //学生
  1128. if (req.body[0]) {
  1129. 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];
  1130. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "updateStudentWorkNew2"); //執行存儲過程
  1131. mysql.usselect(p, function(ret) {
  1132. let course = req.body[0].courseType;
  1133. let courseId = req.body[0].cid;
  1134. let userid = req.body[0].uid;
  1135. delCourseTypeS(course, courseId, userid);
  1136. res.end(JSON.stringify({ success: 1 }));
  1137. });
  1138. }
  1139. });
  1140. router.route('/updateWorkNew3').all((req, res, next) => {
  1141. if (req.body[0]) {
  1142. 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];
  1143. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "update_teacher_work_new3"); //執行存儲過程
  1144. mysql.usselect(p, function(ret) {
  1145. let course = req.body[0].courseType;
  1146. let courseId = req.body[0].cid;
  1147. let userid = req.body[0].uid;
  1148. delCourseType(course, courseId, userid);
  1149. res.end(JSON.stringify({ success: 1 }));
  1150. });
  1151. }
  1152. });
  1153. function guid() {
  1154. var _num,
  1155. i,
  1156. _guid = "";
  1157. for (i = 0; i < 32; i++) {
  1158. _guid += Math.floor(Math.random() * 16).toString(16); //随机0 - 16 的数字 转变为16进制的字符串
  1159. _num = Math.floor((i - 7) / 4); //计算 (i-7)除4
  1160. if (_num > -1 && _num < 4 && i == 7 + 4 * _num) {
  1161. //会使guid中间加 "-" 形式为xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
  1162. _guid += "-";
  1163. }
  1164. }
  1165. return _guid;
  1166. }
  1167. router.route('/updateWorkNew4').all((req, res, next) => {
  1168. if (req.body[0]) {
  1169. let p = [req.body[0].cid];
  1170. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "select_course_detail"); //執行存儲過程
  1171. mysql.usselect(p, function(ret) {
  1172. let _unitIndex = parseInt(req.body[0].unitIndex);
  1173. let _chapters = JSON.parse(req.body[0].chapters);
  1174. let _unitJson = JSON.parse(ret[0][0].chapters)
  1175. if ((_unitJson.length - 1) < _unitIndex) {
  1176. let _i = _unitIndex - (_unitJson.length - 1)
  1177. for (let i = 0; i < _i; i++) {
  1178. _unitJson.push({
  1179. dyName: "", //单元标题
  1180. chapterInfo: [{
  1181. isread: false,
  1182. chapterid: guid(),
  1183. title: "",
  1184. courseName: "",
  1185. taskJson: [{
  1186. task: "",
  1187. taskDetail: "",
  1188. chapterData: [],
  1189. toolText: "",
  1190. toolChoose: [{
  1191. tool: [],
  1192. toolDetail: "",
  1193. toolType: 0,
  1194. askCount: 1,
  1195. askTitle: "",
  1196. askJson: [{ askstitle: "", askItem: 1, checkList: [] }],
  1197. }, ],
  1198. isShowTools: false,
  1199. askCount: 1,
  1200. isFold: 0,
  1201. askTitle: "",
  1202. askJson: [{ askstitle: "", askItem: 1, checkList: [] }],
  1203. checkJson: [{ checkCount: [], checkPerent: [] }],
  1204. homeworkList: [],
  1205. }, ],
  1206. itemCount: 1,
  1207. fileList1: [],
  1208. video: [],
  1209. testData: [],
  1210. pData: [],
  1211. templateArray: [],
  1212. }, ],
  1213. })
  1214. }
  1215. _unitJson[_unitIndex] = _chapters[_unitIndex]
  1216. } else {
  1217. _unitJson[_unitIndex] = _chapters[_unitIndex]
  1218. }
  1219. // console.log(_unitJson);
  1220. let p2 = [req.body[0].cid, JSON.stringify(_unitJson).replaceAll(/%/g, "%25")];
  1221. p2.unshift(_mysqlLabor[0], _mysqlLabor[1], "update_teacher_work_new4"); //執行存儲過程
  1222. mysql.usselect(p2, function(ret) {
  1223. res.end(JSON.stringify({ success: 1 }));
  1224. });
  1225. // res.end(JSON.stringify({ success: 1 }));
  1226. });
  1227. }
  1228. });
  1229. router.route('/updateStudentWorkNew4').all((req, res, next) => { //学生
  1230. if (req.body[0]) {
  1231. let p = [req.body[0].cid];
  1232. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "select_student_course_detail2"); //執行存儲過程
  1233. mysql.usselect(p, function(ret) {
  1234. let _unitIndex = parseInt(req.body[0].unitIndex);
  1235. let _chapters = JSON.parse(req.body[0].chapters);
  1236. let _unitJson = JSON.parse(ret[0][0].chapters)
  1237. if ((_unitJson.length - 1) < _unitIndex) {
  1238. let _i = _unitIndex - (_unitJson.length - 1)
  1239. for (let i = 0; i < _i; i++) {
  1240. _unitJson.push({
  1241. dyName: "", //单元标题
  1242. chapterInfo: [{
  1243. isread: false,
  1244. chapterid: guid(),
  1245. title: "",
  1246. courseName: "",
  1247. taskJson: [{
  1248. task: "",
  1249. taskDetail: "",
  1250. chapterData: [],
  1251. toolText: "",
  1252. toolChoose: [{
  1253. tool: [],
  1254. toolDetail: "",
  1255. toolType: 0,
  1256. askCount: 1,
  1257. askTitle: "",
  1258. askJson: [{ askstitle: "", askItem: 1, checkList: [] }],
  1259. }, ],
  1260. isShowTools: false,
  1261. askCount: 1,
  1262. isFold: 0,
  1263. askTitle: "",
  1264. askJson: [{ askstitle: "", askItem: 1, checkList: [] }],
  1265. checkJson: [{ checkCount: [], checkPerent: [] }],
  1266. homeworkList: [],
  1267. }, ],
  1268. itemCount: 1,
  1269. fileList1: [],
  1270. video: [],
  1271. testData: [],
  1272. pData: [],
  1273. templateArray: [],
  1274. }, ],
  1275. })
  1276. }
  1277. _unitJson[_unitIndex] = _chapters[_unitIndex]
  1278. } else {
  1279. _unitJson[_unitIndex] = _chapters[_unitIndex]
  1280. }
  1281. // console.log(_unitJson);
  1282. let p2 = [req.body[0].cid, JSON.stringify(_unitJson).replaceAll(/%/g, "%25")];
  1283. p2.unshift(_mysqlLabor[0], _mysqlLabor[1], "updateStudentWorkNew4"); //執行存儲過程
  1284. mysql.usselect(p2, function(ret) {
  1285. res.end(JSON.stringify({ success: 1 }));
  1286. });
  1287. // res.end(JSON.stringify({ success: 1 }));
  1288. });
  1289. }
  1290. });
  1291. //协同删除阶段
  1292. router.route('/deleteWork').all((req, res, next) => {
  1293. if (req.body[0]) {
  1294. let p = [req.body[0].cid];
  1295. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "select_course_detail"); //執行存儲過程
  1296. mysql.usselect(p, function(ret) {
  1297. let _chapid = req.body[0].chapid;
  1298. // console.log(_chapid);
  1299. let _chapters = JSON.parse(req.body[0].chapters);
  1300. let _unitJson = JSON.parse(ret[0][0].chapters)
  1301. let _unitJson2 = []
  1302. for (var i = 0; i < _unitJson.length; i++) {
  1303. if (_unitJson[i].chapterInfo[0].chapterid != _chapid) {
  1304. // console.log(1);
  1305. // _unitJson.splice(i, -1)
  1306. _unitJson2.push(_unitJson[i])
  1307. // break;
  1308. }
  1309. }
  1310. // console.log(_unitJson2);
  1311. let p2 = [req.body[0].cid, JSON.stringify(_unitJson2).replaceAll(/%/g, "%25")];
  1312. p2.unshift(_mysqlLabor[0], _mysqlLabor[1], "update_teacher_work_new4"); //執行存儲過程
  1313. mysql.usselect(p2, function(ret) {
  1314. res.end(JSON.stringify({ success: 1 }));
  1315. });
  1316. // res.end(JSON.stringify({ success: 1 }));
  1317. });
  1318. }
  1319. });
  1320. //协同删除阶段
  1321. router.route('/deleteStudentWork').all((req, res, next) => { //学生
  1322. if (req.body[0]) {
  1323. let p = [req.body[0].cid];
  1324. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "select_student_course_detail2"); //執行存儲過程
  1325. mysql.usselect(p, function(ret) {
  1326. let _chapid = req.body[0].chapid;
  1327. // console.log(_chapid);
  1328. let _chapters = JSON.parse(req.body[0].chapters);
  1329. let _unitJson = JSON.parse(ret[0][0].chapters)
  1330. let _unitJson2 = []
  1331. for (var i = 0; i < _unitJson.length; i++) {
  1332. if (_unitJson[i].chapterInfo[0].chapterid != _chapid) {
  1333. // console.log(1);
  1334. // _unitJson.splice(i, -1)
  1335. _unitJson2.push(_unitJson[i])
  1336. // break;
  1337. }
  1338. }
  1339. // console.log(_unitJson2);
  1340. let p2 = [req.body[0].cid, JSON.stringify(_unitJson2).replaceAll(/%/g, "%25")];
  1341. p2.unshift(_mysqlLabor[0], _mysqlLabor[1], "updateStudentWorkNew4"); //執行存儲過程
  1342. mysql.usselect(p2, function(ret) {
  1343. res.end(JSON.stringify({ success: 1 }));
  1344. });
  1345. // res.end(JSON.stringify({ success: 1 }));
  1346. });
  1347. }
  1348. });
  1349. //协同恢复删除的阶段
  1350. router.route('/restoreWork').all((req, res, next) => {
  1351. if (req.body[0]) {
  1352. let p = [req.body[0].cid];
  1353. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "select_course_detail"); //執行存儲過程
  1354. mysql.usselect(p, function(ret) {
  1355. let _chapid = req.body[0].chapid;
  1356. // console.log(_chapid);
  1357. let _chapters = JSON.parse(req.body[0].chapters);
  1358. let _unitJson = JSON.parse(ret[0][0].chapters)
  1359. let _unitJson2 = []
  1360. let chpaindex;
  1361. for (var i = 0; i < _chapters.length; i++) {
  1362. if (_chapters[i].chapterInfo[0].chapterid == _chapid) {
  1363. chpaindex = i
  1364. }
  1365. }
  1366. for (var i = 0; i < _unitJson.length; i++) {
  1367. if (_unitJson[i].chapterInfo[0].chapterid != _chapid) {
  1368. // console.log(1);
  1369. // _unitJson.splice(i, -1)
  1370. _unitJson2.push(_unitJson[i])
  1371. // break;
  1372. }
  1373. }
  1374. _unitJson2.splice(chpaindex, 0, _chapters[chpaindex])
  1375. // console.log(_unitJson2);
  1376. let p2 = [req.body[0].cid, JSON.stringify(_unitJson2).replaceAll(/%/g, "%25")];
  1377. p2.unshift(_mysqlLabor[0], _mysqlLabor[1], "update_teacher_work_new4"); //執行存儲過程
  1378. mysql.usselect(p2, function(ret) {
  1379. res.end(JSON.stringify({ success: 1 }));
  1380. });
  1381. // res.end(JSON.stringify({ success: 1 }));
  1382. });
  1383. }
  1384. });
  1385. //协同恢复删除的阶段
  1386. router.route('/restoreStudentWork').all((req, res, next) => { //学生
  1387. if (req.body[0]) {
  1388. let p = [req.body[0].cid];
  1389. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "select_student_course_detail2"); //執行存儲過程
  1390. mysql.usselect(p, function(ret) {
  1391. let _chapid = req.body[0].chapid;
  1392. // console.log(_chapid);
  1393. let _chapters = JSON.parse(req.body[0].chapters);
  1394. let _unitJson = JSON.parse(ret[0][0].chapters)
  1395. let _unitJson2 = []
  1396. let chpaindex;
  1397. for (var i = 0; i < _chapters.length; i++) {
  1398. if (_chapters[i].chapterInfo[0].chapterid == _chapid) {
  1399. chpaindex = i
  1400. }
  1401. }
  1402. for (var i = 0; i < _unitJson.length; i++) {
  1403. if (_unitJson[i].chapterInfo[0].chapterid != _chapid) {
  1404. // console.log(1);
  1405. // _unitJson.splice(i, -1)
  1406. _unitJson2.push(_unitJson[i])
  1407. // break;
  1408. }
  1409. }
  1410. _unitJson2.splice(chpaindex, 0, _chapters[chpaindex])
  1411. // console.log(_unitJson2);
  1412. let p2 = [req.body[0].cid, JSON.stringify(_unitJson2).replaceAll(/%/g, "%25")];
  1413. p2.unshift(_mysqlLabor[0], _mysqlLabor[1], "updateStudentWorkNew4"); //執行存儲過程
  1414. mysql.usselect(p2, function(ret) {
  1415. res.end(JSON.stringify({ success: 1 }));
  1416. });
  1417. // res.end(JSON.stringify({ success: 1 }));
  1418. });
  1419. }
  1420. });
  1421. router.route('/selectCourseNew').all((req, res, next) => {
  1422. var json = queryString(req.url);
  1423. 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);
  1424. });
  1425. router.route('/selectCourseNew2').all((req, res, next) => {
  1426. var json = queryString(req.url);
  1427. getmysql(req, res, "select_course_new2", json['type'], json['uid'], json['oid'], json['org'], json['typea'], json['typeb'], json['typec'], json['typed'], json['typeE'], json['cu'], json['cn'], json['page'], json['pageSize']);
  1428. });
  1429. router.route('/selectStudentCourseNew2').all((req, res, next) => {
  1430. var json = queryString(req.url);
  1431. 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);
  1432. });
  1433. router.route('/selectStudentCourseNew22').all((req, res, next) => {
  1434. var json = queryString(req.url);
  1435. 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'], json['pageSize']);
  1436. });
  1437. router.route('/selectStudentCourseNew222').all((req, res, next) => {
  1438. var json = queryString(req.url);
  1439. getmysql(req, res, "selectStudentCourseNew222", 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'], json['pageSize']);
  1440. });
  1441. router.route('/selectStudentCourseNew22Mode').all((req, res, next) => {
  1442. var json = queryString(req.url);
  1443. getmysql(req, res, "selectStudentCourseNew22Mode", json['type'], json['uid'], json['oid'], json['org'], json['typea'], json['typeb'], json['typec'], json['typed'], json['typef'], json['typeE'], json['cu'], json['cn']);
  1444. });
  1445. //查询协同编辑课程
  1446. router.route('/selectCourseTeam').all((req, res, next) => {
  1447. var json = queryString(req.url);
  1448. getmysql(req, res, "selectCourseTeam", json['uid'], json['oid']);
  1449. });
  1450. //查询学校
  1451. router.route('/selectSchoolName').all((req, res, next) => {
  1452. var json = queryString(req.url);
  1453. getmysql(req, res, "selectOidName", json['cu'], json['cn'], json['page'], 10);
  1454. });
  1455. //查询组织
  1456. router.route('/selectOrgName').all((req, res, next) => {
  1457. var json = queryString(req.url);
  1458. getmysql(req, res, "selectOrgName", json['page'], 10);
  1459. });
  1460. //查询学校
  1461. router.route('/selectSchoolName2').all((req, res, next) => {
  1462. var json = queryString(req.url);
  1463. getmysql(req, res, "selectOidName2", json['oid']);
  1464. });
  1465. //查询学校
  1466. router.route('/selectSchoolNameOrg').all((req, res, next) => {
  1467. var json = queryString(req.url);
  1468. getmysql(req, res, "selectSchoolNameOrg", json['org'], json['page'], 10);
  1469. });
  1470. //查询协同学校和被协同学校
  1471. router.route('/selectOrgType').all((req, res, next) => {
  1472. var json = queryString(req.url);
  1473. getmysql(req, res, "selectOrgType", json['t'], json['org'], json['page'], 10);
  1474. });
  1475. //新增批注
  1476. router.route('/addPz').all((req, res, next) => {
  1477. postmysql(req, res, "addPz");
  1478. });
  1479. //新增批注
  1480. router.route('/addPz2').all((req, res, next) => {
  1481. postmysql(req, res, "addPz2");
  1482. });
  1483. //删除批注
  1484. router.route('/deletePz').all((req, res, next) => {
  1485. postmysql(req, res, "deletePz");
  1486. });
  1487. //查询批注列表
  1488. router.route('/selectPzList').all((req, res, next) => {
  1489. var json = queryString(req.url);
  1490. getmysql(req, res, "selectPzList", json['cid'], json['s'], json['t']);
  1491. });
  1492. //评分
  1493. router.route('/scoreWork').all((req, res, next) => {
  1494. postmysql(req, res, "scoreWork");
  1495. });
  1496. //删除学生
  1497. router.route('/deleteStudent').all((req, res, next) => {
  1498. postmysql(req, res, "delete_student");
  1499. });
  1500. //查询学校底下的班级
  1501. router.route('/selectClassBySchool').all((req, res, next) => {
  1502. var json = queryString(req.url);
  1503. getmysql(req, res, "selectClassBySchool", json['oid']);
  1504. });
  1505. //查询学校底下的班级
  1506. router.route('/selectClassBySchoolSearch').all((req, res, next) => {
  1507. var json = queryString(req.url);
  1508. getmysql(req, res, "selectClassBySchoolSearch", json['oid'], json['cn']);
  1509. });
  1510. //查询组织底下的学校
  1511. router.route('/selectSchoolByOrg').all((req, res, next) => {
  1512. var json = queryString(req.url);
  1513. getmysql(req, res, "selectSchoolByOrg", json['org']);
  1514. });
  1515. //学生注册接口
  1516. router.route('/register_student').post(function(req, res, next) {
  1517. //mode的处理
  1518. if (req.body[0]) {
  1519. // 0 用户名 1 用户密码 2用户身份 3 第三方id(可有可无)
  1520. p = Object.values(req.body[0]); //获取用户密码
  1521. //没有第三方id的处理
  1522. // if (p.length < 4) {
  1523. // p.push("")
  1524. // }
  1525. p[1] = bcrypt.hashSync(p[1], bcrypt.genSaltSync(10));
  1526. //密码加密
  1527. // bcrypt.hash(p[1], 10, function (err, hash) {
  1528. // if (err) {
  1529. // return next(err);
  1530. // }
  1531. // p[1] = hash;
  1532. // });
  1533. //参数拼接,注册
  1534. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "register_student");
  1535. //返回注册用户数据
  1536. // mysql.usselect(p, function (ret) {
  1537. // res.end(ret);
  1538. // });
  1539. mysql.usselect(p, function(ret) {
  1540. res.end(JSON.stringify(ret));
  1541. });
  1542. }
  1543. });
  1544. //查询课程详情
  1545. router.route('/selectCourseDetail').all((req, res, next) => {
  1546. var json = queryString(req.url);
  1547. getmysql(req, res, "selectCourseDetail", json['courseId']);
  1548. });
  1549. //查询课程详情
  1550. router.route('/selectCourseDetail2').all((req, res, next) => {
  1551. var json = queryString(req.url);
  1552. getmysql(req, res, "selectCourseDetail2", json['courseId']);
  1553. });
  1554. //查询课程详情
  1555. router.route('/selectCourseDetail3').all((req, res, next) => {
  1556. var json = queryString(req.url);
  1557. getmysql(req, res, "selectCourseDetail3", json['courseId']);
  1558. });
  1559. //查询学校底下的所有赛事
  1560. router.route('/selectRaceByOid').all((req, res, next) => {
  1561. var json = queryString(req.url);
  1562. getmysql(req, res, "selectRaceByOid", json['sid']);
  1563. });
  1564. //修改作业学生名称
  1565. router.route('/updateCourseWorksName').all((req, res, next) => {
  1566. var json = queryString(req.url);
  1567. getmysql(req, res, "updateCourseWorksName", json['n'], json['cid']);
  1568. });
  1569. //查询课程详情
  1570. router.route('/selectStudentCourseDetail').all((req, res, next) => { //学生
  1571. var json = queryString(req.url);
  1572. getmysql(req, res, "selectStudentCourseDetail", json['courseId']);
  1573. });
  1574. //查询课程详情
  1575. router.route('/selectStudentCourseDetail3').all((req, res, next) => { //学生
  1576. var json = queryString(req.url);
  1577. getmysql(req, res, "selectStudentCourseDetail3", json['courseId']);
  1578. });
  1579. //查询课程详情
  1580. router.route('/selectStudentCourseDetail2').all((req, res, next) => { //学生
  1581. var json = queryString(req.url);
  1582. getmysql(req, res, "selectStudentCourseDetail2", json['courseId']);
  1583. });
  1584. //跳转阶段时,如果有课程就查询1返回,如果没有就插入
  1585. router.route('/addUserR').all((req, res, next) => {
  1586. var json = queryString(req.url);
  1587. getmysql(req, res, "insertUserR", json['uid'], json['cid']);
  1588. });
  1589. //新增学生端作业
  1590. router.route('/addWorks').all((req, res, next) => {
  1591. postmysql(req, res, "add_works");
  1592. });
  1593. //查询已提交作业
  1594. router.route('/selectWork').all((req, res, next) => {
  1595. var json = queryString(req.url);
  1596. getmysql(req, res, "selectWork", json['cid'], json['stage'], json['task'], json['uid']);
  1597. });
  1598. //查询作业详情
  1599. router.route('/selectWorksDetail').all((req, res, next) => {
  1600. var json = queryString(req.url);
  1601. getmysql(req, res, "selectWorksDetail", json['uid'], json['cid']);
  1602. });
  1603. //新增作业评分
  1604. router.route('/updateWorks').all((req, res, next) => {
  1605. var json = queryString(req.url);
  1606. getmysql(req, res, "updateWorks", json['rate'], json['tuid'], json['id']);
  1607. });
  1608. //新增素材信息
  1609. router.route('/addMtl').all((req, res, next) => {
  1610. var json = queryString(req.url);
  1611. getmysql(req, res, "add_mtl", json['cInfo'], json['t'], json['cBy']);
  1612. });
  1613. //根据类型查询素材信息
  1614. router.route('/selectMtl').all((req, res, next) => {
  1615. var json = queryString(req.url);
  1616. getmysql(req, res, "selectMtl", json['t'], json['page'], 10);
  1617. });
  1618. //根据类型查询素材信息
  1619. router.route('/selectMtl2').all((req, res, next) => {
  1620. var json = queryString(req.url);
  1621. getmysql(req, res, "selectMtl2", json['t'], json['uid'], json['page'], 10);
  1622. });
  1623. //学习中心
  1624. //新增学习资源信息
  1625. router.route('/addStuMtl').all((req, res, next) => {
  1626. var json = queryString(req.url);
  1627. getmysql(req, res, "addStuMtl", json['cInfo'], json['t'], json['cBy']);
  1628. });
  1629. //根据类型查询学习资料信息
  1630. router.route('/selectStuMtl').all((req, res, next) => {
  1631. var json = queryString(req.url);
  1632. getmysql(req, res, "selectStuMtl", json['t'], json['page'], 10);
  1633. });
  1634. //删除素材
  1635. router.route('/deleteStuM').all((req, res, next) => {
  1636. var json = queryString(req.url);
  1637. getmysql(req, res, "deleteStuM", json['id']);
  1638. });
  1639. //查询学生信息
  1640. router.route('/selectSDetail').all((req, res, next) => {
  1641. var json = queryString(req.url);
  1642. getmysql(req, res, "selectStudentDetail", json['uid']);
  1643. });
  1644. //查询个人课程
  1645. router.route('/selectMyCourse').all((req, res, next) => {
  1646. var json = queryString(req.url);
  1647. getmysql(req, res, "selectMyCourse", json['uid']);
  1648. });
  1649. //查询个人课程groupby课程id
  1650. router.route('/selectMyCourseBycid').all((req, res, next) => {
  1651. var json = queryString(req.url);
  1652. getmysql(req, res, "selectMyCourseBycid", json['uid']);
  1653. });
  1654. //查询所有课程
  1655. router.route('/selectAllCourse').all((req, res, next) => {
  1656. var json = queryString(req.url);
  1657. getmysql(req, res, "selectAllCourse", json['oid'], json['page'], 10);
  1658. });
  1659. //根据班级查询所有课程
  1660. router.route('/selectAllCourseByCid').all((req, res, next) => {
  1661. var json = queryString(req.url);
  1662. getmysql(req, res, "selectAllCourseByCid", json['oid'], json['cid'], json['page'], 10);
  1663. });
  1664. //根据分类查询所有课程
  1665. router.route('/selectTypeCourse').all((req, res, next) => {
  1666. var json = queryString(req.url);
  1667. 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);
  1668. });
  1669. //根据分类查询所有课程
  1670. router.route('/selectTypeCourse2').all((req, res, next) => {
  1671. var json = queryString(req.url);
  1672. 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'], json['pageSize']);
  1673. });
  1674. //根据分类查询所有课程
  1675. router.route('/selectTypeCourse2Mode').all((req, res, next) => {
  1676. var json = queryString(req.url);
  1677. getmysql(req, res, "selectTypeCourse2Mode", json['uid'], json['oid'], json['typea'], json['typeb'], json['typec'], json['typed'], json['typeE'], json['cu'], json['cn'], json['classid'], json['org']);
  1678. });
  1679. //根据分类查询所有课程
  1680. router.route('/selectTypeCourse2GM').all((req, res, next) => {
  1681. var json = queryString(req.url);
  1682. 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);
  1683. });
  1684. //根据分类查询所有课程
  1685. router.route('/selectCourseExamine').all((req, res, next) => {
  1686. var json = queryString(req.url);
  1687. getmysql(req, res, "selectCourseExamine", json['oid'], json['org'], json['cn'], json['page'], 10);
  1688. });
  1689. //根据分类查询所有课程
  1690. router.route('/selectTypeCourse3').all((req, res, next) => {
  1691. var json = queryString(req.url);
  1692. 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);
  1693. });
  1694. //审核课程
  1695. router.route('/examineCourse').all((req, res, next) => {
  1696. postmysql(req, res, "examineCourse");
  1697. });
  1698. //删除素材
  1699. router.route('/deleteM').all((req, res, next) => {
  1700. var json = queryString(req.url);
  1701. getmysql(req, res, "deleteM", json['id']);
  1702. });
  1703. //点击阶段时添加观看人数
  1704. router.route('/updateVc').all((req, res, next) => {
  1705. var json = queryString(req.url);
  1706. getmysql(req, res, "updateVc", json['cid']);
  1707. });
  1708. //删除课程
  1709. router.route('/deleteCourse').all((req, res, next) => {
  1710. var json = queryString(req.url);
  1711. getmysql(req, res, "deleteCourse", json['cid']);
  1712. });
  1713. //删除课程
  1714. router.route('/deleteStudentCourse').all((req, res, next) => {
  1715. var json = queryString(req.url);
  1716. getmysql(req, res, "deleteStudentCourse", json['cid']);
  1717. });
  1718. //复制课程
  1719. router.route('/copyCourse').all((req, res, next) => {
  1720. postmysql(req, res, "copyCourse");
  1721. });
  1722. //查看课程
  1723. router.route('/select_course_detail').all((req, res, next) => {
  1724. var json = queryString(req.url);
  1725. getmysql(req, res, "select_course_detail", json['cid']);
  1726. });
  1727. //查看课程
  1728. router.route('/select_student_course_detail').all((req, res, next) => { //学生
  1729. var json = queryString(req.url);
  1730. getmysql(req, res, "select_student_course_detail", json['cid']);
  1731. });
  1732. //查看课程
  1733. router.route('/select_student_course_detail2').all((req, res, next) => { //学生
  1734. var json = queryString(req.url);
  1735. getmysql(req, res, "select_student_course_detail2", json['cid']);
  1736. });
  1737. //查看课程
  1738. router.route('/getExportScourse').all((req, res, next) => { //学生
  1739. var json = queryString(req.url);
  1740. getmysql(req, res, "getExportScourse", json['cid']);
  1741. });
  1742. //模糊查找课程
  1743. // router.route('/searchCourse').all((req, res, next) => {
  1744. // var json = queryString(req.url);
  1745. // getmysql(req, res, "searchCourse", json['cu'], json['cn'], json['page'], 10);
  1746. // });
  1747. //创建调查问卷
  1748. router.route('/addAsk').all((req, res, next) => {
  1749. postmysql(req, res, "insert_ask");
  1750. });
  1751. //学生提交问卷
  1752. router.route('/addAskList').all((req, res, next) => {
  1753. postmysql(req, res, "insert_askList");
  1754. });
  1755. //根据课程id阶段id获取已提交的问卷
  1756. router.route('/getAskListByCidStage').all((req, res, next) => {
  1757. var json = queryString(req.url);
  1758. getmysql(req, res, "getAskListByCidStage", json['cid'], json['stage'], json['task']);
  1759. });
  1760. //获取调查问卷
  1761. router.route('/getAsk').all((req, res, next) => {
  1762. var json = queryString(req.url);
  1763. getmysql(req, res, "select_ask", json['uid'], json['page'], 10);
  1764. });
  1765. //删除问卷
  1766. router.route('/deleteAsk').all((req, res, next) => {
  1767. postmysql(req, res, "deleteAsk");
  1768. });
  1769. //问卷调查数据统计
  1770. router.route('/getAskListByAskid').all((req, res, next) => {
  1771. var json = queryString(req.url);
  1772. getmysql(req, res, "select_askListByAskid", json['aid']);
  1773. });
  1774. //删除学生提交问卷
  1775. router.route('/deleteAskList').all((req, res, next) => {
  1776. postmysql(req, res, "update_askList_delete");
  1777. });
  1778. //根据id获取调查问卷
  1779. router.route('/getAskList').all((req, res, next) => {
  1780. var json = queryString(req.url);
  1781. getmysql(req, res, "select_askList", json['uid'], json['page'], 10);
  1782. });
  1783. //查看便签列表
  1784. router.route('/selectNote').all((req, res, next) => {
  1785. var json = queryString(req.url);
  1786. getmysql(req, res, "selectNote", json['uid']);
  1787. });
  1788. //新增便签列表
  1789. router.route('/insertNote').all((req, res, next) => {
  1790. var json = queryString(req.url);
  1791. getmysql(req, res, "insertNote", json['uid'], json['c']);
  1792. });
  1793. //根据便签id修改便签内容
  1794. router.route('/updateNote').all((req, res, next) => {
  1795. var json = queryString(req.url);
  1796. getmysql(req, res, "updateNote", json['nid'], json['c']);
  1797. });
  1798. //删除便签
  1799. router.route('/deleteNote').all((req, res, next) => {
  1800. var json = queryString(req.url);
  1801. getmysql(req, res, "deleteNote", json['nid']);
  1802. });
  1803. //查询便签
  1804. router.route('/selectNoteContent').all((req, res, next) => {
  1805. var json = queryString(req.url);
  1806. getmysql(req, res, "selectNoteContent", json['cn']);
  1807. });
  1808. //修改用户信息
  1809. router.route('/updateUserByEdu').all((req, res, next) => {
  1810. postmysql(req, res, "updateUserByEdu");
  1811. });
  1812. //修改用户信息
  1813. router.route('/updateUserByEdu1').all((req, res, next) => {
  1814. postmysql(req, res, "updateUserByEdu1");
  1815. });
  1816. //修改用户信息
  1817. router.route('/updateUserByEduOid').all((req, res, next) => {
  1818. postmysql(req, res, "updateUserByEduOid");
  1819. });
  1820. //修改学生信息
  1821. router.route('/updateStudentInfo').all((req, res, next) => {
  1822. postmysql(req, res, "updateStudentInfo");
  1823. });
  1824. //教师端data修改pbl用户信息
  1825. router.route('/updatePblMessage').all((req, res, next) => {
  1826. postmysql2(req, res, "updatePblMessage");
  1827. });
  1828. //登录次数
  1829. router.route('/addLoginOperation').all((req, res, next) => {
  1830. postmysql2(req, res, "addLoginOperation");
  1831. });
  1832. //当日登录时间
  1833. router.route('/addOperationTime').all((req, res, next) => {
  1834. postmysql2(req, res, "addOperationTime");
  1835. });
  1836. //课程学习时间
  1837. router.route('/addOperationTime2').all((req, res, next) => {
  1838. postmysql(req, res, "addOperationTime");
  1839. });
  1840. //当日登录时间
  1841. router.route('/addOperationTimeT').all((req, res, next) => {
  1842. postmysql2(req, res, "addOperationTime2");
  1843. });
  1844. //课程学习时间
  1845. router.route('/addOperationTimeT2').all((req, res, next) => {
  1846. postmysql(req, res, "addOperationTime2");
  1847. });
  1848. router.route('/updatePblMessage2').all((req, res, next) => {
  1849. postmysql(req, res, "updatePblMessage");
  1850. });
  1851. router.route('/updateRaceUser').all((req, res, next) => {
  1852. postmysql(req, res, "updateRaceUser");
  1853. });
  1854. //查询用户信息
  1855. router.route('/selectUser').all((req, res, next) => {
  1856. var json = queryString(req.url);
  1857. getmysql(req, res, "selectUser", json['userid']);
  1858. });
  1859. //查询分类及所有子分类
  1860. router.route('/selectAllType').all((req, res, next) => {
  1861. var json = queryString(req.url);
  1862. getmysql(req, res, "selectAllType", json['org'], json['oid']);
  1863. });
  1864. //查询分类及所有子分类
  1865. router.route('/selectAllTypeS').all((req, res, next) => {
  1866. var json = queryString(req.url);
  1867. getmysql(req, res, "selectAllTypeS", json['org'], json['oid']);
  1868. });
  1869. //查询分类及子分类
  1870. router.route('/selectType').all((req, res, next) => {
  1871. var json = queryString(req.url);
  1872. getmysql(req, res, "selectType", );
  1873. });
  1874. //查询分类及子分类
  1875. router.route('/selectStudentType').all((req, res, next) => {
  1876. var json = queryString(req.url);
  1877. getmysql(req, res, "selectStudentType", );
  1878. });
  1879. //查询赛事分类及子分类
  1880. router.route('/selectMatType').all((req, res, next) => {
  1881. var json = queryString(req.url);
  1882. getmysql(req, res, "selectMatType", );
  1883. });
  1884. //根据学校查询分类
  1885. router.route('/selectPtype').all((req, res, next) => {
  1886. var json = queryString(req.url);
  1887. getmysql(req, res, "selectPtype", json["page"], 10);
  1888. });
  1889. //根据学校查询学生项目分类
  1890. router.route('/selectSPtype').all((req, res, next) => {
  1891. var json = queryString(req.url);
  1892. getmysql(req, res, "selectSPtype", json["page"], 10);
  1893. });
  1894. //根据学校查询分类1
  1895. router.route('/selectPtype1').all((req, res, next) => {
  1896. var json = queryString(req.url);
  1897. getmysql(req, res, "selectPtype1", json["oid"], json["page"], 10);
  1898. });
  1899. //添加分类
  1900. router.route('/addPtype').all((req, res, next) => {
  1901. var json = queryString(req.url);
  1902. getmysql(req, res, "addPtype", json["n"], json["uid"], json["oid"]);
  1903. });
  1904. //修改分类
  1905. router.route('/updatePtype').all((req, res, next) => {
  1906. var json = queryString(req.url);
  1907. getmysql(req, res, "updatePtype", json["n"], json["tid"]);
  1908. });
  1909. //修改学生项目分类
  1910. router.route('/updateSPtype').all((req, res, next) => {
  1911. var json = queryString(req.url);
  1912. getmysql(req, res, "updateSPtype", json["n"], json["tid"]);
  1913. });
  1914. //删除分类
  1915. router.route('/deletePtype').all((req, res, next) => {
  1916. var json = queryString(req.url);
  1917. getmysql(req, res, "deletePtype", json["tid"]);
  1918. });
  1919. //删除学生项目分类
  1920. router.route('/deleteSPtype').all((req, res, next) => {
  1921. var json = queryString(req.url);
  1922. getmysql(req, res, "deleteSPtype", json["tid"]);
  1923. });
  1924. //查询子分类列表
  1925. router.route('/selectStype').all((req, res, next) => {
  1926. var json = queryString(req.url);
  1927. getmysql(req, res, "selectStype", json["pid"], json["oid"], json["page"], 10);
  1928. });
  1929. //查询学生项目子分类列表
  1930. router.route('/selectSStype').all((req, res, next) => {
  1931. var json = queryString(req.url);
  1932. getmysql(req, res, "selectSStype", json["pid"], json["oid"], json["page"], 10);
  1933. });
  1934. //添加子分类
  1935. router.route('/addStype').all((req, res, next) => {
  1936. var json = queryString(req.url);
  1937. getmysql(req, res, "addStype", json["pid"], json["n"], json["uid"], json["oid"]);
  1938. });
  1939. //添加学生项目子分类
  1940. router.route('/addSStype').all((req, res, next) => {
  1941. var json = queryString(req.url);
  1942. getmysql(req, res, "addSStype", json["pid"], json["n"], json["uid"], json["oid"]);
  1943. });
  1944. //根据学校查询工作分类
  1945. router.route('/selectStudioPtype').all((req, res, next) => {
  1946. var json = queryString(req.url);
  1947. getmysql(req, res, "selectStudioPtype", json["page"], 10);
  1948. });
  1949. //查询工作室项目子分类列表
  1950. router.route('/selectStudioStype').all((req, res, next) => {
  1951. var json = queryString(req.url);
  1952. getmysql(req, res, "selectStudioStype", json["pid"], json["oid"], json["page"], 10);
  1953. });
  1954. //添加工作室项目子分类
  1955. router.route('/addStudioStype').all((req, res, next) => {
  1956. var json = queryString(req.url);
  1957. getmysql(req, res, "addStudioStype", json["pid"], json["n"], json["uid"], json["oid"]);
  1958. });
  1959. //修改工作项目分类
  1960. router.route('/updateStudioPtype').all((req, res, next) => {
  1961. var json = queryString(req.url);
  1962. getmysql(req, res, "updateStudioPtype", json["n"], json["tid"]);
  1963. });
  1964. //删除工作项目分类
  1965. router.route('/deleteStudioPtype').all((req, res, next) => {
  1966. var json = queryString(req.url);
  1967. getmysql(req, res, "deleteStudioPtype", json["tid"]);
  1968. });
  1969. //查看本校所有学生(分页)
  1970. router.route('/selectAllStudent').all((req, res, next) => {
  1971. var json = queryString(req.url);
  1972. getmysql(req, res, "selectAllStudent", json["oid"], json["cn"], json["cid"], json["page"], 10);
  1973. });
  1974. //根据学校id查询子分类
  1975. router.route('/selectTypeByOid').all((req, res, next) => {
  1976. var json = queryString(req.url);
  1977. getmysql(req, res, "selectTypeByOid", json["oid"]);
  1978. });
  1979. //根据学校id查询子分类
  1980. router.route('/selectTypeByOrg').all((req, res, next) => {
  1981. var json = queryString(req.url);
  1982. getmysql(req, res, "selectTypeByOid", json["oid"]);
  1983. });
  1984. //根据组织id查询子分类
  1985. router.route('/selectStudentTypeByOid').all((req, res, next) => {
  1986. var json = queryString(req.url);
  1987. getmysql(req, res, "selectStudentTypeByOid", json["oid"]);
  1988. });
  1989. //更加父id查询分类
  1990. router.route('/selectTypeByPid').all((req, res, next) => {
  1991. var json = queryString(req.url);
  1992. getmysql(req, res, "selectTypeByPid", json['pid']);
  1993. });
  1994. //点击工具计数
  1995. router.route('/insertToolsCount').all((req, res, next) => {
  1996. var json = queryString(req.url);
  1997. getmysql(req, res, "insertToolsCount", json['cid'], json['chid'], json['uid'], json['tid'], json['count']);
  1998. });
  1999. //修改工具次数
  2000. router.route('/updateToolsCount').all((req, res, next) => {
  2001. var json = queryString(req.url);
  2002. getmysql(req, res, "updateToolsCount", json['cid'], json['chid'], json['uid'], json['tid'], json['count']);
  2003. });
  2004. //查询工具次数
  2005. router.route('/selectToolsCount').all((req, res, next) => {
  2006. var json = queryString(req.url);
  2007. getmysql(req, res, "selectToolsCount", json['cid'], json['chid'], json['uid']);
  2008. });
  2009. //导出学生
  2010. router.route('/selectUserBySchool').all((req, res, next) => {
  2011. var json = queryString(req.url);
  2012. getmysql(req, res, "selectUserBySchool", json['oid']);
  2013. });
  2014. //上传学生作业
  2015. router.route('/insertSWork').all((req, res, next) => {
  2016. var json = queryString(req.url);
  2017. getmysql(req, res, "insertSWork", json['uid'], json['cid'], json['p'], json['t'], json['upload']);
  2018. });
  2019. //查询学生作业
  2020. router.route('/selectSWork').all((req, res, next) => {
  2021. var json = queryString(req.url);
  2022. getmysql(req, res, "selectSWork", json['uid'], json['cid'], json['p'], json['type']);
  2023. });
  2024. //课程进展数据
  2025. router.route('/selectCase').all((req, res, next) => {
  2026. var json = queryString(req.url);
  2027. getmysql(req, res, "selectCase", json['org']);
  2028. });
  2029. //课程进展数据
  2030. router.route('/selectCase2').all((req, res, next) => {
  2031. var json = queryString(req.url);
  2032. getmysql(req, res, "selectCase2", json['org']);
  2033. });
  2034. //课程进展数据
  2035. router.route('/selectCase3').all((req, res, next) => {
  2036. var json = queryString(req.url);
  2037. getmysql(req, res, "selectCase3", json['org'], json['oid'], json['page'], json['pageSize']);
  2038. });
  2039. //项目进展数据
  2040. router.route('/selectCaseS').all((req, res, next) => {
  2041. var json = queryString(req.url);
  2042. getmysql(req, res, "selectCaseS", json['org'], json['oid']);
  2043. });
  2044. //项目进展数据
  2045. router.route('/selectCaseS2').all((req, res, next) => {
  2046. var json = queryString(req.url);
  2047. getmysql(req, res, "selectCaseS2", json['org'], json['oid'], json['type'], json['page'], json['pageSize']);
  2048. });
  2049. //查询赛事项目列表
  2050. router.route('/selectRaceList').all((req, res, next) => {
  2051. var json = queryString(req.url);
  2052. getmysql(req, res, "selectRaceList", json['uid'], json['t']);
  2053. });
  2054. //修改赛事状态
  2055. router.route('/updateRaceState').all((req, res, next) => {
  2056. var json = queryString(req.url);
  2057. getmysql(req, res, "updateRaceState", json['id'], json['s']);
  2058. });
  2059. //查询赛事项目详情
  2060. router.route('/selectRaceDetail').all((req, res, next) => {
  2061. var json = queryString(req.url);
  2062. getmysql(req, res, "selectRaceDetail", json['id']);
  2063. });
  2064. //race 查询学校
  2065. router.route('/getSchool').all((req, res, next) => {
  2066. var json = queryString(req.url);
  2067. getmysql(req, res, "getSchool", json['n']);
  2068. });
  2069. //查询我的学习报告
  2070. router.route('/selectMrEva').all((req, res, next) => {
  2071. var json = queryString(req.url);
  2072. getmysql(req, res, "selectMrEva", json["uid"], json["oid"], json["cid"]);
  2073. });
  2074. //查询行为数据库
  2075. router.route('/selectModelList').all((req, res, next) => {
  2076. var json = queryString(req.url);
  2077. getmysql(req, res, "selectModelList", json["cn"], json["oid"]);
  2078. });
  2079. //lsc
  2080. //admin 查询学校
  2081. router.route('/getSchoolAdmin').all((req, res, next) => {
  2082. var json = queryString(req.url);
  2083. getmysql(req, res, "select_school", json['page'], 10);
  2084. });
  2085. //admin 添加学校
  2086. router.route('/addSchoolAdmin').all((req, res, next) => {
  2087. postmysql(req, res, "add_school");
  2088. });
  2089. //组织添加学校
  2090. router.route('/addSchoolOrg').all((req, res, next) => {
  2091. postmysql(req, res, "addSchoolOrg");
  2092. });
  2093. //教师端组织添加学校
  2094. router.route('/insertSchoolByOrg').all((req, res, next) => {
  2095. postmysql(req, res, "insertSchoolByOrg");
  2096. });
  2097. //admin 删除学校
  2098. router.route('/deleteSchoolAdmin').all((req, res, next) => {
  2099. postmysql(req, res, "delete_school");
  2100. });
  2101. //admin 查询班级
  2102. router.route('/getClassAdmin').all((req, res, next) => {
  2103. var json = queryString(req.url);
  2104. getmysql(req, res, "select_classAdmin", json['cn'], json['page'], 10);
  2105. });
  2106. //admin 添加班级
  2107. router.route('/addClassAdmin').all((req, res, next) => {
  2108. postmysql(req, res, "add_classAdmin");
  2109. });
  2110. //admin 查询班级是否重复
  2111. router.route('/getClassRepeat').all((req, res, next) => {
  2112. var json = queryString(req.url);
  2113. getmysql(req, res, "select_classRepeatAdmin", json['n'], json['oid']);
  2114. });
  2115. //查询未在此班级的学生
  2116. router.route('/getClassStudent').all((req, res, next) => {
  2117. var json = queryString(req.url);
  2118. getmysql(req, res, "getClassStudent", json['cid'], json['oid'], json['cn'], json['page'], json['num']);
  2119. });
  2120. //添加学生到班级
  2121. router.route('/addClassStudent').all((req, res, next) => {
  2122. let cid = req.body[0].cid
  2123. let student = JSON.parse(req.body[0].student)
  2124. for (let i = 0; i < student.length; i++) {
  2125. let _userdata = [student[i]]
  2126. _userdata.unshift(_mysqlLabor[0], _mysqlLabor[1], "selectUser");
  2127. mysql.usselect(_userdata, function(ret) {
  2128. let classid = ret[0][0].classid
  2129. if (classid.indexOf(cid) == -1) {
  2130. classid = classid.split(",")
  2131. classid.push(cid)
  2132. let _userdata2 = [student[i], classid.join(",")]
  2133. _userdata2.unshift(_mysqlLabor[0], _mysqlLabor[1], "updateStudentClass");
  2134. mysql.usselect(_userdata2, function(ret) {
  2135. if (i == student.length - 1) {
  2136. res.end(JSON.stringify({ success: 1 }));
  2137. }
  2138. });
  2139. }
  2140. });
  2141. }
  2142. });
  2143. //移除学生此班级
  2144. router.route('/deleteClassStudent').all((req, res, next) => {
  2145. let cid = req.body[0].cid
  2146. let student = req.body[0].uid
  2147. let _userdata = [student]
  2148. _userdata.unshift(_mysqlLabor[0], _mysqlLabor[1], "selectUser");
  2149. mysql.usselect(_userdata, function(ret) {
  2150. let classid = ret[0][0].classid
  2151. if (classid.indexOf(cid) != -1) {
  2152. classid = classid.split(",")
  2153. classid.splice(classid.indexOf(cid), 1)
  2154. let _userdata2 = [student, classid.join(",")]
  2155. _userdata2.unshift(_mysqlLabor[0], _mysqlLabor[1], "updateStudentClass");
  2156. mysql.usselect(_userdata2, function(ret) {
  2157. res.end(JSON.stringify({ success: 1 }));
  2158. });
  2159. }
  2160. });
  2161. });
  2162. //admin 发布通知
  2163. router.route('/addNews').all((req, res, next) => {
  2164. postmysql(req, res, "add_news");
  2165. });
  2166. //admin 删除通知
  2167. router.route('/deleteNews').all((req, res, next) => {
  2168. postmysql(req, res, "delete_news");
  2169. });
  2170. //admin 添加banner
  2171. router.route('/addBanner').all((req, res, next) => {
  2172. postmysql(req, res, "add_banner");
  2173. });
  2174. //admin 添加banner
  2175. router.route('/deleteBanner').all((req, res, next) => {
  2176. postmysql(req, res, "delete_banner");
  2177. });
  2178. //admin 查询banner
  2179. router.route('/getBanner').all((req, res, next) => {
  2180. var json = queryString(req.url);
  2181. getmysql(req, res, "select_banner");
  2182. });
  2183. //根据学校查询banner
  2184. router.route('/selectBannerByOid').all((req, res, next) => {
  2185. var json = queryString(req.url);
  2186. getmysql(req, res, "selectBannerByOid", json["oid"]);
  2187. });
  2188. //admin 查询banner
  2189. router.route('/getBannerS').all((req, res, next) => {
  2190. var json = queryString(req.url);
  2191. getmysql(req, res, "getBannerS");
  2192. });
  2193. //根据学校查询banner
  2194. router.route('/selectBannerByOidS').all((req, res, next) => {
  2195. var json = queryString(req.url);
  2196. getmysql(req, res, "selectBannerByOidS", json["oid"]);
  2197. });
  2198. //admin 查询课程getSearchCourse
  2199. router.route('/getSearchCourse').all((req, res, next) => {
  2200. var json = queryString(req.url);
  2201. getmysql(req, res, "selectAll_courseSearch", json['t']);
  2202. });
  2203. //根据学校查询课程
  2204. router.route('/getSearchCourseByoid').all((req, res, next) => {
  2205. var json = queryString(req.url);
  2206. getmysql(req, res, "selectAll_courseByOid", json['t'], json['oid']);
  2207. });
  2208. //admin 查询所有课程专区
  2209. router.route('/getZone').all((req, res, next) => {
  2210. getmysql(req, res, "select_zone");
  2211. });
  2212. //admin 添加课程专区
  2213. router.route('/addZone').all((req, res, next) => {
  2214. postmysql(req, res, "insert_classZone");
  2215. });
  2216. //评审
  2217. router.route('/reviewCourse').all((req, res, next) => {
  2218. postmysql(req, res, "reviewCourse");
  2219. });
  2220. //查询评审
  2221. router.route('/getReview').all((req, res, next) => {
  2222. var json = queryString(req.url);
  2223. getmysql(req, res, "getReview", json['cid']);
  2224. });
  2225. //查询所有课程专区下的课程
  2226. router.route('/getZoneClass').all((req, res, next) => {
  2227. var json = queryString(req.url);
  2228. getmysql(req, res, "select_zoneClass", json['bid'], json['oid'], json['page'], 10);
  2229. });
  2230. //查询所有课程专区下的课程
  2231. router.route('/getZoneClass').all((req, res, next) => {
  2232. var json = queryString(req.url);
  2233. getmysql(req, res, "select_zoneClass", json['bid'], json['oid'], json['page'], 10);
  2234. });
  2235. //查询所有课程专区下的课程
  2236. router.route('/getZoneClassStudent').all((req, res, next) => {
  2237. var json = queryString(req.url);
  2238. getmysql(req, res, "select_zoneClass", json['bid'], json['oid'], json['page'], 20);
  2239. });
  2240. //admin 后台查看专区下课程的数量
  2241. router.route('/getZoneClassNum').all((req, res, next) => {
  2242. var json = queryString(req.url);
  2243. getmysql(req, res, "select_zoneClassNum", json['bid']);
  2244. });
  2245. //admin 后台添加课程专区时查看课程是否在此专区重复
  2246. router.route('/getZoneClassRepeat').all((req, res, next) => {
  2247. var json = queryString(req.url);
  2248. getmysql(req, res, "select_zoneClassRepeat", json['pid'], json['cid']);
  2249. });
  2250. //把课程添加进专区
  2251. router.route('/addZoneCourse').all((req, res, next) => {
  2252. postmysql(req, res, "insert_app");
  2253. });
  2254. //admin 删除课程专区底下的课程
  2255. router.route('/deleteZoneCourse').all((req, res, next) => {
  2256. postmysql(req, res, "delete_app");
  2257. });
  2258. //admin 删除班级
  2259. router.route('/deleteZone').all((req, res, next) => {
  2260. postmysql(req, res, "delete_zone");
  2261. });
  2262. //admin 后台专区上移下移
  2263. router.route('/zoneRank').all((req, res, next) => {
  2264. postmysql(req, res, "update_classRank");
  2265. });
  2266. //admin 添加模板文档
  2267. router.route('/addTemplateAdmin').all((req, res, next) => {
  2268. postmysql(req, res, "add_template");
  2269. });
  2270. //admin 添加模板文档
  2271. router.route('/deleteTemplateAdmin').all((req, res, next) => {
  2272. postmysql(req, res, "delete_template");
  2273. });
  2274. //admin 查询模板文档
  2275. router.route('/getTemplateAdmin').all((req, res, next) => {
  2276. var json = queryString(req.url);
  2277. getmysql(req, res, "select_template", json['page'], 10);
  2278. });
  2279. //查询上传作业
  2280. router.route('/getCourseWorks').all((req, res, next) => {
  2281. var json = queryString(req.url); //cid 课程id,page 页数
  2282. getmysql(req, res, "select_courseWorks", json['cid'], json['stage'], json['task'], json['page'], 10);
  2283. });
  2284. //查询上传作业
  2285. router.route('/getCourseWorks2').all((req, res, next) => {
  2286. var json = queryString(req.url); //cid 课程id,page 页数
  2287. getmysql(req, res, "select_courseWorks2", json['cid'], json['uname'], json['stage'], json['task'], json['page'], 10);
  2288. });
  2289. //查询上传作业
  2290. router.route('/getCourseWorks3').all((req, res, next) => {
  2291. var json = queryString(req.url); //cid 课程id,page 页数
  2292. getmysql(req, res, "select_courseWorks3", json['cid'], json['uname'], json['stage'], json['task'], json['page'], 10);
  2293. });
  2294. //查询所有学生上传作业
  2295. router.route('/getCourseWorks4').all((req, res, next) => {
  2296. var json = queryString(req.url); //cid 课程id,page 页数
  2297. getmysql(req, res, "select_courseWorks4", json['cid'], json['uname'], json['stage'], json['task']);
  2298. });
  2299. //查询学生课程作业
  2300. router.route('/selectStudentCourseWorks').all((req, res, next) => {
  2301. var json = queryString(req.url); //cid 课程id,page 页数
  2302. getmysql(req, res, "selectStudentCourseWorks", json['uid'], json['cid'], json['stage'], json['task'], json['page'], 10);
  2303. });
  2304. //查询报告数据
  2305. router.route('/getCourseWorksReport').all((req, res, next) => {
  2306. var json = queryString(req.url); //cid 课程id,page 页数
  2307. getmysql(req, res, "getCourseWorksReport", json['cid']);
  2308. });
  2309. //查询多个课程报告数据
  2310. router.route('/getCourseWorksReportMore').all((req, res, next) => {
  2311. var json = queryString(req.url); //cid 课程id,page 页数
  2312. getmysql(req, res, "getCourseWorksReportMore", json['cid']);
  2313. });
  2314. //查询学生课程报告数据
  2315. router.route('/getStudentCourseWorksReport').all((req, res, next) => {
  2316. var json = queryString(req.url); //cid 课程id,page 页数
  2317. getmysql(req, res, "getStudentCourseWorksReport", json['uid']);
  2318. });
  2319. //admin 添加项目模板文档
  2320. router.route('/addCourseTemplateAdmin').all((req, res, next) => {
  2321. postmysql(req, res, "add_courseTemplate");
  2322. });
  2323. //admin 添加项目模板文档
  2324. router.route('/deleteCourseTemplateAdmin').all((req, res, next) => {
  2325. postmysql(req, res, "delete_courseTemplate");
  2326. });
  2327. //admin 查询项目模板文档
  2328. router.route('/getCourseTemplateAdmin').all((req, res, next) => {
  2329. var json = queryString(req.url);
  2330. getmysql(req, res, "select_courseTemplate", json['page'], 10);
  2331. });
  2332. //teacher 查询项目模板
  2333. router.route('/getCourseTemplateT').all((req, res, next) => {
  2334. var json = queryString(req.url);
  2335. getmysql(req, res, "select_courseTemplateT");
  2336. });
  2337. //teacher 查询项目模板
  2338. router.route('/getCourseTemplateTByOid').all((req, res, next) => {
  2339. var json = queryString(req.url);
  2340. getmysql(req, res, "getCourseTemplateTByOid", json['oid']);
  2341. });
  2342. //teacher 查询项目模板
  2343. router.route('/getCourseTemplateTs').all((req, res, next) => {
  2344. var json = queryString(req.url);
  2345. getmysql(req, res, "getCourseTemplateTs", json['oid']);
  2346. });
  2347. //teacher 查询项目模板
  2348. router.route('/getCourseTemplateTStudio').all((req, res, next) => {
  2349. var json = queryString(req.url);
  2350. getmysql(req, res, "getCourseTemplateTStudio", json['oid']);
  2351. });
  2352. //admin 查询课程
  2353. router.route('/getCourseAdmin').all((req, res, next) => {
  2354. var json = queryString(req.url);
  2355. getmysql(req, res, "select_courseAdmin", json['cn'], json['page'], 10);
  2356. });
  2357. //admin 查询模板文档
  2358. router.route('/deleteCourseAdmin').all((req, res, next) => {
  2359. postmysql(req, res, "delete_courseAdmin");
  2360. });
  2361. //设置分组
  2362. router.route('/setCourseGroup').all((req, res, next) => {
  2363. postmysql(req, res, "setCourseGroup");
  2364. });
  2365. //删除分组
  2366. router.route('/deleteCourseGroup').all((req, res, next) => {
  2367. postmysql(req, res, "deleteCourseGroup");
  2368. });
  2369. //获取分组
  2370. router.route('/getCourseGroup').all((req, res, next) => {
  2371. var json = queryString(req.url);
  2372. getmysql(req, res, "getCourseGroup", json["cid"], json["classid"]);
  2373. });
  2374. //加入分组
  2375. router.route('/joinCourseGroup').all((req, res, next) => {
  2376. postmysql(req, res, "joinCourseGroup");
  2377. });
  2378. //退出分组
  2379. router.route('/exitCourseGroup').all((req, res, next) => {
  2380. postmysql(req, res, "exitCourseGroup");
  2381. });
  2382. //加入分组
  2383. router.route('/joinGroup').all((req, res, next) => {
  2384. postmysql(req, res, "joinGroup");
  2385. });
  2386. //退出分组
  2387. router.route('/exitGroup').all((req, res, next) => {
  2388. postmysql(req, res, "exitGroup");
  2389. });
  2390. //查看分组
  2391. router.route('/selectGroup').all((req, res, next) => {
  2392. postmysql(req, res, "selectGroup");
  2393. });
  2394. //查询ppt在哪页
  2395. router.route('/selectPptPage').all((req, res, next) => {
  2396. var json = queryString(req.url);
  2397. getmysql(req, res, "selectPptPage", json['id']);
  2398. });
  2399. //修改ppt页码
  2400. router.route('/updatePptPage').all((req, res, next) => {
  2401. postmysql(req, res, "updatePptPage");
  2402. });
  2403. //修改ppt操作
  2404. router.route('/updatePPTHandle').all((req, res, next) => {
  2405. postmysql(req, res, "updatePPTHandle");
  2406. });
  2407. //查询实时课堂
  2408. router.route('/getRealTimeClass').all((req, res, next) => {
  2409. var json = queryString(req.url);
  2410. getmysql(req, res, "getRealTimeClass", json["cn"], json["uid"], json["page"], 10);
  2411. });
  2412. //查询实时课堂学生
  2413. router.route('/getRealTimeClassStu').all((req, res, next) => {
  2414. var json = queryString(req.url);
  2415. getmysql(req, res, "getRealTimeClassStu", json["oid"], json["cid"], json["page"], 10);
  2416. });
  2417. //查询实时课堂学生
  2418. router.route('/getRealTimeClassById').all((req, res, next) => {
  2419. var json = queryString(req.url);
  2420. getmysql(req, res, "getRealTimeClassById", json["id"]);
  2421. });
  2422. //根据区级管理者查询案例
  2423. router.route('/selectAnliList').all((req, res, next) => {
  2424. var json = queryString(req.url);
  2425. getmysql(req, res, "selectAnliList", json["typea"], json["typeb"], json["typec"], json["typed"], json["typeE"], json["cn"], json["cid"], json["page"], 10);
  2426. });
  2427. //根据市级管理者查询案例
  2428. router.route('/selectAnliList1').all((req, res, next) => {
  2429. var json = queryString(req.url);
  2430. getmysql(req, res, "selectAnliList1", json["typea"], json["typeb"], json["typec"], json["typed"], json["typeE"], json["cn"], json["cid"], json["page"], 10);
  2431. });
  2432. //根据省级级管理者查询案例
  2433. router.route('/selectAnliList2').all((req, res, next) => {
  2434. var json = queryString(req.url);
  2435. getmysql(req, res, "selectAnliList2", json["typea"], json["typeb"], json["typec"], json["typed"], json["typeE"], json["cn"], json["cid"], json["page"], 10);
  2436. });
  2437. //删除案例
  2438. router.route('/deleteAnli').all((req, res, next) => {
  2439. var json = queryString(req.url);
  2440. getmysql(req, res, "deleteAnli", json["id"]);
  2441. });
  2442. //根据区县管理者查询评分
  2443. router.route('/selectPoint').all((req, res, next) => {
  2444. var json = queryString(req.url);
  2445. getmysql(req, res, "selectPoint", json["typea"], json["typeb"], json["typec"], json["typed"], json["typeE"], json["cn"], json["cid"], json["page"], 10);
  2446. });
  2447. //根据市级管理者查询评分
  2448. router.route('/selectPoint1').all((req, res, next) => {
  2449. var json = queryString(req.url);
  2450. getmysql(req, res, "selectPoint1", json["typea"], json["typeb"], json["typec"], json["typed"], json["typeE"], json["cn"], json["cid"], json["page"], 10);
  2451. });
  2452. //查询分配案例
  2453. router.route('/selectCaseUser').all((req, res, next) => {
  2454. var json = queryString(req.url);
  2455. getmysql(req, res, "select_case", json["uid"]);
  2456. });
  2457. //根据用户id,课程id,阶段,任务,工具去查询协同
  2458. router.route('/selectWord').all((req, res, next) => {
  2459. var json = queryString(req.url);
  2460. getmysql(req, res, "selectWord", json["uid"], json["cid"], json["s"], json["task"], json["t"]);
  2461. });
  2462. //根据用户id,课程id,阶段,任务,工具去查询协同
  2463. router.route('/selectWord2').all((req, res, next) => {
  2464. var json = queryString(req.url);
  2465. getmysql(req, res, "selectWord2", json["uid"], json["cid"], json["s"], json["task"], json["t"], json["type"]);
  2466. });
  2467. //根据用户id,课程id,阶段,任务,工具去查询协同
  2468. router.route('/selectWords').all((req, res, next) => {
  2469. var json = queryString(req.url);
  2470. getmysql(req, res, "selectWords", json["uid"], json["cid"], json["s"], json["task"], json["t"], json["type"]);
  2471. });
  2472. //根据用户id,课程id,阶段,任务,工具去查询协同
  2473. router.route('/selectWordsY').all((req, res, next) => {
  2474. var json = queryString(req.url);
  2475. getmysql(req, res, "selectWordsY", json["uid"], json["cid"], json["s"], json["task"], json["t"], json["type"]);
  2476. });
  2477. //新增协同内容
  2478. router.route('/insertWord2y').all((req, res, next) => {
  2479. var json = queryString(req.url);
  2480. // getmysql(req, res, "insertWord2y", json["uid"], json["cid"], json["s"], json["task"], json["t"], json["text"], json["type"]);
  2481. postmysql3(req, res, "insertWord2y");
  2482. });
  2483. //新增协同内容
  2484. router.route('/insertWord').all((req, res, next) => {
  2485. var json = queryString(req.url);
  2486. getmysql(req, res, "insertWord", json["uid"], json["cid"], json["s"], json["task"], json["t"], json["text"]);
  2487. });
  2488. //分配案例
  2489. router.route('/insertCase').all((req, res, next) => {
  2490. if (req.body[0]) {
  2491. p = [req.body[0].uid, req.body[0].box];
  2492. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "insertCase"); //執行存儲過程
  2493. mysql.usselect(p, function(ret) {
  2494. res.end(JSON.stringify({ success: 1 }));
  2495. });
  2496. }
  2497. });
  2498. //新增评分
  2499. router.route('/addScore').all((req, res, next) => {
  2500. var json = queryString(req.url);
  2501. getmysql(req, res, "addScore", json["rid"], json["suser"], json["s"]);
  2502. });
  2503. //查询评分
  2504. router.route('/selectScore').all((req, res, next) => {
  2505. var json = queryString(req.url);
  2506. getmysql(req, res, "selectScore", json["rid"]);
  2507. });
  2508. //赛事推荐
  2509. router.route('/updateRaceRec').all((req, res, next) => {
  2510. var json = queryString(req.url);
  2511. getmysql(req, res, "updateRaceRec", json["id"], json["rec"]);
  2512. });
  2513. //查询数据报告学生报告列表
  2514. router.route('/selectSr').all((req, res, next) => {
  2515. var json = queryString(req.url);
  2516. getmysql(req, res, "selectSr", json['cu'], json['cn'], json['oid'], json['page'], 10);
  2517. });
  2518. //查询数据报告班级报告列表
  2519. router.route('/selectCr').all((req, res, next) => {
  2520. var json = queryString(req.url);
  2521. getmysql(req, res, "selectCr", json['cu'], json['cn'], json['oid'], json['page'], 10);
  2522. });
  2523. //查询数据报告查看班级报告底下学生列表
  2524. router.route('/selectCStudent').all((req, res, next) => {
  2525. var json = queryString(req.url);
  2526. getmysql(req, res, "selectCStudent", json['cid'], json['courseid']);
  2527. });
  2528. //查询数据报告课程报告列表
  2529. router.route('/selectCourseR').all((req, res, next) => {
  2530. var json = queryString(req.url);
  2531. getmysql(req, res, "selectCourseR", json['cu'], json['cn'], json['cl'], json['oid'], json['page'], 10);
  2532. });
  2533. //根据学校id查询学校底下有评价的课程
  2534. router.route('/selectCourseByOid').all((req, res, next) => {
  2535. var json = queryString(req.url);
  2536. getmysql(req, res, "selectCourseByOid", json['oid']);
  2537. });
  2538. //根据目标id和班级id查询底下有作业的课程
  2539. router.route('/selectEvaCourse').all((req, res, next) => {
  2540. var json = queryString(req.url);
  2541. getmysql(req, res, "selectEvaCourse", json['eid'], json['cid']);
  2542. });
  2543. //teacher 查询模板
  2544. router.route('/getTemplateT').all((req, res, next) => {
  2545. var json = queryString(req.url);
  2546. getmysql(req, res, "select_templateT");
  2547. });
  2548. //思维网格 创建房间
  2549. router.route('/insertRoom').all((req, res, next) => {
  2550. postmysql(req, res, "insertRoom");
  2551. });
  2552. //删除作业阶段任务工具
  2553. router.route('/deleteStudentToolSTT').all((req, res, next) => {
  2554. postmysql(req, res, "deleteStudentToolSTT");
  2555. });
  2556. //删除作业阶段任务
  2557. router.route('/deleteStudentToolST').all((req, res, next) => {
  2558. postmysql(req, res, "deleteStudentToolST");
  2559. });
  2560. //删除作业阶段
  2561. router.route('/deleteStudentToolS').all((req, res, next) => {
  2562. postmysql(req, res, "deleteStudentToolST");
  2563. });
  2564. //协同编辑 创建房间
  2565. router.route('/insertRoomByFile').all((req, res, next) => {
  2566. //var json = queryString(req.url);
  2567. postmysql2(req, res, "insertRoomByFile");
  2568. //getmysql(req, res, "insertRoomByFile", json["uid"], json["n"], json["d"]);
  2569. });
  2570. //思维网格 查询是否是重复房间号
  2571. router.route('/checkRoomNum').all((req, res, next) => {
  2572. var json = queryString(req.url);
  2573. getmysql(req, res, "checkRoomNum", json['num']);
  2574. });
  2575. //思维网格 查询房间列表
  2576. router.route('/selectRoomList').all((req, res, next) => {
  2577. var json = queryString(req.url);
  2578. getmysql(req, res, "selectRoomList", json['uid'], json['oid'], json['cid'], json['cu'], json['cn']);
  2579. });
  2580. //查询pdf列表
  2581. router.route('/selectRTC').all((req, res, next) => {
  2582. var json = queryString(req.url);
  2583. getmysql(req, res, "selectRTC", json['uid'], json['cu'], json['cn']);
  2584. });
  2585. //协同文档 查询房间列表
  2586. router.route('/selectFileList').all((req, res, next) => {
  2587. var json = queryString(req.url);
  2588. getmysql(req, res, "selectFileList", json['uid'], json['oid'], json['cid'], json['cu'], json['cn']);
  2589. });
  2590. //协同编辑 查询是否是重复房间号
  2591. router.route('/checkRoomNumByFile').all((req, res, next) => {
  2592. var json = queryString(req.url);
  2593. getmysql(req, res, "checkRoomNumByFile", json['num']);
  2594. });
  2595. //思维网格 根据房间号或者用户id查询房间信息
  2596. router.route('/selectRoom').all((req, res, next) => {
  2597. var json = queryString(req.url);
  2598. getmysql(req, res, "selectRoom", json['uid']);
  2599. });
  2600. //思维网格 根据房间号或者用户id查询房间信息
  2601. router.route('/getRoom').all((req, res, next) => {
  2602. var json = queryString(req.url);
  2603. getmysql(req, res, "select_room", json['fid']);
  2604. });
  2605. //协同编辑 根据房间号或者用户id查询房间信息
  2606. router.route('/selectRoomByFile').all((req, res, next) => {
  2607. var json = queryString(req.url);
  2608. getmysql(req, res, "selectRoomByFile", json['uid']);
  2609. });
  2610. //思维网格 修改房间数据
  2611. router.route('/updateRoomData').all((req, res, next) => {
  2612. postmysql(req, res, "updateRoomData");
  2613. });
  2614. router.route('/updateFileData').all((req, res, next) => {
  2615. var json = queryString(req.url);
  2616. var json2 = json['mode'].split(',');
  2617. getmysql(req, res, "updateFileData", json2[0], json2[1]);
  2618. });
  2619. router.route('/select_file').all((req, res, next) => {
  2620. var json = queryString(req.url);
  2621. getmysql(req, res, "select_file", json['fid']);
  2622. });
  2623. //思维网格 解散房间
  2624. router.route('/dismiss').all((req, res, next) => {
  2625. postmysql(req, res, "update_room");
  2626. });
  2627. //提交提问
  2628. router.route('/addProblem').all((req, res, next) => {
  2629. postmysql(req, res, "add_problem");
  2630. //cid 课程id,chid 章节id,t 提问内容,uid 用户id
  2631. });
  2632. //查询提交的提问
  2633. router.route('/getProblem').all((req, res, next) => {
  2634. var json = queryString(req.url); //cid 课程id,page 页数
  2635. getmysql(req, res, "select_problem", json['cid'], json['page'], 10);
  2636. });
  2637. //获取用户基本信息
  2638. router.route('/getUserInfo').all((req, res, next) => {
  2639. var json = queryString(req.url);
  2640. getmysql(req, res, "getUserInfo", json['uid'], json['cid']);
  2641. });
  2642. //获取用户多个课程基本信息
  2643. router.route('/getUserInfoMore').all((req, res, next) => {
  2644. var json = queryString(req.url);
  2645. getmysql(req, res, "getUserInfoMore", json['uid'], json['cid']);
  2646. });
  2647. //获取多个用户单个课程基本信息
  2648. router.route('/getClassUserInfoMore').all((req, res, next) => {
  2649. var json = queryString(req.url);
  2650. getmysql(req, res, "getClassUserInfoMore", json['uid'], json['cid']);
  2651. });
  2652. //获取课程下所有有作业的学生id
  2653. router.route('/selectCourseSuid').all((req, res, next) => {
  2654. var json = queryString(req.url);
  2655. getmysql(req, res, "selectCourseSuid", json['cid'], json['courseid']);
  2656. });
  2657. //获取项目基本信息
  2658. router.route('/getCourseInfo').all((req, res, next) => {
  2659. var json = queryString(req.url);
  2660. getmysql(req, res, "getCourseInfo", json['cid']);
  2661. });
  2662. //获取多个项目基本信息
  2663. router.route('/getCourseInfoMore').all((req, res, next) => {
  2664. var json = queryString(req.url);
  2665. getmysql(req, res, "getCourseInfoMore", json['cid']);
  2666. });
  2667. //获取用户基本信息
  2668. router.route('/getAllUserById').all((req, res, next) => {
  2669. var json = queryString(req.url);
  2670. getmysql(req, res, "getAllUserById", json['uid']);
  2671. });
  2672. //作业生成报告
  2673. router.route('/getWorkData').all((req, res, next) => {
  2674. var json = queryString(req.url); //cid 课程id,page 页数
  2675. getmysql(req, res, "select_work_data", json['cid']);
  2676. });
  2677. //查询评价体系
  2678. router.route('/getEvaluation').all((req, res, next) => {
  2679. var json = queryString(req.url); //cid 课程id,page 页数
  2680. getmysql(req, res, "select_evaluation", json['oid'], json['n'], json['page'], 10);
  2681. });
  2682. //添加评价体系
  2683. router.route('/addEvaluation').all((req, res, next) => {
  2684. postmysql(req, res, "add_evaluation");
  2685. //uid 用户id t标题 c内容
  2686. });
  2687. //修改评价体系
  2688. router.route('/updateEvaluation').all((req, res, next) => {
  2689. postmysql(req, res, "update_evaluation");
  2690. //c内容 t标题 id评价id
  2691. });
  2692. //删除评价体系
  2693. router.route('/deleteEvaluation').all((req, res, next) => {
  2694. postmysql(req, res, "delete_evaluation");
  2695. // id评价id
  2696. });
  2697. //批量添加学校
  2698. router.route('/batchRegistrationSchool').post(function(req, res, next) {
  2699. let users = req.body[0];
  2700. let arr = JSON.parse(req.body[0].arr);
  2701. for (let i = 0; i < arr.length; i++) {
  2702. let _school = arr[i].school;
  2703. let _org = users.org;
  2704. //用戶數據
  2705. let _data = [
  2706. _school,
  2707. _org,
  2708. '',
  2709. '1',
  2710. '',
  2711. ];
  2712. //參數拼接,註冊
  2713. _data.unshift(_mysqlLabor[0], _mysqlLabor[1], "insertSchoolByOrg");
  2714. //用戶註冊處理
  2715. mysql.usselect(_data, function(ret) {
  2716. res.end(JSON.stringify({ success: 1 }));
  2717. });
  2718. }
  2719. });
  2720. //批量添加学生
  2721. router.route('/batchRegistrationMore').post(function(req, res, next) {
  2722. let users = req.body[0];
  2723. let arr = JSON.parse(req.body[0].arr);
  2724. for (let i = 0; i < arr.length; i++) {
  2725. let _username = arr[i].name;
  2726. let _mail = arr[i].mail;
  2727. let _password = users.password || "123456";
  2728. let _alias = arr[i].name;
  2729. let _oid = users.oid;
  2730. let _ph = arr[i].phone ? arr[i].phone : '';
  2731. let _class = arr[i].class;
  2732. let _sId = arr[i].sId;
  2733. //加密密碼
  2734. _password = bcrypt.hashSync(_password, bcrypt.genSaltSync(10));
  2735. //生成激活碼
  2736. let _hashstr = new Date().getTime() + "";
  2737. let _digest = crypto.createHash('sha256').update(_hashstr, 'utf8').digest('hex');
  2738. //用戶數據
  2739. let _userdata = [
  2740. _mail,
  2741. _password,
  2742. _alias,
  2743. "",
  2744. 1, //0老师 1学生
  2745. _username,
  2746. "",
  2747. generateAPIKey(_username),
  2748. _digest,
  2749. "",
  2750. _username,
  2751. _sId,
  2752. 2, //1老师 2学生
  2753. _oid,
  2754. _ph,
  2755. _class,
  2756. '',
  2757. "0",
  2758. ];
  2759. //參數拼接,註冊
  2760. _userdata.unshift(_mysqluser[0], _mysqluser[1], "pbl_add_batchregister");
  2761. //用戶註冊處理
  2762. mysql.usselect(_userdata, function(ret) {
  2763. // let _pbluserdata = [
  2764. // ret[1][0].uid,
  2765. // _username,
  2766. // _sId,
  2767. // 2,
  2768. // _oid,
  2769. // _ph,
  2770. // _class,
  2771. // '',
  2772. // "0",
  2773. // ];
  2774. // _pbluserdata.unshift(_mysqlLabor[0], _mysqlLabor[1], "updateUserByEdu");
  2775. // mysql.usselect(_pbluserdata, function(ret) {
  2776. res.end(JSON.stringify({ success: 1 }));
  2777. // });
  2778. });
  2779. }
  2780. });
  2781. //初始化密码
  2782. router.route('/iniPassword').post(function(req, res, next) {
  2783. let users = req.body[0];
  2784. _password = users.pa;
  2785. //加密密碼
  2786. _password = bcrypt.hashSync(_password, bcrypt.genSaltSync(10));
  2787. //用戶數據
  2788. let _userList = [
  2789. users.uid,
  2790. _password,
  2791. ];
  2792. _userList.unshift(_mysqlLabor[0], _mysqlLabor[1], "iniPassword");
  2793. mysql.usselect(_userList, function(ret) {
  2794. res.end(JSON.stringify({ success: 1 }));
  2795. });
  2796. });
  2797. //批量添加教师
  2798. router.route('/batchRegistrationMore1').post(function(req, res, next) {
  2799. let users = req.body[0];
  2800. let arr = JSON.parse(req.body[0].arr);
  2801. for (let i = 0; i < arr.length; i++) {
  2802. let _username = arr[i].name;
  2803. let _mail = arr[i].mail;
  2804. let _password = users.password || "123456";
  2805. let _alias = arr[i].name;
  2806. let _org = users.org;
  2807. let _oid = arr[i].school;
  2808. let _ph = arr[i].phone ? arr[i].phone : '';
  2809. let _class = arr[i].class;
  2810. let _sId = arr[i].sId;
  2811. //加密密碼
  2812. _password = bcrypt.hashSync(_password, bcrypt.genSaltSync(10));
  2813. //生成激活碼
  2814. let _hashstr = new Date().getTime() + "";
  2815. let _digest = crypto.createHash('sha256').update(_hashstr, 'utf8').digest('hex');
  2816. //用戶數據
  2817. let _userdata = [
  2818. _mail,
  2819. _password,
  2820. _alias,
  2821. "",
  2822. 0, //0老师 1学生
  2823. _username,
  2824. "",
  2825. generateAPIKey(_username),
  2826. _digest,
  2827. "",
  2828. _username,
  2829. _sId,
  2830. 1, //1老师 2学生
  2831. _org,
  2832. _oid,
  2833. '',
  2834. '',
  2835. '',
  2836. "0",
  2837. ];
  2838. //參數拼接,註冊
  2839. _userdata.unshift(_mysqluser[0], _mysqluser[1], "pbl_add_batchregister_oid");
  2840. //用戶註冊處理
  2841. mysql.usselect(_userdata, function(ret) {
  2842. res.end(JSON.stringify({ success: 1 }));
  2843. });
  2844. }
  2845. });
  2846. //赛事批量注册老师
  2847. router.route('/pbl_add_raceuser_oid').post(function(req, res, next) {
  2848. let users = req.body[0];
  2849. let arr = JSON.parse(req.body[0].arr);
  2850. for (let i = 0; i < arr.length; i++) {
  2851. let _username = arr[i].name;
  2852. let _mail = arr[i].mail;
  2853. let _password = users.password || "123456";
  2854. let _oid = arr[i].school;
  2855. //加密密碼
  2856. _password = bcrypt.hashSync(_password, bcrypt.genSaltSync(10));
  2857. //生成激活碼
  2858. let _hashstr = new Date().getTime() + "";
  2859. let _digest = crypto.createHash('sha256').update(_hashstr, 'utf8').digest('hex');
  2860. //用戶數據
  2861. let _userdata = [
  2862. _mail,
  2863. _oid,
  2864. _password,
  2865. _username,
  2866. 1, //1普通教师 2市级 3省级 4市级子级评委 5县区评委 6县区子级
  2867. ];
  2868. //參數拼接,註冊
  2869. _userdata.unshift(_mysqlLabor[0], _mysqlLabor[1], "pbl_add_raceuser_oid");
  2870. //用戶註冊處理
  2871. mysql.usselect(_userdata, function(ret) {
  2872. res.end(JSON.stringify({ success: 1 }));
  2873. });
  2874. }
  2875. });
  2876. //新增学生
  2877. router.route('/batchRegistration').post(function(req, res, next) {
  2878. var users = req.body[0];
  2879. //循环注册
  2880. var _username = users.alias;
  2881. var _mail = users.username;
  2882. var _password = users.password || "123456";
  2883. var _alias = users.alias;
  2884. var _oid = users.oid;
  2885. var _ph = users.ph;
  2886. var _class = users.cid;
  2887. var _sId = users.sid;
  2888. //加密密碼
  2889. _password = bcrypt.hashSync(_password, bcrypt.genSaltSync(10));
  2890. //生成激活碼
  2891. let _hashstr = new Date().getTime() + "";
  2892. let _digest = crypto.createHash('sha256').update(_hashstr, 'utf8').digest('hex');
  2893. //用戶數據
  2894. var _userdata = [
  2895. _mail,
  2896. _password,
  2897. _alias,
  2898. "",
  2899. 1,
  2900. _username,
  2901. "",
  2902. generateAPIKey(_username),
  2903. _digest,
  2904. "",
  2905. _username,
  2906. _sId,
  2907. 2,
  2908. _oid,
  2909. _ph,
  2910. _class,
  2911. '',
  2912. "0",
  2913. ];
  2914. //參數拼接,註冊
  2915. _userdata.unshift(_mysqluser[0], _mysqluser[1], "pbl_add_batchregister");
  2916. //用戶註冊處理
  2917. mysql.usselect(_userdata, function(ret) {
  2918. res.end(JSON.stringify({ uid: ret[1][0].uid, ph: _ph, oid: _oid, cid: _class, success: 1 }));
  2919. });
  2920. });
  2921. //新增教师
  2922. router.route('/batchRegistration1').post(function(req, res, next) {
  2923. var users = req.body[0];
  2924. //循环注册
  2925. var _username = users.alias;
  2926. var _mail = users.username;
  2927. var _password = users.password || "123456";
  2928. var _alias = users.alias;
  2929. var _org = users.org;
  2930. var _oid = users.oid;
  2931. var _ph = users.ph;
  2932. var _class = users.cid;
  2933. var _sId = users.sid;
  2934. //加密密碼
  2935. _password = bcrypt.hashSync(_password, bcrypt.genSaltSync(10));
  2936. //生成激活碼
  2937. let _hashstr = new Date().getTime() + "";
  2938. let _digest = crypto.createHash('sha256').update(_hashstr, 'utf8').digest('hex');
  2939. //用戶數據
  2940. var _userdata = [
  2941. _mail,
  2942. _password,
  2943. _alias,
  2944. "",
  2945. 0,
  2946. _username,
  2947. "",
  2948. generateAPIKey(_username),
  2949. _digest,
  2950. "",
  2951. _username,
  2952. _sId,
  2953. 1,
  2954. _org,
  2955. _oid,
  2956. _ph,
  2957. _class,
  2958. '',
  2959. "0",
  2960. ];
  2961. //參數拼接,註冊
  2962. _userdata.unshift(_mysqluser[0], _mysqluser[1], "pbl_add_batchregister1");
  2963. //用戶註冊處理
  2964. mysql.usselect(_userdata, function(ret) {
  2965. res.end(JSON.stringify({ uid: ret[1][0].uid, ph: _ph, oid: _oid, cid: _class, success: 1 }));
  2966. });
  2967. });
  2968. router.route('/batchRegistrationOrg').post(function(req, res, next) {
  2969. var users = req.body[0];
  2970. //循环注册
  2971. var _username = users.alias;
  2972. var _mail = users.username;
  2973. var _password = users.password || "123456";
  2974. var _alias = users.alias;
  2975. var _oid = users.oid;
  2976. var _ph = users.ph;
  2977. var _class = users.cid;
  2978. var _sId = users.sid;
  2979. var _org = users.org;
  2980. //加密密碼
  2981. _password = bcrypt.hashSync(_password, bcrypt.genSaltSync(10));
  2982. //生成激活碼
  2983. let _hashstr = new Date().getTime() + "";
  2984. let _digest = crypto.createHash('sha256').update(_hashstr, 'utf8').digest('hex');
  2985. //用戶數據
  2986. var _userdata = [
  2987. _mail,
  2988. _password,
  2989. _alias,
  2990. "",
  2991. 1,
  2992. _username,
  2993. "",
  2994. generateAPIKey(_username),
  2995. _digest,
  2996. "",
  2997. _username,
  2998. _sId,
  2999. 2,
  3000. _oid,
  3001. _ph,
  3002. _class,
  3003. '',
  3004. "0",
  3005. _org
  3006. ];
  3007. //參數拼接,註冊
  3008. _userdata.unshift(_mysqluser[0], _mysqluser[1], "pbl_add_batchregister_org");
  3009. //用戶註冊處理
  3010. mysql.usselect(_userdata, function(ret) {
  3011. res.end(JSON.stringify({ uid: ret[1][0].uid, ph: _ph, oid: _oid, cid: _class, success: 1 }));
  3012. });
  3013. });
  3014. router.route('/batchRegistrationMoreOrg').post(function(req, res, next) {
  3015. let users = req.body[0];
  3016. let arr = JSON.parse(req.body[0].arr);
  3017. for (let i = 0; i < arr.length; i++) {
  3018. let _username = arr[i].name;
  3019. let _mail = arr[i].mail;
  3020. let _password = users.password || "123456";
  3021. let _alias = arr[i].name;
  3022. let _oid = users.oid;
  3023. let _ph = arr[i].phone ? arr[i].phone : '';
  3024. let _class = arr[i].class;
  3025. let _sId = arr[i].sId;
  3026. let _org = users.org;
  3027. //加密密碼
  3028. _password = bcrypt.hashSync(_password, bcrypt.genSaltSync(10));
  3029. //生成激活碼
  3030. let _hashstr = new Date().getTime() + "";
  3031. let _digest = crypto.createHash('sha256').update(_hashstr, 'utf8').digest('hex');
  3032. //用戶數據
  3033. let _userdata = [
  3034. _mail,
  3035. _password,
  3036. _alias,
  3037. "",
  3038. 1, //0老师 1学生
  3039. _username,
  3040. "",
  3041. generateAPIKey(_username),
  3042. _digest,
  3043. "",
  3044. _username,
  3045. _sId,
  3046. 2, //1老师 2学生
  3047. _oid,
  3048. _ph,
  3049. _class,
  3050. '',
  3051. "0",
  3052. _org
  3053. ];
  3054. //參數拼接,註冊
  3055. _userdata.unshift(_mysqluser[0], _mysqluser[1], "pbl_add_batchregister_org2");
  3056. //用戶註冊處理
  3057. mysql.usselect(_userdata, function(ret) {
  3058. res.end(JSON.stringify({ success: 1 }));
  3059. });
  3060. }
  3061. });
  3062. //工作室管理
  3063. router.route('/updateStudioWorkNew4').all((req, res, next) => { //学生
  3064. if (req.body[0]) {
  3065. let p = [req.body[0].cid];
  3066. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "select_studio_course_detail2"); //執行存儲過程
  3067. mysql.usselect(p, function(ret) {
  3068. let _unitIndex = parseInt(req.body[0].unitIndex);
  3069. let _chapters = JSON.parse(req.body[0].chapters);
  3070. let _unitJson = JSON.parse(ret[0][0].chapters)
  3071. if ((_unitJson.length - 1) < _unitIndex) {
  3072. let _i = _unitIndex - (_unitJson.length - 1)
  3073. for (let i = 0; i < _i; i++) {
  3074. _unitJson.push({
  3075. dyName: "", //单元标题
  3076. chapterInfo: [{
  3077. isread: false,
  3078. chapterid: guid(),
  3079. title: "",
  3080. courseName: "",
  3081. taskJson: [{
  3082. task: "",
  3083. taskDetail: "",
  3084. chapterData: [],
  3085. toolText: "",
  3086. toolChoose: [{
  3087. tool: [],
  3088. toolDetail: "",
  3089. toolType: 0,
  3090. askCount: 1,
  3091. askTitle: "",
  3092. askJson: [{ askstitle: "", askItem: 1, checkList: [] }],
  3093. }, ],
  3094. isShowTools: false,
  3095. askCount: 1,
  3096. isFold: 0,
  3097. askTitle: "",
  3098. askJson: [{ askstitle: "", askItem: 1, checkList: [] }],
  3099. checkJson: [{ checkCount: [], checkPerent: [] }],
  3100. homeworkList: [],
  3101. }, ],
  3102. itemCount: 1,
  3103. fileList1: [],
  3104. video: [],
  3105. testData: [],
  3106. pData: [],
  3107. templateArray: [],
  3108. }, ],
  3109. })
  3110. }
  3111. _unitJson[_unitIndex] = _chapters[_unitIndex]
  3112. } else {
  3113. _unitJson[_unitIndex] = _chapters[_unitIndex]
  3114. }
  3115. // console.log(_unitJson);
  3116. let p2 = [req.body[0].cid, JSON.stringify(_unitJson).replaceAll(/%/g, "%25")];
  3117. p2.unshift(_mysqlLabor[0], _mysqlLabor[1], "updateStudioWorkNew4"); //執行存儲過程
  3118. mysql.usselect(p2, function(ret) {
  3119. res.end(JSON.stringify({ success: 1 }));
  3120. });
  3121. // res.end(JSON.stringify({ success: 1 }));
  3122. });
  3123. }
  3124. });
  3125. router.route('/updateStudioWorkNew2').all((req, res, next) => { //学生
  3126. if (req.body[0]) {
  3127. 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];
  3128. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "updateStudioWorkNew2"); //執行存儲過程
  3129. mysql.usselect(p, function(ret) {
  3130. let course = req.body[0].courseType;
  3131. let courseId = req.body[0].cid;
  3132. let userid = req.body[0].uid;
  3133. delStudioCourseTypeS(course, courseId, userid);
  3134. res.end(JSON.stringify({ success: 1 }));
  3135. });
  3136. }
  3137. });
  3138. router.route('/addStudioCourseWorkNew2').all((req, res, next) => { //学生
  3139. if (req.body[0]) {
  3140. 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];
  3141. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "addStudioCourseWorkNew2"); //執行存儲過程
  3142. mysql.usselect(p, function(ret) {
  3143. let course = req.body[0].courseType;
  3144. let courseId = ret[0][0].courseId;
  3145. let userid = req.body[0].uid;
  3146. delStudioCourseTypeS(course, courseId, userid);
  3147. res.end(JSON.stringify({ ordernumber: ret[0][0].ordernumber, courseId: ret[0][0].courseId, success: 1 }));
  3148. });
  3149. }
  3150. });
  3151. //teacher 查询项目模板
  3152. router.route('/getStudioTemplateTs').all((req, res, next) => {
  3153. var json = queryString(req.url);
  3154. getmysql(req, res, "getStudioTemplateTs", json['oid']);
  3155. });
  3156. //查看课程
  3157. router.route('/select_studio_course_detail').all((req, res, next) => { //学生
  3158. var json = queryString(req.url);
  3159. getmysql(req, res, "select_studio_course_detail", json['cid']);
  3160. });
  3161. //查看课程
  3162. router.route('/select_studio_course_detail2').all((req, res, next) => { //学生
  3163. var json = queryString(req.url);
  3164. getmysql(req, res, "select_studio_course_detail2", json['cid']);
  3165. });
  3166. //协同恢复删除的阶段
  3167. router.route('/restoreStudioWork').all((req, res, next) => { //学生
  3168. if (req.body[0]) {
  3169. let p = [req.body[0].cid];
  3170. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "select_studio_course_detail2"); //執行存儲過程
  3171. mysql.usselect(p, function(ret) {
  3172. let _chapid = req.body[0].chapid;
  3173. // console.log(_chapid);
  3174. let _chapters = JSON.parse(req.body[0].chapters);
  3175. let _unitJson = JSON.parse(ret[0][0].chapters)
  3176. let _unitJson2 = []
  3177. let chpaindex;
  3178. for (var i = 0; i < _chapters.length; i++) {
  3179. if (_chapters[i].chapterInfo[0].chapterid == _chapid) {
  3180. chpaindex = i
  3181. }
  3182. }
  3183. for (var i = 0; i < _unitJson.length; i++) {
  3184. if (_unitJson[i].chapterInfo[0].chapterid != _chapid) {
  3185. // console.log(1);
  3186. // _unitJson.splice(i, -1)
  3187. _unitJson2.push(_unitJson[i])
  3188. // break;
  3189. }
  3190. }
  3191. _unitJson2.splice(chpaindex, 0, _chapters[chpaindex])
  3192. // console.log(_unitJson2);
  3193. let p2 = [req.body[0].cid, JSON.stringify(_unitJson2).replaceAll(/%/g, "%25")];
  3194. p2.unshift(_mysqlLabor[0], _mysqlLabor[1], "updateStudioWorkNew4"); //執行存儲過程
  3195. mysql.usselect(p2, function(ret) {
  3196. res.end(JSON.stringify({ success: 1 }));
  3197. });
  3198. // res.end(JSON.stringify({ success: 1 }));
  3199. });
  3200. }
  3201. });
  3202. //查询分类及所有子分类
  3203. router.route('/selectAllTypeStudio').all((req, res, next) => {
  3204. var json = queryString(req.url);
  3205. getmysql(req, res, "selectAllTypeStudio", json['org'], json['oid']);
  3206. });
  3207. //上传文件
  3208. router.route('/addStudioCourseWorksS').all((req, res, next) => {
  3209. postmysql(req, res, "addStudioCourseWorksS");
  3210. });
  3211. //删除提交的作业
  3212. router.route('/deleteStudioCourseWorkS').all((req, res, next) => {
  3213. postmysql(req, res, "deleteStudioCourseWorkS");
  3214. });
  3215. router.route('/selectStudioCourseNew222').all((req, res, next) => {
  3216. var json = queryString(req.url);
  3217. getmysql(req, res, "selectStudioCourseNew222", 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'], json['pageSize']);
  3218. });
  3219. //删除课程
  3220. router.route('/deleteStudioCourse').all((req, res, next) => {
  3221. var json = queryString(req.url);
  3222. getmysql(req, res, "deleteStudioCourse", json['cid']);
  3223. });
  3224. function delStudioCourseTypeS(course, courseId, userid) {
  3225. let _courseId = courseId;
  3226. var _userdata = [
  3227. _courseId
  3228. ];
  3229. _userdata.unshift(_mysqlLabor[0], _mysqlLabor[1], "delete_studioCourseTypeS");
  3230. mysql.usselect(_userdata, function(ret) {
  3231. // console.log(ret);
  3232. addStudioCourseTypeS(userid, course, _courseId)
  3233. });
  3234. // setTimeout(() => {
  3235. // }, 1000);
  3236. }
  3237. function addStudioCourseTypeS(userid, course, _courseId) {
  3238. var _uid = userid;
  3239. var _courses = _courseId
  3240. var _tid = JSON.parse(course)
  3241. for (let i = 0; i < _tid.length; i++) {
  3242. if (_tid[i] == '') {
  3243. continue;
  3244. }
  3245. var _userdata = [
  3246. _courses,
  3247. _tid[i],
  3248. _uid,
  3249. ];
  3250. _userdata.unshift(_mysqlLabor[0], _mysqlLabor[1], "add_studioCourseTypeS");
  3251. mysql.usselect(_userdata, function(ret) {
  3252. // console.log(ret);
  3253. });
  3254. }
  3255. }
  3256. //删除作业阶段任务工具
  3257. router.route('/deleteStudioToolSTT').all((req, res, next) => {
  3258. postmysql(req, res, "deleteStudioToolSTT");
  3259. });
  3260. //删除作业阶段任务
  3261. router.route('/deleteStudioToolST').all((req, res, next) => {
  3262. postmysql(req, res, "deleteStudioToolST");
  3263. });
  3264. //删除作业阶段
  3265. router.route('/deleteStudioToolS').all((req, res, next) => {
  3266. postmysql(req, res, "deleteStudioToolST");
  3267. });
  3268. //工作管理首页查询分类
  3269. router.route('/selectStudioCourseNew22Mode').all((req, res, next) => {
  3270. var json = queryString(req.url);
  3271. getmysql(req, res, "selectStudioCourseNew22Mode", json['type'], json['uid'], json['oid'], json['org'], json['typea'], json['typeb'], json['typec'], json['typed'], json['typef'], json['typeE'], json['cu'], json['cn']);
  3272. });
  3273. //工作管理首页查询
  3274. router.route('/selectStudioCourseNew22').all((req, res, next) => {
  3275. var json = queryString(req.url);
  3276. getmysql(req, res, "selectStudioCourseNew22", 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'], json['pageSize']);
  3277. });
  3278. //根据学校查询banner
  3279. router.route('/selectBannerByOidStudio').all((req, res, next) => {
  3280. var json = queryString(req.url);
  3281. getmysql(req, res, "selectBannerByOidStudio", json["oid"]);
  3282. });
  3283. //admin 查询banner
  3284. router.route('/getBannerStudio').all((req, res, next) => {
  3285. var json = queryString(req.url);
  3286. getmysql(req, res, "getBannerStudio");
  3287. });
  3288. //查询工作课程详情
  3289. router.route('/selectStudioCourseDetail2').all((req, res, next) => { //学生
  3290. var json = queryString(req.url);
  3291. getmysql(req, res, "selectStudioCourseDetail2", json['courseId']);
  3292. });
  3293. //查询工作课程详情
  3294. router.route('/selectStudioCourseDetail3').all((req, res, next) => { //学生
  3295. var json = queryString(req.url);
  3296. getmysql(req, res, "selectStudioCourseDetail3", json['courseId']);
  3297. });
  3298. //上传文件
  3299. router.route('/addCourseWorks4studio').all((req, res, next) => {
  3300. postmysql3(req, res, "addCourseWorks4studio");
  3301. });
  3302. //查询教师资源分类
  3303. router.route('/selectAllSourceType').all((req, res, next) => { //学生
  3304. var json = queryString(req.url);
  3305. getmysql(req, res, "selectAllSourceType", json['oid'], json['org']);
  3306. });
  3307. router.route('/addSource').all((req, res, next) => { //添加资源
  3308. if (req.body[0]) {
  3309. p = [req.body[0].name, req.body[0].url, req.body[0].detail, req.body[0].label, req.body[0].userid];
  3310. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "addSource");
  3311. //執行存儲過程
  3312. mysql.usselect(p, function(ret) {
  3313. let course = req.body[0].courseType;
  3314. let courseId = ret[0][0].id;
  3315. let userid = req.body[0].userid;
  3316. delSourceType(course, courseId, userid);
  3317. res.end(JSON.stringify({ id: ret[0][0].id, success: 1 }));
  3318. // res.end(JSON.stringify(ret));
  3319. });
  3320. }
  3321. });
  3322. router.route('/updateSource').all((req, res, next) => { //修改资源
  3323. if (req.body[0]) {
  3324. p = [req.body[0].id, req.body[0].name, req.body[0].url, req.body[0].detail, req.body[0].label, req.body[0].userid];
  3325. p.unshift(_mysqlLabor[0], _mysqlLabor[1], "updateSource");
  3326. //執行存儲過程
  3327. mysql.usselect(p, function(ret) {
  3328. let course = req.body[0].courseType;
  3329. let courseId = req.body[0].id;
  3330. let userid = req.body[0].userid;
  3331. delSourceType(course, courseId, userid);
  3332. res.end(JSON.stringify({ id: req.body[0].id, success: 1 }));
  3333. // res.end(JSON.stringify(ret));
  3334. });
  3335. }
  3336. });
  3337. function delSourceType(course, courseId, userid) {
  3338. let _courseId = courseId;
  3339. var _userdata = [
  3340. _courseId
  3341. ];
  3342. _userdata.unshift(_mysqlLabor[0], _mysqlLabor[1], "delete_sourceType");
  3343. mysql.usselect(_userdata, function(ret) {
  3344. addSourceType(userid, course, _courseId)
  3345. });
  3346. }
  3347. function addSourceType(userid, course, _courseId) {
  3348. var _uid = userid;
  3349. var _courses = _courseId
  3350. var _tid = JSON.parse(course)
  3351. for (let i = 0; i < _tid.length; i++) {
  3352. if (_tid[i] == '') {
  3353. continue;
  3354. }
  3355. var _userdata = [
  3356. _courses,
  3357. _tid[i],
  3358. _uid,
  3359. ];
  3360. _userdata.unshift(_mysqlLabor[0], _mysqlLabor[1], "add_sourceType");
  3361. mysql.usselect(_userdata, function(ret) {
  3362. // console.log(ret);
  3363. });
  3364. }
  3365. }
  3366. //资源查询
  3367. router.route('/selectSource').all((req, res, next) => {
  3368. var json = queryString(req.url);
  3369. getmysql(req, res, "selectSource", json['uid'], json['oid'], json['org'], json['typea'], json['typeb'], json['typeE'], json['cn'], json['page'], json['pageSize']);
  3370. });
  3371. function generateAPIKey(username) {
  3372. let timeStamp = new Date().getTime();
  3373. let hashStr = timeStamp + username;
  3374. let digest = crypto.createHash('sha256').update(hashStr, 'utf8').digest('hex');
  3375. return digest;
  3376. }
  3377. queryString = function(url) {
  3378. var a = url.split("?");
  3379. var json = querystring.parse(a[1])
  3380. return json;
  3381. }
  3382. //post存儲過程處理
  3383. postmysql = function(req, res, functionname) {
  3384. //mode的處理
  3385. if (req.body[0]) {
  3386. p = Object.values(req.body[0]);
  3387. p.unshift(_mysqlLabor[0], _mysqlLabor[1], functionname);
  3388. //執行存儲過程
  3389. mysql.usselect(p, function(ret) { res.end(JSON.stringify(ret)); });
  3390. }
  3391. }
  3392. //post存儲過程處理
  3393. postmysql2 = function(req, res, functionname) {
  3394. //mode的處理
  3395. if (req.body) {
  3396. p = Object.values(req.body)[0].split(",");
  3397. p.unshift(_mysqlLabor[0], _mysqlLabor[1], functionname);
  3398. //執行存儲過程
  3399. mysql.usselect(p, function(ret) { res.end(JSON.stringify(ret)); });
  3400. }
  3401. }
  3402. //post存儲過程處理
  3403. postmysql3 = function(req, res, functionname) {
  3404. //mode的處理
  3405. if (req.body) {
  3406. p = Object.values(req.body);
  3407. p.unshift(_mysqlLabor[0], _mysqlLabor[1], functionname);
  3408. //執行存儲過程
  3409. mysql.usselect(p, function(ret) { res.end(JSON.stringify(ret)); });
  3410. }
  3411. }
  3412. //get獲取數據庫信息
  3413. getmysql = function(req, res, functionname, ...p) {
  3414. p = p || [];
  3415. p.unshift(_mysqlLabor[0], _mysqlLabor[1], functionname);
  3416. //執行存儲過程
  3417. mysql.usselect(p, function(ret) { res.end(JSON.stringify(ret)); }); //
  3418. }
  3419. //post存储过程处理
  3420. userpostmysql = function(req, res, functionname) {
  3421. //mode的处理
  3422. if (req.body.mode) {
  3423. p = req.body.mode.split(",");
  3424. p.unshift(_mysqluser[0], _mysqluser[1], functionname);
  3425. //执行存储过程
  3426. mysql.usselect(p, function(ret) { res.end(JSON.stringify(ret)); });
  3427. }
  3428. }
  3429. //get获取数据库信息
  3430. usergetmysql = function(req, res, functionname, ...p) {
  3431. p = p || [];
  3432. p.unshift(_mysqluser[0], _mysqluser[1], functionname);
  3433. //执行存储过程
  3434. mysql.usselect(p, function(ret) { res.end(JSON.stringify(ret)); }); //
  3435. }
  3436. module.exports = router;