Skip to content

Commit

Permalink
Merge pull request #29 from PBTP/feature/update-profile
Browse files Browse the repository at this point in the history
DMVM-174 feat: Add update profile api
  • Loading branch information
shine-jung authored Jul 23, 2024
2 parents f782634 + 7842a96 commit e0d188d
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { AuthModule } from './auth/auth.module';
import { RedisModule } from '@liaoliaots/nestjs-redis';
import { CacheModule } from './common/cache/cache.module';
import { LoggerModule } from './config/logger/logger.module';
import { SystemAlarmModule } from "./system/system.alarm.module";
import { SystemAlarmModule } from './system/system.alarm.module';
import { ImageModule } from './common/image/image.module';
import { CloudModule } from './common/cloud/cloud.module';

Expand Down
8 changes: 4 additions & 4 deletions src/common/cache/cache.module.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Module } from "@nestjs/common";
import { RedisModule } from "@liaoliaots/nestjs-redis";
import { CacheService } from "./cache.service";
import { Module } from '@nestjs/common';
import { RedisModule } from '@liaoliaots/nestjs-redis';
import { CacheService } from './cache.service';

@Module({
imports:[RedisModule],
imports: [RedisModule],
providers: [CacheService],
exports: [CacheService],
})
Expand Down
31 changes: 29 additions & 2 deletions src/customer/presentation/customer.controller.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { CustomerService } from '../application/customer.service';
import { Controller, Get } from '@nestjs/common';
import { Body, Controller, Get, Put } from '@nestjs/common';
import { CustomerDto } from './customer.dto';
import { Customer } from '../../schemas/customers.entity';
import { Auth, CurrentCustomer } from '../../auth/decorator/auth.decorator';
import { ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger';
import { UpdateProfileDto } from './update-profile.dto';

@ApiTags('고객 관련 API')
@Controller('/v1/customer')
export class CustomerController {
constructor(private readonly authService: CustomerService) {}
constructor(private readonly customerService: CustomerService) {}

@ApiOperation({
summary: '내 정보 조회',
Expand All @@ -29,4 +30,30 @@ export class CustomerController {
authProvider: customer.authProvider,
};
}

@ApiOperation({
summary: '사용자 정보 수정',
description: '사용자 정보를 수정합니다.',
})
@ApiOkResponse({ type: CustomerDto, description: '사용자 정보 수정 성공' })
@Auth()
@Put()
async updateProfile(
@CurrentCustomer() customer: Customer,
@Body() dto: UpdateProfileDto,
): Promise<Omit<CustomerDto, 'refreshToken'>> {
const updatedCustomer = await this.customerService.update({
...customer,
...dto,
});

return {
customerId: updatedCustomer.customerId,
uuid: updatedCustomer.uuid,
customerName: updatedCustomer.customerName,
customerPhoneNumber: updatedCustomer.customerPhoneNumber,
customerLocation: updatedCustomer.customerLocation,
authProvider: updatedCustomer.authProvider,
};
}
}
33 changes: 33 additions & 0 deletions src/customer/presentation/update-profile.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { IsOptional, Length } from 'class-validator';
import { Point } from 'typeorm';
import { ApiProperty } from '@nestjs/swagger';

export class UpdateProfileDto {
@ApiProperty({
description: '고객 이름',
nullable: true,
required: false,
type: String,
})
@IsOptional()
@Length(1, 30)
customerName: string;

@ApiProperty({
description: '고객 전화번호',
nullable: true,
required: false,
type: String,
})
@IsOptional()
@Length(1, 30)
customerPhoneNumber?: string;

@ApiProperty({
description: '고객 위치',
nullable: true,
required: false,
})
@IsOptional()
customerLocation?: Point;
}

0 comments on commit e0d188d

Please sign in to comment.