diff --git a/soul-api/internal/handler/match_records.go b/soul-api/internal/handler/match_records.go index 6493a066..742674b1 100644 --- a/soul-api/internal/handler/match_records.go +++ b/soul-api/internal/handler/match_records.go @@ -155,3 +155,34 @@ func DBMatchPoolCounts(c *gin.Context) { }, }) } + +// DBMatchRecordInsertTest POST /api/db/match-records/test 插入测试匹配记录 +func DBMatchRecordInsertTest(c *gin.Context) { + var body struct { + MatchType string `json:"matchType"` + Phone string `json:"phone"` + WechatID string `json:"wechatId"` + } + _ = c.ShouldBindJSON(&body) + if body.MatchType == "" { + body.MatchType = "team" + } + if body.Phone == "" { + body.Phone = "13800000000" + } + db := database.DB() + rec := model.MatchRecord{ + ID: fmt.Sprintf("mr_test_%d", time.Now().UnixNano()), + UserID: "admin_test", + MatchType: body.MatchType, + Phone: &body.Phone, + } + if body.WechatID != "" { + rec.WechatID = &body.WechatID + } + if err := db.Create(&rec).Error; err != nil { + c.JSON(http.StatusOK, gin.H{"success": false, "message": err.Error()}) + return + } + c.JSON(http.StatusOK, gin.H{"success": true, "message": "测试记录已插入", "id": rec.ID}) +}