user.go 674 B

1234567891011121314151617181920212223242526272829
  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. )
  9. var (
  10. User = UserController{}
  11. )
  12. type UserController struct {
  13. baseController
  14. }
  15. func (c *UserController) Login(ctx context.Context, req *system.UserLoginReq) (res *system.UserLoginRes, err error) {
  16. //判断验证码是否正确
  17. debug := genv.GetWithCmd("gf.debug")
  18. if debug.Int() != 1 {
  19. if !commonService.Captcha.VerifyString(req.VerifyKey, req.VerifyCode) {
  20. err = gerror.New("验证码输入错误")
  21. return
  22. }
  23. }
  24. return
  25. }