authz

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

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 Model added in v0.8.0

type Model interface {
	GetID() int64
	GetObjectId() int64
	GetUserId() string
	GetEmail() *string
	SetEmail(newEmail *string)
	GetCreatedAt() time.Time
	GetUpdatedAt() time.Time
	GetDeletedAt() *time.Time
	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 service.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 service.ListParams) ([]Model, error)

func (PostgresRepository) UpdateByUserId added in v0.4.0

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

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

func (repo SQLiteRepository) Create(ctx context.Context, model Model) (int64, error)

func (SQLiteRepository) DeleteByUserId added in v0.11.0

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

func (SQLiteRepository) GetById added in v0.11.0

func (repo SQLiteRepository) GetById(ctx context.Context, id int64) (Model, error)

func (SQLiteRepository) GetByUserId added in v0.11.0

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

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

func (repo SQLiteRepository) UpdateByUserId(ctx context.Context, userId string, model Model) error

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 User) GetCreatedAt() time.Time

func (User) GetDeletedAt added in v0.8.0

func (user User) GetDeletedAt() *time.Time

func (User) GetEmail added in v0.8.0

func (user User) GetEmail() *string

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 *string)

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

type UserSpec

type UserSpec struct {
	UserId    string    `json:"userId" validate:"omitempty,valid_object_id"`
	Email     *string   `json:"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