user_auth.go 1.4 KB
package repository

import "opp/models"

type IUserAuthRepository interface {
	GetUserAuthByUserId(uid int64, deviceType int) (v *models.UserAuth, err error)
	UpdateUserAuthById(m *models.UserAuth) (err error)
	GetUserAuthByAuthCode(authCode string) (v *models.UserAuth, err error)
	GetUserAuthByRefreshToken(refreshToken string) (v *models.UserAuth, err error)
	GetUserAuthByToken(refreshToken string) (v *models.UserAuth, err error)
	AddUserAuth(m *models.UserAuth) (err error)
}

var _ IUserAuthRepository = (*UserAuthRepository)(nil)

type UserAuthRepository struct{}

func (r *UserAuthRepository) GetUserAuthByUserId(uid int64, deviceType int) (v *models.UserAuth, err error) {
	return models.GetUserAuthByUserId(uid, deviceType)
}

func (r *UserAuthRepository) UpdateUserAuthById(m *models.UserAuth) (err error) {
	return models.UpdateUserAuthById(m)
}

func (r *UserAuthRepository) AddUserAuth(m *models.UserAuth) (err error) {
	_, err = models.AddUserAuth(m)
	return
}

func (r *UserAuthRepository) GetUserAuthByAuthCode(authCode string) (v *models.UserAuth, err error) {
	return models.GetUserByAuthCode(authCode)
}

func (r *UserAuthRepository) GetUserAuthByRefreshToken(refreshToken string) (v *models.UserAuth, err error) {
	return models.GetUserAuthByRefreshToken(refreshToken)
}

func (r *UserAuthRepository) GetUserAuthByToken(refreshToken string) (v *models.UserAuth, err error) {
	return models.GetUserAuthByToken(refreshToken)
}