authz

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 20, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

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) Create

func (repo MySQLRepository) Create(ctx context.Context, user User) (int64, error)

func (MySQLRepository) DeleteByUserId

func (repo MySQLRepository) DeleteByUserId(ctx context.Context, userId string) error

func (MySQLRepository) GetById

func (repo MySQLRepository) GetById(ctx context.Context, id int64) (*User, error)

func (MySQLRepository) GetByUserId

func (repo MySQLRepository) GetByUserId(ctx context.Context, userId string) (*User, error)

func (MySQLRepository) List

func (repo MySQLRepository) List(ctx context.Context, listParams middleware.ListParams) ([]User, error)

func (MySQLRepository) UpdateByUserId

func (repo MySQLRepository) UpdateByUserId(ctx context.Context, userId string, user User) error

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) Create added in v0.4.0

func (repo PostgresRepository) Create(ctx context.Context, user User) (int64, error)

func (PostgresRepository) DeleteByUserId added in v0.4.0

func (repo PostgresRepository) DeleteByUserId(ctx context.Context, userId string) error

func (PostgresRepository) GetById added in v0.4.0

func (repo PostgresRepository) GetById(ctx context.Context, id int64) (*User, error)

func (PostgresRepository) GetByUserId added in v0.4.0

func (repo PostgresRepository) GetByUserId(ctx context.Context, userId string) (*User, error)

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

func (repo PostgresRepository) UpdateByUserId(ctx context.Context, userId string, user User) error

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

func (user User) ToUserSpec() *UserSpec

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) Create

func (svc UserService) Create(ctx context.Context, userSpec UserSpec) (*UserSpec, error)

func (UserService) DeleteByUserId

func (svc UserService) DeleteByUserId(ctx context.Context, userId string) error

func (UserService) GetByUserId

func (svc UserService) GetByUserId(ctx context.Context, userId string) (*UserSpec, error)

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

func (UserSpec) ToUser

func (spec UserSpec) ToUser(objectId int64) *User

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL