1+ import { Controller , Get , Post , Put , Delete , Body , Param , Query , UseGuards } from '@nestjs/common' ;
2+ import { AssetTransfersService } from './asset-transfers.service' ;
3+ import { CreateTransferDto } from './dto/create-transfer.dto' ;
4+ import { ApproveTransferDto , RejectTransferDto } from './dto/approve-transfer.dto' ;
5+ import { TransferFilterDto } from './dto/transfer-filter.dto' ;
6+
7+ // Mock decorator since we don't have auth implemented yet
8+ const AuthGuard = ( ) => {
9+ return ( target : any , key ?: string | symbol , descriptor ?: PropertyDescriptor ) => {
10+ // Mock implementation - in real auth, this would validate JWT
11+ } ;
12+ } ;
13+ const GetUser = ( ) => {
14+ return ( target : any , propertyKey : string , parameterIndex : number ) => {
15+ // Mock implementation - in real auth, this would extract user from request
16+ } ;
17+ } ;
18+
19+ @Controller ( 'transfers' )
20+ export class AssetTransfersController {
21+ constructor ( private readonly assetTransfersService : AssetTransfersService ) { }
22+
23+ @Post ( )
24+ @UseGuards ( AuthGuard ( ) )
25+ async createTransfer (
26+ @Body ( ) createTransferDto : CreateTransferDto ,
27+ @GetUser ( ) user : any
28+ ) {
29+ return await this . assetTransfersService . createTransfer ( createTransferDto , user . id ) ;
30+ }
31+
32+ @Get ( )
33+ @UseGuards ( AuthGuard ( ) )
34+ async getTransfers (
35+ @Query ( ) filterDto : TransferFilterDto ,
36+ @GetUser ( ) user : any
37+ ) {
38+ return await this . assetTransfersService . getTransfers ( filterDto , user . id ) ;
39+ }
40+
41+ @Get ( ':id' )
42+ @UseGuards ( AuthGuard ( ) )
43+ async getTransferById ( @Param ( 'id' ) id : string ) {
44+ return await this . assetTransfersService . getTransferById ( id ) ;
45+ }
46+
47+ @Put ( ':id/approve' )
48+ @UseGuards ( AuthGuard ( ) )
49+ async approveTransfer (
50+ @Param ( 'id' ) id : string ,
51+ @Body ( ) approveDto : ApproveTransferDto ,
52+ @GetUser ( ) user : any
53+ ) {
54+ return await this . assetTransfersService . approveTransfer ( id , {
55+ ...approveDto ,
56+ approvedById : user . id
57+ } ) ;
58+ }
59+
60+ @Put ( ':id/reject' )
61+ @UseGuards ( AuthGuard ( ) )
62+ async rejectTransfer (
63+ @Param ( 'id' ) id : string ,
64+ @Body ( ) rejectDto : RejectTransferDto ,
65+ @GetUser ( ) user : any
66+ ) {
67+ return await this . assetTransfersService . rejectTransfer ( id , {
68+ ...rejectDto ,
69+ rejectedById : user . id
70+ } ) ;
71+ }
72+
73+ @Delete ( ':id' )
74+ @UseGuards ( AuthGuard ( ) )
75+ async cancelTransfer ( @Param ( 'id' ) id : string , @GetUser ( ) user : any ) {
76+ return await this . assetTransfersService . cancelTransfer ( id , user . id ) ;
77+ }
78+
79+ @Get ( 'notifications' )
80+ @UseGuards ( AuthGuard ( ) )
81+ async getNotifications ( @GetUser ( ) user : any ) {
82+ return await this . assetTransfersService . getNotifications ( user . id ) ;
83+ }
84+
85+ @Put ( 'notifications/:id/read' )
86+ @UseGuards ( AuthGuard ( ) )
87+ async markNotificationAsRead (
88+ @Param ( 'id' ) notificationId : string ,
89+ @GetUser ( ) user : any
90+ ) {
91+ return await this . assetTransfersService . markNotificationAsRead ( notificationId , user . id ) ;
92+ }
93+ }
0 commit comments