From 74c86dd69b4b944a4fca85157e9c2fbc9ea2093a Mon Sep 17 00:00:00 2001 From: VIVIMAN Date: Wed, 7 Dec 2022 11:01:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/main.go b/main.go index ecbdc8e..4505f51 100644 --- a/main.go +++ b/main.go @@ -31,8 +31,8 @@ func init() { dbPort, _ := beego.AppConfig.String("mysqlport") maxIdleConn, _ := beego.AppConfig.Int("db_max_idle_conn") maxOpenConn, _ := beego.AppConfig.Int("db_max_open_open") - orm.RegisterDriver("mysql", orm.DRMySQL) - orm.RegisterDataBase("default", "mysql", + _ = orm.RegisterDriver("mysql", orm.DRMySQL) + _ = orm.RegisterDataBase("default", "mysql", dbUser+":"+dbPass+"@tcp("+dbHost+":"+dbPort+")/"+dbName+"?charset=utf8&parseTime=true&loc=Asia%2FShanghai", ) orm.MaxIdleConnections(maxIdleConn) @@ -47,9 +47,16 @@ func init() { logs.Async() level, _ := beego.AppConfig.Int("logLevel") logs.SetLevel(level) - logs.SetLogger(logs.AdapterMultiFile, `{"filename":"./logs/yshop.log", - "level":6,"maxlines":0,"maxsize":0,"daily":true,"maxdays":30, - "separate":["emergency", "alert", "critical", "error", "warning", "notice", "info"]}`) + _ = logs.SetLogger(logs.AdapterMultiFile, + `{ + "filename":"./logs/viviman.log", + "level":6, + "maxlines":0, + "maxsize":0, + "daily":true, + "maxdays":30, + "separate":["emergency", "alert", "critical", "error", "warning", "notice", "info"] + }`) } @@ -78,7 +85,7 @@ func main() { mytoken := ctx.Input.Header("Authorization") if len(mytoken) < bearerLength { ctx.Output.Status = 401 - ctx.Output.JSON(controllers.ErrMsg("header Authorization has not Bearer token", 40001), + _ = ctx.Output.JSON(controllers.ErrMsg("header Authorization has not Bearer token", 40001), true, true) return } @@ -86,7 +93,7 @@ func main() { usr, err := jwt.ValidateToken(token) if err != nil { ctx.Output.Status = 401 - ctx.Output.JSON(controllers.ErrMsg(err.Error(), 40001), + _ = ctx.Output.JSON(controllers.ErrMsg(err.Error(), 40001), true, true) return } @@ -121,7 +128,7 @@ func checkPermission(url string, method string, token string) int { userMap, _ := redis.Get(key) jsonStr := userMap[key] user := &models.SysUser{} - json.Unmarshal([]byte(jsonStr), user) + _ = json.Unmarshal([]byte(jsonStr), user) index := untils.Contains(user.Permissions, permission)