diff --git a/src/api/one/scheme/tip/delete-tip.action/function.ts b/src/api/one/scheme/tip/delete-tip.action/function.ts index cb147b4d..bdfb4e95 100644 --- a/src/api/one/scheme/tip/delete-tip.action/function.ts +++ b/src/api/one/scheme/tip/delete-tip.action/function.ts @@ -20,11 +20,7 @@ const func: OneApiFunc = async (data) => { return oneApiResponse(OneApiError.FORBIDDEN) } - await prisma.tip.update({ - where: { id: tipId }, - data: { isRemoved: true }, - }) - + Tip.delete(tipId) return oneApiResponse({ isRemoved: true }) } diff --git a/src/database/models/tip.ts b/src/database/models/tip.ts index 5d7cefa3..5b7fc85a 100644 --- a/src/database/models/tip.ts +++ b/src/database/models/tip.ts @@ -159,6 +159,14 @@ export class Tip extends Model { }) return true } + + static async delete(tipId: number): Promise { + await prisma.tip.update({ + where: { id: tipId }, + data: { isRemoved: true }, + }) + return true + } } export const getTip = createInitModelFunction(Tip, 'tip', { diff --git a/src/database/repository/tip-repository.ts b/src/database/repository/tip-repository.ts index 266a1f44..62ecf44f 100644 --- a/src/database/repository/tip-repository.ts +++ b/src/database/repository/tip-repository.ts @@ -1,6 +1,5 @@ -import { Tip, TipAttrs } from '../models/tip' - import Time from '@/modules/time' +import { TipAttrs } from '../models/tip' import { TipTopic } from '@prisma/client' import prisma from '@/modules/prisma'