docs(delivery): add Swagger annotations and regenerate API docs

Add Swagger annotations to all 7 delivery handlers. Fix existing
test.go type references (Response -> response.Response). Add swaggo
dependencies to go.mod. Regenerate swagger.json/yaml/docs.go with
delivery endpoints visible in /swagger/index.html.

Relates-to: #97
This commit is contained in:
mac
2026-07-23 12:05:21 +08:00
parent 5ddb434b74
commit c421be3ae9
6 changed files with 1429 additions and 66 deletions
+10 -10
View File
@@ -17,7 +17,7 @@ import (
// @Tags 系统
// @Accept json
// @Produce json
// @Success 200 {object} Response{data=object{time=string}}
// @Success 200 {object} response.Response{data=object{time=string}}
// @Router /ping [get]
func Ping(c *gin.Context) {
response.Success(c, gin.H{"time": time.Now().Format(time.RFC3339)})
@@ -29,7 +29,7 @@ func Ping(c *gin.Context) {
// @Tags 测试
// @Accept json
// @Produce json
// @Success 200 {object} Response{data=object{username=string,role=string}}
// @Success 200 {object} response.Response{data=object{username=string,role=string}}
// @Router /test/success [get]
func TestSuccess(c *gin.Context) {
response.Success(c, gin.H{
@@ -45,8 +45,8 @@ func TestSuccess(c *gin.Context) {
// @Accept json
// @Produce json
// @Param code path int true "业务错误码 (10001-10099: 认证相关, 20001-20099: 任务相关)"
// @Success 200 {object} Response{details=string}
// @Failure 400 {object} Response
// @Success 200 {object} response.Response{details=string}
// @Failure 400 {object} response.Response
// @Router /test/error/{code} [get]
func TestError(c *gin.Context) {
codeStr := c.Param("code")
@@ -65,7 +65,7 @@ func TestError(c *gin.Context) {
// @Tags 测试
// @Accept json
// @Produce json
// @Success 500 {object} Response
// @Success 500 {object} response.Response
// @Router /test/500 [get]
func Test500(c *gin.Context) {
response.InternalError(c, "模拟服务器内部错误")
@@ -77,7 +77,7 @@ func Test500(c *gin.Context) {
// @Tags 测试
// @Accept json
// @Produce json
// @Success 401 {object} Response
// @Success 401 {object} response.Response
// @Router /test/401 [get]
func Test401(c *gin.Context) {
response.Unauthorized(c, "模拟 Token 过期")
@@ -89,7 +89,7 @@ func Test401(c *gin.Context) {
// @Tags 测试
// @Accept json
// @Produce json
// @Success 403 {object} Response
// @Success 403 {object} response.Response
// @Router /test/403 [get]
func Test403(c *gin.Context) {
response.Forbidden(c, "模拟无权限")
@@ -101,8 +101,8 @@ func Test403(c *gin.Context) {
// @Tags 测试
// @Accept json
// @Produce json
// @Success 200 {object} Response
// @Failure 408 {object} Response
// @Success 200 {object} response.Response
// @Failure 408 {object} response.Response
// @Router /test/timeout [get]
func TestTimeout(c *gin.Context) {
time.Sleep(15 * time.Second)
@@ -115,7 +115,7 @@ func TestTimeout(c *gin.Context) {
// @Tags 测试
// @Accept json
// @Produce json
// @Success 200 {object} Response{data=PaginatedData{items=[]object}}
// @Success 200 {object} response.Response{data=response.PaginatedData{items=[]object}}
// @Router /test/paginated [get]
func TestPaginated(c *gin.Context) {
items := []gin.H{