From 43c36f9964c9b0fe52889bead2bb1b9e5c45d33c Mon Sep 17 00:00:00 2001 From: Tit Petric Date: Tue, 16 Oct 2018 12:39:48 +0200 Subject: [PATCH] upd(crm): return page on module content items --- crm/repository/content.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/crm/repository/content.go b/crm/repository/content.go index efc6f2f77..89bb1e77b 100644 --- a/crm/repository/content.go +++ b/crm/repository/content.go @@ -45,7 +45,13 @@ func (r *content) With(ctx context.Context, db *factory.DB) ContentRepository { func (r *content) FindByID(id uint64) (*types.Content, error) { mod := &types.Content{} - return mod, r.db().Get(mod, "SELECT * FROM crm_content WHERE id=? and deleted_at IS NULL", id) + if err := r.db().Get(mod, "SELECT * FROM crm_content WHERE id=? and deleted_at IS NULL", id); err != nil { + return nil, err + } + if err := r.fillPage(mod); err != nil { + return nil, err + } + return mod, nil } func (r *content) Find() ([]*types.Content, error) { @@ -122,3 +128,9 @@ func (r *content) Fields(content *types.Content) ([]*types.ContentColumn, error) } return result, r.db().Select(&result, "select * from crm_content_column where content_id=? order by "+order, args...) } + +func (r *content) fillPage(content *types.Content) (err error) { + api := Page(r.Context(), r.db()) + content.Page, err = api.FindByModuleID(content.ModuleID) + return +}