當前位置: 首頁>>代碼示例>>Golang>>正文


Golang utils.Page類代碼示例

本文整理匯總了Golang中github.com/blackmady/NoneCMS/utils.Page的典型用法代碼示例。如果您正苦於以下問題:Golang Page類的具體用法?Golang Page怎麽用?Golang Page使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Page類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: GetCommentList

//獲取評論列表
func (c *Comment) GetCommentList(search string, Page int64, Perpage int64) (comment_arr []*Comment, html template.HTML, where map[string]interface{}) {

	comment_list := []*Comment{}

	//查詢條件
	var WhereStr string = " 1 AND "

	if len(search) > 0 {

		//解碼
		where = utils.DecodeSegment(search)

		revel.WARN.Println(where)

		if where["start_time"] != "" {
			WhereStr += " `regdate` >='" + fmt.Sprintf("%s", where["start_time"]) + " 00:00:00' AND "
		}
	}

	WhereStr += " 1 "

	//查詢總數
	comment := new(Comment)
	Total, err := DB_Read.Table("comment").Where(WhereStr).Count(comment)
	if err != nil {
		revel.WARN.Printf("錯誤: %v", err)
	}

	//分頁
	Pager := new(utils.Page)
	if len(search) > 0 {
		Pager.SubPage_link = "/Comment/" + search + "/"
	} else {
		Pager.SubPage_link = "/Comment/"
	}

	Pager.Nums = Total
	Pager.Perpage = Perpage
	Pager.Current_page = Page
	Pager.SubPage_type = 2
	pages := Pager.Show()

	DB_Read.Table("comment").Where(WhereStr).Limit(int(Perpage), int((Page-1)*Pager.Perpage)).Desc("id").Find(&comment_list)

	if len(comment_list) > 0 {
		user := new(User)
		for i, v := range comment_list {
			comment_list[i].User = user.GetById(v.Uid)
		}
	}

	return comment_list, pages, where
}
開發者ID:blackmady,項目名稱:GoCMS,代碼行數:54,代碼來源:comment.go

示例2: GetByAll

//獲取分類列表
func (c *FocusCate) GetByAll(Page int64, Perpage int64) ([]*FocusCate, template.HTML) {
	focuscate_list := []*FocusCate{}

	//查詢總數
	focuscate := new(FocusCate)
	Total, err := DB_Read.Count(focuscate)
	if err != nil {
		revel.WARN.Printf("錯誤: %v", err)
	}

	//分頁
	Pager := new(utils.Page)
	Pager.SubPage_link = "/FocusCate/"
	Pager.Nums = Total
	Pager.Perpage = Perpage
	Pager.Current_page = Page
	Pager.SubPage_type = 2
	pages := Pager.Show()

	//查詢數據
	DB_Read.Limit(int(Perpage), int((Page-1)*Pager.Perpage)).Desc("id").Find(&focuscate_list)
	return focuscate_list, pages
}
開發者ID:blackmady,項目名稱:GoCMS,代碼行數:24,代碼來源:focuscate.go

示例3: GetByAll

//獲取來源列表
func (c *Copyfrom) GetByAll(Page int64, Perpage int64) ([]*Copyfrom, template.HTML) {
	copyfrom_list := []*Copyfrom{}

	//查詢總數
	copyfrom := new(Copyfrom)
	Total, err := DB_Read.Count(copyfrom)
	if err != nil {
		revel.WARN.Printf("錯誤: %v", err)
	}

	//分頁
	Pager := new(utils.Page)
	Pager.SubPage_link = "/Copyfrom/"
	Pager.Nums = Total
	Pager.Perpage = Perpage
	Pager.Current_page = Page
	Pager.SubPage_type = 2
	pages := Pager.Show()

	//查詢數據
	DB_Read.Limit(int(Perpage), int((Page-1)*Pager.Perpage)).Desc("id").Find(&copyfrom_list)
	return copyfrom_list, pages
}
開發者ID:blackmady,項目名稱:GoCMS,代碼行數:24,代碼來源:copyfrom.go

