ht_biz_config.go 1.7 KB

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