value

package module
v0.0.0-...-7a903f9 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2020 License: MIT Imports: 4 Imported by: 0

README

DDD Value Object

Domain Design Drive 常用的 Value Object

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AreaStringer func(area Area) string

AreaStringer 地区码转换文案函数

Functions

This section is empty.

Types

type Address

type Address struct {
	Area   Area
	Detail string
}

Address 详细地址

func NewAddress

func NewAddress(area, detail string) (Address, error)

func (Address) String

func (addr Address) String() string

type Area

type Area string

Area 8位地区码 ** | ** | ** | ** 国 | 省 | 市 | 区

func NewArea

func NewArea(v string) (Area, error)

func (Area) City

func (area Area) City() Area

func (Area) Country

func (area Area) Country() Area

func (Area) District

func (area Area) District() Area

func (Area) Province

func (area Area) Province() Area

func (Area) String

func (area Area) String() string

type Birthday

type Birthday struct{ time.Time }

Birthday 出生日期

func NewBirthday

func NewBirthday(v interface{}) (btd Birthday, err error)

func (Birthday) ActualAge

func (b Birthday) ActualAge() int

func (Birthday) NominalAge

func (b Birthday) NominalAge() int

func (*Birthday) Scan

func (b *Birthday) Scan(dest interface{}) error

func (Birthday) String

func (b Birthday) String() string

func (Birthday) Value

func (b Birthday) Value() (driver.Value, error)

type Currency

type Currency int16
const (
	CNF Currency = 1
	CNJ Currency = 10
	CNY Currency = 100
	USD Currency = 694
)

type Money

type Money struct {
	Amount   float64
	Currency Currency
}

func NewMoney

func NewMoney(amount float64, currency Currency) (Money, error)

func (Money) Format

func (m Money) Format(currency Currency) float64

func (*Money) Scan

func (m *Money) Scan(dest interface{}) error

func (Money) Value

func (m Money) Value() (driver.Value, error)

type Percent

type Percent float64

func (Percent) Mul

func (p Percent) Mul(v float64) float64

func (Percent) MulInt

func (p Percent) MulInt(v int) int

func (Percent) MulInt64

func (p Percent) MulInt64(v int64) int64

Jump to

Keyboard shortcuts

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