Browse Source

更新

master
huangjiajun 7 months ago
parent
commit
c7ce4c6b25
2 changed files with 38 additions and 10 deletions
  1. +31
    -0
      app/db/db_master_list_cfg.go
  2. +7
    -10
      app/hdl/hdl_kuaishou_auth.go

+ 31
- 0
app/db/db_master_list_cfg.go View File

@@ -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
}

+ 7
- 10
app/hdl/hdl_kuaishou_auth.go View File

@@ -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
}

Loading…
Cancel
Save