vona-cli-set-api 1.1.144 → 1.1.145

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -53,17 +53,17 @@ export class Controller<%=argv.resourceNameCapitalize%> extends BeanBase {
53
53
  await this.scope.service.<%=argv.resourceName%>.update(id, <%=argv.resourceName%>);
54
54
  }
55
55
 
56
- @Web.post('bulk/delete', { summary: $locale('BulkDelete') })
57
- @Api.body(z.null())
58
- @Passport.systemAdmin()
59
- async deleteBulk(@Arg.body() command: Dto<%=argv.resourceNameCapitalize%>DeleteBulk): Promise<void> {
60
- await this.scope.service.<%=argv.resourceName%>.deleteBulk(command.ids);
61
- }
62
-
63
56
  @Web.delete(':id', { summary: $locale('<%=argv.resourceNameCapitalize%>Delete') })
64
57
  @Api.body(z.null())
65
58
  @Passport.systemAdmin()
66
59
  async delete(@Arg.param('id', v.tableIdentity()) id: TableIdentity): Promise<void> {
67
60
  await this.scope.service.<%=argv.resourceName%>.delete(id);
68
61
  }
62
+
63
+ @Web.post('bulk/delete', { summary: $locale('BulkDelete') })
64
+ @Api.body(z.null())
65
+ @Passport.systemAdmin()
66
+ async deleteBulk(@Arg.body() command: Dto<%=argv.resourceNameCapitalize%>DeleteBulk): Promise<void> {
67
+ await this.scope.service.<%=argv.resourceName%>.deleteBulk(command.ids);
68
+ }
69
69
  }
@@ -1,5 +1,6 @@
1
1
  import type { TableIdentity } from 'table-identity';
2
2
  import type { IQueryParams } from 'vona-module-a-orm';
3
+ import type { IRbacScopeAccess } from 'vona-module-a-rbac';
3
4
  import type { IDecoratorControllerOptions } from 'vona-module-a-web';
4
5
 
5
6
  import { BeanBase } from 'vona';
@@ -53,17 +54,29 @@ export class Controller<%=argv.resourceNameCapitalize%> extends BeanBase {
53
54
  await this.scope.service.<%=argv.resourceName%>.update(id, <%=argv.resourceName%>);
54
55
  }
55
56
 
56
- @Web.post('bulk/delete', { summary: $locale('BulkDelete') })
57
- @Api.body(z.null())
58
- @Passport.rbac()
59
- async deleteBulk(@Arg.body() command: Dto<%=argv.resourceNameCapitalize%>DeleteBulk): Promise<void> {
60
- await this.scope.service.<%=argv.resourceName%>.deleteBulk(command.ids);
61
- }
62
-
63
57
  @Web.delete(':id', { summary: $locale('<%=argv.resourceNameCapitalize%>Delete') })
64
58
  @Api.body(z.null())
65
59
  @Passport.rbac()
66
60
  async delete(@Arg.param('id', v.tableIdentity()) id: TableIdentity): Promise<void> {
67
61
  await this.scope.service.<%=argv.resourceName%>.delete(id);
68
62
  }
63
+
64
+ @Web.post('bulk/delete', { summary: $locale('BulkDelete') })
65
+ @Api.body(z.null())
66
+ @Passport.rbac({ actionInherit: 'delete' })
67
+ async deleteBulk(
68
+ @Arg.body() command: Dto<%=argv.resourceNameCapitalize%>DeleteBulk,
69
+ @Arg.rbacScopeCurrent() rbacScopeCurrent: IRbacScopeAccess,
70
+ ): Promise<void> {
71
+ const entries = await this.bean.rbacResourceBulk.entries(
72
+ command.ids,
73
+ async ids => {
74
+ return await this.scope.model.<%=argv.resourceName%>.select({
75
+ where: rbacScopeCurrent.where({ id: ids }),
76
+ });
77
+ },
78
+ rbacScopeCurrent,
79
+ );
80
+ await this.scope.service.<%=argv.resourceName%>.deleteBulk(entries.map(entry => entry.id));
81
+ }
69
82
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vona-cli-set-api",
3
- "version": "1.1.144",
4
- "gitHead": "8ecb407bf2c0bb2e28592206ca1a39f37ab50902",
3
+ "version": "1.1.145",
4
+ "gitHead": "24cd64478e2daf1722ed024968308df27608cee9",
5
5
  "description": "vona cli-set-api",
6
6
  "keywords": [
7
7
  "framework",