fix: update user nickname;

feat: add database/kafka.
This commit is contained in:
loveuer
2024-12-04 15:49:37 +08:00
parent 3ec150b015
commit e5ae2efcef
15 changed files with 585 additions and 64 deletions

View File

@ -3,25 +3,32 @@ package db
import (
"context"
"io"
"ultone/internal/opt"
"ultone/internal/tool"
"gorm.io/gorm"
)
var (
Default *Client
var Default *Client
type DBType string
const (
DBTypeSqlite = "sqlite"
DBTypeMysql = "mysql"
DBTypePostgres = "postgres"
)
type Client struct {
ctx context.Context
cli *gorm.DB
ttype string
dbType DBType
cfgSqlite *cfgSqlite
}
func (c *Client) Type() string {
return c.ttype
func (c *Client) Type() DBType {
return c.dbType
}
func (c *Client) Session(ctxs ...context.Context) *gorm.DB {
@ -49,7 +56,7 @@ func (c *Client) Close() {
// Dump
// Only for sqlite with mem mode to dump data to bytes(io.Reader)
func (c *Client) Dump() (reader io.ReadSeekCloser, ok bool) {
if c.ttype != "sqlite" {
if c.dbType != DBTypeSqlite {
return nil, false
}