This commit is contained in:
toom1996
2026-08-26 10:45:21 +08:00
parent 3cf1368e68
commit 30c9f21da4
48 changed files with 3442 additions and 0 deletions

View File

@ -0,0 +1,12 @@
// Package repository 数据访问层:封装全部 SQL / GORM 细节。
//
// 分层约定:
// - 只有本层可以感知 *gorm.DB 与表结构;service 与 handler 不得直接触碰数据库。
// - 对外只暴露接口 + 构造函数,便于在测试中替换实现。
// - 数据库错误在此层归一化为本包的 sentinel error,避免 gorm 错误类型向上层泄漏。
package repository
import "errors"
// ErrNotFound 记录不存在。
var ErrNotFound = errors.New("record not found")