update
This commit is contained in:
@ -52,6 +52,8 @@ type ArticleRepository interface {
|
||||
SetRunwayCover(ctx context.Context, runwayID uint32, image string) error
|
||||
// SetRunwayDeleted 上下架:deleted=1 下架(对外不可见),0 上架。
|
||||
SetRunwayDeleted(ctx context.Context, id uint32, deleted uint8) error
|
||||
// SumImageSize 返回某条走秀全部存活图片的原图字节数之和(供后台「图集原图总大小」展示)。
|
||||
SumImageSize(ctx context.Context, runwayID uint32) (int64, error)
|
||||
}
|
||||
|
||||
type articleRepository struct {
|
||||
@ -565,3 +567,14 @@ func (r *articleRepository) SetRunwayDeleted(ctx context.Context, id uint32, del
|
||||
Where("id = ?", id).
|
||||
Updates(map[string]any{"is_deleted": deleted, "updated_at": uint32(time.Now().Unix())}).Error
|
||||
}
|
||||
|
||||
// SumImageSize 返回某条走秀全部存活图片的原图字节数之和(image_size 由 worker 下载时写入源文件字节数)。
|
||||
func (r *articleRepository) SumImageSize(ctx context.Context, runwayID uint32) (int64, error) {
|
||||
var total int64
|
||||
err := r.db.WithContext(ctx).
|
||||
Model(&model.BrandRunwayImage{}).
|
||||
Where("runway_id = ? AND is_deleted = 0", runwayID).
|
||||
Select("COALESCE(SUM(image_size), 0)").
|
||||
Scan(&total).Error
|
||||
return total, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user