Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tsarenkotxt/rule-engine-example
Easy Rules with Spring Boot example, save rules via REST API, save composite rules via REST API, process entity through rules via REST API
https://github.com/tsarenkotxt/rule-engine-example
easy-rules java11 rest-api spring-boot
Last synced: about 1 month ago
JSON representation
Easy Rules with Spring Boot example, save rules via REST API, save composite rules via REST API, process entity through rules via REST API
- Host: GitHub
- URL: https://github.com/tsarenkotxt/rule-engine-example
- Owner: tsarenkotxt
- Created: 2019-10-29T17:17:01.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2019-11-10T02:13:12.000Z (about 5 years ago)
- Last Synced: 2024-09-30T13:23:59.728Z (about 2 months ago)
- Topics: easy-rules, java11, rest-api, spring-boot
- Language: Java
- Homepage:
- Size: 59.6 KB
- Stars: 7
- Watchers: 0
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Easy Rules with Spring Boot
Simple example with [Rule Engine (easy-rules)](https://github.com/j-easy/easy-rules):
- save rules via REST API
- save composite rules via REST API
- process entity through rules via REST API### Requirements
***Java 11***### Get started
#### Run Spring Boot application
```bash
./gradlew bootRun
```
#### Save simple rule
URL - ***http://localhost:8080/rules***
HTTP Method - ***POST***
```json
{
"name": "person rule 1",
"description": "simple person rule for save",
"priority": 1,
"condition": "person.item.name == \"some item\"",
"action": "savePerson"
}
```
#### Save composite rule
URL - ***http://localhost:8080/rules/composite***
HTTP Method - ***POST***
```json
{
"name": "composite person rule 1",
"rules": [
{
"name": "person rule 2",
"description": "simple person rule for send to vendor one",
"priority": 1,
"condition": "person.age > 10",
"action": "sendPersonToVendorOne"
},
{
"name": "person rule 3",
"description": "simple person rule for send to vendor two",
"priority": 1,
"condition": "person.item.count == 1",
"action": "sendPersonToVendorTwo"
}
]
}
```
#### Process Person through rules
URL - ***http://localhost:8080/persons***
HTTP Method - ***POST***
```json
{
"name": "some name",
"age": 18,
"item": {
"name": "some item",
"count": 1
}
}
```
> Response:
```json
{
"person rule 1": true,
"composite person rule 1": true
}
```
#### Get available actions
URL - ***http://localhost:8080/persons***
HTTP Method - ***GET***
> Response:
```json
[
"savePerson",
"sendPersonToVendorOne",
"sendPersonToVendorTwo",
"sendPersonToVendorThree"
]
```
#### Swagger UI
URL - ***http://localhost:8080/swagger-ui.html#/***