Skip to content

Commit 2c23530

Browse files
authored
Merge pull request #7 from chan000518/feat_chan
feat: 스켸줄에 운동 부위 추가
2 parents 7492d0a + fa2a3eb commit 2c23530

File tree

6 files changed

+33
-4
lines changed

6 files changed

+33
-4
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
-- AlterTable
2+
ALTER TABLE "Schedule" ADD COLUMN "comment" TEXT,
3+
ADD COLUMN "trainingTarget" TEXT NOT NULL DEFAULT 'default_value';
4+
5+
-- CreateTable
6+
CREATE TABLE "ExerciseDetail" (
7+
"id" SERIAL NOT NULL,
8+
"scheduleId" INTEGER NOT NULL,
9+
"exerciseName" TEXT NOT NULL,
10+
"reps" INTEGER NOT NULL,
11+
"sets" INTEGER NOT NULL,
12+
"weight" DOUBLE PRECISION,
13+
"duration" INTEGER,
14+
15+
CONSTRAINT "ExerciseDetail_pkey" PRIMARY KEY ("id")
16+
);
17+
18+
-- AddForeignKey
19+
ALTER TABLE "ExerciseDetail" ADD CONSTRAINT "ExerciseDetail_scheduleId_fkey" FOREIGN KEY ("scheduleId") REFERENCES "Schedule"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- AlterTable
2+
ALTER TABLE "Schedule" ALTER COLUMN "trainingTarget" DROP DEFAULT;

prisma/schema.prisma

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ model Schedule {
6464
date DateTime // PT 날짜 및 시간
6565
location String? // PT 장소 (선택적)
6666
status Status @default(SCHEDULED) // 일정 상태
67-
trainingTarget String
67+
trainingTarget String // 기본값 설정
6868
comment String?
6969
exerciseDetails ExerciseDetail[]
7070
memberId Int

src/controllers/trainerController.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ const getMemberByTrainerController = asyncHandler(async (req, res) => {
5858

5959
// 스케줄 제안 (트레이너)
6060
const proposeScheduleByTrainerController = asyncHandler(async (req, res) => {
61-
const { memberId, date, location } = req.body;
61+
const { memberId, date, location, trainingTarget } = req.body;
6262
const trainer= req.role;
63-
const schedule = await proposeScheduleByTrainer(trainer.id, memberId, new Date(date), location);
63+
const schedule = await proposeScheduleByTrainer(trainer.id, memberId, new Date(date), location, trainingTarget);
6464
res.status(201).json(schedule);
6565
});
6666

src/routers/trainerRouters.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,9 @@ router.get("/schedules", authenticateToken, trainerMiddleware, getTrainerSchedul
199199
* location:
200200
* type: string
201201
* description: "스케줄 장소"
202+
* trainingTarget:
203+
* type: string
204+
* description: "운동 부위"
202205
* responses:
203206
* 201:
204207
* description: "스케줄 생성 성공"
@@ -328,6 +331,10 @@ module.exports = router;
328331
* type: string
329332
* description: "스케줄 장소"
330333
* example: "Gym A"
334+
* trainingTarget:
335+
* type: string
336+
* description: "운동 부위"
337+
* example: "등"
331338
* status:
332339
* type: string
333340
* enum:

src/services/trainerService.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,13 @@ const ScheduleStatus = {
159159
};
160160

161161
// 트레이너가 스케줄 제안
162-
const proposeScheduleByTrainer = async (trainerId, memberId, date, location) => {
162+
const proposeScheduleByTrainer = async (trainerId, memberId, date, location, trainingTarget) => {
163163
return await prisma.schedule.create({
164164
data: {
165165
date,
166166
location,
167167
status: ScheduleStatus.TRAINER_PROPOSED,
168+
trainingTarget,
168169
trainerId,
169170
memberId,
170171
},

0 commit comments

Comments
 (0)