2020-11-08 12:12:49 +03:00
|
|
|
package repositories
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/muety/wakapi/models"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
type IAliasRepository interface {
|
2021-01-21 02:26:52 +03:00
|
|
|
Insert(*models.Alias) (*models.Alias, error)
|
|
|
|
Delete(uint) error
|
|
|
|
DeleteBatch([]uint) error
|
2021-04-18 11:59:13 +03:00
|
|
|
GetAll() ([]*models.Alias, error)
|
2020-11-08 12:12:49 +03:00
|
|
|
GetByUser(string) ([]*models.Alias, error)
|
2021-01-21 02:26:52 +03:00
|
|
|
GetByUserAndKey(string, string) ([]*models.Alias, error)
|
|
|
|
GetByUserAndKeyAndType(string, string, uint8) ([]*models.Alias, error)
|
|
|
|
GetByUserAndTypeAndValue(string, uint8, string) (*models.Alias, error)
|
2020-11-08 12:12:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
type IHeartbeatRepository interface {
|
|
|
|
InsertBatch([]*models.Heartbeat) error
|
2021-04-18 11:59:13 +03:00
|
|
|
GetAll() ([]*models.Heartbeat, error)
|
2020-11-08 12:12:49 +03:00
|
|
|
GetAllWithin(time.Time, time.Time, *models.User) ([]*models.Heartbeat, error)
|
|
|
|
GetFirstByUsers() ([]*models.TimeByUser, error)
|
2021-02-13 13:23:58 +03:00
|
|
|
GetLastByUsers() ([]*models.TimeByUser, error)
|
2021-02-06 02:31:30 +03:00
|
|
|
GetLatestByOriginAndUser(string, *models.User) (*models.Heartbeat, error)
|
2021-02-13 13:23:58 +03:00
|
|
|
Count() (int64, error)
|
|
|
|
CountByUser(*models.User) (int64, error)
|
|
|
|
CountByUsers([]*models.User) ([]*models.CountByUser, error)
|
2020-11-08 12:12:49 +03:00
|
|
|
DeleteBefore(time.Time) error
|
|
|
|
}
|
|
|
|
|
|
|
|
type IKeyValueRepository interface {
|
2021-04-18 11:59:13 +03:00
|
|
|
GetAll() ([]*models.KeyStringValue, error)
|
2020-11-08 12:12:49 +03:00
|
|
|
GetString(string) (*models.KeyStringValue, error)
|
|
|
|
PutString(*models.KeyStringValue) error
|
|
|
|
DeleteString(string) error
|
|
|
|
}
|
|
|
|
|
|
|
|
type ILanguageMappingRepository interface {
|
2021-04-18 11:59:13 +03:00
|
|
|
GetAll() ([]*models.LanguageMapping, error)
|
2020-11-08 12:12:49 +03:00
|
|
|
GetById(uint) (*models.LanguageMapping, error)
|
|
|
|
GetByUser(string) ([]*models.LanguageMapping, error)
|
|
|
|
Insert(*models.LanguageMapping) (*models.LanguageMapping, error)
|
|
|
|
Delete(uint) error
|
|
|
|
}
|
|
|
|
|
|
|
|
type ISummaryRepository interface {
|
|
|
|
Insert(*models.Summary) error
|
2021-04-18 11:59:13 +03:00
|
|
|
GetAll() ([]*models.Summary, error)
|
2020-11-08 12:12:49 +03:00
|
|
|
GetByUserWithin(*models.User, time.Time, time.Time) ([]*models.Summary, error)
|
|
|
|
GetLastByUser() ([]*models.TimeByUser, error)
|
|
|
|
DeleteByUser(string) error
|
|
|
|
}
|
|
|
|
|
|
|
|
type IUserRepository interface {
|
|
|
|
GetById(string) (*models.User, error)
|
2021-02-13 13:23:58 +03:00
|
|
|
GetByIds([]string) ([]*models.User, error)
|
2020-11-08 12:12:49 +03:00
|
|
|
GetByApiKey(string) (*models.User, error)
|
2021-04-05 23:57:57 +03:00
|
|
|
GetByEmail(string) (*models.User, error)
|
|
|
|
GetByResetToken(string) (*models.User, error)
|
2020-11-08 12:12:49 +03:00
|
|
|
GetAll() ([]*models.User, error)
|
2021-02-13 01:06:48 +03:00
|
|
|
GetByLoggedInAfter(time.Time) ([]*models.User, error)
|
2021-02-13 13:23:58 +03:00
|
|
|
GetByLastActiveAfter(time.Time) ([]*models.User, error)
|
2021-02-12 20:49:47 +03:00
|
|
|
Count() (int64, error)
|
2020-11-08 12:12:49 +03:00
|
|
|
InsertOrGet(*models.User) (*models.User, bool, error)
|
|
|
|
Update(*models.User) (*models.User, error)
|
|
|
|
UpdateField(*models.User, string, interface{}) (*models.User, error)
|
2021-02-03 00:54:22 +03:00
|
|
|
Delete(*models.User) error
|
2020-11-08 12:12:49 +03:00
|
|
|
}
|