db

package
v0.0.0-...-c275005 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MailSearchOptionsTypeSend = iota
	MailSearchOptionsTypeInbox
	MailSearchOptionsTypeDraft
	MailSearchOptionsTypeDeleted
	MailSearchOptionsTypeFlags
	MailSearchOptionsTypeJunk
	MailSearchOptionsTypeUnread
)

Variables

View Source
var Tables = []interface{}{
	new(User), new(Domain), new(Mail),
	new(MailLog), new(MailContent), new(Box),
	new(Class), new(Queue),
}

Functions

func BoxUserList

func BoxUserList(uid int64) (int64, int64)

func BoxUserMessageCountByClassName

func BoxUserMessageCountByClassName(uid int64, className string) (int64, int64)

Get statistics under classification

func BoxUserTotal

func BoxUserTotal(uid int64) (int64, int64)

func CheckDb

func CheckDb() bool

func ClassGetIdByName

func ClassGetIdByName(uid int64, name string) (int64, error)

func CreateUser

func CreateUser(u *User) (err error)

CreateUser creates record of a new user.

func DomainCount

func DomainCount() int64

func DomainCreate

func DomainCreate(d *Domain) (err error)

func DomainDeleteById

func DomainDeleteById(id int64) error

func DomainDeleteByName

func DomainDeleteByName(name string) error

func DomainGetMainForDomain

func DomainGetMainForDomain() (string, error)

func DomainSetDefaultOnlyOne

func DomainSetDefaultOnlyOne(id int64) error

func DomainUpdateById

func DomainUpdateById(id int64, d Domain) error

func DomainVaild

func DomainVaild(name string) bool

func Init

func Init() error

func LogAdd

func LogAdd(ty, content string) error

func LogClear

func LogClear() error

func LogCount

func LogCount() int64

func LogDeleteById

func LogDeleteById(id int64) error

func LoginByUserPassword

func LoginByUserPassword(name string, password string) (bool, int64)

func LoginWithCode

func LoginWithCode(name string, code string) (bool, int64)

func MailContentDelete

func MailContentDelete(uid int64, mid int64) bool

func MailContentDeleteDb

func MailContentDeleteDb(mid int64) bool

func MailContentDeleteHardDisk

func MailContentDeleteHardDisk(uid int64, mid int64) bool

func MailContentDir

func MailContentDir(uid, mid int64) string

func MailContentFilename

func MailContentFilename(uid, mid int64) string

func MailContentRead

func MailContentRead(uid, mid int64) (string, error)

func MailContentReadDb

func MailContentReadDb(mid int64) (string, error)

func MailContentReadHardDisk

func MailContentReadHardDisk(uid int64, mid int64) (string, error)

func MailContentWrite

func MailContentWrite(uid int64, mid int64, content string) error

func MailContentWriteDb

func MailContentWriteDb(mid int64, content string) error

func MailContentWriteHardDisk

func MailContentWriteHardDisk(uid int64, mid int64, content string) error

func MailCount

func MailCount() int64

func MailCountWithOpts

func MailCountWithOpts(opts *MailSearchOptions) int64

func MailDeleteById

func MailDeleteById(id int64, status int64) bool

func MailHardDeleteById

func MailHardDeleteById(uid, mid int64) bool

func MailHardDeleteByIds

func MailHardDeleteByIds(ids []int64) bool

TODO:批量硬删除邮件数据

func MailPosContentForPop

func MailPosContentForPop(uid int64, pos int64) (string, int, error)

func MailPush

func MailPush(uid int64, mtype int, mail_from string, mail_to string, content string, status int, is_draft bool) (int64, error)

func MailPushReceive

func MailPushReceive(uid int64, mail_from string, mail_to string, content string) (int64, error)

func MailPushSend

func MailPushSend(uid int64, mail_from string, mail_to string, content string, is_draft bool) (int64, error)

func MailSearchByNameCond

func MailSearchByNameCond(opts *MailSearchOptions, dbm *gorm.DB) *gorm.DB

func MailSeenById

func MailSeenById(id int64) bool

func MailSeenByIds

func MailSeenByIds(ids []int64) bool

func MailSetFlagsById

func MailSetFlagsById(id int64, status int64) bool

func MailSetIsCheckById

func MailSetIsCheckById(id int64, status int64) bool

func MailSetJunkById

func MailSetJunkById(id int64, status int64) bool

func MailSetJunkByIds

func MailSetJunkByIds(ids []int64, status int64) bool

func MailSetStatusById

func MailSetStatusById(id int64, status int64) bool

func MailSoftDeleteById

func MailSoftDeleteById(id int64) bool

func MailSoftDeleteByIds

func MailSoftDeleteByIds(ids []int64) bool

func MailStatInfo

func MailStatInfo(uid int64, mtype int64) (int64, int64)

func MailStatInfoForImap

func MailStatInfoForImap(uid int64, mtype int64) (int64, int64)

func MailStatInfoForPop

func MailStatInfoForPop(uid int64) (int64, int64)

func MailUnSeenById

func MailUnSeenById(id int64) bool

func MailUnSeenByIds

func MailUnSeenByIds(ids []int64) bool

