Skip to content

Commit 171e9c1

Browse files
authored
Merge pull request #297 from snack-25/feature/86-auth
Feature/86 auth
2 parents 53a6819 + fbd8db9 commit 171e9c1

4 files changed

Lines changed: 12 additions & 9 deletions

File tree

src/budgets/budgets.controller.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,9 @@ export class BudgetsController {
3131
})
3232
@ApiResponse({ status: 200, description: '예산 정보 수정에 성공했습니다' })
3333
@Put('update')
34-
public async update(
35-
@Body() dto: BudgetsRequestDto,
36-
// @Req() req: Request,
37-
@Res() res: Response,
38-
): Promise<void> {
34+
public async update(@Body() dto: BudgetsRequestDto, @Res() res: Response): Promise<void> {
3935
const update = await this.budgetsService.update(dto);
4036
res.status(200).json({ data: update, message: '예산 변경에 성공했습니다' });
4137
}
42-
4338
//TODO: /budgets/{budgetId} (DELETE) 예산 정보 삭제
4439
}

src/budgets/budgets.service.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Injectable } from '@nestjs/common';
1+
import { Injectable, BadRequestException } from '@nestjs/common';
22
import { PrismaService } from '@src/shared/prisma/prisma.service';
33
import { BudgetsRequestDto, BudgetsResponseDto } from './dto/budgets.dto';
44

@@ -46,6 +46,12 @@ export class BudgetsService {
4646
try {
4747
// 특정 예산 레코드 조회
4848
console.log('dto', dto);
49+
50+
const MAX_AMOUNT = 500_000_000;
51+
if (dto.currentAmount > MAX_AMOUNT || dto.initialAmount > MAX_AMOUNT) {
52+
throw new BadRequestException('금액이 5억을 초과하였습니다.');
53+
}
54+
4955
const existingBudget = await this.prisma.budget.findUnique({
5056
where: {
5157
companyId_year_month: {
@@ -100,7 +106,7 @@ export class BudgetsService {
100106
};
101107
} catch (err) {
102108
console.error('예산 처리 중 에러 발생', err);
103-
throw new Error('예산 처리 중 오류 발생');
109+
throw err; // 덮어씌우지 않고 원래 에러 그대로 전달
104110
}
105111
}
106112
}

src/users/users.controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export class UsersController {
4848
@Patch('update/info')
4949
@ApiResponse({ status: 200, description: '유저 정보 수정' })
5050
public async updateData(
51-
@Body() body: { password: string; company?: string },
51+
@Body() body: { password?: string; company?: string },
5252
@Req() req: Request,
5353
@Res() res: Response,
5454
): Promise<void> {

src/users/users.service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ export class UsersService {
190190
}
191191

192192
if (body.password) {
193+
this.validatePassword(body.password);
194+
193195
const hashedPassword = await argon2.hash(body.password);
194196

195197
const currentData = await this.prisma.user.findUnique({

0 commit comments

Comments
 (0)