feat: 完整 MVP — 剁手小黑屋反冲动消费 Web App
- 数据层: Prisma 7 + SQLite (better-sqlite3 adapter), Item 模型 - API: POST/GET/PATCH /api/items, 商品 CRUD 与状态流转 - 关押表单: 图片拖拽上传 + Canvas 压缩, Base64 存储 - 首页看守所: 72h 倒计时 Hook, 省钱看板, 冷却/释放卡片交互 - PWA: manifest.ts, apple-icon, viewport 沉浸配置, iOS 引导组件 - 部署: Dockerfile 多阶段构建, docker-compose, Jenkinsfile CI/CD - 图标: 全套专属像素风锁头+购物车图标 (favicon/96/180/192/512/OG)
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
export async function GET() {
|
||||
const items = await prisma.item.findMany({
|
||||
orderBy: { createdAt: "desc" },
|
||||
});
|
||||
return NextResponse.json(items);
|
||||
}
|
||||
|
||||
export async function POST(request: Request) {
|
||||
const body = await request.json();
|
||||
const { name, price, link, image } = body;
|
||||
|
||||
if (!name || price == null || !link || !image) {
|
||||
return NextResponse.json({ error: "缺少必填字段" }, { status: 400 });
|
||||
}
|
||||
|
||||
const item = await prisma.item.create({
|
||||
data: { name, price: Number(price), link, image },
|
||||
});
|
||||
|
||||
return NextResponse.json(item, { status: 201 });
|
||||
}
|
||||
Reference in New Issue
Block a user