Files
jackyu66gitandCursor 2fb1dfee14 chore: seal Design Vision v1 and monorepo scaffold
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>
2026-08-02 16:00:44 +08:00

804 B

Pattern: Handler

Responsibility

HTTP only: bind JSON/query → validate → call service interface → map errors to envelope.

Shape

type ReportService interface {
    Decode(ctx context.Context, in DecodeInput) (*DecodeOutput, error)
}

type ReportHandler struct {
    svc ReportService
}

func (h *ReportHandler) Decode(c *gin.Context) {
    var req DecodeRequest
    if err := c.ShouldBindJSON(&req); err != nil {
        response.Fail(c, 400, 10000, "invalid request")
        return
    }
    out, err := h.svc.Decode(c.Request.Context(), toInput(req))
    if err != nil {
        // map domain errors → codes
        response.Fail(c, 400, 30001, err.Error())
        return
    }
    response.OK(c, out)
}

Never

  • SQL here
  • Business unlock math here (belongs service)