-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2ca7a0a
commit 27d78cc
Showing
4 changed files
with
65 additions
and
4 deletions.
There are no files selected for viewing
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,48 @@ | ||
import { BusinessCode, responseHandler } from "@/lib/fetch_utils"; | ||
import prisma from "@/lib/pg"; | ||
import { getServerSession } from "next-auth"; | ||
import { authOptions } from "@/lib/auth_options"; | ||
import { z } from "zod"; | ||
import { NextRequest, NextResponse } from "next/server"; | ||
import { getToken } from "next-auth/jwt"; | ||
|
||
export const dynamic = "force-dynamic"; | ||
|
||
const postDetailSchema = z.object({ | ||
blog_key: z.string(), | ||
// 其他字段的验证规则,如果有的话 | ||
}); | ||
|
||
export async function GET(request: NextRequest) { | ||
const key = new URL(request.url).searchParams.get("key"); | ||
if (!key) { | ||
return responseHandler( | ||
null, | ||
BusinessCode.normal, | ||
BusinessCode.abnormal, | ||
"无 key" | ||
); | ||
} | ||
try { | ||
const res = await prisma.post.findUnique({ | ||
where: { blog_key: key }, | ||
}); | ||
if (!res) { | ||
return responseHandler( | ||
null, | ||
BusinessCode.normal, | ||
BusinessCode.abnormal, | ||
"key 值错误" | ||
); | ||
} | ||
return responseHandler(res); | ||
} catch (error: any) { | ||
console.error("GET 请求错误:", error); | ||
return responseHandler( | ||
null, | ||
BusinessCode.normal, | ||
BusinessCode.abnormal, | ||
"未知异常" | ||
); | ||
} | ||
} |
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,9 @@ | ||
import MainLayout from "@/Layouts/MainLayout"; | ||
import ArticleList from "@/components/Article/ArticleList"; | ||
export default function MyPraise() { | ||
return ( | ||
<MainLayout> | ||
<ArticleList posts={[]}></ArticleList> | ||
</MainLayout> | ||
); | ||
} |
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
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