引入文档解析
This commit is contained in:
@ -8,6 +8,8 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@ -15,8 +17,18 @@ import (
|
||||
|
||||
type TestController struct{}
|
||||
|
||||
func (t TestController) Logic(ctx *gin.Context, formData *TestForm) (any, error) {
|
||||
return formData, nil
|
||||
func (t TestController) Logic(ctx *gin.Context, formData *TestForm) (TestOut, error) {
|
||||
return TestOut{
|
||||
FormData: formData,
|
||||
}, nil
|
||||
}
|
||||
|
||||
type TestOut struct {
|
||||
Age int `json:"age" form:"age" binding:"min=20" err_msg:"年龄不能小于20"`
|
||||
Name string `json:"name" form:"name"`
|
||||
Test *Test `json:"test" form:"test"`
|
||||
Num *int64 `json:"num" form:"num"`
|
||||
FormData *TestForm `json:"form_data" form:"form_data"`
|
||||
}
|
||||
|
||||
type TestForm struct {
|
||||
@ -34,5 +46,7 @@ func Test_parseController(t *testing.T) {
|
||||
SetValidateErrTag("err_msg")
|
||||
s := NewServer(8080, nil)
|
||||
s.Group("test", nil, TestController{})
|
||||
byteData, _ := json.Marshal(s.docInstance.Data())
|
||||
fmt.Println(string(byteData))
|
||||
s.Start()
|
||||
}
|
||||
|
Reference in New Issue
Block a user