db

package
v0.0.0-...-2b22c89 Latest Latest
Warning

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

Go to latest
Published: May 16, 2023 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenUserToken

func GenUserToken() string

Types

type BaseModel

type BaseModel struct {
	Created int64 `json:"created"`
	Updated int64 `json:"updated"`
}

type Config

type Config struct {
	DSN string `mapstructure:"dsn"`
}

type DB

type DB struct {
	*leveldb.DB
}

func NewDB

func NewDB(cfg *Config) (*DB, error)

func (*DB) Close

func (db *DB) Close()

func (*DB) Create

func (db *DB) Create(m Model) error

func (*DB) CreateUser

func (db *DB) CreateUser(m *User) error

func (*DB) GenUserSid

func (db *DB) GenUserSid() string

func (*DB) GetUserByGithub

func (db *DB) GetUserByGithub(gid int64) (*User, error)

func (*DB) GetUserBySid

func (db *DB) GetUserBySid(sid string) (*User, error)

func (*DB) GetUserByToken

func (db *DB) GetUserByToken(token string, withapi bool) (*User, error)

func (*DB) Update

func (db *DB) Update(m Model) error

func (*DB) UpdateUser

func (db *DB) UpdateUser(m *User) error

func (*DB) UserExistWithSid

func (db *DB) UserExistWithSid(sid string) bool

type GithubUserInfo

type GithubUserInfo struct {
	ID     int64  `json:"id"`
	Name   string `json:"name"`
	Email  string `json:"email"`
	Home   string `json:"html_url"`
	Avatar string `json:"avatar_url"`
}

type Model

type Model interface {
	// contains filtered or unexported methods
}

type Notify

type Notify struct {
	Enable bool `json:"enable"`
	Bark   struct {
		Key    string `json:"key"`
		Server string `json:"server"`
	} `json:"bark"`
	Dingtalk struct {
		Token  string `json:"token"`
		Secret string `json:"secret"`
	} `json:"dingtalk"`
	Lark struct {
		Token  string `json:"token"`
		Secret string `json:"secret"`
	} `json:"lark"`
	Feishu struct {
		Token  string `json:"token"`
		Secret string `json:"secret"`
	} `json:"feishu"`
	ServerChan struct {
		UserID  string `json:"user_id"`
		SendKey string `json:"send_key"`
	} `json:"serverchan"`
}

type User

type User struct {
	BaseModel
	GithubUserInfo
	Sid       string `json:"sid"`       // 用于分配子域名
	Token     string `json:"token"`     // token
	APIToken  string `json:"api_token"` // API Token
	DnsRebind struct {
		DNS   []string `json:"dns"`
		Times int64    `json:"times"`
	} `json:"dns_rebind"`
	Notify Notify `json:"notify"`
}

Jump to

Keyboard shortcuts

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