LjApiHelper.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. var request = require('request');
  2. var cryptoJS = require("crypto-js");
  3. var mac = require('getmac');//获取mac地址
  4. var macAddressStr = "";
  5. //获取机器mac地址
  6. mac.getMac(function(err,macAddress){
  7. if (err) throw err;
  8. macAddressStr = macAddress; //获取mac地址
  9. });
  10. /**
  11. * The helper of api
  12. */
  13. class LjApiHelper
  14. {
  15. /**
  16. * Gets the API for query course
  17. * @param lessonId the lesson id
  18. * @param courseId the course id
  19. * @param eid the eid
  20. * @returns {string} the API url
  21. */
  22. static getApiForQueryCourse(lessonId, courseId, eid)
  23. {
  24. var http = "http://tt-web.api.ai160.com/lesson/" + lessonId;
  25. http += "?courseId=" + courseId
  26. http += "&eid=" + eid
  27. http += "&cache=true";
  28. return http;
  29. }
  30. /**
  31. * Gets the API for add download
  32. * @param lessonId the lesson id
  33. * @param data the data
  34. * @returns {string}
  35. */
  36. static getApiForAddDownload(lessonId,courseId,resTotal,data)
  37. {
  38. return "http://tt-web.api.ai160.com/callback/download/add?lessonId=" + lessonId+"&courseId="+courseId+"&resTotal="+resTotal+"&resSize=0&mac="+macAddressStr;
  39. }
  40. /**
  41. * Gets the API for delete download
  42. * @param lessonId the lesson id
  43. * @param data the data
  44. * @returns {string}
  45. */
  46. static getApiForDelDownload(lessonId,data)
  47. {
  48. return "http://tt-web.api.ai160.com/callback/download/delete?lessonId=" + lessonId+"&data="+data;
  49. }
  50. /**
  51. * Gets the API for update resource size
  52. * @param lessonId the lesson id
  53. * @returns {string}
  54. */
  55. static getApiForUpdateResSize(lessonId)
  56. {
  57. return "http://tt-web.api.ai160.com/callback/download/update/resource/size?lessonId=" + lessonId;
  58. }
  59. }
  60. module.exports = LjApiHelper;