package tik_tok import ( "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/db" "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/db/model" "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md" zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils" "errors" "github.com/tidwall/gjson" "xorm.io/xorm" ) func Base(eg *xorm.Engine, dbName, unionId string) (*md.TikTokBase, error) { var cfg *model.SysUnionSet var err error if zhios_third_party_utils.StrToInt(unionId) == 0 { cfg, err = db.SysUnionByTikTokByUseByAuth(eg, dbName) } else { cfg = db.SysUnionById(eg, unionId) } if cfg == nil { return &md.TikTokBase{}, errors.New("没配置") } if err != nil { return &md.TikTokBase{}, err } var tmp = &md.TikTokBase{ AuthSubjectType: gjson.Get(cfg.KeyData, "authSubjectType").String(), LiveAuthSubjectType: gjson.Get(cfg.KeyData, "liveAuthSubjectType").String(), AuthType: zhios_third_party_utils.IntToStr(cfg.AuthType), LiveAuthType: zhios_third_party_utils.IntToStr(cfg.LiveAuthType), ApiGoodsAppKey: gjson.Get(cfg.KeyData, "apiGoodsAppKey").String(), ApiGoodsAppSecret: gjson.Get(cfg.KeyData, "apiGoodsAppSecret").String(), GoodsAccessToken: gjson.Get(cfg.KeyData, "goodsAccessToken").String(), GoodsPid: gjson.Get(cfg.KeyData, "goodsPid").String(), ApiLiveAppKey: gjson.Get(cfg.KeyData, "apiLiveAppKey").String(), ApiLiveAppSecret: gjson.Get(cfg.KeyData, "apiLiveAppSecret").String(), LiveAccessToken: gjson.Get(cfg.KeyData, "liveAccessToken").String(), LivePid: gjson.Get(cfg.KeyData, "livePid").String(), TeamAccessToken: gjson.Get(cfg.KeyData, "teamAccessToken").String(), ApiTeamAppKey: "7136155008692651560", ApiTeamAppSecret: "b132549f-f62c-491e-86f1-89af3658896a", SysApiGoodsAppKey: "7076371480799348261", SysApiGoodsAppSecret: "9e58409e-5729-441e-a9f3-c077ec939fbb", SysApiLiveAppKey: "7075886119509853704", SysApiLiveAppSecret: "77b4a105-ecc3-4389-a6a9-07b26e9d38b2", SysGoodsAccessToken: gjson.Get(cfg.KeyData, "sysGoodsAccessToken").String(), SysLiveAccessToken: gjson.Get(cfg.KeyData, "sysLiveAccessToken").String(), SysGoodsPid: gjson.Get(cfg.KeyData, "sysGoodsPid").String(), SysLivePid: gjson.Get(cfg.KeyData, "sysLivePid").String(), } if tmp.AuthType == "3" { tmp.ApiGoodsAppKey = tmp.SysApiGoodsAppKey tmp.ApiGoodsAppSecret = tmp.SysApiGoodsAppSecret tmp.GoodsAccessToken = tmp.SysGoodsAccessToken tmp.GoodsPid = tmp.SysGoodsPid } if tmp.LiveAuthType == "3" { tmp.ApiLiveAppKey = tmp.SysApiLiveAppKey tmp.ApiLiveAppSecret = tmp.SysApiLiveAppSecret tmp.LiveAccessToken = tmp.SysLiveAccessToken tmp.LivePid = tmp.SysLivePid } if tmp.AuthSubjectType == "DouKe" { tmp.ApiLiveAppKey = tmp.ApiGoodsAppKey tmp.ApiLiveAppSecret = tmp.ApiGoodsAppSecret tmp.LiveAccessToken = tmp.GoodsAccessToken tmp.LivePid = tmp.GoodsPid } return tmp, nil } func Base1(eg *xorm.Engine, id string) (*md.TikTokBase, error) { cfg, err := db.SysUnionByTikTokByUseByAuthId(eg, id) if err != nil || cfg == nil { return &md.TikTokBase{}, err } var tmp = &md.TikTokBase{ AuthSubjectType: gjson.Get(cfg.KeyData, "authSubjectType").String(), LiveAuthSubjectType: gjson.Get(cfg.KeyData, "liveAuthSubjectType").String(), AuthType: zhios_third_party_utils.IntToStr(cfg.AuthType), LiveAuthType: zhios_third_party_utils.IntToStr(cfg.LiveAuthType), ApiGoodsAppKey: gjson.Get(cfg.KeyData, "apiGoodsAppKey").String(), ApiGoodsAppSecret: gjson.Get(cfg.KeyData, "apiGoodsAppSecret").String(), GoodsAccessToken: gjson.Get(cfg.KeyData, "goodsAccessToken").String(), GoodsPid: gjson.Get(cfg.KeyData, "goodsPid").String(), ApiLiveAppKey: gjson.Get(cfg.KeyData, "apiLiveAppKey").String(), ApiLiveAppSecret: gjson.Get(cfg.KeyData, "apiLiveAppSecret").String(), LiveAccessToken: gjson.Get(cfg.KeyData, "liveAccessToken").String(), LivePid: gjson.Get(cfg.KeyData, "livePid").String(), TeamAccessToken: gjson.Get(cfg.KeyData, "teamAccessToken").String(), ApiTeamAppKey: "7136155008692651560", ApiTeamAppSecret: "b132549f-f62c-491e-86f1-89af3658896a", SysApiGoodsAppKey: "7076371480799348261", SysApiGoodsAppSecret: "9e58409e-5729-441e-a9f3-c077ec939fbb", SysApiLiveAppKey: "7075886119509853704", SysApiLiveAppSecret: "77b4a105-ecc3-4389-a6a9-07b26e9d38b2", SysGoodsAccessToken: gjson.Get(cfg.KeyData, "sysGoodsAccessToken").String(), SysLiveAccessToken: gjson.Get(cfg.KeyData, "sysLiveAccessToken").String(), SysGoodsPid: gjson.Get(cfg.KeyData, "sysGoodsPid").String(), SysLivePid: gjson.Get(cfg.KeyData, "sysLivePid").String(), } if tmp.AuthType == "3" { tmp.ApiGoodsAppKey = tmp.SysApiGoodsAppKey tmp.ApiGoodsAppSecret = tmp.SysApiGoodsAppSecret tmp.GoodsAccessToken = tmp.SysGoodsAccessToken tmp.GoodsPid = tmp.SysGoodsPid } if tmp.LiveAuthType == "3" { tmp.ApiLiveAppKey = tmp.SysApiLiveAppKey tmp.ApiLiveAppSecret = tmp.SysApiLiveAppSecret tmp.LiveAccessToken = tmp.SysLiveAccessToken tmp.LivePid = tmp.SysLivePid } if tmp.AuthSubjectType == "DouKe" { tmp.ApiLiveAppKey = tmp.ApiGoodsAppKey tmp.ApiLiveAppSecret = tmp.ApiGoodsAppSecret tmp.LiveAccessToken = tmp.GoodsAccessToken tmp.LivePid = tmp.GoodsPid } return tmp, nil }