pbl.js 135 KB

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