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 { funGetUserByCookies, funGetUserById } from "@/module/auth";
|
||||
import { createLogUser, createLogUserMobile } from "@/module/user";
|
||||
import { funGetUserById } from "@/module/auth";
|
||||
import { createLogUserMobile } from "@/module/user";
|
||||
import _ from "lodash";
|
||||
import moment from "moment";
|
||||
import "moment/locale/id";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
|
||||
@@ -279,9 +280,9 @@ export async function POST(request: Request) {
|
||||
|
||||
const nameFile = await prisma.divisionDocumentFolderFile.count({
|
||||
where: {
|
||||
name,
|
||||
idDivision,
|
||||
path,
|
||||
name: String(name),
|
||||
idDivision: String(idDivision),
|
||||
path: String(path),
|
||||
extension: "folder",
|
||||
category: "FOLDER",
|
||||
isActive: true
|
||||
@@ -295,12 +296,12 @@ export async function POST(request: Request) {
|
||||
|
||||
const data = await prisma.divisionDocumentFolderFile.create({
|
||||
data: {
|
||||
name,
|
||||
path,
|
||||
idDivision,
|
||||
name: String(name),
|
||||
path: String(path),
|
||||
idDivision: String(idDivision),
|
||||
category: "FOLDER",
|
||||
extension: "folder",
|
||||
createdBy: user.id,
|
||||
createdBy: userMobile.id,
|
||||
},
|
||||
select: {
|
||||
id: true
|
||||
@@ -382,7 +383,12 @@ export async function PUT(request: Request) {
|
||||
// DELETE ITEM
|
||||
export async function DELETE(request: Request) {
|
||||
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++) {
|
||||
const id = data[i].id;
|
||||
@@ -397,7 +403,7 @@ export async function DELETE(request: Request) {
|
||||
}
|
||||
|
||||
// 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 });
|
||||
|
||||
Reference in New Issue
Block a user