master
黄海 5 years ago
parent 88d2313586
commit 7f7ddfd6d4

@ -23,7 +23,7 @@ var db = DbUtil.Engine
/** /**
*/ */
func AddApp(appCode string, appName string, sortId int32) (string,error) { func AddApp(appCode string, appName string, sortId int32) (string, error) {
//生成AK+SK //生成AK+SK
ak := xid.New() ak := xid.New()
appKey := ak.String() //新增就生成一个secret appKey := ak.String() //新增就生成一个secret
@ -35,7 +35,7 @@ func AddApp(appCode string, appName string, sortId int32) (string,error) {
list, _ := db.SQL(sql, appCode).Query().List() list, _ := db.SQL(sql, appCode).Query().List()
count := list[0]["c"].(int64) count := list[0]["c"].(int64)
if count > 0 { if count > 0 {
return "",errors.New("系统代码已存在,请重新输入!") return "", errors.New("系统代码已存在,请重新输入!")
} }
//插入数据库数据 //插入数据库数据
model := new(models.TAppBase) model := new(models.TAppBase)
@ -47,7 +47,7 @@ func AddApp(appCode string, appName string, sortId int32) (string,error) {
if sortId == 0 { if sortId == 0 {
c, err := getMaxSortId() c, err := getMaxSortId()
if err != nil { if err != nil {
return model.AppId,err return model.AppId, err
} }
sortId = int32(c) sortId = int32(c)
} }
@ -55,11 +55,11 @@ func AddApp(appCode string, appName string, sortId int32) (string,error) {
model.BUse = 1 model.BUse = 1
_, err := db.Insert(model) _, err := db.Insert(model)
if err != nil { if err != nil {
return model.AppId,err return model.AppId, err
} }
//插入REDIS缓存 //插入REDIS缓存
err = insertRedisCache(model.AccessKey, model.SecretKey, model.RedirectUri) err = insertRedisCache(model.AccessKey, model.SecretKey, model.RedirectUri)
return model.AppId,err return model.AppId, err
} }
/** /**
@ -460,11 +460,7 @@ func insertRedisCache(accessKey string, secretKey string, redirectUri string) er
} }
defer resp.Body.Close() defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body) _, _ = ioutil.ReadAll(resp.Body)
if err != nil {
return err
}
fmt.Println(string(body))
return nil return nil
} }

Loading…
Cancel
Save