rich

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2018 License: Apache-2.0 Imports: 46 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CustomerIDPrefix 客户前缀
	CustomerIDPrefix byte = 'C'
	// UserIDPrefix 用户前缀
	UserIDPrefix byte = 'U'
	// TradeIDPrefix 订单前缀
	TradeIDPrefix byte = 'T'
	// ItemIDPrefix 商品前缀
	ItemIDPrefix byte = 'I'
	// ExtIDPrefix 扩展前缀
	ExtIDPrefix byte = 'E'
	// XlsxIDPrefix Excel定义前缀
	XlsxIDPrefix byte = 'X'
	// TagIDPrefix 标签前缀
	TagIDPrefix byte = 'A'
)
View Source
const (

	// XlsxTypeCustomers 客户Excel模板
	XlsxTypeCustomers
	// XlsxTypeItems 商品Excel模板
	XlsxTypeItems
	// XlsxTypeTrides 订单Excel模板
	XlsxTypeTrides
)
View Source
const DayFormat = "2006-01-02"

DayFormat 日期格式化

Variables

View Source
var DaysKey = []byte("days")

DaysKey 文件日期列表主键

View Source
var TagKeys = []string{
	"tag-C",
	"tag-I",
}

TagKeys 标签键值

Functions

func Axis

func Axis(col, row int) string

Axis 装环Excel坐标

func Download

func Download(url, target string) error

Download 下载并解压缩

func GetIP

func GetIP() (string, error)

GetIP 获取IP地址

func GetURL

func GetURL(address string, tls bool) (string, error)

GetURL 获取网址

func Initial

func Initial(str string) []string

Initial 首字母

func LastURL

func LastURL(owner, project, tagName string) (string, string, error)

LastURL 最后一个下载地址

func PC

func PC(array [][]string) []string

PC 排列组合

func Pass

func Pass(str string) []byte

Pass 密码生成

func PrintQR added in v0.1.10

func PrintQR(str string)

PrintQR 控制台输出二维码

func ReadXlsx added in v0.1.12

func ReadXlsx(file string, add func(row []string)) error

ReadXlsx 读取Excel文件

func Zip added in v0.1.10

func Zip(srcDirPath string, destFilePath string) error

Zip 压缩目录或文件

Types

type App added in v0.1.10

type App struct {
	Name    string `json:"name"`    // 应用名称
	Usage   string `json:"usage"`   // 使用方法
	Version string `json:"version"` // 版本
	IsNew   bool   `json:"isNew"`   // 新应用
}

App 应用信息

func NewApp added in v0.1.10

func NewApp(app *cli.App) *App

NewApp 新建应用

type Batch added in v0.1.12

type Batch struct {
	Cost      int64 `json:"cost"`      // 成本,单位分
	Total     int   `json:"total"`     // 采购总量
	Inventory int   `json:"inventory"` // 库存
}

Batch 批次

type Binder

type Binder interface {
	// Bind 绑定数据
	Bind(c echo.Context) error
}

Binder 对象绑定

type Customer

type Customer struct {
	Obj
	Phone  string            `json:"phone,omitempty"`  // 电话
	Trades []utils.ID        `json:"trades,omitempty"` // 消费记录
	Extend map[string]string `json:"extend"`           // 扩展属性
	Tags   Tags              `json:"tags"`             // 标签
}

Customer 客户

func (*Customer) BeforePost

func (c *Customer) BeforePost(key byte) utils.ID

BeforePost 创建前设置拼音标签

func (*Customer) BeforePut

func (c *Customer) BeforePut(id utils.ID)

BeforePut 修改前设置拼音标签

func (Customer) Includes

func (c Customer) Includes(tags []string) bool

Includes 包含

func (Customer) Match

func (c Customer) Match(txt string) bool

Match 匹配

type Days

type Days []string

Days 日期

func (*Days) Add

func (d *Days) Add(day string) bool

Add 增加

func (*Days) Clean

func (d *Days) Clean()

Clean 清空

func (*Days) Includes

func (d *Days) Includes(day string) bool

Includes 包含

type Deleter

type Deleter interface {
	IsDelete() bool
	Delete()
}

Deleter 删除器

