You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
852 B
38 lines
852 B
// 账号相关的接口实现 |
|
package handler |
|
|
|
import ( |
|
"server/common" |
|
"server/db" |
|
"server/modules/customer/app" |
|
"server/modules/customer/bdb" |
|
"server/modules/customer/values" |
|
"server/util" |
|
|
|
"github.com/liangdas/mqant/log" |
|
|
|
"github.com/gin-gonic/gin" |
|
) |
|
|
|
func Login(c *gin.Context) { |
|
a := app.NewApp(c) |
|
defer func() { |
|
a.Response() |
|
}() |
|
req := new(values.LoginReq) |
|
if !a.S(req) { |
|
return |
|
} |
|
one := &values.User{Account: req.Account, Password: req.Pass} |
|
if err := bdb.BackDB.Get(one); err != nil { |
|
a.Code = values.CodeParam |
|
a.Msg = "账号不存在" |
|
return |
|
} |
|
token := util.GetSimpleRandomString(6) |
|
err := db.Redis().SetJsonData(common.GetBackendTokenKey(token), one, values.RedisTokenEx) |
|
if err != nil { |
|
log.Error(err.Error()) |
|
} |
|
a.Data = values.LoginResp{Role: one.Role, Token: token, Power: one.Power, Id: int(one.ID)} |
|
}
|
|
|