- Introduced Jurisdiction and RuleCategory entities along with their respective values. - Implemented service methods for managing rule categories and values. - Updated MasterDataService to include seeding logic for jurisdictions and rule categories. - Added DTOs for creating and updating rule categories and values. feat(policy-engine): enhance policy management with new entities and operations - Created Policy, PolicyRule, PolicyAction, PolicyTargetAudience, and RuleCondition entities. - Implemented create, update, and delete operations for policies and their associated rules and actions. - Added enums for PolicyStatus and AudienceType to manage policy states and target audiences. - Developed DTOs for creating and updating policies with nested structures for rules and audiences.
67 lines
1.5 KiB
TypeScript
67 lines
1.5 KiB
TypeScript
import {
|
|
Controller,
|
|
Get,
|
|
Post,
|
|
Put,
|
|
Delete,
|
|
Patch,
|
|
Body,
|
|
Param,
|
|
Query,
|
|
} from '@nestjs/common';
|
|
import { PolicyEngineService } from './policy-engine.service';
|
|
import { CreatePolicyDto } from './dto/create-policy.dto';
|
|
import { UpdatePolicyDto } from './dto/update-policy.dto';
|
|
import { PolicyStatus, AudienceType } from './entities/policy.enums';
|
|
|
|
@Controller('policy-engine')
|
|
export class PolicyEngineController {
|
|
constructor(private readonly policyEngineService: PolicyEngineService) { }
|
|
|
|
@Post()
|
|
async create(@Body() createPolicyDto: CreatePolicyDto) {
|
|
return this.policyEngineService.create(createPolicyDto);
|
|
}
|
|
|
|
@Get()
|
|
async findAll(
|
|
@Query('page') page: string = '1',
|
|
@Query('limit') limit: string = '10',
|
|
@Query('status') status?: PolicyStatus,
|
|
@Query('audienceType') audienceType?: AudienceType,
|
|
) {
|
|
return this.policyEngineService.findAll(
|
|
Number(page),
|
|
Number(limit),
|
|
status,
|
|
audienceType,
|
|
);
|
|
}
|
|
|
|
@Get(':id')
|
|
async findOne(@Param('id') id: string) {
|
|
return this.policyEngineService.findOne(id);
|
|
}
|
|
|
|
@Put(':id')
|
|
async update(
|
|
@Param('id') id: string,
|
|
@Body() updatePolicyDto: UpdatePolicyDto,
|
|
) {
|
|
return this.policyEngineService.update(id, updatePolicyDto);
|
|
}
|
|
|
|
@Patch(':id/status')
|
|
async updateStatus(
|
|
@Param('id') id: string,
|
|
@Body('status') status: PolicyStatus,
|
|
) {
|
|
return this.policyEngineService.updateStatus(id, status);
|
|
}
|
|
|
|
@Delete(':id')
|
|
async remove(@Param('id') id: string) {
|
|
return this.policyEngineService.remove(id);
|
|
}
|
|
}
|