postgres

package
v0.0.0-...-5a72114 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

internal/repository/postgres/price_history.go

Index

Constants

View Source
const (
	OrderStatusInProcess = "in_process"
	OrderStatusCanceled  = "canceled"
	OrderStatusCompleted = "completed"
)

Variables

This section is empty.

Functions

func NewAdvertRepository

func NewAdvertRepository(db *pgxpool.Pool, ctx context.Context, timeout time.Duration) (repository.AdvertRepository, error)

func NewCartRepository

func NewCartRepository(db *pgxpool.Pool, ctx context.Context) (repository.Cart, error)

func NewCategoryRepository

func NewCategoryRepository(db *pgxpool.Pool, logger *zap.Logger, ctx context.Context, timeout time.Duration) (repository.CategoryRepository, error)

func NewPaymentRepository

func NewPaymentRepository(db *pgxpool.Pool, ctx context.Context, timeout time.Duration) (repository.PaymentRepository, error)

func NewPromotionRepository

func NewPromotionRepository(db *pgxpool.Pool, ctx context.Context, timeout time.Duration) (repository.PromotionRepository, error)

func NewPurchaseRepository

func NewPurchaseRepository(db *pgxpool.Pool, ctx context.Context, timeout time.Duration) (repository.PurchaseRepository, error)

func NewSellerRepository

func NewSellerRepository(db *pgxpool.Pool, ctx context.Context) (repository.Seller, error)

func NewStaticRepository

func NewStaticRepository(ctx context.Context, dbpool *pgxpool.Pool, basicPath string, maxSize int, logger *zap.Logger, timeout time.Duration) (repository.StaticRepository, error)

func NewUserRepository

func NewUserRepository(db *pgxpool.Pool, ctx context.Context, timeout time.Duration) (repository.User, error)

Types

type AdvertDB

type AdvertDB struct {
	DB DBExecutor
	// contains filtered or unexported fields
}

func (*AdvertDB) Add

func (r *AdvertDB) Add(a *entity.Advert) (*entity.Advert, error)

func (*AdvertDB) AddToSaved

func (r *AdvertDB) AddToSaved(advertId, userId uuid.UUID) error

func (*AdvertDB) AddViewed

func (r *AdvertDB) AddViewed(userId, advertId uuid.UUID) error

func (*AdvertDB) BeginTransaction

func (r *AdvertDB) BeginTransaction() (pgx.Tx, error)

func (*AdvertDB) CheckIfExists

func (r *AdvertDB) CheckIfExists(advertId uuid.UUID) (bool, error)

func (*AdvertDB) Count

func (r *AdvertDB) Count() (int, error)

func (*AdvertDB) DeleteById

func (r *AdvertDB) DeleteById(advertId uuid.UUID) error

func (*AdvertDB) DeleteFromSaved

func (r *AdvertDB) DeleteFromSaved(userId uuid.UUID, advertId uuid.UUID) error

func (*AdvertDB) Get

func (r *AdvertDB) Get(limit, offset int, userId uuid.UUID) ([]*entity.Advert, error)

func (*AdvertDB) GetByCartId

func (r *AdvertDB) GetByCartId(cartId, userId uuid.UUID) ([]*entity.Advert, error)

func (*AdvertDB) GetByCategoryId

func (r *AdvertDB) GetByCategoryId(categoryId, userId uuid.UUID) ([]*entity.Advert, error)

func (*AdvertDB) GetById

func (r *AdvertDB) GetById(advertId, userId uuid.UUID) (*entity.Advert, error)

func (*AdvertDB) GetBySellerId

func (r *AdvertDB) GetBySellerId(sellerId, userId uuid.UUID) ([]*entity.Advert, error)

func (*AdvertDB) GetByUserId

func (r *AdvertDB) GetByUserId(sellerId, userId uuid.UUID) ([]*entity.Advert, error)

func (*AdvertDB) GetSavedByUserId

func (r *AdvertDB) GetSavedByUserId(userId uuid.UUID) ([]*entity.Advert, error)

func (*AdvertDB) PromoteAdvert

func (r *AdvertDB) PromoteAdvert(advertID uuid.UUID) (*entity.Advert, error)

