第三方api接口
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123 рядки
5.4 KiB

  1. package tik_tok
  2. import (
  3. "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/db"
  4. "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/db/model"
  5. "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md"
  6. zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
  7. "errors"
  8. "github.com/tidwall/gjson"
  9. "xorm.io/xorm"
  10. )
  11. func Base(eg *xorm.Engine, dbName, unionId string) (*md.TikTokBase, error) {
  12. var cfg *model.SysUnionSet
  13. var err error
  14. if zhios_third_party_utils.StrToInt(unionId) == 0 {
  15. cfg, err = db.SysUnionByTikTokByUseByAuth(eg, dbName)
  16. } else {
  17. cfg = db.SysUnionById(eg, unionId)
  18. }
  19. if cfg == nil {
  20. return &md.TikTokBase{}, errors.New("没配置")
  21. }
  22. if err != nil {
  23. return &md.TikTokBase{}, err
  24. }
  25. var tmp = &md.TikTokBase{
  26. AuthSubjectType: gjson.Get(cfg.KeyData, "authSubjectType").String(),
  27. LiveAuthSubjectType: gjson.Get(cfg.KeyData, "liveAuthSubjectType").String(),
  28. AuthType: zhios_third_party_utils.IntToStr(cfg.AuthType),
  29. LiveAuthType: zhios_third_party_utils.IntToStr(cfg.LiveAuthType),
  30. ApiGoodsAppKey: gjson.Get(cfg.KeyData, "apiGoodsAppKey").String(),
  31. ApiGoodsAppSecret: gjson.Get(cfg.KeyData, "apiGoodsAppSecret").String(),
  32. GoodsAccessToken: gjson.Get(cfg.KeyData, "goodsAccessToken").String(),
  33. GoodsPid: gjson.Get(cfg.KeyData, "goodsPid").String(),
  34. ApiLiveAppKey: gjson.Get(cfg.KeyData, "apiLiveAppKey").String(),
  35. ApiLiveAppSecret: gjson.Get(cfg.KeyData, "apiLiveAppSecret").String(),
  36. LiveAccessToken: gjson.Get(cfg.KeyData, "liveAccessToken").String(),
  37. LivePid: gjson.Get(cfg.KeyData, "livePid").String(),
  38. TeamAccessToken: gjson.Get(cfg.KeyData, "teamAccessToken").String(),
  39. ApiTeamAppKey: "7136155008692651560",
  40. ApiTeamAppSecret: "b132549f-f62c-491e-86f1-89af3658896a",
  41. SysApiGoodsAppKey: "7076371480799348261",
  42. SysApiGoodsAppSecret: "9e58409e-5729-441e-a9f3-c077ec939fbb",
  43. SysApiLiveAppKey: "7075886119509853704",
  44. SysApiLiveAppSecret: "77b4a105-ecc3-4389-a6a9-07b26e9d38b2",
  45. SysGoodsAccessToken: gjson.Get(cfg.KeyData, "sysGoodsAccessToken").String(),
  46. SysLiveAccessToken: gjson.Get(cfg.KeyData, "sysLiveAccessToken").String(),
  47. SysGoodsPid: gjson.Get(cfg.KeyData, "sysGoodsPid").String(),
  48. SysLivePid: gjson.Get(cfg.KeyData, "sysLivePid").String(),
  49. }
  50. if tmp.AuthType == "3" {
  51. tmp.ApiGoodsAppKey = tmp.SysApiGoodsAppKey
  52. tmp.ApiGoodsAppSecret = tmp.SysApiGoodsAppSecret
  53. tmp.GoodsAccessToken = tmp.SysGoodsAccessToken
  54. tmp.GoodsPid = tmp.SysGoodsPid
  55. }
  56. if tmp.LiveAuthType == "3" {
  57. tmp.ApiLiveAppKey = tmp.SysApiLiveAppKey
  58. tmp.ApiLiveAppSecret = tmp.SysApiLiveAppSecret
  59. tmp.LiveAccessToken = tmp.SysLiveAccessToken
  60. tmp.LivePid = tmp.SysLivePid
  61. }
  62. if tmp.AuthSubjectType == "DouKe" {
  63. tmp.ApiLiveAppKey = tmp.ApiGoodsAppKey
  64. tmp.ApiLiveAppSecret = tmp.ApiGoodsAppSecret
  65. tmp.LiveAccessToken = tmp.GoodsAccessToken
  66. tmp.LivePid = tmp.GoodsPid
  67. }
  68. return tmp, nil
  69. }
  70. func Base1(eg *xorm.Engine, id string) (*md.TikTokBase, error) {
  71. cfg, err := db.SysUnionByTikTokByUseByAuthId(eg, id)
  72. if err != nil || cfg == nil {
  73. return &md.TikTokBase{}, err
  74. }
  75. var tmp = &md.TikTokBase{
  76. AuthSubjectType: gjson.Get(cfg.KeyData, "authSubjectType").String(),
  77. LiveAuthSubjectType: gjson.Get(cfg.KeyData, "liveAuthSubjectType").String(),
  78. AuthType: zhios_third_party_utils.IntToStr(cfg.AuthType),
  79. LiveAuthType: zhios_third_party_utils.IntToStr(cfg.LiveAuthType),
  80. ApiGoodsAppKey: gjson.Get(cfg.KeyData, "apiGoodsAppKey").String(),
  81. ApiGoodsAppSecret: gjson.Get(cfg.KeyData, "apiGoodsAppSecret").String(),
  82. GoodsAccessToken: gjson.Get(cfg.KeyData, "goodsAccessToken").String(),
  83. GoodsPid: gjson.Get(cfg.KeyData, "goodsPid").String(),
  84. ApiLiveAppKey: gjson.Get(cfg.KeyData, "apiLiveAppKey").String(),
  85. ApiLiveAppSecret: gjson.Get(cfg.KeyData, "apiLiveAppSecret").String(),
  86. LiveAccessToken: gjson.Get(cfg.KeyData, "liveAccessToken").String(),
  87. LivePid: gjson.Get(cfg.KeyData, "livePid").String(),
  88. TeamAccessToken: gjson.Get(cfg.KeyData, "teamAccessToken").String(),
  89. ApiTeamAppKey: "7136155008692651560",
  90. ApiTeamAppSecret: "b132549f-f62c-491e-86f1-89af3658896a",
  91. SysApiGoodsAppKey: "7076371480799348261",
  92. SysApiGoodsAppSecret: "9e58409e-5729-441e-a9f3-c077ec939fbb",
  93. SysApiLiveAppKey: "7075886119509853704",
  94. SysApiLiveAppSecret: "77b4a105-ecc3-4389-a6a9-07b26e9d38b2",
  95. SysGoodsAccessToken: gjson.Get(cfg.KeyData, "sysGoodsAccessToken").String(),
  96. SysLiveAccessToken: gjson.Get(cfg.KeyData, "sysLiveAccessToken").String(),
  97. SysGoodsPid: gjson.Get(cfg.KeyData, "sysGoodsPid").String(),
  98. SysLivePid: gjson.Get(cfg.KeyData, "sysLivePid").String(),
  99. }
  100. if tmp.AuthType == "3" {
  101. tmp.ApiGoodsAppKey = tmp.SysApiGoodsAppKey
  102. tmp.ApiGoodsAppSecret = tmp.SysApiGoodsAppSecret
  103. tmp.GoodsAccessToken = tmp.SysGoodsAccessToken
  104. tmp.GoodsPid = tmp.SysGoodsPid
  105. }
  106. if tmp.LiveAuthType == "3" {
  107. tmp.ApiLiveAppKey = tmp.SysApiLiveAppKey
  108. tmp.ApiLiveAppSecret = tmp.SysApiLiveAppSecret
  109. tmp.LiveAccessToken = tmp.SysLiveAccessToken
  110. tmp.LivePid = tmp.SysLivePid
  111. }
  112. if tmp.AuthSubjectType == "DouKe" {
  113. tmp.ApiLiveAppKey = tmp.ApiGoodsAppKey
  114. tmp.ApiLiveAppSecret = tmp.ApiGoodsAppSecret
  115. tmp.LiveAccessToken = tmp.GoodsAccessToken
  116. tmp.LivePid = tmp.GoodsPid
  117. }
  118. return tmp, nil
  119. }