fix: order product

This commit is contained in:
ilham
2021-12-15 08:51:05 +07:00
parent e8bbc1e554
commit 53575f36d6
9 changed files with 125 additions and 54 deletions

View File

@@ -12,7 +12,7 @@ export class CommissionService {
private commissionRepository: Repository<CommissionSetting>,
) {}
findAllRoles(page) {
findAllCommission(page) {
return this.commissionRepository.findAndCount({
skip: page * 10,
take: 10,
@@ -22,6 +22,28 @@ export class CommissionService {
});
}
async findOne(role: string) {
try {
return await this.commissionRepository.findOneOrFail({
where: {
role: role,
},
});
} catch (e) {
if (e instanceof EntityNotFoundError) {
throw new HttpException(
{
statusCode: HttpStatus.NOT_FOUND,
error: 'Data not found',
},
HttpStatus.NOT_FOUND,
);
} else {
throw e;
}
}
}
async updateCommission(id: string, request) {
try {
await this.commissionRepository.findOneOrFail(id);

View File

@@ -37,7 +37,7 @@ export class ConfigurableController {
@Get('/commission')
async findCommission(@Query('page') page: number) {
const [data, count] = await this.commissionService.findAllRoles(page);
const [data, count] = await this.commissionService.findAllCommission(page);
return {
data,

View File

@@ -10,6 +10,6 @@ import { CommissionSetting } from './entities/commission_setting.entity';
imports: [TypeOrmModule.forFeature([Roles, CommissionSetting])],
controllers: [ConfigurableController],
providers: [RoleService, CommissionService],
exports: [RoleService],
exports: [RoleService, CommissionService],
})
export class ConfigurableModule {}