3
0

upd(crm): return page on module content items

This commit is contained in:
Tit Petric
2018-10-16 12:39:48 +02:00
parent ef5e56717b
commit 43c36f9964
+13 -1
View File
@@ -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
}