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
|
||||||
|
|
||||||
|
/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 (
|
return (
|
||||||
<div className="bg-white relative min-h-screen w-full">
|
<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">
|
<div className="content-stretch flex gap-[99px] items-center relative shrink-0">
|
||||||
{/* 로고 */}
|
{/* 로고 */}
|
||||||
<button
|
<button
|
||||||
onClick={() => router.push('/')}
|
onClick={() => router.push('/')}
|
||||||
className="h-[74px] relative shrink-0 w-[72px] cursor-pointer"
|
className="h-[74px] relative shrink-0 w-[72px] cursor-pointer"
|
||||||
>
|
>
|
||||||
<div className="absolute inset-0 overflow-hidden pointer-events-none">
|
<Image
|
||||||
<img alt="" className="absolute h-[291.74%] left-[-100%] max-w-none top-[-95.73%] w-[301.18%]" src={imgImage2} />
|
src={logo}
|
||||||
</div>
|
alt="로고"
|
||||||
|
className="w-full h-full object-contain"
|
||||||
|
width={72}
|
||||||
|
height={74}
|
||||||
|
/>
|
||||||
</button>
|
</button>
|
||||||
{/* 메뉴 */}
|
{/* 메뉴 */}
|
||||||
<div className="content-stretch flex gap-[24px] items-center relative shrink-0">
|
<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">
|
<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>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</button>
|
||||||
<div className="content-stretch flex gap-[150px] items-center relative shrink-0">
|
<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">
|
<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>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</button>
|
||||||
<div className="content-stretch flex gap-[150px] items-center relative shrink-0">
|
<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">
|
<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>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/* 사용자 메뉴 */}
|
{/* 사용자 메뉴 */}
|
||||||
@@ -131,7 +147,7 @@ export default function HomePage() {
|
|||||||
</header>
|
</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]">
|
<div className="absolute bottom-0 left-0 right-0 top-[-1px]">
|
||||||
<img alt="" className="block max-w-none size-full" src={imgLine2} />
|
<img alt="" className="block max-w-none size-full" src={imgLine2} />
|
||||||
</div>
|
</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 { defineConfig, env } from "prisma/config";
|
||||||
|
import { config } from "dotenv";
|
||||||
|
config();
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
schema: "prisma/schema.prisma",
|
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