mirror of
https://github.com/ProudMuBai/GoFilm.git
synced 2026-02-14 05:54:40 +08:00
add new features
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"server/plugin/SystemInit"
|
||||
"server/plugin/common/util"
|
||||
"server/plugin/spider"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func ManageIndex(c *gin.Context) {
|
||||
@@ -235,6 +236,99 @@ 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) {
|
||||
idStr := c.Query("id")
|
||||
if idStr == "" {
|
||||
system.Failed("Banner信息获取失败, ID信息异常", c)
|
||||
return
|
||||
}
|
||||
id, err := strconv.ParseInt(idStr, 10, 64)
|
||||
if err != nil {
|
||||
system.Failed("删除失败,参数类型异常", 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
|
||||
}
|
||||
bl := logic.ML.GetBanners()
|
||||
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) {
|
||||
idStr := c.Query("id")
|
||||
if idStr == "" {
|
||||
system.Failed("Banner信息获取失败, ID信息异常", c)
|
||||
return
|
||||
}
|
||||
id, err := strconv.ParseInt(idStr, 10, 64)
|
||||
if err != nil {
|
||||
system.Failed("删除失败,参数类型异常", 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