xdb

package
v0.0.0-...-3001dc0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MailVisibleNormal = "normal"
	MailVisibleHidden = "hidden"
)
View Source
const (
	MailSourceTypeSystem = "system"
	MailSourceTypeUser   = "user"
)
View Source
const (
	MailReceiveTypeOnce    = "once"
	MailReceiveTypeUnlimit = "unlimit"
)
View Source
const (
	NotDeleted = "deleted_at IS NULL"
)

Variables

This section is empty.

Functions

func BeginTx

func BeginTx(rdb *redis.Client, cb func(tx *redis.Tx) error, keys ...string) error

func BuildFieldQuery

func BuildFieldQuery[T any](ydb *gorm.DB, newObj *T, queryFields []string) (*gorm.DB, error)

func Commit

func Commit(rdb *redis.Client, cb func(pipe redis.Pipeliner) error) error

func CommitTx

func CommitTx(tx *redis.Tx, cb func(pipe redis.Pipeliner) error) error

func DeleteMail

func DeleteMail(ydb *gorm.DB, userID, mailID int64) (int64, error)

func Getter

func Getter[T any, PT SetGetter[T]](rdb *redis.Client, key string) (*T, bool, error)

func InitMysql

func InitMysql(conf *xcm.MysqlConfig) (*gorm.DB, *ssh.Client, error)

func InitRedis

func InitRedis(conf *xcm.RedisConfig) (*redis.Client, *ssh.Client, error)

func Insert

func Insert[T any](ydb *gorm.DB, newObj *T, queryFields []string) (*T, bool, error)

func InsertMail

func InsertMail(ydb *gorm.DB, mail *Mail) (int64, error)

func MysqlOverSsh

func MysqlOverSsh(dsn string, cli *ssh.Client) string

func NewRedisOptions

func NewRedisOptions(addr, user, pass string, db int) *redis.Options

func NewRedisOptionsWithUrl

func NewRedisOptionsWithUrl(url string) *redis.Options

func PickMailAttachments

func PickMailAttachments(ydb *gorm.DB, userID, mailID int64,
	handleAttachments func(attachments AttachmentsType) error) error

func RedisOverSsh

func RedisOverSsh(opt *redis.Options, cli *ssh.Client) (*redis.Client, error)

func Setter

func Setter[T any](key string, t *T) func(redis.Pipeliner) error

Types

type AttachmentsType

type AttachmentsType map[string]any

type Mail

type Mail struct {
	gorm.Model `json:"model"`

	UserID            int64           `json:"user_id" gorm:"column:user_id;not null"`
	VisibleType       string          `json:"visible_type" gorm:"column:visible_type;type:varchar(128);not null"`
	SourceType        string          `json:"source_type" gorm:"type:varchar(128);not null"`
	SourceUuid        string          `json:"source_uuid" gorm:"type:varchar(255);not null"`
	ReceiveType       string          `json:"receive_type" gorm:"column:receive_type;type:varchar(128);index:idx_receive_type_uuid;not null"`
	ReceiveUuid       string          `json:"receive_uuid" gorm:"column:receive_uuid;type:varchar(255);index:idx_receive_type_uuid"`
	Subject           string          `json:"subject" gorm:"type:text;not null"`
	Body              string          `json:"body" gorm:"type:text;"`
	AttachmentsJSON   string          `json:"-" gorm:"type:json"`
	AttachmentsPicked bool            `json:"-" gorm:"column:attachments_picked"`
	Attachments       AttachmentsType `json:"attachments" gorm:"-"`
}

func GetMailList

func GetMailList(ydb *gorm.DB, userID int64, offset, limit int, order string, seeall bool) ([]*Mail, error)

type SetGetter

type SetGetter[T any] interface {
	Init()
	*T
}

Jump to

Keyboard shortcuts

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