本文整理匯總了Golang中github.com/grafana/grafana/pkg/models.Org類的典型用法代碼示例。如果您正苦於以下問題:Golang Org類的具體用法?Golang Org怎麽用?Golang Org使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Org類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: getOrgIdForNewUser
func getOrgIdForNewUser(userEmail string, sess *session) (int64, error) {
var org m.Org
if setting.AutoAssignOrg {
// right now auto assign to org with id 1
has, err := sess.Where("id=?", 1).Get(&org)
if err != nil {
return 0, err
}
if has {
return org.Id, nil
} else {
org.Name = "Main Org."
org.Id = 1
}
} else {
org.Name = userEmail
}
org.Created = time.Now()
org.Updated = time.Now()
if _, err := sess.Insert(&org); err != nil {
return 0, err
}
sess.publishAfterCommit(&events.OrgCreated{
Timestamp: org.Created,
Id: org.Id,
Name: org.Name,
})
return org.Id, nil
}
示例2: getOrgIdForNewUser
func getOrgIdForNewUser(cmd *m.CreateUserCommand, sess *session) (int64, error) {
if cmd.SkipOrgSetup {
return -1, nil
}
var org m.Org
if setting.AutoAssignOrg {
// right now auto assign to org with id 1
has, err := sess.Where("id=?", 1).Get(&org)
if err != nil {
return 0, err
}
if has {
return org.Id, nil
} else {
org.Name = "Main Org."
org.Id = 1
}
} else {
org.Name = cmd.OrgName
if len(org.Name) == 0 {
org.Name = util.StringsFallback2(cmd.Email, cmd.Login)
}
}
org.Created = time.Now()
org.Updated = time.Now()
if _, err := sess.Insert(&org); err != nil {
return 0, err
}
sess.publishAfterCommit(&events.OrgCreated{
Timestamp: org.Created,
Id: org.Id,
Name: org.Name,
})
return org.Id, nil
}