From 8d71e58734df035e9f30f7523ac41c0ce76f7ef5 Mon Sep 17 00:00:00 2001 From: Echo <1711788888@qq.com> Date: Fri, 10 Nov 2023 13:32:04 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E6=96=B0=E5=A2=9E=E8=BD=AE=E6=92=AD?= =?UTF-8?q?=E5=9B=BE=E4=BF=AE=E6=94=B9=E7=8A=B6=E6=80=81=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/v1/system/banner.go | 19 +++++++++++++++++++ core/server.go | 2 +- router/system/banner.go | 8 ++++---- service/system/banner.go | 5 +++++ 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/api/v1/system/banner.go b/api/v1/system/banner.go index 1c5e632..706b447 100644 --- a/api/v1/system/banner.go +++ b/api/v1/system/banner.go @@ -106,3 +106,22 @@ func (b *BannerApi) GetBannerById(ctx *gin.Context) { r.OkWithDetailed(banner, "获取成功", ctx) } + +// UpdateBannerStatus 更新轮播图状态 +func (b *BannerApi) UpdateBannerStatus(ctx *gin.Context) { + var banner common.Banner + if err := ctx.ShouldBindJSON(&banner); err != nil { + global.GVA_LOG.Error("参数错误" + err.Error()) + r.FailWithMessage("参数错误"+err.Error(), ctx) + return + } + + err := bannerService.UpdateBannerStatus(&banner) + if err != nil { + global.GVA_LOG.Error("更新失败" + err.Error()) + r.FailWithMessage("更新失败"+err.Error(), ctx) + return + } + + r.OkWithMessage("更新成功", ctx) +} diff --git a/core/server.go b/core/server.go index 1d2cc5e..bdac93f 100644 --- a/core/server.go +++ b/core/server.go @@ -33,7 +33,7 @@ func RunWindowsServer() { // 保证文本顺序输出 // In order to ensure that the text order output can be deleted time.Sleep(10 * time.Microsecond) - global.GVA_LOG.Info("server.exe.exe run success on ", zap.String("address", address)) + global.GVA_LOG.Info("server run success on ", zap.String("address", address)) global.GVA_LOG.Error(s.ListenAndServe().Error()) } diff --git a/router/system/banner.go b/router/system/banner.go index 2c90647..c78d729 100644 --- a/router/system/banner.go +++ b/router/system/banner.go @@ -16,10 +16,10 @@ func (s *BannerRouter) InitBannerRouter(Router *gin.RouterGroup) { bannerApi := v1.ApiGroupApp.SystemApiGroup.BannerApi { - hospitalRouter.POST("", bannerApi.CreateBanner) // 创建医院 - hospitalRouter.DELETE("", bannerApi.DeleteBanner) // 删除医院 - hospitalRouter.PUT("", bannerApi.UpdateBanner) // 更新医院 - + hospitalRouter.POST("", bannerApi.CreateBanner) // 创建医院 + hospitalRouter.DELETE("", bannerApi.DeleteBanner) // 删除医院 + hospitalRouter.PUT("", bannerApi.UpdateBanner) // 更新医院 + hospitalRouter.PUT("status", bannerApi.UpdateBannerStatus) // 更新医院状态 } { publicRouter.GET("list", bannerApi.GetBannerList) // 获取医院列表 diff --git a/service/system/banner.go b/service/system/banner.go index 022ea9c..ad4fb0b 100644 --- a/service/system/banner.go +++ b/service/system/banner.go @@ -35,3 +35,8 @@ func (b BannerService) GetBannerById(id string) (banner *common.Banner, err erro err = global.GVA_DB.Where("id = ?", id).First(&banner).Error return } + +// UpdateBannerStatus 更新轮播图状态 +func (b BannerService) UpdateBannerStatus(c *common.Banner) (err error) { + return global.GVA_DB.Model(&c).Update("status", c.Status).Error +}