示例4: GetByAll

//獲取焦點圖列表
func (c *Focus) GetByAll(search string, Page int64, Perpage int64) (focus_arr []*Focus, html template.HTML, where map[string]interface{}) {
	focus_list := []*Focus{}

	//查詢條件
	var WhereStr string = " 1 AND "

	if len(search) > 0 {

		//解碼
		where = utils.DecodeSegment(search)

		revel.WARN.Println(where)

		if where["cid"] != "" {
			WhereStr += " `cid`='" + fmt.Sprintf("%d", where["cid"]) + "' AND "
		}

		if where["keyword"] != "" {
			//關鍵字
			keyword := fmt.Sprintf("%s", where["keyword"])
			WhereStr += " `title` like '%" + keyword + "%' AND "
		}
	}

	WhereStr += " 1 "

	//查詢總數
	focus := new(Focus)
	Total, err := DB_Read.Where(WhereStr).Count(focus)
	if err != nil {
		revel.WARN.Printf("錯誤: %v", err)
	}

	//分頁
	Pager := new(utils.Page)
	Pager.SubPage_link = "/Focus/"
	Pager.Nums = Total
	Pager.Perpage = Perpage
	Pager.Current_page = Page
	Pager.SubPage_type = 2
	pages := Pager.Show()

	//查詢數據
	DB_Read.Where(WhereStr).Limit(int(Perpage), int((Page-1)*Pager.Perpage)).Desc("id").Find(&focus_list)

	if len(focus_list) > 0 {
		admin := new(Admin)
		focuscate := new(FocusCate)

		for i, v := range focus_list {
			focus_list[i].Admin = admin.GetById(v.Aid)

			//所屬欄目
			focus_list[i].Focuscate = focuscate.GetById(v.Cid)

			if v.Img != "" {
				//判斷是否是係統的分隔符
				separator := "/"
				if os.IsPathSeparator('\\') {
					separator = "\\"
				} else {
					separator = "/"
				}

				config_file := (revel.BasePath + "/conf/config.conf")
				config_file = strings.Replace(config_file, "/", separator, -1)
				config_conf, _ := config.ReadDefault(config_file)

				//前台網站地址
				sitedomain, _ := config_conf.String("website", "website.sitedomain")
				v.Img = sitedomain + v.Img
			}
		}
	}

	return focus_list, pages, where
}
開發者ID:blackmady,項目名稱:GoCMS,代碼行數:78,代碼來源:focus.go

示例5: GetByAll

//獲取管理員列表
func (a *Admin) GetByAll(RoleId int64, where map[string]string, Page int64, Perpage int64) ([]*Admin, template.HTML) {
	admin_list := []*Admin{}

	if RoleId > 0 {

		//查詢總數
		admin := new(Admin)
		Total, err := DB_Read.Where("roleid=?", RoleId).Count(admin)
		if err != nil {
			revel.WARN.Printf("錯誤: %v", err)
		}

		//分頁
		Pager := new(utils.Page)
		Pager.SubPage_link = "/Admin/"
		Pager.Nums = Total
		Pager.Perpage = Perpage
		Pager.Current_page = Page
		Pager.SubPage_type = 2
		pages := Pager.Show()

		DB_Read.Where("roleid=?", RoleId).Limit(int(Perpage), int((Page-1)*Pager.Perpage)).Desc("id").Find(&admin_list)

		if len(admin_list) > 0 {
			role := new(Role)

			for i, v := range admin_list {
				admin_list[i].Role = role.GetById(v.Roleid)
			}
		}

		return admin_list, pages
	} else {

		//查詢總數
		admin := new(Admin)
		Total, err := DB_Read.Count(admin)
		if err != nil {
			revel.WARN.Printf("錯誤: %v", err)
		}

		//分頁
		Pager := new(utils.Page)
		Pager.SubPage_link = "/Admin/"
		Pager.Nums = Total
		Pager.Perpage = Perpage
		Pager.Current_page = Page
		Pager.SubPage_type = 2
		pages := Pager.Show()

		DB_Read.Limit(int(Perpage), int((Page-1)*Pager.Perpage)).Find(&admin_list)

		if len(admin_list) > 0 {
			role := new(Role)

			for i, v := range admin_list {
				admin_list[i].Role = role.GetById(v.Roleid)
			}
		}

		return admin_list, pages
	}
}
開發者ID:blackmady,項目名稱:GoCMS,代碼行數:64,代碼來源:admin.go

