Skip to content

Commit

Permalink
Merge pull request #101 from mash-up-kr/feat/error-in-same-folder-id
Browse files Browse the repository at this point in the history
Feat: Add error code F003 to update as same folder name
  • Loading branch information
J-Hoplin authored Aug 15, 2024
2 parents bd3d0a6 + 45a5f6c commit 4d8b63f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/app.swagger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export function nestSwaggerConfig<
- F001 - ํด๋” ์ด๋ฆ„์ด ์ค‘๋ณต๋˜๋Š” ๊ฒฝ์šฐ ์ž…๋‹ˆ๋‹ค\n
- F002 - ํด๋”๊ฐ€ ์‚ฌ์šฉ์ž์˜ ํด๋”๊ฐ€ ์•„๋‹Œ ๊ฒฝ์šฐ ์ž…๋‹ˆ๋‹ค
- F003 - ์ˆ˜์ •ํ•˜๋ ค๋Š” ํด๋” ์ด๋ฆ„์ด ๊ธฐ์กด ์ด๋ฆ„๊ณผ ๋™์ผํ•œ ์ด๋ฆ„์ž…๋‹ˆ๋‹ค
\n
### [ํ”ผ๋“œ]\n
Expand Down
4 changes: 1 addition & 3 deletions src/infrastructure/ai/ai.constant.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import OpenAI from 'openai';

// GPT Model Version
export const gptVersion: OpenAI.Chat.ChatModel = 'gpt-4o-mini-2024-07-18';
export const gptVersion = 'gpt-4o-mini-2024-07-18';

// TODO: ์„œ๋ฒ„์—์„œ ๋ถ™์—ฌ์ฃผ๋Š” ์ž„์˜์˜ ํด๋” ๋ฆฌ์ŠคํŠธ
export const mockFolderLists = [];
2 changes: 1 addition & 1 deletion src/modules/folders/docs/folder-api.docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const UpdateFolderDocs = applyDecorators(
type: FolderResponse,
}),
ApiNotFoundResponse({
description: ['F002'].join(', '),
description: ['F002', 'F003'].join(', '),
}),
);

Expand Down
4 changes: 4 additions & 0 deletions src/modules/folders/error/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ export const F001 = (folderName: string) => {
};

export const F002 = createErrorObject('F002', 'ํด๋”๊ฐ€ ์กด์žฌํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค!');

export const F003 = (folderName: string) => {
return createErrorObject('F003', `๋™์ผํ•œ ํด๋”์ด๋ฆ„ ์ž…๋‹ˆ๋‹ค: ${folderName}`);
};
6 changes: 5 additions & 1 deletion src/modules/folders/folders.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Types } from 'mongoose';
import { PostsRepository } from '../posts/posts.repository';
import { FolderListServiceDto } from './dto/folder-list-service.dto';
import { CreateFolderDto, UpdateFolderDto } from './dto/mutate-folder.dto';
import { F001 } from './error';
import { F001, F003 } from './error';
import { FolderRepository } from './folders.repository';

@Injectable()
Expand Down Expand Up @@ -111,6 +111,10 @@ export class FoldersService {
userId,
});

if (folder.name === updateFolderDto.name) {
throw new BadRequestException(F003(folder.name));
}

folder.name = updateFolderDto.name;
const response = await folder.save();
return response;
Expand Down

0 comments on commit 4d8b63f

Please sign in to comment.