src/userInteraction/user-interaction.controller.ts
user-interaction
Methods |
|
| Async create | ||||||||
create(createUserInteractionDto: CreateUserInteractionDto)
|
||||||||
Decorators :
@Post()
|
||||||||
|
Creates a new user interaction.
Parameters :
Returns :
unknown
The created user interaction. |
| Async findByCriteria | ||||||||||||||||
findByCriteria(projectId?: string, userId?: string, interactionType?: InteractionType)
|
||||||||||||||||
Decorators :
@Get()
|
||||||||||||||||
|
Retrieves user interactions based on optional criteria.
Parameters :
Returns :
unknown
The list of user interactions matching the criteria. |
import {
Controller,
Post,
Get,
Body,
Query,
BadRequestException,
} from "@nestjs/common";
import { UserInteractionService } from "./user-interaction.service";
import { CreateUserInteractionDto } from "./dto/create-user-interaction.dto";
import { InteractionType } from "./entities/user-interaction.entity";
@Controller("user-interaction")
export class UserInteractionController {
constructor(
private readonly userInteractionService: UserInteractionService,
) {}
/**
* Creates a new user interaction.
*
* @param {CreateUserInteractionDto} createUserInteractionDto - The DTO containing the data for the new user interaction.
* @returns {Promise<any>} The created user interaction.
*/
@Post()
async create(@Body() createUserInteractionDto: CreateUserInteractionDto) {
const { userId, projectId } = createUserInteractionDto;
if (!userId && !projectId) {
throw new BadRequestException(
"Either userId or projectId must be present",
);
}
return this.userInteractionService.create(createUserInteractionDto);
}
/**
* Retrieves user interactions based on optional criteria.
*
* @param {string} [projectId] - The ID of the project.
* @param {string} [userId] - The ID of the user.
* @param {InteractionType} [interactionType] - The type of interaction.
* @returns {Promise<any[]>} The list of user interactions matching the criteria.
*/
@Get()
async findByCriteria(
@Query("projectId") projectId?: string,
@Query("userId") userId?: string,
@Query("interactionType") interactionType?: InteractionType,
) {
return this.userInteractionService.findByCriteria(
projectId,
userId,
interactionType,
);
}
}