Explorar el Código

fix: 测试路由每次生成唯一车牌——避免空车牌重复入场冲突

lq hace 1 mes
padre
commit
3b3b655557
Se han modificado 1 ficheros con 6 adiciones y 1 borrados
  1. 6 1
      internal/modules/printer/api.go

+ 6 - 1
internal/modules/printer/api.go

@@ -1,6 +1,9 @@
 package printer
 
 import (
+	"fmt"
+	"time"
+
 	"github.com/gin-gonic/gin"
 	"wails-app/internal/dao"
 	"wails-app/internal/global"
@@ -73,8 +76,10 @@ func SetupPrinterPublic(router *gin.RouterGroup) {
 }
 
 func TicketMachineButtonTest(c *gin.Context) {
+	// 每次生成唯一测试车牌
+	testPlate := fmt.Sprintf("TEST%04d", time.Now().Unix()%10000)
 	entryResp, err := vehicleSvc.VehicleEntry(request.VehicleEntry{
-		PlateNumber: "", RFIDTag: "",
+		PlateNumber: testPlate, RFIDTag: "",
 		ParkingLotID: 1, ParkingSpaceID: 1,
 	})
 	if err != nil {