import { PartnerInfo } from '@/common/decorators/partnerInfo.decorator' import type { IPartnerPayload } from '@/common/models/partnerPayload.model' import { multerImageOptions } from '@/multer.config' import { Body, Controller, Get, Patch, Put, UploadedFile, UseInterceptors, } from '@nestjs/common' import { FileInterceptor } from '@nestjs/platform-express' import { ApiBody, ApiConsumes, ApiTags } from '@nestjs/swagger' import { UpdatePartnerProfileDto } from './dto/partner.dto' import { PartnerServiceGetInfoResponseDto, PartnerServiceMeResponseDto, PartnerServiceUpdateInfoResponseDto, } from './dto/partners-response.dto' import { UpdatePartnerPasswordDto } from './dto/update-password-request.dto' import { PartnerService } from './partners.service' @ApiTags('Partner') @Controller('partner') export class PartnerController { constructor(private service: PartnerService) {} @Get('') async me( @PartnerInfo() { id, account_id }: IPartnerPayload, ): Promise { return this.service.me(id, account_id) } @Get('info') async getInfo( @PartnerInfo('id') partnerId: string, ): Promise { return this.service.getInfo(partnerId) } @Patch('') @UseInterceptors(FileInterceptor('logo', multerImageOptions)) @ApiConsumes('multipart/form-data') @ApiBody({ schema: { type: 'object', properties: { logo: { type: 'string', format: 'binary' }, }, }, }) async update( @PartnerInfo('id') partnerId: string, @Body() data: UpdatePartnerProfileDto, @UploadedFile() logo: Express.Multer.File, ): Promise { return this.service.updateInfo(partnerId, data, logo) } @Put('update-password') async updatePassword( @PartnerInfo('id') partnerId: string, @PartnerInfo('account_id') accountId: string, @Body() data: UpdatePartnerPasswordDto, ) { return this.service.updatePassword(partnerId, accountId, data) } }