Become a sponsor

必须遵守
一个模块固定四个文件(dto / repository / service / handler),对外 JSON 契约(json 标签、字段名、路径、权限码、binding 标签)以表结构与前端约定为准,保持稳定。本页是规约全文要点。
form:"同json名" 标签;binding/msg 与 dc 注释按校验需求书写*LocalTime;文件字段 *multipart.FileHeader + UnmarshalBodyIds []int64type XxxListRes = []*XxxItem、type XxxPageRes = PageData[XxxItem]type XxxRepo struct{ Base }
func NewXxxRepo() *XxxRepo { return &XxxRepo{Base: NewBase("gin_xxx")} }
func (r *XxxRepo) Ctx(ctx context.Context) *gorm.DB { return r.Base.Ctx(ctx) }表名 = gin_ + 模块名;关联表同样建仓储。铁律见 12.3 数据访问铁律。
type sXxx struct{} + init 注册 + var Xxx *sXxxDataScope: ApplyDataScope("dept_id")db.WithTrans(ctx, func(ctx context.Context) error { ... })consts.CodeXxx 哨兵或 apperr.Newf(consts.CodeXxx.Code(), "fmt", a...)type CXxx struct{} + 与 dto 一一对应的方法func (c *CXxx) Method(ctx context.Context, req *dto.XxxReq) (*dto.XxxRes, error)