This commit is contained in:
mubai
2024-10-30 23:41:50 +08:00
parent d1433e4b5b
commit 57323dae2f
48 changed files with 1134 additions and 425 deletions

View File

@@ -162,3 +162,10 @@ func FilmClassify(c *gin.Context) {
"content": logic.IL.GetFilmClassify(pid, &page),
}, "分类影片信息获取成功", c)
}
// IndexCacheDel 删除首页缓存数据
func IndexCacheDel(c *gin.Context) {
// 删除首页缓存
logic.IL.ClearIndexCache()
system.SuccessOnlyMsg("首页缓存数据已清除!!!", c)
}

View File

@@ -9,7 +9,6 @@ import (
"server/plugin/SystemInit"
"server/plugin/common/util"
"server/plugin/spider"
"strconv"
)
func ManageIndex(c *gin.Context) {
@@ -246,16 +245,11 @@ func BannerList(c *gin.Context) {
// BannerFind 返回ID对应的横幅信息
func BannerFind(c *gin.Context) {
idStr := c.Query("id")
if idStr == "" {
id := c.Query("id")
if id == "" {
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 {
@@ -273,7 +267,13 @@ func BannerAdd(c *gin.Context) {
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)
@@ -307,16 +307,11 @@ func BannerUpdate(c *gin.Context) {
// BannerDel 删除海报数据
func BannerDel(c *gin.Context) {
idStr := c.Query("id")
if idStr == "" {
id := c.Query("id")
if id == "" {
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 {

View File

@@ -103,6 +103,22 @@ func CoverFilmClass(c *gin.Context) {
system.SuccessOnlyMsg("影视分类信息重置成功, 请稍等片刻后刷新页面", c)
}
// DirectedSpider 采集指定的影片
func DirectedSpider(c *gin.Context) {
}
// SingleUpdateSpider 单一影片更新采集
func SingleUpdateSpider(c *gin.Context) {
// 获取影片对应的唯一标识
id := c.Query("id")
if id == "" {
system.Failed("参数异常, 资源站标识不能为空", c)
return
}
// 通过ID对指定影片进行同步更新
}
// 校验密码有效性
func verifyPassword(c *gin.Context, password string) bool {
// 获取已登录的用户信息

View File

@@ -7,6 +7,7 @@ import (
"server/config"
"server/model/system"
"server/plugin/db"
"server/plugin/spider"
"strings"
)
@@ -52,11 +53,19 @@ func (i *IndexLogic) IndexPage() map[string]interface{} {
list = append(list, item)
}
Info["content"] = list
// 3. 获取首页轮播数据
Info["banners"] = system.GetBanners()
// 不存在首页数据缓存时将查询数据缓存到redis中
system.DataCache(config.IndexCacheKey, Info)
return Info
}
// ClearIndexCache 删除首页数据缓存
func (i *IndexLogic) ClearIndexCache() {
// 更新成功后删除首页缓存
spider.ClearCache()
}
// GetFilmDetail 影片详情信息页面处理
func (i *IndexLogic) GetFilmDetail(id int) system.MovieDetailVo {
// 通过Id 获取影片search信息

View File

@@ -29,10 +29,8 @@ func main() {
}
func start() {
// 启动前先执行数据库内容的初始化工作
DefaultDataInit()
SystemInit.BannersInit()
// 开启路由监听
r := router.SetupRouter()
_ = r.Run(fmt.Sprintf(":%s", config.ListenerPort))
@@ -45,7 +43,9 @@ func DefaultDataInit() {
SystemInit.TableInIt()
// 初始化网站基本配置信息
SystemInit.BasicConfigInit()
// 初始化影视来源列表信息
SystemInit.SpiderInit()
// 初始化轮播组件信息
SystemInit.BannersInit()
}
// 初始化影视来源列表信息
SystemInit.SpiderInit()
}

View File

@@ -21,7 +21,8 @@ type BasicConfig struct {
// Banner 首页横幅信息
type Banner struct {
Id int64 `json:"id"` // 绑定所属影片Id
Id string `json:"id"` // 唯一标识
Mid int64 `json:"mid"` // 绑定所属影片Id
Name string `json:"name"` // 影片名称
Year int64 `json:"year"` // 上映年份
CName string `json:"cName"` // 分类名称

View File

@@ -1,6 +1,9 @@
package SystemInit
import "server/model/system"
import (
"server/model/system"
"server/plugin/common/util"
)
// SiteConfigInit 网站配置初始化
func SiteConfigInit() {
@@ -23,10 +26,10 @@ func BasicConfigInit() {
func BannersInit() {
var bl = system.Banners{
system.Banner{Name: "樱花庄的宠物女孩", Year: 2020, CName: "日韩动漫", Poster: "https://s2.loli.net/2024/02/21/Wt1QDhabdEI7HcL.jpg", Picture: "https://img.bfzypic.com/upload/vod/20230424-43/06e79232a4650aea00f7476356a49847.jpg", Remark: "已完结"},
system.Banner{Name: "从零开始的异世界生活", Year: 2020, CName: "日韩动漫", Poster: "https://s2.loli.net/2024/02/21/Wt1QDhabdEI7HcL.jpg", Picture: "https://img.bfzypic.com/upload/vod/20230424-43/06e79232a4650aea00f7476356a49847.jpg", Remark: "已完结"},
system.Banner{Name: "五等分的花嫁", Year: 2020, CName: "日韩动漫", Poster: "https://s2.loli.net/2024/02/21/Wt1QDhabdEI7HcL.jpg", Picture: "https://img.bfzypic.com/upload/vod/20230424-43/06e79232a4650aea00f7476356a49847.jpg", Remark: "已完结"},
system.Banner{Name: "我的青春恋爱物语果然有问题", Year: 2020, CName: "日韩动漫", Poster: "https://s2.loli.net/2024/02/21/Wt1QDhabdEI7HcL.jpg", Picture: "https://img.bfzypic.com/upload/vod/20230424-43/06e79232a4650aea00f7476356a49847.jpg", Remark: "已完结"},
system.Banner{Id: util.GenerateSalt(), Name: "樱花庄的宠物女孩", Year: 2020, CName: "日韩动漫", Poster: "https://s2.loli.net/2024/02/21/Wt1QDhabdEI7HcL.jpg", Picture: "https://img.bfzypic.com/upload/vod/20230424-43/06e79232a4650aea00f7476356a49847.jpg", Remark: "已完结"},
system.Banner{Id: util.GenerateSalt(), Name: "从零开始的异世界生活", Year: 2020, CName: "日韩动漫", Poster: "https://s2.loli.net/2024/02/21/UkpdhIRO12fsy6C.jpg", Picture: "https://img.bfzypic.com/upload/vod/20230424-43/06e79232a4650aea00f7476356a49847.jpg", Remark: "已完结"},
system.Banner{Id: util.GenerateSalt(), Name: "五等分的花嫁", Year: 2020, CName: "日韩动漫", Poster: "https://s2.loli.net/2024/02/21/wXJr59Zuv4tcKNp.jpg", Picture: "https://img.bfzypic.com/upload/vod/20230424-43/06e79232a4650aea00f7476356a49847.jpg", Remark: "已完结"},
system.Banner{Id: util.GenerateSalt(), Name: "我的青春恋爱物语果然有问题", Year: 2020, CName: "日韩动漫", Poster: "https://s2.loli.net/2024/02/21/oMAGzSliK2YbhRu.jpg", Picture: "https://img.bfzypic.com/upload/vod/20230424-43/06e79232a4650aea00f7476356a49847.jpg", Remark: "已完结"},
}
_ = system.SaveBanners(bl)
}

View File

@@ -123,6 +123,15 @@ func (jc *JsonCollect) CustomSearch(r util.RequestInfo) {
// 设置搜索参数 wd (影片名模糊搜索)
}
// GetSingleFilm 获取单一影片信息
func (jc *JsonCollect) GetSingleFilm(r util.RequestInfo, ids string) {
// 设置固定参数 ac 请求类型 pg 页数
r.Params.Set("ac", "detail")
r.Params.Set("pg", "1")
r.Params.Set("ids", ids)
//
}
// ------------------------------------------------- XML Collect -------------------------------------------------
// XmlCollect 处理返回值为XML格式的采集数据

View File

@@ -17,6 +17,7 @@ func SetupRouter() *gin.Engine {
r.Static(config.FilmPictureUrlPath, config.FilmPictureUploadDir)
r.GET(`/index`, controller.Index)
r.GET(`/cache/del`, controller.IndexCacheDel)
r.GET(`/config/basic`, controller.SiteBasicConfig)
r.GET(`/navCategory`, controller.CategoriesInfo)
r.GET(`/filmDetail`, controller.FilmDetail)
@@ -49,7 +50,7 @@ func SetupRouter() *gin.Engine {
banner.GET(`/list`, controller.BannerList)
banner.GET(`/find`, controller.BannerFind)
banner.POST(`/add`, controller.BannerAdd)
banner.GET(`/update`, controller.BannerUpdate)
banner.POST(`/update`, controller.BannerUpdate)
banner.GET(`/del`, controller.BannerDel)
}