diff --git a/dao/taking.go b/dao/taking.go index a251371..92187fe 100644 --- a/dao/taking.go +++ b/dao/taking.go @@ -109,18 +109,18 @@ func TakingUpdate(ctx context.Context, i *models.TakingUpdate, token *vcapool.Ac return } -func TakingGet(ctx context.Context, query *models.TakingQuery, token *vcapool.AccessToken) (result *[]models.Taking, listSize int64, err error) { +func TakingGet(ctx context.Context, query *models.TakingQuery, token *vcapool.AccessToken) (result []models.Taking, listSize int64, err error) { if err = models.TakingPermission(token); err != nil { return } - result = new([]models.Taking) + result = []models.Taking{} filter := query.PermittedFilter(token) sort := query.Sort() pipeline := models.TakingPipeline().SortFields(sort).Match(filter).Sort(sort).Skip(query.Skip, 0).Limit(query.Limit, 100).Pipe if err = TakingCollection.Aggregate( ctx, pipeline, - result, + &result, ); err != nil { return } diff --git a/handlers/token/artist.go b/handlers/token/artist.go index 8017cec..5b441e9 100644 --- a/handlers/token/artist.go +++ b/handlers/token/artist.go @@ -87,7 +87,7 @@ func (i *ArtistHandler) Update(cc echo.Context) (err error) { func (i *ArtistHandler) Delete(cc echo.Context) (err error) { c := cc.(vcago.Context) body := new(models.ArtistParam) - if c.BindAndValidate(body); err != nil { + if err = c.BindAndValidate(body); err != nil { return c.ErrorResponse(err) } token := new(vcapool.AccessToken) diff --git a/handlers/token/login.go b/handlers/token/login.go index cf987dd..b9f676c 100644 --- a/handlers/token/login.go +++ b/handlers/token/login.go @@ -75,7 +75,7 @@ func (i *LoginHandler) Callback(cc echo.Context) (err error) { func (i *LoginHandler) LoginAPI(cc echo.Context) (err error) { c := cc.(vcago.Context) body := new(models.UserEmail) - if c.BindAndValidate(body); err != nil { + if err = c.BindAndValidate(body); err != nil { return } result := new(models.User) diff --git a/handlers/token/organizer.go b/handlers/token/organizer.go index 61ed940..22171e5 100644 --- a/handlers/token/organizer.go +++ b/handlers/token/organizer.go @@ -87,7 +87,7 @@ func (i *OrganizerHandler) Update(cc echo.Context) (err error) { func (i *OrganizerHandler) Delete(cc echo.Context) (err error) { c := cc.(vcago.Context) body := new(models.OrganizerParam) - if c.BindAndValidate(body); err != nil { + if err = c.BindAndValidate(body); err != nil { return c.ErrorResponse(err) } token := new(vcapool.AccessToken) diff --git a/handlers/token/taking.go b/handlers/token/taking.go index f988f85..6c55eb3 100644 --- a/handlers/token/taking.go +++ b/handlers/token/taking.go @@ -70,7 +70,7 @@ func (i TakingHandler) Get(cc echo.Context) (err error) { if err = c.AccessToken(token); err != nil { return } - result := new([]models.Taking) + var result []models.Taking var listSize int64 if result, listSize, err = dao.TakingGet(c.Ctx(), body, token); err != nil { return diff --git a/models/taking.go b/models/taking.go index 1533c18..c74cca0 100644 --- a/models/taking.go +++ b/models/taking.go @@ -112,7 +112,7 @@ func TakingPipeline() *vmdb.Pipeline { pipe.Lookup(SourceCollection, "_id", "taking_id", "sources") pipe.LookupUnwind(CrewCollection, "crew_id", "_id", "crew") pipe.LookupUnwind(EventCollection, "_id", "taking_id", "event") - //pipe.LookupList(ArtistCollection, "event.artist_ids", "_id", "event.artists") + pipe.Lookup(ArtistCollection, "event.artist_ids", "_id", "event.artists") pipe.Append(bson.D{{Key: "$addFields", Value: bson.D{ {Key: "state.wait.amount", Value: bson.D{{Key: "$sum", Value: "$wait.money.amount"}}}, }}})