Yimaru-BackEnd/internal/ports/user.go

82 lines
3.2 KiB
Go

package ports
import (
"context"
"time"
"Yimaru-Backend/internal/domain"
)
type UserStore interface {
IsUserNameUnique(ctx context.Context, userName string) (bool, error)
IsUserPending(ctx context.Context, UserName string) (bool, error)
GetUserByUserName(
ctx context.Context,
userName string,
) (domain.User, error)
CreateUser(
ctx context.Context,
user domain.User,
usedOtpId int64,
) (domain.User, error)
CreateUserWithoutOtp(
ctx context.Context,
user domain.User,
) (domain.User, error)
GetUserByID(
ctx context.Context,
id int64,
) (domain.User, error)
GetAllUsers(
ctx context.Context,
role *string,
query *string,
createdBefore, createdAfter *time.Time,
limit, offset int32,
) ([]domain.User, int64, error)
GetTotalUsers(ctx context.Context, role *string) (int64, error)
SearchUserByNameOrPhone(
ctx context.Context,
search string,
role *string,
) ([]domain.User, error)
UpdateUser(ctx context.Context, user domain.User) error
DeleteUser(ctx context.Context, userID int64) error
CheckPhoneEmailExist(ctx context.Context, phone, email string) (phoneExists, emailExists bool, err error)
GetUserByEmailPhone(
ctx context.Context,
email string,
phone string,
) (domain.User, error)
UpdatePassword(ctx context.Context, password, email, phone string, updatedAt time.Time) error
// GetOwnerByOrganizationID(ctx context.Context, organizationID int64) (domain.User, error)
// GetOwnerByOrganizationID(ctx context.Context, organizationID int64) (domain.User, error)
// UpdateUserSuspend(ctx context.Context, id int64, status bool) error
// UpdateUser(ctx context.Context, user domain.UpdateUserReq) error
// UpdateUserSuspend(ctx context.Context, id int64, status bool) error
// DeleteUser(ctx context.Context, id int64) error
// CheckPhoneEmailExist(ctx context.Context, phoneNum, email string, companyID domain.ValidInt64) (bool, bool, error)
// GetUserByEmail(ctx context.Context, email string, companyID domain.ValidInt64) (domain.User, error)
// GetUserByPhone(ctx context.Context, phoneNum string, companyID domain.ValidInt64) (domain.User, error)
// SearchUserByNameOrPhone(ctx context.Context, searchString string, role *domain.Role, companyID domain.ValidInt64) ([]domain.User, error)
// UpdatePassword(ctx context.Context, identifier string, password []byte, usedOtpId int64, companyId int64) error
// GetUserByEmailPhone(ctx context.Context, email, phone string, companyID domain.ValidInt64) (domain.User, error)
// GetCustomerCounts(ctx context.Context, filter domain.ReportFilter) (total, active, inactive int64, err error)
// GetCustomerDetails(ctx context.Context, filter domain.ReportFilter) (map[int64]domain.CustomerDetail, error)
// GetRoleCounts(ctx context.Context, role string, filter domain.ReportFilter) (total, active, inactive int64, err error)
}
type SmsGateway interface {
SendSMSOTP(ctx context.Context, phoneNumber, otp string) error
}
type EmailGateway interface {
SendEmailOTP(ctx context.Context, email string, otp string) error
}
type OtpStore interface {
UpdateExpiredOtp(ctx context.Context, otp, userName string) error
MarkOtpAsUsed(ctx context.Context, otp domain.Otp) error
CreateOtp(ctx context.Context, otp domain.Otp) error
GetOtp(ctx context.Context, userName string) (domain.Otp, error)
}