Skip to content

Commit

Permalink
feat(services): rename methods
Browse files Browse the repository at this point in the history
  • Loading branch information
georgiirocket committed Nov 29, 2024
1 parent a4f379b commit 76636b1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion apps/post/src/post.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,6 @@ export class PostController {
*/
@MessagePattern(POST_PATTERNS.DELETE_POST)
async deleteEntity(data: DeletePostDto): Promise<PostDto> {
return this.postService.deleteUser(data);
return this.postService.deleteEntity(data);
}
}
2 changes: 1 addition & 1 deletion apps/post/src/post.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class PostService {
* Delete entity
* @param data
*/
async deleteUser(data: DeletePostDto): Promise<PostDto> {
async deleteEntity(data: DeletePostDto): Promise<PostDto> {
return this.prismaService.post.delete({ where: data });
}
}
6 changes: 3 additions & 3 deletions apps/user/src/user.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class UserController {
*/
@MessagePattern(USER_PATTERNS.CREATE_USER)
async createEntity(data: CreateUserDto): Promise<UserDto> {
const existUser = await this.userService.checkExistUser(data.name);
const existUser = await this.userService.checkExistEntity(data.name);

if (existUser) {
throw new Error('Choose another user');
Expand All @@ -57,7 +57,7 @@ export class UserController {
*/
@MessagePattern(USER_PATTERNS.UPDATE_USER)
async updateEntity(data: UpdateUserDto): Promise<UserDto> {
const existUser = await this.userService.checkExistUser(data.name);
const existUser = await this.userService.checkExistEntity(data.name);

if (existUser) {
throw new Error('Choose another user');
Expand All @@ -72,6 +72,6 @@ export class UserController {
*/
@MessagePattern(USER_PATTERNS.DELETE_USER)
async deleteEntity(data: DeleteUserDto): Promise<UserDto> {
return this.userService.deleteUser(data);
return this.userService.deleteEntity(data);
}
}
6 changes: 3 additions & 3 deletions apps/user/src/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ export class UserService {
* Delete entity
* @param data
*/
async deleteUser(data: DeleteUserDto): Promise<UserDto> {
async deleteEntity(data: DeleteUserDto): Promise<UserDto> {
return this.prismaService.user.delete({ where: data });
}

/**
* Check exist user
* Check exist entity
* @param userName
*/
async checkExistUser(userName: string): Promise<UserDto | null> {
async checkExistEntity(userName: string): Promise<UserDto | null> {
return this.prismaService.user.findUnique({ where: { name: userName } });
}
}

0 comments on commit 76636b1

Please sign in to comment.