controller

package
v0.0.0-...-9d843bf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2024 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type UserController

type UserController interface {
	Create(ctx context.Context, requestData *UserCreateRequestIDO) (*user_s.User, error)
	GetByID(ctx context.Context, id primitive.ObjectID) (*user_s.User, error)
	GetUserBySessionUUID(ctx context.Context, sessionUUID string) (*user_s.User, error)
	ArchiveByID(ctx context.Context, id primitive.ObjectID) (*user_s.User, error)
	DeleteByID(ctx context.Context, id primitive.ObjectID) error
	ListByFilter(ctx context.Context, f *user_s.UserPaginationListFilter) (*user_s.UserPaginationListResult, error)
	ListAsSelectOptionByFilter(ctx context.Context, f *user_s.UserPaginationListFilter) ([]*user_s.UserAsSelectOption, error)
	UpdateByID(ctx context.Context, request *UserUpdateRequestIDO) (*user_s.User, error)
	CreateComment(ctx context.Context, customerID primitive.ObjectID, content string) (*user_s.User, error)
	Star(ctx context.Context, id primitive.ObjectID) (*user_s.User, error)
	ChangePassword(ctx context.Context, req *UserOperationChangePasswordRequest) error
	ChangeTwoFactorAuthentication(ctx context.Context, req *UserOperationChangeTwoFactorAuthenticationRequest) error
}

UserController Interface for user business logic controller.

func NewController

func NewController(
	appCfg *config.Conf,
	loggerp *slog.Logger,
	uuidp uuid.Provider,
	passwordp password.Provider,
	client *mongo.Client,
	org_storer store_s.StoreStorer,
	usr_storer user_s.UserStorer,
	st_storer submission_s.ComicSubmissionStorer,
	credit_storer credit_s.CreditStorer,
	attch_storer attachment_s.AttachmentStorer,
	receipt_storer receipt_s.ReceiptStorer,
	up_storer userpurchase_s.UserPurchaseStorer,
	temailer templatedemailer.TemplatedEmailer,
) UserController

type UserControllerImpl

type UserControllerImpl struct {
	Config                *config.Conf
	Logger                *slog.Logger
	UUID                  uuid.Provider
	Password              password.Provider
	DbClient              *mongo.Client
	UserStorer            user_s.UserStorer
	ComicSubmissionStorer submission_s.ComicSubmissionStorer
	StoreStorer           store_s.StoreStorer
	CreditStorer          credit_s.CreditStorer
	AttachmentStorer      attachment_s.AttachmentStorer
	ReceiptStorer         receipt_s.ReceiptStorer
	UserPurchaseStorer    userpurchase_s.UserPurchaseStorer
	TemplatedEmailer      templatedemailer.TemplatedEmailer
}

func (*UserControllerImpl) ArchiveByID

func (impl *UserControllerImpl) ArchiveByID(ctx context.Context, id primitive.ObjectID) (*user_s.User, error)

func (*UserControllerImpl) ChangePassword

func (*UserControllerImpl) ChangeTwoFactorAuthentication

func (impl *UserControllerImpl) ChangeTwoFactorAuthentication(ctx context.Context, req *UserOperationChangeTwoFactorAuthenticationRequest) error

func (*UserControllerImpl) Create

func (impl *UserControllerImpl) Create(ctx context.Context, requestData *UserCreateRequestIDO) (*user_s.User, error)

func (*UserControllerImpl) CreateComment

func (impl *UserControllerImpl) CreateComment(ctx context.Context, customerID primitive.ObjectID, content string) (*user_s.User, error)

func (*UserControllerImpl) DeleteByID

func (impl *UserControllerImpl) DeleteByID(ctx context.Context, id primitive.ObjectID) error

func (*UserControllerImpl) GetByID

func (*UserControllerImpl) GetUserBySessionUUID

func (c *UserControllerImpl) GetUserBySessionUUID(ctx context.Context, sessionUUID string) (*domain.User, error)

CreateInitialRootAdmin function creates the initial root administrator if not previously created.

func (*UserControllerImpl) ListAsSelectOptionByFilter

func (c *UserControllerImpl) ListAsSelectOptionByFilter(ctx context.Context, f *user_s.UserPaginationListFilter) ([]*user_s.UserAsSelectOption, error)

func (*UserControllerImpl) ListByFilter

func (*UserControllerImpl) Star

Star function will either set this user's `is_starred` to `true` or `false` depending if it was previously starred.

func (*UserControllerImpl) UpdateByID

