|
|
|
@ -9,6 +9,7 @@ package service
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
|
"context" |
|
|
|
|
"errors" |
|
|
|
|
"fmt" |
|
|
|
|
"github.com/gogf/gf/v2/container/gset" |
|
|
|
|
"github.com/gogf/gf/v2/database/gdb" |
|
|
|
@ -130,12 +131,13 @@ func (s *userImpl) NotCheckAuthAdminIds(ctx context.Context) *gset.Set {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (s *userImpl) GetAdminUserByUsernamePassword(ctx context.Context, req *system.UserLoginReq) (user *model2.LoginUserRes, err error) { |
|
|
|
|
status := getUserStatus(req.Username) |
|
|
|
|
if status != nil && status.Time != nil { |
|
|
|
|
err = errors.New("账号被冻结," + fmt.Sprint(status.Time.Add(freeze*time.Minute).Layout(consts.TIME_FORMAT)) + "后解冻。") |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
err = g.Try(ctx, func(ctx context.Context) { |
|
|
|
|
status := getUserStatus(req.Username) |
|
|
|
|
if status != nil && status.Time != nil { |
|
|
|
|
err = gerror.New("账号被冻结," + fmt.Sprint(status.Time.Add(freeze*time.Minute).Layout(consts.TIME_FORMAT)) + "后解冻。") |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
user, err = s.GetUserByUsername(ctx, req.Username) |
|
|
|
|
liberr.ErrIsNil(ctx, err) |
|
|
|
|
liberr.ValueIsNil(user, "账号密码错误") |
|
|
|
@ -153,12 +155,12 @@ func (s *userImpl) GetAdminUserByUsernamePassword(ctx context.Context, req *syst
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (s *userImpl) GetAdminUserByPhone(ctx context.Context, req *system.UserLoginMobileReq) (user *model2.LoginUserRes, err error) { |
|
|
|
|
status := getUserStatus(req.Phone) |
|
|
|
|
if status != nil && status.Time != nil { |
|
|
|
|
err = errors.New("账号被冻结," + fmt.Sprint(status.Time.Add(freeze*time.Minute).Layout(consts.TIME_FORMAT)) + "后解冻。") |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
err = g.Try(ctx, func(ctx context.Context) { |
|
|
|
|
status := getUserStatus(req.Phone) |
|
|
|
|
if status != nil && status.Time != nil { |
|
|
|
|
err = gerror.New("账号被冻结," + fmt.Sprint(status.Time.Add(freeze*time.Minute).Layout(consts.TIME_FORMAT)) + "后解冻。") |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
user, err = s.GetUserByMobile(ctx, req.Phone) |
|
|
|
|
liberr.ErrIsNil(ctx, err) |
|
|
|
|
liberr.ValueIsNil(user, "手机验证码错误") |
|
|
|
@ -183,12 +185,12 @@ func (s *userImpl) GetAdminUserByPhone(ctx context.Context, req *system.UserLogi
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (s *userImpl) GetAdminUserByEmail(ctx context.Context, req *system.UserLoginEmailReq) (user *model2.LoginUserRes, err error) { |
|
|
|
|
status := getUserStatus(req.Email) |
|
|
|
|
if status != nil && status.Time != nil { |
|
|
|
|
err = errors.New("账号被冻结," + fmt.Sprint(status.Time.Add(freeze*time.Minute).Layout(consts.TIME_FORMAT)) + "后解冻。") |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
err = g.Try(ctx, func(ctx context.Context) { |
|
|
|
|
status := getUserStatus(req.Email) |
|
|
|
|
if status != nil && status.Time != nil { |
|
|
|
|
err = gerror.New("账号被冻结," + fmt.Sprint(status.Time.Add(freeze*time.Minute).Layout(consts.TIME_FORMAT)) + "后解冻。") |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
user, err = s.GetUserByEmail(ctx, req.Email) |
|
|
|
|
liberr.ErrIsNil(ctx, err) |
|
|
|
|
liberr.ValueIsNil(user, "验证码错误") |
|
|
|
@ -316,7 +318,7 @@ func (s *userImpl) LoginLog(ctx context.Context, params *model2.LoginLogParams)
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (s *userImpl) UpdateLoginInfo(ctx context.Context, id uint64, ip string) (err error) { |
|
|
|
|
g.Try(ctx, func(ctx context.Context) { |
|
|
|
|
err = g.Try(ctx, func(ctx context.Context) { |
|
|
|
|
_, err = dao.SysUser.Ctx(ctx).WherePri(id).Update(g.Map{ |
|
|
|
|
dao.SysUser.Columns().LastLoginIp: ip, |
|
|
|
|
dao.SysUser.Columns().LastLoginTime: gtime.Now(), |
|
|
|
|