在设计一个典型的手环/手表应用时,要做简单的固件管理,添加固件,查询固件。如何用fobj服务直接完成呢
添加固件
| 字段名 |
字段说明 |
字段举例 |
| url |
文件路径 |
可以是任何公网路径 |
| size |
文件大小 |
由添加的人自愿填写 |
| idx1 |
第一索引 |
存放固件的整形版本号 |
| idx2 |
第二索引 |
存放固件的子串版本号 |
| idx3 |
第三索引 |
存放固件的发布状态 |
| idx4 |
第四索引 |
存放固件的发布时间 |
| cato |
常数子串 |
firmware |
| name |
文件名 |
字符串 |
add_params = {
url:"http://file.xdua.com/fobj/HealthRingFirmware/E6-ap-FW6.6.31-HW4.5.15-190528.zip",
size:47932345,
idx1:160631,
idx2:"6.6.31",
idx3:1,
idx4:201906191232,
param:{"version":"6.6.31","versioncode":160632,"creator":"wellink@shenzhen","ptime":201906191232},
name:"手表固件6.6.31版本",
note:"微尔联智能手表,专为健康打造。",
cato:"firmware"
}
const dua = await lovearth({
APP_KEY: "EIxcPdpT",
APP_SECRET: "b8466f37b99bea6496b192be399cfbd2",
})
const res_login = await dua.login({
by : "tel",
ustr: '+86-15810419011',
pwd : 'a906449d5769fa7361d7ecc6aa3f6d28',
ugrp: "XdUaXduA",
role: "none"
})
console.log(res_login);
api_name = "添加对象";
res = await dua.addFobj(add_params)
console.log(res);
if(res.error == 0){
console.log(api_name+"成功");
}else{
console.log(api_name+"失败 "+res.reason);
}
查询固件
| 字段名 |
字段说明 |
字段举例 |
| mail |
用户电话 |
example@email.com |
async function test_qryFobj(obj_filter) {
const dua = await lovearth({
APP_KEY: "EIxcPdpT",
APP_SECRET: "b8466f37b99bea6496b192be399cfbd2",
})
api_name = "查询对象";
res = await dua.qryFobj(obj_filter)
console.log(res);
console.log(JSON.stringify(res));
if(res.error == 0){
console.log(api_name+"成功");
}else{
console.log(api_name+"失败 "+res.reason);
}
}
test_qryFobj({filter:{cato:"firmware"},order:"idx1:DESC",limit:1})