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>
32 lines
610 B
Markdown
32 lines
610 B
Markdown
# Pattern: Service
|
|
|
|
## Responsibility
|
|
|
|
Business rules, authorization, orchestration, transactions.
|
|
|
|
## Shape
|
|
|
|
```go
|
|
type ReportRepo interface {
|
|
SaveReport(ctx context.Context, r *model.Report) error
|
|
}
|
|
|
|
type ReportService struct {
|
|
repo ReportRepo
|
|
}
|
|
|
|
func (s *ReportService) Decode(ctx context.Context, in DecodeInput) (*DecodeOutput, error) {
|
|
if err := in.Validate(); err != nil {
|
|
return nil, fmt.Errorf("validate decode: %w", err)
|
|
}
|
|
// rules / engine
|
|
// persist via repo
|
|
return out, nil
|
|
}
|
|
```
|
|
|
|
## Never
|
|
|
|
- Import `gin`
|
|
- Bypass repo with ad-hoc SQL drivers scattered around
|