func (*AdvertDB) Search

func (r *AdvertDB) Search(query string, limit, offset int, userId uuid.UUID) ([]*entity.Advert, error)

func (*AdvertDB) Update

func (r *AdvertDB) Update(advert *entity.Advert) error

func (*AdvertDB) UpdateStatus

func (r *AdvertDB) UpdateStatus(tx pgx.Tx, advertId uuid.UUID, status entity.AdvertStatus) error

func (*AdvertDB) UploadImage

func (r *AdvertDB) UploadImage(advertId uuid.UUID, imageId uuid.UUID) error

type AdvertRepoModel

type AdvertRepoModel struct {
	ID            uuid.UUID
	SellerId      uuid.UUID
	CategoryId    uuid.UUID
	Title         string
	Description   string
	Price         uint
	ImageId       uuid.UUID
	Status        string
	HasDelivery   bool
	Location      string
	CreatedAt     time.Time
	UpdatedAt     time.Time
	PromotedUntil sql.NullTime
}

type CartDB

type CartDB struct {
	DB DBExecutor
	// contains filtered or unexported fields
}

func (*CartDB) AddAdvert

func (c *CartDB) AddAdvert(cartID uuid.UUID, AdvertID uuid.UUID) error

func (*CartDB) Create

func (c *CartDB) Create(userID uuid.UUID) (uuid.UUID, error)

func (*CartDB) DeleteAdvert

func (c *CartDB) DeleteAdvert(cartID uuid.UUID, AdvertID uuid.UUID) error

func (*CartDB) GetAdvertsByCartId

func (c *CartDB) GetAdvertsByCartId(cartID uuid.UUID) ([]entity.Advert, error)

func (*CartDB) GetById

func (c *CartDB) GetById(cartID uuid.UUID) (entity.Cart, error)

func (*CartDB) GetByUserId

func (c *CartDB) GetByUserId(userID uuid.UUID) (entity.Cart, error)

func (*CartDB) UpdateStatus

func (c *CartDB) UpdateStatus(tx pgx.Tx, cartID uuid.UUID, status entity.CartStatus) error

type CategoryDB

type CategoryDB struct {
	DB DBExecutor
	// contains filtered or unexported fields
}

func (*CategoryDB) Get

func (c *CategoryDB) Get() ([]*entity.Category, error)

type DBExecutor

type DBExecutor interface {
	QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row
	Exec(ctx context.Context, sql string, args ...interface{}) (pgconn.CommandTag, error)
	Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)
	Begin(ctx context.Context) (pgx.Tx, error)
}

type DBSeller

type DBSeller struct {
	ID          uuid.UUID
	UserID      uuid.UUID
	Description sql.NullString
	CreatedAt   time.Time
	UpdatedAt   time.Time
}

func (*DBSeller) GetEntity

func (dbSeller *DBSeller) GetEntity() entity.Seller

type DBUser

type DBUser struct {
	ID           uuid.UUID
	Email        string
	PasswordHash []byte
	PasswordSalt []byte
	Username     sql.NullString
	Phone        sql.NullString
	AvatarId     uuid.UUID
	Status       sql.NullString
	CreatedAt    time.Time
	UpdatedAt    time.Time
}

func (*DBUser) GetEntity

func (us *DBUser) GetEntity() entity.User

type PaymentDB

type PaymentDB struct {
	DB DBExecutor
	// contains filtered or unexported fields
}

func (*PaymentDB) GetOrderByID

func (r *PaymentDB) GetOrderByID(orderID string) (*entity.Order, error)

func (*PaymentDB) GetOrdersInProcess

func (r *PaymentDB) GetOrdersInProcess() ([]entity.Order, error)

func (*PaymentDB) InsertOrder

func (r *PaymentDB) InsertOrder(orderID, amount, paymentID, status string) (*entity.Order, error)

func (*PaymentDB) UpdateOrderStatus

func (r *PaymentDB) UpdateOrderStatus(orderID string, status string) (*entity.Order, error)

type PgxConnIface

type PgxConnIface interface {
	pgx.Conn
}

type PgxPoolIface

