fix: Bug fixed für alle Seiten und das Profil und label
This commit is contained in:
1 parent
133edcd5ba
commit
0a52b29c57
52 files changed
+1290
-129
No files matched your search
@@ -157,6 +157,7 @@ export const PERMISSION_CATALOG = [
|
||||
[
|
||||
['read', 'Ansehen'],
|
||||
['create', 'Anlegen'],
|
||||
['update', 'Bearbeiten'],
|
||||
['relocate', 'Umlagern'],
|
||||
['measure', 'Messwerte erfassen'],
|
||||
],
|
||||
@@ -168,6 +169,7 @@ export const PERMISSION_CATALOG = [
|
||||
[
|
||||
['read', 'Ansehen'],
|
||||
['create', 'Anlegen'],
|
||||
['update', 'Bearbeiten'],
|
||||
['move', 'Bewegung buchen'],
|
||||
],
|
||||
1400,
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import { PartialType, PickType } from '@nestjs/swagger';
|
||||
import { CreateHoneyBatchDto } from './create-honey-batch.dto';
|
||||
|
||||
export class UpdateHoneyBatchDto extends PartialType(
|
||||
PickType(CreateHoneyBatchDto, [
|
||||
'honeyType',
|
||||
'amount',
|
||||
'waterContent',
|
||||
] as const),
|
||||
) {}
|
||||
@@ -1,10 +1,19 @@
|
||||
import { Body, Controller, Get, Param, Post, Query } from '@nestjs/common';
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Get,
|
||||
Param,
|
||||
Patch,
|
||||
Post,
|
||||
Query,
|
||||
} from '@nestjs/common';
|
||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||
import { HoneyBatchStatus } from '../../generated/prisma';
|
||||
import { RequirePermission } from '../auth/decorators/require-permission.decorator';
|
||||
import { CurrentUser } from '../auth/decorators/current-user.decorator';
|
||||
import type { AuthenticatedUser } from '../auth/types/authenticated-user';
|
||||
import { CreateHoneyBatchDto } from './dto/create-honey-batch.dto';
|
||||
import { UpdateHoneyBatchDto } from './dto/update-honey-batch.dto';
|
||||
import { CreateHoneyMeasurementDto } from './dto/create-honey-measurement.dto';
|
||||
import { RelocateHoneyBatchDto } from './dto/relocate-honey-batch.dto';
|
||||
import { HoneyBatchesService } from './honey-batches.service';
|
||||
@@ -58,6 +67,16 @@ export class HoneyBatchesController {
|
||||
return this.honeyBatchesService.create(dto, actor.id);
|
||||
}
|
||||
|
||||
@RequirePermission('honey-batches:update')
|
||||
@Patch(':id')
|
||||
update(
|
||||
@Param('id') id: string,
|
||||
@Body() dto: UpdateHoneyBatchDto,
|
||||
@CurrentUser() actor: AuthenticatedUser,
|
||||
) {
|
||||
return this.honeyBatchesService.update(id, dto, actor.id);
|
||||
}
|
||||
|
||||
@RequirePermission('honey-batches:measure')
|
||||
@Post(':id/measurements')
|
||||
addMeasurement(
|
||||
|
||||
@@ -4,6 +4,7 @@ import { AuditLogService } from '../audit/audit-log.service';
|
||||
import { WebhooksService } from '../webhooks/webhooks.service';
|
||||
import { HoneyBatchStatus } from '../../generated/prisma';
|
||||
import { CreateHoneyBatchDto } from './dto/create-honey-batch.dto';
|
||||
import { UpdateHoneyBatchDto } from './dto/update-honey-batch.dto';
|
||||
import { CreateHoneyMeasurementDto } from './dto/create-honey-measurement.dto';
|
||||
import { RelocateHoneyBatchDto } from './dto/relocate-honey-batch.dto';
|
||||
|
||||
@@ -68,6 +69,24 @@ export class HoneyBatchesService {
|
||||
return created;
|
||||
}
|
||||
|
||||
async update(id: string, dto: UpdateHoneyBatchDto, actingUserId: string) {
|
||||
const before = await this.findById(id);
|
||||
await this.prisma.honeyBatch.update({
|
||||
where: { id },
|
||||
data: { ...dto },
|
||||
});
|
||||
const updated = await this.findById(id);
|
||||
await this.auditLog.record({
|
||||
entityType: 'HoneyBatch',
|
||||
entityId: id,
|
||||
action: 'UPDATE',
|
||||
userId: actingUserId,
|
||||
beforeData: before,
|
||||
afterData: updated,
|
||||
});
|
||||
return updated;
|
||||
}
|
||||
|
||||
async addMeasurement(
|
||||
id: string,
|
||||
dto: CreateHoneyMeasurementDto,
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import { PartialType, PickType } from '@nestjs/swagger';
|
||||
import { CreateStockItemDto } from './create-stock-item.dto';
|
||||
|
||||
export class UpdateStockItemDto extends PartialType(
|
||||
PickType(CreateStockItemDto, [
|
||||
'name',
|
||||
'category',
|
||||
'unit',
|
||||
'minThreshold',
|
||||
'notes',
|
||||
] as const),
|
||||
) {}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { PartialType, PickType } from '@nestjs/swagger';
|
||||
import { CreateStorageContainerDto } from './create-storage-container.dto';
|
||||
|
||||
export class UpdateStorageContainerDto extends PartialType(
|
||||
PickType(CreateStorageContainerDto, [
|
||||
'containerType',
|
||||
'capacity',
|
||||
'location',
|
||||
] as const),
|
||||
) {}
|
||||
@@ -1,10 +1,12 @@
|
||||
import { Body, Controller, Get, Param, Post } from '@nestjs/common';
|
||||
import { Body, Controller, Get, Param, Patch, Post } from '@nestjs/common';
|
||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||
import { RequirePermission } from '../auth/decorators/require-permission.decorator';
|
||||
import { CurrentUser } from '../auth/decorators/current-user.decorator';
|
||||
import type { AuthenticatedUser } from '../auth/types/authenticated-user';
|
||||
import { CreateStorageContainerDto } from './dto/create-storage-container.dto';
|
||||
import { UpdateStorageContainerDto } from './dto/update-storage-container.dto';
|
||||
import { CreateStockItemDto } from './dto/create-stock-item.dto';
|
||||
import { UpdateStockItemDto } from './dto/update-stock-item.dto';
|
||||
import { CreateStockMovementDto } from './dto/create-stock-movement.dto';
|
||||
import { StorageService } from './storage.service';
|
||||
|
||||
@@ -29,6 +31,16 @@ export class StorageController {
|
||||
return this.storageService.createContainer(dto, actor.id);
|
||||
}
|
||||
|
||||
@RequirePermission('storage:update')
|
||||
@Patch('storage-containers/:id')
|
||||
updateContainer(
|
||||
@Param('id') id: string,
|
||||
@Body() dto: UpdateStorageContainerDto,
|
||||
@CurrentUser() actor: AuthenticatedUser,
|
||||
) {
|
||||
return this.storageService.updateContainer(id, dto, actor.id);
|
||||
}
|
||||
|
||||
@RequirePermission('storage:read')
|
||||
@Get('stock-items')
|
||||
findAllStockItems() {
|
||||
@@ -50,6 +62,16 @@ export class StorageController {
|
||||
return this.storageService.createStockItem(dto, actor.id);
|
||||
}
|
||||
|
||||
@RequirePermission('storage:update')
|
||||
@Patch('stock-items/:id')
|
||||
updateStockItem(
|
||||
@Param('id') id: string,
|
||||
@Body() dto: UpdateStockItemDto,
|
||||
@CurrentUser() actor: AuthenticatedUser,
|
||||
) {
|
||||
return this.storageService.updateStockItem(id, dto, actor.id);
|
||||
}
|
||||
|
||||
@RequirePermission('storage:move')
|
||||
@Post('stock-items/:id/movements')
|
||||
addMovement(
|
||||
|
||||
@@ -4,7 +4,9 @@ import { AuditLogService } from '../audit/audit-log.service';
|
||||
import { WebhooksService } from '../webhooks/webhooks.service';
|
||||
import { StockItem, StorageContainer } from '../../generated/prisma';
|
||||
import { CreateStorageContainerDto } from './dto/create-storage-container.dto';
|
||||
import { UpdateStorageContainerDto } from './dto/update-storage-container.dto';
|
||||
import { CreateStockItemDto } from './dto/create-stock-item.dto';
|
||||
import { UpdateStockItemDto } from './dto/update-stock-item.dto';
|
||||
import { CreateStockMovementDto } from './dto/create-stock-movement.dto';
|
||||
|
||||
@Injectable()
|
||||
@@ -36,6 +38,32 @@ export class StorageService {
|
||||
return container;
|
||||
}
|
||||
|
||||
async updateContainer(
|
||||
id: string,
|
||||
dto: UpdateStorageContainerDto,
|
||||
actingUserId: string,
|
||||
): Promise<StorageContainer> {
|
||||
const before = await this.prisma.storageContainer.findUnique({
|
||||
where: { id },
|
||||
});
|
||||
if (!before) {
|
||||
throw new NotFoundException('Storage container not found');
|
||||
}
|
||||
const container = await this.prisma.storageContainer.update({
|
||||
where: { id },
|
||||
data: { ...dto },
|
||||
});
|
||||
await this.auditLog.record({
|
||||
entityType: 'StorageContainer',
|
||||
entityId: id,
|
||||
action: 'UPDATE',
|
||||
userId: actingUserId,
|
||||
beforeData: before,
|
||||
afterData: container,
|
||||
});
|
||||
return container;
|
||||
}
|
||||
|
||||
async findAllStockItems(): Promise<StockItem[]> {
|
||||
return this.prisma.stockItem.findMany({ orderBy: { name: 'asc' } });
|
||||
}
|
||||
@@ -66,6 +94,27 @@ export class StorageService {
|
||||
return stockItem;
|
||||
}
|
||||
|
||||
async updateStockItem(
|
||||
id: string,
|
||||
dto: UpdateStockItemDto,
|
||||
actingUserId: string,
|
||||
): Promise<StockItem> {
|
||||
const before = await this.findStockItemById(id);
|
||||
const stockItem = await this.prisma.stockItem.update({
|
||||
where: { id },
|
||||
data: { ...dto },
|
||||
});
|
||||
await this.auditLog.record({
|
||||
entityType: 'StockItem',
|
||||
entityId: id,
|
||||
action: 'UPDATE',
|
||||
userId: actingUserId,
|
||||
beforeData: before,
|
||||
afterData: stockItem,
|
||||
});
|
||||
return stockItem;
|
||||
}
|
||||
|
||||
async addMovement(
|
||||
id: string,
|
||||
dto: CreateStockMovementDto,
|
||||
|
||||
Reference in new issue
Block a user