package app import ( . "code.hoteas.com/golang/hotime" . "code.hoteas.com/golang/hotime/common" ) var ArticleCtr = Ctr{ "getdispatchs": func(that *Context) { res := that.Db.Select("article", "dispatch_name", Map{"del_flag": 0, "GROUP": "dispatch_name"}) that.Display(0, res) }, //用户微信公众号或者小程序登录 "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["OR"] = Map{"title[~]": keywords, "description[~]": keywords, "content[~]": keywords} } startTime := that.Req.FormValue("starttime") finishTime := that.Req.FormValue("finishtime") if startTime != "" { data["release_date[>=]"] = startTime } if finishTime != "" { data["release_date[<=]"] = finishTime } dispatchName := that.Req.FormValue("dispatch_name") if dispatchName != "" { data["dispatch_name"] = dispatchName } //判断类型 tp := that.Req.FormValue("type") if tp == "notify" { data["notify_id[!]"] = nil } if tp == "policy" { data["policy_id[!]"] = nil } if tp == "declare" { data["declare_id[!]"] = nil } if len(data) > 1 { data = Map{"AND": data, "ORDER": "release_time DESC"} } count := that.Db.Count("article", data) res := that.Db.Page(page, pageSize).PageSelect("article", "id,title,description,department_id,click_num+click_num_base AS click_num,"+ "favorite_num_base+favorite_num AS favorite_num,dispatch_num,dispatch_name,prepare_date,release_time,expire_date,area_id,status,policy_id,declare_id,notify_id", data) for _, v := range res { if v.GetCeilInt("notify_id") > 0 { v["notify"] = that.Db.Get("notify", "tag", Map{"id": v.GetCeilInt("notify_id")}) } if v.GetCeilInt("policy_id") > 0 { v["policy"] = that.Db.Get("policy", "tag", Map{"id": v.GetCeilInt("policy_id")}) } if v.GetCeilInt("declare_id") > 0 { v["declare"] = that.Db.Get("declare", "money_scope_min,money_scope_max,status", Map{"id": v.GetCeilInt("declare_id")}) } } that.Display(0, Map{"total": count, "data": res}) }, }