Browse Source

代码格式化

master
VIVIMAN 2 years ago
parent
commit
74c86dd69b
  1. 23
      main.go

23
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)

Loading…
Cancel
Save