Documentation
¶
Index ¶
- Constants
- func CreateHandler(svc UserService, w http.ResponseWriter, r *http.Request) error
- func DeleteHandler(svc UserService, w http.ResponseWriter, r *http.Request) error
- func GetHandler(svc UserService, w http.ResponseWriter, r *http.Request) error
- func ListHandler(svc UserService, w http.ResponseWriter, r *http.Request) error
- func UpdateHandler(svc UserService, w http.ResponseWriter, r *http.Request) error
- type Model
- type MySQLRepository
- func (repo MySQLRepository) Create(ctx context.Context, model Model) (int64, error)
- func (repo MySQLRepository) DeleteByUserId(ctx context.Context, userId string) error
- func (repo MySQLRepository) GetById(ctx context.Context, id int64) (Model, error)
- func (repo MySQLRepository) GetByUserId(ctx context.Context, userId string) (Model, error)
- func (repo MySQLRepository) List(ctx context.Context, listParams service.ListParams) ([]Model, error)
- func (repo MySQLRepository) UpdateByUserId(ctx context.Context, userId string, model Model) error
- type PostgresRepository
- func (repo PostgresRepository) Create(ctx context.Context, model Model) (int64, error)
- func (repo PostgresRepository) DeleteByUserId(ctx context.Context, userId string) error
- func (repo PostgresRepository) GetById(ctx context.Context, id int64) (Model, error)
- func (repo PostgresRepository) GetByUserId(ctx context.Context, userId string) (Model, error)
- func (repo PostgresRepository) List(ctx context.Context, listParams service.ListParams) ([]Model, error)
- func (repo PostgresRepository) UpdateByUserId(ctx context.Context, userId string, model Model) error
- type SQLiteRepository
- func (repo SQLiteRepository) Create(ctx context.Context, model Model) (int64, error)
- func (repo SQLiteRepository) DeleteByUserId(ctx context.Context, userId string) error
- func (repo SQLiteRepository) GetById(ctx context.Context, id int64) (Model, error)
- func (repo SQLiteRepository) GetByUserId(ctx context.Context, userId string) (Model, error)
- func (repo SQLiteRepository) List(ctx context.Context, listParams service.ListParams) ([]Model, error)
- func (repo SQLiteRepository) UpdateByUserId(ctx context.Context, userId string, model Model) error
- type UpdateUserSpec
- type User
- func (user User) GetCreatedAt() time.Time
- func (user User) GetDeletedAt() *time.Time
- func (user User) GetEmail() *string
- func (user User) GetID() int64
- func (user User) GetObjectId() int64
- func (user User) GetUpdatedAt() time.Time
- func (user User) GetUserId() string
- func (user *User) SetEmail(newEmail *string)
- func (user User) ToUserSpec() *UserSpec
- type UserListParamParser
- type UserRepository
- type UserService
- func (svc UserService) Create(ctx context.Context, userSpec UserSpec) (*UserSpec, error)
- func (svc UserService) DeleteByUserId(ctx context.Context, userId string) error
- func (svc UserService) GetByUserId(ctx context.Context, userId string) (*UserSpec, error)
- func (svc UserService) List(ctx context.Context, listParams service.ListParams) ([]UserSpec, error)
- func (svc UserService) Routes() ([]service.Route, error)
- func (svc UserService) UpdateByUserId(ctx context.Context, userId string, userSpec UpdateUserSpec) (*UserSpec, error)
- type UserSpec
Constants ¶
View Source
const DefaultSortBy = "userId"
View Source
const ResourceTypeUser = "user"
Variables ¶
This section is empty.
Functions ¶
func CreateHandler ¶ added in v0.11.0
func CreateHandler(svc UserService, w http.ResponseWriter, r *http.Request) error
func DeleteHandler ¶ added in v0.11.0
func DeleteHandler(svc UserService, w http.ResponseWriter, r *http.Request) error
func GetHandler ¶ added in v0.11.0
func GetHandler(svc UserService, w http.ResponseWriter, r *http.Request) error
func ListHandler ¶ added in v0.11.0
func ListHandler(svc UserService, w http.ResponseWriter, r *http.Request) error
func UpdateHandler ¶ added in v0.11.0
func UpdateHandler(svc UserService, w http.ResponseWriter, r *http.Request) error
Types ¶
type MySQLRepository ¶
type MySQLRepository struct {
database.SQLRepository
}
func NewMySQLRepository ¶
func NewMySQLRepository(db *database.MySQL) MySQLRepository
func (MySQLRepository) DeleteByUserId ¶
func (repo MySQLRepository) DeleteByUserId(ctx context.Context, userId string) error
func (MySQLRepository) GetByUserId ¶
func (MySQLRepository) List ¶
func (repo MySQLRepository) List(ctx context.Context, listParams service.ListParams) ([]Model, error)
func (MySQLRepository) UpdateByUserId ¶
type PostgresRepository ¶ added in v0.4.0
type PostgresRepository struct {
database.SQLRepository
}
func NewPostgresRepository ¶ added in v0.4.0
func NewPostgresRepository(db *database.Postgres) PostgresRepository
func (PostgresRepository) DeleteByUserId ¶ added in v0.4.0
func (repo PostgresRepository) DeleteByUserId(ctx context.Context, userId string) error
func (PostgresRepository) GetByUserId ¶ added in v0.4.0
func (PostgresRepository) List ¶ added in v0.4.0
func (repo PostgresRepository) List(ctx context.Context, listParams service.ListParams) ([]Model, error)
func (PostgresRepository) UpdateByUserId ¶ added in v0.4.0
type SQLiteRepository ¶ added in v0.11.0
type SQLiteRepository struct {
database.SQLRepository
}
func NewSQLiteRepository ¶ added in v0.11.0
func NewSQLiteRepository(db *database.SQLite) SQLiteRepository
func (SQLiteRepository) DeleteByUserId ¶ added in v0.11.0
func (repo SQLiteRepository) DeleteByUserId(ctx context.Context, userId string) error
func (SQLiteRepository) GetByUserId ¶ added in v0.11.0
func (SQLiteRepository) List ¶ added in v0.11.0
func (repo SQLiteRepository) List(ctx context.Context, listParams service.ListParams) ([]Model, error)
func (SQLiteRepository) UpdateByUserId ¶ added in v0.11.0
type UpdateUserSpec ¶
type UpdateUserSpec struct {
Email *string `json:"email"`
}
type User ¶
type User struct {
ID int64 `mysql:"id" postgres:"id" sqlite:"id"`
ObjectId int64 `mysql:"objectId" postgres:"object_id" sqlite:"objectId"`
UserId string `mysql:"userId" postgres:"user_id" sqlite:"userId"`
Email *string `mysql:"email" postgres:"email" sqlite:"email"`
CreatedAt time.Time `mysql:"createdAt" postgres:"created_at" sqlite:"createdAt"`
UpdatedAt time.Time `mysql:"updatedAt" postgres:"updated_at" sqlite:"updatedAt"`
DeletedAt *time.Time `mysql:"deletedAt" postgres:"deleted_at" sqlite:"deletedAt"`
}
func (User) GetCreatedAt ¶ added in v0.8.0
func (User) GetDeletedAt ¶ added in v0.8.0
func (User) GetObjectId ¶ added in v0.8.0
func (User) GetUpdatedAt ¶ added in v0.8.0
func (User) ToUserSpec ¶
type UserListParamParser ¶
type UserListParamParser struct{}
func (UserListParamParser) GetDefaultSortBy ¶
func (parser UserListParamParser) GetDefaultSortBy() string
func (UserListParamParser) GetSupportedSortBys ¶
func (parser UserListParamParser) GetSupportedSortBys() []string
func (UserListParamParser) ParseValue ¶
func (parser UserListParamParser) ParseValue(val string, sortBy string) (interface{}, error)
type UserRepository ¶
type UserRepository interface {
Create(ctx context.Context, user Model) (int64, error)
GetById(ctx context.Context, id int64) (Model, error)
GetByUserId(ctx context.Context, userId string) (Model, error)
List(ctx context.Context, listParams service.ListParams) ([]Model, error)
UpdateByUserId(ctx context.Context, userId string, user Model) error
DeleteByUserId(ctx context.Context, userId string) error
}
func NewRepository ¶
func NewRepository(db database.Database) (UserRepository, error)
type UserService ¶
type UserService struct {
service.BaseService
Repository UserRepository
EventSvc event.EventService
ObjectSvc object.ObjectService
}
func NewService ¶
func NewService(env service.Env, repository UserRepository, eventSvc event.EventService, objectSvc object.ObjectService) UserService
func (UserService) DeleteByUserId ¶
func (svc UserService) DeleteByUserId(ctx context.Context, userId string) error
func (UserService) GetByUserId ¶
func (UserService) List ¶
func (svc UserService) List(ctx context.Context, listParams service.ListParams) ([]UserSpec, error)
func (UserService) Routes ¶ added in v0.8.0
func (svc UserService) Routes() ([]service.Route, error)
func (UserService) UpdateByUserId ¶
func (svc UserService) UpdateByUserId(ctx context.Context, userId string, userSpec UpdateUserSpec) (*UserSpec, error)
Click to show internal directories.
Click to hide internal directories.