Skip to content
Snippets Groups Projects
Commit b82d73cd authored by 세현 임's avatar 세현 임
Browse files

Refactor/#22

parents 12fbca62 6e0ce3d0
Branches
No related tags found
2 merge requests!42[#25] 배포코드 master브랜치로 이동,!35Refactor/#22
...@@ -14,7 +14,7 @@ class MeetingController { ...@@ -14,7 +14,7 @@ class MeetingController {
* "time_idx_start": 40, // 예: 10:00 AM * "time_idx_start": 40, // 예: 10:00 AM
* "time_idx_end": 42, // 예: 10:30 AM * "time_idx_end": 42, // 예: 10:30 AM
* "location": "회의실 A", * "location": "회의실 A",
* "deadline": "2024-04-25T23:59:59Z", * "deadline": "43",
* "type": "OPEN" // "OPEN" 또는 "CLOSE" * "type": "OPEN" // "OPEN" 또는 "CLOSE"
* "max_num": * "max_num":
* } * }
...@@ -116,6 +116,23 @@ class MeetingController { ...@@ -116,6 +116,23 @@ class MeetingController {
res.status(500).json({ error: err.message || '모임 상세 조회 실패' }); res.status(500).json({ error: err.message || '모임 상세 조회 실패' });
} }
} }
/*
Delete /api/meetings/:meetingId
*/
async closeMeeting(req,res)
{
const { meetingId } = req.params;
const userid=req.user.id;
try {
const meetingDetail = await MeetingService.leaveMeeting(meetingId,userId);
res.status(200).json('모임 삭제성공!');
} catch (err) {
console.error('모임 삭제 오류', err);
res.status(500).json({ error: err.message || '모임삭제 실패' });
}
}
} }
module.exports = new MeetingController(); module.exports = new MeetingController();
//models/friend.js
const { DataTypes } = require('sequelize'); const { DataTypes } = require('sequelize');
const sequelize = require('../config/sequelize'); const sequelize = require('../config/sequelize');
const User = require('./user'); // 올바른 경로 확인 const User = require('./user'); // 올바른 경로 확인
......
...@@ -5,7 +5,7 @@ const User = require('../models/user'); ...@@ -5,7 +5,7 @@ const User = require('../models/user');
module.exports = new GoogleStrategy( module.exports = new GoogleStrategy(
{ {
clientID: process.env.GOOGLE_CLIENT_ID, // .env 파일에 설정 clientID: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET, clientSecret: process.env.GOOGLE_CLIENT_SECRET,
callbackURL: process.env.CALLBACK_URL, callbackURL: process.env.CALLBACK_URL,
}, },
......
...@@ -11,9 +11,7 @@ const FriendListDTO = require('../dtos/FriendListDTO'); ...@@ -11,9 +11,7 @@ const FriendListDTO = require('../dtos/FriendListDTO');
class FriendService { class FriendService {
/** /**
* User 존재 여부 유효성 검사 * User 존재 여부 유효성 검사
* @param {number} userId - 검사할 사용자 ID * userId - 검사할 사용자 ID
* @returns {Promise<User>} - 유효한 사용자 객체
* @throws {Error} - 사용자가 존재하지 않을 경우
*/ */
async validUser(userId) { async validUser(userId) {
const user = await User.findByPk(userId); const user = await User.findByPk(userId);
...@@ -25,10 +23,9 @@ class FriendService { ...@@ -25,10 +23,9 @@ class FriendService {
/** /**
* 친구 요청 보내기 * 친구 요청 보내기
* @param {number} userId - 친구 요청을 보내는 사용자 ID * userId - 친구 요청을 보내는 사용자 ID
* @param {number} friendId - 친구 요청을 받는 사용자 ID * friendId - 친구 요청을 받는 사용자 ID
* @returns {Promise<FriendResponseDTO>} - 생성된 친구 요청 DTO * returns - 생성된 친구 요청 DTO
* @throws {Error} - 유효하지 않은 요청일 경우
*/ */
async sendFriendRequest(userId, friendId) { async sendFriendRequest(userId, friendId) {
await this.validUser(userId); await this.validUser(userId);
...@@ -81,8 +78,8 @@ class FriendService { ...@@ -81,8 +78,8 @@ class FriendService {
/** /**
* 받은 친구 요청 목록 조회 * 받은 친구 요청 목록 조회
* @param {number} userId - 요청을 받은 사용자 ID userId - 요청을 받은 사용자 ID
* @returns {Promise<Array<FriendResponseDTO>>} - 받은 친구 요청 목록 DTO 배열 받은 친구 요청 목록 DTO 배열
*/ */
async getReceivedRequests(userId) { async getReceivedRequests(userId) {
const receivedRequests = await Friend.findAll({ const receivedRequests = await Friend.findAll({
...@@ -101,8 +98,7 @@ class FriendService { ...@@ -101,8 +98,7 @@ class FriendService {
/** /**
* 보낸 친구 요청 목록 조회 * 보낸 친구 요청 목록 조회
* @param {number} userId - 요청을 보낸 사용자 ID * userId - 요청을 보낸 사용자 ID
* @returns {Promise<Array<FriendResponseDTO>>} - 보낸 친구 요청 목록 DTO 배열
*/ */
async getSentRequests(userId) { async getSentRequests(userId) {
const sentRequests = await Friend.findAll({ const sentRequests = await Friend.findAll({
...@@ -163,10 +159,9 @@ class FriendService { ...@@ -163,10 +159,9 @@ class FriendService {
/** /**
* 친구 요청 거절 * 친구 요청 거절
* @param {number} userId - 요청을 거절하는 사용자 ID *userId - 요청을 거절하는 사용자 ID
* @param {number} friendId - 친구 요청을 보낸 사용자 ID * friendId - 친구 요청을 보낸 사용자 ID
* @returns {Promise<number>} - 삭제된 친구 요청 수 * returns - 삭제된 친구 요청 수
* @throws {Error} - 친구 요청이 존재하지 않을 경우
*/ */
async rejectFriendRequest(userId, friendId) { async rejectFriendRequest(userId, friendId) {
const result = await Friend.destroy({ const result = await Friend.destroy({
...@@ -186,10 +181,10 @@ class FriendService { ...@@ -186,10 +181,10 @@ class FriendService {
/** /**
* 친구 목록 조회 * 친구 목록 조회
* @param {number} userId - 친구 목록을 조회할 사용자 ID userId - 친구 목록을 조회할 사용자 ID
* @param {number} limit - 한 페이지에 표시할 친구 수 limit - 한 페이지에 표시할 친구 수
* @param {number} offset - 페이징 오프셋 offset - 페이징 오프셋
* @returns {Promise<Array<FriendListDTO>>} - 친구 목록 DTO 배열 친구 목록 DTO 배열
*/ */
async getFriendList(userId, pagination) { async getFriendList(userId, pagination) {
const { limit = 20, offset = 0 } = pagination; const { limit = 20, offset = 0 } = pagination;
...@@ -232,10 +227,10 @@ class FriendService { ...@@ -232,10 +227,10 @@ class FriendService {
/** /**
* 친구 삭제 * 친구 삭제
* @param {number} userId - 친구를 삭제하는 사용자 ID - 친구를 삭제하는 사용자 ID
* @param {number} friendId - 삭제할 친구의 사용자 ID - 삭제할 친구의 사용자 ID
* @returns {Promise<number>} - 삭제된 친구 관계 수 - 삭제된 친구 관계 수
* @throws {Error} - 친구 관계가 존재하지 않을 경우 -친구 관계가 존재하지 않을 경우
*/ */
async deleteFriend(userId, friendId) { async deleteFriend(userId, friendId) {
const result = await Friend.destroy({ const result = await Friend.destroy({
......
// test/scheduleService.test.js // test/scheduleService.test.js
const sequelize = require('../config/sequelize'); // 실제 경로에 맞게 수정 const sequelize = require('../config/sequelize');
const { Schedule, User } = require('../models'); const { Schedule, User } = require('../models');
const ScheduleService = require('../services/scheduleService'); // Uppercase 'S'로 가져오기 const ScheduleService = require('../services/scheduleService');
const ScheduleResponseDTO = require('../dtos/ScheduleResponseDTO'); const ScheduleResponseDTO = require('../dtos/ScheduleResponseDTO');
beforeAll(async () => { beforeAll(async () => {
// 테스트 스위트가 시작되기 전에 데이터베이스를 동기화합니다.
await sequelize.sync({ force: true }); await sequelize.sync({ force: true });
}); });
beforeEach(async () => { beforeEach(async () => {
// 각 테스트가 시작되기 전에 기존 데이터를 삭제합니다.
await Schedule.destroy({ where: {} }); await Schedule.destroy({ where: {} });
await User.destroy({ where: {} }); await User.destroy({ where: {} });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment