Skip to content

feat: implement bulk assets, tags, upload service, and notification p…#720

Merged
yusuftomilola merged 2 commits into
DistinctCodes:mainfrom
Mkalbani:feat/be-41-42-43-44-697-699
Apr 26, 2026
Merged

feat: implement bulk assets, tags, upload service, and notification p…#720
yusuftomilola merged 2 commits into
DistinctCodes:mainfrom
Mkalbani:feat/be-41-42-43-44-697-699

Conversation

@Mkalbani

@Mkalbani Mkalbani commented Apr 25, 2026

Copy link
Copy Markdown
Contributor

closes #696
closes #697
closes #698
closes #699

Implementation Details

  • Auth & Authorization: All endpoints protected by `JwtAuthGuard`; bulk operations require `ADMIN` or `MANAGER` role
  • Role-Based Access: Custom `@Roles()` decorator with `RolesGuard` for fine-grained control
  • History Logging: Bulk asset operations automatically log per-asset history entries
  • Validation: DTOs with class-validator for request validation
  • Storage: Multer disk storage with environment variable configuration
  • Database: TypeORM entities with proper relationships and timestamps

Files Added

```
backend/contrib/
├── src/
│ ├── app.module.ts
│ ├── main.ts
│ ├── assets/
│ │ ├── asset.entity.ts
│ │ ├── asset-history.entity.ts
│ │ ├── assets.service.ts
│ │ ├── assets.controller.ts
│ │ ├── assets.module.ts
│ │ ├── enums.ts
│ │ └── dto/ (5 DTOs)
│ ├── upload/
│ │ ├── upload.service.ts
│ │ ├── upload.controller.ts
│ │ ├── upload.module.ts
│ ├── notifications/
│ │ ├── notification-preference.entity.ts
│ │ ├── notification-preferences.service.ts
│ │ ├── notification-preferences.controller.ts
│ │ ├── notifications.module.ts
│ │ ├── user-registration.subscriber.ts
│ │ └── dto/
│ ├── auth/
│ │ ├── guards/
│ │ │ ├── jwt-auth.guard.ts
│ │ │ └── roles.guard.ts
│ │ └── decorators/ (roles decorator)
│ └── users/
│ └── user.entity.ts
└── .gitignore
```

Issues Resolved

Changes

BE-42: Bulk Asset Operations

  • PATCH /assets/bulk-status - Update status for multiple assets
  • DELETE /assets/bulk - Soft-delete multiple assets
  • PATCH /assets/bulk-department - Transfer multiple assets to another department
  • Protected by JwtAuthGuard with @roles(UserRole.ADMIN, UserRole.MANAGER)
  • Each operation logs an AssetHistory entry per affected asset

BE-43: Asset Tags & Global Search

  • PATCH /assets/:id/tags - Replace asset tags
  • GET /assets/search?q=query - Full-text search across assets
  • Searches: name, assetId, serialNumber, manufacturer, model, description, tags
  • Ranking: Exact assetId match ranked first with weighted relevance scoring

BE-41: File Upload Service

  • POST /upload/image - Upload image (JPEG, PNG, WebP, max 5MB)
  • POST /upload/document - Upload document (PDF, DOC, DOCX, max 20MB)
  • Saves to uploads/images/ and uploads/documents/ with UUID filenames
  • Returns { url: string }
  • UPLOAD_DEST environment variable controls storage directory
  • Protected by JwtAuthGuard

BE-44: Notification Preferences

  • NotificationPreference entity with userId, assetCreated, assetTransferred, maintenanceDue, warrantyExpiring flags
  • Default preferences auto-created on user registration
  • GET /notifications/preferences - Retrieve current user preferences
  • PATCH /notifications/preferences - Update notification preferences
  • All endpoints protected by JwtAuthGuard

Implementation Details

  • All endpoints protected by JwtAuthGuard
  • Bulk operations require ADMIN or MANAGER role
  • Custom @roles() decorator with RolesGuard for fine-grained control
  • Bulk asset operations automatically log per-asset history entries
  • DTOs with class-validator for request validation
  • Multer disk storage with environment variable configuration
  • TypeORM entities with proper relationships and timestamps

…references

Implements all four backend features for BE-41 through BE-44 issues.

- BE-42: Bulk asset operations (status, delete, department transfer)
- BE-43: Asset tags management and global search with relevance ranking
- BE-41: File upload service for images and documents
- BE-44: User notification preferences module

All endpoints protected by JWT auth with role-based access control.
Asset operations log history entries per affected asset.
Search supports full-text matching across asset fields with ranking.

Closes DistinctCodes#696 DistinctCodes#697 DistinctCodes#698 DistinctCodes#699
@vercel

vercel Bot commented Apr 25, 2026

Copy link
Copy Markdown

@Mkalbani is attempting to deploy a commit to the naijabuz's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Apr 25, 2026

Copy link
Copy Markdown

@Mkalbani Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@yusuftomilola yusuftomilola merged commit a55cb88 into DistinctCodes:main Apr 26, 2026
0 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants