当前位置: 首页>>代码示例>>Golang>>正文


Golang util.MapKeys函数代码示例

本文整理汇总了Golang中util.MapKeys函数的典型用法代码示例。如果您正苦于以下问题:Golang MapKeys函数的具体用法?Golang MapKeys怎么用?Golang MapKeys使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了MapKeys函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Find

// Find 查找单条数据
// colFieldMap 数据库表中列对应go中对象的字段
func (this *Dao) Find(colFieldMap map[string]interface{}, selectCol ...string) error {
	colNum := len(selectCol)
	if colNum == 0 || (colNum == 1 && selectCol[0] == "*") {
		selectCol = util.MapKeys(colFieldMap)
	}
	sort.Sort(sort.StringSlice(selectCol))
	this.selectCols = "`" + strings.Join(selectCol, "`,`") + "`"
	strSql := util.SelectSql(this)
	logger.Debugln("Find sql:", strSql)
	err := this.Open()
	if err != nil {
		return err
	}
	defer this.Close()
	row := this.QueryRow(strSql, this.whereVal...)
	scanInterface := make([]interface{}, 0, colNum)
	for _, column := range selectCol {
		scanInterface = append(scanInterface, colFieldMap[column])
	}
	err = row.Scan(scanInterface...)
	if err == sql.ErrNoRows {
		logger.Infoln("Find", strSql, ":no result ret")
		return nil
	}
	return err
}
开发者ID:jimmykuu,项目名称:studygolang,代码行数:28,代码来源:dao.go

示例2: FindAll

func (this *TopicNode) FindAll(selectCol ...string) ([]*TopicNode, error) {
	if len(selectCol) == 0 {
		selectCol = util.MapKeys(this.colFieldMap())
	}
	rows, err := this.Dao.FindAll(selectCol...)
	if err != nil {
		return nil, err
	}
	// TODO:
	nodeList := make([]*TopicNode, 0, 10)
	logger.Debugln("selectCol", selectCol)
	colNum := len(selectCol)
	for rows.Next() {
		node := NewTopicNode()
		colFieldMap := node.colFieldMap()
		scanInterface := make([]interface{}, 0, colNum)
		for _, column := range selectCol {
			scanInterface = append(scanInterface, colFieldMap[column])
		}
		err = rows.Scan(scanInterface...)
		if err != nil {
			logger.Errorln("TopicNode FindAll Scan Error:", err)
			continue
		}
		nodeList = append(nodeList, node)
	}
	return nodeList, nil
}
开发者ID:jimmykuu,项目名称:studygolang,代码行数:28,代码来源:topic.go

示例3: FindAll

func (this *MorningReading) FindAll(selectCol ...string) ([]*MorningReading, error) {
	if len(selectCol) == 0 {
		selectCol = util.MapKeys(this.colFieldMap())
	}
	rows, err := this.Dao.FindAll(selectCol...)
	if err != nil {
		return nil, err
	}
	// TODO:
	readingList := make([]*MorningReading, 0, 10)
	logger.Debugln("selectCol", selectCol)
	colNum := len(selectCol)
	for rows.Next() {
		reading := NewMorningReading()
		err = this.Scan(rows, colNum, reading.colFieldMap(), selectCol...)
		if err != nil {
			logger.Errorln("MorningReading FindAll Scan Error:", err)
			continue
		}
		reading.Rdate = reading.Ctime[:10]
		if reading.Moreurls != "" {
			reading.Urls = strings.Split(reading.Moreurls, ",")
		}
		readingList = append(readingList, reading)
	}
	return readingList, nil
}
开发者ID:bluefchen,项目名称:studygolang,代码行数:27,代码来源:reading.go

示例4: FindAll

func (this *UserRole) FindAll(selectCol ...string) ([]*UserRole, error) {
	if len(selectCol) == 0 {
		selectCol = util.MapKeys(this.colFieldMap())
	}
	rows, err := this.Dao.FindAll(selectCol...)
	if err != nil {
		logger.Errorln("[UserRole.FindAll] error:", err)
		return nil, err
	}
	// TODO:
	userRoleList := make([]*UserRole, 0, 10)
	colNum := len(selectCol)
	for rows.Next() {
		userRole := NewUserRole()
		colFieldMap := userRole.colFieldMap()
		scanInterface := make([]interface{}, 0, colNum)
		for _, column := range selectCol {
			scanInterface = append(scanInterface, colFieldMap[column])
		}
		err = rows.Scan(scanInterface...)
		if err != nil {
			logger.Errorln("[UserRole.FindAll Rows] error:", err)
		}
		userRoleList = append(userRoleList, userRole)
	}
	return userRoleList, nil
}
开发者ID:jimmykuu,项目名称:studygolang,代码行数:27,代码来源:user.go

示例5: FindAll

