add models and jwt

This commit is contained in:
张超
2024-01-10 16:05:15 +08:00
parent 45bc7c5140
commit 2455f0d897
19 changed files with 990 additions and 4 deletions

22
conf/conf.ini Normal file
View File

@@ -0,0 +1,22 @@
[mysql]
Type = mysql
Host = 127.0.0.1
Port = 3306
User = root
Password = root
DB = login
Charset = utf8mb4
;Prefix = gin_
[jwt]
SecretKey = \x13\xbf\xd2 1\xce\x8b\xc1\t\xc1=\xec\x07\x93\xd4\x9e\xbco\xb0Z
[project]
StaticUrlMapPath = {"assets/static/": "static/", "assets/docs/": "docs/", "media/": "media/"}
TemplateGlob = templates/**/*
MediaFilePath = "media/upload/"
[server]
Port = 7890
ReadTimeout = 60
WriteTimeout = 60

65
conf/config.go Normal file
View File

@@ -0,0 +1,65 @@
/*
@Time : 2020/6/28 21:48
@Author : xuyiqing
@File : config.py
*/
package conf
import (
"github.com/go-ini/ini"
"time"
)
type SqlDataBase struct {
Type string
Host string
Port string
User string
Password string
DB string
Charset string
Prefix string
}
type Jwt struct {
SecretKey string
}
type Project struct {
StaticUrlMapPath string
TemplateGlob string
MediaFilePath string
}
type Server struct {
Port string
ReadTimeout time.Duration
WriteTimeout time.Duration
}
var (
DataBase = &SqlDataBase{}
JwtSecretKey = &Jwt{}
ProjectCfg = &Project{}
HttpServer = &Server{}
)
func SetUp() {
cfg, err := ini.Load("conf/conf.ini")
if err != nil {
panic(err)
}
if err := cfg.Section("mysql").MapTo(DataBase); err != nil {
panic(err)
}
if err := cfg.Section("jwt").MapTo(JwtSecretKey); err != nil {
panic(err)
}
if err := cfg.Section("project").MapTo(ProjectCfg); err != nil {
panic(err)
}
if err := cfg.Section("server").MapTo(HttpServer); err != nil {
panic(err)
}
}