type Ext

type Ext struct {
	Key   string `json:"key"`   // 键
	Value string `json:"value"` // 值
}

Ext 扩展定义

type HTTPError

type HTTPError struct {
	Error   string `json:"error,omitempty"`
	Message string `json:"message"`
}

HTTPError 错误

type Includeser

type Includeser interface {
	Includes(tags []string) bool
}

Includeser 包含

type Item

type Item struct {
	Obj
	Price  int64             `json:"price"`  // 价格,单位分
	Cost   int64             `json:"cost"`   // 成本,单位分
	Batchs []Batch           `json:"batchs"` // 批次
	Extend map[string]string `json:"extend"` // 扩展属性
	Tags   Tags              `json:"tags"`   // 标签
}

Item 商品

func (*Item) BeforePost

func (i *Item) BeforePost(key byte) utils.ID

BeforePost 创建前设置拼音标签

func (*Item) BeforePut

func (i *Item) BeforePut(id utils.ID)

BeforePut 修改前设置拼音标签

func (Item) Includes

func (i Item) Includes(tags []string) bool

Includes 包含

type Matcher

type Matcher interface {
	Match(txt string) bool
}

Matcher 对象比较

type Obj

type Obj struct {
	ID     utils.ID  `json:"id"`                              // 主键
	Name   string    `json:"name" validate:"required,lte=50"` // 名称 必填 最长50
	Pinyin string    `json:"pinyin"`                          // 拼音
	Note   string    `json:"note" validate:"lte=100"`         // 备注 最长100
	Ca     time.Time `json:"ca"`                              // 创建时间
	Da     time.Time `json:"da,omitempty"`                    // 删除时间
}

Obj 基础对象

func (*Obj) BeforePost

func (o *Obj) BeforePost(key byte) utils.ID

BeforePost 对象新建前

func (*Obj) BeforePut

func (o *Obj) BeforePut(id utils.ID)

BeforePut 修改对象

func (*Obj) Delete

func (o *Obj) Delete()

Delete 删除对象

func (*Obj) IsDelete

func (o *Obj) IsDelete() bool

IsDelete 对象是否删除

func (Obj) Match

func (o Obj) Match(txt string) bool

Match 查找匹配

type Order

type Order struct {
	ID    utils.ID `json:"id"`    // 商品
	Num   int      `json:"num"`   // 数量
	Price int64    `json:"price"` // 价格,单位分
	Cost  int64    `json:"cost"`  // 成本,单位分
}

Order 订单子项

type Paging

type Paging struct {
	Data  interface{} `json:"data"`  // 数据
	Total int         `json:"total"` // 总数
}

Paging 分页对象

type Poster

type Poster interface {
	// BeforePost 保存前
	BeforePost(key byte) utils.ID
}

Poster 新对象操作

type Puter

type Puter interface {
	// BeforePut 修改前
	BeforePut(id utils.ID)
}

Puter 对象修改

type Tag

type Tag struct {
	Obj
	Color string          `json:"color"` // 颜色
	Use   map[string]bool `json:"use"`   // 使用
	Nums  map[string]int  `json:"nums"`  // 数量
}

Tag 标签

type Tags

type Tags []string

Tags 标签

func (*Tags) Add

func (t *Tags) Add(tag string)

Add 增加新标签

func (*Tags) DelPy

func (t *Tags) DelPy()

DelPy 删除拼音标签

func (Tags) Includes

func (t Tags) Includes(tags []string) bool

Includes 包含

func (Tags) Sort

func (t Tags) Sort()

Sort 标签排序

type Trade

type Trade struct {
	ID     utils.ID    `json:"id"`                      // 主键
	CID    utils.ID    `json:"cid"`                     // 客户ID
	Status TradeStatus `json:"status"`                  // 状态
	Ca     time.Time   `json:"ca"`                      // 创建时间
	Pa     time.Time   `json:"pa"`                      // 付款时间
	Orders []Order     `json:"orders"`                  // 订单详情
	Cost   int64       `json:"cost"`                    // 成本,单位分
	Total  int64       `json:"total"`                   // 总额,单位分
	Note   string      `json:"note" validate:"lte=100"` // 备注 最长100
}