func (this *Comment) FindAll(selectCol ...string) ([]*Comment, error) {
	if len(selectCol) == 0 {
		selectCol = util.MapKeys(this.colFieldMap())
	}
	rows, err := this.Dao.FindAll(selectCol...)
	if err != nil {
		return nil, err
	}
	// TODO:
	commentList := make([]*Comment, 0, 10)
	colNum := len(selectCol)
	for rows.Next() {
		comment := NewComment()
		colFieldMap := comment.colFieldMap()
		scanInterface := make([]interface{}, 0, colNum)
		for _, column := range selectCol {
			scanInterface = append(scanInterface, colFieldMap[column])
		}
		err = rows.Scan(scanInterface...)
		if err != nil {
			logger.Errorln("Comment FindAll Scan Error:", err)
			continue
		}
		commentList = append(commentList, comment)
	}
	return commentList, nil
}
开发者ID:jimmykuu,项目名称:studygolang,代码行数:27,代码来源:comment.go

示例6: FindAll

func (this *Comment) FindAll(selectCol ...string) ([]*Comment, error) {
	if len(selectCol) == 0 {
		selectCol = util.MapKeys(this.colFieldMap())
	}
	rows, err := this.Dao.FindAll(selectCol...)
	if err != nil {
		return nil, err
	}
	// TODO:
	commentList := make([]*Comment, 0, 10)
	colNum := len(selectCol)
	for rows.Next() {
		comment := NewComment()
		err = this.Scan(rows, colNum, comment.colFieldMap(), selectCol...)
		if err != nil {
			logger.Errorln("Comment FindAll Scan Error:", err)
			continue
		}
		commentList = append(commentList, comment)
	}
	return commentList, nil
}
开发者ID:jackyxie,项目名称:btcrobot,代码行数:22,代码来源:comment.go

示例7: FindAll

func (this *Message) FindAll(selectCol ...string) ([]*Message, error) {
	if len(selectCol) == 0 {
		selectCol = util.MapKeys(this.colFieldMap())
	}
	rows, err := this.Dao.FindAll(selectCol...)
	if err != nil {
		return nil, err
	}
	// TODO:
	messageList := make([]*Message, 0, 10)
	colNum := len(selectCol)
	for rows.Next() {
		message := NewMessage()
		err = this.Scan(rows, colNum, message.colFieldMap(), selectCol...)
		if err != nil {
			logger.Errorln("Message FindAll Scan Error:", err)
			continue
		}
		messageList = append(messageList, message)
	}
	return messageList, nil
}
开发者ID:BillyMC,项目名称:studygolang,代码行数:22,代码来源:message.go

示例8: FindAll

func (this *Like) FindAll(selectCol ...string) ([]*Like, error) {
	if len(selectCol) == 0 {
		selectCol = util.MapKeys(this.colFieldMap())
	}
	rows, err := this.Dao.FindAll(selectCol...)
	if err != nil {
		return nil, err
	}
	// TODO:
	likeList := make([]*Like, 0, 10)
	colNum := len(selectCol)
	for rows.Next() {
		like := NewLike()
		err = this.Scan(rows, colNum, like.colFieldMap(), selectCol...)
		if err != nil {
			logger.Errorln("Like FindAll Scan Error:", err)
			continue
		}
		likeList = append(likeList, like)
	}
	return likeList, nil
}
开发者ID:bluefchen,项目名称:studygolang,代码行数:22,代码来源:like.go

示例9: FindAll

func (this *TopicNode) FindAll(selectCol ...string) ([]*TopicNode, error) {
	if len(selectCol) == 0 {
		selectCol = util.MapKeys(this.colFieldMap())
	}
	rows, err := this.Dao.FindAll(selectCol...)
	if err != nil {
		return nil, err
	}
	// TODO:
	nodeList := make([]*TopicNode, 0, 10)
	//logger.Debugln("selectCol", selectCol)
	colNum := len(selectCol)
	for rows.Next() {
		node := NewTopicNode()
		err = this.Scan(rows, colNum, node.colFieldMap(), selectCol...)
		if err != nil {
			logger.Errorln("TopicNode FindAll Scan Error:", err)
			continue
		}
		nodeList = append(nodeList, node)
	}
	return nodeList, nil
}
开发者ID:xuzhiping7,项目名称:studygolang,代码行数:23,代码来源:topic.go

示例10: FindAll

func (this *Favorite) FindAll(selectCol ...string) ([]*Favorite, error) {
	if len(selectCol) == 0 {
		selectCol = util.MapKeys(this.colFieldMap())
	}
	rows, err := this.Dao.FindAll(selectCol...)
	if err != nil {
		return nil, err
	}
	// TODO:
	favoriteList := make([]*Favorite, 0, 10)
	logger.Debugln("selectCol", selectCol)
	colNum := len(selectCol)
	for rows.Next() {
		favorite := NewFavorite()
		err = this.Scan(rows, colNum, favorite.colFieldMap(), selectCol...)
		if err != nil {
			logger.Errorln("Favorite FindAll Scan Error:", err)
			continue
		}
		favoriteList = append(favoriteList, favorite)
	}
	return favoriteList, nil
}
开发者ID:bluefchen,项目名称:studygolang,代码行数:23,代码来源:favorite.go

