dddvo

package module
v0.0.0-...-ec4d44f Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2020 License: MIT Imports: 8 Imported by: 0

README

dddvo

DDD Value Object

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AbsURL

type AbsURL string

AbsURL 绝对URL

func (AbsURL) Accessible

func (au AbsURL) Accessible(ttl time.Duration) bool

func (AbsURL) UrlStruct

func (au AbsURL) UrlStruct() *url.URL

type Bool

type Bool int
const (
	NullBool Bool = 0
	True     Bool = 1
	False    Bool = 2
)

func (Bool) IsFalse

func (b Bool) IsFalse() bool

func (Bool) IsTrue

func (b Bool) IsTrue() bool

func (Bool) Validate

func (b Bool) Validate() bool

type Currency

type Currency string

Currency 货币单位

const (
	CNF Currency = "CNF"
	CNJ Currency = "CNJ"
	CNY Currency = "CNY"
	USD Currency = "USD"
)

func (Currency) String

func (c Currency) String(format func(Currency) string) string

type Money

type Money struct {
	Amount   float64  `json:"amount" format:"float64"` // 金额
	Currency Currency `json:"currency"`                // 单位(CNF,CNJ,CNY,USD)
}

Money 金额值对象

func NewMoney

func NewMoney(amount float64, currency Currency) Money

func (Money) Equal

func (m Money) Equal(m2 Money) bool

func (Money) Format

func (m Money) Format(currency Currency) Money

func (Money) MarshalJSON

func (m Money) MarshalJSON() ([]byte, error)

func (Money) Multiply

func (m Money) Multiply(ratio float64) Money

func (*Money) Scan

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

func (*Money) UnmarshalJSON

func (m *Money) UnmarshalJSON(data []byte) error

func (*Money) Validate

func (m *Money) Validate() bool

func (Money) Value

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

type Percent

type Percent float64

Percent 百分比

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