iedc-go/example/app/search_record.go
2022-05-03 22:40:02 +08:00

50 lines
1.0 KiB
Go

package app
import (
. "code.hoteas.com/golang/hotime"
. "code.hoteas.com/golang/hotime/common"
)
var SearchRecordCtr = Ctr{
"search": func(that *Context) {
page := ObjToInt(that.Req.FormValue("page"))
pageSize := ObjToInt(that.Req.FormValue("pageSize"))
if page < 1 {
page = 1
}
if pageSize <= 0 {
pageSize = 20
}
data := Map{"del_flag": 0}
keywords := that.Req.FormValue("keywords")
if keywords != "" {
data["search_company_name[~]"] = keywords
}
startTime := that.Req.FormValue("starttime")
finishTime := that.Req.FormValue("finishtime")
if startTime != "" {
data["create_time[>=]"] = startTime
}
if finishTime != "" {
data["create_time[<=]"] = finishTime
}
if len(data) > 1 {
data = Map{"AND": data, "ORDER": "create_time DESC"}
}
count := that.Db.Count("search_record", data)
res := that.Db.Page(page, pageSize).PageSelect("search_record", "id,search_company_name,policy_match_count,money_scope,create_time", data)
that.Display(0, Map{"total": count, "data": res})
},
}