Archive the differentiated YuXinGu product docs, AI engineering system, design contract, and Go/Vue scaffold. Next execution prioritizes Cece-parity over early innovation (see .ai/product/STRATEGY.md). Co-authored-by: Cursor <cursoragent@cursor.com>
25 lines
617 B
Markdown
25 lines
617 B
Markdown
# Pattern: Repository
|
|
|
|
## Responsibility
|
|
|
|
Persistence only. Parameterized SQL. Map rows ↔ model.
|
|
|
|
## Shape
|
|
|
|
```go
|
|
func (r *ReportRepository) SaveReport(ctx context.Context, m *model.Report) error {
|
|
const q = `INSERT INTO report (id, user_id, kind, payload, created_at, updated_at)
|
|
VALUES ($1,$2,$3,$4,now(),now())`
|
|
_, err := r.db.ExecContext(ctx, q, m.ID, m.UserID, m.Kind, m.Payload)
|
|
if err != nil {
|
|
return fmt.Errorf("insert report: %w", err)
|
|
}
|
|
return nil
|
|
}
|
|
```
|
|
|
|
## Never
|
|
|
|
- `SELECT *` in new code
|
|
- Business policy (VIP checks) here — return data, let service decide
|