瀏覽代碼

simplify code

joe 4 年之前
父節點
當前提交
2b29fce3ef
共有 19 個文件被更改,包括 146 次插入83 次删除
  1. 2 2
      .gitignore
  2. 2 1
      cmd/root.go
  3. 2 2
      cmd/server.go
  4. 1 1
      cmd/version.go
  5. 23 27
      config/config.go
  6. 31 0
      config/flytalk.toml
  7. 54 0
      config/lang.go
  8. 1 0
      controller/about.go
  9. 0 38
      controller/auth.go
  10. 1 1
      controller/ip.go
  11. 1 1
      controller/visitor.go
  12. 1 1
      database/mysql.go
  13. 5 2
      go.mod
  14. 19 5
      go.sum
  15. 0 0
      lang/en/flytalk.js
  16. 0 0
      lang/zh/flytalk.js
  17. 1 0
      middleware/jwt.go
  18. 1 1
      models/models.go
  19. 1 1
      user/provider/twong/user.go

+ 2 - 2
.gitignore

@@ -1,7 +1,7 @@
 .idea
 imaptool.exe
-gofly
+flytalk
 logs/
 static/upload/
 *.tar.gz
-bin/
+bin/

+ 2 - 1
cmd/root.go

@@ -19,17 +19,18 @@ var rootCmd = &cobra.Command{
 
 func args(cmd *cobra.Command, args []string) error {
 	if len(args) < 1 {
-
 		return errors.New("至少需要一个参数!")
 	}
 	return nil
 }
+
 func Execute() {
 	if err := rootCmd.Execute(); err != nil {
 		fmt.Println(err)
 		os.Exit(1)
 	}
 }
+
 func init() {
 	rootCmd.AddCommand(versionCmd)
 	rootCmd.AddCommand(serverCmd)

+ 2 - 2
cmd/server.go

@@ -1,7 +1,6 @@
 package cmd
 
 import (
-	"git.wanbits.cc/sin/flytalk/config"
 	"git.wanbits.cc/sin/flytalk/docs"
 	"git.wanbits.cc/sin/flytalk/router"
 	"git.wanbits.cc/sin/flytalk/tools"
@@ -21,8 +20,8 @@ var (
 	port        string
 	tcpport     string
 	daemon      bool
-	GoflyConfig *config.Config
 )
+
 var serverCmd = &cobra.Command{
 	Use:     "server",
 	Short:   "example:flytalk server port 8081",
@@ -38,6 +37,7 @@ func init() {
 	serverCmd.PersistentFlags().StringVarP(&tcpport, "tcpport", "t", "8082", "监听tcp端口号")
 	serverCmd.PersistentFlags().BoolVarP(&daemon, "daemon", "d", false, "是否为守护进程模式")
 }
+
 func run() {
 	if daemon == true {
 		if os.Getppid() != 1 {

+ 1 - 1
cmd/version.go

@@ -10,6 +10,6 @@ var versionCmd = &cobra.Command{
 	Use:   "version",
 	Short: "example:flytalk version",
 	Run: func(cmd *cobra.Command, args []string) {
-		fmt.Println("flytalk " + config.Version)
+		fmt.Println("flytalk " + config.VERSION)
 	},
 }

+ 23 - 27
config/config.go

@@ -9,15 +9,19 @@ import (
 )
 
 var (
-	PageSize        uint = 10
-	VisitorPageSize uint = 8
-	Version              = "0.1.2"
-	GoflyConfig     *Config
-	QiniuConfig     *Qiniu
+	PageSize uint = 10
+
+	GoflyConfig *Config
+	QiniuConfig *Qiniu
+)
+
+const (
+	VERSION           = "0.1.2"
+	PAGE_SIZE_VISITOR = 8
+	DIR               = "config"
 )
 
 const Dir = "config/"
-const AccountConf = Dir + "account.json"
 const MysqlConf = Dir + "mysql.json"
 const QiniuFile = Dir + "qiniu.json"
 const MailConf = Dir + "mail.json"
@@ -29,10 +33,11 @@ func init() {
 	QiniuConfig = CreateQiniu(QiniuFile)
 }
 
-type Mysql struct {
+type Database struct {
+	Driver   string
 	Server   string
 	Port     string
-	Database string
+	Db       string
 	Username string
 	Password string
 }
@@ -48,16 +53,17 @@ type Qiniu struct {
 type MailServer struct {
 	Server, Email, Password string
 }
+
 type Config struct {
-	Upload            string
-	NoticeServerJiang bool
+	Upload       string
+	NoticeServer bool
 }
 
 func CreateConfig() *Config {
 	var configObj Config
 	c := &Config{
-		Upload:            "static/upload/",
-		NoticeServerJiang: false,
+		Upload:       "static/upload/",
+		NoticeServer: false,
 	}
 	isExist, _ := tools.IsFileExist(MainConf)
 	if !isExist {
@@ -70,6 +76,7 @@ func CreateConfig() *Config {
 	err = json.Unmarshal(info, &configObj)
 	return &configObj
 }
+
 func CreateMailServer() *MailServer {
 	var imap MailServer
 	isExist, _ := tools.IsFileExist(MailConf)
@@ -84,8 +91,9 @@ func CreateMailServer() *MailServer {
 	err = json.Unmarshal(info, &imap)
 	return &imap
 }
-func CreateMysql(f string) *Mysql {
-	var mysql Mysql
+
+func CreateMysql(f string) *Database {
+	var mysql Database
 	isExist, _ := tools.IsFileExist(f)
 	if !isExist {
 		return &mysql
@@ -130,20 +138,7 @@ func GetMysql() map[string]string {
 	err = json.Unmarshal(info, &mysql)
 	return mysql
 }
-func GetAccount() map[string]string {
-	var account map[string]string
-	isExist, _ := tools.IsFileExist(AccountConf)
-	if !isExist {
-		return account
-	}
-	info, err := ioutil.ReadFile(AccountConf)
-	if err != nil {
-		return account
-	}
 
-	err = json.Unmarshal(info, &account)
-	return account
-}
 func GetUserInfo(uid string) map[string]string {
 	var userInfo map[string]string
 	userFile := Dir + "sess_" + uid + ".json"
@@ -159,6 +154,7 @@ func GetUserInfo(uid string) map[string]string {
 	err = json.Unmarshal(info, &userInfo)
 	return userInfo
 }
+
 func SetUserInfo(uid string, info map[string]string) {
 	userFile := Dir + "sess_" + uid + ".json"
 	isExist, _ := tools.IsFileExist(Dir)

+ 31 - 0
config/flytalk.toml

@@ -0,0 +1,31 @@
+[basic]
+upload=""
+noticeServer=""
+lang=""
+
+[database]
+driver="mysql"
+host=""
+port=3306
+db="flytalk"
+username=""
+password=""
+
+[imap]
+server=""
+email=""
+password=""
+
+[qiniu]
+access="SneSBtnWLdStBhCx0O_QogNkXoRlKNOiv1--XMBB"
+secret="GXMg-ENcp2UKYQWdeaf43tk_06NnMoA4OVFxdkYw"
+bucket="twongd"
+zone="huanan"
+domain="http://twongpicd.shotshock.shop/"
+
+[twong]
+server="192.168.3.187"
+port="58888"
+db="twong"
+username="twong"
+password="twong"

+ 54 - 0
config/lang.go

@@ -0,0 +1,54 @@
+package config
+
+var (
+	defaultLang = NewLang("lang")
+)
+
+func SetDefaultLang(l *Lang) {
+	defaultLang = l
+}
+
+type Lang struct {
+	baseDir   string            // lang file base dir
+	lang      string            // current language
+	words     map[string]string // single lang words
+	supported map[string]int    // supported langs
+}
+
+func NewLang(dir string) *Lang {
+	return &Lang{
+		baseDir:   dir,
+		lang:      "en",
+		words:     make(map[string]string),
+		supported: map[string]int{"en": 1},
+	}
+}
+
+func (self *Lang) Register(lang string) {
+	self.supported[lang] = 1
+}
+
+func (self *Lang) ChLang(newLang string) {
+	// check
+	self.lang = newLang
+	// reload
+}
+
+func (self *Lang) Get(k string) string {
+	if r, ok := self.words[k]; ok {
+		return r
+	}
+	//log
+	return ""
+}
+
+func (self *Lang) reload() {
+}
+
+func (self *Lang) check() {
+
+}
+
+func (self *Lang) scan() {
+
+}

+ 1 - 0
controller/about.go

@@ -17,6 +17,7 @@ func GetAbout(c *gin.Context) {
 		"result": about,
 	})
 }
+
 func PostAbout(c *gin.Context) {
 	title_cn := c.PostForm("title_cn")
 	title_en := c.PostForm("title_en")

+ 0 - 38
controller/auth.go

@@ -6,25 +6,6 @@ import (
 	"git.wanbits.cc/sin/flytalk/tools"
 )
 
-func CheckPass(username string, password string) string {
-	account := config.GetAccount()
-	if account == nil {
-		account = make(map[string]string)
-	}
-	if account["Username"] == "" && account["Password"] == "" {
-		account["Username"] = "admin"
-		account["Password"] = "admin123"
-	}
-	if username == account["Username"] && password == account["Password"] {
-
-		sessionId := tools.Md5(username)
-		info := make(map[string]string)
-		info["username"] = username
-		config.SetUserInfo(sessionId, info)
-		return sessionId
-	}
-	return ""
-}
 func CheckKefuPass(username string, password string) (models.User, models.User_role, bool) {
 	info := models.FindUser(username)
 	var uRole models.User_role
@@ -35,25 +16,6 @@ func CheckKefuPass(username string, password string) (models.User, models.User_r
 
 	return info, uRole, true
 }
-func AuthLocal(username string, password string) string {
-	account := config.GetAccount()
-	if account == nil {
-		account = make(map[string]string)
-	}
-	if account["Username"] == "" && account["Password"] == "" {
-		account["Username"] = "admin"
-		account["Password"] = "admin123"
-	}
-	if username == account["Username"] && password == account["Password"] {
-
-		sessionId := tools.Md5(username)
-		info := make(map[string]string)
-		info["username"] = username
-		config.SetUserInfo(sessionId, info)
-		return sessionId
-	}
-	return ""
-}
 
 //验证是否已经登录
 func AuthCheck(uid string) map[string]string {

+ 1 - 1
controller/ip.go

@@ -44,7 +44,7 @@ func GetIpblacks(c *gin.Context) {
 		page = 1
 	}
 	count := models.CountIps(nil, nil)
-	list := models.FindIps(nil, nil, uint(page), config.VisitorPageSize)
+	list := models.FindIps(nil, nil, uint(page), config.PAGE_SIZE_VISITOR)
 	c.JSON(200, gin.H{
 		"code": 200,
 		"msg":  "ok",

+ 1 - 1
controller/visitor.go

@@ -145,7 +145,7 @@ func GetVisitor(c *gin.Context) {
 func GetVisitors(c *gin.Context) {
 	page, _ := strconv.Atoi(c.Query("page"))
 	kefuId, _ := c.Get("kefu_name")
-	vistors := models.FindVisitorsByKefuId(uint(page), config.VisitorPageSize, kefuId.(string))
+	vistors := models.FindVisitorsByKefuId(uint(page), config.PAGE_SIZE_VISITOR, kefuId.(string))
 	count := models.CountVisitorsByKefuId(kefuId.(string))
 	c.JSON(200, gin.H{
 		"code": 200,

+ 1 - 1
database/mysql.go

@@ -14,7 +14,7 @@ type Mysql struct {
 
 func NewMysql() *Mysql {
 	mysql := config.CreateMysql(config.MysqlConf)
-	dsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8&parseTime=True&loc=Local", mysql.Username, mysql.Password, mysql.Server, mysql.Port, mysql.Database)
+	dsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8&parseTime=True&loc=Local", mysql.Username, mysql.Password, mysql.Server, mysql.Port, mysql.Db)
 	return &Mysql{
 		Dsn: dsn,
 	}

+ 5 - 2
go.mod

@@ -19,13 +19,16 @@ require (
 	github.com/gorilla/websocket v1.4.2
 	github.com/ipipdotnet/ipdb-go v1.3.0
 	github.com/jinzhu/gorm v1.9.14
-	github.com/qiniu/api.v7 v7.2.5+incompatible
 	github.com/qiniu/api.v7/v7 v7.6.0
 	github.com/satori/go.uuid v1.2.0
 	github.com/sirupsen/logrus v1.4.2
 	github.com/spf13/cobra v0.0.5
+	github.com/spf13/pflag v1.0.5 // indirect
 	github.com/swaggo/gin-swagger v1.2.0
 	github.com/swaggo/swag v1.5.1
 	golang.org/x/net v0.0.0-20201024042810-be3efd7ff127
-	golang.org/x/text v0.3.3
+	golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57 // indirect
+	golang.org/x/text v0.3.6
+	golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc // indirect
+	gopkg.in/yaml.v2 v2.4.0 // indirect
 )

+ 19 - 5
go.sum

@@ -40,6 +40,7 @@ github.com/emersion/go-textwrapper v0.0.0-20160606182133-d0e65e56babe h1:40SWqY0
 github.com/emersion/go-textwrapper v0.0.0-20160606182133-d0e65e56babe/go.mod h1:aqO8z8wPrjkscevZJFVE1wXJrLpC5LtJG7fqLOsPb2U=
 github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 h1:Yzb9+7DPaBjB8zlTR87/ElzFsnQfuHnVUVqpZZIcV5Y=
 github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0=
+github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
 github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
 github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
 github.com/gin-contrib/cors v1.3.1 h1:doAsuITavI4IOcd0Y19U4B+O0dNWihRyX//nn4sEmgA=
@@ -94,6 +95,7 @@ github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaW
 github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
 github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
 github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
+github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
 github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
 github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
 github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
@@ -141,6 +143,7 @@ github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Ky
 github.com/mattn/go-sqlite3 v1.14.0 h1:mLyGNKR8+Vv9CAU7PphKa2hkEqxxhn8i32J6FPj1/QA=
 github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus=
 github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
+github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
 github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
 github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
 github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
@@ -150,16 +153,14 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLD
 github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
 github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
 github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
+github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=
 github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
 github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
 github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
 github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
-github.com/qiniu/api.v7 v7.2.5+incompatible h1:6KKaGt7MbFzVGSniwzv7qsM/Qv0or4SkRJfmak8LqZE=
-github.com/qiniu/api.v7 v7.2.5+incompatible/go.mod h1:V8/EzlTgLN6q0s0CJmg/I81ytsvldSF22F7h6MI02+c=
 github.com/qiniu/api.v7/v7 v7.6.0 h1:396UGG+AWLh80pIhpPNCgEzb04t4S8CGKxqvLkiQeZI=
 github.com/qiniu/api.v7/v7 v7.6.0/go.mod h1:zg3DaqU8mVnoQSQmtC/Mr2wXTJIE7fvcup+7sMt58Q0=
-github.com/qiniu/x v1.11.5 h1:TYr5cl4g2yoHAZeDK4MTjKF6CMoG+IHlCDvvM5qym6U=
 github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
 github.com/rogpeppe/go-internal v1.3.0 h1:RR9dF3JtopPvtkroDZuVD7qquD0bnHlKSqaQhgwt8yk=
 github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
@@ -168,13 +169,18 @@ github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
 github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
 github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
 github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
+github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI=
 github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
+github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8=
 github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
 github.com/spf13/cobra v0.0.5 h1:f0B+LkLX6DtmRH1isoNA9VTtNUK9K8xYd28JNNfOv/s=
 github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
+github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk=
 github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
 github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
 github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
+github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
+github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
 github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
 github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
 github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
@@ -214,10 +220,9 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn
 golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
 golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
 golang.org/x/net v0.0.0-20190611141213-3f473d35a33a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
 golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
 golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
-golang.org/x/net v0.0.0-20200513185701-a91f0712d120 h1:EZ3cVSzKOlJxAd8e8YAJ7no8nNypTxexh/YE/xW3ZEY=
-golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
 golang.org/x/net v0.0.0-20201024042810-be3efd7ff127 h1:pZPp9+iYUqwYKLjht0SDBbRCRK/9gAXDy7pz5fRDpjo=
 golang.org/x/net v0.0.0-20201024042810-be3efd7ff127/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
 golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -237,16 +242,23 @@ golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20u
 golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA=
 golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57 h1:F5Gozwx4I1xtr/sr/8CFbb57iKi3297KFs0QDbGN60A=
+golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
 golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
 golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
 golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
+golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
 golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
 golang.org/x/tools v0.0.0-20190606050223-4d9ae51c2468/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
 golang.org/x/tools v0.0.0-20190611222205-d73e1c7e250b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
 golang.org/x/tools v0.0.0-20190624180213-70d37148ca0c h1:KfpJVdWhuRqNk4XVXzjXf2KAV4TBEP77SYdFGjeGuIE=
 golang.org/x/tools v0.0.0-20190624180213-70d37148ca0c/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
+golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc h1:NCy3Ohtk6Iny5V/reW2Ktypo4zIpWBdRJ1uFMjBxdg8=
+golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
@@ -258,3 +270,5 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
 gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
 gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
 gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
+gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=

+ 0 - 0
lang/en/flytalk.js


+ 0 - 0
lang/zh/flytalk.js


+ 1 - 0
middleware/jwt.go

@@ -15,6 +15,7 @@ func JwtPageMiddleware(c *gin.Context) {
 	//	c.Abort()
 	//}
 }
+
 func JwtApiMiddleware(c *gin.Context) {
 	token := c.GetHeader("token")
 	if token == "" {

+ 1 - 1
models/models.go

@@ -18,7 +18,7 @@ type Model struct {
 
 func init() {
 	mysql := config.CreateMysql(config.MysqlConf)
-	dsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8&parseTime=True&loc=Local", mysql.Username, mysql.Password, mysql.Server, mysql.Port, mysql.Database)
+	dsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8&parseTime=True&loc=Local", mysql.Username, mysql.Password, mysql.Server, mysql.Port, mysql.Db)
 	var err error
 	DB, err = gorm.Open("mysql", dsn)
 	if err != nil {

+ 1 - 1
user/provider/twong/user.go

@@ -23,7 +23,7 @@ var (
 
 func init() {
 	mysql := config.CreateMysql(twong_confile)
-	dsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8&parseTime=True&loc=Local", mysql.Username, mysql.Password, mysql.Server, mysql.Port, mysql.Database)
+	dsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8&parseTime=True&loc=Local", mysql.Username, mysql.Password, mysql.Server, mysql.Port, mysql.Db)
 	var err error
 	Db, err = gorm.Open("mysql", dsn)
 	if err != nil {