LjApiHelper.js 2.1 KB

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