package AccessSystemDao import ( "dsSupport/Utils/CommonUtil" "dsSupport/Utils/DbUtil" "dsSupport/models" "github.com/oklog/ulid" "github.com/rs/xid" "math/rand" "strings" "time" ) var db = DbUtil.Engine /** 功能:增加一个接入系统 */ func AddApp(appCode string, appName string, appUrl string, appIcon string, redirectUri string) error { //生成AK+SK ak := xid.New() appKey := ak.String() //新增就生成一个secret t := time.Now().UTC() entropy := rand.New(rand.NewSource(t.UnixNano())) appSecret := strings.ToLower(ulid.MustNew(ulid.Timestamp(t), entropy).String()) //插入数据库数据 model := new(models.TAppBase) model.AppId = CommonUtil.GetUUID() model.AppCode = appCode model.AppName = appName model.AccessKey = appKey model.SecretKey = appSecret model.AppUrl = appUrl model.AppIcon = appIcon model.RedirectUri = redirectUri model.BUse = 1 _, err := db.Insert(&model) //插入REDIS缓存 //TODO return err } /** 功能:删除一个接入系统 */ func DelApp(appId string) error { model := new(models.TAppBase) _, err := db.ID(appId).Delete(model) //删除REDIS缓存 //TODO return err } /** 功能:修改一个接入系统 */ func UpdateApp() { } /** 功能:列表查询AppList */ func ListApp() { }