@@ -69,7 +69,7 @@ type Store interface {
6969 limit , offset int ,
7070 ) ([]* ProductCard , int , error )
7171 GetProductDetailBySlug (ctx context.Context , slug string ) (* ProductDetail , error )
72- ListAdminProductCards (ctx context.Context , limit , offset int ) ([]* ProductCard , int , error )
72+ ListAdminProductCards (ctx context.Context , limit , offset int ) ([]* AdminProductCard , int , error )
7373
7474 FullTextSearchProducts (ctx context.Context , query string , limit , offset int ) ([]* ProductCardWithRank , int , error )
7575 SearchProducts (ctx context.Context , query string , limit , offset int ) ([]* ProductCard , int , error )
@@ -334,7 +334,7 @@ func (r *Repository) CreateCategory(ctx context.Context, c *Category) (*Category
334334func (r * Repository ) CountCategories (ctx context.Context ) (int , error ) {
335335 var n int
336336 if err := r .db .QueryRow (ctx , `SELECT COUNT(*) FROM categories` ).Scan (& n ); err != nil {
337- return 0 , fmt .Errorf ("Count categories: %w" , err )
337+ return 0 , fmt .Errorf ("count categories: %w" , err )
338338 }
339339 return n , nil
340340}
@@ -1625,7 +1625,7 @@ func (r *Repository) GetProductDetailBySlug(ctx context.Context, slug string) (*
16251625}
16261626
16271627// List admin products with counts (variants_count, images_count)
1628- func (r * Repository ) ListAdminProductCards (ctx context.Context , limit , offset int ) ([]* ProductCard , int , error ) {
1628+ func (r * Repository ) ListAdminProductCards (ctx context.Context , limit , offset int ) ([]* AdminProductCard , int , error ) {
16291629 if limit <= 0 || limit > 50 {
16301630 limit = 50
16311631 }
@@ -1659,45 +1659,41 @@ func (r *Repository) ListAdminProductCards(ctx context.Context, limit, offset in
16591659 }
16601660 defer rows .Close ()
16611661
1662- type adminCard struct {
1663- ProductCard
1664- VariantsCount int `json:"variants_count"`
1665- ImagesCount int `json:"images_count"`
1666- }
1667-
1668- out := make ([]* ProductCard , 0 , limit )
1662+ out := make ([]* AdminProductCard , 0 , limit )
16691663 for rows .Next () {
16701664 var (
1671- pc ProductCard
1672- desc sql.NullString
1673- catName , brandName sql.NullString
1674- slug string
1675- variantsCount , imagesCount int
1665+ card AdminProductCard
1666+ desc sql.NullString
1667+ catName , brandName sql.NullString
1668+ slug string
16761669 )
1670+
16771671 if err := rows .Scan (
1678- & pc .ID , & pc .Name , & slug , & desc ,
1679- & pc .CategoryID , & catName ,
1680- & pc .BrandID , & brandName ,
1681- & pc .IsActive , & pc .CreatedAt , & pc .UpdatedAt ,
1682- & variantsCount , & imagesCount ,
1672+ & card .ID , & card .Name , & slug , & desc ,
1673+ & card .CategoryID , & catName ,
1674+ & card .BrandID , & brandName ,
1675+ & card .IsActive , & card .CreatedAt , & card .UpdatedAt ,
1676+ & card . VariantsCount , & card . ImagesCount ,
16831677 ); err != nil {
16841678 return nil , 0 , fmt .Errorf ("scan admin product card: %w" , err )
16851679 }
1686- pc .Slug = slug
1680+
1681+ card .Slug = slug
1682+
16871683 if desc .Valid {
16881684 s := desc .String
1689- pc .Description = & s
1685+ card .Description = & s
16901686 }
16911687 if catName .Valid {
16921688 s := catName .String
1693- pc .CategoryName = & s
1689+ card .CategoryName = & s
16941690 }
16951691 if brandName .Valid {
16961692 s := brandName .String
1697- pc .BrandName = & s
1693+ card .BrandName = & s
16981694 }
1699- // We’ll attach counts in handler if needed
1700- out = append (out , & pc )
1695+
1696+ out = append (out , & card )
17011697 }
17021698 if err := rows .Err (); err != nil {
17031699 return nil , 0 , fmt .Errorf ("rows: %w" , err )
0 commit comments