Initial commit: HealthCarePregnant project documentation and platform
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import { Controller, Post, Get, Body, Param } from '@nestjs/common';
|
||||
import { EmotionService } from './emotion.service';
|
||||
import { CreateEmotionDto, EmotionCheckin } from './emotion.types';
|
||||
import { RequireCaps } from '../../common/auth/capabilities.decorator';
|
||||
import { CurrentUser } from '../../common/auth/current-user.decorator';
|
||||
import { RequestUser } from '../../common/auth/request-user';
|
||||
|
||||
@Controller('emotions')
|
||||
export class EmotionController {
|
||||
constructor(private readonly service: EmotionService) {}
|
||||
|
||||
@Post()
|
||||
@RequireCaps('emotion:create')
|
||||
async create(
|
||||
@CurrentUser() user: RequestUser,
|
||||
@Body() dto: CreateEmotionDto,
|
||||
): Promise<EmotionCheckin> {
|
||||
// 强制关联为当前登录孕妇患者 ID
|
||||
const patientId = user.role === 'patient' ? user.id : dto.patientId;
|
||||
return this.service.create({
|
||||
...dto,
|
||||
patientId,
|
||||
});
|
||||
}
|
||||
|
||||
@Get('patient/:patientId')
|
||||
@RequireCaps('emotion:read')
|
||||
async getByPatient(@Param('patientId') patientId: string): Promise<EmotionCheckin[]> {
|
||||
return this.service.listByPatient(patientId);
|
||||
}
|
||||
|
||||
@Get()
|
||||
@RequireCaps('emotion:read')
|
||||
async getAll(): Promise<EmotionCheckin[]> {
|
||||
return this.service.listAll();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user