finish up project

This commit is contained in:
marvzhang
2020-02-02 13:29:56 +08:00
parent 9d5d0253a8
commit 024f9ac3b2
4 changed files with 24 additions and 4 deletions

View File

@@ -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