我正在尝试使用 JHipster 对微服务应用程序进行原型设计,并且我已经尝试收集所有我能够正确完成的信息,但目前尚不完全清楚如何将 JDL 放在一起以使正确的实体处于正确的位置产生的服务。
我希望有一个目录布局,如:
/..
gateway <- Ideal would be to have only fronted code
invoice <- Invoice CRUD code with corresponding ms (with below JDL it is empty)
order <- Order CRUD code with corresponding ms
usage <- Usage CRUD code with corresponding ms (with below JDL it is empty)
这是使用的 JDL:
application {
config {
baseName gateway,
applicationType gateway,
packageName com.org.myApp.sales,
serviceDiscoveryType eureka,
searchEngine elasticsearch,
authenticationType oauth2,
prodDatabaseType postgresql,
cacheProvider hazelcast,
buildTool gradle,
clientFramework react,
testFrameworks [protractor]
}
entities *
}
application {
config {
baseName invoice,
applicationType microservice,
packageName com.org.myApp.invoice,
serviceDiscoveryType eureka,
searchEngine elasticsearch,
authenticationType oauth2,
prodDatabaseType postgresql,
devDatabaseType postgresql,
buildTool gradle,
serverPort 8081,
skipUserManagement true
}
entities Invoice, Product
}
application {
config {
baseName usage,
applicationType microservice,
packageName com.org.myApp.usage,
serviceDiscoveryType eureka,
searchEngine elasticsearch,
authenticationType oauth2,
prodDatabaseType postgresql,
devDatabaseType postgresql,
cacheProvider no,
enableHibernateCache false,
buildTool gradle,
serverPort 8082,
skipUserManagement true
}
entities Usage
}
application {
config {
baseName order,
applicationType microservice,
packageName com.org.myApp.order,
serviceDiscoveryType eureka,
searchEngine elasticsearch,
authenticationType oauth2,
prodDatabaseType postgresql,
devDatabaseType postgresql,
buildTool gradle,
serverPort 8083,
skipUserManagement true
}
entities ProductOrder, OrderItem, ProductCategory, Product
}
entity Product {
name String required
description String
price BigDecimal required min(0)
size Size required
image ImageBlob
}
enum Size {
S, M, L, XL, XXL
}
entity ProductCategory {
name String required
description String
}
entity Customer {
firstName String required
lastName String required
gender Gender required
email String required pattern(/^[^@\s]+@[^@\s]+\.[^@\s]+$/)
phone String required
addressLine1 String required
addressLine2 String
city String required
country String required
}
enum Gender {
MALE, FEMALE, OTHER
}
entity ProductOrder {
placedDate Instant required
status OrderStatus required
code String required
invoiceId Long
}
enum OrderStatus {
COMPLETED, PENDING, CANCELLED
}
entity OrderItem {
quantity Integer required min(0)
totalPrice BigDecimal required min(0)
status OrderItemStatus required
}
enum OrderItemStatus {
AVAILABLE, OUT_OF_STOCK, BACK_ORDER
}
relationship OneToOne {
Customer{user(login) required} to User
}
relationship ManyToOne {
OrderItem{product(name) required} to Product
}
relationship OneToMany {
ProductOrder{orderItem} to OrderItem{order(code) required} ,
ProductCategory{product} to Product{productCategory(name)}
}
service Product, ProductCategory, Customer, ProductOrder, OrderItem with serviceClass
paginate Product, Customer, ProductOrder, OrderItem with pagination
/* Entities for Invoice microservice */
entity Invoice {
code String required
date Instant required
details String
status InvoiceStatus required
paymentMethod PaymentMethod required
paymentDate Instant required
paymentAmount BigDecimal required
}
enum InvoiceStatus {
PAID, ISSUED, CANCELLED
}
enum PaymentMethod {
CREDIT_CARD, CASH_ON_DELIVERY, PAYPAL
}
entity Usage {
date Instant required
details String
sentDate Instant required
userId Long required
productId Long required
}
microservice Invoice with invoice
microservice Usage with usage
microservice Product, ProductCategory, ProductOrder, OrderItem with order
dto * with mapstruct
paginate Invoice with pagination
环境:
##### **Environment and Tools**
JHipster version: v6.6.0
java version "11.0.5" 2019-10-15 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.5+10-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.5+10-LTS, mixed mode)
node: v12.14.0
npm: 6.13.4
yeoman: 3.1.1
INFO! Congratulations, JHipster execution is complete!
所以这是我的问题:
1. 究竟是什么控制了实体的生成位置?
application {
config {
baseName gateway,
applicationType gateway,
packageName com.org.myApp.sales,
serviceDiscoveryType eureka,
searchEngine elasticsearch,
authenticationType oauth2,
prodDatabaseType postgresql,
cacheProvider hazelcast,
buildTool gradle,
clientFramework react,
testFrameworks [protractor]
}
entities * <-- What if all entities associated to a different service not to the gateway? (actually when I tried I ended up with an empty folder for gateway)
}
2.microservice <ENTITIES> with <MICROSERVICE_APP_NAME>
与上述entities *
部分有何关系?
3. 实体之间的关系会影响代码的生成位置吗?