12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- const {
- db,
- _
- } = require("../../utils/http");
- async function MediaService(data) {
- const list = [];
- const orilist = await db.collection('AudioAndVideo').where({
- type: _.eq(data.typeMedia)
- }).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.uptime,
- 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)
- }).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
- })
- } else {
- // push
- keysOir[v.localtion] = list.length;
- list.push({
- location: v.localtion,
- date: v.uptime,
- id: v._id,
- child: [{
- url: v.url,
- title: v.title,
- cover: v.cover,
- id: v._id
- }]
- })
- }
- }
- return list
- }
- module.exports = {
- MediaService,
- MediaOnceService
- }
|