Documentation
¶
Index ¶
- Constants
- type MySQLRepository
- func (repo MySQLRepository) Create(ctx context.Context, user User) (int64, error)
- func (repo MySQLRepository) DeleteByUserId(ctx context.Context, userId string) error
- func (repo MySQLRepository) GetById(ctx context.Context, id int64) (*User, error)
- func (repo MySQLRepository) GetByUserId(ctx context.Context, userId string) (*User, error)
- func (repo MySQLRepository) List(ctx context.Context, listParams middleware.ListParams) ([]User, error)
- func (repo MySQLRepository) UpdateByUserId(ctx context.Context, userId string, user User) error
- type PostgresRepository
- func (repo PostgresRepository) Create(ctx context.Context, user User) (int64, error)
- func (repo PostgresRepository) DeleteByUserId(ctx context.Context, userId string) error
- func (repo PostgresRepository) GetById(ctx context.Context, id int64) (*User, error)
- func (repo PostgresRepository) GetByUserId(ctx context.Context, userId string) (*User, error)
- func (repo PostgresRepository) List(ctx context.Context, listParams middleware.ListParams) ([]User, error)
- func (repo PostgresRepository) UpdateByUserId(ctx context.Context, userId string, user User) error
- type UpdateUserSpec
- type User
- 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) GetRoutes() []service.Route
- func (svc UserService) List(ctx context.Context, listParams middleware.ListParams) ([]UserSpec, error)
- func (svc UserService) UpdateByUserId(ctx context.Context, userId string, userSpec UpdateUserSpec) (*UserSpec, error)
- type UserSpec
Constants ¶
View Source
const ResourceTypeUser = "user"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
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 middleware.ListParams) ([]User, 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 middleware.ListParams) ([]User, error)
func (PostgresRepository) UpdateByUserId ¶ added in v0.4.0
type UpdateUserSpec ¶
type UpdateUserSpec struct {
Email database.NullString `json:"email" validate:"email"`
}
type User ¶
type User struct {
ID int64 `mysql:"id" postgres:"id"`
ObjectId int64 `mysql:"objectId" postgres:"object_id"`
UserId string `mysql:"userId" postgres:"user_id"`
Email database.NullString `mysql:"email" postgres:"email"`
CreatedAt time.Time `mysql:"createdAt" postgres:"created_at"`
UpdatedAt time.Time `mysql:"updatedAt" postgres:"updated_at"`
DeletedAt database.NullTime `mysql:"deletedAt" postgres:"deleted_at"`
}
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 User) (int64, error)
GetById(ctx context.Context, id int64) (*User, error)
GetByUserId(ctx context.Context, userId string) (*User, error)
List(ctx context.Context, listParams middleware.ListParams) ([]User, error)
UpdateByUserId(ctx context.Context, userId string, user User) error
DeleteByUserId(ctx context.Context, userId string) error
}
func NewRepository ¶
func NewRepository(db database.Database) (UserRepository, error)
type UserService ¶
type UserService struct {
service.BaseService
}
func NewService ¶
func NewService(env service.Env) UserService
func (UserService) DeleteByUserId ¶
func (svc UserService) DeleteByUserId(ctx context.Context, userId string) error
func (UserService) GetByUserId ¶
func (UserService) GetRoutes ¶
func (svc UserService) GetRoutes() []service.Route
func (UserService) List ¶
func (svc UserService) List(ctx context.Context, listParams middleware.ListParams) ([]UserSpec, error)
func (UserService) UpdateByUserId ¶
func (svc UserService) UpdateByUserId(ctx context.Context, userId string, userSpec UpdateUserSpec) (*UserSpec, error)
type UserSpec ¶
type UserSpec struct {
UserId string `json:"userId"`
Email database.NullString `json:"email" validate:"email"`
CreatedAt time.Time `json:"createdAt"`
}
func (UserSpec) ToObjectSpec ¶
func (spec UserSpec) ToObjectSpec() *object.ObjectSpec
Click to show internal directories.
Click to hide internal directories.