Merge pull request #70 from bipproduction/amalia/29-jul-24

Amalia/29 jul 24
This commit is contained in:
Amalia
2024-07-29 12:29:47 +08:00
committed by GitHub
13 changed files with 60 additions and 58 deletions

View File

@@ -280,28 +280,30 @@ model DivisionProjectFile {
}
model DivisionDisscussion {
id String @id @default(cuid())
Division Division @relation(fields: [idDivision], references: [id])
idDivision String
title String
desc String @db.Text
status Int @default(1) // 1 = open, 2 = close
isActive Boolean @default(true)
User User @relation(fields: [createdBy], references: [id])
createdBy String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
id String @id @default(cuid())
Division Division @relation(fields: [idDivision], references: [id])
idDivision String
title String
desc String @db.Text
status Int @default(1) // 1 = open, 2 = close
isActive Boolean @default(true)
User User @relation(fields: [createdBy], references: [id])
createdBy String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
DivisionDisscussionComment DivisionDisscussionComment[]
}
model DivisionDisscussionComment {
id String @id @default(cuid())
idDisscussion String
comment String @db.Text
isActive Boolean @default(true)
User User @relation(fields: [createdBy], references: [id])
createdBy String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
id String @id @default(cuid())
DivisionDisscussion DivisionDisscussion @relation(fields: [idDisscussion], references: [id])
idDisscussion String
comment String @db.Text
isActive Boolean @default(true)
User User @relation(fields: [createdBy], references: [id])
createdBy String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model DivisionDocumentFolderFile {

View File

@@ -3,12 +3,12 @@ import { API_INDEX_GROUP } from "./api_index";
type Method = "GET" | "POST";
export async function apiGroup(req: NextRequest, method: Method) {
const { searchParams } = new URL(req.url);
const path = searchParams.get("path");
const act = API_INDEX_GROUP.find((v) => v.path === path && v.method === method);
if (!path)
return Response.json({ message: "page not found" }, { status: 404 });
const { searchParams } = new URL(req.url);
const path = searchParams.get("path");
const act = API_INDEX_GROUP.find((v) => v.path === path && v.method === method);
if (!path)
return Response.json({ success: false, message: "page not found" }, { status: 404 });
if (act) return act.bin(req);
return Response.json({ message: "404" });
}
return Response.json({ success: false, message: "404" });
}

View File

@@ -2,7 +2,7 @@ import { prisma } from "@/module/_global";
import { NextRequest } from "next/server";
export async function listGroups(req: NextRequest): Promise<Response> {
try {
const searchParams = req.nextUrl.searchParams
const villaId = searchParams.get('villageId');
@@ -20,6 +20,6 @@ export async function listGroups(req: NextRequest): Promise<Response> {
return Response.json(groups);
} catch (error) {
console.error(error);
return Response.json({ message: "Internal Server Error" }, { status: 500 });
return Response.json({ success: false, message: "Internal Server Error" }, { status: 500 });
}
}

View File

@@ -1,13 +1,13 @@
import { prisma } from "@/module/_global";
export async function createGroup(req: Request){
export async function createGroup(req: Request) {
try {
const data = await req.json();
const data = await req.json();
if (!data || !data.name) {
return Response.json(
{ message: "Nama grup harus diisi" },
{ success: false, message: "Nama grup harus diisi" },
{ status: 400 }
);
}
@@ -27,6 +27,6 @@ export async function createGroup(req: Request){
return Response.json(group, { status: 201 });
} catch (error) {
console.error(error);
return Response.json({ message: "Internal Server Error" }, { status: 500 });
return Response.json({ success: false, message: "Internal Server Error" }, { status: 500 });
}
}

View File

@@ -4,12 +4,12 @@ import { API_INDEX_POSITION } from "./api_index";
type Method = "GET" | "POST";
export async function apiPosition(req: NextRequest, method: Method) {
const { searchParams } = new URL(req.url);
const path = searchParams.get("path");
const act = API_INDEX_POSITION.find((v) => v.path === path && v.method === method);
if (!path)
return Response.json({ message: "page not found" }, { status: 404 });
const { searchParams } = new URL(req.url);
const path = searchParams.get("path");
const act = API_INDEX_POSITION.find((v) => v.path === path && v.method === method);
if (!path)
return Response.json({ success: false, message: "page not found" }, { status: 404 });
if (act) return act.bin(req);
return Response.json({ message: "404" });
}
return Response.json({ success: false, message: "404" });
}

View File

@@ -19,6 +19,6 @@ export async function getAllPosition(req: NextRequest) {
return Response.json(positions);
} catch (error) {
console.error(error);
return Response.json({ message: "Internal Server Error" }, { status: 500 });
return Response.json({ success: false, message: "Internal Server Error" }, { status: 500 });
}
}

View File

@@ -19,6 +19,6 @@ export async function createlPosition(req: Request) {
return Response.json(positions, { status: 201 });
} catch (error) {
console.error(error);
return Response.json({ message: "Internal Server Error" }, { status: 500 });
return Response.json({ success: false, message: "Internal Server Error" }, { status: 500 });
}
}

View File

@@ -4,12 +4,12 @@ import { API_INDEX_USER } from "./api_index";
type Method = "GET" | "POST";
export async function apiUser(req: NextRequest, method: Method) {
const { searchParams } = new URL(req.url);
const path = searchParams.get("path");
const act = API_INDEX_USER.find((v) => v.path === path && v.method === method);
if (!path)
return Response.json({ message: "page not found" }, { status: 404 });
const { searchParams } = new URL(req.url);
const path = searchParams.get("path");
const act = API_INDEX_USER.find((v) => v.path === path && v.method === method);
if (!path)
return Response.json({ success: false, message: "page not found" }, { status: 404 });
if (act) return act.bin(req);
return Response.json({ message: "404" });
}
return Response.json({ success: false, message: "404" });
}

View File

@@ -31,6 +31,6 @@ export async function getAllUser(req: NextRequest) {
return Response.json(users);
} catch (error) {
console.error(error);
return Response.json({ message: "Internal Server Error" }, { status: 500 });
return Response.json({ success: false, message: "Internal Server Error" }, { status: 500 });
}
}

View File

@@ -30,6 +30,6 @@ export async function createUser(req: NextRequest) {
return Response.json(users, { status: 200 });
} catch (error) {
console.error(error);
return Response.json({ message: "Internal Server Error" }, { status: 500 });
return Response.json({ success: false, message: "Internal Server Error" }, { status: 500 });
}
}

View File

@@ -8,8 +8,8 @@ export async function apiViilage(req: Request, method: Method) {
(v) => v.path === path && v.method === method
);
if (!path)
return Response.json({ message: "page not found" }, { status: 404 });
return Response.json({ success: false, message: "page not found" }, { status: 404 });
if (act) return act.bin(req);
return Response.json({ message: "404" });
return Response.json({ success: false, message: "404" });
}

View File

@@ -16,6 +16,6 @@ export async function getAllVillage(req: Request) {
return Response.json(villages);
} catch (error) {
console.error(error);
return Response.json({ message: "Internal Server Error" }, { status: 500 });
return Response.json({ success: false, message: "Internal Server Error" }, { status: 500 });
}
}

View File

@@ -19,6 +19,6 @@ export async function createVillage(req: Request) {
return Response.json(village, { status: 201 });
} catch (error) {
console.error(error);
return Response.json({ message: "Internal Server Error" }, { status: 500 });
return Response.json({ success: false, message: "Internal Server Error" }, { status: 500 });
}
}