|
|
@@ -21,6 +21,16 @@ func NoticeList(c *gin.Context) { |
|
|
|
} |
|
|
|
e.OutSuc(c, map[string]interface{}{ |
|
|
|
"list": notices, |
|
|
|
"is_pop_to_central_kitchen_list": []map[string]interface{}{ |
|
|
|
{ |
|
|
|
"name": "弹出", |
|
|
|
"value": 1, |
|
|
|
}, |
|
|
|
{ |
|
|
|
"name": "不弹出", |
|
|
|
"value": 0, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, nil) |
|
|
|
return |
|
|
|
} |
|
|
@@ -78,6 +88,41 @@ func NoticeAdd(c *gin.Context) { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
func NoticeIsPopToCentralKitchen(c *gin.Context) { |
|
|
|
id := c.DefaultQuery("id", "0") |
|
|
|
isPopToCentralKitchen := c.DefaultQuery("is_pop_to_central_kitchen", "0") |
|
|
|
noticeDb := db.NoticeDb{} |
|
|
|
noticeDb.Set() |
|
|
|
popToCentralKitchen, err := noticeDb.GetPopToCentralKitchen() |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
if popToCentralKitchen != nil && utils.StrToInt(id) != popToCentralKitchen.Id { |
|
|
|
e.OutErr(c, e.ERR_NO_DATA, "当前已有弹出至央厨公告!") |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
notice, err := noticeDb.GetNotice(utils.StrToInt(id)) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
if notice == nil { |
|
|
|
e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录") |
|
|
|
return |
|
|
|
} |
|
|
|
now := time.Now() |
|
|
|
notice.IsPopToCentralKitchen = utils.StrToInt(isPopToCentralKitchen) |
|
|
|
notice.UpdateAt = now.Format("2006-01-02 15:04:05") |
|
|
|
_, err = noticeDb.NoticeUpdate(notice, "is_pop_to_central_kitchen", "update_at") |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
e.OutSuc(c, "success", nil) |
|
|
|
} |
|
|
|
|
|
|
|
func NoticeUpdate(c *gin.Context) { |
|
|
|
var req md.NoticeUpdateReq |
|
|
|
err := c.ShouldBindJSON(&req) |
|
|
|