示例6: GetByAll

//獲取日誌列表
func (L *Logs) GetByAll(search string, Page int64, Perpage int64) (logs_arr []*Logs, html template.HTML, where map[string]interface{}) {

	logs_list := []*Logs{}

	//查詢條件
	var WhereStr string = " 1 AND "

	if len(search) > 0 {
		//解碼
		where = utils.DecodeSegment(search)

		revel.WARN.Println(where)

		if where["module"] != "" {
			WhereStr += " `module`='" + fmt.Sprintf("%s", where["module"]) + "' AND "
		}

		if where["username"] != "" {
			admin := new(Admin)
			AdminInfo := admin.GetByName(fmt.Sprintf("%s", where["username"]))
			WhereStr += " `uid`=" + strconv.Itoa(int(AdminInfo.Id)) + " AND "
		}

		if where["realname"] != "" {
			admin := new(Admin)
			AdminInfo := admin.GetByRealName(fmt.Sprintf("%s", where["realname"]))
			WhereStr += " `uid`='" + strconv.Itoa(int(AdminInfo.Id)) + "' AND "
		}

		if where["start_time"] != "" {
			WhereStr += " `createtime` >='" + fmt.Sprintf("%s", where["start_time"]) + " 00:00:00' AND "
		}

		if where["end_time"] != "" {
			WhereStr += " `createtime` <='" + fmt.Sprintf("%s", where["end_time"]) + " 23:59:59' AND "
		}
	}

	WhereStr += " 1 "

	//查詢總數
	logs := new(Logs)
	Total, err := DB_Read.Where(WhereStr).Count(logs)
	if err != nil {
		revel.WARN.Printf("錯誤: %v", err)
	}

	//分頁
	Pager := new(utils.Page)
	if len(search) > 0 {
		Pager.SubPage_link = "/Logs/" + search + "/"
	} else {
		Pager.SubPage_link = "/Logs/"
	}

	Pager.Nums = Total
	Pager.Perpage = Perpage
	Pager.Current_page = Page
	Pager.SubPage_type = 2
	pages := Pager.Show()

	//查詢數據
	DB_Read.Where(WhereStr).Limit(int(Perpage), int((Page-1)*Pager.Perpage)).Desc("id").Find(&logs_list)

	if len(logs_list) > 0 {
		admin := new(Admin)

		for i, v := range logs_list {
			logs_list[i].Admin = admin.GetById(v.Uid)
			logs_list[i].IpAddress = utils.GetIpAddress(v.Ip)
		}
	}

	return logs_list, pages, where
}
開發者ID:blackmady,項目名稱:GoCMS,代碼行數:76,代碼來源:logs.go

示例7: GetByList

