ht_biz_config.go 1.3 KB

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