implemented get all teams the user is part of
This commit is contained in:
parent
b11bd9f0b1
commit
f6a816941b
3 changed files with 15 additions and 1 deletions
|
@ -120,3 +120,15 @@ func (t *Team) ReadOne(id int64) (err error) {
|
|||
*t, err = GetTeamByID(id)
|
||||
return
|
||||
}
|
||||
|
||||
// ReadAll gets all teams the user is part of
|
||||
func (t *Team) ReadAll(user *User) (teams interface{}, err error) {
|
||||
all := []*Team{}
|
||||
err = x.Select("teams.*").
|
||||
Table("teams").
|
||||
Join("INNER", "team_members", "team_members.team_id = teams.id").
|
||||
Where("team_members.user_id = ?", user.ID).
|
||||
Find(&all)
|
||||
|
||||
return all, err
|
||||
}
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
package models
|
|
@ -1,6 +1,7 @@
|
|||
package crud
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.kolaente.de/konrad/list/models"
|
||||
"github.com/labstack/echo"
|
||||
"net/http"
|
||||
|
@ -15,6 +16,8 @@ func (c *WebHandler) ReadAllWeb(ctx echo.Context) error {
|
|||
|
||||
lists, err := c.CObject.ReadAll(¤tUser)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
|
||||
return echo.NewHTTPError(http.StatusInternalServerError, "An error occured.")
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue