HttpClient.hpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*
  2. * @Description:
  3. * @Version: 1.0
  4. * @Autor: lishengyin
  5. * @Date: 2022-02-23 09:31:32
  6. * @LastEditors: Your Name lishengyin@sz-sunwin.com
  7. * @LastEditTime: 2022-09-04 21:32:43
  8. */
  9. #ifndef __HTTPCLIENT_H_
  10. #define __HTTPCLIENT_H_
  11. #include <iostream>
  12. #include <time.h>
  13. #include <ctime>
  14. #include "Util/logger.h"
  15. #include "Util/NoticeCenter.h"
  16. #include "Poller/EventPoller.h"
  17. #include "Util/SqlPool.h"
  18. #include "Network/TcpClient.h"
  19. #include "Poller/Timer.h"
  20. #include "TCPClient.hpp"
  21. #include <httplib.h>
  22. #include "Notices.h"
  23. #include "md5.h"
  24. // dataType
  25. #include "NettyHttpResultMsg.h"
  26. #include "NettyHttpToken.h"
  27. #include "NettyHttpNull.h"
  28. #include "NettyExpelDevInfo.h"
  29. #include "NettyHttpDicCode.h"
  30. #include "HttpNull.hpp"
  31. #include "HttpResultMsg.hpp"
  32. #include "HttpToken.hpp"
  33. #include "UtilBase.hpp"
  34. #include "config.hpp"
  35. using namespace std;
  36. namespace gsd{
  37. class HttpClient: public enable_shared_from_this<HttpClient>, public ModuleBase
  38. {
  39. private:
  40. // 用户名
  41. std::string account;
  42. std::string pwd = "sunwin20200507";
  43. // 固定16位私钥
  44. std::string privateKey = "mwWAH2eUAAHodlRt";
  45. // authToken
  46. std::string authToken = "";
  47. // refreshToken
  48. std::string refreshToken = "";
  49. public:
  50. HttpClient() {}
  51. ~HttpClient() {}
  52. /**
  53. * @description: Init
  54. * @return {*}
  55. */
  56. virtual bool Init(){
  57. return true;
  58. }
  59. /**
  60. * @description: Destroy
  61. * @return {*}
  62. */
  63. virtual void Destroy(){
  64. }
  65. /**
  66. * @description: 初始化
  67. * @param {string} account
  68. * @param {string} url
  69. * @param {int} port
  70. * @return {*}
  71. */
  72. int32_t Init(std::string account,std::string url, int port);
  73. /**
  74. * @description: 创建对象
  75. * @param {*}
  76. * @return {*}
  77. */
  78. static std::shared_ptr<HttpClient> CreateNew();
  79. /**
  80. * @description: 登录
  81. * @param {*}
  82. * @return {*}
  83. */
  84. int32_t LoginNetty();
  85. /**
  86. * @description: 判断是否获取到Token
  87. * @param {*}
  88. * @return {*}
  89. */
  90. bool alive();
  91. /**
  92. * @description: 获取时间
  93. * @param {char} *ctime
  94. * @return {*}
  95. */
  96. static void getDataTime(char *ctime);
  97. /**
  98. * @description: 获取驱鸟设备信息
  99. * @param {*}
  100. * @return {*}
  101. */
  102. int32_t getExpelInfo(std::string simCode, NettyHttpResultMsg<NettyExpelDevInfo,NettyHttpNull>& nettyHttpResultMsg);
  103. /**
  104. * @description: 获取派尔云的设备数据
  105. * @param {*}
  106. * @return {*}
  107. */
  108. int32_t getHttpDicCode(std::string dictCode,NettyHttpResultMsg<NettyHttpDicCode,NettyHttpNull>& nettyHttpResultMsg);
  109. /**
  110. * @description: 送入判定器
  111. * @return {*}
  112. */
  113. std::pair<bool, std::string> getCheck(std::string& ImageBase64, std::string& datas);
  114. };
  115. };
  116. #endif