LjApiHelper.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. //获取机器mac地址
  39. console.info(macAddressStr);
  40. return "http://tt-web.api.ai160.com/callback/download/add?lessonId=" + lessonId+"&courseId="+courseId+"&resTotal="+resTotal+"&resSize=0&mac="+macAddressStr;
  41. }
  42. /**
  43. * Gets the API for delete download
  44. * @param lessonId the lesson id
  45. * @param data the data
  46. * @returns {string}
  47. */
  48. static getApiForDelDownload(lessonId,data)
  49. {
  50. return "http://tt-web.api.ai160.com/callback/download/delete?lessonId=" + lessonId+"&data="+data;
  51. }
  52. /**
  53. * Gets the API for update resource size
  54. * @param lessonId the lesson id
  55. * @returns {string}
  56. */
  57. static getApiForUpdateResSize(lessonId)
  58. {
  59. return "http://tt-web.api.ai160.com/callback/download/update/resource/size?lessonId=" + lessonId;
  60. }
  61. }
  62. module.exports = LjApiHelper;