forked from golang/hotime
100 lines
2.2 KiB
Go
100 lines
2.2 KiB
Go
package provider
|
|
|
|
import (
|
|
. "code.hoteas.com/golang/hotime"
|
|
. "code.hoteas.com/golang/hotime/common"
|
|
)
|
|
|
|
var MattersCtr = Ctr{
|
|
|
|
"info": func(that *Context) {
|
|
if that.Session("salesman_id").Data == nil {
|
|
that.Display(2, "没有登录")
|
|
return
|
|
}
|
|
|
|
id := ObjToInt(that.Req.FormValue("id"))
|
|
|
|
if id == 0 {
|
|
that.Display(3, "请求参数异常")
|
|
return
|
|
}
|
|
|
|
res := that.Db.Get("matters", "*", Map{"id": id})
|
|
if res == nil {
|
|
that.Display(4, "找不到事项")
|
|
return
|
|
}
|
|
if res.GetCeilInt("salesman_id") != that.Session("salesman_id").ToCeilInt() {
|
|
that.Display(4, "不是你的事项")
|
|
return
|
|
}
|
|
|
|
res["salesman"] = that.Db.Get("salesman", "name,id", Map{"id": res.GetCeilInt64("salesman_id")})
|
|
|
|
res["provider"] = that.Db.Get("provider", "name,id", Map{"id": res.GetCeilInt64("provider_id")})
|
|
|
|
that.Display(0, res)
|
|
},
|
|
|
|
//用户微信公众号或者小程序登录
|
|
"search": func(that *Context) {
|
|
if that.Session("salesman_id").Data == nil {
|
|
that.Display(2, "没有登录")
|
|
return
|
|
}
|
|
userId := ObjToInt(that.Req.FormValue("id"))
|
|
|
|
page := ObjToInt(that.Req.FormValue("page"))
|
|
pageSize := ObjToInt(that.Req.FormValue("pageSize"))
|
|
|
|
tp := that.Req.FormValue("type")
|
|
|
|
if page < 1 {
|
|
page = 1
|
|
}
|
|
|
|
if pageSize <= 0 {
|
|
pageSize = 20
|
|
}
|
|
|
|
data := Map{"del_flag": 0, "salesman_id": that.Session("salesman_id").Data}
|
|
keywords := that.Req.FormValue("keywords")
|
|
if keywords != "" {
|
|
data["OR"] = Map{"title[~]": keywords, "description[~]": keywords, "content[~]": keywords}
|
|
}
|
|
|
|
if userId != 0 {
|
|
|
|
user := that.Db.Get("user", "id", Map{"AND": Map{"id": userId, "salesman_id": that.Session("salesman_id").Data}})
|
|
if user != nil {
|
|
data["user_id"] = userId
|
|
}
|
|
}
|
|
|
|
if tp != "" {
|
|
data["type"] = ObjToInt("tp")
|
|
}
|
|
|
|
startTime := that.Req.FormValue("starttime")
|
|
finishTime := that.Req.FormValue("finishtime")
|
|
|
|
if startTime != "" {
|
|
data["modify_time[>=]"] = startTime
|
|
}
|
|
if finishTime != "" {
|
|
data["modify_time[<=]"] = finishTime
|
|
}
|
|
|
|
if len(data) > 1 {
|
|
data = Map{"AND": data}
|
|
}
|
|
|
|
count := that.Db.Count("matters", data)
|
|
|
|
res := that.Db.Page(page, pageSize).PageSelect("matters", "*", data)
|
|
|
|
that.Display(0, Map{"total": count, "data": res})
|
|
},
|
|
}
|