feat(sms): add sms login method

This commit is contained in:
2024-10-28 14:41:27 +08:00
parent bb580ff488
commit b5b839fdba
13 changed files with 532 additions and 20 deletions

View File

@ -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
View 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)
}
}