85 lines
1.7 KiB
TypeScript
85 lines
1.7 KiB
TypeScript
import {
|
|
Controller,
|
|
Get,
|
|
Post,
|
|
Body,
|
|
Put,
|
|
Param,
|
|
Delete,
|
|
ParseUUIDPipe,
|
|
HttpStatus,
|
|
Query,
|
|
} from '@nestjs/common';
|
|
import { RoleService } from './roles.service';
|
|
import { CommissionService } from './commission.service';
|
|
|
|
@Controller({
|
|
path: 'config',
|
|
version: '1',
|
|
})
|
|
export class ConfigurableController {
|
|
constructor(
|
|
private readonly roleService: RoleService,
|
|
private readonly commissionService: CommissionService,
|
|
) {}
|
|
|
|
@Get('/roles')
|
|
async findAll(@Query('page') page: number) {
|
|
const [data, count] = await this.roleService.findAllRoles(page);
|
|
|
|
return {
|
|
data,
|
|
count,
|
|
statusCode: HttpStatus.OK,
|
|
message: 'success',
|
|
};
|
|
}
|
|
|
|
@Get('/commission')
|
|
async findCommission(@Query('page') page: number) {
|
|
const [data, count] = await this.commissionService.findAllCommission(page);
|
|
|
|
return {
|
|
data,
|
|
count,
|
|
statusCode: HttpStatus.OK,
|
|
message: 'success',
|
|
};
|
|
}
|
|
|
|
@Get('/roles/for-membership')
|
|
async findAllForMembership(@Query('page') page: number) {
|
|
const [data, count] = await this.roleService.findAllRolesForCreateMember(
|
|
page,
|
|
);
|
|
|
|
return {
|
|
data,
|
|
count,
|
|
statusCode: HttpStatus.OK,
|
|
message: 'success',
|
|
};
|
|
}
|
|
|
|
@Get(':id')
|
|
async findOne(@Param('id', ParseUUIDPipe) id: string) {
|
|
return {
|
|
data: await this.roleService.findOne(id),
|
|
statusCode: HttpStatus.OK,
|
|
message: 'success',
|
|
};
|
|
}
|
|
|
|
@Put('/commission/:id')
|
|
async updateCommission(
|
|
@Param('id', ParseUUIDPipe) id: string,
|
|
@Body() request,
|
|
) {
|
|
return {
|
|
data: await this.commissionService.updateCommission(id, request),
|
|
statusCode: HttpStatus.OK,
|
|
message: 'success',
|
|
};
|
|
}
|
|
}
|