feat: complete contract-driven business development and MySQL integration

This commit is contained in:
2026-09-24 21:56:04 +08:00
parent f9afb8f8dd
commit f5478cdc76
108 changed files with 6557 additions and 550 deletions

View File

@@ -0,0 +1,61 @@
syntax = "v1"
@app (
defaultResponse: CommonResponse
request: {"unknownQuery":"reject","utf8":"reject","charset":"utf8"}
)
response CommonResponse (
codeType: int32
successCode: 0
errorCode: 9999
messageField: msg
dataMode: always
requestIdField: "-"
)
type Item {
Name string `json:"name"`
}
type Query {
Mode string `form:"mode,optional"`
Tags []string `form:"tags,optional"`
}
type Upload {
Title string `multipart:"title" binding:"required,max=20"`
Metadata Item `multipartJSON:"metadata"`
Attachment File `file:"attachment,maxBytes=1024"`
Extras []File `file:"extras,optional,maxFiles=2,maxBytes=512"`
}
@server (group: demo; middleware: RequireAccess)
service business {
@handler upload
@body (mode: multipart; maxBytes: 4096; maxParts: 6; maxFieldBytes: 128)
post /upload (Upload) returns (Item)
@handler list
get /list (Query) returns ([]Item)
@handler nullable
get /nullable (Query) returns (*Item)
@handler nothing
post /nothing returns (null)
@handler rawNull
@response raw
get /rawNull returns (null)
@handler rawArray
@response raw
get /rawArray returns ([]Item)
@handler empty
@request (body: emptyObject)
post /empty returns (null)
@handler absent
@request (body: none)
post /absent returns (null)
@handler optional
@request (body: optional)
post /optional (Item) returns (Item)
@handler echo
post /echo (Item) returns (Item)
@handler tolerant
@request (unknownQuery: ignore; utf8: replace; charset: any)
post /tolerant (Item) returns (Item)
@handler noContent
delete /noContent
}