domain.go 2.71 KB
Newer Older
hujiebin's avatar
hujiebin committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
package mysql

import (
	"strconv"
)

/**
基于PDM,建立统计的数据domain结构。注意,不要选择0, 因为go的int默认值为0
*/

//主键ID
type ID = uint64

//性别
type Sex = uint8

//加减
type AddReduce = uint8

//拥有
type YesNo = uint8

//短描述
type Str = string

//时间戳
type Time = int64

//状态
type UserYesNo = uint8

//平台
type Platform = uint8

//多枚举类型
type Type = uint8

//数量
type Num = uint32

//时间戳
type Timestamp = uint64

//排序
type Index = uint16

//数量,并且用到-1作为特殊标记位
type NumAll = int

//开启关闭
type OpenClose = uint8

//逻辑删除
type LogicDel = uint8

//设备
type Device = uint8

type PeriodType = uint8

type FinishYesNo = uint8

type PayOrderType = uint8

//性别
const (
	MAN   Sex = 1
	WOMAN Sex = 2
	EMPTY Sex = 0
)

//yes no
const (
	YES YesNo = 1
	NO  YesNo = 2
)

const (
	OPEN  OpenClose = 1
	CLOSE OpenClose = 2
)

//加,减
const (
	ADD          AddReduce = 1
	REDUCE       AddReduce = 2
	NilAddREDUCE AddReduce = 3
)

const (
	USER   UserYesNo = 1
	NOUSER UserYesNo = 2
)

const (
	Apple     Platform = 1
	GOOGLE    Platform = 2
	EGG_PLANT Platform = 3 // 通过starchat回调的茄子充值 代理充值
	Checkout  Platform = 4
	PayerMax  Platform = 5 // 通过hilo发起,starchat回调的PayerMax/茄子充值
	Paypal    Platform = 6 // paypal

	ApplePink  Platform = 31 // Apple pay 购买粉钻
	GOOGLEPink Platform = 32 // GOOGLE pay 购买粉钻

	PayTypeZero        PayOrderType = 0 //
	PayTypeProxy       PayOrderType = 1 // 1.代理给自己充值
	PayTypeUserToProxy PayOrderType = 2 // 2.用户给代理充值

	CheckoutName = "cheakout支付"
	PayerMaxName = "茄子支付"
	PayPalName   = "PayPal支付"
)

//逻辑删除
const (
	EXIST LogicDel = 1
	DEL   LogicDel = 2
)

const (
	DAY   PeriodType = 1
	Week  PeriodType = 2
	Month PeriodType = 3
	Year  PeriodType = 4
)

const (
	FinishNo  FinishYesNo = 0
	FinishYes FinishYesNo = 1
)

const (
	DiamondYellow Type = 1
	DiamondPink   Type = 2
)

func IdToStr(id ID) string {
	return strconv.Itoa(int(id))
}

func StrToId(id string) (ID, error) {
	var idInt int
	var err error
	if idInt, err = strconv.Atoi(id); err != nil {
		return 0, err
	}
	return ID(idInt), nil
}

func NumToString(num Num) string {
	return strconv.Itoa(int(num))
}

func TypeToString(t Type) string {
	return strconv.Itoa(int(t))
}

func StrToType(t string) (Type, error) {
	var tInt int
	var err error
	if tInt, err = strconv.Atoi(t); err != nil {
		return 0, err
	}
	return Type(tInt), nil
}

/*func IdToUint64(id ID) uint64 {
	return uint64(id)
}*/

func IdsToUint64(ids []ID) []uint64 {
	uints := []uint64{}
	for i := 0; i < len(ids); i++ {
		uints = append(uints, uint64(ids[i]))
	}
	return uints
}