import { Injectable } from '@nestjs/common'; import { randomUUID } from 'crypto'; import { getStore } from '../common/store'; export interface Feedback { id: string; openid: string; content: string; contact?: string; createdAt: string; } @Injectable() export class FeedbackService { private store = getStore('feedback'); submit(openid: string, content: string, contact?: string): Feedback { return this.store.insert({ id: randomUUID(), openid, content, contact: contact || undefined, createdAt: new Date().toISOString(), }); } // 管理员视角:按时间倒序返回全部留言 list(): Feedback[] { return this.store .all() .sort((a, b) => (a.createdAt < b.createdAt ? 1 : -1)); } }