ht_biz_config.go 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. WebhookPrivateKey string
  12. WebhookPublicKey string
  13. AccountInfoUrl string
  14. CapAppId string
  15. CapSecretKey string
  16. }
  17. type HTBizConfig struct {
  18. BaseConfig
  19. opts HTOpts
  20. }
  21. func (e *HTBizConfig) GetReportIndex() string {
  22. return e.opts.ReportIndex
  23. }
  24. func (e *HTBizConfig) GetMediaIndex() string {
  25. return e.opts.MediaIndex
  26. }
  27. func (e *HTBizConfig) GetAccountInfoUrl() string {
  28. return e.opts.AccountInfoUrl
  29. }
  30. func (e *HTBizConfig) NeedEncode() bool {
  31. if e.opts.Encode == "true" {
  32. return true
  33. }
  34. return false
  35. }
  36. func (e *HTBizConfig) EnableTask() bool {
  37. if e.opts.Task == "true" {
  38. return true
  39. }
  40. return false
  41. }
  42. func (e *HTBizConfig) GetWebhookPrivateKey() string {
  43. return e.opts.WebhookPrivateKey
  44. }
  45. func (e *HTBizConfig) GetWebhookPublicKey() string {
  46. return e.opts.WebhookPublicKey
  47. }
  48. func (e *HTBizConfig) GetAccountApiUrl() string {
  49. return e.opts.AccountApiUrl
  50. }
  51. func (e *HTBizConfig) GetAppId() string {
  52. return e.opts.CapAppId
  53. }
  54. func (e *HTBizConfig) GetSecretKey() string {
  55. return e.opts.CapSecretKey
  56. }
  57. func (e *HTBizConfig) GetDesCode() string {
  58. return e.opts.DesCode
  59. }
  60. func (e *HTBizConfig) InitConfig() {
  61. opts := HTOpts{
  62. ReportIndex: e.GetString("es_report_index"),
  63. MediaIndex: e.GetString("es_media_index"),
  64. Encode: e.GetString("response.encode"),
  65. DesCode: e.GetString("response.des_code"),
  66. Task: e.GetString("task"),
  67. AccountApiUrl: e.GetString("api.account_url"),
  68. WebhookPrivateKey: e.GetString("webhook.private_key"),
  69. WebhookPublicKey: e.GetString("webhook.public_key"),
  70. AccountInfoUrl: e.GetString("api.account_url"),
  71. CapAppId: e.GetString("api.app_id"),
  72. CapSecretKey: e.GetString("api.secret_key"),
  73. }
  74. e.opts = opts
  75. }
  76. func NewHT() Config {
  77. return &HTBizConfig{
  78. BaseConfig: BaseConfig{prefix: contants.HT},
  79. opts: HTOpts{},
  80. }
  81. }
  82. func init() {
  83. Register(contants.HT, NewHT)
  84. }