/* * @Author: ag * @LastEditTime: 2022-11-14 10:25:48 * @LastEditors: ag 2663588772@qq.com * @Description: */ import { Query, QueryTask, QueryType, Operator, ThirdpartyObjectType } from './cellsysUtil.js'; import { CellsysExtensionRecord } from './cellsysExtension.js'; class CellsysElement { constructor(params) { if (!params) { params = {}; } this.orgName = params.org_name; this.id = params.id; this.name = params.name; this.description = params.description; this.type = params.type; this.typeIsUnlock = params.type_is_unlock; this.typeIsUpdate = params.type_is_update; this.createBy = params.create_by; this.createTime = params.create_time; this.updateBy = params.update_by; this.updateTime = params.update_time; this.typeIsPublish = params.type_is_publish; this.typeIsUnlock = params.type_is_unlock; this.typeIsUpdate = params.type_is_update; //外部跳转链接 if (params.links && params.links.length > 0) { this.links = { href: null, title: null, }; let links = params.links[0]; //暂时先只读取一个 this.links['href'] = links.href; this.links['title'] = links.title; } let creator = params.creator; this.creator = { memberId: null, name: null, }; if (creator) { this.creator = { memberId: creator.member_id, name: creator.name, }; } let updater = params.updater; this.updater = { memberId: null, name: null, }; if (updater) { this.updater = { memberId: updater.member_id, name: updater.name, }; } } //查询第三方数据 queryExtension() { let query = new Query(); query.addFilter('object_type', Operator.Equals, ThirdpartyObjectType[this.cellsysType]); query.addFilter('type_id', Operator.Equals, this.type); query.addFilter('api_is_publish', Operator.Equals, 1); let queryTask = new QueryTask(QueryType.ThirdpartyTypeRel, false); return new Promise((resolve, reject) => { queryTask .execute(query) .then((res) => { let thirdPartyList = []; for (let item of res) { let cellsysExtensionRecord = new CellsysExtensionRecord(item); thirdPartyList.push(cellsysExtensionRecord); } resolve(thirdPartyList); }) .catch((err) => { reject(err); }); }); } } export default CellsysElement;