|
@@ -94,7 +94,7 @@ func (f *Front) LoadSpider(codeTaskIdReState string) error {
|
|
|
} else if taskId == "restate=3" {
|
|
|
restate = 3
|
|
|
} else {
|
|
|
- if auth == role_dev && qu.ObjToString(f.GetSession(taskId)) == "" {
|
|
|
+ if auth == u.Role_Dev && qu.ObjToString(f.GetSession(taskId)) == "" {
|
|
|
xgTime := time.Unix(time.Now().Unix(), 0).Format("2006-01-02 15:04:05")
|
|
|
f.SetSession(taskId, xgTime)
|
|
|
}
|
|
@@ -108,6 +108,18 @@ func (f *Front) LoadSpider(codeTaskIdReState string) error {
|
|
|
auth := qu.IntAll(f.GetSession("auth"))
|
|
|
if qu.ObjToString((*lua)["createuserid"]) == f.GetSession("userid").(string) || auth >= 1 {
|
|
|
if len(*lua) > 0 {
|
|
|
+ if qu.IntAll((*lua)["event"]) == 7000 && qu.IntAll((*lua)["urgency"]) == 0 && qu.IntAll((*lua)["state"]) == 0 {
|
|
|
+ q := map[string]interface{}{
|
|
|
+ "event": 7000,
|
|
|
+ "state": 0,
|
|
|
+ "urgency": 1,
|
|
|
+ "modifyuserid": f.GetSession("userid"),
|
|
|
+ }
|
|
|
+ if u.MgoEB.Count("luaconfig", q) > 0 {
|
|
|
+ f.Write("名下还有7000节点待完成的紧急爬虫,暂无法处理该爬虫!")
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ }
|
|
|
if copy != "" {
|
|
|
//luacopy, _ := u.MgoE.FindOne("luaconfig", map[string]interface{}{"code": copy})
|
|
|
luacopy, _ := u.MgoEB.FindOne("luaconfig", map[string]interface{}{"code": copy})
|
|
@@ -277,7 +289,7 @@ func (f *Front) SaveStep() {
|
|
|
if len((*one)) > 0 {
|
|
|
comeintime = qu.Int64All((*one)["comeintime"])
|
|
|
ouserid := qu.ObjToString((*one)["createuserid"])
|
|
|
- if ouserid != userid && auth == role_dev {
|
|
|
+ if ouserid != userid && auth == u.Role_Dev {
|
|
|
f.Write("权限不够,不能修改他人脚本")
|
|
|
return
|
|
|
} else {
|
|
@@ -286,14 +298,14 @@ func (f *Front) SaveStep() {
|
|
|
f.Base.SpiderName = ((*one)["param_common"].([]interface{}))[1].(string)
|
|
|
}
|
|
|
} else {
|
|
|
- if auth != role_admin {
|
|
|
+ if auth != u.Role_Admin {
|
|
|
f.Write("不能新建爬虫,请联系管理员导入")
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
listcheck := f.GetString("listcheck")
|
|
|
contentcheck := f.GetString("contentcheck")
|
|
|
- if auth == role_dev {
|
|
|
+ if auth == u.Role_Dev {
|
|
|
//f.Base.SpiderStoreToMsgEvent = 4002
|
|
|
}
|
|
|
common := []interface{}{
|
|
@@ -368,7 +380,7 @@ func (f *Front) SaveStep() {
|
|
|
param["code"] = (*one)["code"]
|
|
|
//开发员关联任务修改爬虫状态
|
|
|
state = qu.IntAll((*one)["state"])
|
|
|
- if auth == role_dev && state >= Sp_state_3 && restate != 1 { //开发员修改,已经审核通过(不包含已上架),状态重置为待完成(restate!=1判断,重采修改保存爬虫时不修改爬虫状态)
|
|
|
+ if auth == u.Role_Dev && state >= Sp_state_3 && restate != 1 { //开发员修改,已经审核通过(不包含已上架),状态重置为待完成(restate!=1判断,重采修改保存爬虫时不修改爬虫状态)
|
|
|
param["state"] = 0
|
|
|
} else {
|
|
|
param["state"] = state
|
|
@@ -401,6 +413,7 @@ func (f *Front) SaveStep() {
|
|
|
} else if event := qu.IntAll((*one)["event"]); event != 7000 { //默认增量节点
|
|
|
param["incrementevent"] = event
|
|
|
}
|
|
|
+ param["urgency"] = 1 //保存到7000时,爬虫紧急度变为紧急(控制7000节点爬虫紧急未写完不能写普通)
|
|
|
} else if f.OtherBase.SpiderType == "increment" && err == nil { //增量
|
|
|
param["event"] = tmpEvent //开发人员切换增量节点
|
|
|
}
|
|
@@ -924,7 +937,7 @@ func (f *Front) DownSpider(code string) {
|
|
|
user := f.GetSession("loginuser")
|
|
|
success := false
|
|
|
script := ""
|
|
|
- if auth > role_dev {
|
|
|
+ if auth > u.Role_Dev {
|
|
|
success = true
|
|
|
//one, _ := u.MgoE.FindOne("luaconfig", map[string]interface{}{"code": code})
|
|
|
one, _ := u.MgoEB.FindOne("luaconfig", map[string]interface{}{"code": code})
|
|
@@ -984,7 +997,7 @@ func DelSpiderHeart(code string) bool {
|
|
|
func (f *Front) Checktime() {
|
|
|
code := f.GetString("code")
|
|
|
auth := qu.IntAll(f.GetSession("auth"))
|
|
|
- if auth != role_admin {
|
|
|
+ if auth != u.Role_Admin {
|
|
|
f.ServeJson(false)
|
|
|
} else {
|
|
|
//b := u.MgoE.Update("luaconfig", map[string]interface{}{"code": code}, map[string]interface{}{"$set": map[string]interface{}{
|
|
@@ -1424,7 +1437,7 @@ func UpTaskState(code []string, num int, reason string, startTime int64) {
|
|
|
//更新节点
|
|
|
func (f *Front) ChangeEvent() {
|
|
|
auth := qu.IntAll(f.GetSession("auth"))
|
|
|
- if auth != role_admin {
|
|
|
+ if auth != u.Role_Admin {
|
|
|
f.ServeJson("没有权限")
|
|
|
}
|
|
|
code := f.GetString("code")
|
|
@@ -1478,15 +1491,15 @@ func (f *Front) ChangeEvent() {
|
|
|
func IsHasUpState(auth, state int) bool {
|
|
|
rep := false
|
|
|
switch auth {
|
|
|
- case role_dev:
|
|
|
+ case u.Role_Dev:
|
|
|
if state == Sp_state_1 || state == Sp_state_7 {
|
|
|
rep = true
|
|
|
}
|
|
|
- case role_examine:
|
|
|
+ case u.Role_Examine:
|
|
|
if state == Sp_state_2 || state == Sp_state_3 {
|
|
|
rep = true
|
|
|
}
|
|
|
- case role_admin:
|
|
|
+ case u.Role_Admin:
|
|
|
rep = true
|
|
|
default:
|
|
|
}
|
|
@@ -1498,7 +1511,7 @@ var list_fields = `{"_id":1,"code":1,"createuser":1,"modifyuser":1,"modifytime":
|
|
|
//脚本管理,结合爬虫运行信息
|
|
|
func (f *Front) LuaList() {
|
|
|
auth := qu.IntAll(f.GetSession("auth"))
|
|
|
- if auth != role_admin {
|
|
|
+ if auth != u.Role_Admin {
|
|
|
f.ServeJson("没有权限!")
|
|
|
return
|
|
|
}
|