"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PostService = void 0;
const tslib_1 = require("tslib");
const core_1 = require("@loopback/core");
const models_1 = require("../../models");
const object_tree_service_1 = require("./../../services/object-tree/object-tree.service");
const transient_entity_service_1 = require("./../../services/transient-entity/transient-entity.service");
const post_const_1 = require("./post.const");
let PostService = class PostService {
    constructor(transientEntityService, objectTreeService) {
        this.transientEntityService = transientEntityService;
        this.objectTreeService = objectTreeService;
        this.transientEntityService.registerTransientEntityTypeFunction(post_const_1.POST_PROVIDER, PostService.name, 'Add postTrees field, list of sub-post', models_1.EntityName.objectTree, post_const_1.POST_WITH_SUB_POST_TYPE.name, this.completePostWithSubPostTree.bind(this));
    }
    async completePostWithSubPostTree(entity, ctx) {
        const postTrees = (await this.objectTreeService.getChildrenByImplementedTypeId(entity))[post_const_1.POST_WITH_SUB_POST_TYPE.name];
        entity.postTrees = postTrees ? postTrees : [];
    }
};
PostService = tslib_1.__decorate([
    tslib_1.__param(0, core_1.service(transient_entity_service_1.TransientEntityService)),
    tslib_1.__param(1, core_1.service(object_tree_service_1.ObjectTreeService)),
    tslib_1.__metadata("design:paramtypes", [transient_entity_service_1.TransientEntityService,
        object_tree_service_1.ObjectTreeService])
], PostService);
exports.PostService = PostService;
//# sourceMappingURL=post.service.js.map