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


Golang info.User类代码示例

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


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

示例1: setUserLogo

func (this *UserService) setUserLogo(user *info.User) {
	// Logo路径问题, 有些有http: 有些没有
	if user.Logo == "" {
		user.Logo = "images/blog/default_avatar.png"
	}
	if user.Logo != "" && !strings.HasPrefix(user.Logo, "http") {
		user.Logo = strings.Trim(user.Logo, "/")
		user.Logo = configService.GetSiteUrl() + "/" + user.Logo
	}
}
开发者ID:JacobXie,项目名称:leanote-daocloud,代码行数:10,代码来源:UserService.go

示例2: Register

// 1. 添加用户
// 2. 将leanote共享给我
// [ok]
func (this *AuthService) Register(email, pwd, fromUserId string) (bool, string) {
	// 用户是否已存在
	if userService.IsExistsUser(email) {
		return false, "userHasBeenRegistered-" + email
	}
	passwd := GenPwd(pwd)
	if passwd == "" {
		return false, "GenerateHash error"
	}
	user := info.User{UserId: bson.NewObjectId(), Email: email, Username: email, Pwd: passwd}
	if fromUserId != "" && IsObjectId(fromUserId) {
		user.FromUserId = bson.ObjectIdHex(fromUserId)
	}
	return this.register(user)
}
开发者ID:JacobXie,项目名称:leanote-daocloud,代码行数:18,代码来源:AuthService.go

示例3: AddUser

// 添加用户
func (this *UserService) AddUser(user info.User) bool {
	if user.UserId == "" {
		user.UserId = bson.NewObjectId()
	}
	user.CreatedTime = time.Now()

	if user.Email != "" {
		user.Email = strings.ToLower(user.Email)

		// 发送验证邮箱
		go func() {
			emailService.RegisterSendActiveEmail(user, user.Email)
			// 发送给我 [email protected]
			emailService.SendEmail("[email protected]", "新增用户", "{header}用户名"+user.Email+"{footer}")
		}()
	}

	return db.Insert(db.Users, user)
}
开发者ID:JacobXie,项目名称:leanote-daocloud,代码行数:20,代码来源:UserService.go

示例4: Init

// 初始化时连接数据库
func Init(url, dbname string) {
	ok := true
	config := revel.Config
	if url == "" {
		url, ok = config.String("db.url")
		if !ok {
			url, ok = config.String("db.urlEnv")
			if ok {
				Log("get db conf from urlEnv: " + url)
			}
		} else {
			Log("get db conf from db.url: " + url)
		}

		if ok {
			// get dbname from urlEnv
			urls := strings.Split(url, "/")
			dbname = urls[len(urls)-1]
		}
	}
	if dbname == "" {
		dbname, _ = config.String("db.dbname")
	}

	// get db config from host, port, username, password
	if !ok {
		host, _ := revel.Config.String("db.host")
		port, _ := revel.Config.String("db.port")
		username, _ := revel.Config.String("db.username")
		password, _ := revel.Config.String("db.password")
		usernameAndPassword := username + ":" + password + "@"
		if username == "" || password == "" {
			usernameAndPassword = ""
		}
		//mpodified by JacobXie
		//url = "mongodb://" + usernameAndPassword + host + ":" + port + "/" + dbname
		url = fmt.Sprintf("%s%s:%s/%s", usernameAndPassword, host, port, dbname)
	}
	Log(url)

	// [mongodb://][user:[email protected]]host1[:port1][,host2[:port2],...][/database][?options]
	// mongodb://myuser:[email protected]:40001,otherhost:40001/mydb
	var err error
	Session, err = mgo.Dial(url)
	if err != nil {
		panic(err)
	}

	// Optional. Switch the session to a monotonic behavior.
	Session.SetMode(mgo.Monotonic, true)

	// notebook
	Notebooks = Session.DB(dbname).C("notebooks")

	// notes
	Notes = Session.DB(dbname).C("notes")

	// noteContents
	NoteContents = Session.DB(dbname).C("note_contents")
	NoteContentHistories = Session.DB(dbname).C("note_content_histories")

	// share
	ShareNotes = Session.DB(dbname).C("share_notes")
	ShareNotebooks = Session.DB(dbname).C("share_notebooks")
	HasShareNotes = Session.DB(dbname).C("has_share_notes")

	// user
	Users = Session.DB(dbname).C("users")
	// group
	Groups = Session.DB(dbname).C("groups")
	GroupUsers = Session.DB(dbname).C("group_users")

	// blog
	Blogs = Session.DB(dbname).C("blogs")

	// tag
	Tags = Session.DB(dbname).C("tags")
	NoteTags = Session.DB(dbname).C("note_tags")
	TagCounts = Session.DB(dbname).C("tag_count")

	// blog
	UserBlogs = Session.DB(dbname).C("user_blogs")
	BlogSingles = Session.DB(dbname).C("blog_singles")
	Themes = Session.DB(dbname).C("themes")

	// find password
	Tokens = Session.DB(dbname).C("tokens")

	// Suggestion
	Suggestions = Session.DB(dbname).C("suggestions")

	// Album & file
	Albums = Session.DB(dbname).C("albums")
	Files = Session.DB(dbname).C("files")
	Attachs = Session.DB(dbname).C("attachs")

	NoteImages = Session.DB(dbname).C("note_images")

	Configs = Session.DB(dbname).C("configs")
//.........这里部分代码省略.........
开发者ID:JacobXie,项目名称:leanote,代码行数:101,代码来源:Mgo.go


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