Commit af6a18e5 by 汤文兵

node_modules

parent 5e5538e2
...@@ -90,7 +90,6 @@ class WXSDK{ ...@@ -90,7 +90,6 @@ class WXSDK{
r(JSON.parse(data)); r(JSON.parse(data));
}) })
.on('error', (error) => { .on('error', (error) => {
console.log(error)
j(error); j(error);
}); });
}); });
......
...@@ -32,19 +32,8 @@ class DeviceController extends ControllerBase{ ...@@ -32,19 +32,8 @@ class DeviceController extends ControllerBase{
* @param {number} number - 每页条数 默认10 * @param {number} number - 每页条数 默认10
*/ */
async getListAction(data){ async getListAction(data){
let product=this.getConfig(); data.params.user_id=data.user.uid;//获取userid
let params=data.params; let res = await this.dao.get('device').findList(data.params);
params.user_id=data.user.uid;//获取userid
if (params.product_id){
if(typeof params.product_id=='object') {
for (let i = 0; i < params.product_id.length; i++) {
params.product_id[i]=product[params.product_id[i]];
}
}else{
params.product_id=product[params.product_id]
}
}
let res = await this.dao.get('device').findList(params);
return res; return res;
} }
...@@ -260,7 +249,6 @@ class DeviceController extends ControllerBase{ ...@@ -260,7 +249,6 @@ class DeviceController extends ControllerBase{
} }
this.error("fail to update",30500); this.error("fail to update",30500);
} }
@NoAuth @NoAuth
async getVersionAction(data){ async getVersionAction(data){
switch(data.params.type){ switch(data.params.type){
...@@ -271,36 +259,5 @@ class DeviceController extends ControllerBase{ ...@@ -271,36 +259,5 @@ class DeviceController extends ControllerBase{
} }
this.error('type is undefined',30010) this.error('type is undefined',30010)
} }
@NoAuth
async setVersionAction(data){
let params={};
switch(data.params.type){
case 'ios':
params={
key:this.getConfig().wxAppId,
'value.ios':{
version:data.params.version,
url:data.params.url
}
}
break;
case 'android':
params={
key:this.getConfig().wxAppId,
'value.android':{
version:data.params.version,
url:data.params.url
}
}
break;
}
if (!params.key) {
this.error('type is undefined',30010)
}
let res = await this.public.core.setVersion(params);
return res;
}
} }
module.exports = DeviceController; module.exports = DeviceController;
\ No newline at end of file
/** /**
* DeviceDao.js * DeviceDao.js
* Version: 0.1 * Version: 0.1
* User: zym * User: zym
...@@ -603,23 +603,6 @@ class DeviceDao extends DaoBase { ...@@ -603,23 +603,6 @@ class DeviceDao extends DaoBase {
} }
return res.role return res.role
} }
//查找用户与设备直接是否有关系
async findStatusByDeviceIdAndUserId(data) {
this.checkKeyExists(data, "user_id","device_id")
let res = await this.models.mysql.user_device.findAll({
attributes: ['id'],
raw: true,
where: {
status:1,
user_id: data.user_id,
device_id: data.device_id
}
});
if (res.length>0) {
return true;
}
return false;
}
//根据user_id获取info字段 //根据user_id获取info字段
async findUserInfo(data) { async findUserInfo(data) {
this.checkKeyExists(data, "user_id", "Key") this.checkKeyExists(data, "user_id", "Key")
...@@ -947,7 +930,7 @@ class DeviceDao extends DaoBase { ...@@ -947,7 +930,7 @@ class DeviceDao extends DaoBase {
as: 'device', as: 'device',
attributes: [], attributes: [],
where: { where: {
device_id:data.mac mac:data.mac
} }
},{ },{
model: this.models.mysql.user, model: this.models.mysql.user,
......
...@@ -43,7 +43,17 @@ class Device extends MysqlBase { ...@@ -43,7 +43,17 @@ class Device extends MysqlBase {
device.info = JSON.parse(device.info) device.info = JSON.parse(device.info)
} }
}, },
freezeTableName: true indexes:[
{
unique: false,
fields: ['product_id']
},
{
unique: false,
fields: ['mac']
}
],
freezeTableName: true,
}); });
return model; return model;
} }
......
...@@ -39,13 +39,6 @@ class Public extends PublicFunBase{ ...@@ -39,13 +39,6 @@ class Public extends PublicFunBase{
checkRole(role,...action){ checkRole(role,...action){
return this.role.checkRole(role,action); return this.role.checkRole(role,action);
} }
checkStatus(user,...device){
let params={
user_id:user,
device_id:device
}
return this.dao.get('device').findStatusByDeviceIdAndUserId(params);
}
async sendModel(data){ async sendModel(data){
ServiceManager.execute("wxpush","push_wx", {appid:this.getConfig().wxAppId,msg:data.data}); ServiceManager.execute("wxpush","push_wx", {appid:this.getConfig().wxAppId,msg:data.data});
...@@ -128,28 +121,24 @@ class Public extends PublicFunBase{ ...@@ -128,28 +121,24 @@ class Public extends PublicFunBase{
} }
//单独绑定一个设备 //单独绑定一个设备
async bindDevice(data,condition){ async bindDevice(data,condition){
console.log("product_id"+data.product_id); if (!data.device_id&&!data.mac && !data.product_id) {
if (!data.device_id&&!data.mac) { this.error('缺少参数(device_id、mac、product_id)',30805)
this.error('没有设备mac或id',30805)
} }
let tip=this.getConfig(); let tip=this.getConfig();
console.log(tip); let product_id = tip[data.product_id]?tip[data.product_id]:data.product_id;
console.log(tip[data.product_id]);
let auth; let auth;
if (condition) { if (condition) {
auth = await ServiceManager.execute("devices","deviceAuth", {'mac':data.mac?data.mac:data.device_id,'product_id':tip[data.product_id]}); auth = await this.checkOrCreateDeviceAuth({'mac':data.mac?data.mac:data.device_id,'product_id':product_id});
}else{ }else{
auth = await ServiceManager.execute("devices","cloudDeviceAuth", {'mac':data.mac?data.mac:data.device_id,'product_id':tip[data.product_id]}); auth = await ServiceManager.execute("devices","cloudDeviceAuth", {'mac':data.mac?data.mac:data.device_id,'product_id':product_id});
} }
console.log("res")
console.log(auth)
if (!auth) { if (!auth) {
this.error('没有权限注册设备',30806); this.error('没有权限注册设备',30806);
} }
let res = await this.dao.get('device').findDevice(data);//查询绑定设备是否存在 let res = await this.dao.get('device').findDevice(data);//查询绑定设备是否存在
let device_date={ let device_date={
device_id:data.device_id?data.device_id:data.mac, device_id:data.device_id?data.device_id:data.mac,
product_id:tip[data.product_id], product_id:product_id,
mac:data.mac?data.mac:data.device_id, mac:data.mac?data.mac:data.device_id,
device_name: data.nickname?data.nickname:"我的设备", device_name: data.nickname?data.nickname:"我的设备",
parent_id: 0, parent_id: 0,
...@@ -365,7 +354,7 @@ class Public extends PublicFunBase{ ...@@ -365,7 +354,7 @@ class Public extends PublicFunBase{
//注册设备 //注册设备
async regDevice(data){ async regDevice(data){
let tip=this.getConfig(); let tip=this.getConfig();
data.product_id=tip[data.product_id]; data.product_id = tip[data.product_id]?tip[data.product_id]:data.product_id;
return await this.dao.get('device').createDevice(data); return await this.dao.get('device').createDevice(data);
} }
//设置权限 //设置权限
...@@ -492,16 +481,5 @@ class Public extends PublicFunBase{ ...@@ -492,16 +481,5 @@ class Public extends PublicFunBase{
newUser.utoken = data.auth.sign(Calculation.signParams(newUser.id)); newUser.utoken = data.auth.sign(Calculation.signParams(newUser.id));
return newUser; return newUser;
} }
async findDeviceUser(data){
let params=data;
params.status=1;
let res={};
res.count = await this.dao.get('device').countDeviceUser(params);
console.log(params)
res.info = await this.dao.get('device').findDeviceUserByMac(params);
return res;
}
} }
module.exports = Public; module.exports = Public;
\ No newline at end of file
...@@ -125,7 +125,7 @@ class DataPublicDao extends DaoBase{ ...@@ -125,7 +125,7 @@ class DataPublicDao extends DaoBase{
// get._id = {$gt:data.start_id}; // get._id = {$gt:data.start_id};
// get.action = data.action; // get.action = data.action;
console.log(HistoryProgram)
//变量接收getHistoryList //变量接收getHistoryList
let getHistoryList = await this.models.mongo.data_history.find(HistoryProgram).limit(parseInt(data.page_size)).sort({create_time:data.order}); let getHistoryList = await this.models.mongo.data_history.find(HistoryProgram).limit(parseInt(data.page_size)).sort({create_time:data.order});
//返回getHistoryList //返回getHistoryList
...@@ -181,9 +181,6 @@ class DataPublicDao extends DaoBase{ ...@@ -181,9 +181,6 @@ class DataPublicDao extends DaoBase{
} }
async getHistoryByAggregaate(data){ async getHistoryByAggregaate(data){
if(data[0].$match._id){
data[0].$match._id = {$lt:mongoose.Types.ObjectId(data[0].$match._id)};
}
let getHistoryList = await this.models.mongo.data_history.aggregate(data); let getHistoryList = await this.models.mongo.data_history.aggregate(data);
//返回getHistoryList //返回getHistoryList
return getHistoryList; return getHistoryList;
......
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