mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 03:24:26 +00:00
fa9f581d56
* chore: move to new org * logging * fix: org rename caos -> zitadel Co-authored-by: adlerhurst <silvan.reusser@gmail.com>
42 lines
948 B
Go
42 lines
948 B
Go
package view
|
|
|
|
import (
|
|
"database/sql"
|
|
|
|
"github.com/jinzhu/gorm"
|
|
|
|
"github.com/zitadel/zitadel/internal/crypto"
|
|
"github.com/zitadel/zitadel/internal/id"
|
|
"github.com/zitadel/zitadel/internal/query"
|
|
)
|
|
|
|
type View struct {
|
|
Db *gorm.DB
|
|
keyAlgorithm crypto.EncryptionAlgorithm
|
|
idGenerator id.Generator
|
|
prefixAvatarURL string
|
|
query *query.Queries
|
|
}
|
|
|
|
func StartView(sqlClient *sql.DB, keyAlgorithm crypto.EncryptionAlgorithm, queries *query.Queries, idGenerator id.Generator, prefixAvatarURL string) (*View, error) {
|
|
gorm, err := gorm.Open("postgres", sqlClient)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &View{
|
|
Db: gorm,
|
|
keyAlgorithm: keyAlgorithm,
|
|
idGenerator: idGenerator,
|
|
prefixAvatarURL: prefixAvatarURL,
|
|
query: queries,
|
|
}, nil
|
|
}
|
|
|
|
func (v *View) Health() (err error) {
|
|
return v.Db.DB().Ping()
|
|
}
|
|
|
|
func (v *View) PrefixAvatarURL() string {
|
|
return v.prefixAvatarURL
|
|
}
|