//獲取內容列表
func (a *Article) GetByList(Cid int64, Search string, Page int64, Perpage int64) (article_arr []*Article, html template.HTML, where map[string]interface{}) {
	article_list := []*Article{}

	//查詢條件
	var WhereStr string = " 1 AND "

	if len(Search) > 0 {

		//解碼
		where = utils.DecodeSegment(Search)

		revel.WARN.Println(where)

		if where["cid"] != "0" {
			WhereStr += " `cid`='" + fmt.Sprintf("%s", where["cid"]) + "' AND "
		}

		if where["field"] != "" && where["keyword"] != "" {

			if where["field"] == "title" {
				//標題
				WhereStr += " `title` like %'" + fmt.Sprintf("%s", where["keyword"]) + "'% AND "

			} else if where["field"] == "keywords" {
				//關鍵詞
				WhereStr += " `keywords` like %'" + fmt.Sprintf("%s", where["keyword"]) + "'% AND "
			} else if where["field"] == "description" {
				//描述
				WhereStr += " `description` like %'" + fmt.Sprintf("%s", where["keyword"]) + "'% AND "
			} else if where["field"] == "id" {
				//ID
				WhereStr += " `id`='" + fmt.Sprintf("%s", where["keyword"]) + "' AND "
			}

		}
	}

	WhereStr += " 1 "

	//查詢總數
	article := new(Article)
	Total, err := DB_Read.Where(WhereStr).Count(article)
	if err != nil {
		revel.WARN.Printf("錯誤: %v", err)
	}

	//分頁
	Pager := new(utils.Page)
	Pager.SubPage_link = "/Content/relationlist/" + strconv.FormatInt(Cid, 10) + "/"
	Pager.Nums = Total
	Pager.Perpage = Perpage
	Pager.Current_page = Page
	Pager.SubPage_type = 2
	pages := Pager.Show()

	//查詢數據
	DB_Read.Where(WhereStr).Limit(int(Perpage), int((Page-1)*Pager.Perpage)).Desc("id").Find(&article_list)

	if len(article_list) > 0 {

		admin := new(Admin)
		category := new(Category)

		for i, v := range article_list {
			article_list[i].Admin = admin.GetById(v.Aid)

			//所屬欄目
			article_list[i].Category = category.GetById(v.Cid)
		}
	}

	return article_list, pages, where
}
開發者ID:blackmady,項目名稱:GoCMS,代碼行數:74,代碼來源:article.go

示例8: GetByAll

//獲取內容列表
func (a *Article) GetByAll(search string, Cid int64, Page int64, Perpage int64) (article_arr []*Article, html template.HTML, where map[string]interface{}) {
	article_list := []*Article{}

	//查詢條件
	var WhereStr string = " 1 AND `cid`=" + strconv.FormatInt(Cid, 10) + " AND "

	if len(search) > 0 {

		//解碼
		where = utils.DecodeSegment(search)

		revel.WARN.Println(where)

		if where["start_time"] != "" {
			WhereStr += " `createtime`='" + fmt.Sprintf("%s", where["start_time"]) + "' AND "
		}

		if where["start_time"] != "" {
			WhereStr += " `createtime`='" + fmt.Sprintf("%s", where["end_time"]) + "' AND "
		}

		if where["istop"] != "" {
			WhereStr += " `istop`='" + fmt.Sprintf("%s", where["istop"]) + "' AND "
		}

		if where["searchtype"] != "" && where["keyword"] != "" {

			if where["searchtype"] == "1" {
				//標題
				WhereStr += " `title` like '%" + fmt.Sprintf("%s", where["keyword"]) + "%' AND "
			} else if where["searchtype"] == "2" {
				//簡介
				WhereStr += " `description` like '%" + fmt.Sprintf("%s", where["keyword"]) + "%' AND "
			} else if where["searchtype"] == "3" {

				//用戶名
				keyword := fmt.Sprintf("%s", where["keyword"])
				Keyword, err := strconv.Atoi(keyword)

				revel.WARN.Println(Keyword)

				if err != nil {
					admin := new(Admin)
					admin_info := admin.GetByRealName(keyword)

					if admin_info.Id > 0 {
						WhereStr += " `aid`='" + strconv.FormatInt(admin_info.Id, 10) + "' AND "
					}
				} else {
					revel.WARN.Println(keyword)
					WhereStr += " `aid`='" + keyword + "' AND "
				}

			} else {
				//ID
				WhereStr += " `id`='" + fmt.Sprintf("%s", where["keyword"]) + "' AND "
			}
		}
	}

	WhereStr += " 1 "

	//查詢總數
	article := new(Article)
	Total, err := DB_Read.Where(WhereStr).Count(article)
	if err != nil {
		revel.WARN.Printf("錯誤: %v", err)
	}

	//分頁
	Pager := new(utils.Page)
	Pager.SubPage_link = "/Content/list/" + strconv.FormatInt(Cid, 10) + "/"
	Pager.Nums = Total
	Pager.Perpage = Perpage
	Pager.Current_page = Page
	Pager.SubPage_type = 2
	pages := Pager.Show()

	//查詢數據
	DB_Read.Where(WhereStr).Limit(int(Perpage), int((Page-1)*Pager.Perpage)).Desc("id").Find(&article_list)

	if len(article_list) > 0 {
		admin := new(Admin)
		category := new(Category)

		for i, v := range article_list {
			article_list[i].Admin = admin.GetById(v.Aid)

			//所屬欄目
			article_list[i].Category = category.GetById(v.Cid)
		}
	}

	return article_list, pages, where
}
開發者ID:blackmady,項目名稱:GoCMS,代碼行數:96,代碼來源:article.go

