feat: 整合elements主题

This commit is contained in:
2026-01-08 11:20:30 +08:00
parent b174a57b7f
commit e673ee2479
9 changed files with 92 additions and 31 deletions

View File

@@ -9,25 +9,17 @@ package router
import (
"testing"
"time"
"git.zhangdeman.cn/zhangdeman/rate_limit"
"github.com/gin-gonic/gin"
)
type testCommon struct {
UserID uint `json:"user_id"`
}
type testForm struct {
Meta `json:"-" method:"get" path:"test" rate-limit:"1/5/60" tag:"测试,验证" summary:"本地调试"`
testCommon
Name string `json:"name"`
}
func TestNewServer(t *testing.T) {
s := NewServer(9087, WithRateLimitInstance(rate_limit.MemoryClient), WithDocConfig(&DocConfig{
Enable: true,
UiTheme: "ydoc-lucky-ui",
UiTheme: "elements",
BaseUri: "",
Flag: "test-server",
ServerList: nil,
@@ -42,9 +34,27 @@ func TestNewServer(t *testing.T) {
s.Start()
}
type testCategory struct {
Meta `json:"-" method:"get" path:"test" rate-limit:"1/5/60" tag:"测试,验证" summary:"本地调试"`
ID int64 `json:"id" description:"分类ID" eg:"123" binding:"required,min=10,max=100"`
Sex string `json:"sex" dc:"性别" binding:"required,oneof=man woman" enum-desc:"man:男||woman:女"`
Name string `json:"name" description:"分类名称" eg:"baichaqinghuan" binding:"required,min=8"`
}
type testProduct struct {
ID int64 `json:"id,omitempty" description:"产品ID" example:"1001" required:"true" binding:"required"`
Name string `json:"name" description:"产品名称" example:"iPhone 13" minLength:"2" maxLength:"100" required:"true"`
Price float64 `json:"price" description:"价格" example:"6999.99" min:"0"`
Stock int `json:"stock" description:"库存" example:"100" min:"0"`
Tags []string `json:"tags" description:"标签"`
Attributes map[string]string `json:"attributes" description:"属性"`
CreatedAt time.Time `json:"created_at" description:"创建时间"`
UpdatedAt *time.Time `json:"updated_at,omitempty" description:"更新时间"`
Category *testCategory `json:"category,omitempty" description:"分类"`
}
type testController struct {
}
func (tc testController) Test(ctx *gin.Context, requestData *testForm) (*testCommon, error) {
return &testCommon{UserID: requestData.UserID}, nil
func (tc testController) Test(ctx *gin.Context, requestData *testCategory) (*testProduct, error) {
return &testProduct{}, nil
}