refactor: standardize quotation marks across all files and improve code consistency
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { prisma } from "@/lib/prisma"
|
||||
import type { Category } from "@/lib/types"
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import type { Category } from "@/lib/types";
|
||||
|
||||
export const categoryService = {
|
||||
async create(data: Omit<Category, "id">): Promise<Category> {
|
||||
@@ -11,7 +11,7 @@ export const categoryService = {
|
||||
keywords: JSON.stringify(data.keywords),
|
||||
parentId: data.parentId,
|
||||
},
|
||||
})
|
||||
});
|
||||
|
||||
return {
|
||||
id: created.id,
|
||||
@@ -20,10 +20,13 @@ export const categoryService = {
|
||||
icon: created.icon,
|
||||
keywords: JSON.parse(created.keywords) as string[],
|
||||
parentId: created.parentId,
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
async update(id: string, data: Partial<Omit<Category, "id">>): Promise<Category> {
|
||||
async update(
|
||||
id: string,
|
||||
data: Partial<Omit<Category, "id">>,
|
||||
): Promise<Category> {
|
||||
const updated = await prisma.category.update({
|
||||
where: { id },
|
||||
data: {
|
||||
@@ -33,7 +36,7 @@ export const categoryService = {
|
||||
keywords: data.keywords ? JSON.stringify(data.keywords) : undefined,
|
||||
parentId: data.parentId,
|
||||
},
|
||||
})
|
||||
});
|
||||
|
||||
return {
|
||||
id: updated.id,
|
||||
@@ -42,7 +45,7 @@ export const categoryService = {
|
||||
icon: updated.icon,
|
||||
keywords: JSON.parse(updated.keywords) as string[],
|
||||
parentId: updated.parentId,
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
async delete(id: string): Promise<void> {
|
||||
@@ -50,11 +53,10 @@ export const categoryService = {
|
||||
await prisma.transaction.updateMany({
|
||||
where: { categoryId: id },
|
||||
data: { categoryId: null },
|
||||
})
|
||||
});
|
||||
|
||||
await prisma.category.delete({
|
||||
where: { id },
|
||||
})
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user