mod_centersetting.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. #ifndef RVC_MOD_CENTERSETTING_H__
  2. #define RVC_MOD_CENTERSETTING_H__
  3. #pragma once
  4. #include "CenterSetting_server_g.h"
  5. using namespace CenterSetting;
  6. #include "CenterSettingConn.h"
  7. #include <regex>
  8. #include <map>
  9. #include <string>
  10. #ifdef RVC_OS_LINUX
  11. #include <mutex>
  12. #endif
  13. using namespace std;
  14. enum DownloadStat
  15. {
  16. SUCC = 1,
  17. AccessServiceFail = 2,
  18. EXIST = 3,
  19. MANUAL = 4,
  20. AllAddressNull = 5,
  21. CalcSM3Fail = 6,
  22. CheckSM3Fail = 7,
  23. UNknown = 8
  24. };
  25. static void HTTPLogCallback(const char* msg){
  26. }
  27. class CCenterSettingEntity : public CEntityBase, public ITimerListener
  28. {
  29. public:
  30. CCenterSettingEntity() : m_strFilePath(true){}
  31. virtual ~CCenterSettingEntity() {}
  32. virtual const char* GetEntityName() const { return "CenterSetting"; }
  33. virtual bool IsService()const{ return true; }
  34. virtual void OnStarted();
  35. virtual void OnPreClose(EntityCloseCauseEnum eCloseCause, CSmartPointer<ITransactionContext> pTransactionContext);
  36. virtual void OnTimeout(DWORD dwTimerID);
  37. virtual CServerSessionBase* OnNewSession(const char* /*pszRemoteEntityName*/, const char* /*pszClass*/);
  38. ErrorCodeEnum DownloadCenterSetting(SpReqAnsContext<CenterSettingService_Downloadv2_Req, CenterSettingService_Downloadv2_Ans>::Pointer sp);
  39. ErrorCodeEnum GetAccessUrl(CSimpleStringA &url);
  40. ErrorCodeEnum GetCertainAceessUrl(CSimpleStringA &accessName, CSimpleStringA& url);
  41. private:
  42. ErrorCodeEnum BeginDownloadCenterSetting(bool bByHand = false, const string& url = "");
  43. private:
  44. CenterSettingsMicroServiceHelper* m_pMicroServiceHelper;
  45. CSimpleStringA m_strFilePath;
  46. CSmartPointer<IConfigInfo> m_pCenterConfig;
  47. CSimpleStringA m_strBakPath;
  48. #ifdef _MSC_VER
  49. CRITICAL_SECTION m_lock;
  50. #else
  51. std::mutex m_lock;
  52. #endif
  53. SpReqAnsContext<CenterSettingService_Downloadv2_Req, CenterSettingService_Downloadv2_Ans>::Pointer m_spDownloadCall;
  54. friend class CCenterSettingConn;
  55. bool m_isUseMemCfg;
  56. };
  57. class CCenterSettingService : public CenterSettingService_ServerSessionBase
  58. {
  59. public:
  60. CCenterSettingService(CCenterSettingEntity* pEntity) :m_pEntity(pEntity){}
  61. virtual ~CCenterSettingService(){}
  62. virtual void Handle_Downloadv2(SpReqAnsContext<CenterSettingService_Downloadv2_Req, CenterSettingService_Downloadv2_Ans>::Pointer ctx)
  63. {
  64. DbgToBeidou(ctx->link, __FUNCTION__)();
  65. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode(CenterSettingService_LogCode_Downloadv2).setAPI(__FUNCTION__)(__FUNCTION__);
  66. m_pEntity->DownloadCenterSetting(ctx);
  67. }
  68. /** 有必要废弃,采用通用化的接口获取即可,特别是要JS化时 [Gifur@2023823]*/
  69. virtual void Handle_GetAccessUrl(SpReqAnsContext<CenterSettingService_GetAccessUrl_Req, CenterSettingService_GetAccessUrl_Ans>::Pointer ctx)
  70. {
  71. DbgToBeidou(ctx->link, __FUNCTION__)();
  72. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode(CenterSettingService_LogCode_GetAccessUrl).setAPI(__FUNCTION__)(__FUNCTION__);
  73. auto rc = m_pEntity->GetAccessUrl(ctx->Ans.HostUrl); //获取初始化地址,是的,就是初始化地址,不要在意这里的名称问题,之前同事开发接口的时候估计随手一打
  74. ctx->Answer(rc);
  75. }
  76. virtual void Handle_GetCertainAceessUrl(SpReqAnsContext<CenterSettingService_GetCertainAceessUrl_Req, CenterSettingService_GetCertainAceessUrl_Ans>::Pointer ctx)
  77. {
  78. DbgToBeidou(ctx->link, __FUNCTION__)();
  79. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode(CenterSettingService_LogCode_GetCertainAceessUrl).setAPI(__FUNCTION__)(__FUNCTION__);
  80. auto rc = m_pEntity->GetCertainAceessUrl(ctx->Req.reqName, ctx->Ans.CertainAceessUrl); //获取准入地址,这个接口是后面加的
  81. ctx->Answer(rc);
  82. }
  83. private:
  84. CCenterSettingEntity* m_pEntity;
  85. };
  86. #endif /*RVC_MOD_CENTERSETTING_H__*/