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

@@ -3,6 +3,7 @@ package controller
import (
"fmt"
"github.com/gin-gonic/gin"
"server/config"
"server/logic"
"server/model/system"
"strconv"
@@ -64,13 +65,27 @@ func StarSpider(c *gin.Context) {
system.SuccessOnlyMsg("采集任务已成功开启!!!", c)
}
// ClearAllFilm 删除所有film信息
func ClearAllFilm(c *gin.Context) {
// 清空采集数据进行重新采集前校验输入的密码是否正确
pwd := c.DefaultQuery("password", "")
// 如密码错误则不执行后续操作
if !verifyPassword(c, pwd) {
system.Failed("重置失败, 密钥校验失败!!!", c)
return
}
// 删除已采集的所有影片信息
logic.SL.ClearFilms()
system.SuccessOnlyMsg("影视数据已删除!!!", c)
}
// SpiderReset 重置影视数据, 清空库存, 从零开始
func SpiderReset(c *gin.Context) {
// 清空采集数据进行重新采集前校验输入的密码是否正确
key := c.DefaultQuery("accessKey", "")
pwd := c.DefaultQuery("password", "")
// 如密码错误则不执行后续操作
if len(key) <= 0 || key != "Re0" {
system.Failed("重置失败, 密校验失败!!!", c)
if !verifyPassword(c, pwd) {
system.Failed("重置失败, 密校验失败!!!", c)
return
}
// 前置校验通过则清空采集数据并对已启用站点进行 全量采集
@@ -87,3 +102,33 @@ 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 {
// 获取已登录的用户信息
v, ok := c.Get(config.AuthUserClaims)
if !ok {
system.Failed("操作失败,登录信息异常!!!", c)
return false
}
// 从context中获取用户的登录信息
uc := v.(*system.UserClaims)
// 校验密码
return logic.UL.VerifyUserPassword(uc.UserID, password)
}