feat(sms): add sms login method
This commit is contained in:
@ -5,6 +5,7 @@ import "github.com/BurntSushi/toml"
|
||||
type Config struct {
|
||||
Server ServerConfig `toml:"server"`
|
||||
DB DBConfig `toml:"db"`
|
||||
Redis RedisConfig `toml:"redis"`
|
||||
}
|
||||
|
||||
type ServerConfig struct {
|
||||
@ -19,6 +20,13 @@ type DBConfig struct {
|
||||
Passwd string `toml:"passwd"`
|
||||
}
|
||||
|
||||
type RedisConfig struct {
|
||||
Host string `toml:"host"`
|
||||
Port int `toml:"port"`
|
||||
DB int `toml:"db"`
|
||||
Passwd string `toml:"passwd"`
|
||||
}
|
||||
|
||||
var Conf *Config
|
||||
|
||||
func ReadConfig(path string) error {
|
||||
|
27
config/redis.go
Normal file
27
config/redis.go
Normal file
@ -0,0 +1,27 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/redis/go-redis/v9"
|
||||
)
|
||||
|
||||
var (
|
||||
RDC *redis.Client
|
||||
CTX = context.Background()
|
||||
)
|
||||
|
||||
func InitRedis() {
|
||||
RDC = redis.NewClient(&redis.Options{
|
||||
Addr: fmt.Sprintf("%s:%d", Conf.Redis.Host, Conf.Redis.Port),
|
||||
Password: Conf.Redis.Passwd,
|
||||
DB: Conf.Redis.DB,
|
||||
})
|
||||
}
|
||||
|
||||
func CloseRedis() {
|
||||
err := RDC.Close()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user