prisma 성공~
This commit is contained in:
6
.gitignore
vendored
6
.gitignore
vendored
@@ -47,3 +47,9 @@ next-env.d.ts
|
||||
/lib/generated/prisma
|
||||
|
||||
/lib/generated/prisma
|
||||
|
||||
/lib/generated/prisma
|
||||
|
||||
/lib/generated/prisma
|
||||
|
||||
/lib/generated/prisma
|
||||
|
||||
30
app/api/test/route.ts
Normal file
30
app/api/test/route.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { PrismaClient } from "@/lib/generated/prisma/client";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
export async function GET() {
|
||||
try {
|
||||
const tests = await prisma.test.findMany();
|
||||
return NextResponse.json(tests);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return NextResponse.json({ error: "Failed to fetch tests." }, { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
export async function POST(req: Request) {
|
||||
try {
|
||||
const body = await req.json();
|
||||
const { name } = body;
|
||||
if (!name) {
|
||||
return NextResponse.json({ error: "Name is required." }, { status: 400 });
|
||||
}
|
||||
const test = await prisma.test.create({
|
||||
data: { name },
|
||||
});
|
||||
return NextResponse.json(test, { status: 201 });
|
||||
} catch (error) {
|
||||
return NextResponse.json({ error: "Failed to create test." }, { status: 500 });
|
||||
}
|
||||
}
|
||||
44
app/page.tsx
44
app/page.tsx
@@ -69,40 +69,56 @@ export default function HomePage() {
|
||||
return (
|
||||
<div className="bg-white relative min-h-screen w-full">
|
||||
{/* 헤더 */}
|
||||
<header className="absolute content-stretch flex items-center justify-between left-[calc(12.5%+91.375px)] top-[43px] w-[1332px]">
|
||||
<header className="absolute content-stretch flex items-center justify-between left-[332px] top-[43px] w-[1332px]">
|
||||
<div className="content-stretch flex gap-[99px] items-center relative shrink-0">
|
||||
{/* 로고 */}
|
||||
<button
|
||||
onClick={() => router.push('/')}
|
||||
className="h-[74px] relative shrink-0 w-[72px] cursor-pointer"
|
||||
>
|
||||
<div className="absolute inset-0 overflow-hidden pointer-events-none">
|
||||
<img alt="" className="absolute h-[291.74%] left-[-100%] max-w-none top-[-95.73%] w-[301.18%]" src={imgImage2} />
|
||||
</div>
|
||||
<Image
|
||||
src={logo}
|
||||
alt="로고"
|
||||
className="w-full h-full object-contain"
|
||||
width={72}
|
||||
height={74}
|
||||
/>
|
||||
</button>
|
||||
{/* 메뉴 */}
|
||||
<div className="content-stretch flex gap-[24px] items-center relative shrink-0">
|
||||
<div className="content-stretch flex gap-[150px] items-center relative shrink-0">
|
||||
<button
|
||||
onClick={() => router.push('/lecturelist')}
|
||||
className="content-stretch flex gap-[150px] items-center relative shrink-0 cursor-pointer group transition-colors"
|
||||
>
|
||||
<div className="box-border content-stretch flex gap-[10px] items-center justify-center p-[10px] relative shrink-0">
|
||||
<p className="font-bold leading-[normal] not-italic relative shrink-0 text-[#515151] text-[24px] text-nowrap whitespace-pre">
|
||||
<p className="font-bold leading-[normal] not-italic relative shrink-0 text-[#515151] text-[24px] text-nowrap whitespace-pre group-hover:text-blue-500 transition-colors">
|
||||
교육 과정 목록
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="content-stretch flex gap-[150px] items-center relative shrink-0">
|
||||
</button>
|
||||
<button
|
||||
onClick={() => router.push('/studydata')}
|
||||
className="content-stretch flex gap-[150px] items-center relative shrink-0 cursor-pointer group transition-colors"
|
||||
>
|
||||
<div className="box-border content-stretch flex gap-[10px] items-center justify-center p-[10px] relative shrink-0">
|
||||
<p className="font-bold leading-[normal] not-italic relative shrink-0 text-[#515151] text-[24px] text-nowrap whitespace-pre">
|
||||
<p className="font-bold leading-[normal] not-italic relative shrink-0 text-[#515151] text-[24px] text-nowrap whitespace-pre group-hover:text-blue-500 transition-colors">
|
||||
학습 자료실
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="content-stretch flex gap-[150px] items-center relative shrink-0">
|
||||
</button>
|
||||
<button
|
||||
onClick={() => {
|
||||
// 공지사항 섹션으로 스크롤
|
||||
window.scrollTo({ top: 1213, behavior: 'smooth' });
|
||||
}}
|
||||
className="content-stretch flex gap-[150px] items-center relative shrink-0 cursor-pointer group transition-colors"
|
||||
>
|
||||
<div className="box-border content-stretch flex gap-[10px] items-center justify-center p-[10px] relative shrink-0">
|
||||
<p className="font-bold leading-[normal] not-italic relative shrink-0 text-[#515151] text-[24px] text-nowrap whitespace-pre">
|
||||
<p className="font-bold leading-[normal] not-italic relative shrink-0 text-[#515151] text-[24px] text-nowrap whitespace-pre group-hover:text-blue-500 transition-colors">
|
||||
공지사항
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{/* 사용자 메뉴 */}
|
||||
@@ -131,7 +147,7 @@ export default function HomePage() {
|
||||
</header>
|
||||
|
||||
{/* 구분선 */}
|
||||
<div className="absolute h-0 left-[calc(50%+0.5px)] top-[150px] translate-x-[-50%] w-full">
|
||||
<div className="absolute h-0 left-1/2 top-[150px] translate-x-[-50%] w-[1920px]">
|
||||
<div className="absolute bottom-0 left-0 right-0 top-[-1px]">
|
||||
<img alt="" className="block max-w-none size-full" src={imgLine2} />
|
||||
</div>
|
||||
|
||||
0
app/studydata/page.tsx
Normal file
0
app/studydata/page.tsx
Normal file
@@ -1,4 +1,6 @@
|
||||
import { defineConfig, env } from "prisma/config";
|
||||
import { config } from "dotenv";
|
||||
config();
|
||||
|
||||
export default defineConfig({
|
||||
schema: "prisma/schema.prisma",
|
||||
|
||||
22
prisma/schema.prisma
Normal file
22
prisma/schema.prisma
Normal file
@@ -0,0 +1,22 @@
|
||||
// This is your Prisma schema file,
|
||||
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
||||
|
||||
// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
|
||||
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client"
|
||||
output = "../lib/generated/prisma"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
model Test {
|
||||
id String @id @default(uuid())
|
||||
name String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
Reference in New Issue
Block a user