# All files / modules/feedback feedback.service.ts

0% Statements 0/19
0% Branches 0/1
0% Functions 0/1
0% Lines 0/19

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40

     import { PrismaClient } from '@prisma/client';
    import { v4 as uuidv4 } from 'uuid';

    const prisma = new PrismaClient();

    export interface FeedbackInput {
      type: 'suggestion' | 'bug' | 'other';
      title: string;
      content: string;
      contact?: string;
      screenshotUrls?: string[];
    }

    export interface FeedbackResult {
      id: string;
      status: 'submitted';
    }

    export const feedbackService = {
      /**
       * 提交反馈
       */
      async submitFeedback(input: FeedbackInput): Promise<FeedbackResult> {
        const id = uuidv4();

        await prisma.feedback.create({
          data: {
            id,
            type: input.type,
            title: input.title,
            content: input.content,
            contact: input.contact || '',
            screenshotUrls: JSON.stringify(input.screenshotUrls || []),
            status: 'submitted',
          },
        });

        return { id, status: 'submitted' };
      },
    };