func (impl *UserControllerImpl) UpdateByID(ctx context.Context, requestData *UserUpdateRequestIDO) (*user_s.User, error)

type UserCreateRequestIDO

type UserCreateRequestIDO struct {
	StoreID                                         primitive.ObjectID `bson:"store_id" json:"store_id,omitempty"`
	FirstName                                       string             `json:"first_name"`
	LastName                                        string             `json:"last_name"`
	Email                                           string             `json:"email"`
	Phone                                           string             `json:"phone,omitempty"`
	Country                                         string             `json:"country,omitempty"`
	Region                                          string             `json:"region,omitempty"`
	City                                            string             `json:"city,omitempty"`
	PostalCode                                      string             `json:"postal_code,omitempty"`
	AddressLine1                                    string             `json:"address_line1,omitempty"`
	AddressLine2                                    string             `json:"address_line2,omitempty"`
	HowDidYouHearAboutUs                            int8               `json:"how_did_you_hear_about_us,omitempty"`
	HowDidYouHearAboutUsOther                       string             `json:"how_did_you_hear_about_us_other,omitempty"`
	HowLongStoreOperating                           int8               `bson:"how_long_store_operating" json:"how_long_store_operating,omitempty"`
	GradingComicsExperience                         string             `bson:"grading_comics_experience" json:"grading_comics_experience,omitempty"`
	RetailPartnershipReason                         string             `bson:"retail_partnership_reason" json:"retail_partnership_reason,omitempty"` // "Please describe how you could become a good retail partner for CPS"
	CPSPartnershipReason                            string             `bson:"cps_partnership_reason" json:"cps_partnership_reason,omitempty"`       // "Please describe how CPS could help you grow your business"
	AgreeTOS                                        bool               `json:"agree_tos,omitempty"`
	AgreePromotionsEmail                            bool               `json:"agree_promotions_email,omitempty"`
	Status                                          int8               `bson:"status" json:"status"`
	Role                                            int8               `bson:"role" json:"role"`
	HasShippingAddress                              bool               `bson:"has_shipping_address" json:"has_shipping_address,omitempty"`
	ShippingName                                    string             `bson:"shipping_name" json:"shipping_name,omitempty"`
	ShippingPhone                                   string             `bson:"shipping_phone" json:"shipping_phone,omitempty"`
	ShippingCountry                                 string             `bson:"shipping_country" json:"shipping_country,omitempty"`
	ShippingRegion                                  string             `bson:"shipping_region" json:"shipping_region,omitempty"`
	ShippingCity                                    string             `bson:"shipping_city" json:"shipping_city,omitempty"`
	ShippingPostalCode                              string             `bson:"shipping_postal_code" json:"shipping_postal_code,omitempty"`
	ShippingAddressLine1                            string             `bson:"shipping_address_line1" json:"shipping_address_line1,omitempty"`
	ShippingAddressLine2                            string             `bson:"shipping_address_line2" json:"shipping_address_line2,omitempty"`
	HowLongCollectingComicBooksForGrading           int8               `bson:"how_long_collecting_comic_books_for_grading" json:"how_long_collecting_comic_books_for_grading"`
	HasPreviouslySubmittedComicBookForGrading       int8               `bson:"has_previously_submitted_comic_book_for_grading" json:"has_previously_submitted_comic_book_for_grading"`
	HasOwnedGradedComicBooks                        int8               `bson:"has_owned_graded_comic_books" json:"has_owned_graded_comic_books"`
	HasRegularComicBookShop                         int8               `bson:"has_regular_comic_book_shop" json:"has_regular_comic_book_shop"`
	HasPreviouslyPurchasedFromAuctionSite           int8               `bson:"has_previously_purchased_from_auction_site" json:"has_previously_purchased_from_auction_site"`
	HasPreviouslyPurchasedFromFacebookMarketplace   int8               `bson:"has_previously_purchased_from_facebook_marketplace" json:"has_previously_purchased_from_facebook_marketplace"`
	HasRegularlyAttendedComicConsOrCollectibleShows int8               `bson:"has_regularly_attended_comic_cons_or_collectible_shows" json:"has_regularly_attended_comic_cons_or_collectible_shows"`
}

type UserOperationChangePasswordRequest

type UserOperationChangePasswordRequest struct {
	UserID           primitive.ObjectID `bson:"user_id" json:"user_id"`
	Password         string             `bson:"password" json:"password"`
	PasswordRepeated string             `bson:"password_repeated" json:"password_repeated"`
}

