mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-29 18:00:51 +01:00
updated contributors
This commit is contained in:
@@ -56,7 +56,7 @@ func PutAction(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
action.UserId = services.GetCurrentUser(c).Id
|
||||
action.UserId = services.GetCurrentUserId(c)
|
||||
|
||||
if err := action.Add(); err != nil {
|
||||
HandleError(http.StatusInternalServerError, c, err)
|
||||
|
||||
@@ -3,13 +3,15 @@ package routes
|
||||
import (
|
||||
"crawlab/constants"
|
||||
"crawlab/model"
|
||||
"crawlab/services"
|
||||
"crawlab/services/challenge"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func GetChallengeList(c *gin.Context) {
|
||||
// 获取列表
|
||||
users, err := model.GetChallengeList(nil, 0, constants.Infinite, "create_ts")
|
||||
users, err := model.GetChallengeListWithAchieved(nil, 0, constants.Infinite, "create_ts", services.GetCurrentUserId(c))
|
||||
if err != nil {
|
||||
HandleError(http.StatusInternalServerError, c, err)
|
||||
return
|
||||
@@ -29,3 +31,15 @@ func GetChallengeList(c *gin.Context) {
|
||||
Total: total,
|
||||
})
|
||||
}
|
||||
|
||||
func CheckChallengeList(c *gin.Context) {
|
||||
uid := services.GetCurrentUserId(c)
|
||||
if err := challenge.CheckChallengeAndUpdateAll(uid); err != nil {
|
||||
HandleError(http.StatusInternalServerError, c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, Response{
|
||||
Status: "ok",
|
||||
Message: "success",
|
||||
})
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ func PutSchedule(c *gin.Context) {
|
||||
}
|
||||
|
||||
// 加入用户ID
|
||||
item.UserId = services.GetCurrentUser(c).Id
|
||||
item.UserId = services.GetCurrentUserId(c)
|
||||
|
||||
// 更新数据库
|
||||
if err := model.AddSchedule(item); err != nil {
|
||||
|
||||
@@ -189,6 +189,9 @@ func PutSpider(c *gin.Context) {
|
||||
// 将FileId置空
|
||||
spider.FileId = bson.ObjectIdHex(constants.ObjectIdNull)
|
||||
|
||||
// UserId
|
||||
spider.UserId = services.GetCurrentUserId(c)
|
||||
|
||||
// 爬虫目录
|
||||
spiderDir := filepath.Join(viper.GetString("spider.path"), spider.Name)
|
||||
|
||||
@@ -274,6 +277,9 @@ func CopySpider(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// UserId
|
||||
spider.UserId = services.GetCurrentUserId(c)
|
||||
|
||||
// 复制爬虫
|
||||
if err := services.CopySpider(spider, reqBody.Name); err != nil {
|
||||
HandleError(http.StatusInternalServerError, c, err)
|
||||
@@ -365,6 +371,8 @@ func UploadSpider(c *gin.Context) {
|
||||
Type: constants.Customized,
|
||||
Src: filepath.Join(srcPath, spiderName),
|
||||
FileId: fid,
|
||||
ProjectId: bson.ObjectIdHex(constants.ObjectIdNull),
|
||||
UserId: services.GetCurrentUserId(c),
|
||||
}
|
||||
if name != "" {
|
||||
spider.Name = name
|
||||
@@ -617,7 +625,8 @@ func RunSelectedSpider(c *gin.Context) {
|
||||
SpiderId: taskParam.SpiderId,
|
||||
NodeId: node.Id,
|
||||
Param: taskParam.Param,
|
||||
UserId: services.GetCurrentUser(c).Id,
|
||||
UserId: services.GetCurrentUserId(c),
|
||||
RunType: constants.RunTypeAllNodes,
|
||||
}
|
||||
|
||||
id, err := services.AddTask(t)
|
||||
@@ -633,7 +642,8 @@ func RunSelectedSpider(c *gin.Context) {
|
||||
t := model.Task{
|
||||
SpiderId: taskParam.SpiderId,
|
||||
Param: taskParam.Param,
|
||||
UserId: services.GetCurrentUser(c).Id,
|
||||
UserId: services.GetCurrentUserId(c),
|
||||
RunType: constants.RunTypeRandom,
|
||||
}
|
||||
id, err := services.AddTask(t)
|
||||
if err != nil {
|
||||
@@ -648,7 +658,8 @@ func RunSelectedSpider(c *gin.Context) {
|
||||
SpiderId: taskParam.SpiderId,
|
||||
NodeId: nodeId,
|
||||
Param: taskParam.Param,
|
||||
UserId: services.GetCurrentUser(c).Id,
|
||||
UserId: services.GetCurrentUserId(c),
|
||||
RunType: constants.RunTypeSelectedNodes,
|
||||
}
|
||||
|
||||
id, err := services.AddTask(t)
|
||||
|
||||
@@ -115,7 +115,8 @@ func PutTask(c *gin.Context) {
|
||||
SpiderId: reqBody.SpiderId,
|
||||
NodeId: node.Id,
|
||||
Param: reqBody.Param,
|
||||
UserId: services.GetCurrentUser(c).Id,
|
||||
UserId: services.GetCurrentUserId(c),
|
||||
RunType: constants.RunTypeAllNodes,
|
||||
}
|
||||
|
||||
id, err := services.AddTask(t)
|
||||
@@ -131,7 +132,8 @@ func PutTask(c *gin.Context) {
|
||||
t := model.Task{
|
||||
SpiderId: reqBody.SpiderId,
|
||||
Param: reqBody.Param,
|
||||
UserId: services.GetCurrentUser(c).Id,
|
||||
UserId: services.GetCurrentUserId(c),
|
||||
RunType: constants.RunTypeRandom,
|
||||
}
|
||||
id, err := services.AddTask(t)
|
||||
if err != nil {
|
||||
@@ -146,7 +148,8 @@ func PutTask(c *gin.Context) {
|
||||
SpiderId: reqBody.SpiderId,
|
||||
NodeId: nodeId,
|
||||
Param: reqBody.Param,
|
||||
UserId: services.GetCurrentUser(c).Id,
|
||||
UserId: services.GetCurrentUserId(c),
|
||||
RunType: constants.RunTypeSelectedNodes,
|
||||
}
|
||||
|
||||
id, err := services.AddTask(t)
|
||||
|
||||
Reference in New Issue
Block a user