|
@@ -85,7 +85,7 @@ type OtherBase struct {
|
|
SpiderMoveEvent string //爬虫采集完历史后要转移到的节点 comm:队列模式、bid:高性能模式
|
|
SpiderMoveEvent string //爬虫采集完历史后要转移到的节点 comm:队列模式、bid:高性能模式
|
|
}
|
|
}
|
|
|
|
|
|
-//加载某个爬虫
|
|
|
|
|
|
+// 加载某个爬虫
|
|
func (f *Front) LoadSpider(codeTaskIdReState string) error {
|
|
func (f *Front) LoadSpider(codeTaskIdReState string) error {
|
|
tmpStr := strings.Split(codeTaskIdReState, "__")
|
|
tmpStr := strings.Split(codeTaskIdReState, "__")
|
|
code := tmpStr[0]
|
|
code := tmpStr[0]
|
|
@@ -194,7 +194,7 @@ func (f *Front) LoadSpider(codeTaskIdReState string) error {
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
-//查看某个爬虫
|
|
|
|
|
|
+// 查看某个爬虫
|
|
func (f *Front) ViewSpider(id string) error {
|
|
func (f *Front) ViewSpider(id string) error {
|
|
auth := qu.IntAll(f.GetSession("auth"))
|
|
auth := qu.IntAll(f.GetSession("auth"))
|
|
if auth >= 1 {
|
|
if auth >= 1 {
|
|
@@ -579,76 +579,78 @@ func LuaSaveLog(code, user string, data *map[string]interface{}, stype int) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-/*爬虫保存时,检查列表页和三级页代码中是否含lua原生方法
|
|
|
|
-func LuaTextCheck(code, list, detail string, type_list, infoformat int, model map[string]interface{}, msgResult map[string]string) bool {
|
|
|
|
- defer qu.Catch()
|
|
|
|
- //1、异常校验
|
|
|
|
- var errmsg, warnmsg string
|
|
|
|
- if LuaReg.MatchString(list) || LuaReg.MatchString(detail) {
|
|
|
|
- errmsg += "代码中含有lua原生方法;"
|
|
|
|
- }
|
|
|
|
- if ListFilterReg.MatchString(detail) && !strings.Contains(detail, "delete") { //三级页含过滤但是没有data["delete"]="true"
|
|
|
|
- errmsg += `三级页缺少data["delete"]="true";`
|
|
|
|
- }
|
|
|
|
- sln_reg := regexp.MustCompile(`sendListNum\(pageno,list\)`)
|
|
|
|
- slnIndexArr := sln_reg.FindAllStringIndex(list, -1)
|
|
|
|
- if type_list != 0 && len(slnIndexArr) == 0 { //列表页专家模式且不含sendListNum
|
|
|
|
- errmsg += "代码中缺少sendListNum(pageno,list)方法;"
|
|
|
|
- } else if type_list == 1 && len(slnIndexArr) > 0 { //判断sendListNum方法的位置
|
|
|
|
- trim_reg := regexp.MustCompile("trim")
|
|
|
|
- insert_reg := regexp.MustCompile("insert")
|
|
|
|
|
|
+/*
|
|
|
|
+爬虫保存时,检查列表页和三级页代码中是否含lua原生方法
|
|
|
|
|
|
- trIndexArr := trim_reg.FindAllStringIndex(list, -1)
|
|
|
|
- irIndexArr := insert_reg.FindAllStringIndex(list, -1)
|
|
|
|
- slIndex := slnIndexArr[len(slnIndexArr)-1] //sendListNum位置
|
|
|
|
- trIndex := trIndexArr[len(trIndexArr)-1] //com.trim位置
|
|
|
|
- irIndex := irIndexArr[len(irIndexArr)-1] //insert位置
|
|
|
|
- qu.Debug("sendListNum位置:", trIndex, slIndex, irIndex)
|
|
|
|
- if slIndex[1] < trIndex[0] || slIndex[0] > irIndex[1] { //sendListNum方法必须在com.trim方法后,table.insert方法前
|
|
|
|
- errmsg += "sendListNum方法位置错误;"
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if type_list == 1 {
|
|
|
|
- //校验列表页area、city、distric
|
|
|
|
- if !strings.Contains(list, "area") {
|
|
|
|
- errmsg += `模板item["area"]不存在;`
|
|
|
|
- }
|
|
|
|
- if !strings.Contains(list, "city") {
|
|
|
|
- errmsg += `模板item["city"]不存在;`
|
|
|
|
- }
|
|
|
|
- if !strings.Contains(list, "district") {
|
|
|
|
- errmsg += `模板item["district"]不存在;`
|
|
|
|
- }
|
|
|
|
- area := qu.ObjToString(model["area"])
|
|
|
|
- city := qu.ObjToString(model["city"])
|
|
|
|
- district := qu.ObjToString(model["district"])
|
|
|
|
- if area != "" && !strings.Contains(list, area) {
|
|
|
|
- errmsg += "省份信息与模板不一致;"
|
|
|
|
- }
|
|
|
|
- if city != "" && !strings.Contains(list, city) {
|
|
|
|
- errmsg += "城市信息与模板不一致;"
|
|
|
|
- }
|
|
|
|
- if district != "" && !strings.Contains(list, district) {
|
|
|
|
- errmsg += "区/县信息与模板不一致;"
|
|
|
|
|
|
+ func LuaTextCheck(code, list, detail string, type_list, infoformat int, model map[string]interface{}, msgResult map[string]string) bool {
|
|
|
|
+ defer qu.Catch()
|
|
|
|
+ //1、异常校验
|
|
|
|
+ var errmsg, warnmsg string
|
|
|
|
+ if LuaReg.MatchString(list) || LuaReg.MatchString(detail) {
|
|
|
|
+ errmsg += "代码中含有lua原生方法;"
|
|
|
|
+ }
|
|
|
|
+ if ListFilterReg.MatchString(detail) && !strings.Contains(detail, "delete") { //三级页含过滤但是没有data["delete"]="true"
|
|
|
|
+ errmsg += `三级页缺少data["delete"]="true";`
|
|
|
|
+ }
|
|
|
|
+ sln_reg := regexp.MustCompile(`sendListNum\(pageno,list\)`)
|
|
|
|
+ slnIndexArr := sln_reg.FindAllStringIndex(list, -1)
|
|
|
|
+ if type_list != 0 && len(slnIndexArr) == 0 { //列表页专家模式且不含sendListNum
|
|
|
|
+ errmsg += "代码中缺少sendListNum(pageno,list)方法;"
|
|
|
|
+ } else if type_list == 1 && len(slnIndexArr) > 0 { //判断sendListNum方法的位置
|
|
|
|
+ trim_reg := regexp.MustCompile("trim")
|
|
|
|
+ insert_reg := regexp.MustCompile("insert")
|
|
|
|
+
|
|
|
|
+ trIndexArr := trim_reg.FindAllStringIndex(list, -1)
|
|
|
|
+ irIndexArr := insert_reg.FindAllStringIndex(list, -1)
|
|
|
|
+ slIndex := slnIndexArr[len(slnIndexArr)-1] //sendListNum位置
|
|
|
|
+ trIndex := trIndexArr[len(trIndexArr)-1] //com.trim位置
|
|
|
|
+ irIndex := irIndexArr[len(irIndexArr)-1] //insert位置
|
|
|
|
+ qu.Debug("sendListNum位置:", trIndex, slIndex, irIndex)
|
|
|
|
+ if slIndex[1] < trIndex[0] || slIndex[0] > irIndex[1] { //sendListNum方法必须在com.trim方法后,table.insert方法前
|
|
|
|
+ errmsg += "sendListNum方法位置错误;"
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- if infoformat == 2 && !strings.Contains(detail, "projectname") {
|
|
|
|
- errmsg += "拟建/审批数据缺少projectname字段;"
|
|
|
|
|
|
+ if type_list == 1 {
|
|
|
|
+ //校验列表页area、city、distric
|
|
|
|
+ if !strings.Contains(list, "area") {
|
|
|
|
+ errmsg += `模板item["area"]不存在;`
|
|
|
|
+ }
|
|
|
|
+ if !strings.Contains(list, "city") {
|
|
|
|
+ errmsg += `模板item["city"]不存在;`
|
|
|
|
+ }
|
|
|
|
+ if !strings.Contains(list, "district") {
|
|
|
|
+ errmsg += `模板item["district"]不存在;`
|
|
|
|
+ }
|
|
|
|
+ area := qu.ObjToString(model["area"])
|
|
|
|
+ city := qu.ObjToString(model["city"])
|
|
|
|
+ district := qu.ObjToString(model["district"])
|
|
|
|
+ if area != "" && !strings.Contains(list, area) {
|
|
|
|
+ errmsg += "省份信息与模板不一致;"
|
|
|
|
+ }
|
|
|
|
+ if city != "" && !strings.Contains(list, city) {
|
|
|
|
+ errmsg += "城市信息与模板不一致;"
|
|
|
|
+ }
|
|
|
|
+ if district != "" && !strings.Contains(list, district) {
|
|
|
|
+ errmsg += "区/县信息与模板不一致;"
|
|
|
|
+ }
|
|
|
|
+ if infoformat == 2 && !strings.Contains(detail, "projectname") {
|
|
|
|
+ errmsg += "拟建/审批数据缺少projectname字段;"
|
|
|
|
+ }
|
|
|
|
+ //校验爬虫代码的一致性
|
|
|
|
+ if !strings.Contains(list, code) {
|
|
|
|
+ errmsg += `模板item["spidercode"]值错误;`
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- //校验爬虫代码的一致性
|
|
|
|
- if !strings.Contains(list, code) {
|
|
|
|
- errmsg += `模板item["spidercode"]值错误;`
|
|
|
|
|
|
+ //2、提醒校验
|
|
|
|
+ if !strings.Contains(detail, "downloadFile") && !strings.Contains(detail, "getFileAttachmentsArrayWithTag") {
|
|
|
|
+ warnmsg += "三级页缺少下载附件方法;"
|
|
}
|
|
}
|
|
|
|
+ msgResult["warn"] += warnmsg
|
|
|
|
+ msgResult["err"] = errmsg
|
|
|
|
+ return errmsg != ""
|
|
}
|
|
}
|
|
- //2、提醒校验
|
|
|
|
- if !strings.Contains(detail, "downloadFile") && !strings.Contains(detail, "getFileAttachmentsArrayWithTag") {
|
|
|
|
- warnmsg += "三级页缺少下载附件方法;"
|
|
|
|
- }
|
|
|
|
- msgResult["warn"] += warnmsg
|
|
|
|
- msgResult["err"] = errmsg
|
|
|
|
- return errmsg != ""
|
|
|
|
-}*/
|
|
|
|
|
|
+*/
|
|
func LuaTextCheck(infoformat int, param map[string]interface{}, param_list_chrome, param_list_rangechrome, param_content_chrome []sp.ChromeActions, msgResult map[string]string) bool {
|
|
func LuaTextCheck(infoformat int, param map[string]interface{}, param_list_chrome, param_list_rangechrome, param_content_chrome []sp.ChromeActions, msgResult map[string]string) bool {
|
|
- code := qu.ObjToString(param["code"])
|
|
|
|
list := qu.ObjToString(param["str_list"])
|
|
list := qu.ObjToString(param["str_list"])
|
|
detail := qu.ObjToString(param["str_content"])
|
|
detail := qu.ObjToString(param["str_content"])
|
|
type_list := qu.IntAll(param["type_list"])
|
|
type_list := qu.IntAll(param["type_list"])
|
|
@@ -657,15 +659,10 @@ func LuaTextCheck(infoformat int, param map[string]interface{}, param_list_chrom
|
|
defer qu.Catch()
|
|
defer qu.Catch()
|
|
//1、异常校验
|
|
//1、异常校验
|
|
var errmsg, warnmsg string
|
|
var errmsg, warnmsg string
|
|
- if LuaReg.MatchString(list) || LuaReg.MatchString(detail) {
|
|
|
|
- errmsg += "代码中含有lua原生方法;"
|
|
|
|
- }
|
|
|
|
- if ListFilterReg.MatchString(detail) && !strings.Contains(detail, "delete") { //三级页含过滤但是没有data["delete"]="true"
|
|
|
|
- errmsg += `三级页缺少data["delete"]="true";`
|
|
|
|
- }
|
|
|
|
- sln_reg := regexp.MustCompile(`sendListNum\(pageno,list\)`)
|
|
|
|
- slnIndexArr := sln_reg.FindAllStringIndex(list, -1)
|
|
|
|
if type_list == 1 {
|
|
if type_list == 1 {
|
|
|
|
+ if LuaReg.MatchString(list) || LuaReg.MatchString(detail) {
|
|
|
|
+ errmsg += "代码中含有lua原生方法;"
|
|
|
|
+ }
|
|
if strings.Contains(list, "downloadByChrome") { //chrome下载方法动作参数判断
|
|
if strings.Contains(list, "downloadByChrome") { //chrome下载方法动作参数判断
|
|
for _, act := range param_list_chrome {
|
|
for _, act := range param_list_chrome {
|
|
if act.Action != "changeip" && act.Param == "" {
|
|
if act.Action != "changeip" && act.Param == "" {
|
|
@@ -680,6 +677,16 @@ func LuaTextCheck(infoformat int, param map[string]interface{}, param_list_chrom
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if strings.Contains(list, `item["title"]="a"`) {
|
|
|
|
+ if !strings.Contains(detail, `data["title"]`) {
|
|
|
|
+ errmsg += "检查代码title的完整性;"
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if strings.Contains(list, "stringFind") && !strings.Contains(list, "--关键词过滤") {
|
|
|
|
+ errmsg += "列表页代码有过滤方法stringFind但缺少注释:--关键词过滤;"
|
|
|
|
+ }
|
|
|
|
+ sln_reg := regexp.MustCompile(`sendListNum\(pageno,list\)`)
|
|
|
|
+ slnIndexArr := sln_reg.FindAllStringIndex(list, -1)
|
|
if len(slnIndexArr) == 0 { //列表页专家模式且不含sendListNum
|
|
if len(slnIndexArr) == 0 { //列表页专家模式且不含sendListNum
|
|
errmsg += "代码中缺少sendListNum(pageno,list)方法;"
|
|
errmsg += "代码中缺少sendListNum(pageno,list)方法;"
|
|
} else if len(slnIndexArr) > 0 { //判断sendListNum方法的位置
|
|
} else if len(slnIndexArr) > 0 { //判断sendListNum方法的位置
|
|
@@ -695,6 +702,14 @@ func LuaTextCheck(infoformat int, param map[string]interface{}, param_list_chrom
|
|
errmsg += "sendListNum方法位置错误;"
|
|
errmsg += "sendListNum方法位置错误;"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if param, ok := param["param_common"].([]interface{}); ok && len(param) >= 3 {
|
|
|
|
+ spidercode := qu.ObjToString(param[0])
|
|
|
|
+ site := qu.ObjToString(param[1])
|
|
|
|
+ checkText := fmt.Sprintf(`item["spidercode"]="%s";item["site"]="%s"`, spidercode, site)
|
|
|
|
+ if strings.Contains(list, `item["spidercode"]`) && !strings.Contains(list, checkText) {
|
|
|
|
+ errmsg += `item["spidercode"]、item["site"]的值与模板不一致;`
|
|
|
|
+ }
|
|
|
|
+ }
|
|
//校验列表页area、city、distric
|
|
//校验列表页area、city、distric
|
|
if !strings.Contains(list, "area") {
|
|
if !strings.Contains(list, "area") {
|
|
errmsg += `模板item["area"]不存在;`
|
|
errmsg += `模板item["area"]不存在;`
|
|
@@ -721,11 +736,38 @@ func LuaTextCheck(infoformat int, param map[string]interface{}, param_list_chrom
|
|
errmsg += "拟建/审批数据缺少projectname字段;"
|
|
errmsg += "拟建/审批数据缺少projectname字段;"
|
|
}
|
|
}
|
|
//校验爬虫代码的一致性
|
|
//校验爬虫代码的一致性
|
|
- if !strings.Contains(list, code) {
|
|
|
|
- errmsg += `模板item["spidercode"]值错误;`
|
|
|
|
|
|
+ //if !strings.Contains(list, code) {
|
|
|
|
+ // errmsg += `模板item["spidercode"]值错误;`
|
|
|
|
+ //}
|
|
|
|
+ isHttps := false
|
|
|
|
+ for _, text := range u.DomainNameReg.FindAllString(list, -1) {
|
|
|
|
+ if strings.Contains(text, "https") {
|
|
|
|
+ isHttps = true
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if isHttps {
|
|
|
|
+ for tmpStr, tmpText := range map[string]string{"列表页": list, "三级页": detail} {
|
|
|
|
+ downLoadText := u.DownLoadReg.FindString(tmpText)
|
|
|
|
+ if downLoadText != "" {
|
|
|
|
+ textArr := strings.Split(downLoadText, ",")
|
|
|
|
+ if len(textArr) < 4 {
|
|
|
|
+ errmsg += "download方法添加下载参数;"
|
|
|
|
+ } else if len(textArr) == 4 {
|
|
|
|
+ if !u.CodeTypeReg.MatchString(textArr[0]) || (textArr[1] != "true" && textArr[1] != "false") {
|
|
|
|
+ errmsg += tmpStr + "download方法添加下载参数;"
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if type_content == 1 {
|
|
if type_content == 1 {
|
|
|
|
+ if ListFilterReg.MatchString(detail) && !strings.Contains(detail, "delete") { //三级页含过滤但是没有data["delete"]="true"
|
|
|
|
+ errmsg += `三级页缺少data["delete"]="true";`
|
|
|
|
+ }
|
|
|
|
+ if !strings.Contains(detail, "s_title") {
|
|
|
|
+ errmsg += "三级页缺少s_title;"
|
|
|
|
+ }
|
|
if strings.Contains(detail, "downloadByChrome") { //chrome下载方法动作参数判断
|
|
if strings.Contains(detail, "downloadByChrome") { //chrome下载方法动作参数判断
|
|
for _, act := range param_content_chrome {
|
|
for _, act := range param_content_chrome {
|
|
if act.Action != "changeip" && act.Param == "" {
|
|
if act.Action != "changeip" && act.Param == "" {
|
|
@@ -743,7 +785,7 @@ func LuaTextCheck(infoformat int, param map[string]interface{}, param_list_chrom
|
|
return errmsg != ""
|
|
return errmsg != ""
|
|
}
|
|
}
|
|
|
|
|
|
-//方法测试
|
|
|
|
|
|
+// 方法测试
|
|
func (f *Front) RunStep() {
|
|
func (f *Front) RunStep() {
|
|
imodal, _ := f.GetInteger("imodal")
|
|
imodal, _ := f.GetInteger("imodal")
|
|
script, _ := f.GetBool("script")
|
|
script, _ := f.GetBool("script")
|
|
@@ -923,7 +965,7 @@ func (f *Front) RunStep() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-//爬虫测试数据json
|
|
|
|
|
|
+// 爬虫测试数据json
|
|
func (f *Front) GetJson() {
|
|
func (f *Front) GetJson() {
|
|
code := f.GetString("code")
|
|
code := f.GetString("code")
|
|
username := f.GetSession("username").(string)
|
|
username := f.GetSession("username").(string)
|
|
@@ -970,7 +1012,7 @@ func (f *Front) GetJson() {
|
|
|
|
|
|
var TestResultMap = map[string]*TestResult{} //username+code
|
|
var TestResultMap = map[string]*TestResult{} //username+code
|
|
|
|
|
|
-//某个爬虫整体测试结果
|
|
|
|
|
|
+// 某个爬虫整体测试结果
|
|
type TestResult struct {
|
|
type TestResult struct {
|
|
task_remark string
|
|
task_remark string
|
|
task_rateremark []string
|
|
task_rateremark []string
|
|
@@ -981,7 +1023,7 @@ type TestResult struct {
|
|
dataInfo map[string]interface{}
|
|
dataInfo map[string]interface{}
|
|
}
|
|
}
|
|
|
|
|
|
-//整体测试
|
|
|
|
|
|
+// 整体测试
|
|
func (f *Front) SpiderPass() {
|
|
func (f *Front) SpiderPass() {
|
|
defer mu.Catch()
|
|
defer mu.Catch()
|
|
tr := &TestResult{}
|
|
tr := &TestResult{}
|
|
@@ -1189,7 +1231,7 @@ func (f *Front) DownSpider(code string) {
|
|
u.MgoEB.Save("luadownlogs", downlogs)
|
|
u.MgoEB.Save("luadownlogs", downlogs)
|
|
}
|
|
}
|
|
|
|
|
|
-//下架删除心跳
|
|
|
|
|
|
+// 下架删除心跳
|
|
func DelSpiderHeart(code string) bool {
|
|
func DelSpiderHeart(code string) bool {
|
|
return u.MgoS.Update("spider_heart", map[string]interface{}{"code": code}, map[string]interface{}{"$set": map[string]interface{}{"del": true}}, false, true)
|
|
return u.MgoS.Update("spider_heart", map[string]interface{}{"code": code}, map[string]interface{}{"$set": map[string]interface{}{"del": true}}, false, true)
|
|
}
|
|
}
|
|
@@ -1207,7 +1249,7 @@ func DelSpiderHeart(code string) bool {
|
|
// }
|
|
// }
|
|
//}
|
|
//}
|
|
|
|
|
|
-//爬虫核对
|
|
|
|
|
|
+// 爬虫核对
|
|
func (f *Front) Checktime() {
|
|
func (f *Front) Checktime() {
|
|
code := f.GetString("code")
|
|
code := f.GetString("code")
|
|
auth := qu.IntAll(f.GetSession("auth"))
|
|
auth := qu.IntAll(f.GetSession("auth"))
|
|
@@ -1224,7 +1266,7 @@ func (f *Front) Checktime() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-//批量作废
|
|
|
|
|
|
+// 批量作废
|
|
func (f *Front) Disables() error {
|
|
func (f *Front) Disables() error {
|
|
auth := qu.IntAll(f.GetSession("auth"))
|
|
auth := qu.IntAll(f.GetSession("auth"))
|
|
events := strings.Split(f.GetString("events"), ",")
|
|
events := strings.Split(f.GetString("events"), ",")
|
|
@@ -1264,7 +1306,7 @@ func (f *Front) Disables() error {
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
-//批量上下架
|
|
|
|
|
|
+// 批量上下架
|
|
func (f *Front) BatchShelves() {
|
|
func (f *Front) BatchShelves() {
|
|
codes := strings.Split(f.GetString("codes"), ",")
|
|
codes := strings.Split(f.GetString("codes"), ",")
|
|
state, _ := f.GetInteger("state")
|
|
state, _ := f.GetInteger("state")
|
|
@@ -1299,7 +1341,7 @@ func (f *Front) BatchShelves() {
|
|
f.ServeJson(errCode)
|
|
f.ServeJson(errCode)
|
|
}
|
|
}
|
|
|
|
|
|
-//更新爬虫状态
|
|
|
|
|
|
+// 更新爬虫状态
|
|
func (f *Front) UpState() error {
|
|
func (f *Front) UpState() error {
|
|
username := f.GetSession("username").(string)
|
|
username := f.GetSession("username").(string)
|
|
code := f.GetString("code")
|
|
code := f.GetString("code")
|
|
@@ -1420,7 +1462,7 @@ func (f *Front) Assort() {
|
|
f.ServeJson(map[string]interface{}{"success": success, "msg": msg})
|
|
f.ServeJson(map[string]interface{}{"success": success, "msg": msg})
|
|
}
|
|
}
|
|
|
|
|
|
-//更新爬虫状态,并判断是否更新节点爬虫
|
|
|
|
|
|
+// 更新爬虫状态,并判断是否更新节点爬虫
|
|
func UpStateAndUpSpider(code, id, reason, username string, state int) (bool, error) {
|
|
func UpStateAndUpSpider(code, id, reason, username string, state int) (bool, error) {
|
|
upresult := false
|
|
upresult := false
|
|
var err error
|
|
var err error
|
|
@@ -1570,7 +1612,7 @@ func UpStateAndUpSpider(code, id, reason, username string, state int) (bool, err
|
|
return upresult, err
|
|
return upresult, err
|
|
}
|
|
}
|
|
|
|
|
|
-//保存记录信息
|
|
|
|
|
|
+// 保存记录信息
|
|
func SaveRemark(taskid []string, reason, username string) {
|
|
func SaveRemark(taskid []string, reason, username string) {
|
|
timeNow := time.Now().Unix()
|
|
timeNow := time.Now().Unix()
|
|
if reason == "" {
|
|
if reason == "" {
|
|
@@ -1601,7 +1643,7 @@ func SaveRemark(taskid []string, reason, username string) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-//修改任务状态
|
|
|
|
|
|
+// 修改任务状态
|
|
func UpTaskState(code []string, num int, reason string, startTime int64) {
|
|
func UpTaskState(code []string, num int, reason string, startTime int64) {
|
|
query := map[string]interface{}{}
|
|
query := map[string]interface{}{}
|
|
update := map[string]interface{}{}
|
|
update := map[string]interface{}{}
|
|
@@ -1667,7 +1709,7 @@ func UpTaskState(code []string, num int, reason string, startTime int64) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-//更新节点
|
|
|
|
|
|
+// 更新节点
|
|
func (f *Front) ChangeEvent() {
|
|
func (f *Front) ChangeEvent() {
|
|
auth := qu.IntAll(f.GetSession("auth"))
|
|
auth := qu.IntAll(f.GetSession("auth"))
|
|
if auth != u.Role_Admin {
|
|
if auth != u.Role_Admin {
|
|
@@ -1720,7 +1762,7 @@ func (f *Front) ChangeEvent() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-//验证用户是否有更改状态权限
|
|
|
|
|
|
+// 验证用户是否有更改状态权限
|
|
func IsHasUpState(auth, state int) bool {
|
|
func IsHasUpState(auth, state int) bool {
|
|
rep := false
|
|
rep := false
|
|
switch auth {
|
|
switch auth {
|
|
@@ -1741,7 +1783,7 @@ func IsHasUpState(auth, state int) bool {
|
|
|
|
|
|
var list_fields = `{"_id":1,"code":1,"createuser":1,"modifyuser":1,"modifytime":1,"l_uploadtime":1,"l_checktime":1,"state":1,"param_common":1,"event":1,"urgency":1,"platform":1,"pendstate":1}`
|
|
var list_fields = `{"_id":1,"code":1,"createuser":1,"modifyuser":1,"modifytime":1,"l_uploadtime":1,"l_checktime":1,"state":1,"param_common":1,"event":1,"urgency":1,"platform":1,"pendstate":1}`
|
|
|
|
|
|
-//脚本管理,结合爬虫运行信息
|
|
|
|
|
|
+// 脚本管理,结合爬虫运行信息
|
|
func (f *Front) LuaList() {
|
|
func (f *Front) LuaList() {
|
|
auth := qu.IntAll(f.GetSession("auth"))
|
|
auth := qu.IntAll(f.GetSession("auth"))
|
|
if auth != u.Role_Admin {
|
|
if auth != u.Role_Admin {
|
|
@@ -1847,7 +1889,7 @@ func (f *Front) LuaList() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-//心跳监控
|
|
|
|
|
|
+// 心跳监控
|
|
func (f *Front) Heart() {
|
|
func (f *Front) Heart() {
|
|
if f.Method() == "POST" {
|
|
if f.Method() == "POST" {
|
|
event, _ := f.GetInteger("event")
|
|
event, _ := f.GetInteger("event")
|
|
@@ -1937,7 +1979,7 @@ func (f *Front) Heart() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-//爬虫信息
|
|
|
|
|
|
+// 爬虫信息
|
|
type spinfo struct {
|
|
type spinfo struct {
|
|
code string
|
|
code string
|
|
todayDowncount, toDayRequestNum int
|
|
todayDowncount, toDayRequestNum int
|
|
@@ -1949,7 +1991,7 @@ type spinfo struct {
|
|
lstate string
|
|
lstate string
|
|
}
|
|
}
|
|
|
|
|
|
-//爬虫信息
|
|
|
|
|
|
+// 爬虫信息
|
|
func SpiderInfo(data string) {
|
|
func SpiderInfo(data string) {
|
|
data = sp.Se.DecodeString(data)
|
|
data = sp.Se.DecodeString(data)
|
|
infos := []map[string]interface{}{}
|
|
infos := []map[string]interface{}{}
|
|
@@ -1979,7 +2021,7 @@ func SpiderInfo(data string) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-//接受维护任务信息
|
|
|
|
|
|
+// 接受维护任务信息
|
|
func SpiderModifyTask(data string) {
|
|
func SpiderModifyTask(data string) {
|
|
data = sp.Se.DecodeString(data)
|
|
data = sp.Se.DecodeString(data)
|
|
mtasks := []map[string]interface{}{}
|
|
mtasks := []map[string]interface{}{}
|
|
@@ -1992,7 +2034,7 @@ func SpiderModifyTask(data string) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-//查看是否有该任务
|
|
|
|
|
|
+// 查看是否有该任务
|
|
func checkTask(codes []string, num int) []string {
|
|
func checkTask(codes []string, num int) []string {
|
|
// var id string = ""
|
|
// var id string = ""
|
|
query := map[string]interface{}{}
|
|
query := map[string]interface{}{}
|