proxymysql/app/mysqlserver/helper_test.go

13 lines
1.2 KiB
Go
Raw Normal View History

2024-02-04 18:17:06 +08:00
package mysqlserver
import (
"testing"
)
func TestParseSqlComment(t *testing.T) {
query := "/* TzAdmin-{\"AdminId\":39,\"AdminName\":\"test\",\"AdminRealName\":\"postman调试账号\",\"QueryGameId\":666,\"HeaderGameId\":888,\"Ip\":\"219.137.24.171\",\"RequestPath\":\"/api/general/day_report/totalAccount\",\"RequestInfo\":\"Path:\\\"/api/general/day_report/totalAccount\\\" RawQuery:\\\"qw=123\\\"\",\"UnixMilli\":1702539552664}-TzAdmin */ SELECT sum(if(`index`=9, index_value, 0)) as act_account_num, sum(if(`index`=6, index_value, 0)) as reg_account_num, sum(if(`index`=5, index_value, 0)) as pay_account_num, sum(if(`index`=8, index_value, 0)) as reg_pay_account_num, sum(if(`index`=12, index_value, 0)) as first_charge_account_num, sum(if(`index`=3, index_value, 0)) as pay_amount, sum(if(`index`=7, index_value, 0)) as reg_pay_amount FROM new_tzpt.tzpingtai_report_index_all t1 WHERE t1.game_id = 666 and t1.game_id in (666,888,999,1213,10001) AND t1.channel_id IN (5, 6, 100011, 100012, 100101, 100102, 100111, 125593, 10000001, 10000004, 10000005, 10000006, 10000007, 10000008, 10000009,10000011, -1) AND t1.collect_date BETWEEN '2023-11-01' AND '2023-11-30' ORDER BY pay_amount desc"
s := &RecordQuery{}
s.parseSqlComment(query)
}