Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions controllers/notificationController.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const createNotification = async (req, res) => {
message,
notificationType,
url,
notificationId: notification.id,
});
res.status(200).json({
status: { success: true, code: 200, message: notification },
Expand Down
13 changes: 13 additions & 0 deletions controllers/userController.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,18 @@ const passwordChange = async (req, res) => {
}
};

const profileImageDelete = async (req, res) => {
const { id: userId } = req.user;
try {
await userService.profileImageDelete(userId);
res.status(200).json({ status: { success: true } });
} catch (error) {
res.status(500).json({
status: { success: false, code: 500, message: error.message },
});
}
};

export default {
signup,
deleteUser,
Expand All @@ -251,4 +263,5 @@ export default {
checkEmail,
resetPassword,
passwordChange,
profileImageDelete,
};
10 changes: 10 additions & 0 deletions repositorys/userRepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,15 @@ const passwordChange = async (userId, newPassword, confirmPassword) => {
});
return;
};

const profileImageDelete = async (userId) => {
await prisma.user.update({
where: { id: userId },
data: { profile_image: null },
});
return;
};

export default {
createUser,
deleteUser,
Expand All @@ -370,4 +379,5 @@ export default {
checkEmail,
resetPassword,
passwordChange,
profileImageDelete,
};
50 changes: 50 additions & 0 deletions router/userRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -1083,4 +1083,54 @@ router.patch(
userController.passwordChange
);

/**
* @swagger
* /api/v1/user/profile-image-delete:
* delete:
* tags:
* - User
* summary: 프로필 이미지 삭제
* description: 사용자의 프로필 이미지를 삭제합니다.
* security:
* - bearerAuth: []
* responses:
* '200':
* description: 프로필 이미지 삭제 성공
* content:
* application/json:
* schema:
* type: object
* properties:
* status:
* type: object
* properties:
* success:
* type: boolean
* example: true
* '500':
* description: 서버 에러
* content:
* application/json:
* schema:
* type: object
* properties:
* status:
* type: object
* properties:
* success:
* type: boolean
* example: false
* code:
* type: integer
* example: 500
* message:
* type: string
* example: "프로필 이미지 삭제 중 오류가 발생했습니다."
*/
router.delete(
'/profile-image-delete',
jwtToken.accessVerifyToken,
userController.profileImageDelete
);

export default router;
6 changes: 6 additions & 0 deletions services/userService.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ const passwordChange = async (userId, newPassword, confirmPassword) => {
return user;
};

const profileImageDelete = async (userId) => {
const user = await userRepository.profileImageDelete(userId);
return user;
};

export default {
createUser,
deleteUser,
Expand All @@ -129,4 +134,5 @@ export default {
checkEmail,
resetPassword,
passwordChange,
profileImageDelete,
};
Loading