added Get api for some table
This commit is contained in:
parent
2c02ad8d06
commit
bc7b4cd272
@ -8,19 +8,19 @@ export class ConversationsController {
|
|||||||
constructor(private readonly conversationsService: ConversationsService) {}
|
constructor(private readonly conversationsService: ConversationsService) {}
|
||||||
|
|
||||||
@Post()
|
@Post()
|
||||||
create(@Body() createConversationDto: CreateConversationDto) {
|
async create(@Body() createConversationDto: CreateConversationDto) {
|
||||||
return this.conversationsService.create(createConversationDto);
|
return await this.conversationsService.create(createConversationDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
findAll() {
|
async findAll() {
|
||||||
return this.conversationsService.findAll();
|
return await this.conversationsService.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get(':id')
|
// @Get(':id')
|
||||||
findOne(@Param('id') id: string) {
|
// findOne(@Param('id') id: string) {
|
||||||
return this.conversationsService.findOne(+id);
|
// return this.conversationsService.findOne(+id);
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Patch(':id')
|
@Patch(':id')
|
||||||
update(@Param('id') id: string, @Body() updateConversationDto: UpdateConversationDto) {
|
update(@Param('id') id: string, @Body() updateConversationDto: UpdateConversationDto) {
|
||||||
|
|||||||
@ -16,8 +16,8 @@ export class ConversationsService {
|
|||||||
return await this.conversationModel.create(createConversationDto)
|
return await this.conversationModel.create(createConversationDto)
|
||||||
}
|
}
|
||||||
|
|
||||||
findAll() {
|
async findAll():Promise<ConversationDocument[]> {
|
||||||
return `This action returns all conversations`;
|
return await this.conversationModel.find().exec()
|
||||||
}
|
}
|
||||||
|
|
||||||
async findP2p(senderId:string, targetUserId:string){
|
async findP2p(senderId:string, targetUserId:string){
|
||||||
@ -27,9 +27,9 @@ export class ConversationsService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
findOne(id: number) {
|
// findOne(id: number) {
|
||||||
return `This action returns a #${id} conversation`;
|
// return `This action returns a #${id} conversation`;
|
||||||
}
|
// }
|
||||||
|
|
||||||
update(id: number, updateConversationDto: UpdateConversationDto) {
|
update(id: number, updateConversationDto: UpdateConversationDto) {
|
||||||
return `This action updates a #${id} conversation`;
|
return `This action updates a #${id} conversation`;
|
||||||
|
|||||||
@ -2,24 +2,22 @@ import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/commo
|
|||||||
import { UsersService } from './users.service';
|
import { UsersService } from './users.service';
|
||||||
import { CreateUserDto } from './dto/create-user.dto';
|
import { CreateUserDto } from './dto/create-user.dto';
|
||||||
import { UpdateUserDto } from './dto/update-user.dto';
|
import { UpdateUserDto } from './dto/update-user.dto';
|
||||||
|
import { ApiOperation } from '@nestjs/swagger';
|
||||||
|
|
||||||
@Controller('users')
|
@Controller('users')
|
||||||
export class UsersController {
|
export class UsersController {
|
||||||
constructor(private readonly usersService: UsersService) {}
|
constructor(private readonly usersService: UsersService) {}
|
||||||
|
|
||||||
// @Post()
|
@ApiOperation({ summary: 'Get all users' })
|
||||||
// create(@Body() createUserDto: CreateUserDto) {
|
|
||||||
// return this.usersService.create(createUserDto);
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
findAll() {
|
async findAll() {
|
||||||
return this.usersService.findAll();
|
return await this.usersService.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation({ summary: 'Get a user by id' })
|
||||||
@Get(':id')
|
@Get(':id')
|
||||||
findOne(@Param('id') id: string) {
|
async findOne(@Param('id') id: string) {
|
||||||
return this.usersService.findOne(id);
|
return await this.usersService.findById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Patch(':id')
|
// @Patch(':id')
|
||||||
|
|||||||
@ -15,10 +15,15 @@ export class UsersService {
|
|||||||
return await this.userModel.create(createUserDto)
|
return await this.userModel.create(createUserDto)
|
||||||
}
|
}
|
||||||
|
|
||||||
findAll() {
|
async findAll():Promise<UserDocument[]> {
|
||||||
return `This action returns all users`;
|
return await this.userModel.find().exec()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async findById(id:string):Promise<UserDocument | null>{
|
||||||
|
return await this.userModel.findById(id).exec()
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE:this is used in another module
|
||||||
async findOne(name: string):Promise<UserDocument | null> {
|
async findOne(name: string):Promise<UserDocument | null> {
|
||||||
return await this.userModel.findOne({name}).exec()
|
return await this.userModel.findOne({name}).exec()
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user