ht_biz_config.go 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. package config
  2. import "eta/eta_mini_ht_api/common/contants"
  3. // ESOpts es连接属性
  4. type HTOpts struct {
  5. ReportIndex string
  6. MediaIndex string
  7. ChartIndex string
  8. Encode string
  9. DesCode string
  10. Task string
  11. AccountApiUrl string
  12. PaymentApiUrl string
  13. WebhookPrivateKey string
  14. WebhookPublicKey string
  15. AccountInfoUrl string
  16. CapAppId string
  17. CapSecretKey string
  18. PaymentAppId string
  19. PaymentSign string
  20. MerchantId string
  21. }
  22. type HTBizConfig struct {
  23. BaseConfig
  24. opts HTOpts
  25. }
  26. func (e *HTBizConfig) GetReportIndex() string {
  27. return e.opts.ReportIndex
  28. }
  29. func (e *HTBizConfig) GetMediaIndex() string {
  30. return e.opts.MediaIndex
  31. }
  32. func (e *HTBizConfig) GetChartIndex() string {
  33. return e.opts.ChartIndex
  34. }
  35. func (e *HTBizConfig) GetAccountInfoUrl() string {
  36. return e.opts.AccountInfoUrl
  37. }
  38. func (e *HTBizConfig) NeedEncode() bool {
  39. if e.opts.Encode == "true" {
  40. return true
  41. }
  42. return false
  43. }
  44. func (e *HTBizConfig) EnableTask() bool {
  45. if e.opts.Task == "true" {
  46. return true
  47. }
  48. return false
  49. }
  50. func (e *HTBizConfig) GetWebhookPrivateKey() string {
  51. return e.opts.WebhookPrivateKey
  52. }
  53. func (e *HTBizConfig) GetWebhookPublicKey() string {
  54. return e.opts.WebhookPublicKey
  55. }
  56. func (e *HTBizConfig) GetAccountApiUrl() string {
  57. return e.opts.AccountApiUrl
  58. }
  59. func (e *HTBizConfig) GetMerchantId() string {
  60. return e.opts.MerchantId
  61. }
  62. func (e *HTBizConfig) GetPaymentApiUrl() string {
  63. return e.opts.PaymentApiUrl
  64. }
  65. func (e *HTBizConfig) GetPaymentAppId() string {
  66. return e.opts.PaymentAppId
  67. }
  68. func (e *HTBizConfig) GetPaymentSign() string {
  69. return e.opts.PaymentSign
  70. }
  71. func (e *HTBizConfig) GetAppId() string {
  72. return e.opts.CapAppId
  73. }
  74. func (e *HTBizConfig) GetSecretKey() string {
  75. return e.opts.CapSecretKey
  76. }
  77. func (e *HTBizConfig) GetDesCode() string {
  78. return e.opts.DesCode
  79. }
  80. func (e *HTBizConfig) InitConfig() {
  81. opts := HTOpts{
  82. ReportIndex: e.GetString("es_report_index"),
  83. MediaIndex: e.GetString("es_media_index"),
  84. ChartIndex: e.GetString("es_chart_index"),
  85. Encode: e.GetString("response.encode"),
  86. DesCode: e.GetString("response.des_code"),
  87. Task: e.GetString("task"),
  88. AccountApiUrl: e.GetString("api.account_url"),
  89. WebhookPrivateKey: e.GetString("webhook.private_key"),
  90. WebhookPublicKey: e.GetString("webhook.public_key"),
  91. AccountInfoUrl: e.GetString("api.account_url"),
  92. PaymentApiUrl: e.GetString("api.payment_url"),
  93. CapAppId: e.GetString("api.app_id"),
  94. CapSecretKey: e.GetString("api.secret_key"),
  95. PaymentAppId: e.GetString("api.payment_app_id"),
  96. PaymentSign: e.GetString("api.payment_secret_key"),
  97. MerchantId: e.GetString("merchant_id"),
  98. }
  99. e.opts = opts
  100. }
  101. func NewHT() Config {
  102. return &HTBizConfig{
  103. BaseConfig: BaseConfig{prefix: contants.HT},
  104. opts: HTOpts{},
  105. }
  106. }
  107. func init() {
  108. Register(contants.HT, NewHT)
  109. }