mirror of
https://github.com/ProudMuBai/GoFilm.git
synced 2026-02-15 23:24:41 +08:00
update
This commit is contained in:
@@ -235,6 +235,95 @@ func ResetSiteBasic(c *gin.Context) {
|
||||
system.SuccessOnlyMsg("配置信息重置成功", c)
|
||||
}
|
||||
|
||||
// ------------------------------------------------------ 轮播数据配置 ------------------------------------------------------
|
||||
|
||||
// BannerList 获取轮播图数据
|
||||
func BannerList(c *gin.Context) {
|
||||
bl := logic.ML.GetBanners()
|
||||
system.Success(bl, "配置信息重置成功", c)
|
||||
}
|
||||
|
||||
// BannerFind 返回ID对应的横幅信息
|
||||
func BannerFind(c *gin.Context) {
|
||||
id := c.Query("id")
|
||||
if id == "" {
|
||||
system.Failed("Banner信息获取失败, ID信息异常", c)
|
||||
return
|
||||
}
|
||||
bl := logic.ML.GetBanners()
|
||||
for _, b := range bl {
|
||||
if b.Id == id {
|
||||
system.Success(b, "Banner信息获取成功", c)
|
||||
return
|
||||
}
|
||||
}
|
||||
system.Failed("Banner信息获取失败", c)
|
||||
}
|
||||
|
||||
// BannerAdd 添加海报数据
|
||||
func BannerAdd(c *gin.Context) {
|
||||
var b system.Banner
|
||||
if err := c.ShouldBindJSON(&b); err != nil {
|
||||
system.Failed("Banner参数提交异常", c)
|
||||
return
|
||||
}
|
||||
// 为新增的banner生成Id
|
||||
b.Id = util.GenerateSalt()
|
||||
bl := logic.ML.GetBanners()
|
||||
if len(bl) > 6 {
|
||||
system.Failed("Banners最大阈值为6, 无法添加新的banner信息", c)
|
||||
return
|
||||
}
|
||||
bl = append(bl, b)
|
||||
if err := logic.ML.SaveBanners(bl); err != nil {
|
||||
system.Failed(fmt.Sprintln("Banners信息添加失败,", err), c)
|
||||
return
|
||||
}
|
||||
system.SuccessOnlyMsg("海报信息添加成功", c)
|
||||
}
|
||||
|
||||
// BannerUpdate 更新海报数据
|
||||
func BannerUpdate(c *gin.Context) {
|
||||
var banner system.Banner
|
||||
if err := c.ShouldBindJSON(&banner); err != nil {
|
||||
system.Failed("Banner参数提交异常", c)
|
||||
return
|
||||
}
|
||||
bl := logic.ML.GetBanners()
|
||||
for i, b := range bl {
|
||||
if b.Id == banner.Id {
|
||||
bl[i] = banner
|
||||
if err := logic.ML.SaveBanners(bl); err != nil {
|
||||
system.Failed("海报信息更新失败", c)
|
||||
} else {
|
||||
system.SuccessOnlyMsg("海报信息更新成功", c)
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
system.Failed("海报信息更新失败, 未匹配对应Banner信息", c)
|
||||
}
|
||||
|
||||
// BannerDel 删除海报数据
|
||||
func BannerDel(c *gin.Context) {
|
||||
id := c.Query("id")
|
||||
if id == "" {
|
||||
system.Failed("Banner信息获取失败, ID信息异常", c)
|
||||
return
|
||||
}
|
||||
bl := logic.ML.GetBanners()
|
||||
for i, b := range bl {
|
||||
if b.Id == id {
|
||||
bl = append(bl[:i], bl[i+1:]...)
|
||||
_ = logic.ML.SaveBanners(bl)
|
||||
system.SuccessOnlyMsg("海报信息删除成功", c)
|
||||
return
|
||||
}
|
||||
}
|
||||
system.Failed("海报信息删除失败", c)
|
||||
}
|
||||
|
||||
// ------------------------------------------------------ 参数校验 ------------------------------------------------------
|
||||
func validFilmSource(fs system.FilmSource) error {
|
||||
// 资源名称不能为空 且长度不能超过20
|
||||
|
||||
Reference in New Issue
Block a user