diff --git a/app/db/db_master_list_cfg.go b/app/db/db_master_list_cfg.go index ce4ced2..f8a9452 100644 --- a/app/db/db_master_list_cfg.go +++ b/app/db/db_master_list_cfg.go @@ -98,3 +98,34 @@ func (masterListCfgDb *MasterListCfgDb) MasterListCfgDel(HKey string) error { } return nil } + +func MasterListCfgGetOneData(uid, key string) string { + var cfgList model.MasterListCfg + has, err := ZhimengDb.Where("`k`=? and uid=?", key, uid).Get(&cfgList) + if err != nil { + return "" + } + if has == false { + cfgList = model.MasterListCfg{Uid: uid, K: key} + ZhimengDb.InsertOne(&cfgList) + } + return cfgList.V +} +func MasterListCfgGetKeyAll(key string) *[]model.MasterListCfg { + var cfgList []model.MasterListCfg + err := ZhimengDb.Where("`k`=? ", key).Find(&cfgList) + if err != nil { + return nil + } + return &cfgList +} +func MasterListCfgSave(uid, key, val string) { + var cfgList model.MasterListCfg + has, err := ZhimengDb.Where("`k`=? and uid=?", key, uid).Get(&cfgList) + if err != nil || has == false { + return + } + cfgList.V = val + ZhimengDb.Where("`k`=? and uid=?", key, uid).Update(&cfgList) + return +} diff --git a/app/hdl/hdl_kuaishou_auth.go b/app/hdl/hdl_kuaishou_auth.go index be44442..bb9da65 100644 --- a/app/hdl/hdl_kuaishou_auth.go +++ b/app/hdl/hdl_kuaishou_auth.go @@ -1,19 +1,16 @@ package hdl import ( - offical "applet/app/db/official" + "applet/app/db" "github.com/gin-gonic/gin" ) func KuaishouAuth(c *gin.Context) { - kuaishouOfficialAccessToken := offical.MasterListCfgGetOneData("0", "kuaishou_official_access_token") - kuaishouOfficialAccessToken = c.PostForm("access_token") - offical.MasterListCfgSave("0", "kuaishou_official_access_token", kuaishouOfficialAccessToken) - kuaishouOfficialExpiresIn := offical.MasterListCfgGetOneData("0", "kuaishou_official_expires_in") - kuaishouOfficialExpiresIn = c.PostForm("expires_in") - offical.MasterListCfgSave("0", "kuaishou_official_expires_in", kuaishouOfficialExpiresIn) - kuaishouOfficialRefreshToken := offical.MasterListCfgGetOneData("0", "kuaishou_official_refresh_token") - kuaishouOfficialRefreshToken = c.PostForm("refresh_token") - offical.MasterListCfgSave("0", "kuaishou_official_refresh_token", kuaishouOfficialRefreshToken) + kuaishouOfficialAccessToken := c.PostForm("access_token") + db.MasterListCfgSave("0", "kuaishou_official_access_token", kuaishouOfficialAccessToken) + kuaishouOfficialExpiresIn := c.PostForm("expires_in") + db.MasterListCfgSave("0", "kuaishou_official_expires_in", kuaishouOfficialExpiresIn) + kuaishouOfficialRefreshToken := c.PostForm("refresh_token") + db.MasterListCfgSave("0", "kuaishou_official_refresh_token", kuaishouOfficialRefreshToken) return }