- 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.
30 lines
1012 B
TypeScript
30 lines
1012 B
TypeScript
import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, OneToMany, JoinColumn } from 'typeorm';
|
|
import { Policy } from './policy.entity';
|
|
import { RuleCondition } from './rule-condition.entity';
|
|
import { PolicyAction } from './policy-action.entity';
|
|
|
|
@Entity({ name: 'policy_rules', schema: 'policy_engine' })
|
|
export class PolicyRule {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id: string;
|
|
|
|
@Column({ name: 'policy_id', type: 'uuid' })
|
|
policyId: string;
|
|
|
|
@Column({ name: 'rule_category_id', type: 'uuid', nullable: true })
|
|
ruleCategoryId: string;
|
|
|
|
@Column({ type: 'int', default: 0 })
|
|
priority: number;
|
|
|
|
@ManyToOne(() => Policy, (policy) => policy.rules, { onDelete: 'CASCADE' })
|
|
@JoinColumn({ name: 'policy_id' })
|
|
policy: Policy;
|
|
|
|
@OneToMany(() => RuleCondition, (condition) => condition.rule, { cascade: true, onDelete: 'CASCADE' })
|
|
conditions: RuleCondition[];
|
|
|
|
@OneToMany(() => PolicyAction, (action) => action.rule, { cascade: true, onDelete: 'CASCADE' })
|
|
actions: PolicyAction[];
|
|
}
|