generated from jphacks/JP_sample
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/hikahana/add-point-dailog
- Loading branch information
Showing
13 changed files
with
479 additions
and
236 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
app/src/app/api/experiencePoint/continuation/[id]/route.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { prisma } from "@lib/prisma"; | ||
import type { NextRequest } from "next/server"; | ||
import { NextResponse } from "next/server"; | ||
|
||
// continuationDayの更新 | ||
export async function PUT(req: NextRequest) { | ||
const { pathname } = new URL(req.url || ""); | ||
const id = Number(pathname.split("/").pop()); | ||
|
||
if (!id) { | ||
return NextResponse.json( | ||
{ error: "Invalid or missing ID" }, | ||
{ status: 400 }, | ||
); | ||
} | ||
|
||
try { | ||
const { continuationDay } = await req.json(); | ||
if (typeof continuationDay !== "number") { | ||
return NextResponse.json( | ||
{ error: "Invalid speed value" }, | ||
{ status: 400 }, | ||
); | ||
} | ||
|
||
const putContinuationDay = await prisma.experiencePoint.update({ | ||
where: { id }, | ||
data: { continuationDay: continuationDay }, | ||
}); | ||
|
||
return NextResponse.json({ putContinuationDay }, { status: 200 }); | ||
} catch (error) { | ||
return NextResponse.json( | ||
{ error: "Failed to update continuationDay", details: error }, | ||
{ status: 500 }, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { prisma } from "@lib/prisma"; | ||
import type { NextRequest } from "next/server"; | ||
|
||
// GETメソッドのハンドラ関数 | ||
export async function GET(req: NextRequest) { | ||
const { searchParams } = new URL(req.url || ""); | ||
const id = searchParams.get("id") || ""; | ||
const numId = Number(id) | ||
|
||
// prismaでユーザを取得 | ||
const exp = await prisma.experiencePoint.findFirst({ | ||
where: { userId: numId }, | ||
}); | ||
|
||
if (!exp) { | ||
return new Response(JSON.stringify({ message: "Not Found" }), { | ||
status: 404, | ||
headers: { "Content-Type": "application/json" }, | ||
}); | ||
} | ||
|
||
return new Response(JSON.stringify(exp), { | ||
status: 200, | ||
headers: { "Content-Type": "application/json" }, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { prisma } from "@lib/prisma"; | ||
import type { NextRequest } from "next/server"; | ||
import { NextResponse } from "next/server"; | ||
|
||
// similarityPointの更新 | ||
export async function PUT(req: NextRequest) { | ||
const { pathname } = new URL(req.url || ""); | ||
const id = Number(pathname.split("/").pop()); | ||
|
||
if (!id) { | ||
return NextResponse.json( | ||
{ error: "Invalid or missing ID" }, | ||
{ status: 400 }, | ||
); | ||
} | ||
|
||
try { | ||
const { similarity } = await req.json(); | ||
if (typeof similarity !== "number") { | ||
return NextResponse.json( | ||
{ error: "Invalid speed value" }, | ||
{ status: 400 }, | ||
); | ||
} | ||
|
||
const putSimilarity = await prisma.experiencePoint.update({ | ||
where: { id }, | ||
data: { similarityPoint: similarity }, | ||
}); | ||
|
||
return NextResponse.json({ putSimilarity }, { status: 200 }); | ||
} catch (error) { | ||
return NextResponse.json( | ||
{ error: "Failed to update similarityPoint", details: error }, | ||
{ status: 500 }, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { prisma } from "@lib/prisma"; | ||
import type { NextRequest } from "next/server"; | ||
import { NextResponse } from "next/server"; | ||
|
||
// speedPointの更新 | ||
export async function PUT(req: NextRequest) { | ||
const { pathname } = new URL(req.url || ""); | ||
const id = Number(pathname.split("/").pop()); | ||
|
||
if (!id) { | ||
return NextResponse.json( | ||
{ error: "Invalid or missing ID" }, | ||
{ status: 400 }, | ||
); | ||
} | ||
|
||
try { | ||
const { speed } = await req.json(); | ||
if (typeof speed !== "number") { | ||
return NextResponse.json( | ||
{ error: "Invalid speed value" }, | ||
{ status: 400 }, | ||
); | ||
} | ||
|
||
const putSpeed = await prisma.experiencePoint.update({ | ||
where: { id }, | ||
data: { speedPoint: speed }, | ||
}); | ||
|
||
return NextResponse.json({ putSpeed }, { status: 200 }); | ||
} catch (error) { | ||
return NextResponse.json( | ||
{ error: "Failed to update speedPoint", details: error }, | ||
{ status: 500 }, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { prisma } from "@lib/prisma"; | ||
import type { NextRequest } from "next/server"; | ||
import { NextResponse } from "next/server"; | ||
|
||
// totalPointの更新 | ||
export async function PUT(req: NextRequest) { | ||
const { pathname } = new URL(req.url || ""); | ||
const id = Number(pathname.split("/").pop()); | ||
|
||
if (!id) { | ||
return NextResponse.json( | ||
{ error: "Invalid or missing ID" }, | ||
{ status: 400 }, | ||
); | ||
} | ||
|
||
try { | ||
const { total } = await req.json(); | ||
if (typeof total !== "number") { | ||
return NextResponse.json( | ||
{ error: "Invalid speed value" }, | ||
{ status: 400 }, | ||
); | ||
} | ||
|
||
const putTotal = await prisma.experiencePoint.update({ | ||
where: { id }, | ||
data: { totalPoint: total }, | ||
}); | ||
|
||
return NextResponse.json({ putTotal }, { status: 200 }); | ||
} catch (error) { | ||
return NextResponse.json( | ||
{ error: "Failed to update totalPoint", details: error }, | ||
{ status: 500 }, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.