record.go 605 Bytes
package dto

import (
	"apigame/service/constd"
	"apigame/util/util-lx/lxalilog"
	"fmt"
	"github.com/astaxie/beego/orm"
)

func SaveRecord(gameId string, data IRecordData) {
	text1 := ""
	text2 := ""
	indexPairs := 0
	for s, s2 := range data.SqlPairs() {
		if indexPairs != 0 {
			text1 += ","
			text2 += ","
		}
		text1 += s
		text2 += s2
		indexPairs++
	}
	sql := fmt.Sprintf("insert into %s (%s) value (%s)",
		data.TableName(gameId), text1, text2)

	o := orm.NewOrm()
	o.Using(constd.MYSQL_MERGECOMMON)

	_, err := o.Raw(sql).Exec()
	if err != nil {
		lxalilog.Errors(err, sql, gameId)
		return
	}
}