panghu hace 8 meses
padre
commit
60fdd47b92
Se han modificado 3 ficheros con 32 adiciones y 1 borrados
  1. 14 0
      api/ceshi.go
  2. 1 1
      pkg/order/order.go
  3. 17 0
      router/api_ceshi.go

+ 14 - 0
api/ceshi.go

@@ -0,0 +1,14 @@
+package api
+
+import (
+	"github.com/gin-gonic/gin"
+	"go_zh/pkg/order"
+)
+
+type CeshiController struct {
+	BaseController
+}
+
+func (cs CeshiController) GetTime(c *gin.Context) {
+	order.TestConcurrentGeneration()
+}

+ 1 - 1
pkg/order/order.go

@@ -43,7 +43,7 @@ func (g *Generator) Generate() string {
 }
 
 // 并发测试函数
-func testConcurrentGeneration() {
+func TestConcurrentGeneration() {
 	fmt.Println("=== 并发测试 ===")
 	generator := NewOrderGenerator(1)
 

+ 17 - 0
router/api_ceshi.go

@@ -0,0 +1,17 @@
+package router
+
+import (
+	"github.com/gin-gonic/gin"
+	"go_zh/api"
+)
+
+func init() {
+	RegisterRoute(func(engine *gin.Engine) {
+		v1 := engine.Group("/v1")
+		// 用户路由组
+		ceshiGroup := v1.Group("/ceshi")
+		{
+			ceshiGroup.GET("/inviteCode", api.CeshiController{}.GetTime)
+		}
+	})
+}