-
-
Save mengu/79b858cabfdcfccd26b4679f573afbd5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
micronaut: | |
application: | |
name: events | |
security: | |
enabled: true | |
endpoints: | |
routes: | |
enabled: Boolean | |
sensitive: Boolean | |
datasources: | |
default: | |
url: jdbc:postgresql://localhost:5432/events | |
driverClassName: org.postgresql.Driver | |
username: mengu | |
password: '' | |
schema-generate: CREATE_DROP | |
dialect: POSTGRES | |
logSql: true | |
api: | |
url: jdbc:postgresql://localhost:5432/api | |
driverClassName: org.postgresql.Driver | |
username: mengu | |
password: '' | |
schema-generate: none | |
dialect: POSTGRES | |
logSql: true | |
# kafka.bootstrap.servers: localhost:9092 | |
# rabbitmq.uri: amqp://localhost:5672 | |
jpa: | |
default: | |
entity-scan: | |
packages: | |
- 'domain' | |
properties: | |
hibernate: | |
hbm2ddl: | |
auto: update | |
show_sql: true | |
api: | |
entity-scan: | |
packages: | |
- 'domain' | |
properties: | |
show_sql: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package domain | |
import com.vladmihalcea.hibernate.type.json.JsonBinaryType | |
import org.hibernate.annotations.Type | |
import org.hibernate.annotations.TypeDef | |
import java.util.* | |
import javax.persistence.* | |
@Entity | |
@Table(name = "rules") | |
@TypeDef(name = "jsonb", typeClass = JsonBinaryType::class) | |
data class Rule( | |
val nodeId: UUID, | |
val event: String, | |
val name: String, | |
val code: String, | |
val status: Int, | |
@Type(type = "jsonb") | |
@Column(columnDefinition = "jsonb") | |
val flow: List<Map<String, Any>> | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package services | |
import domain.Rule | |
import java.util.* | |
import javax.inject.Inject | |
import javax.inject.Named | |
import javax.persistence.EntityManager | |
import javax.persistence.PersistenceContext | |
import javax.transaction.Transactional | |
class RuleService { | |
@Inject | |
@PersistenceContext(name = "api") | |
lateinit var entityManager: EntityManager | |
@Transactional | |
fun findAccountRules(nodeId: UUID): List<Rule> { | |
val ruleCriteria = entityManager.criteriaBuilder | |
val ruleQuery = ruleCriteria.createQuery(Rule::class.java) | |
val ruleRoot = ruleQuery.from(Rule::class.java) | |
val rulesQuery = ruleQuery | |
.select(ruleRoot) | |
.where(ruleCriteria.equal(ruleRoot.get<UUID>("nodeId"), nodeId)) | |
return entityManager.createQuery(rulesQuery).resultList | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment