vo.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package authsrv
  2. import (
  3. "Cold_Logistic/internal/pkg/common/constant"
  4. validation "github.com/go-ozzo/ozzo-validation/v4"
  5. "gogs.baozhida.cn/Cold_Logistic_libs/pkg/contrib/errors"
  6. )
  7. type LoginReqVo struct {
  8. LoginType int `json:"loginType"` // 登录类型:1-内部人员 2-普通用户
  9. Openid string `json:"openid"`
  10. NickName string `json:"nickName"`
  11. TokenKey string `json:"tokenKey"`
  12. }
  13. func (r *LoginReqVo) Validate() error {
  14. switch r.LoginType {
  15. case constant.AccountPlatform:
  16. return validation.ValidateStruct(r,
  17. validation.Field(&r.TokenKey, validation.Required),
  18. )
  19. case constant.AccountApplet:
  20. return validation.ValidateStruct(r,
  21. validation.Field(&r.Openid, validation.Required.Error("请在小程序登录")),
  22. //validation.Field(&r.Phone, validation.Required, validation.RuneLength(1, 11)),
  23. )
  24. default:
  25. return errors.New("无法识别登录类型")
  26. }
  27. }
  28. type LoginRespVo struct {
  29. TokenType string `json:"tokenType"`
  30. AccessToken string `json:"accessToken"`
  31. ExpiresIn int64 `json:"expiresIn"`
  32. IsFirst int `json:"isFirst"` // 是否首次登录:1-是 2-否
  33. }