Esempio n. 1
0
//查看每一个value类型有多少个key
func viewValueTypeStatResult(w http.ResponseWriter, r *http.Request) {
	taskId := r.FormValue("taskId")

	if taskId == "" {
		io.WriteString(w, "Need taskId!")
		return
	}

	result := dbutil.FetchResult(string(taskId), "1", 1000, 0)

	var listHtml string = "<body><ol>"
	for _, cont := range result {
		listHtml += "<li>" + cont + "</li>"
	}

	listHtml = listHtml + "</ol></body>"
	io.WriteString(w, listHtml)
}
Esempio n. 2
0
//查看value length 过滤结果
//默认显示100条
//page从地址栏中输入
func viewValueLengthFilterResult(w http.ResponseWriter, r *http.Request) {
	taskId := r.FormValue("taskId")
	page := r.FormValue("page")
	types := r.FormValue("type")

	//验证taskId是否输入
	if taskId == "" {
		io.WriteString(w, "Need taskId!")
		return
	}

	//验证page是否输入
	reg := regexp.MustCompile(num_regu)
	if reg.MatchString(page) == false {
		io.WriteString(w, "Need param page, page must be a numeric type!")
		return
	}

	pageNum, _ := strconv.ParseInt(page, 10, 32)
	var offset int = 0
	if pageNum == 0 || pageNum == 1 {
		offset = 0
	} else {
		offset = (int(pageNum) - 1) * 100
	}

	if types == "" {
		types = "2"
	}

	result := dbutil.FetchResult(string(taskId), types, 100, offset)

	var listHtml string = "<body>" +
		"<p>each page show 100 records</p>" + "<ol>"
	for _, cont := range result {
		listHtml += "<li>" + cont + "</li>"
	}

	listHtml = listHtml + "</ol></body>"
	io.WriteString(w, listHtml)
}