user

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2022 License: GPL-3.0 Imports: 4 Imported by: 0

README

This is an example business domain package.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HttpCreateRequest

type HttpCreateRequest struct {
	Username string `json:"username" binding:"required"`
}

type HttpResponse

type HttpResponse struct {
	Error   bool        `json:"error"`
	Message string      `json:"message"`
	Data    interface{} `json:"data"`
}

type MySQLRepository

type MySQLRepository struct {
	// contains filtered or unexported fields
}

func (*MySQLRepository) FindAll

FindAll finds all user data from MySQL database.

func (*MySQLRepository) FindByUsername

FindByUsername finds user data by username from MySQL database.

func (*MySQLRepository) Insert

Insert inserts user data into MySQL database.

type NewMySQLRepositoryParam

type NewMySQLRepositoryParam struct {
	Db *sql.DB
}

type NewServiceParam

type NewServiceParam struct {
	Repository RepositoryInterface
}

type NewUseCaseParam

type NewUseCaseParam struct {
	Service ServiceInterface
}

type RepositoryFindAllParam

type RepositoryFindAllParam struct {
	Ctx context.Context // If you want to use context.
}

type RepositoryFindAllResult

type RepositoryFindAllResult struct {
	Users *[]User `json:"users"`
	Error error   `json:"error"`
}

type RepositoryFindByUsernameParam

type RepositoryFindByUsernameParam struct {
	Username string          `json:"username"`
	Ctx      context.Context // If you want to use context.
}

type RepositoryFindByUsernameResult

type RepositoryFindByUsernameResult struct {
	User  *User `json:"user"`
	Error error `json:"error"`
}

type RepositoryInsertParam

type RepositoryInsertParam struct {
	Username string          `json:"username"`
	Ctx      context.Context // If you want to use context.
}

type RepositoryInsertResult

type RepositoryInsertResult struct {
	Error error `json:"error"`
}

type RepositoryInterface

RepositoryInterface is the repository interface contract of the domain. Repository is a place where you communicate with the real external data source or database.

func NewMySQLRepository

func NewMySQLRepository(param NewMySQLRepositoryParam) RepositoryInterface

NewMySQLRepository generates new MySQLRepository.

type Service

type Service struct {
	// contains filtered or unexported fields
}

func (*Service) Create

Create creates user data.

func (*Service) GetAll

GetAll gets all user data.

func (*Service) GetByUsername

GetByUsername gets user data by username.

type ServiceCreateParam

type ServiceCreateParam struct {
	Username string          `json:"username"`
	Ctx      context.Context // If you want to use context.
}

type ServiceCreateResult

type ServiceCreateResult struct {
	Error error `json:"error"`
}

type ServiceGetAllParam

type ServiceGetAllParam struct {
	Ctx context.Context // If you want to use context.
}

type ServiceGetAllResult

type ServiceGetAllResult struct {
	Users *[]User `json:"users"`
	Error error   `json:"error"`
}

type ServiceGetByUsernameParam

type ServiceGetByUsernameParam struct {
	Username string          `json:"username"`
	Ctx      context.Context // If you want to use context.
}

type ServiceGetByUsernameResult

type ServiceGetByUsernameResult struct {
	User  *User `json:"user"`
	Error error `json:"error"`
}

type ServiceInterface

type ServiceInterface interface {
	GetAll(param ServiceGetAllParam) ServiceGetAllResult
	GetByUsername(param ServiceGetByUsernameParam) ServiceGetByUsernameResult
	Create(param ServiceCreateParam) ServiceCreateResult
}

ServiceInterface is the service interface contract of the domain. Service is the smallest partial from what the domain can do based on the main business flow. Service is a place where you use & call repository functions of the domain.

func NewService

func NewService(param NewServiceParam) ServiceInterface

NewService generates new Service.

type UseCase

type UseCase struct {
	// contains filtered or unexported fields
}

func (*UseCase) Create

Create creates user data.

func (*UseCase) GetAll

GetAll gets all user data.

type UseCaseCreateParam

type UseCaseCreateParam struct {
	Username string          `json:"username"`
	Ctx      context.Context // If you want to use context.
}

type UseCaseCreateResult

type UseCaseCreateResult struct {
	Error error `json:"error"`
}

type UseCaseGetAllParam

type UseCaseGetAllParam struct {
	Ctx context.Context // If you want to use context.
}

type UseCaseGetAllResult

type UseCaseGetAllResult struct {
	Users *[]User `json:"users"`
	Error error   `json:"error"`
}

type UseCaseInterface

type UseCaseInterface interface {
	GetAll(param UseCaseGetAllParam) UseCaseGetAllResult
	Create(param UseCaseCreateParam) UseCaseCreateResult
}

UseCaseInterface is the use case interface contract of the domain. UseCase describes what the domain can do based on the main business flow. UseCase is a place where you use & call service functions of the domain or services from other domains

func NewUseCase

func NewUseCase(param NewUseCaseParam) UseCaseInterface

NewUseCase generates new UseCase.

type User

type User struct {
	Id        int       `json:"id"`
	Username  string    `json:"username"`
	CreatedAt time.Time `json:"created_at"`
}

Directories

Path Synopsis
delivery

Jump to

Keyboard shortcuts

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