"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.OnmDomainBindingQuery = void 0;
const tslib_1 = require("tslib");
const type_graphql_1 = require("type-graphql");
const shell_1 = require("@things-factory/shell");
const auth_base_1 = require("@things-factory/auth-base");
const onm_domain_binding_1 = require("./onm-domain-binding");
const onm_domain_binding_type_1 = require("./onm-domain-binding-type");
const onm_domain_binding_repository_1 = require("./onm-domain-binding-repository");
let OnmDomainBindingQuery = class OnmDomainBindingQuery {
    // O&M에 속한 발전소 도메인 조회
    async domainsByOnmDomainId(onmDomainId, listParams, context) {
        const { domain } = context.state;
        const queryBuilder = (0, onm_domain_binding_repository_1.getPpDomainListInOnmDomainId)({ onmDomainId, listParams });
        const [items, total] = await queryBuilder.getManyAndCount();
        return { items, total };
    }
    async updater(onmDomainBinding) {
        return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: onmDomainBinding.updaterId });
    }
    async creator(onmDomainBinding) {
        return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: onmDomainBinding.creatorId });
    }
};
exports.OnmDomainBindingQuery = OnmDomainBindingQuery;
tslib_1.__decorate([
    (0, type_graphql_1.Query)(returns => onm_domain_binding_type_1.OnmDomainBindingList, { description: 'To fetch multiple OnmDomainBindings' }),
    tslib_1.__param(0, (0, type_graphql_1.Arg)('onmDomainId')),
    tslib_1.__param(1, (0, type_graphql_1.Args)()),
    tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
    tslib_1.__metadata("design:type", Function),
    tslib_1.__metadata("design:paramtypes", [String, shell_1.ListParam, Object]),
    tslib_1.__metadata("design:returntype", Promise)
], OnmDomainBindingQuery.prototype, "domainsByOnmDomainId", null);
tslib_1.__decorate([
    (0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
    tslib_1.__param(0, (0, type_graphql_1.Root)()),
    tslib_1.__metadata("design:type", Function),
    tslib_1.__metadata("design:paramtypes", [onm_domain_binding_1.OnmDomainBinding]),
    tslib_1.__metadata("design:returntype", Promise)
], OnmDomainBindingQuery.prototype, "updater", null);
tslib_1.__decorate([
    (0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
    tslib_1.__param(0, (0, type_graphql_1.Root)()),
    tslib_1.__metadata("design:type", Function),
    tslib_1.__metadata("design:paramtypes", [onm_domain_binding_1.OnmDomainBinding]),
    tslib_1.__metadata("design:returntype", Promise)
], OnmDomainBindingQuery.prototype, "creator", null);
exports.OnmDomainBindingQuery = OnmDomainBindingQuery = tslib_1.__decorate([
    (0, type_graphql_1.Resolver)(onm_domain_binding_1.OnmDomainBinding)
], OnmDomainBindingQuery);
//# sourceMappingURL=onm-domain-binding-query.js.map