LjApiHelper.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 getApiForGetMac()
  23. {
  24. return macAddressStr;
  25. }
  26. /**
  27. * Gets the API for query course
  28. * @param lessonId the lesson id
  29. * @param courseId the course id
  30. * @param eid the eid
  31. * @returns {string} the API url
  32. */
  33. static getApiForQueryCourse(lessonId, courseId, eid)
  34. {
  35. var http = "http://tt-web.api.ai160.com/lesson/" + lessonId;
  36. http += "?courseId=" + courseId
  37. http += "&eid=" + eid
  38. http += "&cache=true";
  39. return http;
  40. }
  41. /**
  42. * Gets the API for add download
  43. * @param lessonId the lesson id
  44. * @param data the data
  45. * @returns {string}
  46. */
  47. static getApiForAddDownload(lessonId,courseId,resTotal,data)
  48. {
  49. return "http://tt-web.api.ai160.com/callback/download/add?lessonId=" + lessonId+"&courseId="+courseId+"&resTotal="+resTotal+"&resSize=0&mac="+macAddressStr;
  50. }
  51. /**
  52. * Gets the API for delete download
  53. * @param lessonId the lesson id
  54. * @param data the data
  55. * @returns {string}
  56. */
  57. static getApiForDelDownload(lessonId,data)
  58. {
  59. return "http://tt-web.api.ai160.com/callback/download/delete?lessonId=" + lessonId+"&mac="+macAddressStr;
  60. }
  61. /**
  62. * Gets the API for update resource size
  63. * @param lessonId the lesson id
  64. * @returns {string}
  65. */
  66. static getApiForUpdateResSize(lessonId)
  67. {
  68. return "http://tt-web.api.ai160.com/callback/download/update/resource/size?lessonId=" + lessonId+"&mac="+macAddressStr;
  69. }
  70. }
  71. module.exports = LjApiHelper;