123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- const {
- db,
- _
- } = require("../../utils/http");
- async function MediaService(data) {
- const list = [];
- const skip = (data.skip || 0) * (data.limit || 100);
- const orilist = await db.collection('AudioAndVideo').orderBy('_createTime', 'desc').where({
- type: _.eq(data.typeMedia),
- activity_name: _.eq(data.activityName)
- }).skip(skip).limit(data.limit || 100).get();
- const keysOir = {};
- for (let i = 0; i < orilist.data.length; i++) {
- const v = orilist.data[i];
- if (keysOir[v.localtion] !== undefined) {
- // 已经存在
- list[keysOir[v.localtion]].child.push({
- url: v.url,
- title: v.title,
- cover: v.cover,
- id: v._id,
- type: v.type
- })
- } else {
- // push
- keysOir[v.localtion] = list.length;
- list.push({
- location: v.localtion,
- date: v._updateTime,
- id: v._id,
- child: [{
- url: v.url,
- title: v.title,
- cover: v.cover,
- id: v._id,
- type: v.type
- }]
- })
- }
- }
- return list
- }
- async function MediaOnceService(data) {
- const list = [];
- const orilist = await db.collection('AudioAndVideo').where({
- type: _.eq(data.typeMedia),
- localtion: _.eq(data.group),
- activity_name: _.eq(data.activityName)
- }).get();
- const keysOir = {};
- for (let i = 0; i < orilist.data.length; i++) {
- const v = orilist.data[i];
- if (keysOir[v.localtion] !== undefined) {
- // 已经存在
- list[keysOir[v.localtion]].child.push({
- url: v.url,
- title: v.title,
- cover: v.cover,
- id: v._id,
- type: v.type
- })
- } else {
- // push
- keysOir[v.localtion] = list.length;
- list.push({
- location: v.localtion,
- date: v._updateTime,
- id: v._id,
- child: [{
- url: v.url,
- title: v.title,
- cover: v.cover,
- id: v._id,
- type: v.type
- }]
- })
- }
- }
- return list
- }
- module.exports = {
- MediaService,
- MediaOnceService
- }
|