Documentation ¶
Index ¶
- Variables
- func ValidateRecipe(recipe *Recipe) []string
- type Gateway
- func (r *Gateway) CreateRecipe(ctx context.Context, recipe Recipe) (Recipe, error)
- func (r *Gateway) DeleteRecipe(ctx context.Context, recipe Recipe) (bool, error)
- func (r *Gateway) ReadRecipe(ctx context.Context, id uint) (Recipe, error)
- func (r *Gateway) ReadRecipes(ctx context.Context) ([]Recipe, error)
- func (r *Gateway) UpdateRecipe(ctx context.Context, id uint, recipe Recipe) (Recipe, error)
- type MockDB
- type MockGateway
- func (r *MockGateway) CreateRecipe(ctx context.Context, recipe Recipe) (Recipe, error)
- func (r *MockGateway) DeleteRecipe(ctx context.Context, recipe Recipe) (bool, error)
- func (r *MockGateway) ReadRecipe(ctx context.Context, id uint) (Recipe, error)
- func (r *MockGateway) ReadRecipes(ctx context.Context) ([]Recipe, error)
- func (r *MockGateway) UpdateRecipe(ctx context.Context, id uint, recipe Recipe) (Recipe, error)
- type Provider
- func (p *Provider) CreateRecipe(ctx context.Context, title, makingTime, serves, ingredients string, cost int) (Recipe, error)
- func (p *Provider) DeleteRecipe(ctx context.Context, id uint) (bool, error)
- func (p *Provider) ReadRecipe(ctx context.Context, id uint) (Recipe, error)
- func (p *Provider) ReadRecipes(ctx context.Context) ([]Recipe, error)
- func (p *Provider) UpdateRecipe(ctx context.Context, id uint, title, makingTime, serves, ingredients string, ...) (Recipe, error)
- type Recipe
- type Repository
Constants ¶
This section is empty.
Variables ¶
View Source
var Validate *validator.Validate
Validate - バリデータの実体. 外部に公開する.
Functions ¶
func ValidateRecipe ¶
ValidateRecipe - Recipeのバリデーションの関数
Types ¶
type Gateway ¶
type Gateway struct {
// contains filtered or unexported fields
}
Gateway - DBのアダプターの構造体
func (*Gateway) CreateRecipe ¶
CreateRecipe - レシピを作成
func (*Gateway) DeleteRecipe ¶
DeleteRecipe - 指定したIDのレシピを削除
func (*Gateway) ReadRecipe ¶
ReadRecipe - 指定したIDのレシピを取得
func (*Gateway) ReadRecipes ¶
ReadRecipes - 全てのレシピを取得
type MockGateway ¶
type MockGateway struct {
// contains filtered or unexported fields
}
MockGateway - MockDBのアダプターの構造体
func (*MockGateway) CreateRecipe ¶
CreateRecipe - レシピを作成
func (*MockGateway) DeleteRecipe ¶
DeleteRecipe - 指定したIDのレシピを削除
func (*MockGateway) ReadRecipe ¶
ReadRecipe - 指定したIDのレシピを取得
func (*MockGateway) ReadRecipes ¶
func (r *MockGateway) ReadRecipes(ctx context.Context) ([]Recipe, error)
ReadRecipes - 全てのレシピを取得
func (*MockGateway) UpdateRecipe ¶
UpdateRecipe - 指定したIDのレシピを更新
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider - アプリケーションコアの構造体
func (*Provider) CreateRecipe ¶
func (p *Provider) CreateRecipe(ctx context.Context, title, makingTime, serves, ingredients string, cost int) (Recipe, error)
CreateRecipe - レシピを作成
func (*Provider) DeleteRecipe ¶
DeleteRecipe - 指定したIDのレシピを削除
func (*Provider) ReadRecipe ¶
ReadRecipe - 指定したIDのレシピを取得
func (*Provider) ReadRecipes ¶
ReadRecipes - 全てのレシピを取得
type Recipe ¶
type Recipe struct { ID uint `json:"id,omitempty"` Title string `json:"title" validate:"required"` MakingTime string `json:"making_time" validate:"required"` Serves string `json:"serves" validate:"required"` Ingredients string `json:"ingredients" validate:"required"` Cost int `json:"cost,string" validate:"required"` CreatedAt *time.Time `json:"created_at,omitempty"` UpdatedAt *time.Time `json:"updated_at,omitempty"` }
Recipe - Recipeのモデル. 外部に公開する.
type Repository ¶
type Repository interface { CreateRecipe(ctx context.Context, recipe Recipe) (Recipe, error) ReadRecipes(ctx context.Context) ([]Recipe, error) ReadRecipe(ctx context.Context, id uint) (Recipe, error) UpdateRecipe(ctx context.Context, id uint, recipe Recipe) (Recipe, error) DeleteRecipe(ctx context.Context, recipe Recipe) (bool, error) }
Repository - アプリケーションコアからDBへのアダプター
func NewMockGateway ¶
func NewMockGateway(db *MockDB) Repository
NewMockGateway - MockDBのアダプターの構造体のコンストラクタ
Click to show internal directories.
Click to hide internal directories.