master
黄海 5 years ago
parent 9677299b44
commit d9ac35b0da

@ -1,9 +1,11 @@
package DaoAppBase package DaoAppBase
import ( import (
"dsSso/Const/ErrorConst"
"dsSso/Dao/DaoCache" "dsSso/Dao/DaoCache"
"dsSso/Model" "dsSso/Model"
"dsSso/Utils/DbUtil" "dsSso/Utils/DbUtil"
"dsSso/Utils/LogUtil"
) )
var joinModel Model.Selector var joinModel Model.Selector
@ -34,6 +36,18 @@ func GetAppBaseList(page int, limit int, keyword string) ([]map[string]interface
return list, count return list, count
} }
/**
*/
func GetAppBaseListFromDb() ([]map[string]interface{}, error) {
baseSql := "select * from t_app_base where b_use=1"
list, err := db.SQL(baseSql).Query().List()
if err != nil {
LogUtil.Error(ErrorConst.SqlQueryError, err.Error())
}
return list, err
}
/** /**
appId appId

@ -1,16 +1,14 @@
package main package main
import ( import (
"dsSso/Const/ErrorConst"
c "dsSso/Controller" c "dsSso/Controller"
"dsSso/Dao/DaoAppBase"
"dsSso/Handler" "dsSso/Handler"
"dsSso/Middleware" "dsSso/Middleware"
"dsSso/Service/ServiceJoinApp"
"dsSso/Utils" "dsSso/Utils"
"dsSso/Utils/ConfigUtil" "dsSso/Utils/ConfigUtil"
"dsSso/Utils/DbUtil" "dsSso/Utils/DbUtil"
"dsSso/Utils/FileUtil" "dsSso/Utils/FileUtil"
"dsSso/Utils/LogUtil"
"dsSso/Utils/RedisStorage" "dsSso/Utils/RedisStorage"
"dsSso/Utils/RedisUtil" "dsSso/Utils/RedisUtil"
"fmt" "fmt"
@ -32,16 +30,6 @@ var db = DbUtil.Engine
2020-03-25 2020-03-25
*/ */
func startOAuth2Server() { func startOAuth2Server() {
//清除系统的缓存
baseSql := "select app_id from t_app_base where b_use=1"
list, err := db.SQL(baseSql).Query().List()
if err != nil {
LogUtil.Error(ErrorConst.SqlQueryError, err.Error())
}
for i := 0; i < len(list); i++ {
RedisUtil.DEL("TAppBase:" + list[i]["app_id"].(string))
}
//声明OAuth2的Redis存储器 //声明OAuth2的Redis存储器
RedisStorage.OAuth2RedisStorage = &RedisStorage.RedisStorage{ RedisStorage.OAuth2RedisStorage = &RedisStorage.RedisStorage{
Pool: RedisUtil.Pool, Pool: RedisUtil.Pool,
@ -55,7 +43,7 @@ func startOAuth2Server() {
RedisStorage.OsinServer = osin.NewServer(cfg, RedisStorage.OAuth2RedisStorage) RedisStorage.OsinServer = osin.NewServer(cfg, RedisStorage.OAuth2RedisStorage)
//这里需要循环从数据库中获取数据 //这里需要循环从数据库中获取数据
list, _ = ServiceJoinApp.GetAppBaseList(1, 1000, "") list, _ := DaoAppBase.GetAppBaseListFromDb()
for i := 0; i < len(list); i++ { for i := 0; i < len(list); i++ {
appKey := list[i]["access_key"].(string) appKey := list[i]["access_key"].(string)
secret := list[i]["secret_key"].(string) secret := list[i]["secret_key"].(string)
@ -106,11 +94,7 @@ func main() {
//每隔一分钟对redis中的app接入系统数据进行重新加载 //每隔一分钟对redis中的app接入系统数据进行重新加载
func SyncAppRedis() { func SyncAppRedis() {
baseSql := "select * from t_app_base where b_use=1" list, _ := DaoAppBase.GetAppBaseListFromDb()
list, err := db.SQL(baseSql).Query().List()
if err != nil {
LogUtil.Error(ErrorConst.SqlQueryError, err.Error())
}
for i := 0; i < len(list); i++ { for i := 0; i < len(list); i++ {
appKey := list[i]["access_key"].(string) appKey := list[i]["access_key"].(string)
secret := list[i]["secret_key"].(string) secret := list[i]["secret_key"].(string)

Loading…
Cancel
Save