Merge pull request #455 from bipproduction/amalia/30-mei-25
upd: api mobile
This commit is contained in:
@@ -1,8 +1,9 @@
|
|||||||
import { prisma } from "@/module/_global";
|
import { prisma } from "@/module/_global";
|
||||||
import { funGetUserByCookies, funGetUserById } from "@/module/auth";
|
import { funGetUserById } from "@/module/auth";
|
||||||
import { createLogUser, createLogUserMobile } from "@/module/user";
|
import { createLogUserMobile } from "@/module/user";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
|
import "moment/locale/id";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
|
|
||||||
@@ -279,9 +280,9 @@ export async function POST(request: Request) {
|
|||||||
|
|
||||||
const nameFile = await prisma.divisionDocumentFolderFile.count({
|
const nameFile = await prisma.divisionDocumentFolderFile.count({
|
||||||
where: {
|
where: {
|
||||||
name,
|
name: String(name),
|
||||||
idDivision,
|
idDivision: String(idDivision),
|
||||||
path,
|
path: String(path),
|
||||||
extension: "folder",
|
extension: "folder",
|
||||||
category: "FOLDER",
|
category: "FOLDER",
|
||||||
isActive: true
|
isActive: true
|
||||||
@@ -295,12 +296,12 @@ export async function POST(request: Request) {
|
|||||||
|
|
||||||
const data = await prisma.divisionDocumentFolderFile.create({
|
const data = await prisma.divisionDocumentFolderFile.create({
|
||||||
data: {
|
data: {
|
||||||
name,
|
name: String(name),
|
||||||
path,
|
path: String(path),
|
||||||
idDivision,
|
idDivision: String(idDivision),
|
||||||
category: "FOLDER",
|
category: "FOLDER",
|
||||||
extension: "folder",
|
extension: "folder",
|
||||||
createdBy: user.id,
|
createdBy: userMobile.id,
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
id: true
|
id: true
|
||||||
@@ -382,7 +383,12 @@ export async function PUT(request: Request) {
|
|||||||
// DELETE ITEM
|
// DELETE ITEM
|
||||||
export async function DELETE(request: Request) {
|
export async function DELETE(request: Request) {
|
||||||
try {
|
try {
|
||||||
const data = await request.json()
|
const { data, user } = await request.json()
|
||||||
|
|
||||||
|
const userMobile = await funGetUserById({ id: String(user) })
|
||||||
|
if (userMobile.id == "null" || userMobile.id == undefined || userMobile.id == "") {
|
||||||
|
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 200 });
|
||||||
|
}
|
||||||
|
|
||||||
for (let i = 0; i < data.length; i++) {
|
for (let i = 0; i < data.length; i++) {
|
||||||
const id = data[i].id;
|
const id = data[i].id;
|
||||||
@@ -397,7 +403,7 @@ export async function DELETE(request: Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create log user
|
// create log user
|
||||||
// const log = await createLogUserMobile({ act: 'DELETE', desc: 'User menghapus file atau folder', table: 'divisionDocumentFolderFile', data: '', user: userMobile.id })
|
const log = await createLogUserMobile({ act: 'DELETE', desc: 'User menghapus file atau folder', table: 'divisionDocumentFolderFile', data: '', user: userMobile.id })
|
||||||
|
|
||||||
|
|
||||||
return NextResponse.json({ success: true, message: "Berhasil menghapus item" }, { status: 200 });
|
return NextResponse.json({ success: true, message: "Berhasil menghapus item" }, { status: 200 });
|
||||||
|
|||||||
Reference in New Issue
Block a user