修改了登录增加了app登录方式
This commit is contained in:
parent
5452f77680
commit
45cf93e1bf
@ -37,6 +37,13 @@ func (r *Login) Login(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if req.Source == 1 {
|
||||||
|
if req.Mobile != "" {
|
||||||
|
responses.FailWithMessage("登陆失败", c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 开始事务
|
// 开始事务
|
||||||
tx := global.Db.Begin()
|
tx := global.Db.Begin()
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -59,11 +66,15 @@ func (r *Login) Login(c *gin.Context) {
|
|||||||
if req.Mobile != "" {
|
if req.Mobile != "" {
|
||||||
maps["mobile"] = req.Mobile
|
maps["mobile"] = req.Mobile
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if req.Uuid != "" {
|
||||||
|
maps["app_iden"] = req.Uuid
|
||||||
|
}
|
||||||
user, _ := userDao.GetUser(maps)
|
user, _ := userDao.GetUser(maps)
|
||||||
// 新用户处理方式
|
// 新用户处理方式
|
||||||
if user == nil {
|
if user == nil {
|
||||||
// 检测验证码
|
// 检测验证码
|
||||||
if req.Mobile != "" {
|
if req.Source == 1 {
|
||||||
if config.C.Env != "dev" {
|
if config.C.Env != "dev" {
|
||||||
code, _ := global.Redis.Get(c, "login_code_count_"+req.Mobile).Result()
|
code, _ := global.Redis.Get(c, "login_code_count_"+req.Mobile).Result()
|
||||||
if code == "" {
|
if code == "" {
|
||||||
@ -94,7 +105,7 @@ func (r *Login) Login(c *gin.Context) {
|
|||||||
// 新增用户
|
// 新增用户
|
||||||
user = &model.User{
|
user = &model.User{
|
||||||
UserName: req.Nickname,
|
UserName: req.Nickname,
|
||||||
AppIden: "",
|
AppIden: req.Uuid,
|
||||||
Mobile: req.Mobile,
|
Mobile: req.Mobile,
|
||||||
RegisterSource: req.Source,
|
RegisterSource: req.Source,
|
||||||
OpenId: req.OpenId,
|
OpenId: req.OpenId,
|
||||||
|
|||||||
@ -8,9 +8,10 @@ type LoginRequest struct {
|
|||||||
type Login struct {
|
type Login struct {
|
||||||
Mobile string `json:"mobile" form:"mobile" label:"手机号"`
|
Mobile string `json:"mobile" form:"mobile" label:"手机号"`
|
||||||
Code string `json:"code" form:"code" label:"验证码"`
|
Code string `json:"code" form:"code" label:"验证码"`
|
||||||
Source int `json:"source" form:"source" label:"来源" validate:"required"` // (1:app 2:公众号
|
Source int `json:"source" form:"source" label:"来源" validate:"required"` // (1:app 2:公众号)
|
||||||
OpenId string `json:"openid" form:"openid" label:"openid"`
|
OpenId string `json:"openid" form:"openid" label:"openid"`
|
||||||
Nickname string `json:"nickname" form:"nickname" label:"用户昵称"`
|
Nickname string `json:"nickname" form:"nickname" label:"用户昵称"`
|
||||||
HeadImgUrl string `json:"headimgurl" form:"headimgurl" label:"头像"`
|
HeadImgUrl string `json:"headimgurl" form:"headimgurl" label:"头像"`
|
||||||
UnionId string `json:"unionid" form:"unionid" label:"unionid"`
|
UnionId string `json:"unionid" form:"unionid" label:"unionid"`
|
||||||
|
Uuid string `json:"uuid" form:"uuid" label:"app唯一标识"`
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user