Add: 1. select like function, 2. tglog

This commit is contained in:
殷勇 2023-09-12 17:31:47 +08:00
parent 4c371afe63
commit 0317dc9f5e
2 changed files with 46 additions and 32 deletions

View File

@ -84,6 +84,24 @@ func (this *dbPool) OrmSelect(
this.internalQuery(dataSource, sql, params, cb) this.internalQuery(dataSource, sql, params, cb)
} }
func (this *dbPool) SelectLike(
dataSource string,
tblName string,
fields []string,
whereKv [][]string,
likeWhere [][]string,
limit int,
cb QueryResultCb) {
var params []string
sql := fmt.Sprintf("SELECT %s FROM %s WHERE 1=1 ", this.joinSelectFields(fields), tblName)
this.joinWhere(&sql, &params, whereKv)
this.joinWhereLike(&sql, &params, likeWhere)
sql = fmt.Sprintf("%s LIMIT %d", sql, limit)
this.internalQuery(dataSource, sql, params, cb)
}
func (this *dbPool) SelectOne( func (this *dbPool) SelectOne(
dataSource string, dataSource string,
tblName string, tblName string,
@ -259,6 +277,13 @@ func (this *dbPool) joinWhere(sql *string, params *[]string, whereKv [][]string)
} }
} }
func (this *dbPool) joinWhereLike(sql *string, params *[]string, whereKv [][]string) {
for _, items := range whereKv {
*sql += " AND " + items[0] + " LIKE ? "
*params = append(*params, items[1])
}
}
func (this *dbPool) joinUpdateFields(fieldsKv [][]string, params *[]string) string { func (this *dbPool) joinUpdateFields(fieldsKv [][]string, params *[]string) string {
sql := "" sql := ""
for index, items := range fieldsKv { for index, items := range fieldsKv {

View File

@ -1,10 +1,10 @@
package f5 package f5
import ( import (
"q5"
"os"
"sync"
"fmt" "fmt"
"os"
"q5"
"sync"
"time" "time"
) )
@ -36,17 +36,6 @@ func (this *tgLog) SetPolyLog(isPolyLog bool) {
} }
func (this *tgLog) AddTrackLog( func (this *tgLog) AddTrackLog(
gameId int32,
accountId string,
remoteAddr string,
logClass1 int32,
logClass2 int32,
prop map[string]string) {
eventName := fmt.Sprintf("event_%d_%d", logClass1, logClass2)
this.AddTrackLogEx(gameId, accountId, remoteAddr, eventName, prop)
}
func (this *tgLog) AddTrackLogEx(
gameId int32, gameId int32,
accountId string, accountId string,
remoteAddr string, remoteAddr string,