service

package
v0.0.0-...-498e44a Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddExercise

type AddExercise struct {
	DB   store.Execer
	Repo ExerciseAdder
}

func (*AddExercise) AddExercise

func (a *AddExercise) AddExercise(ctx context.Context, title, description string) (*entity.Exercise, error)

*entity.Exercise型を引数で受け取った値で初期化し、RDBMSへ保存 user_idはcontextから習得する

type DeleteExercise

type DeleteExercise struct {
	DB   store.Execer
	Repo ExerciseDeleter
}

func (*DeleteExercise) DeleteExercise

func (d *DeleteExercise) DeleteExercise(ctx context.Context, id entity.ExerciseID) error

type ExerciseAdder

type ExerciseAdder interface {
	AddExercise(ctx context.Context, db store.Execer, e *entity.Exercise) error
}

type ExerciseDeleter

type ExerciseDeleter interface {
	DeleteExercise(ctx context.Context, db store.Execer, id entity.ExerciseID) (*int64, error)
}

type ExerciseGetter

type ExerciseGetter interface {
	GetExercise(ctx context.Context, db store.Queryer, id entity.ExerciseID) (*entity.Exercise, error)
}

type ExerciseLister

type ExerciseLister interface {
	ListExercises(ctx context.Context, db store.Queryer, id entity.UserID) (entity.Exercises, error)
}

type ExerciseUpdater

type ExerciseUpdater interface {
	UpdateExercise(ctx context.Context, db store.Execer, e *entity.Exercise) (*int64, error)
}

type GetExercise

type GetExercise struct {
	DB   store.Queryer
	Repo ExerciseGetter
}

func (*GetExercise) GetExercise

func (g *GetExercise) GetExercise(ctx context.Context, id entity.ExerciseID) (*entity.Exercise, error)

type ListExercise

type ListExercise struct {
	DB   store.Queryer
	Repo ExerciseLister
}

func (*ListExercise) ListExercises

func (l *ListExercise) ListExercises(ctx context.Context) (entity.Exercises, error)

contextからuser_idを取得 取得したユーザーの投稿を取得する

type Login

type Login struct {
	DB             store.Queryer
	Repo           UserGetter
	TokenGenerator TokenGenerator
}

func (*Login) Login

func (l *Login) Login(ctx context.Context, name, pw string) (string, error)

引数で渡されたユーザー名のユーザーを取得し、パスワード認証を行う 成功すればアクセストークンを返す

type RegisterUser

type RegisterUser struct {
	DB   store.Execer
	Repo UserRegister
}

func (*RegisterUser) RegisterUser

func (r *RegisterUser) RegisterUser(
	ctx context.Context, name, password, role string,
) (*entity.User, error)

type TokenGenerator

type TokenGenerator interface {
	GenerateToken(ctx context.Context, u *entity.User) ([]byte, error)
}

*auth.JWTerの直接参照を避ける

type UpdateExercise

type UpdateExercise struct {
	DB   store.Execer
	Repo ExerciseUpdater
}

func (*UpdateExercise) UpdateExercise

func (u *UpdateExercise) UpdateExercise(ctx context.Context, id entity.ExerciseID, title, description string) error

type UserGetter

type UserGetter interface {
	GetUser(ctx context.Context, db store.Queryer, name string) (*entity.User, error)
}

type UserRegister

type UserRegister interface {
	RegisterUser(ctx context.Context, db store.Execer, u *entity.User) error
}

Jump to

Keyboard shortcuts

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