|
|
|
@ -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 := xid.New()
|
|
|
|
|
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()
|
|
|
|
|
count := list[0]["c"].(int64)
|
|
|
|
|
if count > 0 {
|
|
|
|
|
return "",errors.New("系统代码已存在,请重新输入!")
|
|
|
|
|
return "", errors.New("系统代码已存在,请重新输入!")
|
|
|
|
|
}
|
|
|
|
|
//插入数据库数据
|
|
|
|
|
model := new(models.TAppBase)
|
|
|
|
@ -47,7 +47,7 @@ func AddApp(appCode string, appName string, sortId int32) (string,error) {
|
|
|
|
|
if sortId == 0 {
|
|
|
|
|
c, err := getMaxSortId()
|
|
|
|
|
if err != nil {
|
|
|
|
|
return model.AppId,err
|
|
|
|
|
return model.AppId, err
|
|
|
|
|
}
|
|
|
|
|
sortId = int32(c)
|
|
|
|
|
}
|
|
|
|
@ -55,11 +55,11 @@ func AddApp(appCode string, appName string, sortId int32) (string,error) {
|
|
|
|
|
model.BUse = 1
|
|
|
|
|
_, err := db.Insert(model)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return model.AppId,err
|
|
|
|
|
return model.AppId, err
|
|
|
|
|
}
|
|
|
|
|
//插入REDIS缓存
|
|
|
|
|
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()
|
|
|
|
|
body, err := ioutil.ReadAll(resp.Body)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
fmt.Println(string(body))
|
|
|
|
|
_, _ = ioutil.ReadAll(resp.Body)
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|