1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
|
const Authorization = "bearer xxxxxxxxxxxxxxxxxxxxx" const STU_UID = "3240999999" const CourseId = 273 const prdata = [ [4565,1], [4566,2], [4576,3], [4579,4], [4577,5], [4575,6], [4571,7], [4572,8], [4569,9], [4570,10], [4584,11], [4574,12], [4573,13], [4588,14], ]
const md5 = require("js-md5")
const APPKEY = "eb8c68399de7483abb2d8abaea0d039f" const dumpedKey = "7cd476ab866b49d7a9788ad9f4789495"
const host = "http://10.203.16.55:8098/lab-course"
function GET(path,data={}){ const timestamp = Date.parse(new Date)
return fetch(host+path+"?"+(new URLSearchParams(Object.entries({ "app_key":APPKEY, timestamp, ...data, sign:md5(dumpedKey+path+Object.entries(data).map(v=>v.join("")).join("")+timestamp+" "+dumpedKey) }))).toString(),{ headers:{ Authorization } }).then(e=>{ console.log("Fetch ",path," status ",e.status); return e.json() }).then(v=>{ console.log(v); return v; }) }
function POST(path,data){
const timestamp = Date.parse(new Date) return fetch(host+path,{ method:"POST", headers:{ "Content-Type":"application/x-www-form-urlencoded", Authorization }, body:(new URLSearchParams(Object.entries({ "app_key":APPKEY, timestamp, sign:md5(dumpedKey+path+Object.entries(data).sort((a,b)=>(b[0]<a[0]?1:-1)).map(v=>v.join("")).join("")+timestamp+" "+dumpedKey), ...data, }))).toString() }).then(e=>e.json()).then(v=>{ console.log("Response ",v); return v; }).catch(e=>{ console.log("Error ",e); return e; }) }
function s(){
for (let index = 0; index < prdata.length; index++) { const e = prdata[index]; POST("/api/course/lab/students",{ courseId, courseLabId:e[0], termId: 12, uid: STU_UID, selectWeek:e[1] }).then(v=>{ console.log(v); }) }
}
setInterval(()=>{s()},2000)
|