get other accounts works

This commit is contained in:
Torkel Ödegaard
2014-11-24 08:04:41 +01:00
parent f04932aa67
commit fcdcd63dc7
7 changed files with 55 additions and 7 deletions
+1
View File
@@ -32,6 +32,7 @@ func Init() {
models.CreateAccount = CreateAccount
models.GetAccount = GetAccount
models.GetAccountByLogin = GetAccountByLogin
models.GetOtherAccountsFor = GetOtherAccountsFor
models.GetDashboard = GetDashboard
models.SaveDashboard = SaveDashboard
models.SearchQuery = SearchQuery
+12
View File
@@ -60,9 +60,12 @@ func GetAccountByLogin(emailOrLogin string) (*models.Account, error) {
func GetCollaboratorsForAccount(accountId int64) ([]*models.CollaboratorInfo, error) {
collaborators := make([]*models.CollaboratorInfo, 0)
sess := x.Table("Collaborator")
sess.Join("INNER", "Account", "Account.id=Collaborator.account_Id")
sess.Where("Collaborator.for_account_id=?", accountId)
err := sess.Find(&collaborators)
return collaborators, err
}
@@ -85,3 +88,12 @@ func AddCollaborator(collaborator *models.Collaborator) error {
return nil
}
func GetOtherAccountsFor(accountId int64) ([]*models.OtherAccount, error) {
collaborators := make([]*models.OtherAccount, 0)
sess := x.Table("Collaborator")
sess.Join("INNER", "Account", "Account.id=Collaborator.account_Id")
sess.Where("Collaborator.account_id=?", accountId)
err := sess.Find(&collaborators)
return collaborators, err
}