mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-25 17:42:25 +01:00
finish up project
This commit is contained in:
@@ -32,6 +32,7 @@ type Spider struct {
|
||||
Envs []Env `json:"envs" bson:"envs"` // 环境变量
|
||||
Remark string `json:"remark" bson:"remark"` // 备注
|
||||
Src string `json:"src" bson:"src"` // 源码位置
|
||||
ProjectId bson.ObjectId `json:"project_id" bson:"project_id"` // 项目ID
|
||||
|
||||
// 自定义爬虫
|
||||
Cmd string `json:"cmd" bson:"cmd"` // 执行命令
|
||||
@@ -56,6 +57,11 @@ func (spider *Spider) Save() error {
|
||||
|
||||
spider.UpdateTs = time.Now()
|
||||
|
||||
// 兼容没有项目ID的爬虫
|
||||
if spider.ProjectId.Hex() == "" {
|
||||
spider.ProjectId = bson.ObjectIdHex(constants.ObjectIdNull)
|
||||
}
|
||||
|
||||
if err := c.UpdateId(spider.Id, spider); err != nil {
|
||||
debug.PrintStack()
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user