authz

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const ResourceTypeUser = "user"

Variables

This section is empty.

Functions

This section is empty.

Types

type Model added in v0.8.0

type Model interface {
	GetID() int64
	GetObjectId() int64
	GetUserId() string
	GetEmail() database.NullString
	SetEmail(newEmail database.NullString)
	GetCreatedAt() time.Time
	GetUpdatedAt() time.Time
	GetDeletedAt() database.NullTime
	ToUserSpec() *UserSpec
}

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, model Model) (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) (Model, error)

func (MySQLRepository) GetByUserId

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

func (MySQLRepository) List

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

func (MySQLRepository) UpdateByUserId

func (repo MySQLRepository) UpdateByUserId(ctx context.Context, userId string, model Model) 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, model Model) (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) (Model, error)

func (PostgresRepository) GetByUserId added in v0.4.0

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

func (PostgresRepository) List added in v0.4.0

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

func (PostgresRepository) UpdateByUserId added in v0.4.0

func (repo PostgresRepository) UpdateByUserId(ctx context.Context, userId string, model Model) 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) GetCreatedAt added in v0.8.0

func (user User) GetCreatedAt() time.Time

func (User) GetDeletedAt added in v0.8.0

func (user User) GetDeletedAt() database.NullTime

func (User) GetEmail added in v0.8.0

func (user User) GetEmail() database.NullString

func (User) GetID added in v0.8.0

func (user User) GetID() int64

func (User) GetObjectId added in v0.8.0

func (user User) GetObjectId() int64

func (User) GetUpdatedAt added in v0.8.0

func (user User) GetUpdatedAt() time.Time

func (User) GetUserId added in v0.8.0

func (user User) GetUserId() string

func (*User) SetEmail added in v0.8.0

func (user *User) SetEmail(newEmail database.NullString)

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 Model) (int64, error)
	GetById(ctx context.Context, id int64) (Model, error)
	GetByUserId(ctx context.Context, userId string) (Model, error)
	List(ctx context.Context, listParams middleware.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
	// contains filtered or unexported fields
}

func NewService

func NewService(env service.Env, repo UserRepository, eventSvc event.EventService, objectSvc object.ObjectService) 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) List

func (svc UserService) List(ctx context.Context, listParams middleware.ListParams) ([]UserSpec, error)

func (UserService) Routes added in v0.8.0

func (svc UserService) Routes() []service.Route

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