初步版本修正

This commit is contained in:
hoteas
2022-05-05 00:29:30 +08:00
parent ce8059b0a0
commit f0d4efd8fc
20 changed files with 511 additions and 52 deletions
+113
View File
@@ -0,0 +1,113 @@
package provider
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)
},
//用户微信公众号或者小程序登录
"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, "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,declare_id,declare_id,declare_id,dispatch_name,policy_level", 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,status", Map{"id": v.GetCeilInt("declare_id")})
}
}
that.Display(0, Map{"total": count, "data": res})
},
}
+2
View File
@@ -9,10 +9,12 @@ import (
// Project 管理端项目
var Project = Proj{
"company": CompanyCtr,
"declare": DeclareCtr,
"matters": MattersCtr,
"order": OrderCtr,
"salesman": Salesman,
"sms": Sms,
"tag": TagCtr,
"user": UserCtr,
"wechat": Wechat,
}
+2 -2
View File
@@ -96,9 +96,9 @@ var MattersCtr = Ctr{
for _, v := range res {
if v.GetCeilInt64("user_id") != 0 {
v["user"] = that.Db.Get("user", "id,name,nickname,company_id", Map{"user_id": v.GetCeilInt64("user_id")})
v["user"] = that.Db.Get("user", "id,avatar,name,nickname,company_id", Map{"id": v.GetCeilInt64("user_id")})
if v.GetMap("user") != nil && v.GetMap("user").GetCeilInt64("company_id") != 0 {
v["company"] = that.Db.Get("company", "id,name", Map{"company_id": v.GetMap("user").GetCeilInt64("company_id")})
v["company"] = that.Db.Get("company", "id,name", Map{"id": v.GetMap("user").GetCeilInt64("company_id")})
}
}
}
+20 -8
View File
@@ -18,17 +18,23 @@ var OrderCtr = Ctr{
that.Display(3, "请求参数异常")
return
}
salesman := that.Db.Get("salesman", "*", Map{"id": that.Session("salesman_id").Data})
if salesman == nil {
that.Display(2, "登录错误")
return
}
res := that.Db.Get("order", "*", Map{"id": id})
res := that.Db.Get("order", "*", Map{"AND": Map{"id": id, "provider_id": salesman.GetCeilInt64("provider_id")}})
if res == nil {
that.Display(4, "找不到对应订单")
return
}
if res.GetCeilInt("salesman_id") != that.Session("salesman_id").ToCeilInt() {
that.Display(4, "不是你的订单")
return
}
//if res.GetCeilInt("salesman_id") != that.Session("salesman_id").ToCeilInt() {
// that.Display(4, "不是你的订单")
// return
//}
if res.GetCeilInt("user_id") > 0 {
res["user"] = that.Db.Get("user", "name,nickname,avatar", Map{"id": res.GetCeilInt("user_id")})
@@ -59,7 +65,7 @@ var OrderCtr = Ctr{
return
}
order := that.Db.Get("order", "*", Map{"AND": Map{"id": id, "salesman_id": that.Session("salesman_id").Data}})
order := that.Db.Get("order", "*", Map{"AND": Map{"id": id, "provider_id": salesman.GetCeilInt64("provider_id")}})
if order == nil {
that.Display(4, "不是属于你的订单")
return
@@ -129,7 +135,7 @@ var OrderCtr = Ctr{
data["declare_id"] = declareId
}
order := that.Db.Get("order", "*", Map{"AND": Map{"id": id, "salesman_id": that.Session("salesman_id").Data}})
order := that.Db.Get("order", "*", Map{"AND": Map{"id": id, "provider_id": salesman.GetCeilInt64("provider_id")}})
if order == nil {
that.Display(4, "不是属于你的订单")
return
@@ -178,7 +184,13 @@ var OrderCtr = Ctr{
pageSize = 20
}
data := Map{"del_flag": 0, "salesman_id": that.Session("salesman_id").Data}
salesman := that.Db.Get("salesman", "*", Map{"id": that.Session("salesman_id").Data})
if salesman == nil {
that.Display(2, "登录错误")
return
}
data := Map{"del_flag": 0, "provider_id": salesman.GetCeilInt64("provider_id")}
keywords := that.Req.FormValue("keywords")
if keywords != "" {
data["OR"] = Map{"sn[~]": keywords, "name[~]": keywords}
+83
View File
@@ -0,0 +1,83 @@
package provider
import (
. "code.hoteas.com/golang/hotime"
. "code.hoteas.com/golang/hotime/common"
)
var TagCtr = Ctr{
"create": func(that *Context) {
if that.Session("user_id").Data == nil {
that.Display(2, "没有登录")
return
}
name := that.Req.FormValue("name")
oldTag := that.Db.Get("tag", "id", Map{"name": name})
if oldTag != nil {
that.Display(4, "此标签已存在")
return
}
re := that.Db.Insert("tag", Map{
"user_id": that.Session("user_id").Data,
"name": name,
"remark": "用户上传",
"create_time[#]": "now()",
"modify_time[#]": "now()",
"state": 1, //先置为异常状态,等待审核通过
"del_flag": 0,
})
if re == 0 {
that.Display(4, "添加失败")
return
}
that.Display(0, "添加成功")
return
},
//用户微信公众号或者小程序登录
"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 = 40
}
data := Map{"del_flag": 0, "state": 0}
keywords := that.Req.FormValue("keywords")
if keywords != "" {
data["OR"] = Map{"name[~]": keywords, "remark[~]": keywords}
}
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("tag", data)
res := that.Db.Page(page, pageSize).PageSelect("tag", "id,name,remark", data)
that.Display(0, Map{"total": count, "data": res})
},
}
+7 -2
View File
@@ -3,6 +3,7 @@ package provider
import (
. "code.hoteas.com/golang/hotime"
. "code.hoteas.com/golang/hotime/common"
"time"
)
var UserCtr = Ctr{
@@ -124,12 +125,16 @@ var UserCtr = Ctr{
if tp == 2 {
data["certification_flag"] = 1
data["expiration_time[<]"] = "now()"
data["OR"] = Map{"expiration_time": nil, "expiration_time[#]": "now()"}
}
if tp == 3 {
data["certification_flag"] = 1
data["expiration_time[>]"] = "now()"
data["expiration_time[>]"] = time.Now().Format("2006-01-02 15:04:05")
}
if len(data) > 1 {
data = Map{"AND": data, "ORDER": "modify_time DESC"}
}
count := that.Db.Count("user", data)