Documentation
¶
Index ¶
- func CompressAudio(path string) (string, error)
- func CompressJpegImage(path string) (string, error)
- func GetUserIdFromContext(ctx context.Context) uuid.UUID
- func SetUserInContext(ctx context.Context, userId uuid.UUID) context.Context
- type AccessToken
- type AccessTokenCacheDs
- type AccessTokenDatabaseDs
- type AccessTokenRepository
- type CustomClaims
- type File
- type FileDatabaseDs
- type FileRepository
- type HashDatasource
- type JWTMetadata
- type JwtDatasource
- type Note
- type NoteCacheDs
- type NoteDatabaseDs
- type NoteRepository
- type RefreshToken
- type RefreshTokenCacheDs
- type RefreshTokenDatabaseDs
- type RefreshTokenRepository
- type User
- type UserCacheDs
- type UserDatabaseDs
- type UserRepository
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompressAudio ¶
CompressAudio compresses the audio file using ffmpeg
func CompressJpegImage ¶
CompressJPEGImage compresses the image file using "image/jpeg"
func GetUserIdFromContext ¶
Get user from context
Types ¶
type AccessToken ¶
type AccessToken struct {
Id uuid.UUID `json:"id"`
UserId uuid.UUID `json:"user_id"`
RefreshTokenId uuid.UUID `json:"refresh_token_id"`
CreateTime time.Time `json:"create_time"`
UpdateTime time.Time `json:"update_time"`
}
func NewAccessToken ¶
func NewAccessToken(userId uuid.UUID, refreshTokenId uuid.UUID) *AccessToken
NewAccessToken creates a new AccessToken instance
type AccessTokenCacheDs ¶
type AccessTokenDatabaseDs ¶
type AccessTokenDatabaseDs interface {
GetAccessTokenById(ctx context.Context, id uuid.UUID) (*AccessToken, error)
CreateAccessToken(ctx context.Context, tx *sql.Tx, accessToken *AccessToken) (*AccessToken, error)
DeleteAccessTokenByUserId(ctx context.Context, tx *sql.Tx, userId uuid.UUID) (*uuid.UUID, error)
}
type AccessTokenRepository ¶
type AccessTokenRepository interface {
GetAccessToken(ctx context.Context, id uuid.UUID) (*AccessToken, error)
CreateAccessToken(ctx context.Context, tx *sql.Tx, userId uuid.UUID, refreshTokenId uuid.UUID) (*AccessToken, error)
DeleteAccessTokenByUserId(ctx context.Context, tx *sql.Tx, userId uuid.UUID) error
}
func NewAccessTokenRepository ¶
func NewAccessTokenRepository(accessTokenCacheDs AccessTokenCacheDs, accessTokenDatabaseDs AccessTokenDatabaseDs) AccessTokenRepository
type CustomClaims ¶
type CustomClaims struct {
UserID string `json:"user_id"`
jwt.StandardClaims
}
CustomClaims defines the structure of the JWT claims
type File ¶
type File struct {
Id uuid.UUID `json:"id"`
NoteId uuid.UUID `json:"note_id"`
OriginalFile string `json:"original_file"`
ProcessedFile string `json:"processed_file"`
Url string `json:"url"`
CreateTime time.Time `json:"create_time"`
UpdateTime time.Time `json:"update_time"`
DeleteTime time.Time `json:"delete_time"`
}
type FileDatabaseDs ¶
type FileDatabaseDs interface {
ListFilesByNotesIds(ctx context.Context, noteId []uuid.UUID) (*[]File, error)
ListFilesByNoteId(ctx context.Context, noteId uuid.UUID) (*[]File, error)
CreateFile(ctx context.Context, tx *sql.Tx, file *File) (*File, error)
UpdateFileByOriginalId(ctx context.Context, tx *sql.Tx, originalFileId, processFileId string) (*File, error)
HardDeleteFilesByNoteId(ctx context.Context, tx *sql.Tx, noteId uuid.UUID) (*[]File, error)
}
type FileRepository ¶
type FileRepository interface {
Create(ctx context.Context, tx *sql.Tx, ossFileId, path string, noteID uuid.UUID) (*File, error)
Update() error
HardDeleteFiles(ctx context.Context, tx *sql.Tx, files *[]File) error
ListFilesByNoteId(ctx context.Context, noteId uuid.UUID) (*[]File, error)
ListFilesByNotesIds(ctx context.Context, noteId []uuid.UUID) (*[]File, error)
Move() error
Process(ctx context.Context, tx *sql.Tx, ossFileId string) error
}
func NewFileRepository ¶
func NewFileRepository(fileDatabaseDs FileDatabaseDs, objectStorageService oss.ObjectStorageService, cfg *config.Configuration) FileRepository
type HashDatasource ¶
type HashDatasource interface {
// Hash takes a string value and returns its hash representation.
// It returns an error if the hashing operation fails.
Hash(value string) (string, error)
// CheckHash verifies if the given hash matches the hash of the provided value.
// It returns true if the hash matches, false otherwise.
CheckHash(value, hash string) (bool, error)
}
HashDatasource defines the methods for hashing values and checking hashes. Implementations of this interface should provide mechanisms to hash values and verify if a given hash matches a hashed value.
type JwtDatasource ¶
type JwtDatasource interface {
CreateJWT(tokenMetadata *JWTMetadata, expirationTime time.Time) (*string, error)
ParseJWT(tokenMetadata *JWTMetadata) error
}
func NewJWTDatasource ¶
func NewJWTDatasource(cfg *config.Configuration) JwtDatasource
type NoteCacheDs ¶
type NoteDatabaseDs ¶
type NoteDatabaseDs interface {
ListNotesByUser(ctx context.Context, user_id uuid.UUID, cursor time.Time) (*[]Note, error)
ListTrashNotesByUser(ctx context.Context, user_id uuid.UUID, cursor time.Time) (*[]Note, error)
GetNote(ctx context.Context, id uuid.UUID) (*Note, error)
CreateNote(ctx context.Context, tx *sql.Tx, note *Note) (*Note, error)
UpdateNote(ctx context.Context, tx *sql.Tx, note *Note) (*Note, error)
RestoreNote(ctx context.Context, tx *sql.Tx, id uuid.UUID) (*Note, error)
HardDeleteNote(ctx context.Context, tx *sql.Tx, id uuid.UUID) error
SoftDeleteNote(ctx context.Context, tx *sql.Tx, id uuid.UUID) error
}
type NoteRepository ¶
type NoteRepository interface {
ListNotesByUser(ctx context.Context, user_id uuid.UUID, cursor time.Time) (*[]Note, error)
ListTrashNotesByUser(ctx context.Context, user_id uuid.UUID, cursor time.Time) (*[]Note, error)
// GetNote(ctx context.Context, id uuid.UUID) (*Note, error)
CreateNote(ctx context.Context, tx *sql.Tx, note *Note) (*Note, error)
RestoreNote(ctx context.Context, tx *sql.Tx, id uuid.UUID) (*Note, error)
UpdateNote(ctx context.Context, tx *sql.Tx, note *Note) (*Note, error)
DeleteNote(ctx context.Context, tx *sql.Tx, id uuid.UUID, isHard bool) error
}
func NewNoteRepository ¶
func NewNoteRepository(noteCacheDs *NoteCacheDs, noteDatabaseDs *NoteDatabaseDs) NoteRepository
type RefreshToken ¶
type RefreshTokenCacheDs ¶
type RefreshTokenDatabaseDs ¶
type RefreshTokenDatabaseDs interface {
GetRefreshTokenById(ctx context.Context, id uuid.UUID) (*RefreshToken, error)
CreateRefreshToken(ctx context.Context, tx *sql.Tx, refreshToken *RefreshToken) (*RefreshToken, error)
DeleteRefreshTokenByUserId(ctx context.Context, tx *sql.Tx, userId uuid.UUID) (*uuid.UUID, error)
}
type RefreshTokenRepository ¶
type RefreshTokenRepository interface {
GetRefreshToken(ctx context.Context, id uuid.UUID) (*RefreshToken, error)
CreateRefreshToken(ctx context.Context, tx *sql.Tx, refreshToken *RefreshToken) (*RefreshToken, error)
DeleteRefreshTokenByUserId(ctx context.Context, tx *sql.Tx, userId uuid.UUID) error
}
func NewRefreshTokenRepository ¶
func NewRefreshTokenRepository(refreshTokenCacheDs *RefreshTokenCacheDs, refreshTokenDatabaseDs *RefreshTokenDatabaseDs) RefreshTokenRepository
type UserCacheDs ¶
type UserCacheDs interface {
GetUserByEmail(ctx context.Context, email string) (*User, error)
GetUserById(ctx context.Context, id uuid.UUID) (*User, error)
CreateUser(ctx context.Context, user *User) error
UpdateUser(ctx context.Context, user *User) error
DeleteUser(ctx context.Context, id uuid.UUID) error
}
type UserDatabaseDs ¶
type UserRepository ¶
type UserRepository interface {
CreateUser(ctx context.Context, user *User) (*User, error)
GetUserById(ctx context.Context, id uuid.UUID) (*User, error)
GetUserByEmail(ctx context.Context, email string) (*User, error)
}
func NewUserRepository ¶
func NewUserRepository(userCacheDs *UserCacheDs, userDatabaseDs *UserDatabaseDs) UserRepository
Source Files
¶
- access_token.go
- access_token_cache_ds.go
- access_token_database_ds.go
- access_token_repository.go
- file.go
- file_database_ds.go
- file_repository.go
- hash_datasource.go
- jwt_ds.go
- note.go
- note_cache_ds.go
- note_database_ds.go
- note_repository.go
- refresh_token.go
- refresh_token_cache_ds.go
- refresh_token_database_ds.go
- refresh_token_repository.go
- user.go
- user_cache_ds.go
- user_database_ds.go
- user_repository.go
- utils.go
Click to show internal directories.
Click to hide internal directories.