backend scaffold
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
// 契约模块:只放接口、传输模型和事件,不携带任何技术栈。
|
||||
// ArchUnit 有一条规则盯着它不依赖 Spring Web / JPA(见 10-testing.md)。
|
||||
dependencies {
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.continental.retailapp.identitystore.contract
|
||||
|
||||
/**
|
||||
* identity-store 对外发布的读能力,见 11-cross-domain-collaboration.md。
|
||||
*
|
||||
* 契约设计四条规则里最重要的两条:
|
||||
* 1. 只承诺调用方真正需要的最小能力——这里出现的每个方法都是未来的约束;
|
||||
* 2. [StoreInfo] 是独立的数据结构,不是 `StoreEntity` 的别名,不跟着表结构一起长。
|
||||
*/
|
||||
interface StoreQueryService {
|
||||
fun listStoresByUserId(userId: Long): List<StoreInfo>
|
||||
|
||||
fun findStore(storeId: Long): StoreInfo?
|
||||
}
|
||||
|
||||
data class StoreInfo(
|
||||
val storeId: Long,
|
||||
val name: String,
|
||||
val code: String,
|
||||
)
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package com.continental.retailapp.identitystore.contract
|
||||
|
||||
import java.time.Instant
|
||||
|
||||
/**
|
||||
* 门店已切换,见 11-cross-domain-collaboration.md。
|
||||
*
|
||||
* 事件类型必须定义在契约模块,否则订阅方要 import 发布方的内部类型,模块边界就破了。
|
||||
*
|
||||
* 可靠性边界要如实认识:`ApplicationEvent` 是**进程内、内存中**的,
|
||||
* 应用在发布后、监听器执行前崩溃这个事件就永久丢了。所以它只用于"丢了不致命"的副作用
|
||||
* (作废票据、清缓存、记审计),不能用于扣款、发货这类丢了会造成不一致的操作。
|
||||
*/
|
||||
data class StoreSwitchedEvent(
|
||||
val userId: Long,
|
||||
val fromStoreId: Long?,
|
||||
val toStoreId: Long,
|
||||
val occurredAt: Instant,
|
||||
)
|
||||
Reference in New Issue
Block a user