Commit d6c9aaa6 authored by 李超鹏's avatar 李超鹏

增加查询接口

parent 00d24079
'use strict';
exports.main = async (event, context) => {
const field_name = event.field
const param = {
"classify_id": event.classify_id,
"system_id": event.system_id,
......@@ -11,7 +9,6 @@ exports.main = async (event, context) => {
let res = await db.collection("standardV2").aggregate().match(param).group({
_id: "$" + event.field
}).end();
res = await db.collection('dictionary').field({
"_id": true,
"name": true
......
'use strict';
exports.main = async (event, context) => {
//event为客户端上传的参数
const db = uniCloud.database()
let res = await db.collection("standardV2").field({"classify_id": true, "system_id": true, "brand_id": true}).get();
let data = {}
let id = []
res.data.map(item => {
id.push(item.classify_id)
id.push(item.system_id)
id.push(item.brand_id)
if (data[item.classify_id]) {
if (data[item.classify_id][item.system_id]) {
if (data[item.classify_id][item.system_id].indexOf(item.brand_id) < 0)
data[item.classify_id][item.system_id].push(item.brand_id)
} else {
data[item.classify_id][item.system_id] = [item.brand_id]
}
} else {
let obj = {}
obj[item.system_id] = [item.brand_id]
data[item.classify_id] = obj
}
})
let dic = await db.collection("dictionary").where({
_id: db.command.in(id)
}).get()
let dic_data = {}
dic.data.map(item => {
dic_data[item._id] = item.name
})
let result = []
for (let first in data) {
let secondArr = []
for (let second in data[first]) {
let thirdArr = []
data[first][second].map(third => {
thirdArr.push({id: third, name: dic_data[third]})
})
secondArr.push({id: second, name: dic_data[second], child: thirdArr})
}
result.push({id: first, name: dic_data[first], child: secondArr})
}
return result;
};
......@@ -77,7 +77,8 @@
"classify_id": "79550af260555cc20afb34146966a2c4",
"system_id": "79550af260555cc20afb34156c94b32c",
"brand_id": "79550af260555cc20afb3417731a827c",
"describe": "已经报装新能源专用电表,不用签此放弃声明,且不用上传",
"main_point": ["图片清晰","图片正对"],
"note":"已经报装新能源专用电表,不用签此放弃声明,且不用上传",
"image_count": "1",
"images": "https://cloud-bak.banshouhui.com/FkxetdqtVgCN_Xz53w6KqQsEC3K-",
"name": "不需要报装声明(不需要报装必填)",
......@@ -88,7 +89,8 @@
"classify_id": "79550af260555cc20afb34146966a2c4",
"system_id": "79550af260555cc20afb34156c94b32c",
"brand_id": "79550af260555cc20afb341875d0f7ba",
"describe": "已经报装新能源专用电表,不用签此放弃声明,且不用上传",
"main_point": [],
"note":"已经报装新能源专用电表,不用签此放弃声明,且不用上传",
"image_count": "1",
"images": "https://cloud-bak.banshouhui.com/FkxetdqtVgCN_Xz53w6KqQsEC3K-",
"name": "不需要报装声明(不需要报装必填)",
......@@ -133,7 +135,11 @@
"bsonType": "string",
"description": "名称"
},
"describe": {
"main_point":{
"bsonType": "array",
"description": "描述、要求"
},
"note": {
"bsonType": "string",
"description": "描述、要求"
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment