def self.get_cate_news(categories = [])
categories.each do |item|
img = self.get_news_list(false, false, "n.classid = '#{item.id}'", 'n.id desc', '2', '0')
hot = self.get_news_list(false, false, "n.classid = '#{item.id}' and imgurl<>''", 'n.id desc', '12', '0')
item.img = img
item.hot = hot
end
end
categories 对象是这样的:[{"id":1,"classname":"穿越小说"},{"id":2,"classname":"言情小说"},{"id":3,"classname":"玄幻小说"},{"id":4,"classname":"历史架空"},{"id":5,"classname":"武侠仙侠"},{"id":6,"classname":"都市异能"},{"id":7,"classname":"恐怖悬疑"},{"id":8,"classname":"星际科幻"},{"id":9,"classname":"网游竞技"},{"id":10,"classname":"耽美同人"},{"id":11,"classname":"军事战争"}]
我循环 categories 获得对应的 img、hot 数据,然后赋值给 categories 每个对象, item.img = img item.hot = hot 这种方式我就想给每个对象新增两个 key,这种写法不对~