Trade 订单

func (*Trade) BeforePost

func (t *Trade) BeforePost(key byte) utils.ID

BeforePost 订单新建前

func (*Trade) BeforePut

func (t *Trade) BeforePut(id utils.ID)

BeforePut 修改订单

func (*Trade) HasItem added in v0.1.12

func (t *Trade) HasItem(itemID utils.ID) bool

HasItem 商品是否使用

type TradeStatus

type TradeStatus int

TradeStatus 订单状态

type User

type User struct {
	Obj
	Phone  string            `json:"phone"`  // 手机
	Pass   []byte            `json:"-"`      // 密码
	Admin  bool              `json:"admin"`  // 管理员
	Extend map[string]string `json:"extend"` // 扩展属性
}

User 用户

func (User) Match

func (u User) Match(txt string) bool

Match 匹配

type Web

type Web struct {
	Temp    string // 临时文件目录
	Db      string // 数据库目录
	Dev     bool   // 开发模式
	URL     string // 网址
	LogFile string // 日志文件
	App     *App   // 应用信息
	// contains filtered or unexported fields
}

Web 网络服务

func (*Web) Bind

func (w *Web) Bind(c echo.Context, o interface{}) error

Bind 对象绑定

func (*Web) Close

func (w *Web) Close()

Close 关闭服务

func (*Web) Delete

func (w *Web) Delete(key []byte) error

Delete 删除

func (*Web) Get

func (w *Web) Get(key []byte, p interface{}) error

Get 数据库数据读取

func (*Web) Init

func (w *Web) Init() error

Init 初始化.

func (*Web) Iterator

func (w *Web) Iterator(prefix []byte, f func(key, value []byte)) error

Iterator 迭代获取数据

func (*Web) ObjDelete

func (w *Web) ObjDelete(c echo.Context, key byte, check func(id utils.ID) error) error

ObjDelete 对象删除

func (*Web) ObjDeleter

func (w *Web) ObjDeleter(c echo.Context, key byte, obj Deleter, check func() error) error

ObjDeleter 对象删除器

func (*Web) ObjGet

func (w *Web) ObjGet(c echo.Context, o interface{}) error

ObjGet 对象获取

func (*Web) ObjLoad

func (w *Web) ObjLoad(c echo.Context, o interface{}) error

ObjLoad 对象加载

func (*Web) ObjPaging

func (w *Web) ObjPaging(c echo.Context, i interface{}) error

ObjPaging 分页

func (*Web) ObjPost

func (w *Web) ObjPost(c echo.Context, p Poster, key byte, bind func() error, check func() error) error

ObjPost 对象新增

func (*Web) ObjPut

func (w *Web) ObjPut(c echo.Context, p Puter, key byte, bind func() error, check func() error) error

ObjPut 对象修改

func (*Web) ObjSearch

func (w *Web) ObjSearch(c echo.Context, i interface{}) (interface{}, error)

ObjSearch 对象搜索

func (*Web) ObjSelect

func (w *Web) ObjSelect(c echo.Context, i interface{}) (interface{}, error)

ObjSelect 对象选择

func (*Web) Put

func (w *Web) Put(key []byte, p interface{}) error

Put 数据库数据保存

func (*Web) Reset

func (w *Web) Reset() error

Reset 重置帐目

func (*Web) Signed

func (w *Web) Signed(id string, pass []byte) (string, error)

Signed 创建令牌

func (*Web) Start

func (w *Web) Start(address string) error

Start starts an HTTP server.

func (*Web) StartAutoTLS

func (w *Web) StartAutoTLS(address string) error

StartAutoTLS starts an HTTPS server using certificates automatically installed from https://letsencrypt.org.

func (*Web) StartTLS

func (w *Web) StartTLS(address, certFile, keyFile string) error

StartTLS starts an HTTPS server.

func (*Web) UserInit

func (w *Web) UserInit()

UserInit 用户初始化

type Xlsx

type Xlsx struct {
	Obj
	Type int            `json:"type"` // 类型
	Map  map[int]string `json:"map"`  // 列定义
}

Xlsx Excel定义

Jump to

Keyboard shortcuts

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