示例9: GetUserList

//獲取會員列表
func (u *User) GetUserList(search string, Page int64, Perpage int64) (user_arr []*User, html template.HTML, where map[string]interface{}) {
	//初始化菜單
	user_list := []*User{}

	//查詢條件
	var WhereStr string = " 1 AND "

	if len(search) > 0 {
		//解碼
		where = utils.DecodeSegment(search)

		revel.WARN.Println(where)

		if where["start_time"] != "" {
			WhereStr += " `regdate` >='" + fmt.Sprintf("%s", where["start_time"]) + " 00:00:00' AND "
		}

		if where["end_time"] != "" {
			WhereStr += " `regdate` <='" + fmt.Sprintf("%s", where["end_time"]) + " 23:59:59' AND "
		}

		if where["islock"] != "" && where["islock"] != "0" {
			WhereStr += " `islock` =" + fmt.Sprintf("%s", where["islock"])
		}

		if where["type"] != "" && where["keyword"] != "" {

			if where["type"] == "1" {
				//用戶名
				WhereStr += " `username` ='" + fmt.Sprintf("%s", where["keyword"]) + "' AND "
			} else if where["type"] == "2" {
				//用戶ID
				WhereStr += " `id` =" + fmt.Sprintf("%s", where["keyword"]) + " AND "
			} else if where["type"] == "3" {
				//郵箱
				WhereStr += " `email` ='" + fmt.Sprintf("%s", where["keyword"]) + "' AND "
			} else if where["type"] == "4" {
				//注冊ip
				WhereStr += " `regip` ='" + fmt.Sprintf("%s", where["keyword"]) + "' AND "
			} else if where["type"] == "5" {
				//昵稱
				WhereStr += " `nickname` like '%" + fmt.Sprintf("%s", where["keyword"]) + "%' AND "
			}
		}
	}

	WhereStr += " 1 "

	//查詢總數
	user := new(User)
	Total, err := DB_Read.Table("user").Where(WhereStr).Count(user)
	if err != nil {
		revel.WARN.Printf("錯誤: %v", err)
	}

	//分頁
	Pager := new(utils.Page)
	if len(search) > 0 {
		Pager.SubPage_link = "/User/" + search + "/"
	} else {
		Pager.SubPage_link = "/User/"
	}

	Pager.Nums = Total
	Pager.Perpage = Perpage
	Pager.Current_page = Page
	Pager.SubPage_type = 2
	pages := Pager.Show()

	DB_Read.Table("user").Where(WhereStr).Limit(int(Perpage), int((Page-1)*Pager.Perpage)).Desc("id").Find(&user_list)

	if len(user_list) > 0 {
		user_group := new(User_Group)
		for i, v := range user_list {
			user_list[i].UserGroup = user_group.GetById(v.Groupid)
		}
	}

	return user_list, pages, where
}
開發者ID:blackmady,項目名稱:GoCMS,代碼行數:81,代碼來源:user.go


注:本文中的github.com/blackmady/NoneCMS/utils.Page類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。