Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
WebBack
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
websystem
WebBack
Commits
6958b3d4
Commit
6958b3d4
authored
7 months ago
by
조대희
Browse files
Options
Downloads
Patches
Plain Diff
refactor: 스케줄 서비스 수정에 따른 컨트롤러, 미팅 서비스 수정
parent
d28f525a
Branches
Branches containing commit
No related tags found
1 merge request
!42
[#25] 배포코드 master브랜치로 이동
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
controllers/scheduleController.js
+29
-31
29 additions, 31 deletions
controllers/scheduleController.js
services/meetingService.js
+20
-31
20 additions, 31 deletions
services/meetingService.js
with
49 additions
and
62 deletions
controllers/scheduleController.js
+
29
−
31
View file @
6958b3d4
...
...
@@ -22,22 +22,19 @@ class scheduleController {
async
createSchedule
(
req
,
res
)
{
try
{
const
userId
=
req
.
user
.
id
;
const
scheduleRequestDTO
=
new
ScheduleRequestDTO
(
req
.
body
);
const
validatedData
=
scheduleRequestDTO
.
validate
(
'
create
'
);
// 'create' 타입 검증
const
{
title
,
is_fixed
,
time_indices
}
=
req
.
body
;
const
{
title
,
is_fixed
,
events
}
=
validatedData
;
const
schedules
=
await
ScheduleService
.
createSchedules
({
const
schedule
=
await
ScheduleService
.
createSchedules
({
userId
,
title
,
is_fixed
,
event
s
time_indice
s
});
return
res
.
status
(
201
).
json
({
success
:
true
,
data
:
{
schedule
s
schedule
}
});
}
catch
(
error
)
{
...
...
@@ -57,31 +54,32 @@ class scheduleController {
* Bulk update 지원
* 요청 본문 예시:
* {
* updates: [
* { time_idx: 36, title: 'New Title', is_fixed: true },
* { time_idx: 44, title: 'Another Title' },
* // ...
* ]
* "originalTitle": "알고리즘 스터디", // 기존 스케줄의 제목
* "title": "알고리즘 스터디 2.0", // 변경할 제목 (제목 변경 안할거면 기존 제목을 넣어야함 * -> title로 동일 스케줄을 찾아서)
* "is_fixed": true,
* "time_indices": [36, 37, 38, 40] // 변경할 time_indices 배열
* }
*/
async
updateSchedules
(
req
,
res
)
{
try
{
const
userId
=
req
.
user
.
id
;
const
scheduleRequestDTO
=
new
ScheduleRequestDTO
(
req
.
body
);
const
validatedData
=
scheduleRequestDTO
.
validate
(
'
bulk_update
'
);
// 'bulk_update' 타입 검증
const
{
originalTitle
,
title
,
is_fixed
,
time_indices
}
=
req
.
body
;
const
{
updates
}
=
validatedData
;
const
updatedSchedules
=
await
ScheduleService
.
updateSchedules
(
userId
,
updates
);
const
updatedSchedule
=
await
ScheduleService
.
updateSchedules
(
userId
,
{
originalTitle
,
title
,
is_fixed
,
time_indices
});
return
res
.
status
(
200
).
json
({
success
:
true
,
data
:
{
schedule
s
:
updatedSchedule
s
schedule
:
updatedSchedule
}
});
}
catch
(
error
)
{
if
(
error
.
cod
e
===
'
S
CHEDULE_NOT_FOUND
'
)
{
if
(
error
.
messag
e
===
'
S
chedule not found
'
)
{
return
res
.
status
(
404
).
json
({
success
:
false
,
error
:
{
...
...
@@ -106,24 +104,21 @@ class scheduleController {
* Bulk delete 지원
* 요청 본문 예시:
* {
*
ti
me_idxs: [36, 44, ...]
*
"
ti
tle": "알고리즘 스터디"
* }
*/
async
deleteSchedules
(
req
,
res
)
{
try
{
const
userId
=
req
.
user
.
id
;
const
scheduleRequestDTO
=
new
ScheduleRequestDTO
(
req
.
body
);
const
validatedData
=
scheduleRequestDTO
.
validate
(
'
bulk_delete
'
);
// 'bulk_delete' 타입 검증
const
{
time_idxs
}
=
validatedData
;
const
{
title
}
=
req
.
body
;
const
result
=
await
ScheduleService
.
deleteSchedules
(
userId
,
ti
me_idxs
);
const
result
=
await
ScheduleService
.
deleteSchedules
(
userId
,
ti
tle
);
return
res
.
status
(
200
).
json
({
success
:
true
,
data
:
{
message
:
'
Schedule
s
successfully deleted
'
,
deleted
_time_idxs
:
result
.
deleted
_time_idxs
message
:
'
Schedule successfully deleted
'
,
deleted
Count
:
result
.
deleted
Count
}
});
}
catch
(
error
)
{
...
...
@@ -136,7 +131,6 @@ class scheduleController {
});
}
}
/**
* 해당 사용자 전체 스케줄 조회
* GET /api/schedule/all
...
...
@@ -148,7 +142,9 @@ class scheduleController {
return
res
.
status
(
200
).
json
({
success
:
true
,
data
:
schedules
data
:
{
schedules
}
});
}
catch
(
error
)
{
return
res
.
status
(
500
).
json
({
...
...
@@ -175,7 +171,9 @@ class scheduleController {
return
res
.
status
(
200
).
json
({
success
:
true
,
data
:
schedule
data
:
{
schedule
}
});
}
catch
(
error
)
{
if
(
error
.
message
===
'
Schedule not found
'
)
{
...
...
This diff is collapsed.
Click to expand it.
services/meetingService.js
+
20
−
31
View file @
6958b3d4
...
...
@@ -118,20 +118,16 @@ class MeetingService {
{
transaction
}
);
// 스케줄 생성 (모임 시간 범위 내 모든 time_idx에 대해 생성)
const
events
=
[];
for
(
let
idx
=
time_idx_start
;
idx
<=
time_idx_end
;
idx
++
)
{
events
.
push
({
time_idx
:
idx
});
}
await
ScheduleService
.
createSchedules
(
{
const
time_indices
=
Array
.
from
(
{
length
:
time_idx_end
-
time_idx_start
+
1
},
(
_
,
i
)
=>
time_idx_start
+
i
);
await
ScheduleService
.
createSchedules
({
userId
:
created_by
,
title
:
`번개 모임:
${
title
}
`
,
is_fixed
:
false
,
events
:
events
,
},
transaction
);
time_indices
:
time_indices
,
},
transaction
);
// 친구 초대 로직 호출
const
invitedFriendIds
=
await
this
.
sendInvites
({
...
...
@@ -264,24 +260,17 @@ class MeetingService {
{
transaction
}
);
// 스케줄 생성 (모임 시간 범위 내 모든 time_idx에 대해 생성)
const
events
=
[];
for
(
let
idx
=
meeting
.
time_idx_start
;
idx
<=
meeting
.
time_idx_end
;
idx
++
)
{
events
.
push
({
time_idx
:
idx
});
}
await
ScheduleService
.
createSchedules
(
{
const
time_indices
=
Array
.
from
(
{
length
:
meeting
.
time_idx_end
-
meeting
.
time_idx_start
+
1
},
(
_
,
i
)
=>
meeting
.
time_idx_start
+
i
);
await
ScheduleService
.
createSchedules
({
userId
:
userId
,
title
:
`번개 모임:
${
meeting
.
title
}
`
,
is_fixed
:
false
,
events
:
events
,
},
transaction
);
time_indices
:
time_indices
,
},
transaction
);
// 채팅방 참가 (MongoDB)
const
user
=
await
User
.
findOne
({
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment