From 3b75a2472b8c3f5226e923f5c05b677d6f479f1f Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Mon, 29 Jan 2024 14:23:15 +0800 Subject: [PATCH] update --- app/admin/hdl/hdl_notice.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/app/admin/hdl/hdl_notice.go b/app/admin/hdl/hdl_notice.go index 447a806..d738857 100644 --- a/app/admin/hdl/hdl_notice.go +++ b/app/admin/hdl/hdl_notice.go @@ -98,9 +98,21 @@ func NoticeIsPopToCentralKitchen(c *gin.Context) { e.OutErr(c, e.ERR_DB_ORM, err.Error()) return } + now := time.Now() + if popToCentralKitchen != nil && utils.StrToInt(id) != popToCentralKitchen.Id { - e.OutErr(c, e.ERR_NO_DATA, "当前已有弹出至央厨公告!") - return + notice, err1 := noticeDb.GetNotice(utils.StrToInt(id)) + if err1 != nil { + e.OutErr(c, e.ERR_DB_ORM, err1.Error()) + return + } + notice.IsPopToCentralKitchen = 0 + 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 + } } notice, err := noticeDb.GetNotice(utils.StrToInt(id)) @@ -112,7 +124,6 @@ func NoticeIsPopToCentralKitchen(c *gin.Context) { 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")