ht_biz_config.go 1.1 KB

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