UNPKG

@tnwx/commons

Version:

TTNWX 微信系开发脚手架之公共模块

51 lines 1.64 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const OutMsg_1 = require("./OutMsg"); const News_1 = require("./News"); class OutNewsMsg extends OutMsg_1.OutMsg { constructor(inMsg) { super(inMsg); this.articles = []; this.msgType = 'news'; } toXml() { let str = super.toXml(); str += '<ArticleCount>' + this.getArticleCount + '</ArticleCount>\n<Articles>\n'; this.articles.forEach(item => { str += '<item>\n'; str += '<Title><![CDATA[' + item.getTitle + ']]></Title>\n'; str += '<Description><![CDATA[' + item.getDescription + ']]></Description>\n'; str += '<PicUrl><![CDATA[' + item.getPicUrl + ']]></PicUrl>\n'; str += '<Url><![CDATA[' + item.getUrl + ']]></Url>\n'; str += '</item>\n'; }); str += '</Articles>\n'; str += '</xml>\n'; return str; } get getArticleCount() { return this.articles.length; } get getArticles() { return this.articles; } set setArticles(articles) { if (articles != null) this.articles = articles; } addNews(articles) { if (articles != null) this.articles.concat(articles); return this; } addArticle(title, description, picUrl, url) { this.articles.push(News_1.News.getInstantiationNews(title, description, picUrl, url)); return this; } addNew(news) { this.articles.push(news); return this; } } exports.OutNewsMsg = OutNewsMsg; //# sourceMappingURL=OutNewsMsg.js.map