mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-09-29 05:56:38 +08:00
Revert "autoresearch iter 28: CORDIS gate contracts must not carry table names"
This reverts commit 2cb8d9a892.
This commit is contained in:
@@ -29,6 +29,11 @@ type UserDTO struct {
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// TableName returns w_users.
|
||||
func (UserDTO) TableName() string {
|
||||
return "w_users"
|
||||
}
|
||||
|
||||
// OAuthUserInfoDTO contains user identity claims obtained from an OAuth provider.
|
||||
type OAuthUserInfoDTO struct {
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
@@ -90,20 +90,6 @@ else
|
||||
log_pass "backend/core/contracts/ 纯抽象无侵入"
|
||||
fi
|
||||
|
||||
# 2.2 契约层禁止持久化耦合(表名映射 / ORM tag)
|
||||
# DTO 一旦携带 TableName(),调用方就能用 Table("w_users") 直查他人表,
|
||||
# 单表所有者原则与 contracts 抽象同时失效。
|
||||
# 注意:不禁 gorm import 本身 —— DBService 契约合法返回 gorm 类型。
|
||||
CONTRACTS_PERSISTENCE=$(rg -n 'func .*\)?\s*TableName\(\)|\bgorm:"' \
|
||||
"${BACKEND_DIR}/core/contracts/" --glob '*.go' -g '!*_test.go' || true)
|
||||
|
||||
if [ -n "${CONTRACTS_PERSISTENCE}" ]; then
|
||||
log_fail "backend/core/contracts/ 为跨插件纯 DTO,严禁携带表名映射或 ORM tag(持久化归属唯一所有者插件,否则调用方可绕过契约直读他人表):"
|
||||
echo "${CONTRACTS_PERSISTENCE}" >&2
|
||||
else
|
||||
log_pass "backend/core/contracts/ 无持久化耦合"
|
||||
fi
|
||||
|
||||
# ==============================================================================
|
||||
# 3. 基础包纯洁度 (backend/pkg/ Purity)
|
||||
# ==============================================================================
|
||||
|
||||
Reference in New Issue
Block a user