| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- package controller
- import (
- "context"
- "github.com/gogf/gf/v2/errors/gerror"
- "github.com/gogf/gf/v2/os/genv"
- "github.com/tiger1103/gfast/v3/apiv1/system"
- commonService "github.com/tiger1103/gfast/v3/internal/app/common/service"
- "github.com/tiger1103/gfast/v3/internal/app/system/model"
- "github.com/tiger1103/gfast/v3/internal/app/system/service"
- )
- var (
- User = UserController{}
- )
- type UserController struct {
- baseController
- }
- func (c *UserController) Login(ctx context.Context, req *system.UserLoginReq) (res *system.UserLoginRes, err error) {
- var user *model.LoginUserRes
- //判断验证码是否正确
- debug := genv.GetWithCmd("gf.debug")
- if debug.Int() != 1 {
- if !commonService.Captcha().VerifyString(req.VerifyKey, req.VerifyCode) {
- err = gerror.New("验证码输入错误")
- return
- }
- }
- //ip := libUtils.GetClientIp(ctx)
- //userAgent := libUtils.GetUserAgent(ctx)
- user, err = service.User().GetAdminUserByUsernamePassword(ctx, req)
- if err != nil {
- return
- }
- res = &system.UserLoginRes{
- UserInfo: user,
- }
- return
- }
|