xdatabase

package
v0.0.0-...-663b367 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMySQLGormDb

func NewMySQLGormDb(config *MySQLConfig) (e *gorm.DB, err error)

NewMySQLGormDb 创建MySQL客户端

func NewPostgresGormDb

func NewPostgresGormDb(config *PostgresConfig) (e *gorm.DB, err error)

func NewPostgresGormDbWithDSN

func NewPostgresGormDbWithDSN(dsn string) (e *gorm.DB, err error)

Types

type Minio

type Minio struct {
	Conf   MinioConfig
	Client *minio.Client
	// contains filtered or unexported fields
}

func (*Minio) GetFileBytes

func (m *Minio) GetFileBytes(objectName string, opts minio.GetObjectOptions) ([]byte, error)

GetFileBytes 获取文件字节流

func (*Minio) GetFileReader

func (m *Minio) GetFileReader(objectName string, opts minio.GetObjectOptions) (io.Reader, error)

GetFileReader 获取文件流

func (*Minio) GetFileUrl

func (m *Minio) GetFileUrl(objectName string, timeOut *time.Duration) string

func (*Minio) NewClient

func (m *Minio) NewClient(log *xlog.Logger) error

func (*Minio) UploadFile

func (m *Minio) UploadFile(objectName string, fileReader *os.File, opts minio.PutObjectOptions) error

UploadFile 根据文件流上传文件

func (*Minio) UploadFileByBuffer

func (m *Minio) UploadFileByBuffer(objectName string, buf *bytes.Buffer, opts minio.PutObjectOptions) error

UploadFileByBuffer 根据文件缓冲区上传文件

func (*Minio) UploadFileByBytes

func (m *Minio) UploadFileByBytes(objectName string, fileBytes []byte, opts minio.PutObjectOptions) error

UploadFileByBytes 根据文件字节流上传文件

func (*Minio) UploadFileByPath

func (m *Minio) UploadFileByPath(objectName, filePath string, opts minio.PutObjectOptions) error

UploadFileByPath 根据文件完整路径上传文件

type MinioConfig

type MinioConfig struct {
	Endpoint  string `yaml:"endpoint"`
	Bucket    string `yaml:"bucket"`
	AccessKey string `yaml:"access_key"`
	SecretKey string `yaml:"secret_key"`
}

type MySQLConfig

type MySQLConfig struct {
	Path            string `yaml:"path"`
	Username        string `yaml:"username"`
	Password        string `yaml:"password"`
	Database        string `yaml:"database"`
	Config          string `yaml:"config"`
	MaxIdleConns    int    `yaml:"max_idle_conns"`
	MaxOpenConns    int    `yaml:"max_open_conns"`
	ConnMaxLifetime int    `yaml:"conn_max_lifetime"`
	IsConsole       bool   `yaml:"is_console"`
}

MySQLConfig MySQL配置

type PostgresConfig

type PostgresConfig struct {
	URI       string `yaml:"uri"`
	Host      string `yaml:"host"`
	Port      int    `yaml:"port"`
	User      string `yaml:"user"`
	DBName    string `yaml:"dbname"`
	Password  string `yaml:"password"`
	SSLMode   string `yaml:"sslmode"`
	TimeZone  string `yaml:"timeZone"`
	IsConsole bool   `yaml:"is_console"`
}

Jump to

Keyboard shortcuts

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