Browse Source

1

master v1.7.1
lijianbin 17 hours ago
parent
commit
eff8248750
2 changed files with 31 additions and 5 deletions
  1. +30
    -4
      chain_test.go
  2. +1
    -1
      common.go

+ 30
- 4
chain_test.go View File

@ -103,15 +103,15 @@ func Test_Chain(t *testing.T) {
t.Log(err) t.Log(err)
} }
db_name := "" db_name := ""
table_name := "ttl_user_log"
table_name := "ttl_product"
//time := time.Now().Unix() //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 { if err != nil {
t.Log(err) 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"). /*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)*/ 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"). Title("`first`,id,level,mergename,name,pid,shortname").
Select() Select()
if err != nil { if err != nil {
t.Log(err) 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) fmt.Println("===List:", list)
//===========添加数据============ //===========添加数据============
@ -253,3 +267,15 @@ func Test_Chain(t *testing.T) {
} }
fmt.Println("====================执行事务结束==================")*/ 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))
}*/

+ 1
- 1
common.go View File

@ -29,7 +29,7 @@ func ReplaeByOtherSql(sql, sql_type, action string) string {
sql = helper.StringJoin(sql, " RETURNING id") 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{ excludePhrases := []string{
"order by", "group by", "GROUP BY", "ORDER BY", "WITHIN GROUP", "within group", "order by", "group by", "GROUP BY", "ORDER BY", "WITHIN GROUP", "within group",


Loading…
Cancel
Save