mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-02 14:04:50 +00:00
feat(storage): add archive storage support for assets
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { archiveAssets } from '@shumai/operations'
|
||||
import { AuditAction } from '@shumai/dtos'
|
||||
import { assetService } from '@shumai/core/src/asset/asset'
|
||||
import { Permission, ResourceType } from '@shumai/core/src/authz/authz'
|
||||
import { implementOperation } from '../implement'
|
||||
|
||||
export const archiveAssetsOp = implementOperation(archiveAssets, {
|
||||
authz: (input) =>
|
||||
input.assetIds.map((id) => ({
|
||||
permission: Permission.Edit,
|
||||
type: ResourceType.Asset,
|
||||
id,
|
||||
})),
|
||||
execute: async (input) => {
|
||||
return assetService.archiveAssets(input.assetIds)
|
||||
},
|
||||
audit: (input) =>
|
||||
input.assetIds.map((assetId) => ({
|
||||
action: AuditAction.asset_archive,
|
||||
itemId: assetId,
|
||||
contextAssetId: assetId,
|
||||
})),
|
||||
})
|
||||
@@ -0,0 +1,23 @@
|
||||
import { restoreArchivedAssets } from '@shumai/operations'
|
||||
import { AuditAction } from '@shumai/dtos'
|
||||
import { assetService } from '@shumai/core/src/asset/asset'
|
||||
import { Permission, ResourceType } from '@shumai/core/src/authz/authz'
|
||||
import { implementOperation } from '../implement'
|
||||
|
||||
export const restoreArchivedAssetsOp = implementOperation(restoreArchivedAssets, {
|
||||
authz: (input) =>
|
||||
input.assetIds.map((id) => ({
|
||||
permission: Permission.Edit,
|
||||
type: ResourceType.Asset,
|
||||
id,
|
||||
})),
|
||||
execute: async (input) => {
|
||||
return assetService.restoreArchivedAssets(input.assetIds)
|
||||
},
|
||||
audit: (input) =>
|
||||
input.assetIds.map((assetId) => ({
|
||||
action: AuditAction.asset_restore_archive,
|
||||
itemId: assetId,
|
||||
contextAssetId: assetId,
|
||||
})),
|
||||
})
|
||||
Reference in New Issue
Block a user