This commit is contained in:
Philipinho
2026-04-18 13:13:53 +01:00
parent 081bb67239
commit f5b19316af
53 changed files with 4056 additions and 812 deletions
@@ -52,12 +52,16 @@ export class BasePropertyController {
throw new ForbiddenException();
}
return this.basePropertyService.create(workspace.id, dto);
return this.basePropertyService.create(workspace.id, dto, user.id);
}
@HttpCode(HttpStatus.OK)
@Post('update')
async update(@Body() dto: UpdatePropertyDto, @AuthUser() user: User) {
async update(
@Body() dto: UpdatePropertyDto,
@AuthUser() user: User,
@AuthWorkspace() workspace: Workspace,
) {
const base = await this.baseRepo.findById(dto.baseId);
if (!base) {
throw new NotFoundException('Base not found');
@@ -68,12 +72,16 @@ export class BasePropertyController {
throw new ForbiddenException();
}
return this.basePropertyService.update(dto);
return this.basePropertyService.update(dto, workspace.id, user.id);
}
@HttpCode(HttpStatus.OK)
@Post('delete')
async delete(@Body() dto: DeletePropertyDto, @AuthUser() user: User) {
async delete(
@Body() dto: DeletePropertyDto,
@AuthUser() user: User,
@AuthWorkspace() workspace: Workspace,
) {
const base = await this.baseRepo.findById(dto.baseId);
if (!base) {
throw new NotFoundException('Base not found');
@@ -84,12 +92,16 @@ export class BasePropertyController {
throw new ForbiddenException();
}
await this.basePropertyService.delete(dto);
await this.basePropertyService.delete(dto, workspace.id, user.id);
}
@HttpCode(HttpStatus.OK)
@Post('reorder')
async reorder(@Body() dto: ReorderPropertyDto, @AuthUser() user: User) {
async reorder(
@Body() dto: ReorderPropertyDto,
@AuthUser() user: User,
@AuthWorkspace() workspace: Workspace,
) {
const base = await this.baseRepo.findById(dto.baseId);
if (!base) {
throw new NotFoundException('Base not found');
@@ -100,6 +112,6 @@ export class BasePropertyController {
throw new ForbiddenException();
}
await this.basePropertyService.reorder(dto);
await this.basePropertyService.reorder(dto, workspace.id, user.id);
}
}
@@ -60,58 +60,10 @@ export class BaseRowController {
@HttpCode(HttpStatus.OK)
@Post('info')
async getRow(@Body() dto: RowIdDto, @AuthUser() user: User) {
const base = await this.baseRepo.findById(dto.baseId);
if (!base) {
throw new NotFoundException('Base not found');
}
const ability = await this.spaceAbility.createForUser(user, base.spaceId);
if (ability.cannot(SpaceCaslAction.Read, SpaceCaslSubject.Base)) {
throw new ForbiddenException();
}
return this.baseRowService.getRowInfo(dto.rowId, dto.baseId);
}
@HttpCode(HttpStatus.OK)
@Post('update')
async update(@Body() dto: UpdateRowDto, @AuthUser() user: User) {
const base = await this.baseRepo.findById(dto.baseId);
if (!base) {
throw new NotFoundException('Base not found');
}
const ability = await this.spaceAbility.createForUser(user, base.spaceId);
if (ability.cannot(SpaceCaslAction.Edit, SpaceCaslSubject.Base)) {
throw new ForbiddenException();
}
return this.baseRowService.update(dto, user.id);
}
@HttpCode(HttpStatus.OK)
@Post('delete')
async delete(@Body() dto: DeleteRowDto, @AuthUser() user: User) {
const base = await this.baseRepo.findById(dto.baseId);
if (!base) {
throw new NotFoundException('Base not found');
}
const ability = await this.spaceAbility.createForUser(user, base.spaceId);
if (ability.cannot(SpaceCaslAction.Edit, SpaceCaslSubject.Base)) {
throw new ForbiddenException();
}
await this.baseRowService.delete(dto.rowId, dto.baseId);
}
@HttpCode(HttpStatus.OK)
@Post('list')
async list(
@Body() dto: ListRowsDto,
@Body() pagination: PaginationOptions,
async getRow(
@Body() dto: RowIdDto,
@AuthUser() user: User,
@AuthWorkspace() workspace: Workspace,
) {
const base = await this.baseRepo.findById(dto.baseId);
if (!base) {
@@ -123,12 +75,16 @@ export class BaseRowController {
throw new ForbiddenException();
}
return this.baseRowService.list(dto, pagination);
return this.baseRowService.getRowInfo(dto.rowId, dto.baseId, workspace.id);
}
@HttpCode(HttpStatus.OK)
@Post('reorder')
async reorder(@Body() dto: ReorderRowDto, @AuthUser() user: User) {
@Post('update')
async update(
@Body() dto: UpdateRowDto,
@AuthUser() user: User,
@AuthWorkspace() workspace: Workspace,
) {
const base = await this.baseRepo.findById(dto.baseId);
if (!base) {
throw new NotFoundException('Base not found');
@@ -139,6 +95,67 @@ export class BaseRowController {
throw new ForbiddenException();
}
await this.baseRowService.reorder(dto);
return this.baseRowService.update(dto, workspace.id, user.id);
}
@HttpCode(HttpStatus.OK)
@Post('delete')
async delete(
@Body() dto: DeleteRowDto,
@AuthUser() user: User,
@AuthWorkspace() workspace: Workspace,
) {
const base = await this.baseRepo.findById(dto.baseId);
if (!base) {
throw new NotFoundException('Base not found');
}
const ability = await this.spaceAbility.createForUser(user, base.spaceId);
if (ability.cannot(SpaceCaslAction.Edit, SpaceCaslSubject.Base)) {
throw new ForbiddenException();
}
await this.baseRowService.delete(dto, workspace.id, user.id);
}
@HttpCode(HttpStatus.OK)
@Post('list')
async list(
@Body() dto: ListRowsDto,
@Body() pagination: PaginationOptions,
@AuthUser() user: User,
@AuthWorkspace() workspace: Workspace,
) {
const base = await this.baseRepo.findById(dto.baseId);
if (!base) {
throw new NotFoundException('Base not found');
}
const ability = await this.spaceAbility.createForUser(user, base.spaceId);
if (ability.cannot(SpaceCaslAction.Read, SpaceCaslSubject.Base)) {
throw new ForbiddenException();
}
return this.baseRowService.list(dto, pagination, workspace.id);
}
@HttpCode(HttpStatus.OK)
@Post('reorder')
async reorder(
@Body() dto: ReorderRowDto,
@AuthUser() user: User,
@AuthWorkspace() workspace: Workspace,
) {
const base = await this.baseRepo.findById(dto.baseId);
if (!base) {
throw new NotFoundException('Base not found');
}
const ability = await this.spaceAbility.createForUser(user, base.spaceId);
if (ability.cannot(SpaceCaslAction.Edit, SpaceCaslSubject.Base)) {
throw new ForbiddenException();
}
await this.baseRowService.reorder(dto, workspace.id, user.id);
}
}
@@ -54,7 +54,11 @@ export class BaseViewController {
@HttpCode(HttpStatus.OK)
@Post('update')
async update(@Body() dto: UpdateViewDto, @AuthUser() user: User) {
async update(
@Body() dto: UpdateViewDto,
@AuthUser() user: User,
@AuthWorkspace() workspace: Workspace,
) {
const base = await this.baseRepo.findById(dto.baseId);
if (!base) {
throw new NotFoundException('Base not found');
@@ -65,12 +69,16 @@ export class BaseViewController {
throw new ForbiddenException();
}
return this.baseViewService.update(dto);
return this.baseViewService.update(dto, workspace.id, user.id);
}
@HttpCode(HttpStatus.OK)
@Post('delete')
async delete(@Body() dto: DeleteViewDto, @AuthUser() user: User) {
async delete(
@Body() dto: DeleteViewDto,
@AuthUser() user: User,
@AuthWorkspace() workspace: Workspace,
) {
const base = await this.baseRepo.findById(dto.baseId);
if (!base) {
throw new NotFoundException('Base not found');
@@ -81,12 +89,16 @@ export class BaseViewController {
throw new ForbiddenException();
}
await this.baseViewService.delete(dto);
await this.baseViewService.delete(dto, workspace.id, user.id);
}
@HttpCode(HttpStatus.OK)
@Post('list')
async list(@Body() dto: BaseIdDto, @AuthUser() user: User) {
async list(
@Body() dto: BaseIdDto,
@AuthUser() user: User,
@AuthWorkspace() workspace: Workspace,
) {
const base = await this.baseRepo.findById(dto.baseId);
if (!base) {
throw new NotFoundException('Base not found');
@@ -97,6 +109,6 @@ export class BaseViewController {
throw new ForbiddenException();
}
return this.baseViewService.listByBaseId(dto.baseId);
return this.baseViewService.listByBaseId(dto.baseId, workspace.id);
}
}