type UserOperationChangeTwoFactorAuthenticationRequest

type UserOperationChangeTwoFactorAuthenticationRequest struct {
	UserID     primitive.ObjectID `bson:"user_id" json:"user_id"`
	OTPEnabled bool               `bson:"otp_enabled" json:"otp_enabled"`
}

type UserUpdateRequestIDO

type UserUpdateRequestIDO struct {
	ID                                              primitive.ObjectID `bson:"_id" json:"id"`
	StoreID                                         primitive.ObjectID `bson:"store_id" json:"store_id,omitempty"`
	FirstName                                       string             `json:"first_name"`
	LastName                                        string             `json:"last_name"`
	Email                                           string             `json:"email"`
	Password                                        string             `json:"password"`
	PasswordRepeated                                string             `json:"password_repeated"`
	Phone                                           string             `json:"phone,omitempty"`
	Country                                         string             `json:"country,omitempty"`
	Region                                          string             `json:"region,omitempty"`
	City                                            string             `json:"city,omitempty"`
	PostalCode                                      string             `json:"postal_code,omitempty"`
	AddressLine1                                    string             `json:"address_line1,omitempty"`
	AddressLine2                                    string             `json:"address_line2,omitempty"`
	HowDidYouHearAboutUs                            int8               `json:"how_did_you_hear_about_us,omitempty"`
	HowDidYouHearAboutUsOther                       string             `json:"how_did_you_hear_about_us_other,omitempty"`
	HowLongStoreOperating                           int8               `bson:"how_long_store_operating" json:"how_long_store_operating,omitempty"`
	GradingComicsExperience                         string             `bson:"grading_comics_experience" json:"grading_comics_experience,omitempty"`
	RetailPartnershipReason                         string             `bson:"retail_partnership_reason" json:"retail_partnership_reason,omitempty"`
	CPSPartnershipReason                            string             `bson:"cps_partnership_reason" json:"cps_partnership_reason,omitempty"` // "Please describe how CPS could help you grow your business"
	AgreeTOS                                        bool               `json:"agree_tos,omitempty"`
	AgreePromotionsEmail                            bool               `json:"agree_promotions_email,omitempty"`
	Status                                          int8               `bson:"status" json:"status"`
	Role                                            int8               `bson:"role" json:"role"`
	HasShippingAddress                              bool               `bson:"has_shipping_address" json:"has_shipping_address,omitempty"`
	ShippingName                                    string             `bson:"shipping_name" json:"shipping_name,omitempty"`
	ShippingPhone                                   string             `bson:"shipping_phone" json:"shipping_phone,omitempty"`
	ShippingCountry                                 string             `bson:"shipping_country" json:"shipping_country,omitempty"`
	ShippingRegion                                  string             `bson:"shipping_region" json:"shipping_region,omitempty"`
	ShippingCity                                    string             `bson:"shipping_city" json:"shipping_city,omitempty"`
	ShippingPostalCode                              string             `bson:"shipping_postal_code" json:"shipping_postal_code,omitempty"`
	ShippingAddressLine1                            string             `bson:"shipping_address_line1" json:"shipping_address_line1,omitempty"`
	ShippingAddressLine2                            string             `bson:"shipping_address_line2" json:"shipping_address_line2,omitempty"`
	HowLongCollectingComicBooksForGrading           int8               `bson:"how_long_collecting_comic_books_for_grading" json:"how_long_collecting_comic_books_for_grading"`
	HasPreviouslySubmittedComicBookForGrading       int8               `bson:"has_previously_submitted_comic_book_for_grading" json:"has_previously_submitted_comic_book_for_grading"`
	HasOwnedGradedComicBooks                        int8               `bson:"has_owned_graded_comic_books" json:"has_owned_graded_comic_books"`
	HasRegularComicBookShop                         int8               `bson:"has_regular_comic_book_shop" json:"has_regular_comic_book_shop"`
	HasPreviouslyPurchasedFromAuctionSite           int8               `bson:"has_previously_purchased_from_auction_site" json:"has_previously_purchased_from_auction_site"`
	HasPreviouslyPurchasedFromFacebookMarketplace   int8               `bson:"has_previously_purchased_from_facebook_marketplace" json:"has_previously_purchased_from_facebook_marketplace"`
	HasRegularlyAttendedComicConsOrCollectibleShows int8               `bson:"has_regularly_attended_comic_cons_or_collectible_shows" json:"has_regularly_attended_comic_cons_or_collectible_shows"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL