domain

package
v0.0.0-...-6b1c1c1 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2020 License: MIT Imports: 1 Imported by: 0

README

Domain層

Domain層はドメインロジックを実装する責務を持つ。
Domain層はDBアクセスなどの技術的な実装は持たず、それらはInfrastructure層が担当します。
Domain層はどの層にも依存しないのでこの層だけで完結します。

テンプレート

package domain

import "time"

// Sample - Sampleエンティティ
type Sample struct {
	ID           string    `firestore:"id"`
	Email        string    `firestore:"email" validate:"email,max=256"`
	Password     string    `firestore:"-" validate:"password,min=6,max=32"`
	Name         string    `firestore:"name" validate:"max=32"`
	ThumbnailURL string    `firestore:"thumbnail_url"`
	CreatedAt    time.Time `firestore:"created_at"`
	UpdatedAt    time.Time `firestore:"updated_at"`
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CustomError

type CustomError struct {
	ErrorCode        ErrorCode
	Value            error
	ValidationErrors []*ValidationError
}

CustomError - エラーコードを含めた構造体

func (CustomError) Code

func (ce CustomError) Code() ErrorCode

Code - エラーコードを返す

func (CustomError) Error

func (ce CustomError) Error() string

Error - エラー内容を返す

func (CustomError) Validation

func (ce CustomError) Validation() []*ValidationError

Validation - エラー詳細を返す

type ErrorCode

type ErrorCode uint

ErrorCode - エラーの種類

const (
	// Unknown - 不明なエラー
	Unknown ErrorCode = iota
	// Unauthorized - 認証エラー
	Unauthorized
	// Forbidden - 権限エラー
	Forbidden
	// NotFound - 取得エラー
	NotFound
	// InvalidDomainValidation - ドメインのバリデーションエラー
	InvalidDomainValidation
	// InvalidRequestValidation - リクエストのバリデーションエラー
	InvalidRequestValidation
	// UnableParseJSON - JSON型から構造体への変換エラー
	UnableParseJSON
	// ErrorInDatastore - データストアでのエラー
	ErrorInDatastore
	// ErrorInStorage - ストレージでのエラー
	ErrorInStorage
	// AlreadyExists - ユニークチェックでのエラー
	AlreadyExists
	// NotEqualRequestWithDatastore - リクエスト値がデータストアの値と一致しない
	NotEqualRequestWithDatastore
)

func (ErrorCode) New

func (ec ErrorCode) New(err error, ves ...*ValidationError) error

New - 指定したErrorCodeを持つCustomErrorを返す

type ShowError

type ShowError interface {
	Code() ErrorCode
	Error() string
	Validation() []*ValidationError
}

ShowError - エラー内容を返すインターフェース

type User

type User struct {
	ID           string    `firestore:"id"`
	Name         string    `firestore:"name"`
	DisplayName  string    `firestore:"display_name"`
	Email        string    `firestore:"email"`
	PhoneNumber  string    `firestore:"phone_number"`
	ThumbnailURL string    `firestore:"thumbnail_url"`
	Biography    string    `firestore:"biography"`
	Password     string    `firestore:"-"`
	GroupIDs     []string  `firestore:"group_ids,omitempty"`
	CreatedAt    time.Time `firestore:"created_at"`
	UpdatedAt    time.Time `firestore:"updated_at"`
}

User - Userエンティティ

type ValidationError

type ValidationError struct {
	Field   string
	Message string
}

ValidationError - バリデーションエラー用構造体

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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