func (u *userRepository) OAuth2Login(email string) (*user.UserAuth, error) {
	ctx := context.Background()
	var user user.UserAuth
	err := models.TUsers(
		qm.Select("id, oauth2_type"),
		qm.Where("email=?", email),
		qm.And("delete_flg=?", 0),
	).Bind(ctx, u.dbConn, &user)
	if err != nil {
		return nil, errors.Wrap(err, "failed to call models.TUsers().Bind()")
	}
	return &user, nil
}
OAuth2Login validates users when OAuth2 login
package repository
import (
	"context"
	"database/sql"
	"time"
	"github.com/pkg/errors"
	"github.com/volatiletech/null"
	"github.com/volatiletech/sqlboiler/boil"
	"github.com/volatiletech/sqlboiler/queries/qm"
	"go.uber.org/zap"
	"github.com/hiromaily/go-gin-wrapper/pkg/encryption"
	"github.com/hiromaily/go-gin-wrapper/pkg/model/user"
	models "github.com/hiromaily/go-gin-wrapper/pkg/models/rdb"
)
type UserRepository interface {
	Login(email, password string) (int, error)
	OAuth2Login(email string) (*user.UserAuth, error)
	GetUserIDs() ([]int, error)
	GetUsers(id string) ([]*user.User, error)
	InsertUser(user *user.User) (int, error)
	UpdateUser(users *user.User, id int) (int64, error)
	DeleteUser(id int) (int64, error)
}
type userRepository struct {
	dbConn    *sql.DB
	tableName string
	logger    *zap.Logger
	hash      encryption.Hasher
}
func NewUserRepository(dbConn *sql.DB, logger *zap.Logger, hash encryption.Hasher) UserRepository {
	return &userRepository{
		dbConn:    dbConn,
		tableName: "t_user",
		logger:    logger,
		hash:      hash,
	}
}
func (u *userRepository) Login(email, password string) (int, error) {
	type LoginUser struct {
		ID       int    `boil:"id"`
		Email    string `boil:"email"`
		Password string `boil:"password"`
	}
	ctx := context.Background()
	var user LoginUser
	err := models.TUsers(
		qm.Select("id, email, password"),
		qm.Where("email=?", email),
		qm.And("delete_flg=?", 0),
	).Bind(ctx, u.dbConn, &user)
	if err != nil {
		return 0, errors.Wrap(err, "failed to call models.TUsers().Bind()")
	}
	if user.Password != u.hash.Hash(password) {
		return 0, errors.Errorf("password is invalid")
	}
	return user.ID, nil
}