func MailUpdate

func MailUpdate(id int64, uid int64, mtype int, mail_from string, mail_to string, content string, status int, is_draft bool) (int64, error)

func Ping

func Ping() error

func TablePrefix

func TablePrefix(tn string) string

func UpdateUser

func UpdateUser(u *User) error

UpdateUser updates user's information.

func UserCheckIsExist

func UserCheckIsExist(name string) bool

func UserGetAdminForName

func UserGetAdminForName() (string, error)

func UserUpdateCodeGetById

func UserUpdateCodeGetById(id int64, code string) error

func UserUpdateCodeGetByName

func UserUpdateCodeGetByName(name string, code string) bool

func UserUpdateNickGetByName

func UserUpdateNickGetByName(name string, nick string) error

func UserUpdateTokenGetById

func UserUpdateTokenGetById(id int64, token string) error

func UserUpdateTokenGetByName

func UserUpdateTokenGetByName(name string, token string) bool

func UserUpdater

func UserUpdater(u *User) error

func UsersCount

func UsersCount() int64

func UsersVaildCount

func UsersVaildCount() int64

Types

type Box

type Box struct {
	Id         int64 `gorm:"primaryKey"`
	Uid        int64 `gorm:"comment:UID"`
	Mid        int64 `gorm:"comment:MID"`
	Type       int   `gorm:"comment:TYPE|0:接收邮件;1:发送邮件"`
	Size       int   `gorm:"comment:邮件内容大小[byte]"`
	UpdateTime int64 `gorm:"autoCreateTime;comment:更新时间"`
	CreateTime int64 `gorm:"autoCreateTime;comment:创建时间"`
}

func (Box) TableName

func (Box) TableName() string

type Class

type Class struct {
	Id         int64  `gorm:"primaryKey"`
	Uid        int64  `gorm:"comment:用户ID"`
	Name       string `gorm:"size:50;comment:分类名"`
	Type       string `gorm:"size:50;comment:类型"`
	UpdateTime int64  `gorm:"autoCreateTime;comment:更新时间"`
	CreateTime int64  `gorm:"autoCreateTime;comment:创建时间"`
}

func (Class) TableName

func (Class) TableName() string

type DIRType

type DIRType int32
const (
	DIR_DELETED DIRType = 0
	DIR_JUNK    DIRType = 1
	DIR_READ    DIRType = 2
	DIR_FLAGS   DIRType = 3
)

type Domain

type Domain struct {
	Id          int64     `gorm:"primaryKey"`
	Domain      string    `gorm:"unique;comment:顶级域名"`
	Mx          bool      `gorm:"comment:MX记录"`
	A           bool      `gorm:"comment:A记录"`
	Spf         bool      `gorm:"comment:Spf记录"`
	Dkim        bool      `gorm:"comment:Dkim记录"`
	Dmarc       bool      `gorm:"comment:DMARC记录"`
	IsDefault   bool      `gorm:"comment:是否默认"`
	Created     time.Time `gorm:"autoCreateTime;comment:创建时间"`
	CreatedUnix int64     `gorm:"autoCreateTime;comment:创建时间"`
	Updated     time.Time `gorm:"autoCreateTime;comment:更新时间"`
	UpdatedUnix int64     `gorm:"autoCreateTime;comment:更新时间"`
}

func DomainGetById

func DomainGetById(id int64) (Domain, error)

func DomainGetMain

func DomainGetMain() (Domain, error)

func DomainList

func DomainList(page, pageSize int) ([]Domain, error)

func DomainVaildList

func DomainVaildList(page, pageSize int) ([]Domain, error)

func (*Domain) TableName

func (*Domain) TableName() string

type LogSearchOptions

type LogSearchOptions struct {
	Keyword  string
	OrderBy  string
	Page     int
	PageSize int
	TplName  string
}

type Mail

type Mail struct {
	Id                int64  `gorm:"primaryKey"`
	Uid               int64  `gorm:"index;comment:UserID"`
	Type              int    `gorm:"index;comment:0:Send;1:Received"`
	MailFrom          string `gorm:"size:50;comment:Mail From"`
	MailFromInContent string `gorm:"text;comment:Mail From Name In Content"`
	MailTo            string `gorm:"size:50;comment:Receive mail"`
	Subject           string `gorm:"size:191;comment:Subject"`
	SubjectIndex      string `gorm:"index;size:191;comment:Index Subject"`
	Size              int    `gorm:"size:10;comment:Message content size"`
	Status            int    `gorm:"size:2;comment:'0:准备发送;1:发送成功;2:发送失败;3:已接收'"`

	IsRead   bool `gorm:"index;default:0;comment:是否已读"`
	IsDelete bool `gorm:"index;default:0;comment:是否删除"`
	IsFlags  bool `gorm:"index;default:0;comment:是否星标"`
	IsJunk   bool `gorm:"index;default:0;comment:是否无用"`
	IsDraft  bool `gorm:"index;default:0;comment:是否草稿"`

	IsCheck bool `gorm:"default:0;comment:是否通过检查"`

	Created     time.Time `gorm:"autoCreateTime;comment:创建时间"`
	CreatedUnix int64     `gorm:"autoCreateTime;comment:创建时间:UNIX"`
	Updated     time.Time `gorm:"autoCreateTime;comment:更新时间"`
	UpdatedUnix int64     `gorm:"autoCreateTime;comment:更新时间:UNIX"`
}

