ht_biz_config.go 2.8 KB

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