models

package
v0.0.0-...-9beddec Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DelPassword

func DelPassword(db orm.Ormer, user string) error

DelPassword 将指定user的password设置为null

func DelUser

func DelUser(db orm.Ormer, name string) error

DelUser 删除名字与name相同的User,同时会删除UserAmount记录

func GetDBPath

func GetDBPath() (string, error)

GetDBPath 获取数据库存放路径

func PKCS5Padding

func PKCS5Padding(origData []byte, blockSize int) []byte

PKCS5Padding 将数据填充至合适的大小,以便加密算法处理

func PKCS5UnPadding

func PKCS5UnPadding(origData []byte) []byte

PKCS5UnPadding 去除填充

func SetUsedAmount

func SetUsedAmount(db orm.Ormer,
	user string,
	service *parser.Service,
	total, upload, download int,
	date time.Time) error

SetUsedAmount 根据sevice插入使用量信息. 若date已经存在,则更新数据

func SetUserPassword

func SetUserPassword(db orm.Ormer, user string, password string) error

SetUserPassword 将用户名密码保存 password为nil表示不记住密码

Types

type UsedAmount

type UsedAmount struct {
	Id       int    `orm:"auto"`
	Service  string `orm:"size(50)"`
	Total    int
	Upload   int
	Download int
	Date     time.Time `orm:"type(date)"`
	User     *User     `orm:"rel(fk);on_delete(cascade)"`
}

用户的每日的流量使用记录,以service进行区分

func GetRecentUsedAmount

func GetRecentUsedAmount(db orm.Ormer,
	user, service string,
	date time.Time) ([]*UsedAmount, error)

GetRecentUsedAmount 返回date开始最近maxDays天的使用量数据 如果数量不足5天,则以最早一天的数据进行复制补足

type User

type User struct {
	Name   string `orm:"size(100);pk"`
	Passwd string `orm:"size(100);null"`
}

User 用户表,将和使用量表关联

func GetAllUsers

func GetAllUsers(db orm.Ormer) ([]*User, error)

GetAllUsers 返回所有user,包括未

func GetUserPassword

func GetUserPassword(db orm.Ormer, user string) (*User, error)

GetUserPassword 获取用户名以及密码

Jump to

Keyboard shortcuts

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