ht_biz_config.go 2.0 KB

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