瀏覽代碼

更新

master
huangjiajun 7 月之前
父節點
當前提交
c7ce4c6b25
共有 2 個檔案被更改,包括 38 行新增10 行删除
  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 查看文件

@@ -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 查看文件

@@ -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…
取消
儲存