user.go 872 B

123456789101112131415161718192021222324252627282930313233
  1. package controller
  2. import (
  3. "context"
  4. "github.com/gogf/gf/v2/errors/gerror"
  5. "github.com/gogf/gf/v2/os/genv"
  6. "github.com/tiger1103/gfast/v3/apiv1/system"
  7. commonService "github.com/tiger1103/gfast/v3/internal/app/common/service"
  8. "github.com/tiger1103/gfast/v3/internal/app/system/service"
  9. )
  10. var (
  11. User = UserController{}
  12. )
  13. type UserController struct {
  14. baseController
  15. }
  16. func (c *UserController) Login(ctx context.Context, req *system.UserLoginReq) (res *system.UserLoginRes, err error) {
  17. //判断验证码是否正确
  18. debug := genv.GetWithCmd("gf.debug")
  19. if debug.Int() != 1 {
  20. if !commonService.Captcha().VerifyString(req.VerifyKey, req.VerifyCode) {
  21. err = gerror.New("验证码输入错误")
  22. return
  23. }
  24. }
  25. //ip := libUtils.GetClientIp(ctx)
  26. //userAgent := libUtils.GetUserAgent(ctx)
  27. service.User().GetAdminUserByUsernamePassword(ctx, req)
  28. return
  29. }