File

src/userInteraction/user-interaction.controller.ts

Prefix

user-interaction

Index

Methods

Methods

Async create
create(createUserInteractionDto: CreateUserInteractionDto)
Decorators :
@Post()

Creates a new user interaction.

Parameters :
Name Type Optional Description
createUserInteractionDto CreateUserInteractionDto No
  • The DTO containing the data for the new user interaction.
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 :
Name Type Optional Description
projectId string Yes
  • The ID of the project.
userId string Yes
  • The ID of the user.
interactionType InteractionType Yes
  • The type of interaction.
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,
    );
  }
}

results matching ""

    No results matching ""