update
This commit is contained in:
@ -54,6 +54,8 @@ type StreetSnapRepository interface {
|
||||
SetSnapCover(ctx context.Context, snapID uint32, image string) error
|
||||
// SetSnapDeleted 上下架:deleted=1 下架,0 上架。
|
||||
SetSnapDeleted(ctx context.Context, id uint32, deleted uint8) error
|
||||
// SumImageSize 返回某条街拍全部存活图片的原图字节数之和(供后台「图集原图总大小」展示)。
|
||||
SumImageSize(ctx context.Context, snapID uint32) (int64, error)
|
||||
}
|
||||
|
||||
type streetSnapRepository struct {
|
||||
@ -498,3 +500,14 @@ func (r *streetSnapRepository) SetSnapDeleted(ctx context.Context, id uint32, de
|
||||
Where("id = ?", id).
|
||||
Updates(map[string]any{"is_deleted": deleted, "updated_at": uint32(time.Now().Unix())}).Error
|
||||
}
|
||||
|
||||
// SumImageSize 返回某条街拍全部存活图片的原图字节数之和(image_size 由 worker 下载时写入源文件字节数)。
|
||||
func (r *streetSnapRepository) SumImageSize(ctx context.Context, snapID uint32) (int64, error) {
|
||||
var total int64
|
||||
err := r.db.WithContext(ctx).
|
||||
Model(&model.StreetSnapImage{}).
|
||||
Where("snap_id = ? AND is_deleted = 0", snapID).
|
||||
Select("COALESCE(SUM(image_size), 0)").
|
||||
Scan(&total).Error
|
||||
return total, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user