mirror of
https://github.com/ProudMuBai/GoFilm.git
synced 2026-02-12 21:14:41 +08:00
search tag fix
This commit is contained in:
@@ -4,7 +4,7 @@ import AutoImport from 'unplugin-auto-import/vite'
|
||||
import Components from 'unplugin-vue-components/vite'
|
||||
import {ElementPlusResolver} from "unplugin-vue-components/resolvers";
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
|
||||
export default defineConfig({
|
||||
// 本地测试环境
|
||||
server: {
|
||||
@@ -12,8 +12,8 @@ export default defineConfig({
|
||||
port: 3600,
|
||||
proxy: {
|
||||
"/api": {
|
||||
// target: `http://127.0.0.1:3601`,
|
||||
target: `http://1.94.30.26:3601`,
|
||||
target: `http://127.0.0.1:3601`,
|
||||
// target: `http://1.94.30.26:3601`,
|
||||
changeOrigin: true, // 允许跨域
|
||||
rewrite: path => path.replace(/^\/api/, '')
|
||||
}
|
||||
|
||||
@@ -1,6 +1,17 @@
|
||||
#bind 127.0.0.1
|
||||
#bind 0.0.0.0
|
||||
daemonize no
|
||||
requirepass root
|
||||
|
||||
appendonly yes
|
||||
auto-aof-rewrite-percentage 100
|
||||
auto-aof-rewrite-min-size 64mb
|
||||
|
||||
# save 900 1
|
||||
# save 300 10
|
||||
# save 60 10000
|
||||
# dir /data/
|
||||
# dbfilename dump.rdb
|
||||
|
||||
|
||||
tcp-keepalive 300
|
||||
stop-writes-on-bgsave-error no
|
||||
@@ -54,8 +54,8 @@ services:
|
||||
- film-network
|
||||
command: [
|
||||
'mysqld',
|
||||
'--default-authentication-plugin=mysql_native_password',
|
||||
'--innodb-buffer-pool-size=80M',
|
||||
'--default-storage-engine=INNODB',
|
||||
'--innodb-buffer-pool-size=128M',
|
||||
'--character-set-server=utf8mb4',
|
||||
'--collation-server=utf8mb4_unicode_ci',
|
||||
'--default-time-zone=+8:00',
|
||||
@@ -69,10 +69,11 @@ services:
|
||||
ports:
|
||||
- 3620:6379
|
||||
volumes:
|
||||
- /opt/film/data/redis/redis.conf:/usr/local/etc/redis/redis.conf
|
||||
- /opt/film/data/redis/redis.conf:/etc/redis/redis.conf
|
||||
- /opt/film/data/redis/data:/data
|
||||
networks:
|
||||
- film-network
|
||||
command: redis-server /usr/local/etc/redis/redis.conf
|
||||
command: redis-server /etc/redis/redis.conf
|
||||
networks:
|
||||
film-network:
|
||||
driver: bridge
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"server/logic"
|
||||
"server/model/system"
|
||||
"server/plugin/spider"
|
||||
@@ -17,41 +16,25 @@ import (
|
||||
func FilmCronTaskList(c *gin.Context) {
|
||||
tl := logic.CL.GetFilmCrontab()
|
||||
if len(tl) <= 0 {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": "暂无任务定时任务信息",
|
||||
})
|
||||
system.Failed("暂无任务定时任务信息", c)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusOk,
|
||||
"data": tl,
|
||||
})
|
||||
system.Success(tl, "定时任务列表获取成功!!!", c)
|
||||
}
|
||||
|
||||
// GetFilmCronTask 通过Id获取对应的定时任务信息
|
||||
func GetFilmCronTask(c *gin.Context) {
|
||||
id := c.DefaultQuery("id", "")
|
||||
if id == "" {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": "定时任务信息获取失败,任务Id不能为空",
|
||||
})
|
||||
system.Failed("定时任务信息获取失败,任务Id不能为空", c)
|
||||
return
|
||||
}
|
||||
task, err := logic.CL.GetFilmCrontabById(id)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": fmt.Sprint("定时任务信息获取失败", err.Error()),
|
||||
})
|
||||
system.Failed(fmt.Sprint("定时任务信息获取失败", err.Error()), c)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusOk,
|
||||
"data": task,
|
||||
})
|
||||
system.Success(task, "定时任务详情获取成功!!!", c)
|
||||
}
|
||||
|
||||
// FilmCronAdd 添加定时任务
|
||||
@@ -59,35 +42,22 @@ func FilmCronAdd(c *gin.Context) {
|
||||
var vo = system.FilmCronVo{}
|
||||
// 获取请求参数
|
||||
if err := c.ShouldBindJSON(&vo); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": "请求参数异常",
|
||||
})
|
||||
system.Failed("请求参数异常!!!", c)
|
||||
return
|
||||
}
|
||||
// 校验请求参数
|
||||
if err := validTaskAddVo(vo); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": err.Error(),
|
||||
})
|
||||
system.Failed(err.Error(), c)
|
||||
return
|
||||
}
|
||||
// 去除cron表达式左右空格
|
||||
vo.Spec = strings.TrimSpace(vo.Spec)
|
||||
// 执行 定时任务信息保存逻辑
|
||||
if err := logic.CL.AddFilmCrontab(vo); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": fmt.Sprint("定时任务添加失败: ", err.Error()),
|
||||
})
|
||||
system.Failed(fmt.Sprint("定时任务添加失败: ", err.Error()), c)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusOk,
|
||||
"message": "定时任务添加成功",
|
||||
})
|
||||
|
||||
system.SuccessOnlyMsg("定时任务添加成功", c)
|
||||
}
|
||||
|
||||
// FilmCronUpdate 更新定时任务信息
|
||||
@@ -95,40 +65,28 @@ func FilmCronUpdate(c *gin.Context) {
|
||||
var t = system.FilmCollectTask{}
|
||||
// 获取请求参数
|
||||
if err := c.ShouldBindJSON(&t); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": "请求参数异常",
|
||||
})
|
||||
system.Failed("请求参数异常!!!", c)
|
||||
return
|
||||
}
|
||||
// 校验必要参数
|
||||
if err := validTaskInfo(t); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": err.Error(),
|
||||
})
|
||||
system.Failed(err.Error(), c)
|
||||
return
|
||||
}
|
||||
// 获取未更新的task信息
|
||||
task, err := logic.CL.GetFilmCrontabById(t.Id)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": fmt.Sprint("更新失败: ", err.Error()),
|
||||
})
|
||||
system.Failed(fmt.Sprint("更新失败: ", err.Error()), c)
|
||||
return
|
||||
}
|
||||
// 将task的可变更属性进行变更
|
||||
// 将task的可变更属性进行更新
|
||||
task.Ids = t.Ids
|
||||
task.Time = t.Time
|
||||
task.State = t.State
|
||||
task.Remark = t.Remark
|
||||
// 将变更后的task更新到系统中
|
||||
logic.CL.UpdateFilmCron(task)
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusOk,
|
||||
"message": fmt.Sprintf("定时任务[%s]更新成功", task.Id),
|
||||
})
|
||||
system.SuccessOnlyMsg(fmt.Sprintf("定时任务[%s]更新成功", task.Id), c)
|
||||
}
|
||||
|
||||
// ChangeTaskState 开启 | 关闭Id 对应的定时任务
|
||||
@@ -136,54 +94,35 @@ func ChangeTaskState(c *gin.Context) {
|
||||
var t = system.FilmCollectTask{}
|
||||
// 获取请求参数
|
||||
if err := c.ShouldBindJSON(&t); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": "请求参数异常",
|
||||
})
|
||||
system.Failed("请求参数异常!!!", c)
|
||||
return
|
||||
}
|
||||
// 获取未更新的task信息
|
||||
task, err := logic.CL.GetFilmCrontabById(t.Id)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": fmt.Sprint("更新失败: ", err.Error()),
|
||||
})
|
||||
system.Failed(fmt.Sprint("更新失败: ", err.Error()), c)
|
||||
return
|
||||
}
|
||||
// 修改task的状态
|
||||
task.State = t.State
|
||||
// 将变更后的task更新到系统中
|
||||
logic.CL.UpdateFilmCron(task)
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusOk,
|
||||
"message": fmt.Sprintf("定时任务[%s]更新成功", task.Id),
|
||||
})
|
||||
system.SuccessOnlyMsg(fmt.Sprintf("定时任务[%s]更新成功", task.Id), c)
|
||||
}
|
||||
|
||||
// DelFilmCron 删除定时任务
|
||||
func DelFilmCron(c *gin.Context) {
|
||||
id := c.DefaultQuery("id", "")
|
||||
if id == "" {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": "删除失败,任务Id不能为空",
|
||||
})
|
||||
system.Failed("定时任务清除失败, 任务ID不能为空", c)
|
||||
return
|
||||
}
|
||||
// 如果Id不为空则执行删除逻辑
|
||||
if err := logic.CL.DelFilmCrontab(id); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": err.Error(),
|
||||
})
|
||||
system.Failed(err.Error(), c)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusOk,
|
||||
"message": fmt.Sprintf("定时任务[%s]已删除", id),
|
||||
})
|
||||
|
||||
system.SuccessOnlyMsg(fmt.Sprintf("定时任务[%s]已删除", id), c)
|
||||
}
|
||||
|
||||
// -------------------------------------------------- 参数校验 --------------------------------------------------
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"server/logic"
|
||||
"server/model/system"
|
||||
"server/plugin/spider"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
@@ -135,6 +136,7 @@ func FindFilmClass(c *gin.Context) {
|
||||
system.Success(class, "分类信息查找成功", c)
|
||||
}
|
||||
|
||||
// UpdateFilmClass 更新指定分类的影片数据
|
||||
func UpdateFilmClass(c *gin.Context) {
|
||||
// 获取修改后的分类信息
|
||||
var class = system.CategoryTree{}
|
||||
@@ -151,6 +153,8 @@ func UpdateFilmClass(c *gin.Context) {
|
||||
system.Failed(err.Error(), c)
|
||||
return
|
||||
}
|
||||
// 更新成功后删除首页缓存
|
||||
spider.ClearCache()
|
||||
system.SuccessOnlyMsg("影片分类信息更新成功", c)
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"server/logic"
|
||||
"server/model/system"
|
||||
"server/plugin/SystemInit"
|
||||
@@ -13,10 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func ManageIndex(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusOk,
|
||||
"message": "hahah",
|
||||
})
|
||||
system.SuccessOnlyMsg("后台管理中心", c)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -24,10 +20,7 @@ func ManageIndex(c *gin.Context) {
|
||||
|
||||
// FilmSourceList 采集站点信息
|
||||
func FilmSourceList(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusOk,
|
||||
"data": logic.ML.GetFilmSourceList(),
|
||||
})
|
||||
system.Success(logic.ML.GetFilmSourceList(), "影视源站点信息获取成功", c)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -35,169 +28,111 @@ func FilmSourceList(c *gin.Context) {
|
||||
func FindFilmSource(c *gin.Context) {
|
||||
id := c.Query("id")
|
||||
if id == "" {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": "参数异常, 资源站标识不能为空",
|
||||
})
|
||||
system.Failed("参数异常, 资源站标识不能为空", c)
|
||||
return
|
||||
}
|
||||
fs := logic.ML.GetFilmSource(id)
|
||||
if fs == nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": "数据异常,资源站信息不存在",
|
||||
})
|
||||
system.Failed("数据异常,资源站信息不存在", c)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusOk,
|
||||
"data": fs,
|
||||
})
|
||||
system.Success(fs, "原站点详情信息查找成功", c)
|
||||
}
|
||||
|
||||
// FilmSourceAdd 添加采集源
|
||||
func FilmSourceAdd(c *gin.Context) {
|
||||
var s = system.FilmSource{}
|
||||
// 获取请求参数
|
||||
if err := c.ShouldBindJSON(&s); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": "请求参数异常",
|
||||
})
|
||||
system.Failed("请求参数异常", c)
|
||||
return
|
||||
}
|
||||
// 校验必要参数
|
||||
if err := validFilmSource(s); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": err.Error(),
|
||||
})
|
||||
system.Failed(err.Error(), c)
|
||||
return
|
||||
}
|
||||
// 如果采集站开启图片同步, 且采集站为附属站点则返回错误提示
|
||||
if s.SyncPictures && (s.Grade == system.SlaveCollect) {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": "附属站点无法开启图片同步功能",
|
||||
})
|
||||
system.Failed("附属站点无法开启图片同步功能", c)
|
||||
return
|
||||
}
|
||||
// 执行 spider
|
||||
if err := spider.CollectApiTest(s); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": "资源接口测试失败, 请确认接口有效再添加",
|
||||
})
|
||||
system.Failed("资源接口测试失败, 请确认接口有效再添加", c)
|
||||
return
|
||||
}
|
||||
// 测试通过后将资源站信息添加到list
|
||||
if err := logic.ML.SaveFilmSource(s); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": fmt.Sprint("资源站添加失败: ", err.Error()),
|
||||
})
|
||||
system.Failed(fmt.Sprint("资源站添加失败: ", err.Error()), c)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusOk,
|
||||
"message": "添加成功",
|
||||
})
|
||||
system.SuccessOnlyMsg("添加成功", c)
|
||||
}
|
||||
|
||||
func FilmSourceUpdate(c *gin.Context) {
|
||||
var s = system.FilmSource{}
|
||||
// 获取请求参数
|
||||
if err := c.ShouldBindJSON(&s); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": "请求参数异常",
|
||||
})
|
||||
system.Failed("请求参数异常", c)
|
||||
return
|
||||
}
|
||||
// 校验必要参数
|
||||
if err := validFilmSource(s); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": err.Error(),
|
||||
})
|
||||
system.Failed(err.Error(), c)
|
||||
return
|
||||
}
|
||||
// 如果采集站开启图片同步, 且采集站为附属站点则返回错误提示
|
||||
if s.SyncPictures && (s.Grade == system.SlaveCollect) {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": "附属站点无法开启图片同步功能",
|
||||
})
|
||||
system.Failed("附属站点无法开启图片同步功能", c)
|
||||
return
|
||||
}
|
||||
// 校验Id信息是否为空
|
||||
if s.Id == "" {
|
||||
c.JSON(http.StatusOK, gin.H{"status": StatusFailed, "message": "参数异常, 资源站标识不能为空"})
|
||||
system.Failed("参数异常, 资源站标识不能为空", c)
|
||||
return
|
||||
}
|
||||
fs := logic.ML.GetFilmSource(s.Id)
|
||||
if fs == nil {
|
||||
c.JSON(http.StatusOK, gin.H{"status": StatusFailed, "message": "数据异常,资源站信息不存在"})
|
||||
system.Failed("数据异常,资源站信息不存在", c)
|
||||
return
|
||||
}
|
||||
// 如果 uri发生变更则执行spider测试
|
||||
if fs.Uri != s.Uri {
|
||||
// 执行 spider
|
||||
if err := spider.CollectApiTest(s); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": "资源接口测试失败, 请确认更新的数据接口是否有效",
|
||||
})
|
||||
system.Failed("资源接口测试失败, 请确认更新的数据接口是否有效", c)
|
||||
return
|
||||
}
|
||||
}
|
||||
// 更新资源站信息
|
||||
if err := logic.ML.UpdateFilmSource(s); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": fmt.Sprint("资源站更新失败: ", err.Error()),
|
||||
})
|
||||
system.Failed(fmt.Sprint("资源站更新失败: ", err.Error()), c)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusOk,
|
||||
"message": "更新成功",
|
||||
})
|
||||
|
||||
system.SuccessOnlyMsg("更新成功", c)
|
||||
}
|
||||
|
||||
func FilmSourceChange(c *gin.Context) {
|
||||
var s = system.FilmSource{}
|
||||
// 获取请求参数
|
||||
if err := c.ShouldBindJSON(&s); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": "请求参数异常",
|
||||
})
|
||||
system.Failed("请求参数异常", c)
|
||||
return
|
||||
}
|
||||
if s.Id == "" {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": "参数异常, 资源站标识不能为空",
|
||||
})
|
||||
system.Failed("参数异常, 资源站标识不能为空", c)
|
||||
return
|
||||
}
|
||||
// 查找对应的资源站点信息
|
||||
fs := logic.ML.GetFilmSource(s.Id)
|
||||
if fs == nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": "数据异常,资源站信息不存在",
|
||||
})
|
||||
system.Failed("数据异常,资源站信息不存在", c)
|
||||
return
|
||||
}
|
||||
// 如果采集站开启图片同步, 且采集站为附属站点则返回错误提示
|
||||
if s.SyncPictures && (fs.Grade == system.SlaveCollect) {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": "附属站点无法开启图片同步功能",
|
||||
})
|
||||
system.Failed("附属站点无法开启图片同步功能", c)
|
||||
return
|
||||
}
|
||||
if s.State != fs.State || s.SyncPictures != fs.SyncPictures {
|
||||
@@ -206,39 +141,24 @@ func FilmSourceChange(c *gin.Context) {
|
||||
Grade: fs.Grade, SyncPictures: s.SyncPictures, CollectType: fs.CollectType, State: s.State}
|
||||
// 更新资源站信息
|
||||
if err := logic.ML.UpdateFilmSource(s); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": fmt.Sprint("资源站更新失败: ", err.Error()),
|
||||
})
|
||||
system.Failed(fmt.Sprint("资源站更新失败: ", err.Error()), c)
|
||||
return
|
||||
}
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusOk,
|
||||
"message": "更新成功",
|
||||
})
|
||||
system.SuccessOnlyMsg("更新成功", c)
|
||||
}
|
||||
|
||||
func FilmSourceDel(c *gin.Context) {
|
||||
id := c.Query("id")
|
||||
if len(id) <= 0 {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": "资源站ID信息不能为空",
|
||||
})
|
||||
system.Failed("资源站ID信息不能为空", c)
|
||||
return
|
||||
}
|
||||
if err := logic.ML.DelFilmSource(id); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": fmt.Sprint("删除资源站失败: ", err.Error()),
|
||||
})
|
||||
system.Failed("删除资源站失败", c)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusOk,
|
||||
"message": "删除成功:",
|
||||
})
|
||||
system.SuccessOnlyMsg("删除成功", c)
|
||||
}
|
||||
|
||||
// FilmSourceTest 测试影视站点数据是否可用
|
||||
@@ -246,32 +166,20 @@ func FilmSourceTest(c *gin.Context) {
|
||||
var s = system.FilmSource{}
|
||||
// 获取请求参数
|
||||
if err := c.ShouldBindJSON(&s); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": "请求参数异常",
|
||||
})
|
||||
system.Failed("请求参数异常", c)
|
||||
return
|
||||
}
|
||||
// 校验必要参数
|
||||
if err := validFilmSource(s); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": err.Error(),
|
||||
})
|
||||
system.Failed(err.Error(), c)
|
||||
return
|
||||
}
|
||||
// 执行 spider
|
||||
if err := spider.CollectApiTest(s); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": err.Error(),
|
||||
})
|
||||
system.Failed(err.Error(), c)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusOk,
|
||||
"message": "测试成功!!!",
|
||||
})
|
||||
system.SuccessOnlyMsg("测试成功!!!", c)
|
||||
}
|
||||
|
||||
// GetNormalFilmSource 获取状态为启用的采集站信息
|
||||
@@ -283,10 +191,7 @@ func GetNormalFilmSource(c *gin.Context) {
|
||||
l = append(l, system.FilmTaskOptions{Id: v.Id, Name: v.Name})
|
||||
}
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusOk,
|
||||
"data": l,
|
||||
})
|
||||
system.Success(l, "影视源信息获取成功", c)
|
||||
}
|
||||
|
||||
// ------------------------------------------------------ 站点基本配置 ------------------------------------------------------
|
||||
@@ -303,47 +208,31 @@ func UpdateSiteBasic(c *gin.Context) {
|
||||
if err := c.ShouldBindJSON(&bc); err == nil {
|
||||
// 对参数进行校验
|
||||
if !util.ValidDomain(bc.Domain) && !util.ValidIPHost(bc.Domain) {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": "域名格式校验失败: ",
|
||||
})
|
||||
system.Failed("域名格式校验失败", c)
|
||||
return
|
||||
}
|
||||
if len(bc.SiteName) <= 0 {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": "网站名称不能为空: ",
|
||||
})
|
||||
system.Failed("网站名称不能为空", c)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"status": StatusOk, "message": fmt.Sprint("参数提交失败: ", err)})
|
||||
system.Failed(fmt.Sprint("请求参数异常: ", err), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 保存更新后的配置信息
|
||||
if err := logic.ML.UpdateSiteBasic(bc); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": fmt.Sprint("网站配置更新失败: ", err),
|
||||
})
|
||||
system.Failed(fmt.Sprint("网站配置更新失败: ", err), c)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusOk,
|
||||
"message": "更新成功: ",
|
||||
})
|
||||
return
|
||||
system.SuccessOnlyMsg("更新成功", c)
|
||||
}
|
||||
|
||||
// ResetSiteBasic 重置网站配置信息为初始化状态
|
||||
func ResetSiteBasic(c *gin.Context) {
|
||||
// 执行配置初始化方法直接覆盖当前基本配置信息
|
||||
SystemInit.BasicConfigInit()
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusOk,
|
||||
"message": "重置成功: ",
|
||||
})
|
||||
system.SuccessOnlyMsg("配置信息重置成功", c)
|
||||
}
|
||||
|
||||
// ------------------------------------------------------ 参数校验 ------------------------------------------------------
|
||||
@@ -368,7 +257,3 @@ func validFilmSource(fs system.FilmSource) error {
|
||||
return errors.New("资源类型异常, 未知的资源类型")
|
||||
}
|
||||
}
|
||||
|
||||
func apiValidityCheck() {
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package controller
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"server/logic"
|
||||
"server/model/system"
|
||||
"strconv"
|
||||
@@ -14,32 +13,20 @@ func CollectFilm(c *gin.Context) {
|
||||
id := c.DefaultQuery("id", "")
|
||||
hourStr := c.DefaultQuery("h", "0")
|
||||
if id == "" || hourStr == "0" {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": "采集任务开启失败, 缺乏必要参数",
|
||||
})
|
||||
system.Failed("采集任务开启失败, 缺乏必要参数", c)
|
||||
return
|
||||
}
|
||||
h, err := strconv.Atoi(hourStr)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": "采集任务开启失败, hour(时长)参数不符合规范",
|
||||
})
|
||||
system.Failed("采集任务开启失败, 采集(时长)不符合规范", c)
|
||||
return
|
||||
}
|
||||
// 执行采集逻处理逻辑
|
||||
if err = logic.SL.StartCollect(id, h); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": fmt.Sprint("采集任务开启失败: ", err.Error()),
|
||||
})
|
||||
system.Failed(fmt.Sprint("采集任务开启失败: ", err.Error()), c)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusOk,
|
||||
"message": "采集任务已成功开启!!!",
|
||||
})
|
||||
system.SuccessOnlyMsg("采集任务已成功开启!!!", c)
|
||||
}
|
||||
|
||||
// StarSpider 开启并执行采集任务
|
||||
@@ -47,81 +34,48 @@ func StarSpider(c *gin.Context) {
|
||||
var cp system.CollectParams
|
||||
// 获取请求参数
|
||||
if err := c.ShouldBindJSON(&cp); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": "请求参数异常",
|
||||
})
|
||||
system.Failed("请求参数异常!!!", c)
|
||||
return
|
||||
}
|
||||
if cp.Time == 0 {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": "采集开启失败,采集时长不能为0",
|
||||
})
|
||||
system.Failed("采集开启失败,采集时长不能为0", c)
|
||||
return
|
||||
}
|
||||
// 根据 Batch 执行对应的逻辑
|
||||
if cp.Batch {
|
||||
// 执行批量采集
|
||||
if cp.Ids == nil || len(cp.Ids) <= 0 {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": "批量采集开启失败, 关联的资源站信息为空",
|
||||
})
|
||||
system.Failed("批量采集开启失败, 关联的资源站信息为空", c)
|
||||
return
|
||||
}
|
||||
// 执行批量采集
|
||||
logic.SL.BatchCollect(cp.Time, cp.Ids)
|
||||
} else {
|
||||
if len(cp.Id) <= 0 {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": "批量采集开启失败, 资源站Id获取失败",
|
||||
})
|
||||
system.Failed("批量采集开启失败, 资源站Id获取失败", c)
|
||||
return
|
||||
}
|
||||
if err := logic.SL.StartCollect(cp.Id, cp.Time); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": fmt.Sprint("采集任务开启失败: ", err.Error()),
|
||||
})
|
||||
system.Failed(fmt.Sprint("采集任务开启失败: ", err.Error()), c)
|
||||
return
|
||||
}
|
||||
}
|
||||
// 返回成功执行的信息
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusOk,
|
||||
"message": "采集任务已成功开启!!!",
|
||||
})
|
||||
system.SuccessOnlyMsg("采集任务已成功开启!!!", c)
|
||||
}
|
||||
|
||||
// SpiderReset 重置影视数据, 清空库存, 从零开始
|
||||
func SpiderReset(c *gin.Context) {
|
||||
var cp system.CollectParams
|
||||
// 获取请求参数
|
||||
if err := c.ShouldBindJSON(&cp); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": "请求参数异常",
|
||||
})
|
||||
// 清空采集数据进行重新采集前校验输入的密码是否正确
|
||||
key := c.DefaultQuery("accessKey", "")
|
||||
// 如密码错误则不执行后续操作
|
||||
if len(key) <= 0 || key != "Re0" {
|
||||
system.Failed("重置失败, 密钥校验失败!!!", c)
|
||||
return
|
||||
}
|
||||
if cp.Time == 0 {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": "采集开启失败,采集时长不能为0",
|
||||
})
|
||||
return
|
||||
}
|
||||
// 后期加入一些前置验证
|
||||
if len(cp.Id) <= 0 {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": "SpiderReset Failed, 资源站Id获取失败",
|
||||
})
|
||||
return
|
||||
}
|
||||
logic.SL.ZeroCollect(cp.Time)
|
||||
// 前置校验通过则清空采集数据并对已启用站点进行 全量采集
|
||||
logic.SL.ZeroCollect(-1)
|
||||
system.SuccessOnlyMsg("影视数据已重置, 请耐心等待采集完成!!!", c)
|
||||
}
|
||||
|
||||
// CoverFilmClass 重置覆盖影片分类信息
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"log"
|
||||
"net/http"
|
||||
"server/config"
|
||||
"server/logic"
|
||||
"server/model/system"
|
||||
@@ -15,33 +14,20 @@ import (
|
||||
func Login(c *gin.Context) {
|
||||
var u system.User
|
||||
if err := c.ShouldBindJSON(&u); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": "数据格式异常!!!",
|
||||
})
|
||||
system.Failed("登录信息异常!!!", c)
|
||||
return
|
||||
}
|
||||
if len(u.UserName) <= 0 || len(u.Password) <= 0 {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": "用户名和密码信息不能为空!!!",
|
||||
})
|
||||
system.Failed("用户名和密码信息不能为空", c)
|
||||
return
|
||||
}
|
||||
token, err := logic.UL.UserLogin(u.UserName, u.Password)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": err.Error(),
|
||||
})
|
||||
system.Failed(err.Error(), c)
|
||||
return
|
||||
}
|
||||
c.Header("new-token", token)
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusOk,
|
||||
"message": "登录成功!!!",
|
||||
})
|
||||
return
|
||||
system.SuccessOnlyMsg("登录成功!!!", c)
|
||||
}
|
||||
|
||||
// Logout 退出登录
|
||||
@@ -49,29 +35,20 @@ func Logout(c *gin.Context) {
|
||||
// 获取已登录的用户信息
|
||||
v, ok := c.Get(config.AuthUserClaims)
|
||||
if !ok {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": "登录信息异常!!!",
|
||||
})
|
||||
system.Failed("请求失败,登录信息获取异常!!!", c)
|
||||
return
|
||||
}
|
||||
// 清除redis中存储的对应token
|
||||
uc, ok := v.(*system.UserClaims)
|
||||
if !ok {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": "登录信息异常!!!",
|
||||
})
|
||||
system.Failed("注销失败, 身份信息格式化异常!!!", c)
|
||||
return
|
||||
}
|
||||
err := system.ClearUserToken(uc.UserID)
|
||||
if err != nil {
|
||||
log.Println("user logOut err: ", err)
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusOk,
|
||||
"message": "logout success!!!",
|
||||
})
|
||||
system.SuccessOnlyMsg("已退出登录!!!", c)
|
||||
}
|
||||
|
||||
// UserPasswordChange 修改用户密码
|
||||
@@ -79,51 +56,33 @@ func UserPasswordChange(c *gin.Context) {
|
||||
// 接收密码修改参数
|
||||
var params map[string]string
|
||||
if err := c.ShouldBindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": "数据格式异常!!!",
|
||||
})
|
||||
system.Failed("参数校验失败!!!", c)
|
||||
return
|
||||
}
|
||||
// 校验参数是否存在空值
|
||||
if params["password"] == "" || params["newPassword"] == "" {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": "原密码和新密码不能为空!!!",
|
||||
})
|
||||
system.Failed("密码不能为空!!!", c)
|
||||
return
|
||||
}
|
||||
// 校验新密码是否符合规范
|
||||
if err := util.ValidPwd(params["newPassword"]); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": fmt.Sprint("密码格式校验失败: ", err.Error()),
|
||||
})
|
||||
system.Failed(fmt.Sprint("密码格式校验失败: ", err.Error()), c)
|
||||
return
|
||||
}
|
||||
// 获取已登录的用户信息
|
||||
v, ok := c.Get(config.AuthUserClaims)
|
||||
if !ok {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": "登录信息异常!!!",
|
||||
})
|
||||
system.Failed("操作失败,登录信息异常!!!", c)
|
||||
return
|
||||
}
|
||||
// 从context中获取用户的登录信息
|
||||
uc := v.(*system.UserClaims)
|
||||
if err := logic.UL.ChangePassword(uc.UserName, params["password"], params["newPassword"]); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusFailed,
|
||||
"message": fmt.Sprint("密码修改失败: ", err.Error()),
|
||||
})
|
||||
system.Failed(fmt.Sprint("密码修改失败: ", err.Error()), c)
|
||||
return
|
||||
}
|
||||
// 密码修改成功后不主动使token失效, 以免影响体验
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": StatusOk,
|
||||
"message": "密码修改成功",
|
||||
})
|
||||
system.SuccessOnlyMsg("密码修改成功", c)
|
||||
}
|
||||
|
||||
func UserInfo(c *gin.Context) {
|
||||
|
||||
@@ -18,7 +18,7 @@ func init() {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
// 初始化mysql
|
||||
// 初始化mysql00000
|
||||
err = db.InitMysql()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
||||
@@ -561,7 +561,13 @@ func GetTagsByTitle(pid int64, t string) []string {
|
||||
// 过滤分类tag
|
||||
switch t {
|
||||
case "Category":
|
||||
tags = db.Rdb.ZRevRange(db.Cxt, fmt.Sprintf(config.SearchTag, pid, t), 0, -1).Val()
|
||||
//tags = db.Rdb.ZRevRange(db.Cxt, fmt.Sprintf(config.SearchTag, pid, t), 0, -1).Val()
|
||||
// 获取所有展示的子分类
|
||||
for _, c := range GetChildrenTree(pid) {
|
||||
if c.Show {
|
||||
tags = append(tags, fmt.Sprintf("%s:%d", c.Name, c.Id))
|
||||
}
|
||||
}
|
||||
case "Plot":
|
||||
tags = db.Rdb.ZRevRange(db.Cxt, fmt.Sprintf(config.SearchTag, pid, t), 0, 10).Val()
|
||||
case "Area":
|
||||
|
||||
@@ -21,7 +21,7 @@ func FilmSourceInit() {
|
||||
return
|
||||
}
|
||||
var l []system.FilmSource = []system.FilmSource{
|
||||
{Id: util.GenerateSalt(), Name: "HD(lzBk)", Uri: `https://cj.lziapi.com/api.php/provide/vod/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true},
|
||||
{Id: util.GenerateSalt(), Name: "HD(lz)", Uri: `https://cj.lziapi.com/api.php/provide/vod/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true},
|
||||
{Id: util.GenerateSalt(), Name: "HD(sn)", Uri: `https://suoniapi.com/api.php/provide/vod/from/snm3u8/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true, Interval: 2000},
|
||||
{Id: util.GenerateSalt(), Name: "HD(bf)", Uri: `https://bfzyapi.com/api.php/provide/vod/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true, Interval: 2500},
|
||||
{Id: util.GenerateSalt(), Name: "HD(ff)", Uri: `http://cj.ffzyapi.com/api.php/provide/vod/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true},
|
||||
|
||||
@@ -20,7 +20,7 @@ func AuthToken() gin.HandlerFunc {
|
||||
authToken := c.Request.Header.Get("auth-token")
|
||||
// 如果没有登录信息则直接清退
|
||||
if authToken == "" {
|
||||
c.JSON(http.StatusUnauthorized, gin.H{"status": "ok", "message": "用户未授权,请先登录."})
|
||||
system.CustomResult(http.StatusUnauthorized, system.SUCCESS, nil, "用户未授权,请先登录", c)
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
@@ -30,20 +30,14 @@ func AuthToken() gin.HandlerFunc {
|
||||
t := system.GetUserTokenById(uc.UserID)
|
||||
// 如果 redis中获取的token为空则登录已过期需重新登录
|
||||
if len(t) <= 0 {
|
||||
c.JSON(http.StatusUnauthorized, gin.H{
|
||||
"status": "ok",
|
||||
"message": "身份验证信息已过期,请重新登录!!!",
|
||||
})
|
||||
system.CustomResult(http.StatusUnauthorized, system.SUCCESS, nil, "身份验证信息已失效,请重新登录!!!", c)
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
// 如果redis中存在对应token, 校验authToken是否与redis中的一致
|
||||
if t != authToken {
|
||||
// 如果不一致则证明authToken已经失效或在其他地方登录, 则需要重新登录
|
||||
c.JSON(http.StatusUnauthorized, gin.H{
|
||||
"status": "ok",
|
||||
"message": "账号在其它设备登录,身份验证信息失效,请重新登录!!!",
|
||||
})
|
||||
system.CustomResult(http.StatusUnauthorized, system.SUCCESS, nil, "账号在其它设备登录,身份验证信息失效,请重新登录!!!", c)
|
||||
c.Abort()
|
||||
return
|
||||
} else if err != nil && errors.Is(err, jwt.ErrTokenExpired) {
|
||||
@@ -56,7 +50,6 @@ func AuthToken() gin.HandlerFunc {
|
||||
uc, _ = system.ParseToken(newToken)
|
||||
c.Header("new-token", newToken)
|
||||
}
|
||||
|
||||
// 将UserClaims存放到context中
|
||||
c.Set(config.AuthUserClaims, uc)
|
||||
c.Next()
|
||||
|
||||
@@ -100,7 +100,7 @@ func HandleCollect(id string, h int) error {
|
||||
system.SyncFilmPicture()
|
||||
}
|
||||
// 每次成功执行完都清理redis中的相关API接口数据缓存
|
||||
clearCache()
|
||||
ClearCache()
|
||||
}
|
||||
|
||||
case system.CollectArticle, system.CollectActor, system.CollectRole, system.CollectWebSite:
|
||||
|
||||
@@ -85,7 +85,7 @@ func ValidSpec(spec string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// 清理API接口数据缓存
|
||||
func clearCache() {
|
||||
// ClearCache 清理API接口数据缓存
|
||||
func ClearCache() {
|
||||
system.RemoveCache(config.IndexCacheKey)
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ const (
|
||||
|
||||
//mysql服务配置信息 root:root 设置mysql账户的用户名和密码
|
||||
|
||||
MysqlDsn = "root:root@(192.168.20.10:3307)/FilmSite?charset=utf8mb4&parseTime=True&loc=Local"
|
||||
MysqlDsn = "root:root@(192.168.20.7:3306)/FilmSite?charset=utf8mb4&parseTime=True&loc=Local"
|
||||
|
||||
// MysqlDsn docker compose 环境下的链接信息 mysql:3306 为 docker compose 中 mysql服务对应的网络名称和端口
|
||||
//MysqlDsn = "root:root@(mysql:3306)/FilmSite?charset=utf8mb4&parseTime=True&loc=Local"
|
||||
@@ -98,7 +98,7 @@ const (
|
||||
RedisPassword redis访问密码
|
||||
RedisDBNo 使用第几号库
|
||||
*/
|
||||
RedisAddr = `192.168.20.10:6379`
|
||||
RedisAddr = `192.168.20.7:6379`
|
||||
RedisPassword = `root`
|
||||
RedisDBNo = 0
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"server/logic"
|
||||
"server/model/system"
|
||||
"server/plugin/spider"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
@@ -135,6 +136,7 @@ func FindFilmClass(c *gin.Context) {
|
||||
system.Success(class, "分类信息查找成功", c)
|
||||
}
|
||||
|
||||
// UpdateFilmClass 更新指定分类的影片数据
|
||||
func UpdateFilmClass(c *gin.Context) {
|
||||
// 获取修改后的分类信息
|
||||
var class = system.CategoryTree{}
|
||||
@@ -151,6 +153,8 @@ func UpdateFilmClass(c *gin.Context) {
|
||||
system.Failed(err.Error(), c)
|
||||
return
|
||||
}
|
||||
// 更新成功后删除首页缓存
|
||||
spider.ClearCache()
|
||||
system.SuccessOnlyMsg("影片分类信息更新成功", c)
|
||||
}
|
||||
|
||||
|
||||
@@ -561,7 +561,13 @@ func GetTagsByTitle(pid int64, t string) []string {
|
||||
// 过滤分类tag
|
||||
switch t {
|
||||
case "Category":
|
||||
tags = db.Rdb.ZRevRange(db.Cxt, fmt.Sprintf(config.SearchTag, pid, t), 0, -1).Val()
|
||||
//tags = db.Rdb.ZRevRange(db.Cxt, fmt.Sprintf(config.SearchTag, pid, t), 0, -1).Val()
|
||||
// 获取所有展示的子分类
|
||||
for _, c := range GetChildrenTree(pid) {
|
||||
if c.Show {
|
||||
tags = append(tags, fmt.Sprintf("%s:%d", c.Name, c.Id))
|
||||
}
|
||||
}
|
||||
case "Plot":
|
||||
tags = db.Rdb.ZRevRange(db.Cxt, fmt.Sprintf(config.SearchTag, pid, t), 0, 10).Val()
|
||||
case "Area":
|
||||
|
||||
@@ -100,7 +100,7 @@ func HandleCollect(id string, h int) error {
|
||||
system.SyncFilmPicture()
|
||||
}
|
||||
// 每次成功执行完都清理redis中的相关API接口数据缓存
|
||||
clearCache()
|
||||
ClearCache()
|
||||
}
|
||||
|
||||
case system.CollectArticle, system.CollectActor, system.CollectRole, system.CollectWebSite:
|
||||
|
||||
@@ -85,7 +85,7 @@ func ValidSpec(spec string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// 清理API接口数据缓存
|
||||
func clearCache() {
|
||||
// ClearCache 清理API接口数据缓存
|
||||
func ClearCache() {
|
||||
system.RemoveCache(config.IndexCacheKey)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user