Scope knowledge and image libraries by brand
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
type ImageFolder struct {
|
||||
ID int64
|
||||
TenantID int64
|
||||
BrandID int64
|
||||
Name string
|
||||
ImageCount int
|
||||
CreatedAt time.Time
|
||||
@@ -17,12 +18,12 @@ type ImageFolder struct {
|
||||
}
|
||||
|
||||
type ImageFolderRepository interface {
|
||||
List(ctx context.Context, tenantID int64) ([]ImageFolder, error)
|
||||
Get(ctx context.Context, tenantID, id int64) (*ImageFolder, error)
|
||||
Create(ctx context.Context, tenantID int64, name string) (int64, error)
|
||||
Update(ctx context.Context, tenantID, id int64, name string) error
|
||||
Delete(ctx context.Context, tenantID, id int64) error
|
||||
CountActiveImages(ctx context.Context, tenantID, folderID int64) (int, error)
|
||||
List(ctx context.Context, tenantID, brandID int64) ([]ImageFolder, error)
|
||||
Get(ctx context.Context, tenantID, brandID, id int64) (*ImageFolder, error)
|
||||
Create(ctx context.Context, tenantID, brandID int64, name string) (int64, error)
|
||||
Update(ctx context.Context, tenantID, brandID, id int64, name string) error
|
||||
Delete(ctx context.Context, tenantID, brandID, id int64) error
|
||||
CountActiveImages(ctx context.Context, tenantID, brandID, folderID int64) (int, error)
|
||||
}
|
||||
|
||||
type imageFolderRepository struct {
|
||||
@@ -33,8 +34,11 @@ func NewImageFolderRepository(db generated.DBTX) ImageFolderRepository {
|
||||
return &imageFolderRepository{q: newQuerier(db)}
|
||||
}
|
||||
|
||||
func (r *imageFolderRepository) List(ctx context.Context, tenantID int64) ([]ImageFolder, error) {
|
||||
rows, err := r.q.ListImageFolders(ctx, tenantID)
|
||||
func (r *imageFolderRepository) List(ctx context.Context, tenantID, brandID int64) ([]ImageFolder, error) {
|
||||
rows, err := r.q.ListImageFolders(ctx, generated.ListImageFoldersParams{
|
||||
TenantID: tenantID,
|
||||
BrandID: brandID,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -44,6 +48,7 @@ func (r *imageFolderRepository) List(ctx context.Context, tenantID int64) ([]Ima
|
||||
folders[i] = ImageFolder{
|
||||
ID: row.ID,
|
||||
TenantID: row.TenantID,
|
||||
BrandID: row.BrandID,
|
||||
Name: row.Name,
|
||||
ImageCount: int(row.ImageCount),
|
||||
CreatedAt: timeFromTimestamp(row.CreatedAt),
|
||||
@@ -53,10 +58,11 @@ func (r *imageFolderRepository) List(ctx context.Context, tenantID int64) ([]Ima
|
||||
return folders, nil
|
||||
}
|
||||
|
||||
func (r *imageFolderRepository) Get(ctx context.Context, tenantID, id int64) (*ImageFolder, error) {
|
||||
func (r *imageFolderRepository) Get(ctx context.Context, tenantID, brandID, id int64) (*ImageFolder, error) {
|
||||
row, err := r.q.GetImageFolder(ctx, generated.GetImageFolderParams{
|
||||
ID: id,
|
||||
TenantID: tenantID,
|
||||
BrandID: brandID,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -65,37 +71,42 @@ func (r *imageFolderRepository) Get(ctx context.Context, tenantID, id int64) (*I
|
||||
return &ImageFolder{
|
||||
ID: row.ID,
|
||||
TenantID: row.TenantID,
|
||||
BrandID: row.BrandID,
|
||||
Name: row.Name,
|
||||
CreatedAt: timeFromTimestamp(row.CreatedAt),
|
||||
UpdatedAt: timeFromTimestamp(row.UpdatedAt),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (r *imageFolderRepository) Create(ctx context.Context, tenantID int64, name string) (int64, error) {
|
||||
func (r *imageFolderRepository) Create(ctx context.Context, tenantID, brandID int64, name string) (int64, error) {
|
||||
return r.q.CreateImageFolder(ctx, generated.CreateImageFolderParams{
|
||||
TenantID: tenantID,
|
||||
BrandID: brandID,
|
||||
Name: name,
|
||||
})
|
||||
}
|
||||
|
||||
func (r *imageFolderRepository) Update(ctx context.Context, tenantID, id int64, name string) error {
|
||||
func (r *imageFolderRepository) Update(ctx context.Context, tenantID, brandID, id int64, name string) error {
|
||||
return r.q.UpdateImageFolder(ctx, generated.UpdateImageFolderParams{
|
||||
Name: name,
|
||||
ID: id,
|
||||
TenantID: tenantID,
|
||||
BrandID: brandID,
|
||||
})
|
||||
}
|
||||
|
||||
func (r *imageFolderRepository) Delete(ctx context.Context, tenantID, id int64) error {
|
||||
func (r *imageFolderRepository) Delete(ctx context.Context, tenantID, brandID, id int64) error {
|
||||
return r.q.DeleteImageFolder(ctx, generated.DeleteImageFolderParams{
|
||||
ID: id,
|
||||
TenantID: tenantID,
|
||||
BrandID: brandID,
|
||||
})
|
||||
}
|
||||
|
||||
func (r *imageFolderRepository) CountActiveImages(ctx context.Context, tenantID, folderID int64) (int, error) {
|
||||
func (r *imageFolderRepository) CountActiveImages(ctx context.Context, tenantID, brandID, folderID int64) (int, error) {
|
||||
count, err := r.q.CountActiveImagesInFolder(ctx, generated.CountActiveImagesInFolderParams{
|
||||
TenantID: tenantID,
|
||||
BrandID: brandID,
|
||||
FolderID: pgInt8(&folderID),
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user