Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
development to staging (#122)
Browse files Browse the repository at this point in the history
Development to staging
  • Loading branch information
AriefLazuardi authored Dec 16, 2023
2 parents 93b7c09 + 58e6d49 commit d0911f2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion models/web/transactionPaymentResponse.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ type TransactionPaymentResponse struct {
UpdateAt time.Time `json:"updateAt"`
PaymentMethod PaymentMethodResponse `json:"paymentmethod"`
Invoice string `json:"invoice"`
VANumber string `json:"vaNumber"`
VANumber string `json:"vaNumber,omitempty"`
PaymentStatus string `json:"paymentStatus"`
}
26 changes: 20 additions & 6 deletions repository/productRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (repository *ProductRepositoryImpl) Update(request *domain.Product, id uint
func (repository *ProductRepositoryImpl) FindById(id uint) (*domain.Product, error) {
product := domain.Product{}

result := repository.DB.Preload("ProductType").Preload("Admin").Preload("ProductDetail").Where("deleted_at IS NULL").First(&product, id)
result := repository.DB.Preload("ProductType").Preload("Admin").Preload("ProductDetail", "deleted_at IS NULL").Where("deleted_at IS NULL").First(&product, id)

if result.Error != nil {
return nil, result.Error
Expand All @@ -66,7 +66,11 @@ func (repository *ProductRepositoryImpl) FindById(id uint) (*domain.Product, err
func (repository *ProductRepositoryImpl) FindAll() ([]domain.Product, int, error) {
products := []domain.Product{}

result := repository.DB.Preload("ProductType").Preload("ProductDetail").Where("deleted_at IS NULL").Find(&products)
result := repository.DB.
Preload("ProductType").
Preload("ProductDetail", "deleted_at IS NULL").
Where("deleted_at IS NULL").
Find(&products)

if result.Error != nil {
return nil, 0, result.Error
Expand All @@ -78,7 +82,12 @@ func (repository *ProductRepositoryImpl) FindAll() ([]domain.Product, int, error
func (repository *ProductRepositoryImpl) FindByCategory(ProductTypeID uint) ([]domain.Product, error) {
products := []domain.Product{}

result := repository.DB.Preload("ProductType").Preload("Admin").Preload("ProductDetail").Where("deleted_at IS NULL AND product_type_id = ?", ProductTypeID).Find(&products)
result := repository.DB.
Preload("ProductType").
Preload("Admin").
Preload("ProductDetail", "deleted_at IS NULL").
Where("deleted_at IS NULL AND product_type_id = ?", ProductTypeID).
Find(&products)

if result.Error != nil {
return nil, result.Error
Expand All @@ -91,7 +100,12 @@ func (repository *ProductRepositoryImpl) FindByName(name string) ([]domain.Produ
products := []domain.Product{}

// Menambahkan klausa pencarian berdasarkan nama ke query
result := repository.DB.Preload("ProductType").Preload("Admin").Preload("ProductDetail").Where("deleted_at IS NULL AND name LIKE ?", "%"+name+"%").Find(&products)
result := repository.DB.
Preload("ProductType").
Preload("Admin").
Preload("ProductDetail", "deleted_at IS NULL").
Where("deleted_at IS NULL AND name LIKE ?", "%"+name+"%").
Find(&products)

// Memeriksa kesalahan pada query
if result.Error != nil {
Expand All @@ -113,7 +127,7 @@ func (repository *ProductRepositoryImpl) Delete(id uint) error {
func (repository *ProductRepositoryImpl) FindPaginationProduct(orderBy string, paginate helpers.Pagination) ([]domain.Product, *helpers.Pagination, error) {
var products []domain.Product

result := repository.DB.Scopes(helpers.Paginate(products, &paginate, repository.DB)).Preload("Admin").Preload("ProductType").Preload("ProductDetail")
result := repository.DB.Scopes(helpers.Paginate(products, &paginate, repository.DB)).Preload("Admin").Preload("ProductType").Preload("ProductDetail", "deleted_at IS NULL")

if orderBy != "" {
result.Order("name " + orderBy).Where("products.deleted_at IS NULL").Find(&products)
Expand Down Expand Up @@ -175,7 +189,7 @@ func (repository *ProductRepositoryImpl) FindBestSellingProduct() ([]domain.Best
ORDER BY
total_quantity DESC;
`
result := repository.DB.Raw(query).Scan(&bestProduct)
result := repository.DB.Raw(query).Preload("ProductDetail", "deleted_at IS NULL").Scan(&bestProduct)
if result.Error != nil {
return nil, result.Error
}
Expand Down
1 change: 0 additions & 1 deletion services/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ func (service *TransactionImpl) CreateTransaction(request web.TransactionCreateR
status := "pending"
//Add status transaction Payment
request.TransactionPayment.PaymentStatus = status
request.TransactionPayment.VANumber = paymentMethod.Name
transaction := req.TransactionCreateRequestToTransactionDomain(request,
web.TransactionCreate{
Discount: discount,
Expand Down

0 comments on commit d0911f2

Please sign in to comment.