func BoxListByImap

func BoxListByImap(uid int64, className string, start int64, end int64) ([]Mail, error)

// Paging List of Imap Protocol

func BoxListByMid

func BoxListByMid(uid int64, className string, mid int64) ([]Mail, error)

func MailById

func MailById(id int64) (Mail, error)

用过ID获取邮件的全部信息

func MailDeletedListAllForImap

func MailDeletedListAllForImap(uid int64) ([]Mail, error)

func MailList

func MailList(page, pageSize int, opts *MailSearchOptions) ([]Mail, error)

func MailListAllForPop

func MailListAllForPop(uid int64) ([]Mail, error)

func MailListForImap

func MailListForImap(uid int64) []Mail

func MailListForPop

func MailListForPop(uid int64) []Mail

func MailListForRspamd

func MailListForRspamd(limit int64) []Mail

func MailListPosForPop

func MailListPosForPop(uid int64, pos int64) ([]Mail, error)

func MailSearchByName

func MailSearchByName(opts *MailSearchOptions) (user []Mail, _ int64, _ error)

func MailSendListForStatus

func MailSendListForStatus(status int64, limit int64) []Mail

func (*Mail) TableName

func (*Mail) TableName() string

type MailContent

type MailContent struct {
	Id      int64  `gorm:"primaryKey"`
	Mid     int64  `gorm:"uniqueIndex;comment:MID"`
	Content string `gorm:"comment:Content"`
}

func (*MailContent) TableName

func (*MailContent) TableName() string

type MailLog

type MailLog struct {
	Id          int64  `gorm:"primaryKey"`
	Type        string `gorm:"index;comment:type"`
	Content     string `gorm:"comment:content"`
	CreatedUnix int64  `gorm:"autoCreateTime;comment:创建时间"`
	UpdatedUnix int64  `gorm:"autoCreateTime;comment:更新时间"`
}

func LogList

func LogList(page, pageSize int) ([]MailLog, error)

func LogSearchByName

func LogSearchByName(opts *LogSearchOptions) (user []MailLog, _ int64, _ error)

func (*MailLog) TableName

func (*MailLog) TableName() string

type MailSearchOptions

type MailSearchOptions struct {
	Keyword  string
	OrderBy  string
	Page     int
	PageSize int
	Type     int
	Uid      int64
}

type Queue

type Queue struct {
	Id         int64  `gorm:"primaryKey"`
	Uid        int64  `gorm:"comment:用户ID"`
	Type       int    `gorm:"comment:0:发送;1:收到"`
	MailFrom   string `gorm:"size:50;comment:邮件来源"`
	MailTo     string `gorm:"size:50;comment:接收邮件"`
	Content    string `gorm:"comment:邮件内容"`
	Size       int    `gorm:"size:50;comment:邮件内容大小"`
	Status     int    `gorm:"comment:0:准备发送;1:发送成功;2:发送失败;3:已接收"`
	UpdateTime int64  `gorm:"autoCreateTime;comment:更新时间"`
	CreateTime int64  `gorm:"autoCreateTime;comment:创建时间"`
}

func (Queue) TableName

func (Queue) TableName() string

type Statistic

type Statistic struct {
	Counter struct {
		User      int64
		VaildUser int64
	}
}

func GetStatistic

func GetStatistic() (stats Statistic)

type User

type User struct {
	Id       int64  `gorm:"primaryKey"`
	Name     string `gorm:"index:uniqueIndex;unique;size:50;comment:登录账户"`
	Nick     string `gorm:"index:uniqueIndex;unique;size:50;comment:昵称"`
	Password string `gorm:"size:32;comment:用户密码"`
	Salt     string `gorm:"type:varchar(10)"`
	Code     string `gorm:"size:50;comment:编码"`
	Status   int    `gorm:"comment:状态"`

	IsActive bool
	IsAdmin  bool

	Created     time.Time `gorm:"autoCreateTime;comment:创建时间"`
	CreatedUnix int64     `gorm:"autoCreateTime;comment:创建时间"`
	Updated     time.Time `gorm:"autoCreateTime;comment:更新时间"`
	UpdatedUnix int64     `gorm:"autoCreateTime;comment:更新时间"`
}

func UserGetAdmin

func UserGetAdmin() (User, error)

func UserGetById

func UserGetById(id int64) (User, error)

func UserGetByName

func UserGetByName(name string) (User, error)

func UserSearchByName

func UserSearchByName(opts *UserSearchOptions) (user []User, _ int64, _ error)

func UsersList

func UsersList(page, pageSize int) ([]User, error)

func (User) TableName

func (User) TableName() string

func (*User) ValidPassword

func (u *User) ValidPassword(oldPwd string) bool

type UserSearchOptions

type UserSearchOptions struct {
	Keyword  string
	OrderBy  string
	Page     int
	PageSize int
	TplName  string
}

Jump to

Keyboard shortcuts

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