|
@@ -19,6 +19,8 @@ type Exhibition struct {
|
|
|
saveExhibition xweb.Mapper `xweb:"/manage/saveExhibition"`
|
|
|
//删除展会
|
|
|
deleteExhibition xweb.Mapper `xweb:"/manage/deleteExhibition"`
|
|
|
+ //更新
|
|
|
+ updateExhibition xweb.Mapper `xweb:"/manage/updateExhibition"`
|
|
|
//后台展会内容
|
|
|
newsExhibition xweb.Mapper `xweb:"GET /manage/exhibition/(\\w+)"`
|
|
|
////后台展会列表
|
|
@@ -79,6 +81,7 @@ func (a *Exhibition) SaveExhibition() error {
|
|
|
data["activity_introduction"] = a.GetStringComm("s_content")
|
|
|
data["picture"] = a.GetString("s_pic")
|
|
|
data["creation_time"] = tm
|
|
|
+ data["update_time"] = tm
|
|
|
switch {
|
|
|
case tm < startTime:
|
|
|
data["status"] = 0
|
|
@@ -103,7 +106,7 @@ func (a *Exhibition) SaveExhibition() error {
|
|
|
// DeleteExhibition 删除/取消
|
|
|
func (a *Exhibition) DeleteExhibition() error {
|
|
|
if a.Is("GET") {
|
|
|
- return a.Render("/manage/expresslist.html")
|
|
|
+ return a.Render("/manage/exhibitionlist.html")
|
|
|
} else {
|
|
|
var flag string
|
|
|
var msg string
|
|
@@ -122,15 +125,88 @@ func (a *Exhibition) DeleteExhibition() error {
|
|
|
//取消活动
|
|
|
if Update("exhibition_info", `{"_id":"`+_id+`"}`, &map[string]interface{}{
|
|
|
"$set": &map[string]interface{}{
|
|
|
- "status": 3,
|
|
|
- "l_update": time.Now().Unix(),
|
|
|
+ "status": 3,
|
|
|
+ "update_time": time.Now().Unix(),
|
|
|
}}, false, false) {
|
|
|
flag = "true"
|
|
|
- msg = "删除成功!"
|
|
|
+ msg = "取消成功!"
|
|
|
} else {
|
|
|
flag = "false"
|
|
|
- msg = "删除失败!"
|
|
|
+ msg = "取消失败!"
|
|
|
+ }
|
|
|
+ case "3":
|
|
|
+ //取消活动
|
|
|
+ if Update("exhibition_info", `{"_id":"`+_id+`"}`, &map[string]interface{}{
|
|
|
+ "$set": &map[string]interface{}{
|
|
|
+ "status": 1,
|
|
|
+ "update_time": time.Now().Unix(),
|
|
|
+ }}, false, false) {
|
|
|
+ flag = "true"
|
|
|
+ msg = "恢复成功!"
|
|
|
+ } else {
|
|
|
+ flag = "false"
|
|
|
+ msg = "恢复失败!"
|
|
|
}
|
|
|
+
|
|
|
+ }
|
|
|
+ a.Write(`{"flag":` + flag + `,"msg":"` + msg + `"}`)
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateExhibition 更新
|
|
|
+func (a *Exhibition) UpdateExhibition() error {
|
|
|
+ a.DisableHttpCache()
|
|
|
+ if a.Is("GET") {
|
|
|
+ return a.Render("/manage/exhibitionlist.html")
|
|
|
+ } else {
|
|
|
+ var flag string
|
|
|
+ var msg string
|
|
|
+ data := make(map[string]interface{})
|
|
|
+ _id := a.GetString("_id")
|
|
|
+ data["user_id"] = a.GetSession("userId")
|
|
|
+ data["title"] = a.GetString("s_title")
|
|
|
+ data["type"], _ = a.GetInt("s_type")
|
|
|
+ var startTime, endTime int64
|
|
|
+ if stm := a.GetString("s_start_time"); stm != "" {
|
|
|
+ tim, _ := time.ParseInLocation("2006-01-02 15:04:05", stm, time.Local)
|
|
|
+ startTime = tim.Unix()
|
|
|
+ }
|
|
|
+ if etm := a.GetString("s_end_time"); etm != "" {
|
|
|
+ eim, _ := time.ParseInLocation("2006-01-02 15:04:05", etm, time.Local)
|
|
|
+ endTime = eim.Unix()
|
|
|
+ }
|
|
|
+ data["update_userid"] = a.GetSession("userId")
|
|
|
+ data["start_time"] = startTime
|
|
|
+ data["end_time"] = endTime
|
|
|
+ data["organizers"] = a.GetString("s_organizers")
|
|
|
+ data["contacts"] = a.GetString("s_contacts")
|
|
|
+ data["contact_phone"] = a.GetString("contact_phone")
|
|
|
+ data["province"] = a.GetString("province")
|
|
|
+ data["specific_location"] = a.GetString("specific_location")
|
|
|
+ tm := time.Now().Unix()
|
|
|
+ data["city"] = a.GetString("city")
|
|
|
+ data["hall"] = a.GetString("hall")
|
|
|
+ data["website_address"] = a.GetString("website_address")
|
|
|
+ data["activity_introduction"] = a.GetStringComm("s_content")
|
|
|
+ data["picture"] = a.GetString("s_pic")
|
|
|
+ data["update_time"] = tm
|
|
|
+ switch {
|
|
|
+ case tm < startTime:
|
|
|
+ data["status"] = 0
|
|
|
+ case startTime < tm && tm < endTime:
|
|
|
+ data["status"] = 1
|
|
|
+ case tm > endTime:
|
|
|
+ data["status"] = 2
|
|
|
+ }
|
|
|
+ if Update("exhibition_info", `{"_id":"`+_id+`"}`, &map[string]interface{}{
|
|
|
+ "$set": data,
|
|
|
+ }, false, false) {
|
|
|
+ flag = "true"
|
|
|
+ msg = "保存成功!"
|
|
|
+ } else {
|
|
|
+ flag = "false"
|
|
|
+ msg = "保存失败!"
|
|
|
}
|
|
|
a.Write(`{"flag":` + flag + `,"msg":"` + msg + `"}`)
|
|
|
}
|
|
@@ -161,7 +237,7 @@ func (e *Exhibition) GetExhibitionJsonList() error {
|
|
|
if size <= 0 || size > 100 {
|
|
|
size = 20
|
|
|
}
|
|
|
- data := Find("exhibition_info", nil, `{"creation_time": -1}`, nil, false, (currentPage-1)*size, size)
|
|
|
+ data := Find("exhibition_info", nil, `{"update_time": -1}`, nil, false, (currentPage-1)*size, size)
|
|
|
for _, v := range *data {
|
|
|
release := v["creation_time"]
|
|
|
v["creation_time"] = util.FormatDateWithObj(&release, util.Date_Short_Layout)
|
|
@@ -199,6 +275,11 @@ func (n *Exhibition) NewsExhibition(_id string) error {
|
|
|
(*r)["end_time"] = util.FormatDateWithObj(&endTime, util.Date_Full_Layout)
|
|
|
(*r)["activity_introduction"] = template.HTML((*r)["activity_introduction"].(string))
|
|
|
(*r)["s_preurl"] = SysConfig.Jyadd + se.EncodeString((*r)["_id"].(string)) + ".html"
|
|
|
+ (*r)["s_pic"] = (*r)["picture"]
|
|
|
+ (*r)["isCancel"] = 1
|
|
|
+ if util.IntAll((*r)["status"]) == 3 {
|
|
|
+ (*r)["isCancel"] = 0
|
|
|
+ }
|
|
|
n.T = *r
|
|
|
return n.Render("/manage/newExhibition.html")
|
|
|
} else {
|