4180eae944
新增完整反馈闭环: - 后端: Feedback 模块 (schema+service+controller+module) - POST /api/feedback (用户提交) - GET /api/feedback (管理员列表) - PATCH /api/feedback/:id/resolve (管理员标记已处理) - 前端: pages/feedback/feedback.vue - 三种反馈类型: 问题反馈/改进建议/点赞鼓励 - 文本输入 + 联系方式选填 - 提交后显示成功提示 - 用户页新增'意见反馈'菜单入口 - 管理后台可通过 API 查看和管理反馈
32 lines
1.2 KiB
TypeScript
32 lines
1.2 KiB
TypeScript
import { Controller, Post, Get, Patch, Param, Body, Query, UseGuards, HttpException, HttpStatus } from '@nestjs/common'
|
|
import { FeedbackService } from './feedback.service'
|
|
import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard'
|
|
import { AdminGuard } from '../../common/guards/admin.guard'
|
|
import { CurrentUser } from '../../common/decorators/current-user.decorator'
|
|
|
|
@Controller('feedback')
|
|
export class FeedbackController {
|
|
constructor(private service: FeedbackService) {}
|
|
|
|
@UseGuards(JwtAuthGuard)
|
|
@Post()
|
|
async create(@CurrentUser('userId') userId: string, @Body() body: { type?: string; content: string; contact?: string }) {
|
|
if (!body.content || body.content.length < 2) {
|
|
throw new HttpException('请填写反馈内容', HttpStatus.BAD_REQUEST)
|
|
}
|
|
return this.service.create({ userId, type: body.type || 'suggestion', content: body.content, contact: body.contact })
|
|
}
|
|
|
|
@UseGuards(JwtAuthGuard, AdminGuard)
|
|
@Get()
|
|
async list(@Query('page') page?: string, @Query('limit') limit?: string) {
|
|
return this.service.findAll(Number(page) || 1, Number(limit) || 20)
|
|
}
|
|
|
|
@UseGuards(JwtAuthGuard, AdminGuard)
|
|
@Patch(':id/resolve')
|
|
async resolve(@Param('id') id: string) {
|
|
return this.service.markResolved(id)
|
|
}
|
|
}
|