From eff8248750d00497571e619ce6736106071e4abe Mon Sep 17 00:00:00 2001 From: lijianbin <513837235@.qq.com> Date: Wed, 26 Nov 2025 10:40:20 +0800 Subject: [PATCH] 1 --- chain_test.go | 34 ++++++++++++++++++++++++++++++---- common.go | 2 +- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/chain_test.go b/chain_test.go index ff6a605..c761561 100644 --- a/chain_test.go +++ b/chain_test.go @@ -103,15 +103,15 @@ func Test_Chain(t *testing.T) { t.Log(err) } db_name := "" - table_name := "ttl_user_log" + table_name := "ttl_product" //time := time.Now().Unix() //================查询表结构=========== - ret, err := new(Query).Db(db_name).GetTableInfo(table_name) + /*ret, err := new(Query).Db(db_name).GetTableInfo(table_name) if err != nil { t.Log(err) } - fmt.Println("===GetTableInfo:", ret) + fmt.Println("===GetTableInfo:", ret)*/ //==========获取信息================= /*query := new(Query).Db(db_name).Clean().Table("ttl_dorm_goods_reserve").Alias("a"). @@ -130,12 +130,26 @@ func Test_Chain(t *testing.T) { fmt.Println("===Find:", info)*/ //============获取列表================== - list, err := new(Query).Db("").Table("ttl_area"). + /*list, err := new(Query).Db("").Table("ttl_area"). Title("`first`,id,level,mergename,name,pid,shortname"). Select() if err != nil { t.Log(err) + }*/ + + list, err := new(Query).Db(db_name).Table(table_name).Alias("p"). + //Join([]string{config.T_product_type + " as pt", "p.uuid=pt.product_uuid", "LEFT"}). + //Where("pt.type=?").Value("score"). + //Where("p.is_score_goods=?").Value("1"). + Where("p.id=?").Value(1). + Orderby("p.view_count desc"). + Page(1).PageSize(10). + Title("p.id,p.view_count,p.title,p.thumb,p.price,p.exchange_score_spend,p.exchange_score_value"). + Select() + if err != nil { + t.Log(err) } + fmt.Println("===List:", list) //===========添加数据============ @@ -253,3 +267,15 @@ func Test_Chain(t *testing.T) { } fmt.Println("====================执行事务结束==================")*/ } + +/*func Test_Data(t *testing.T) { + aa := 0.50 + bb := 15.5 + + res := ToString(aa) + resb := ToString(bb) + + fmt.Println(res) + fmt.Println(resb) + fmt.Println(fmt.Sprintf("%v", aa)) +}*/ diff --git a/common.go b/common.go index eea7f8f..045f470 100644 --- a/common.go +++ b/common.go @@ -29,7 +29,7 @@ func ReplaeByOtherSql(sql, sql_type, action string) string { sql = helper.StringJoin(sql, " RETURNING id") } // 定义需要处理的关键字列表 - keywords := []string{"user", "order", "group", "table", "view", "admin", "new"} + keywords := []string{"user", "order", "group", "table", "view", "admin", "new", "top"} //设置保护词组 excludePhrases := []string{ "order by", "group by", "GROUP BY", "ORDER BY", "WITHIN GROUP", "within group",