117 lines
3.3 KiB
Go
117 lines
3.3 KiB
Go
package app
|
|
|
|
import (
|
|
. "code.hoteas.com/golang/hotime"
|
|
. "code.hoteas.com/golang/hotime/common"
|
|
)
|
|
|
|
var DeclareCtr = Ctr{
|
|
|
|
"info": func(that *Context) {
|
|
id := ObjToInt(that.Req.FormValue("id"))
|
|
|
|
if id == 0 {
|
|
that.Display(3, "请求参数异常")
|
|
return
|
|
}
|
|
|
|
res := that.Db.Get("declare", "*", Map{"id": id})
|
|
|
|
if res == nil {
|
|
that.Display(4, "找不到通知公告")
|
|
return
|
|
}
|
|
res["click_num"] = res.GetCeilInt64("click_num") + res.GetCeilInt64("click_num_base") + 1
|
|
delete(res, "click_num_base")
|
|
|
|
res["favorite_num"] = res.GetCeilInt64("favorite_num") + res.GetCeilInt64("favorite_num_base")
|
|
delete(res, "favorite_num_base")
|
|
|
|
article := that.Db.Get("article", "*", Map{"id": res.GetCeilInt64("article_id")})
|
|
if article != nil {
|
|
article["click_num"] = article.GetCeilInt64("click_num") + article.GetCeilInt64("click_num_base") + 1
|
|
delete(article, "click_num_base")
|
|
|
|
article["favorite_num"] = article.GetCeilInt64("favorite_num") + article.GetCeilInt64("favorite_num_base")
|
|
delete(article, "favorite_num_base")
|
|
}
|
|
|
|
res["article"] = article
|
|
|
|
//浏览量加1
|
|
that.Db.Update("declare", Map{"click_num[#]": "click_num+1"}, Map{"id": id})
|
|
//浏览量加1
|
|
that.Db.Update("article", Map{"click_num[#]": "click_num+1"}, Map{"id": res.GetCeilInt64("article_id")})
|
|
|
|
//查询是否已关注
|
|
if that.Session("user_id").Data != nil {
|
|
favorite := that.Db.Get("favorite", "user_id,declare_id", Map{"AND": Map{"declare_id": id, "user_id": that.Session("user_id").ToCeilInt(), "del_flag": 0}})
|
|
res["favorite"] = favorite
|
|
}
|
|
|
|
that.Display(0, res)
|
|
},
|
|
//政策匹配
|
|
"match": func(that *Context) {
|
|
|
|
},
|
|
//用户微信公众号或者小程序登录
|
|
"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, "declare_id[!]": nil}
|
|
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
|
|
}
|
|
|
|
if len(data) > 1 {
|
|
data = Map{"AND": data}
|
|
}
|
|
|
|
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,declare_id,declare_id,declare_id", data)
|
|
for _, v := range res {
|
|
|
|
//if v.GetCeilInt("declare_id")>0{
|
|
// v["declare"]=that.Db.Get("declare","id,tag",Map{"id":v.GetCeilInt("declare_id")})
|
|
//}
|
|
//if v.GetCeilInt("declare_id")>0{
|
|
// v["declare"]=that.Db.Get("declare","tag",Map{"id":v.GetCeilInt("declare_id")})
|
|
//}
|
|
if v.GetCeilInt("declare_id") > 0 {
|
|
v["declare"] = that.Db.Get("declare", "money_scope_min,money_scope_max,tag,status", Map{"id": v.GetCeilInt("declare_id")})
|
|
}
|
|
}
|
|
|
|
that.Display(0, Map{"total": count, "data": res})
|
|
},
|
|
}
|