feat: add set status membership endpoint
This commit is contained in:
parent
cab057f683
commit
3835b0ee35
|
@ -191,6 +191,18 @@ export class UsersController {
|
|||
};
|
||||
}
|
||||
|
||||
@Get(':id/:type')
|
||||
async setStatusMembership(
|
||||
@Param('id', ParseUUIDPipe) id: string,
|
||||
@Param('type') type: string,
|
||||
) {
|
||||
return {
|
||||
data: await this.usersService.setStatus(id, type),
|
||||
statusCode: HttpStatus.CREATED,
|
||||
message: 'success',
|
||||
};
|
||||
}
|
||||
|
||||
@Put(':id')
|
||||
async update(
|
||||
@Param('id', ParseUUIDPipe) id: string,
|
||||
|
|
|
@ -261,6 +261,22 @@ export class UsersService {
|
|||
return userData;
|
||||
}
|
||||
|
||||
setStatus = async (id: string, type: string) => {
|
||||
const userData = new User();
|
||||
|
||||
if (type === 'active') {
|
||||
userData.isActive = true;
|
||||
} else {
|
||||
userData.isActive = false;
|
||||
}
|
||||
|
||||
await this.connection.transaction(async (manager) => {
|
||||
await manager.update(User, { id: id }, userData);
|
||||
});
|
||||
|
||||
return userData;
|
||||
};
|
||||
|
||||
async remove(id: string) {
|
||||
try {
|
||||
await this.usersRepository.findOneOrFail(id);
|
||||
|
|
Loading…
Reference in New Issue
Block a user