feat: health checkup CRUD apis #30
@@ -0,0 +1,2 @@
|
|||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "HealthCheckCategory" ALTER COLUMN "slug" DROP NOT NULL;
|
||||||
@@ -224,7 +224,7 @@ model NewsImage {
|
|||||||
model HealthCheckCategory {
|
model HealthCheckCategory {
|
||||||
id Int @id @default(autoincrement())
|
id Int @id @default(autoincrement())
|
||||||
name String @unique
|
name String @unique
|
||||||
slug String @unique
|
slug String? @unique
|
||||||
description String?
|
description String?
|
||||||
isActive Boolean @default(true)
|
isActive Boolean @default(true)
|
||||||
sortOrder Int @default(1000)
|
sortOrder Int @default(1000)
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ export const createCategory = async (req, res) => {
|
|||||||
const category = await prisma.healthCheckCategory.create({
|
const category = await prisma.healthCheckCategory.create({
|
||||||
data: {
|
data: {
|
||||||
name,
|
name,
|
||||||
slug,
|
slug: slug || null,
|
||||||
description,
|
description,
|
||||||
isActive: isActive ?? true,
|
isActive: isActive ?? true,
|
||||||
sortOrder: sortOrder ? Number(sortOrder) : 1000,
|
sortOrder: sortOrder ? Number(sortOrder) : 1000,
|
||||||
@@ -58,6 +58,8 @@ export const updateCategory = async (req, res) => {
|
|||||||
|
|
||||||
if (data.sortOrder !== undefined) data.sortOrder = Number(data.sortOrder);
|
if (data.sortOrder !== undefined) data.sortOrder = Number(data.sortOrder);
|
||||||
|
|
||||||
|
if (data.slug === "") data.slug = null;
|
||||||
|
|
||||||
const updatedCategory = await prisma.$transaction(async (tx) => {
|
const updatedCategory = await prisma.$transaction(async (tx) => {
|
||||||
const category = await tx.healthCheckCategory.update({
|
const category = await tx.healthCheckCategory.update({
|
||||||
where: { id: Number(id) },
|
where: { id: Number(id) },
|
||||||
|
|||||||
Reference in New Issue
Block a user