type PgxPoolIface interface {
	DBExecutor
	Acquire(ctx context.Context) (*pgxpool.Conn, error)
	AcquireAllIdle(ctx context.Context) []*pgxpool.Conn
	AcquireFunc(ctx context.Context, f func(*pgxpool.Conn) error) error
	Close()
	Stat() *pgxpool.Stat
	Reset()
	Config() *pgxpool.Config
}

type PriceHistoryDB

type PriceHistoryDB struct {
	// contains filtered or unexported fields
}

func NewHistoryRepository

func NewHistoryRepository(db *pgxpool.Pool, ctx context.Context, timeout time.Duration) (*PriceHistoryDB, error)

func (*PriceHistoryDB) AddAdvertPriceChange

func (p *PriceHistoryDB) AddAdvertPriceChange(advertID uuid.UUID, oldPrice, newPrice int) error

func (*PriceHistoryDB) GetAdvertPriceHistory

func (p *PriceHistoryDB) GetAdvertPriceHistory(advertID uuid.UUID) ([]*entity.PriceHistory, error)

type PromotionDB

type PromotionDB struct {
	// contains filtered or unexported fields
}

func (*PromotionDB) GetPromotionInfo

func (r *PromotionDB) GetPromotionInfo() (*entity.Promotion, error)

type PurchaseDB

type PurchaseDB struct {
	// contains filtered or unexported fields
}

func (*PurchaseDB) Add

func (r *PurchaseDB) Add(tx pgx.Tx, purchase *entity.Purchase) (*entity.Purchase, error)

func (*PurchaseDB) BeginTransaction

func (c *PurchaseDB) BeginTransaction() (pgx.Tx, error)

func (*PurchaseDB) GetByUserId

func (r *PurchaseDB) GetByUserId(userID uuid.UUID) ([]*entity.Purchase, error)

type SavedAdvertRepoModel

type SavedAdvertRepoModel struct {
	ID        uuid.UUID
	AdvertId  uuid.UUID
	UserId    uuid.UUID
	CreatedAt time.Time
}

type SellerDB

type SellerDB struct {
	DB DBExecutor
	// contains filtered or unexported fields
}

func (*SellerDB) Add

func (s *SellerDB) Add(tx pgx.Tx, userID uuid.UUID) (uuid.UUID, error)

func (*SellerDB) GetById

func (s *SellerDB) GetById(sellerID uuid.UUID) (*entity.Seller, error)

func (*SellerDB) GetByUserId

func (s *SellerDB) GetByUserId(userID uuid.UUID) (*entity.Seller, error)

type StaticDB

type StaticDB struct {
	DB        DBExecutor
	BasicPath string
	MaxSize   int
	Ctx       context.Context
	// contains filtered or unexported fields
}

func (StaticDB) Get

func (s StaticDB) Get(staticID uuid.UUID) (string, error)

func (StaticDB) GetMaxSize

func (s StaticDB) GetMaxSize() int

func (StaticDB) Upload

func (s StaticDB) Upload(path, filename string, data []byte) (uuid.UUID, error)

type UserDB

type UserDB struct {
	DB DBExecutor
	// contains filtered or unexported fields
}

func (*UserDB) Add

func (us *UserDB) Add(tx pgx.Tx, email string, hash, salt []byte) (uuid.UUID, error)

func (*UserDB) BeginTransaction

func (us *UserDB) BeginTransaction() (pgx.Tx, error)

func (*UserDB) CheckIfExists

func (us *UserDB) CheckIfExists(userId uuid.UUID) (bool, error)

func (*UserDB) Delete

func (us *UserDB) Delete(userID uuid.UUID) error

func (*UserDB) GetByEmail

func (us *UserDB) GetByEmail(email string) (*entity.User, error)

func (*UserDB) GetById

func (us *UserDB) GetById(id uuid.UUID) (*entity.User, error)

func (*UserDB) Update

func (us *UserDB) Update(user *entity.User) error

func (*UserDB) UploadImage

func (us *UserDB) UploadImage(userID uuid.UUID, imageId uuid.UUID) error

Jump to

Keyboard shortcuts

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