示例11: FindAll

func (this *RoleAuthority) FindAll(selectCol ...string) ([]*RoleAuthority, error) {
	if len(selectCol) == 0 {
		selectCol = util.MapKeys(this.colFieldMap())
	}
	rows, err := this.Dao.FindAll(selectCol...)
	if err != nil {
		return nil, err
	}
	// TODO:
	roleAuthList := make([]*RoleAuthority, 0, 10)
	logger.Debugln("selectCol", selectCol)
	colNum := len(selectCol)
	for rows.Next() {
		roleAuth := NewRoleAuthority()
		err = this.Scan(rows, colNum, roleAuth.colFieldMap(), selectCol...)
		if err != nil {
			logger.Errorln("RoleAuthority FindAll Scan Error:", err)
			continue
		}
		roleAuthList = append(roleAuthList, roleAuth)
	}
	return roleAuthList, nil
}
开发者ID:bluefchen,项目名称:studygolang,代码行数:23,代码来源:role.go

示例12: FindAll

func (this *OpenProject) FindAll(selectCol ...string) ([]*OpenProject, error) {
	if len(selectCol) == 0 {
		selectCol = util.MapKeys(this.colFieldMap())
	}
	rows, err := this.Dao.FindAll(selectCol...)
	if err != nil {
		return nil, err
	}
	// TODO:
	projectList := make([]*OpenProject, 0, 10)
	logger.Debugln("selectCol", selectCol)
	colNum := len(selectCol)
	for rows.Next() {
		project := NewOpenProject()
		err = this.Scan(rows, colNum, project.colFieldMap(), selectCol...)
		if err != nil {
			logger.Errorln("OpenProject FindAll Scan Error:", err)
			continue
		}
		projectList = append(projectList, project)
	}
	return projectList, nil
}
开发者ID:bluefchen,项目名称:studygolang,代码行数:23,代码来源:openproject.go

示例13: FindAll

func (this *UserRole) FindAll(selectCol ...string) ([]*UserRole, error) {
	if len(selectCol) == 0 {
		selectCol = util.MapKeys(this.colFieldMap())
	}
	rows, err := this.Dao.FindAll(selectCol...)
	if err != nil {
		logger.Errorln("[UserRole.FindAll] error:", err)
		return nil, err
	}
	// TODO:
	userRoleList := make([]*UserRole, 0, 10)
	colNum := len(selectCol)
	for rows.Next() {
		userRole := NewUserRole()
		err = this.Scan(rows, colNum, userRole.colFieldMap(), selectCol...)
		if err != nil {
			logger.Errorln("UserRole FindAll Scan Error:", err)
			continue
		}
		userRoleList = append(userRoleList, userRole)
	}
	return userRoleList, nil
}
开发者ID:bluefchen,项目名称:studygolang,代码行数:23,代码来源:user.go

示例14: FindAll

func (this *Wiki) FindAll(selectCol ...string) ([]*Wiki, error) {
	if len(selectCol) == 0 {
		selectCol = util.MapKeys(this.colFieldMap())
	}
	rows, err := this.Dao.FindAll(selectCol...)
	if err != nil {
		return nil, err
	}
	// TODO:
	wikiList := make([]*Wiki, 0, 10)
	logger.Debugln("selectCol", selectCol)
	colNum := len(selectCol)
	for rows.Next() {
		wiki := NewWiki()
		err = this.Scan(rows, colNum, wiki.colFieldMap(), selectCol...)
		if err != nil {
			logger.Errorln("Wiki FindAll Scan Error:", err)
			continue
		}
		wikiList = append(wikiList, wiki)
	}
	return wikiList, nil
}
开发者ID:bluefchen,项目名称:studygolang,代码行数:23,代码来源:wiki.go

示例15: FindAll

func (this *Resource) FindAll(selectCol ...string) ([]*Resource, error) {
	if len(selectCol) == 0 {
		selectCol = util.MapKeys(this.colFieldMap())
	}
	rows, err := this.Dao.FindAll(selectCol...)
	if err != nil {
		return nil, err
	}
	// TODO:
	resourceList := make([]*Resource, 0, 10)
	logger.Debugln("selectCol", selectCol)
	colNum := len(selectCol)
	for rows.Next() {
		resource := NewResource()
		err = this.Scan(rows, colNum, resource.colFieldMap(), selectCol...)
		if err != nil {
			logger.Errorln("Resource FindAll Scan Error:", err)
			continue
		}
		resourceList = append(resourceList, resource)
	}
	return resourceList, nil
}
开发者ID:BillyMC,项目名称:studygolang,代码行数:23,代码来源:resource.go


注:本文中的util.MapKeys函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。